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
<template>
  <app-list-wrapper v-bind="listWrapperProps">
    <template #header-button="scope">
      <el-button
        icon="Plus"
        size="small"
        type="primary"
        :disabled="!Object.keys(scope.selected).length || scope.selected.parent_id"
        @click="onDialog({parent_id: scope.selected.id})">
      </el-button>
      <el-button
        size="small"
        type="primary"
        icon="Edit"
        :disabled="!scope.selected.id"
        @click="onDialog(scope.selected)">
      </el-button>
      <el-button
        size="small"
        type="danger"
        icon="Delete"
        :disabled="!(Object.keys(scope.selected).length && scope.selected.parent_id)"
        @click="onDelete(scope.selected)"
      >
      </el-button>
    </template>
    <app-list-tree
      v-bind="treeProps"
    >
    </app-list-tree>
  </app-list-wrapper>
  <group-dialog v-bind="groupDialogProps"/>
</template>
 
<script setup>
import {useI18n} from 'vue-i18n';
 
const {t} = useI18n();
 
import {useAppStore, useEntityStore} from '@/store/modules';
import GroupDialog from './GroupDialog';
import {modal} from "@/plugins";
 
const treeRef = ref();
const groupDialogRef = ref();
const listWrapperRef = ref();
 
const entityStore = useEntityStore();
const appStore = useAppStore();
 
const props = defineProps({
  subActive: {
    type: Function,
    default: () => {
    }
  }
});
 
const groupDialogProps = {
  ref: groupDialogRef,
  subReload() {
    treeRef.value.onReload(false);
  }
};
 
const onDialog = (row) => {
  groupDialogRef.value.onOpen(row);
};
 
const onDelete = async (row) => {
  await modal.confirm("是否确认删除?");
 
  await entityStore.dataDelete({
    dataName: 'sys_param_group',
    id: row.id
  });
 
  treeRef.value.onReload(true);
};
 
const treeProps = {
  ref: treeRef,
  expandOnClickNode: false,
  nodeKey: 'id',
  props: {
    children: 'children',
    label: 'name',
  },
  defaultExpandAll: true,
  subRequest: async () => {
    const {data} = await entityStore.getEntityTree({
      dataName: "sys_param_group",
      orderBy: "order_no asc",
      filter: "1=1"
    });
    return data['entityset'];
  },
  subActive: (row) => {
    listWrapperRef.value.setSelected(row)
    props.subActive(row);
  }
}
 
const listWrapperProps = {
  ref: listWrapperRef,
  title: t('views.agm.agmParams.IndexPage.GroupList.title'),
  complementHeight: 30,
};
 
</script>