zhuoyuan.wang
2024-06-19 15ebe96f28cadec6a726c5324593a40bbf56205f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<template>
  <app-dialog-form
    v-bind="dialogFormProps"
  >
    <app-layout-row>
 
      <app-layout-col :span="24">
        <app-table-list v-bind="baseTableListProps" v-loading="loading"/>
      </app-layout-col>
 
      <app-layout-col :span="24" paddingTop="20">
        <app-table-list v-bind="standradTableListProps" v-show="typeCode === 'data_standrad'" v-loading="loading"/>
      </app-layout-col>
 
      <app-layout-col :span="24" paddingTop="20">
        <app-table-list v-bind="filterTableListProps" v-show="typeCode === 'data_standrad'" v-loading="loading">
          <template #table-relation="scope">
            {{ dictMapCode?.filter_type[scope.row.relation] }}
          </template>
        </app-table-list>
      </app-layout-col>
    </app-layout-row>
 
  </app-dialog-form>
</template>
 
<script setup>
 
import {structure, dict} from '@/hooks';
 
const {useStructureData} = structure;
const {useDictMap} = dict;
 
import {useEntityStore} from "@/store/modules";
import {decode} from "@/utils/tools.js";
 
const entityStore = useEntityStore();
 
const loading = ref(false);
 
const props = defineProps({
  options: {
    type: Object,
    default: {}
  },
});
 
const baseTableListRef = ref();
 
const baseTableListProps = {
  ref: baseTableListRef,
  title: '参数列表',
  complementHeight: -1,
  columns: [
    {
      prop: `$data_field_name.${props.options.property.name}`,
      label: "参数描述",
    }
  ]
};
 
const standradTableListRef = ref();
 
const standradTableListProps = {
  ref: standradTableListRef,
  title: '参数列表',
  complementHeight: -1,
  columns: [
    {
      prop: `$data_field_name.${props.options.property.name}`,
      label: "参数描述",
    },
    {
      prop: '$criterion_field_name.labelchinese',
      label: "数据描述",
    },
    {
      prop: 'remark',
      label: "描述",
    }
  ]
};
 
const filterTableListRef = ref();
 
const filterTableListProps = {
  ref: filterTableListRef,
  title: '过滤参数',
  complementHeight: -1,
  columns: [
    {
      prop: `$data_field_name.${props.options.property.name}`,
      label: "参数描述",
    },
    {
      type: 'slot',
      prop: 'relation',
      label: "等式",
    },
    {
      prop: '$criterion_field_name.labelchinese',
      label: "数据描述",
    },
    {
      prop: 'remark',
      label: '备注',
    }
  ]
};
 
const [actionStructure] = useStructureData([
  {
    target: {name: 'sys_data_field_rule', field: 'rule_code'},
    entity: {name: 'sys_library_rule', field: 'code'},
    type: 'object'
  },
  {
    target: {name: 'sys_data_field_rule_standrad', field: 'data_field_name'},
    entity: {name: props.options.property.dataName, field: props.options.property.value},
    type: 'object'
  },
  {
    target: {name: 'sys_data_field_rule_filter', field: 'data_field_name'},
    entity: {name: props.options.property.dataName, field: props.options.property.value},
    type: 'object'
  }
]);
 
const [_, dictMapCode] = useDictMap(['filter_type']);
 
const typeCode = ref('');
 
const init = async (row) => {
  if (row.id) {
    loading.value = true;
    const {data} = await entityStore.getEntity({
      dataName: "pkg_data_field_rule",
      attachMeta: false,
      id: row.id,
    });
 
    const structureData = await actionStructure(data);
 
    typeCode.value = structureData.sys_data_field_rule.$rule_code.type_code;
 
    if (structureData.sys_data_field_rule.$rule_code.type_code === 'data_standrad') {
      const {meta} = await entityStore.getEntitySet({
        dataName: structureData.sys_data_field_rule.$rule_code.object_code,
        filter: '1 != 1',
        attachMeta: true,
      });
      const fields = meta[structureData.sys_data_field_rule.$rule_code.object_code].fields;
 
      fields.forEach(e => {
        e.labelchinese = decode(e.labelchinese)
      });
 
      structureData.sys_data_field_rule_standrad.forEach(e => {
        e.$criterion_field_name = fields.find(f => f.field === e.criterion_field_name)
      });
 
      structureData.sys_data_field_rule_filter.forEach(e => {
        e.$criterion_field_name = fields.find(f => f.field === e.criterion_field_name)
      });
 
      standradTableListRef.value.setTableData(structureData.sys_data_field_rule_standrad);
      filterTableListRef.value.setTableData(structureData.sys_data_field_rule_filter);
    }
 
    baseTableListRef.value.setTableData(structureData.sys_data_field_rule_standrad);
 
    loading.value = false;
  }
}
 
const dialogFormRef = ref();
 
const dialogFormProps = {
  width: 1000,
  title: '参数列表',
  ref: dialogFormRef,
  footerDom: false
};
 
const onOpen = async (row) => {
  dialogFormRef.value.$forceUpdate(dialogFormProps);
  dialogFormRef.value.onOpen();
  await nextTick();
  await init(row);
}
 
defineExpose({
  onOpen
});
 
</script>