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

@ -251,7 +251,9 @@
:width="'min(1000px, 95vw)'"
top="4vh"
destroy-on-close
:close-on-click-modal="false"
:close-on-click-modal="!isUploading"
:close-on-press-escape="!isUploading"
:show-close="!isUploading"
class="stylish-dialog compact-layout"
>
<div class="dialog-scroll-container">
@ -618,8 +620,8 @@
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="visible = false" size="large">取消</el-button>
<el-button type="primary" :loading="submitting" @click="submitForm" size="large" class="confirm-btn">{{ dialogStatus === 'create' ? '确认入库并打印' : '保存修改' }}</el-button>
<el-button @click="visible = false" size="large" :disabled="isUploading">取消</el-button>
<el-button type="primary" :loading="submitting || isUploading" @click="submitForm" size="large" class="confirm-btn">{{ dialogStatus === 'create' ? '确认入库并打印' : '保存修改' }}</el-button>
</div>
</template>
</el-dialog>
@ -782,6 +784,9 @@ const tableData = ref([])
const total = ref(0)
const formRef = ref()
// 上传锁定状态
const isUploading = ref(false)
const categoryOptions = ref<string[]>([])
const typeOptions = ref<string[]>([])
const companyOptions = ref<string[]>([])
@ -1423,6 +1428,7 @@ const customUpload = async (options: any, targetField: 'arrival_photo' | 'inspec
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) {
@ -1448,6 +1454,8 @@ const customUpload = async (options: any, targetField: 'arrival_photo' | 'inspec
} catch (e) {
ElMessage.error('网络错误')
onError(e)
} finally {
isUploading.value = false
}
}