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
| <template>
| <el-dialog title="角色权限设置" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
| <el-tabs tab-position="top">
| <el-tab-pane label="菜单">
| <div class="treeMain">
| <el-tree ref="menu" node-key="name" :data="menu.list" :props="menu.props" show-checkbox></el-tree>
| </div>
| </el-tab-pane>
| <el-tab-pane label="卡片">
| <div class="treeMain">
| <el-tree ref="grid" node-key="key" :data="grid.list" :props="grid.props" :default-checked-keys="grid.checked" show-checkbox></el-tree>
| </div>
| </el-tab-pane>
| </el-tabs>
| <template #footer>
| <el-button @click="visible=false" >取 消</el-button>
| <el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
| </template>
| </el-dialog>
| </template>
|
| <script>
| export default {
| emits: ['success', 'closed'],
| data() {
| return {
| visible: false,
| isSaveing: false,
| menu: {
| list: [],
| checked: [],
| props: {
| label: (data)=>{
| return data.meta.title
| }
| }
| },
| grid: {
| list: [],
| checked: ["welcome", "ver", "time", "progress", "echarts", "about"],
| props: {
| label: (data)=>{
| return data.title
| },
| disabled: (data)=>{
| return data.isFixed
| }
| }
| },
| data: {
| dataType :"1",
| list: [],
| checked: [],
| props: {},
| rule: ""
| },
| dashboard: "0",
| dashboardOptions: [
| {
| value: '0',
| label: '数据统计',
| views: 'stats'
|
| },
| {
| value: '1',
| label: '工作台',
| views: 'work'
| },
| ]
| }
| },
| mounted() {
| // this.getMenu()
| // this.getDept()
| // this.getGrid()
| },
| methods: {
| open(){
| this.visible = true;
| },
| submit(){
| this.isSaveing = true;
|
| //选中的和半选的合并后传值接口
| var checkedKeys = this.$refs.menu.getCheckedKeys().concat(this.$refs.menu.getHalfCheckedKeys())
| console.log(checkedKeys)
|
| var checkedKeys_dept = this.$refs.dept.getCheckedKeys().concat(this.$refs.dept.getHalfCheckedKeys())
| console.log(checkedKeys_dept)
|
| setTimeout(()=>{
| this.isSaveing = false;
| this.visible = false;
| this.$message.success("操作成功")
| this.$emit('success')
| },1000)
| },
| async getMenu(){
| var res = await this.$API.system.menu.list.get()
| this.menu.list = res.data
|
| //获取接口返回的之前选中的和半选的合并,处理过滤掉有叶子节点的key
| this.menu.checked = ["system", "user", "user.add", "user.edit", "user.del", "directive.edit", "other", "directive"]
| this.$nextTick(() => {
| let filterKeys = this.menu.checked.filter(key => this.$refs.menu.getNode(key).isLeaf)
| this.$refs.menu.setCheckedKeys(filterKeys, true)
| })
| },
| async getDept(){
| var res = await this.$API.system.dept.list.get();
| this.data.list = res.data
| this.data.checked = ["12", "2", "21", "22", "1"]
| this.$nextTick(() => {
| let filterKeys = this.data.checked.filter(key => this.$refs.dept.getNode(key).isLeaf)
| this.$refs.dept.setCheckedKeys(filterKeys, true)
| })
| },
| getGrid(){
| this.grid.list = [
| {
| key: "welcome",
| title: "主数据",
| isFixed: true
| },
| {
| key: "ver",
| title: "采集分析",
| isFixed: true
| },
| {
| key: "time",
| title: "生产工艺"
| },
| {
| key: "progress",
| title: "数字看板"
| },
| {
| key: "echarts",
| title: "配置中心"
| }
| ]
| }
| }
| }
| </script>
|
| <style scoped>
| .treeMain {height:280px;overflow: auto;border: 1px solid #dcdfe6;margin-bottom: 10px;}
| </style>
|
|