✨ 完善合同附件上传回填、类型匹配与列表附件弹窗
修复上传成功后表格不回显,附件类型可切换,未匹配文件名默认其他文件;列表附件上传支持合同文件/其它附件。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -592,7 +592,6 @@
|
||||
title="合同文件"
|
||||
description
|
||||
attachment-type
|
||||
use-upload-dialog
|
||||
:attachment-location-options="contractAttachmentLocationOptions"
|
||||
:lock-approved="isAttachmentUploadMode || hasApprovedContractFiles"
|
||||
:mark-approved-on-upload="isAttachmentUploadMode"
|
||||
@@ -813,7 +812,6 @@
|
||||
title="其它附件"
|
||||
description
|
||||
attachment-type
|
||||
use-upload-dialog
|
||||
attachment-location="其它附件"
|
||||
:attachment-location-options="contractAttachmentLocationOptions"
|
||||
:readonly="isAttachmentUploadMode"
|
||||
@@ -925,6 +923,21 @@
|
||||
@save="saveBillingPlan"
|
||||
/>
|
||||
|
||||
<contract-attachment-section
|
||||
ref="listAttachmentUploader"
|
||||
dialog-only
|
||||
title="合同文件"
|
||||
description
|
||||
attachment-type
|
||||
use-upload-dialog
|
||||
mark-approved-on-upload
|
||||
:attachment-location-options="['合同文件', '其它附件']"
|
||||
:rows="listUploadContractFileRows"
|
||||
@update:rows="listUploadContractFileRows = $event"
|
||||
@upload-to-location="handleListAttachmentUploadToLocation"
|
||||
@upload-confirmed="handleListAttachmentUploadConfirmed"
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
v-model="attachmentDocumentPreviewVisible"
|
||||
:title="attachmentPreviewFile.name || '附件预览'"
|
||||
@@ -1236,6 +1249,9 @@ export default {
|
||||
organizationLoading: false,
|
||||
contractFileRows: [],
|
||||
attachmentRows: [],
|
||||
listUploadContractFileRows: [],
|
||||
listUploadAttachmentRows: [],
|
||||
attachmentUploadFromList: false,
|
||||
attachmentImagePreviewVisible: false,
|
||||
attachmentImagePreviewUrls: [],
|
||||
attachmentImagePreviewIndex: 0,
|
||||
@@ -1899,20 +1915,86 @@ export default {
|
||||
return;
|
||||
}
|
||||
this.submitAction = 'attachment';
|
||||
this.api
|
||||
const contractFileRows = this.attachmentUploadFromList
|
||||
? this.listUploadContractFileRows
|
||||
: this.contractFileRows;
|
||||
const attachmentRows = this.attachmentUploadFromList
|
||||
? this.listUploadAttachmentRows
|
||||
: this.attachmentRows;
|
||||
return this.api
|
||||
.updateAttachments({
|
||||
id: this.form.id,
|
||||
contractFileJson: JSON.stringify(this.contractFileRows),
|
||||
attachmentsJson: JSON.stringify(this.attachmentRows),
|
||||
contractFileJson: JSON.stringify(contractFileRows),
|
||||
attachmentsJson: JSON.stringify(attachmentRows),
|
||||
})
|
||||
.then(() => {
|
||||
this.$message.success('附件保存成功');
|
||||
if (this.attachmentUploadFromList) {
|
||||
this.attachmentUploadFromList = false;
|
||||
this.listUploadContractFileRows = [];
|
||||
this.listUploadAttachmentRows = [];
|
||||
this.onLoad(this.page, this.query);
|
||||
return;
|
||||
}
|
||||
this.closeForm();
|
||||
})
|
||||
.finally(() => {
|
||||
this.submitAction = '';
|
||||
});
|
||||
},
|
||||
openAttachmentUploadDialog(row = {}) {
|
||||
if (!row?.id) {
|
||||
this.$message.warning('合同不存在,无法上传附件');
|
||||
return;
|
||||
}
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: '加载中',
|
||||
background: 'rgba(255, 255, 255, 0.6)',
|
||||
});
|
||||
this.attachmentUploadFromList = true;
|
||||
this.listUploadContractFileRows = [];
|
||||
this.listUploadAttachmentRows = [];
|
||||
this.form = { ...defaultForm(), id: row.id };
|
||||
this.api
|
||||
.getDetail(row.id)
|
||||
.then(res => {
|
||||
const detail = res.data?.data || {};
|
||||
this.form = {
|
||||
...defaultForm(),
|
||||
...detail,
|
||||
id: detail.id || row.id,
|
||||
};
|
||||
this.listUploadContractFileRows = normalizeContractFileRows(
|
||||
parseArray(detail.contractFileJson)
|
||||
);
|
||||
this.listUploadAttachmentRows = parseArray(detail.attachmentsJson);
|
||||
this.$nextTick(() => {
|
||||
this.$refs.listAttachmentUploader?.openUploadDialog?.();
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.attachmentUploadFromList = false;
|
||||
this.$message.error('合同详情加载失败');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close();
|
||||
});
|
||||
},
|
||||
handleListAttachmentUploadConfirmed() {
|
||||
if (!this.attachmentUploadFromList) return;
|
||||
this.submitAttachmentUpload();
|
||||
},
|
||||
handleListAttachmentUploadToLocation({ location, rows = [] }) {
|
||||
if (!rows.length) return;
|
||||
if (location === '合同文件') {
|
||||
this.listUploadContractFileRows = [...(this.listUploadContractFileRows || []), ...rows];
|
||||
return;
|
||||
}
|
||||
if (location === '其它附件') {
|
||||
this.listUploadAttachmentRows = [...(this.listUploadAttachmentRows || []), ...rows];
|
||||
}
|
||||
},
|
||||
loadProjectOptions() {
|
||||
if (this.projectLoading) return;
|
||||
this.projectLoading = true;
|
||||
@@ -2749,15 +2831,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (operation.action === 'attachmentUpload') {
|
||||
this.$router.push({
|
||||
path: '/business/contract-manage/form',
|
||||
query: {
|
||||
mode: 'edit',
|
||||
id: row.id,
|
||||
name: '附件上传',
|
||||
attachmentUpload: '1',
|
||||
},
|
||||
});
|
||||
this.openAttachmentUploadDialog(row);
|
||||
return;
|
||||
}
|
||||
const run = value => {
|
||||
@@ -2978,6 +3052,10 @@ export default {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
&--attachment {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
> .dialog-section-title,
|
||||
:deep(.dialog-section-title) {
|
||||
margin-bottom: 20px;
|
||||
|
||||
Reference in New Issue
Block a user