完成字段关联接口

master
lynn 7 months ago
parent 9033db6bc5
commit c614c0141f

@ -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
})
}

@ -121,6 +121,16 @@
<el-option label="单选框" value="radio"></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联字段">
<el-select v-model="editForm.link_field" class="w-100 form-input" clearable placeholder="请选择关联字段">
<el-option
v-for="(label, key) in categoryBaseConfig.contract_template_link_fields || {}"
:key="key"
:label="label"
:value="key"
/>
</el-select>
</el-form-item>
<el-form-item label="数据选项" v-if="['select', 'checkbox', 'radio'].includes(editForm.type)">
<el-input
v-model="editForm.options"
@ -159,7 +169,7 @@
<script>
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;
});
// URLID
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
};
});

@ -226,6 +226,7 @@
import {
parseTime
} from "@/utils";
import { getContractTemplateContext } from '@/api/businessConfig/businessConfig';
// DOMHTML
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() {

Loading…
Cancel
Save