mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 03:46:45 +08:00
feat:增加文件上传数量判断
This commit is contained in:
@@ -150,12 +150,13 @@
|
||||
</div>
|
||||
<div class="filebox">
|
||||
<div>
|
||||
<img class="fileimg" src="../../assets/images/projectadd/enclosure.png" />
|
||||
<a-upload v-model:file-list="fileList1" name="file" action="/api/file/upload" :headers="headers"
|
||||
@change="handleChange1">
|
||||
<img v-if="fileList1.length < 6" class="fileimg" src="../../assets/images/projectadd/enclosure.png" />
|
||||
<a-upload :disabled="fileList1.length > 5" :before-upload="beforeUpload1" v-model:file-list="fileList1"
|
||||
name="file" action="/api/file/upload" :headers="headers" @change="handleChange1">
|
||||
<!-- <a-button> -->
|
||||
<!-- <upload-outlined></upload-outlined> -->
|
||||
<span class="filetext">上传附件</span>
|
||||
<span v-if="fileList1.length > 5" class="filetext">上传数量已经达到最大值</span>
|
||||
<span v-else class="filetext">上传附件</span>
|
||||
<!-- </a-button> -->
|
||||
</a-upload>
|
||||
</div>
|
||||
@@ -243,14 +244,20 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
let uplodaFileCount = false;
|
||||
|
||||
const handleChange1 = (info) => {
|
||||
if (info.file.status === 'uploading') {
|
||||
loading.value = true;
|
||||
return;
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
console.log('上传附件返回的信息 %o', info)
|
||||
|
||||
console.log('上传附件返回的信息 %o', info, info.fileList.length, uplodaFileCount)
|
||||
if (info.fileList.length > 5) {
|
||||
uplodaFileCount = true;
|
||||
} else {
|
||||
uplodaFileCount = false;
|
||||
}
|
||||
}
|
||||
if (info.file.status === 'error') {
|
||||
loading.value = false;
|
||||
@@ -270,6 +277,16 @@ export default {
|
||||
return isJpgOrPng && isLt2M;
|
||||
};
|
||||
|
||||
const beforeUpload1 = () => {
|
||||
return new Promise((resovle, reject) => {
|
||||
if (uplodaFileCount) {
|
||||
message.info("上传文件数量已达最大数量")
|
||||
return reject(false);
|
||||
}
|
||||
return resovle(true);
|
||||
})
|
||||
};
|
||||
|
||||
const onRangeChange = (value, dateString) => {
|
||||
console.log('Selected Time: ', value);
|
||||
// 项目时间选择函数
|
||||
@@ -344,7 +361,7 @@ export default {
|
||||
console.log(obj[i])
|
||||
if (obj[i] === "") {
|
||||
message.destroy()
|
||||
message.info(errorMsgs[i])
|
||||
message.warning(errorMsgs[i])
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -368,11 +385,13 @@ export default {
|
||||
handleChange,
|
||||
handleChange1,
|
||||
beforeUpload,
|
||||
beforeUpload1,
|
||||
onRangeChange,
|
||||
classifyList1,
|
||||
remark,
|
||||
changeChecked,
|
||||
changeChecked1,
|
||||
uplodaFileCount,
|
||||
createProject
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user