mirror of https://github.com/ElemeFE/element
add disabled feature
parent
5abce7d800
commit
b1d74460d9
|
@ -365,6 +365,7 @@ file-list | default uploaded files, i.e: [{name: 'food.jpeg', url: 'https://fuss
|
||||||
list-type | type of fileList | string | text/picture/picture-card | text |
|
list-type | type of fileList | string | text/picture/picture-card | text |
|
||||||
auto-upload | whether to auto upload file | boolean | — | true |
|
auto-upload | whether to auto upload file | boolean | — | true |
|
||||||
http-request | override default xhr behavior, allowing you to implement your own upload-file's request | function | — | — |
|
http-request | override default xhr behavior, allowing you to implement your own upload-file's request | function | — | — |
|
||||||
|
disabled | whether to disable upload | boolean | — | false |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
| Event Name | Description | Parameters |
|
| Event Name | Description | Parameters |
|
||||||
|
|
|
@ -414,6 +414,7 @@
|
||||||
| auto-upload | 是否在选取文件后立即进行上传 | boolean | — | true |
|
| auto-upload | 是否在选取文件后立即进行上传 | boolean | — | true |
|
||||||
| file-list | 上传的文件列表, 例如: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}] | array | — | [] |
|
| file-list | 上传的文件列表, 例如: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}] | array | — | [] |
|
||||||
| http-request | 覆盖默认的上传行为,可以自定义上传的实现 | function | — | — |
|
| http-request | 覆盖默认的上传行为,可以自定义上传的实现 | function | — | — |
|
||||||
|
| disabled | 是否禁用 | boolean | — | false |
|
||||||
|
|
||||||
### Methods
|
### Methods
|
||||||
| 方法名 | 说明 | 参数 |
|
| 方法名 | 说明 | 参数 |
|
||||||
|
|
|
@ -32,7 +32,8 @@ export default {
|
||||||
default: function() {}
|
default: function() {}
|
||||||
},
|
},
|
||||||
drag: Boolean,
|
drag: Boolean,
|
||||||
listType: String
|
listType: String,
|
||||||
|
disabled: Boolean
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -40,7 +41,7 @@ export default {
|
||||||
mouseover: false,
|
mouseover: false,
|
||||||
domain: '',
|
domain: '',
|
||||||
file: null,
|
file: null,
|
||||||
disabled: false
|
submitting: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,7 +50,9 @@ export default {
|
||||||
return str.indexOf('image') !== -1;
|
return str.indexOf('image') !== -1;
|
||||||
},
|
},
|
||||||
handleClick() {
|
handleClick() {
|
||||||
|
if (!this.disabled) {
|
||||||
this.$refs.input.click();
|
this.$refs.input.click();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleChange(ev) {
|
handleChange(ev) {
|
||||||
const file = ev.target.value;
|
const file = ev.target.value;
|
||||||
|
@ -58,8 +61,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
uploadFiles(file) {
|
uploadFiles(file) {
|
||||||
if (this.disabled) return;
|
if (this.submitting) return;
|
||||||
this.disabled = true;
|
this.submitting = true;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.onStart(file);
|
this.onStart(file);
|
||||||
|
|
||||||
|
@ -103,7 +106,7 @@ export default {
|
||||||
} else if (response.result === 'failed') {
|
} else if (response.result === 'failed') {
|
||||||
self.onError(response, self.file);
|
self.onError(response, self.file);
|
||||||
}
|
}
|
||||||
self.disabled = false;
|
self.submitting = false;
|
||||||
self.file = null;
|
self.file = null;
|
||||||
}, false);
|
}, false);
|
||||||
},
|
},
|
||||||
|
@ -113,7 +116,8 @@ export default {
|
||||||
drag,
|
drag,
|
||||||
uploadFiles,
|
uploadFiles,
|
||||||
listType,
|
listType,
|
||||||
frameName
|
frameName,
|
||||||
|
disabled
|
||||||
} = this;
|
} = this;
|
||||||
const oClass = { 'el-upload': true };
|
const oClass = { 'el-upload': true };
|
||||||
oClass[`el-upload--${listType}`] = true;
|
oClass[`el-upload--${listType}`] = true;
|
||||||
|
@ -146,7 +150,7 @@ export default {
|
||||||
</form>
|
</form>
|
||||||
{
|
{
|
||||||
drag
|
drag
|
||||||
? <upload-dragger on-file={uploadFiles}>{this.$slots.default}</upload-dragger>
|
? <upload-dragger on-file={uploadFiles} disabled={disabled}>{this.$slots.default}</upload-dragger>
|
||||||
: this.$slots.default
|
: this.$slots.default
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -86,7 +86,8 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'text' // text,picture,picture-card
|
default: 'text' // text,picture,picture-card
|
||||||
},
|
},
|
||||||
httpRequest: Function
|
httpRequest: Function,
|
||||||
|
disabled: Boolean
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -227,6 +228,7 @@ export default {
|
||||||
fileList: this.uploadFiles,
|
fileList: this.uploadFiles,
|
||||||
autoUpload: this.autoUpload,
|
autoUpload: this.autoUpload,
|
||||||
listType: this.listType,
|
listType: this.listType,
|
||||||
|
disabled: this.disabled,
|
||||||
'on-start': this.handleStart,
|
'on-start': this.handleStart,
|
||||||
'on-progress': this.handleProgress,
|
'on-progress': this.handleProgress,
|
||||||
'on-success': this.handleSuccess,
|
'on-success': this.handleSuccess,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
'is-dragover': dragover
|
'is-dragover': dragover
|
||||||
}"
|
}"
|
||||||
@drop.prevent="onDrop"
|
@drop.prevent="onDrop"
|
||||||
@dragover.prevent="dragover = true"
|
@dragover.prevent="onDragover"
|
||||||
@dragleave.prevent="dragover = false"
|
@dragleave.prevent="dragover = false"
|
||||||
>
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
@ -14,18 +14,27 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'ElUploadDrag',
|
name: 'ElUploadDrag',
|
||||||
|
props: {
|
||||||
|
disabled: Boolean
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dragover: false
|
dragover: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onDragover() {
|
||||||
|
if (!this.disabled) {
|
||||||
|
this.dragover = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
onDrop(e) {
|
onDrop(e) {
|
||||||
|
if (!this.disabled) {
|
||||||
this.dragover = false;
|
this.dragover = false;
|
||||||
this.$emit('file', e.dataTransfer.files);
|
this.$emit('file', e.dataTransfer.files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ export default {
|
||||||
httpRequest: {
|
httpRequest: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: ajax
|
default: ajax
|
||||||
}
|
},
|
||||||
|
disabled: Boolean
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -117,8 +118,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleClick() {
|
handleClick() {
|
||||||
|
if (!this.disabled) {
|
||||||
this.$refs.input.click();
|
this.$refs.input.click();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render(h) {
|
render(h) {
|
||||||
|
@ -130,7 +133,8 @@ export default {
|
||||||
multiple,
|
multiple,
|
||||||
accept,
|
accept,
|
||||||
listType,
|
listType,
|
||||||
uploadFiles
|
uploadFiles,
|
||||||
|
disabled
|
||||||
} = this;
|
} = this;
|
||||||
const data = {
|
const data = {
|
||||||
class: {
|
class: {
|
||||||
|
@ -145,7 +149,7 @@ export default {
|
||||||
<div {...data}>
|
<div {...data}>
|
||||||
{
|
{
|
||||||
drag
|
drag
|
||||||
? <upload-dragger on-file={uploadFiles}>{this.$slots.default}</upload-dragger>
|
? <upload-dragger disabled={disabled} on-file={uploadFiles}>{this.$slots.default}</upload-dragger>
|
||||||
: this.$slots.default
|
: this.$slots.default
|
||||||
}
|
}
|
||||||
<input class="el-upload__input" type="file" ref="input" name={name} on-change={handleChange} multiple={multiple} accept={accept}></input>
|
<input class="el-upload__input" type="file" ref="input" name={name} on-change={handleChange} multiple={multiple} accept={accept}></input>
|
||||||
|
|
Loading…
Reference in New Issue