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
<template>
  <app-dialog-form
    v-bind="dialogFormProps"
  >
    <app-layout-row>
      <app-layout-col :span="24">
        <app-table-search
          v-bind="searchProps"
        />
      </app-layout-col>
      <app-layout-col :span="24" :paddingTop="10">
        <app-table-pro
          v-bind="tableProps"
        />
      </app-layout-col>
    </app-layout-row>
  </app-dialog-form>
</template>
 
<script setup>
import {useEntityStore, useAppStore} from '@/store/modules';
import {modal} from '@/plugins';
import {convertFilter} from '@/utils/filter.js';
import {meta} from '@/hooks';
 
const {useMetaData} = meta;
 
const tableSearchRef = ref();
const tableProRef = ref();
const entityStore = useEntityStore();
const appStore = useAppStore();
 
const props = defineProps({
  subSubmit: {
    type: Function,
    default: () => {
    }
  },
  options: {
    type: Object,
    default: {}
  }
});
 
const [columns, filters, fields] = useMetaData(
  props.options.property.dataName,
  async () => {
  }
);
 
const dialogFormRef = ref();
 
const dialogFormProps = {
  width: 1000,
  title: '规则选择',
  ref: dialogFormRef,
  subSubmit: async () => {
    const current = tableProRef.value.getTableCurrent();
    if (Object.keys(current).length === 0) {
      modal.msgError('请选择规则!');
      throw '';
    }
    props.subSubmit(current);
  },
  subReset: async () => {
    tableProRef.value.getTableData(true);
    tableProRef.value.setTableCurrent({});
  }
};
 
const tableProps = {
  complementHeight: -90,
  ref: tableProRef,
  requestParams: {
    search: {}
  },
  subRequest: async (page) => {
    const result = await entityStore.getEntitySet({
      dataName:   props.options.property.dataName,
      attachMeta: false,
      filter: `${convertFilter({
        andLikeParams: tableProps.requestParams.search,
      })} ${props.options.property.filter}`,
      ...page
    });
    return result;
  },
  subCurrent(row) {
    // props.subCurrent(row);
  },
  title: '参数列表',
  columns
};
 
const searchProps = {
  ref: tableSearchRef,
  formFields: filters,
  subSubmit: (params) => {
    tableProps.requestParams.search = params;
    tableProRef.value.getTableData(true);
  }
}
 
const onReload = (bool) => {
  tableProRef.value.getTableData(bool);
}
 
const onOpen = async () => {
  dialogFormRef.value.onOpen();
  await nextTick();
  tableProRef.value.getTableData(true);
  tableProRef.value.setTableCurrent({});
}
 
defineExpose({
  onReload,
  onOpen
});
 
</script>