Merge branch '0.8.X' of https://gitee.com/hdka/klp-oa into 0.8.X
This commit is contained in:
@@ -48,6 +48,11 @@ export default {
|
||||
props: {
|
||||
// 值
|
||||
value: [String, Object, Array],
|
||||
// 额外的自定义校验函数,返回 false 阻止上传
|
||||
beforeValidate: {
|
||||
type: Function,
|
||||
default: null,
|
||||
},
|
||||
// 数量限制
|
||||
limit: {
|
||||
type: Number,
|
||||
@@ -127,6 +132,15 @@ export default {
|
||||
methods: {
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload(file) {
|
||||
// 额外自定义校验
|
||||
if (this.beforeValidate) {
|
||||
const pass = this.beforeValidate(file);
|
||||
if (pass === false) {
|
||||
// 防止残留文件
|
||||
this.resetUpload();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 校检文件类型
|
||||
if (this.fileType) {
|
||||
const fileName = file.name.split('.');
|
||||
@@ -189,6 +203,17 @@ export default {
|
||||
this.$modal.closeLoading();
|
||||
}
|
||||
},
|
||||
// 重置上传状态(外部可调用)
|
||||
resetUpload() {
|
||||
this.number = 0;
|
||||
this.uploadList = [];
|
||||
this.fileList = [];
|
||||
this.$emit("input", "");
|
||||
if (this.$refs.fileUpload) {
|
||||
this.$refs.fileUpload.clearFiles();
|
||||
}
|
||||
this.$modal.closeLoading();
|
||||
},
|
||||
// 获取文件名称
|
||||
getFileName(name) {
|
||||
// 如果是url那么取最后的名字 如果不是直接返回
|
||||
|
||||
Reference in New Issue
Block a user