<template>
|
<app-page-form v-bind="pageFormProps">
|
<app-g6-tree v-loading="loading" v-bind="g6TreeProps"/>
|
</app-page-form>
|
</template>
|
|
<script setup>
|
|
const router = useRouter();
|
|
import {uuid} from '@/utils/tools.js';
|
import {useEntityStore} from '@/store/modules';
|
|
import {structure} from '@/hooks';
|
|
const {useStructureData} = structure;
|
|
const params = router.currentRoute.value.query;
|
|
const [actionStructure] = useStructureData([
|
{
|
target: {name: 'agm_agreement_template_detail', field: 'field_code'},
|
entity: {name: 'v_data_field_rule_standrad', field: 'criterion_field_name'},
|
type: 'list'
|
},
|
])
|
|
|
const groupModeEnum = {
|
form: '表单',
|
list: '列表'
|
};
|
|
const typeEnum = {
|
signatory: '签署方',
|
detail: '协议明细'
|
}
|
|
const entityStore = useEntityStore();
|
|
import {closeTab} from '@/utils/iframe.js';
|
|
const pageFormProps = {
|
subClose() {
|
closeTab();
|
},
|
submitDom: false,
|
resetDom: false,
|
}
|
|
const loading = ref(false);
|
|
const g6TreeRef = ref();
|
|
const g6TreeProps = {
|
ref: g6TreeRef,
|
}
|
|
const initData = async () => {
|
loading.value = true;
|
const result = await entityStore.getEntity({
|
dataName: 'pkg_agm_agreement_template',
|
id: params.id,
|
});
|
const {agm_agreement_template, agm_agreement_template_detail} = result.data;
|
await actionStructure(result.data)
|
|
const groups = [];
|
const fields = [];
|
|
agm_agreement_template_detail.forEach(item => {
|
if (item.$field_code.length) {
|
const children = [];
|
item.$field_code.forEach(item => {
|
const {
|
rule_name,
|
rule_code,
|
data_field_name,
|
rule_type_code,
|
rule_object_code,
|
formula,
|
rule_format_content
|
} = item;
|
if (rule_type_code === 'required') {
|
children.push({id: uuid(), name: rule_name, desc: rule_code});
|
}
|
if (rule_type_code === 'data_standrad') {
|
console.log(item);
|
children.push({
|
id: uuid(),
|
name: rule_name,
|
desc: rule_code,
|
children: [{id: uuid(), name: rule_object_code, desc: data_field_name}]
|
});
|
}
|
if (rule_type_code === 'calculate') {
|
children.push({
|
id: uuid(),
|
name: rule_name,
|
desc: rule_code,
|
children: [{id: uuid(), name: '公式', desc: formula}]
|
});
|
}
|
if(rule_type_code === 'format') {
|
if (rule_code === 'format_date_cn') {
|
children.push({
|
id: uuid(),
|
name: rule_name,
|
desc: rule_code,
|
children: [{id: uuid(), name: '日期格式', desc: rule_format_content}]
|
});
|
}
|
if (rule_code === 'format_number') {
|
children.push({
|
id: uuid(),
|
name: rule_name,
|
desc: rule_code,
|
children: [{id: uuid(), name: '公式', desc: rule_format_content}]
|
});
|
}
|
}
|
});
|
item.children = children;
|
}
|
|
|
if (item.sort === 'group') {
|
groups.push({
|
id: item.id,
|
group_id: item.group_id,
|
name: item.group_name,
|
desc: groupModeEnum[item.group_mode],
|
type: item.type
|
});
|
}
|
|
if (item.sort === 'field') {
|
fields.push(item);
|
}
|
});
|
|
fields.forEach(field => {
|
groups.forEach(group => {
|
if (group.group_id === field.group_id) {
|
if (!group.children) {
|
group.children = [];
|
}
|
group.children.push({
|
id: uuid(),
|
name: field.field_name,
|
desc: field.field_code,
|
...(field.children ? {children: field.children} : {}),
|
});
|
}
|
});
|
});
|
|
const children = Object.keys(typeEnum).map(key => ({id: uuid(), name: typeEnum[key], desc: key}));
|
|
children.forEach(e => {
|
groups.forEach(item => {
|
if (e.desc === item.type) {
|
if (!e.children) {
|
e.children = [];
|
}
|
delete item.type;
|
e.children.push(item)
|
}
|
})
|
});
|
|
const {id, name, agreement_type} = agm_agreement_template;
|
|
loading.value = false;
|
return {id, name, desc: agreement_type, children};
|
}
|
|
onMounted(async () => {
|
const data = await initData();
|
await nextTick();
|
g6TreeRef.value.registerNode(data);
|
})
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
.container {
|
width: 100%;
|
}
|
</style>
|