yh-pub 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +19 -19
- package/layout/admin/adminIndex.vue +104 -104
- package/layout/admin/api/loginApi.js +24 -24
- package/layout/admin/api/routers.js +93 -93
- package/layout/admin/api/tenantApi.js +123 -123
- package/layout/admin/home/homeIndex.vue +25 -25
- package/layout/admin/login/login.vue +161 -161
- package/layout/admin/menu/MenuIndex.vue +648 -648
- package/layout/admin/menu/icon.vue +108 -108
- package/layout/admin/menu/iconList.js +934 -934
- package/layout/admin/saTenant/saTenant.vue +173 -173
- package/layout/admin/saTenant/saTenantForm.js +80 -80
- package/layout/admin/saTenant/saTenantForm.vue +61 -61
- package/layout/admin/saTenant/saTenantRoleManage.js +417 -417
- package/layout/admin/saTenant/saTenantRoleManage.vue +99 -99
- package/layout/admin/user/saUser.less +6 -6
- package/layout/admin/user/saUser.vue +72 -72
- package/layout/main/components/console/console.vue +205 -205
- package/layout/main/components/error-store/error-store.vue +72 -72
- package/layout/main/components/error-store/index.js +2 -2
- package/layout/main/components/fullscreen/fullscreen.vue +57 -57
- package/layout/main/components/fullscreen/index.js +2 -2
- package/layout/main/components/language/language.vue +71 -71
- package/layout/main/components/side-menu/side-menu.less +73 -73
- package/layout/main/components/side-menu/side-menu.vue +75 -75
- package/layout/main/components/tags-nav/tags-nav.less +44 -44
- package/layout/main/components/tags-nav/tags-nav.vue +144 -144
- package/layout/main/components/user/user.less +12 -12
- package/layout/main/components/user/user.vue +185 -185
- package/layout/main/home/home.vue +480 -480
- package/layout/main/home/index.js +2 -2
- package/layout/main/home/toDoList.vue +32 -32
- package/layout/main/login/login.less +93 -93
- package/layout/main/login/login.vue +151 -151
- package/layout/main/main.less +81 -81
- package/layout/main/main.vue +254 -202
- package/layout/main/system/dict.vue +64 -64
- package/layout/main/system/orgManage.vue +473 -473
- package/layout/main/system/roleManage.js +807 -755
- package/layout/main/system/roleManage.vue +424 -399
- package/package.json +11 -11
- package/view/basic/error-logger.vue +74 -74
- package/view/basic/error-page/401.vue +22 -22
- package/view/basic/error-page/404.vue +22 -22
- package/view/basic/error-page/500.vue +22 -22
- package/view/basic/error-page/back-btn-group.vue +48 -48
- package/view/basic/error-page/error-content.vue +28 -28
- package/view/basic/error-page/error.less +46 -46
- package/view/config/component/confFormItem.vue +49 -49
- package/view/config/config.scss +45 -45
- package/view/config/configIndex.vue +150 -150
- package/view/config/subPage/router-config.vue +4 -4
- package/view/config/subPage/sys-config.vue +249 -249
- package/view/window/IframeFReportView.vue +27 -27
- package/view/window/windowIndex.vue +22 -22
|
@@ -1,417 +1,417 @@
|
|
|
1
|
-
import {
|
|
2
|
-
saTenantGetById,
|
|
3
|
-
saTenantGetMenuList,
|
|
4
|
-
saTenantGetMenuWindowButton,
|
|
5
|
-
saTenantGetRoleMenus,
|
|
6
|
-
saTenantGetRoleWindowButton,
|
|
7
|
-
saTenantSetMenus,
|
|
8
|
-
} from "../api/tenantApi";
|
|
9
|
-
import { deepClone } from "@/libs/util";
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
props: {
|
|
13
|
-
actionData: {
|
|
14
|
-
type: Object,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
watch: {
|
|
18
|
-
actionData: {
|
|
19
|
-
async handler(val) {
|
|
20
|
-
this.id = val.id;
|
|
21
|
-
let dataTemp = await this.getById(val.id);
|
|
22
|
-
this.tenantInfo = dataTemp;
|
|
23
|
-
this.getRoleWindowButton(dataTemp.adRoleId);
|
|
24
|
-
let roleMenuData = await this.getRoleMenus(dataTemp.adRoleId);
|
|
25
|
-
this.initMenu(roleMenuData);
|
|
26
|
-
this.visible = true;
|
|
27
|
-
},
|
|
28
|
-
deep: true,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
data() {
|
|
32
|
-
return {
|
|
33
|
-
tenantInfo: {},
|
|
34
|
-
submitPermLoading: false,
|
|
35
|
-
saveWinBtnList: [],
|
|
36
|
-
unCheckedMenuTreeData: {},
|
|
37
|
-
roleMenuData: {},
|
|
38
|
-
curWindowBtnList: [],
|
|
39
|
-
curSelectedMenuId: "", // 当前选中目录ID
|
|
40
|
-
roleSavedBtnPermMap: {}, // 角色已授予的按钮权限
|
|
41
|
-
checkedMenuKeys: [],
|
|
42
|
-
expandedMenuKeys: [],
|
|
43
|
-
replaceFields: {
|
|
44
|
-
children: "children",
|
|
45
|
-
title: "title",
|
|
46
|
-
},
|
|
47
|
-
permData: [],
|
|
48
|
-
treeLoading: true,
|
|
49
|
-
type: "",
|
|
50
|
-
id: "",
|
|
51
|
-
visible: false,
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
computed: {},
|
|
55
|
-
methods: {
|
|
56
|
-
resetBtnPerData() {
|
|
57
|
-
this.roleSavedBtnPermMap = {};
|
|
58
|
-
this.unCheckedMenuTreeData = {};
|
|
59
|
-
this.roleMenuData = {};
|
|
60
|
-
this.curWindowBtnList = [];
|
|
61
|
-
this.saveWinBtnList = [];
|
|
62
|
-
},
|
|
63
|
-
async submitPermEdit() {
|
|
64
|
-
let curVm = this;
|
|
65
|
-
this.submitPermLoading = true;
|
|
66
|
-
let permMenuIds = this.checkedMenuKeys.join(",");
|
|
67
|
-
// // 所有菜单窗口按钮
|
|
68
|
-
let permMenuBtnIds = {};
|
|
69
|
-
Object.keys(this.roleSavedBtnPermMap).forEach(function (key) {
|
|
70
|
-
permMenuBtnIds["W_" + key] = curVm.roleSavedBtnPermMap[key];
|
|
71
|
-
});
|
|
72
|
-
saTenantSetMenus({
|
|
73
|
-
roleId: this.tenantInfo.adRoleId,
|
|
74
|
-
ids: permMenuIds,
|
|
75
|
-
btns: JSON.stringify(permMenuBtnIds),
|
|
76
|
-
adClientId: this.tenantInfo.adClientId,
|
|
77
|
-
adOrgId: this.tenantInfo.adOrgId,
|
|
78
|
-
}).then((res) => {
|
|
79
|
-
this.submitPermLoading = false;
|
|
80
|
-
if (res.data.result) {
|
|
81
|
-
this.$message.success("操作成功");
|
|
82
|
-
this.permModalVisible = false;
|
|
83
|
-
this.cancel();
|
|
84
|
-
} else {
|
|
85
|
-
this.$message.error(res.data.msg);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
getRoleWindowButton(roleId) {
|
|
90
|
-
saTenantGetRoleWindowButton({ adRoleId: roleId }).then((res) => {
|
|
91
|
-
if (res.data.data) {
|
|
92
|
-
let data = res.data.data;
|
|
93
|
-
let roleBtnPermMap = {};
|
|
94
|
-
data.forEach(function (e) {
|
|
95
|
-
if (!roleBtnPermMap[e.sysWindowId]) {
|
|
96
|
-
roleBtnPermMap[e.sysWindowId] = [];
|
|
97
|
-
}
|
|
98
|
-
roleBtnPermMap[e.sysWindowId].push(e.sysWindowButtonId);
|
|
99
|
-
});
|
|
100
|
-
this.roleSavedBtnPermMap = roleBtnPermMap;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
cancel() {
|
|
105
|
-
this.resetBtnPerData();
|
|
106
|
-
this.visible = false;
|
|
107
|
-
this.$emit("getinfo");
|
|
108
|
-
},
|
|
109
|
-
getById: async function (id) {
|
|
110
|
-
let param = {
|
|
111
|
-
adClientId: id,
|
|
112
|
-
};
|
|
113
|
-
let data;
|
|
114
|
-
await saTenantGetById(param).then((res) => {
|
|
115
|
-
if (res.data.data) {
|
|
116
|
-
data = res.data.data;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return data;
|
|
120
|
-
},
|
|
121
|
-
getRoleMenus: async function (roleId) {
|
|
122
|
-
// 请求角色菜单数据
|
|
123
|
-
let roleMenuData = [];
|
|
124
|
-
let that = this;
|
|
125
|
-
this.expandedMenuKeys.clear();
|
|
126
|
-
this.checkedMenuKeys.clear();
|
|
127
|
-
|
|
128
|
-
await saTenantGetRoleMenus({ adRoleId: roleId }).then((res) => {
|
|
129
|
-
if (res.data.result) {
|
|
130
|
-
res.data.data.forEach(function (e) {
|
|
131
|
-
if (e.MENU_TYPE !== "GROUP") {
|
|
132
|
-
roleMenuData[e.AD_MENU_ID] = e;
|
|
133
|
-
that.checkedMenuKeys.push(e.AD_MENU_ID);
|
|
134
|
-
} else {
|
|
135
|
-
that.expandedMenuKeys.push(e.AD_MENU_ID);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
return roleMenuData;
|
|
141
|
-
},
|
|
142
|
-
initMenu(roleMenuData) {
|
|
143
|
-
let curVm = this;
|
|
144
|
-
saTenantGetMenuList().then((res) => {
|
|
145
|
-
if (res.data.data) {
|
|
146
|
-
let newTreeData = [];
|
|
147
|
-
let data = res.data.data;
|
|
148
|
-
data.forEach(function (e) {
|
|
149
|
-
newTreeData.push(curVm.parseTreeData(e, 0));
|
|
150
|
-
});
|
|
151
|
-
this.calNewTreeData(newTreeData, roleMenuData);
|
|
152
|
-
|
|
153
|
-
curVm.permData = newTreeData;
|
|
154
|
-
curVm.treeLoading = false;
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
// 递归标记是否选中
|
|
159
|
-
calNewTreeData(newTreeData, roleMenuData) {
|
|
160
|
-
let curVm = this;
|
|
161
|
-
newTreeData.forEach(function (e) {
|
|
162
|
-
let checkedCount = 0;
|
|
163
|
-
e.expand = true;
|
|
164
|
-
|
|
165
|
-
// 判断是否选中
|
|
166
|
-
if (roleMenuData[e.adMenuId]) {
|
|
167
|
-
e.checked = true;
|
|
168
|
-
checkedCount++;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (e.children && e.children.length > 0) {
|
|
172
|
-
let sonCheckedCount = curVm.calNewTreeData(e.children, roleMenuData);
|
|
173
|
-
// 判断父节点是否选中
|
|
174
|
-
if (sonCheckedCount === e.children.length) {
|
|
175
|
-
e.checked = true;
|
|
176
|
-
e.selectable = true;
|
|
177
|
-
e.indeterminate = false;
|
|
178
|
-
} else if (sonCheckedCount > 0 && sonCheckedCount < e.children.length) {
|
|
179
|
-
e.indeterminate = true;
|
|
180
|
-
e.checked = false;
|
|
181
|
-
e.selectable = true;
|
|
182
|
-
} else {
|
|
183
|
-
e.checked = false;
|
|
184
|
-
e.indeterminate = false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return checkedCount;
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
selectTree(v, cv) {
|
|
191
|
-
// 菜单选择框不变
|
|
192
|
-
cv.checked = cv.selected;
|
|
193
|
-
if (v.length > 0) {
|
|
194
|
-
this.curSelectedMenuId = cv.selectedNodes[0].data.props.data.sysWindowId;
|
|
195
|
-
if (!this.curSelectedMenuId) {
|
|
196
|
-
this.curWindowBtnList = [];
|
|
197
|
-
// 加载角色已授权的按钮
|
|
198
|
-
this.saveWinBtnList = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 加载目录树
|
|
203
|
-
saTenantGetMenuWindowButton({ sysWindowId: this.curSelectedMenuId }).then((res) => {
|
|
204
|
-
let { result, data } = res.data;
|
|
205
|
-
if (result && data) {
|
|
206
|
-
let roleBtnData = [];
|
|
207
|
-
let tempQyBtnData = [];
|
|
208
|
-
data.forEach((tData) => {
|
|
209
|
-
if (tData.TYPE === "QY") {
|
|
210
|
-
roleBtnData.push(tData);
|
|
211
|
-
tempQyBtnData[tData.ID] = [];
|
|
212
|
-
} else {
|
|
213
|
-
if (tempQyBtnData[tData.PARENT_ID]) {
|
|
214
|
-
tempQyBtnData[tData.PARENT_ID].push(tData);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
roleBtnData.forEach((item) => {
|
|
219
|
-
item["childs"] = tempQyBtnData[item.ID];
|
|
220
|
-
// e['checkAll'] = false
|
|
221
|
-
let checkChilds = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
222
|
-
let tcount = 0;
|
|
223
|
-
tempQyBtnData[item.ID].forEach((es) => {
|
|
224
|
-
if (checkChilds.includes(es.ID)) {
|
|
225
|
-
tcount++;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
if (tcount === tempQyBtnData[item.ID].length) {
|
|
229
|
-
item["checkAll"] = true;
|
|
230
|
-
item["indeterminate"] = false;
|
|
231
|
-
} else if (tcount > 0) {
|
|
232
|
-
item["checkAll"] = false;
|
|
233
|
-
item["indeterminate"] = true;
|
|
234
|
-
} else {
|
|
235
|
-
item["checkAll"] = false;
|
|
236
|
-
item["indeterminate"] = false;
|
|
237
|
-
}
|
|
238
|
-
item["checkChilds"] = checkChilds;
|
|
239
|
-
});
|
|
240
|
-
this.curWindowBtnList = roleBtnData;
|
|
241
|
-
// 加载角色已授权的按钮
|
|
242
|
-
this.saveWinBtnList = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
checkedMenuTree(v, cv) {
|
|
248
|
-
if (cv.menuType !== "GROUP") {
|
|
249
|
-
if (!cv.checked) {
|
|
250
|
-
if (!this.unCheckedMenuTreeData[cv.adMenuId]) {
|
|
251
|
-
this.unCheckedMenuTreeData[cv.adMenuId] = "1";
|
|
252
|
-
}
|
|
253
|
-
} else {
|
|
254
|
-
delete this.unCheckedMenuTreeData[cv.adMenuId];
|
|
255
|
-
}
|
|
256
|
-
} else {
|
|
257
|
-
this.getTreeCheckedDataLoop(cv, !cv.checked);
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
getTreeCheckedDataLoop(cv, delFlag) {
|
|
261
|
-
let curVm = this;
|
|
262
|
-
if (delFlag) {
|
|
263
|
-
if (!this.unCheckedMenuTreeData[cv.adMenuId]) {
|
|
264
|
-
this.unCheckedMenuTreeData[cv.adMenuId] = "1";
|
|
265
|
-
}
|
|
266
|
-
if (cv.children && cv.children.length > 0) {
|
|
267
|
-
cv.children.forEach(function (ss) {
|
|
268
|
-
curVm.getTreeCheckedDataLoop(ss, delFlag);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
delete this.unCheckedMenuTreeData[cv.adMenuId];
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
renderContent(h, { root, node, data }) {
|
|
276
|
-
let icon = "";
|
|
277
|
-
if (data.level === 0) {
|
|
278
|
-
icon = "ios-navigate";
|
|
279
|
-
} else if (data.level === 1) {
|
|
280
|
-
icon = "md-list-box";
|
|
281
|
-
} else if (data.level === 2) {
|
|
282
|
-
icon = "md-list";
|
|
283
|
-
} else if (data.level === 3) {
|
|
284
|
-
icon = "md-radio-button-on";
|
|
285
|
-
} else {
|
|
286
|
-
icon = "md-radio-button-off";
|
|
287
|
-
}
|
|
288
|
-
return h(
|
|
289
|
-
"span",
|
|
290
|
-
{
|
|
291
|
-
style: {
|
|
292
|
-
display: "inline-block",
|
|
293
|
-
cursor: "pointer",
|
|
294
|
-
},
|
|
295
|
-
on: {
|
|
296
|
-
click: () => {
|
|
297
|
-
data.checked = data.selected;
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
[
|
|
302
|
-
h("span", [
|
|
303
|
-
h("Icon", {
|
|
304
|
-
props: {
|
|
305
|
-
type: icon,
|
|
306
|
-
size: "16",
|
|
307
|
-
},
|
|
308
|
-
style: {
|
|
309
|
-
"margin-right": "8px",
|
|
310
|
-
"margin-bottom": "3px",
|
|
311
|
-
},
|
|
312
|
-
}),
|
|
313
|
-
h("span", data.title),
|
|
314
|
-
]),
|
|
315
|
-
]
|
|
316
|
-
);
|
|
317
|
-
},
|
|
318
|
-
handleCheckAll(event, item, key) {
|
|
319
|
-
let checkChilds = [];
|
|
320
|
-
if (item.checkAll && (!item.indeterminate || item.indeterminate)) {
|
|
321
|
-
// 已经全选取消全选状态
|
|
322
|
-
item.checkAll = false;
|
|
323
|
-
item.indeterminate = false;
|
|
324
|
-
item.checkChilds = checkChilds;
|
|
325
|
-
} else {
|
|
326
|
-
// 不是全选状态,获取所有ids,并设定全选状态相关参数
|
|
327
|
-
checkChilds = item.childs.map((item) => item.ID);
|
|
328
|
-
item.checkAll = true;
|
|
329
|
-
item.indeterminate = false;
|
|
330
|
-
item.checkChilds = checkChilds;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// 状态设置完成,将数据赋值到 响应对象上去
|
|
334
|
-
this.$set(this.roleSavedBtnPermMap, this.curSelectedMenuId, checkChilds);
|
|
335
|
-
this.$set(this.curWindowBtnList, key, item);
|
|
336
|
-
},
|
|
337
|
-
checkAllGroupChange(event, key) {
|
|
338
|
-
let list = deepClone({}, this.curWindowBtnList);
|
|
339
|
-
let currentItem = list[key];
|
|
340
|
-
if (event.length > 0) {
|
|
341
|
-
// 判断是否存在值
|
|
342
|
-
let containFlag = 0; // 0 不包含 1 部分包括 2 全包括
|
|
343
|
-
let okCount = 0; // 统计包括次数
|
|
344
|
-
for (let i = 0; i < currentItem.childs.length; i++) {
|
|
345
|
-
if (event.includes(currentItem.childs[i].ID)) {
|
|
346
|
-
okCount++;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
if (okCount === currentItem.childs.length) {
|
|
350
|
-
containFlag = 2;
|
|
351
|
-
} else {
|
|
352
|
-
containFlag = 1;
|
|
353
|
-
}
|
|
354
|
-
// 判断是否选中
|
|
355
|
-
if (containFlag === 1) {
|
|
356
|
-
currentItem.checkAll = false;
|
|
357
|
-
if (okCount === 0) {
|
|
358
|
-
currentItem.indeterminate = false;
|
|
359
|
-
} else {
|
|
360
|
-
currentItem.indeterminate = true;
|
|
361
|
-
}
|
|
362
|
-
} else if (containFlag === 2) {
|
|
363
|
-
currentItem.checkAll = true;
|
|
364
|
-
currentItem.indeterminate = false;
|
|
365
|
-
}
|
|
366
|
-
} else {
|
|
367
|
-
currentItem.checkAll = false;
|
|
368
|
-
currentItem.indeterminate = false;
|
|
369
|
-
}
|
|
370
|
-
currentItem.checkChilds = event;
|
|
371
|
-
this.$set(this.curWindowBtnList, key, currentItem);
|
|
372
|
-
this.roleSavedBtnPermMap[this.curSelectedMenuId] = event;
|
|
373
|
-
},
|
|
374
|
-
doWinBtnData(doType, btnId) {
|
|
375
|
-
if (!this.saveWinBtnList) {
|
|
376
|
-
this.saveWinBtnList = [];
|
|
377
|
-
}
|
|
378
|
-
if (doType === "add") {
|
|
379
|
-
if (this.saveWinBtnList.length !== 0) {
|
|
380
|
-
for (let i = 0; i < this.saveWinBtnList.length; i++) {
|
|
381
|
-
if (this.saveWinBtnList[i] === btnId) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
this.saveWinBtnList.push(btnId);
|
|
387
|
-
} else {
|
|
388
|
-
for (let i = 0; i < this.saveWinBtnList.length; i++) {
|
|
389
|
-
if (this.saveWinBtnList[i] === btnId) {
|
|
390
|
-
this.saveWinBtnList.splice(i, 1);
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
parseTreeData(curLevelData, curLevel) {
|
|
397
|
-
let curVm = this;
|
|
398
|
-
let newLevelData = { data: curLevelData };
|
|
399
|
-
newLevelData["key"] = curLevelData.adMenuId;
|
|
400
|
-
newLevelData["title"] = curLevelData.name;
|
|
401
|
-
|
|
402
|
-
if (curLevelData._childs && curLevelData._childs.length > 0) {
|
|
403
|
-
curLevelData._childs.forEach(function (sonTreeData) {
|
|
404
|
-
if (!newLevelData.children) {
|
|
405
|
-
newLevelData.children = [];
|
|
406
|
-
}
|
|
407
|
-
newLevelData.children.push(curVm.parseTreeData(sonTreeData, curLevel + 1));
|
|
408
|
-
});
|
|
409
|
-
newLevelData["isLeaf"] = false;
|
|
410
|
-
} else {
|
|
411
|
-
newLevelData["isLeaf"] = true;
|
|
412
|
-
}
|
|
413
|
-
delete curLevelData._childs;
|
|
414
|
-
return newLevelData;
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
saTenantGetById,
|
|
3
|
+
saTenantGetMenuList,
|
|
4
|
+
saTenantGetMenuWindowButton,
|
|
5
|
+
saTenantGetRoleMenus,
|
|
6
|
+
saTenantGetRoleWindowButton,
|
|
7
|
+
saTenantSetMenus,
|
|
8
|
+
} from "../api/tenantApi";
|
|
9
|
+
import { deepClone } from "@/libs/util";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
props: {
|
|
13
|
+
actionData: {
|
|
14
|
+
type: Object,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
watch: {
|
|
18
|
+
actionData: {
|
|
19
|
+
async handler(val) {
|
|
20
|
+
this.id = val.id;
|
|
21
|
+
let dataTemp = await this.getById(val.id);
|
|
22
|
+
this.tenantInfo = dataTemp;
|
|
23
|
+
this.getRoleWindowButton(dataTemp.adRoleId);
|
|
24
|
+
let roleMenuData = await this.getRoleMenus(dataTemp.adRoleId);
|
|
25
|
+
this.initMenu(roleMenuData);
|
|
26
|
+
this.visible = true;
|
|
27
|
+
},
|
|
28
|
+
deep: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
tenantInfo: {},
|
|
34
|
+
submitPermLoading: false,
|
|
35
|
+
saveWinBtnList: [],
|
|
36
|
+
unCheckedMenuTreeData: {},
|
|
37
|
+
roleMenuData: {},
|
|
38
|
+
curWindowBtnList: [],
|
|
39
|
+
curSelectedMenuId: "", // 当前选中目录ID
|
|
40
|
+
roleSavedBtnPermMap: {}, // 角色已授予的按钮权限
|
|
41
|
+
checkedMenuKeys: [],
|
|
42
|
+
expandedMenuKeys: [],
|
|
43
|
+
replaceFields: {
|
|
44
|
+
children: "children",
|
|
45
|
+
title: "title",
|
|
46
|
+
},
|
|
47
|
+
permData: [],
|
|
48
|
+
treeLoading: true,
|
|
49
|
+
type: "",
|
|
50
|
+
id: "",
|
|
51
|
+
visible: false,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
computed: {},
|
|
55
|
+
methods: {
|
|
56
|
+
resetBtnPerData() {
|
|
57
|
+
this.roleSavedBtnPermMap = {};
|
|
58
|
+
this.unCheckedMenuTreeData = {};
|
|
59
|
+
this.roleMenuData = {};
|
|
60
|
+
this.curWindowBtnList = [];
|
|
61
|
+
this.saveWinBtnList = [];
|
|
62
|
+
},
|
|
63
|
+
async submitPermEdit() {
|
|
64
|
+
let curVm = this;
|
|
65
|
+
this.submitPermLoading = true;
|
|
66
|
+
let permMenuIds = this.checkedMenuKeys.join(",");
|
|
67
|
+
// // 所有菜单窗口按钮
|
|
68
|
+
let permMenuBtnIds = {};
|
|
69
|
+
Object.keys(this.roleSavedBtnPermMap).forEach(function (key) {
|
|
70
|
+
permMenuBtnIds["W_" + key] = curVm.roleSavedBtnPermMap[key];
|
|
71
|
+
});
|
|
72
|
+
saTenantSetMenus({
|
|
73
|
+
roleId: this.tenantInfo.adRoleId,
|
|
74
|
+
ids: permMenuIds,
|
|
75
|
+
btns: JSON.stringify(permMenuBtnIds),
|
|
76
|
+
adClientId: this.tenantInfo.adClientId,
|
|
77
|
+
adOrgId: this.tenantInfo.adOrgId,
|
|
78
|
+
}).then((res) => {
|
|
79
|
+
this.submitPermLoading = false;
|
|
80
|
+
if (res.data.result) {
|
|
81
|
+
this.$message.success("操作成功");
|
|
82
|
+
this.permModalVisible = false;
|
|
83
|
+
this.cancel();
|
|
84
|
+
} else {
|
|
85
|
+
this.$message.error(res.data.msg);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
getRoleWindowButton(roleId) {
|
|
90
|
+
saTenantGetRoleWindowButton({ adRoleId: roleId }).then((res) => {
|
|
91
|
+
if (res.data.data) {
|
|
92
|
+
let data = res.data.data;
|
|
93
|
+
let roleBtnPermMap = {};
|
|
94
|
+
data.forEach(function (e) {
|
|
95
|
+
if (!roleBtnPermMap[e.sysWindowId]) {
|
|
96
|
+
roleBtnPermMap[e.sysWindowId] = [];
|
|
97
|
+
}
|
|
98
|
+
roleBtnPermMap[e.sysWindowId].push(e.sysWindowButtonId);
|
|
99
|
+
});
|
|
100
|
+
this.roleSavedBtnPermMap = roleBtnPermMap;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
cancel() {
|
|
105
|
+
this.resetBtnPerData();
|
|
106
|
+
this.visible = false;
|
|
107
|
+
this.$emit("getinfo");
|
|
108
|
+
},
|
|
109
|
+
getById: async function (id) {
|
|
110
|
+
let param = {
|
|
111
|
+
adClientId: id,
|
|
112
|
+
};
|
|
113
|
+
let data;
|
|
114
|
+
await saTenantGetById(param).then((res) => {
|
|
115
|
+
if (res.data.data) {
|
|
116
|
+
data = res.data.data;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return data;
|
|
120
|
+
},
|
|
121
|
+
getRoleMenus: async function (roleId) {
|
|
122
|
+
// 请求角色菜单数据
|
|
123
|
+
let roleMenuData = [];
|
|
124
|
+
let that = this;
|
|
125
|
+
this.expandedMenuKeys.clear();
|
|
126
|
+
this.checkedMenuKeys.clear();
|
|
127
|
+
|
|
128
|
+
await saTenantGetRoleMenus({ adRoleId: roleId }).then((res) => {
|
|
129
|
+
if (res.data.result) {
|
|
130
|
+
res.data.data.forEach(function (e) {
|
|
131
|
+
if (e.MENU_TYPE !== "GROUP") {
|
|
132
|
+
roleMenuData[e.AD_MENU_ID] = e;
|
|
133
|
+
that.checkedMenuKeys.push(e.AD_MENU_ID);
|
|
134
|
+
} else {
|
|
135
|
+
that.expandedMenuKeys.push(e.AD_MENU_ID);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
return roleMenuData;
|
|
141
|
+
},
|
|
142
|
+
initMenu(roleMenuData) {
|
|
143
|
+
let curVm = this;
|
|
144
|
+
saTenantGetMenuList().then((res) => {
|
|
145
|
+
if (res.data.data) {
|
|
146
|
+
let newTreeData = [];
|
|
147
|
+
let data = res.data.data;
|
|
148
|
+
data.forEach(function (e) {
|
|
149
|
+
newTreeData.push(curVm.parseTreeData(e, 0));
|
|
150
|
+
});
|
|
151
|
+
this.calNewTreeData(newTreeData, roleMenuData);
|
|
152
|
+
|
|
153
|
+
curVm.permData = newTreeData;
|
|
154
|
+
curVm.treeLoading = false;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
// 递归标记是否选中
|
|
159
|
+
calNewTreeData(newTreeData, roleMenuData) {
|
|
160
|
+
let curVm = this;
|
|
161
|
+
newTreeData.forEach(function (e) {
|
|
162
|
+
let checkedCount = 0;
|
|
163
|
+
e.expand = true;
|
|
164
|
+
|
|
165
|
+
// 判断是否选中
|
|
166
|
+
if (roleMenuData[e.adMenuId]) {
|
|
167
|
+
e.checked = true;
|
|
168
|
+
checkedCount++;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (e.children && e.children.length > 0) {
|
|
172
|
+
let sonCheckedCount = curVm.calNewTreeData(e.children, roleMenuData);
|
|
173
|
+
// 判断父节点是否选中
|
|
174
|
+
if (sonCheckedCount === e.children.length) {
|
|
175
|
+
e.checked = true;
|
|
176
|
+
e.selectable = true;
|
|
177
|
+
e.indeterminate = false;
|
|
178
|
+
} else if (sonCheckedCount > 0 && sonCheckedCount < e.children.length) {
|
|
179
|
+
e.indeterminate = true;
|
|
180
|
+
e.checked = false;
|
|
181
|
+
e.selectable = true;
|
|
182
|
+
} else {
|
|
183
|
+
e.checked = false;
|
|
184
|
+
e.indeterminate = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return checkedCount;
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
selectTree(v, cv) {
|
|
191
|
+
// 菜单选择框不变
|
|
192
|
+
cv.checked = cv.selected;
|
|
193
|
+
if (v.length > 0) {
|
|
194
|
+
this.curSelectedMenuId = cv.selectedNodes[0].data.props.data.sysWindowId;
|
|
195
|
+
if (!this.curSelectedMenuId) {
|
|
196
|
+
this.curWindowBtnList = [];
|
|
197
|
+
// 加载角色已授权的按钮
|
|
198
|
+
this.saveWinBtnList = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 加载目录树
|
|
203
|
+
saTenantGetMenuWindowButton({ sysWindowId: this.curSelectedMenuId }).then((res) => {
|
|
204
|
+
let { result, data } = res.data;
|
|
205
|
+
if (result && data) {
|
|
206
|
+
let roleBtnData = [];
|
|
207
|
+
let tempQyBtnData = [];
|
|
208
|
+
data.forEach((tData) => {
|
|
209
|
+
if (tData.TYPE === "QY") {
|
|
210
|
+
roleBtnData.push(tData);
|
|
211
|
+
tempQyBtnData[tData.ID] = [];
|
|
212
|
+
} else {
|
|
213
|
+
if (tempQyBtnData[tData.PARENT_ID]) {
|
|
214
|
+
tempQyBtnData[tData.PARENT_ID].push(tData);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
roleBtnData.forEach((item) => {
|
|
219
|
+
item["childs"] = tempQyBtnData[item.ID];
|
|
220
|
+
// e['checkAll'] = false
|
|
221
|
+
let checkChilds = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
222
|
+
let tcount = 0;
|
|
223
|
+
tempQyBtnData[item.ID].forEach((es) => {
|
|
224
|
+
if (checkChilds.includes(es.ID)) {
|
|
225
|
+
tcount++;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
if (tcount === tempQyBtnData[item.ID].length) {
|
|
229
|
+
item["checkAll"] = true;
|
|
230
|
+
item["indeterminate"] = false;
|
|
231
|
+
} else if (tcount > 0) {
|
|
232
|
+
item["checkAll"] = false;
|
|
233
|
+
item["indeterminate"] = true;
|
|
234
|
+
} else {
|
|
235
|
+
item["checkAll"] = false;
|
|
236
|
+
item["indeterminate"] = false;
|
|
237
|
+
}
|
|
238
|
+
item["checkChilds"] = checkChilds;
|
|
239
|
+
});
|
|
240
|
+
this.curWindowBtnList = roleBtnData;
|
|
241
|
+
// 加载角色已授权的按钮
|
|
242
|
+
this.saveWinBtnList = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
checkedMenuTree(v, cv) {
|
|
248
|
+
if (cv.menuType !== "GROUP") {
|
|
249
|
+
if (!cv.checked) {
|
|
250
|
+
if (!this.unCheckedMenuTreeData[cv.adMenuId]) {
|
|
251
|
+
this.unCheckedMenuTreeData[cv.adMenuId] = "1";
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
delete this.unCheckedMenuTreeData[cv.adMenuId];
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
this.getTreeCheckedDataLoop(cv, !cv.checked);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
getTreeCheckedDataLoop(cv, delFlag) {
|
|
261
|
+
let curVm = this;
|
|
262
|
+
if (delFlag) {
|
|
263
|
+
if (!this.unCheckedMenuTreeData[cv.adMenuId]) {
|
|
264
|
+
this.unCheckedMenuTreeData[cv.adMenuId] = "1";
|
|
265
|
+
}
|
|
266
|
+
if (cv.children && cv.children.length > 0) {
|
|
267
|
+
cv.children.forEach(function (ss) {
|
|
268
|
+
curVm.getTreeCheckedDataLoop(ss, delFlag);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
delete this.unCheckedMenuTreeData[cv.adMenuId];
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
renderContent(h, { root, node, data }) {
|
|
276
|
+
let icon = "";
|
|
277
|
+
if (data.level === 0) {
|
|
278
|
+
icon = "ios-navigate";
|
|
279
|
+
} else if (data.level === 1) {
|
|
280
|
+
icon = "md-list-box";
|
|
281
|
+
} else if (data.level === 2) {
|
|
282
|
+
icon = "md-list";
|
|
283
|
+
} else if (data.level === 3) {
|
|
284
|
+
icon = "md-radio-button-on";
|
|
285
|
+
} else {
|
|
286
|
+
icon = "md-radio-button-off";
|
|
287
|
+
}
|
|
288
|
+
return h(
|
|
289
|
+
"span",
|
|
290
|
+
{
|
|
291
|
+
style: {
|
|
292
|
+
display: "inline-block",
|
|
293
|
+
cursor: "pointer",
|
|
294
|
+
},
|
|
295
|
+
on: {
|
|
296
|
+
click: () => {
|
|
297
|
+
data.checked = data.selected;
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
[
|
|
302
|
+
h("span", [
|
|
303
|
+
h("Icon", {
|
|
304
|
+
props: {
|
|
305
|
+
type: icon,
|
|
306
|
+
size: "16",
|
|
307
|
+
},
|
|
308
|
+
style: {
|
|
309
|
+
"margin-right": "8px",
|
|
310
|
+
"margin-bottom": "3px",
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
h("span", data.title),
|
|
314
|
+
]),
|
|
315
|
+
]
|
|
316
|
+
);
|
|
317
|
+
},
|
|
318
|
+
handleCheckAll(event, item, key) {
|
|
319
|
+
let checkChilds = [];
|
|
320
|
+
if (item.checkAll && (!item.indeterminate || item.indeterminate)) {
|
|
321
|
+
// 已经全选取消全选状态
|
|
322
|
+
item.checkAll = false;
|
|
323
|
+
item.indeterminate = false;
|
|
324
|
+
item.checkChilds = checkChilds;
|
|
325
|
+
} else {
|
|
326
|
+
// 不是全选状态,获取所有ids,并设定全选状态相关参数
|
|
327
|
+
checkChilds = item.childs.map((item) => item.ID);
|
|
328
|
+
item.checkAll = true;
|
|
329
|
+
item.indeterminate = false;
|
|
330
|
+
item.checkChilds = checkChilds;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 状态设置完成,将数据赋值到 响应对象上去
|
|
334
|
+
this.$set(this.roleSavedBtnPermMap, this.curSelectedMenuId, checkChilds);
|
|
335
|
+
this.$set(this.curWindowBtnList, key, item);
|
|
336
|
+
},
|
|
337
|
+
checkAllGroupChange(event, key) {
|
|
338
|
+
let list = deepClone({}, this.curWindowBtnList);
|
|
339
|
+
let currentItem = list[key];
|
|
340
|
+
if (event.length > 0) {
|
|
341
|
+
// 判断是否存在值
|
|
342
|
+
let containFlag = 0; // 0 不包含 1 部分包括 2 全包括
|
|
343
|
+
let okCount = 0; // 统计包括次数
|
|
344
|
+
for (let i = 0; i < currentItem.childs.length; i++) {
|
|
345
|
+
if (event.includes(currentItem.childs[i].ID)) {
|
|
346
|
+
okCount++;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (okCount === currentItem.childs.length) {
|
|
350
|
+
containFlag = 2;
|
|
351
|
+
} else {
|
|
352
|
+
containFlag = 1;
|
|
353
|
+
}
|
|
354
|
+
// 判断是否选中
|
|
355
|
+
if (containFlag === 1) {
|
|
356
|
+
currentItem.checkAll = false;
|
|
357
|
+
if (okCount === 0) {
|
|
358
|
+
currentItem.indeterminate = false;
|
|
359
|
+
} else {
|
|
360
|
+
currentItem.indeterminate = true;
|
|
361
|
+
}
|
|
362
|
+
} else if (containFlag === 2) {
|
|
363
|
+
currentItem.checkAll = true;
|
|
364
|
+
currentItem.indeterminate = false;
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
currentItem.checkAll = false;
|
|
368
|
+
currentItem.indeterminate = false;
|
|
369
|
+
}
|
|
370
|
+
currentItem.checkChilds = event;
|
|
371
|
+
this.$set(this.curWindowBtnList, key, currentItem);
|
|
372
|
+
this.roleSavedBtnPermMap[this.curSelectedMenuId] = event;
|
|
373
|
+
},
|
|
374
|
+
doWinBtnData(doType, btnId) {
|
|
375
|
+
if (!this.saveWinBtnList) {
|
|
376
|
+
this.saveWinBtnList = [];
|
|
377
|
+
}
|
|
378
|
+
if (doType === "add") {
|
|
379
|
+
if (this.saveWinBtnList.length !== 0) {
|
|
380
|
+
for (let i = 0; i < this.saveWinBtnList.length; i++) {
|
|
381
|
+
if (this.saveWinBtnList[i] === btnId) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
this.saveWinBtnList.push(btnId);
|
|
387
|
+
} else {
|
|
388
|
+
for (let i = 0; i < this.saveWinBtnList.length; i++) {
|
|
389
|
+
if (this.saveWinBtnList[i] === btnId) {
|
|
390
|
+
this.saveWinBtnList.splice(i, 1);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
parseTreeData(curLevelData, curLevel) {
|
|
397
|
+
let curVm = this;
|
|
398
|
+
let newLevelData = { data: curLevelData };
|
|
399
|
+
newLevelData["key"] = curLevelData.adMenuId;
|
|
400
|
+
newLevelData["title"] = curLevelData.name;
|
|
401
|
+
|
|
402
|
+
if (curLevelData._childs && curLevelData._childs.length > 0) {
|
|
403
|
+
curLevelData._childs.forEach(function (sonTreeData) {
|
|
404
|
+
if (!newLevelData.children) {
|
|
405
|
+
newLevelData.children = [];
|
|
406
|
+
}
|
|
407
|
+
newLevelData.children.push(curVm.parseTreeData(sonTreeData, curLevel + 1));
|
|
408
|
+
});
|
|
409
|
+
newLevelData["isLeaf"] = false;
|
|
410
|
+
} else {
|
|
411
|
+
newLevelData["isLeaf"] = true;
|
|
412
|
+
}
|
|
413
|
+
delete curLevelData._childs;
|
|
414
|
+
return newLevelData;
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
};
|