完成字段关联接口

master
lynn 7 months ago
parent 9033db6bc5
commit c614c0141f

@ -75,4 +75,13 @@ export function saveContractCategoryTemplate(data) {
url: '/api/admin/contract-category/save', url: '/api/admin/contract-category/save',
data 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-option label="单选框" value="radio"></el-option>
</el-select> </el-select>
</el-form-item> </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-form-item label="数据选项" v-if="['select', 'checkbox', 'radio'].includes(editForm.type)">
<el-input <el-input
v-model="editForm.options" v-model="editForm.options"
@ -159,7 +169,7 @@
<script> <script>
import mammoth from 'mammoth'; import mammoth from 'mammoth';
import { saveContractForm, getContractFormDetail } from '@/api/businessConfig/businessConfig'; import { saveContractForm, getContractFormDetail, getContractCategoryTemplateBaseConfig } from '@/api/businessConfig/businessConfig';
export default { export default {
name: 'EditPayForm', name: 'EditPayForm',
@ -179,6 +189,7 @@ export default {
name: '', // Renamed from label to name (Chinese name) name: '', // Renamed from label to name (Chinese name)
type: 'text', type: 'text',
options: '', options: '',
link_field: '',
}, },
fieldList: [], fieldList: [],
fieldMetadata: {}, // Use field name as key fieldMetadata: {}, // Use field name as key
@ -1549,6 +1560,7 @@ export default {
unitLeaderAudit: '请输入单位负责人审批意见', unitLeaderAudit: '请输入单位负责人审批意见',
upperCaseAmount: '请输入报销金额(大写)' upperCaseAmount: '请输入报销金额(大写)'
}, },
categoryBaseConfig: {}, //
} }
}, },
computed: { computed: {
@ -1557,6 +1569,10 @@ export default {
} }
}, },
created() { created() {
//
getContractCategoryTemplateBaseConfig().then(res => {
this.categoryBaseConfig = res;
});
// URLID // URLID
const id = this.$route.query.id const id = this.$route.query.id
if (id) { if (id) {
@ -1701,7 +1717,14 @@ export default {
input.click() input.click()
}, },
handleEditField(field) { 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; this.showEditDrawer = true;
console.log('正在编辑字段:', field.name); console.log('正在编辑字段:', field.name);
@ -1717,7 +1740,8 @@ export default {
field: this.editForm.field, // field: this.editForm.field, //
name: this.editForm.name, name: this.editForm.name,
type: this.editForm.type, 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, field,
name: metadata.name, name: metadata.name,
type: metadata.type, type: metadata.type,
options: metadata.options options: metadata.options,
link_field: metadata.link_field || ''
})) }))
this.showEditDrawer = false this.showEditDrawer = false
@ -1830,7 +1855,7 @@ export default {
name: metadata.name, // Chinese name name: metadata.name, // Chinese name
type: metadata.type, type: metadata.type,
options: metadata.options, options: metadata.options,
// Removed placeholder and required as requested link_field: metadata.link_field || ''
})); }));
const params = { const params = {
@ -1893,7 +1918,8 @@ export default {
field, field,
name: metadata.name, name: metadata.name,
type: metadata.type, type: metadata.type,
options: metadata.options options: metadata.options,
link_field: metadata.link_field || ''
})); }));
}, },
formatVariableName(name) { formatVariableName(name) {
@ -1955,6 +1981,7 @@ export default {
name: serverField.name || this.formatVariableName(serverField.field), // Chinese name from server name: serverField.name || this.formatVariableName(serverField.field), // Chinese name from server
type: serverField.type || 'text', type: serverField.type || 'text',
options: serverField.options || '', options: serverField.options || '',
link_field: serverField.link_field || '', // Add link_field
// Removed placeholder and required // Removed placeholder and required
}; };
}); });

@ -226,6 +226,7 @@
import { import {
parseTime parseTime
} from "@/utils"; } from "@/utils";
import { getContractTemplateContext } from '@/api/businessConfig/businessConfig';
// DOMHTML // DOMHTML
function syncFormDomToHtml(dom, contractTemplateFields) { function syncFormDomToHtml(dom, contractTemplateFields) {
@ -360,6 +361,7 @@
showZoomedTable: false, // showZoomedTable: false, //
hasPostPaymentForm: false, // hasPostPaymentForm: false, //
contract_category: {}, contract_category: {},
templateContextData: null, //
} }
}, },
methods: { methods: {
@ -536,6 +538,15 @@
this.contractTemplate = null; this.contractTemplate = null;
this.forms = null; this.forms = null;
} }
//
if (this.contract && this.contract.id) {
getContractTemplateContext({
id: this.contract.id,
model: 'Contract'
}).then(res => {
this.templateContextData = res;
});
}
}, },
submit() { submit() {

Loading…
Cancel
Save