feat: lock dialog and disable close actions during image upload to prevent orphan files and state errors

This commit is contained in:
DXC
2026-03-13 09:23:35 +08:00
parent 96122ed671
commit 9b290506da
4 changed files with 42 additions and 11 deletions

View File

@ -323,6 +323,9 @@
width="700px"
append-to-body
@close="cancel"
:close-on-click-modal="!isUploading"
:close-on-press-escape="!isUploading"
:show-close="!isUploading"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
@ -477,8 +480,8 @@
<template #footer>
<div class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
<el-button @click="cancel" :disabled="isUploading">取 消</el-button>
<el-button type="primary" @click="submitForm" :loading="submitLoading || isUploading">确 定</el-button>
</div>
</template>
</el-dialog>
@ -596,6 +599,10 @@ const total = ref(0);
const tableData = ref<MaterialBaseVO[]>([]);
const tableRef = ref<InstanceType<typeof ElTable>>();
const submitLoading = ref(false);
// 上传锁定状态
const isUploading = ref(false);
const tableSize = ref<'large' | 'default' | 'small'>('large');
const advancedFilterVisible = ref(false);
const advancedConditions = ref([{ field: '', operator: '', value: '' }]);
@ -1278,6 +1285,7 @@ const customUpload = async (options: any, targetField: 'generalImage' | 'general
const { file, onSuccess, onError } = options
const formData = new FormData()
formData.append('file', file)
isUploading.value = true
try {
const res: any = await uploadFile(formData)
if (res.code === 200) {
@ -1293,6 +1301,7 @@ const customUpload = async (options: any, targetField: 'generalImage' | 'general
ElMessage.error('网络错误');
onError(e)
}
finally { isUploading.value = false }
}
const handleRemoveImage = async (uploadFile: any, targetField: 'generalImage' | 'generalManual') => {