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
<template>
  <app-tab-wrapper
    v-bind="tabWrapperProps"
  >
    <template #[tab.name]="scope" v-for="tab in props.tabList" :key="tab.name">
        <slot :name="tab.name"></slot>
    </template>
 
    <template #[page.type]="scope" v-for="page in pageConfig" :key="page.type">
      <rules-table v-bind="rulesTableProps" :options="page"/>
      <rules-dialog v-bind="rulesDialogProps" :options="page"/>
    </template>
  </app-tab-wrapper>
</template>
 
<script setup>
 
import {modal} from '@/plugins';
 
import RulesTable from './RulesTable';
import RulesDialog from './RulesDialog';
import {useEntityStore} from "@/store/modules";
 
const entityStore = useEntityStore();
 
const props = defineProps({
  subCurrent: {
    type: Function,
    default: () => {
    }
  },
  pageConfig: {
    type: Array,
    default: []
  },
  tabList: {
    type: Array,
    default: []
  },
});
 
const rulesDialogRef = ref();
 
const rulesTableRef = ref();
 
const tabWrapperRef = ref();
 
const tabWrapperProps = {
  ref: tabWrapperRef,
  tabList: [
    ...props.tabList,
    ...props.pageConfig.map(e => ({name: e.type, label: e.label}))
  ],
  subActive(val) {
    props.subCurrent({tab: val, edit: null, add: null});
  }
}
 
const rulesTableProps = {
  ref: rulesTableRef,
  subCurrent(row) {
    props.subCurrent(row);
  },
}
 
const rulesDialogProps = {
  ref: rulesDialogRef,
  subReload(bool) {
    rulesTableRef.value.onReload(bool);
  }
}
 
const onDialog = (row) => {
  rulesDialogRef.value.onOpen(row);
};
 
const onDelete = async (row) => {
  await modal.confirm("是否确认删除?");
 
  await entityStore.deleteEntity({
    dataName: 'sys_data_field_rule',
    id: row.id
  });
  rulesTableRef.value.onReload(false)
};
 
 
defineExpose({
  onDialog,
  onDelete
});
 
</script>