Skip to content

Commit a7abc70

Browse files
committed
优化 cl-upload 参数配置
1 parent aa14bbb commit a7abc70

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/cool/modules/upload/components/index.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
:on-preview="_onPreview"
3535
:on-progress="onProgress"
3636
:on-change="onChange"
37-
:on-exceed="onExceed"
37+
:on-exceed="_onExceed"
3838
:before-upload="_beforeUpload"
3939
:before-remove="beforeRemove"
4040
:style="_style"
@@ -110,7 +110,7 @@
110110
<script>
111111
import { mapGetters } from "vuex";
112112
import path from "path";
113-
import { cloneDeep, last, isArray, isNumber, isBoolean } from "cl-admin/utils";
113+
import { cloneDeep, last, isArray, isNumber, isBoolean, isEmpty } from "cl-admin/utils";
114114
import { v4 as uuidv4 } from "uuid";
115115
116116
export default {
@@ -222,7 +222,7 @@ export default {
222222
},
223223
224224
_text() {
225-
return this.text || this.conf.text || "选择文件";
225+
return isEmpty(this.text) ? this.conf.text : this.text;
226226
},
227227
228228
_accept() {
@@ -407,6 +407,15 @@ export default {
407407
}
408408
},
409409
410+
// 超出个数限制提示
411+
_onExceed(file, fileList) {
412+
if (this.onExceed) {
413+
this.onExceed(file, fileList);
414+
} else {
415+
this.$message.warning(`当前限制选择 ${this.limit} 个文件`);
416+
}
417+
},
418+
410419
// 上传前
411420
_beforeUpload(file) {
412421
this.loading = true;
@@ -505,9 +514,7 @@ export default {
505514
} else {
506515
this.$service.common
507516
.upload()
508-
.then(res => {
509-
next(res);
510-
})
517+
.then(next)
511518
.catch(reject);
512519
}
513520
});

0 commit comments

Comments
 (0)