Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -182,7 +182,7 @@
|
||||
accept=".zip,.7z"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
:on-change="uploadVoucher"
|
||||
:on-change="selectVoucherFile"
|
||||
:on-remove="clearFile"
|
||||
><el-button
|
||||
type="primary"
|
||||
@@ -429,7 +429,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: '',
|
||||
@@ -503,6 +504,7 @@ const changeProject = projectId => {
|
||||
};
|
||||
const openUpload = async row => {
|
||||
await loadProjects();
|
||||
selectedVoucherFile.value = undefined;
|
||||
Object.assign(editing, {
|
||||
id: row?.id || '',
|
||||
voucherBatchNo: row?.voucherBatchNo || '',
|
||||
@@ -524,7 +526,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 => {
|
||||
@@ -547,11 +552,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;
|
||||
@@ -637,6 +642,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,
|
||||
@@ -730,14 +736,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;
|
||||
@@ -777,21 +792,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;
|
||||
|
||||
Reference in New Issue
Block a user