update:文件不符合规范不会加入到列表中

This commit is contained in:
2021-06-08 10:10:41 +08:00
parent fe95499fbf
commit 3650bea744

View File

@@ -119,7 +119,9 @@
accept="application/pdf" accept="application/pdf"
action="/api2/upload/uploadfile" action="/api2/upload/uploadfile"
v-model:fileList="loaPicFileList" v-model:fileList="loaPicFileList"
:beforeUpload="file => beforeUpload(file, true)" :beforeUpload="
(file, fileList) => beforeUpload(file, fileList, true)
"
@change="info => handleChange(info, 'loaPicId')" @change="info => handleChange(info, 'loaPicId')"
:disabled="disabledUpload" :disabled="disabledUpload"
> >
@@ -255,7 +257,11 @@
</a-col> </a-col>
</a-row> </a-row>
<a-form-item :wrapper-col="{ span: 12, offset: 10 }"> <a-form-item :wrapper-col="{ span: 12, offset: 10 }">
<a-button v-if="progressingId" type="primary" @click="onSubmit" <a-button
v-if="progressingId"
type="primary"
@click="onSubmit"
:loading="loading"
>查询</a-button >查询</a-button
> >
<a-button v-else type="primary" @click="onSubmit">提交</a-button> <a-button v-else type="primary" @click="onSubmit">提交</a-button>
@@ -530,8 +536,10 @@ export default {
1; 1;
} }
}; };
const loading = ref(false);
const onSubmit = async e => { const onSubmit = async e => {
e.preventDefault(); e.preventDefault();
loading.value = true;
if (progressingId.value == 0) { if (progressingId.value == 0) {
if (modelRef.orderNo) { if (modelRef.orderNo) {
await modifyUnitApply(); await modifyUnitApply();
@@ -548,21 +556,26 @@ export default {
await queryUnitApply(progressingId.value); await queryUnitApply(progressingId.value);
} }
} }
loading.value = false;
}; };
const beforeUpload = (file, isPdf) => { const beforeUpload = (file, fileList, isPdf) => {
console.log(file, isPdf); console.log(file, fileList, isPdf);
const isValid = const isValid =
isPdf === true isPdf === true
? file.type === "application/pdf" ? file.type === "application/pdf"
: file.type === "image/jpeg" || file.type === "image/png"; : file.type === "image/jpeg" || file.type === "image/png";
if (!isValid) { if (!isValid) {
message.error("只能上传受支持格式的文件"); message.error("只能上传受支持格式的文件");
fileList.pop();
return false;
} }
const isLt2M = file.size / 1024 / 1024 < 2; const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) { if (!isLt2M) {
message.error("文件大小超过2MB!"); message.error("文件大小超过2MB!");
fileList.pop();
return false;
} }
return isValid && isLt2M; return true;
}; };
const handleChange2 = (info, v) => { const handleChange2 = (info, v) => {
console.log(info.file.status, info.file, info.fileList); console.log(info.file.status, info.file, info.fileList);
@@ -784,6 +797,7 @@ export default {
router: useRouter(), router: useRouter(),
progressingId, progressingId,
addSealApply, addSealApply,
loading,
status: { status: {
0: { 0: {
color: "orange", color: "orange",