From c614c0141f91a9d88d1e01f4d28f68014ab1b36e Mon Sep 17 00:00:00 2001 From: lynn Date: Wed, 28 May 2025 18:40:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AD=97=E6=AE=B5=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/businessConfig/businessConfig.js | 9 +++++ src/views/businessConfig/EditPayForm.vue | 39 ++++++++++++++++--- .../components/paymentRegistration.vue | 11 ++++++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/api/businessConfig/businessConfig.js b/src/api/businessConfig/businessConfig.js index 4cb4418..7ff8c9d 100644 --- a/src/api/businessConfig/businessConfig.js +++ b/src/api/businessConfig/businessConfig.js @@ -75,4 +75,13 @@ export function saveContractCategoryTemplate(data) { url: '/api/admin/contract-category/save', data }) +} + +// 获取合同模板关联数据 +export function getContractTemplateContext(params) { + return request({ + method: 'get', + url: '/api/admin/contract-template/context', + params + }) } \ No newline at end of file diff --git a/src/views/businessConfig/EditPayForm.vue b/src/views/businessConfig/EditPayForm.vue index 859c1e8..58916d6 100644 --- a/src/views/businessConfig/EditPayForm.vue +++ b/src/views/businessConfig/EditPayForm.vue @@ -121,6 +121,16 @@ + + + + + import mammoth from 'mammoth'; -import { saveContractForm, getContractFormDetail } from '@/api/businessConfig/businessConfig'; +import { saveContractForm, getContractFormDetail, getContractCategoryTemplateBaseConfig } from '@/api/businessConfig/businessConfig'; export default { name: 'EditPayForm', @@ -179,6 +189,7 @@ export default { name: '', // Renamed from label to name (Chinese name) type: 'text', options: '', + link_field: '', }, fieldList: [], fieldMetadata: {}, // Use field name as key @@ -1549,6 +1560,7 @@ export default { unitLeaderAudit: '请输入单位负责人审批意见', upperCaseAmount: '请输入报销金额(大写)' }, + categoryBaseConfig: {}, // 合同基础配置 } }, computed: { @@ -1557,6 +1569,10 @@ export default { } }, created() { + // 页面加载时拉取合同基础配置 + getContractCategoryTemplateBaseConfig().then(res => { + this.categoryBaseConfig = res; + }); // 从URL中获取ID参数 const id = this.$route.query.id if (id) { @@ -1701,7 +1717,14 @@ export default { input.click() }, handleEditField(field) { - this.editForm = { ...field }; + // 保证link_field响应式 + this.editForm = { + field: field.field || '', + name: field.name || '', + type: field.type || 'text', + options: field.options || '', + link_field: field.link_field || '' + }; this.showEditDrawer = true; console.log('正在编辑字段:', field.name); @@ -1717,7 +1740,8 @@ export default { field: this.editForm.field, // 确保保留字段名 name: this.editForm.name, type: this.editForm.type, - options: this.editForm.options + options: this.editForm.options, + link_field: this.editForm.link_field || '' } // 更新代码预览区 @@ -1797,7 +1821,8 @@ export default { field, name: metadata.name, type: metadata.type, - options: metadata.options + options: metadata.options, + link_field: metadata.link_field || '' })) this.showEditDrawer = false @@ -1830,7 +1855,7 @@ export default { name: metadata.name, // Chinese name type: metadata.type, options: metadata.options, - // Removed placeholder and required as requested + link_field: metadata.link_field || '' })); const params = { @@ -1893,7 +1918,8 @@ export default { field, name: metadata.name, type: metadata.type, - options: metadata.options + options: metadata.options, + link_field: metadata.link_field || '' })); }, formatVariableName(name) { @@ -1955,6 +1981,7 @@ export default { name: serverField.name || this.formatVariableName(serverField.field), // Chinese name from server type: serverField.type || 'text', options: serverField.options || '', + link_field: serverField.link_field || '', // Add link_field // Removed placeholder and required }; }); diff --git a/src/views/contract/components/paymentRegistration.vue b/src/views/contract/components/paymentRegistration.vue index 619fc17..474f556 100644 --- a/src/views/contract/components/paymentRegistration.vue +++ b/src/views/contract/components/paymentRegistration.vue @@ -226,6 +226,7 @@ import { parseTime } from "@/utils"; + import { getContractTemplateContext } from '@/api/businessConfig/businessConfig'; // 添加同步表单DOM到HTML的函数 function syncFormDomToHtml(dom, contractTemplateFields) { @@ -360,6 +361,7 @@ showZoomedTable: false, // 控制放大表格弹窗的显示 hasPostPaymentForm: false, // 是否有事后支付表格 contract_category: {}, + templateContextData: null, // 合同模板关联数据 } }, methods: { @@ -536,6 +538,15 @@ this.contractTemplate = null; this.forms = null; } + // 拉取合同模板关联数据 + if (this.contract && this.contract.id) { + getContractTemplateContext({ + id: this.contract.id, + model: 'Contract' + }).then(res => { + this.templateContextData = res; + }); + } }, submit() {