修复业务模块bug

This commit is contained in:
2026-08-13 20:55:55 +08:00
parent b25b2fae20
commit 5c89140b21
5 changed files with 99 additions and 33 deletions
+30 -13
View File
@@ -181,7 +181,7 @@
accept=".zip,.7z"
:auto-upload="false"
:limit="1"
:on-change="uploadVoucher"
:on-change="selectVoucherFile"
:on-remove="clearFile"
><el-button
type="primary"
@@ -425,7 +425,8 @@ const loading = ref(false),
closingProgressDialog = ref(false),
cancelledTaskIds = ref(new Set()),
uploadCancelled = ref(false),
activeUploadTaskId = ref();
activeUploadTaskId = ref(),
selectedVoucherFile = ref();
const query = reactive({
voucherBatchNo: '',
auditStatus: '',
@@ -499,6 +500,7 @@ const changeProject = projectId => {
};
const openUpload = async row => {
await loadProjects();
selectedVoucherFile.value = undefined;
Object.assign(editing, {
id: row?.id || '',
voucherBatchNo: row?.voucherBatchNo || '',
@@ -520,7 +522,10 @@ const openUpload = async row => {
editing.waybillImportBatchIds = selectedBatches.value.map(item => item.id);
}
};
const clearFile = () => Object.assign(editing, { fileName: '', fileUrl: '', fileTaskId: '' });
const clearFile = () => {
selectedVoucherFile.value = undefined;
Object.assign(editing, { fileName: '', fileUrl: '', fileTaskId: '' });
};
const isCurrentUploadTask = taskId =>
taskId && activeUploadTaskId.value && String(taskId) === String(activeUploadTaskId.value);
const stopCurrentUpload = async taskId => {
@@ -543,11 +548,11 @@ const stopCurrentUpload = async taskId => {
ElMessage.error(error.message || '暂停上传失败');
}
};
const closeUploadDialog = async () => {
const closeUploadDialog = async (pauseUpload = true) => {
if (closingUploadDialog.value) return;
closingUploadDialog.value = true;
try {
await stopCurrentUpload(editing.fileTaskId);
if (pauseUpload) await stopCurrentUpload(editing.fileTaskId);
uploadVisible.value = false;
} finally {
closingUploadDialog.value = false;
@@ -633,6 +638,7 @@ const uploadParts = async (file, task, sessionId) => {
editing.fileName = file.name;
editing.fileTaskId = task.id;
editing.fileUrl = fileUrlRes.data?.data || '';
if (!editing.fileUrl) throw new Error('未获取到上传文件地址,请稍后重试');
await api.completeUploadFile({
voucherBatchNo: task.businessId,
fileTaskId: task.id,
@@ -726,14 +732,23 @@ const uploadVoucher = async file => {
cancelledTaskIds.value.delete(String(task.id));
resumeTarget.value = undefined;
await uploadParts(raw, task, sessionId);
return Boolean(editing.fileUrl);
} catch (error) {
if (error.name !== 'AbortError')
ElMessage.error(error.message || '上传中断,可在上传进度中继续上传');
return false;
}
};
const selectVoucherFile = file => {
if (!file?.raw) return;
selectedVoucherFile.value = file.raw;
editing.fileName = file.raw.name;
editing.fileUrl = '';
editing.fileTaskId = '';
};
watch(uploadVisible, visible => {
// 兜底处理:右上角、遮罩、Esc 直接修改 v-model 时仍必须停止上传。
if (!visible) void stopCurrentUpload(editing.fileTaskId);
if (!visible && !closingUploadDialog.value) void stopCurrentUpload(editing.fileTaskId);
});
const openBatchDialog = async () => {
batchVisible.value = true;
@@ -773,21 +788,23 @@ const removeBatch = row => {
const submitUpload = async () => {
saving.value = true;
try {
if (uploading.value && editing.fileTaskId) {
await stopCurrentUpload(editing.fileTaskId);
}
const valid = await uploadFormRef.value.validate().catch(() => false);
if (!valid) return;
if (!editing.fileUrl && !editing.fileTaskId) {
ElMessage.warning('请先选择执行凭证');
return;
if (!editing.fileUrl) {
if (!selectedVoucherFile.value) {
ElMessage.warning('请先选择执行凭证');
return;
}
const uploaded = await uploadVoucher({ raw: selectedVoucherFile.value });
if (!uploaded) return;
selectedVoucherFile.value = undefined;
}
await api.submit({
...editing,
waybillImportBatchIds: selectedBatches.value.map(item => item.id),
});
ElMessage.success('提交成功');
await closeUploadDialog();
await closeUploadDialog(false);
load();
} finally {
saving.value = false;