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
<template>
  <app-dialog-form
    v-bind="dialogFormProps"
  >
    <app-table-list v-bind="tableListProps" v-loading="appStore.getLoading('getEntitySet')">
      <template #table-base="scope">
        {{ fields.base.find(e => scope.row.field_base === e.code)?.name || scope.row.field_base }}
      </template>
 
      <template #table-join="scope">
        {{ dictMapCode?.filter_type[scope.row.join_type] }}
      </template>
 
      <template #table-target="scope">
        {{ fields.target.find(e => scope.row.field_target === e.code)?.name || scope.row.field_target }}
      </template>
 
      <template #table-active="scope">
        <app-column-tag
          :value="scope.row?.active"
          :valueEnum="{T:'生效',F:'失效'}"
          :typeEnum="{T:'success',F:'danger'}"
        />
      </template>
    </app-table-list>
  </app-dialog-form>
</template>
 
<script setup>
 
import {dict} from '@/hooks';
 
const {useDictMap} = dict;
 
import {useAppStore, useEntityStore} from "@/store/modules";
 
const entityStore = useEntityStore();
 
const appStore = useAppStore();
 
const dialogFormRef = ref();
 
const [_, dictMapCode] = useDictMap(['filter_type']);
 
const fields = reactive({
  target: [],
  base: []
})
 
 
const tableListRef = ref();
 
const tableListProps = {
  class: 'table-class',
  ref: tableListRef,
  title: '匹配列表',
  complementHeight: -1,
  columns: [
    {
      type: 'slot',
      prop: 'base',
      label: "基础表",
      table: {
        width: 190
      }
    },
    {
      type: 'slot',
      prop: 'join',
      label: "公式",
      table: {
        width: 130
      }
    },
    {
      type: 'slot',
      prop: 'target',
      label: "匹配表",
      table: {
        width: 190
      }
    },
    {
      type: 'slot',
      prop: 'remark',
      label: "描述"
    },
    {
      type: 'slot',
      prop: 'active',
      label: "生效",
      table: {
        width: 80
      }
    }
  ]
};
 
const init = async (row) => {
  tableListRef.value.setTableData([]);
  const [detail, target, base] = await Promise.all([
    entityStore.getEntitySet({
      dataName: "fee_joint_detail",
      filter: `parent_id = '${row.id}'`,
    }),
    entityStore.getEntitySet({
      dataName: "fee_model_band_column",
      filter: `bandid = '${row.target_band_id}'`,
    }),
    entityStore.getEntitySet({
      dataName: "fee_model_band_column",
      filter: `bandid = '${row.base_band_id}'`,
    }),
  ]);
  tableListRef.value.setTableData(detail.data.entityset);
  fields.target = target.data.entityset;
  fields.base = base.data.entityset;
}
 
const dialogFormProps = {
  width: 1000,
  title: '匹配数据',
  ref: dialogFormRef,
  footerDom: false
};
 
const onOpen = async (row) => {
  dialogFormRef.value.onOpen();
  await nextTick();
  await init(row);
}
 
defineExpose({
  onOpen
});
 
</script>