yh-pub 1.0.0
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 -0
- package/layout/admin/adminIndex.vue +104 -0
- package/layout/admin/api/loginApi.js +24 -0
- package/layout/admin/api/routers.js +93 -0
- package/layout/admin/api/tenantApi.js +123 -0
- package/layout/admin/home/homeIndex.vue +25 -0
- package/layout/admin/login/login.vue +161 -0
- package/layout/admin/menu/MenuIndex.vue +648 -0
- package/layout/admin/menu/icon.vue +108 -0
- package/layout/admin/menu/iconList.js +934 -0
- package/layout/admin/saTenant/saTenant.js +0 -0
- package/layout/admin/saTenant/saTenant.vue +173 -0
- package/layout/admin/saTenant/saTenantForm.js +80 -0
- package/layout/admin/saTenant/saTenantForm.vue +61 -0
- package/layout/admin/saTenant/saTenantRoleManage.js +417 -0
- package/layout/admin/saTenant/saTenantRoleManage.vue +99 -0
- package/layout/admin/user/saUser.less +6 -0
- package/layout/admin/user/saUser.vue +72 -0
- package/layout/main/components/console/console.vue +205 -0
- package/layout/main/components/error-store/error-store.vue +72 -0
- package/layout/main/components/error-store/index.js +2 -0
- package/layout/main/components/fullscreen/fullscreen.vue +57 -0
- package/layout/main/components/fullscreen/index.js +2 -0
- package/layout/main/components/language/language.vue +71 -0
- package/layout/main/components/side-menu/side-menu.less +74 -0
- package/layout/main/components/side-menu/side-menu.vue +75 -0
- package/layout/main/components/tags-nav/tags-nav.less +45 -0
- package/layout/main/components/tags-nav/tags-nav.vue +144 -0
- package/layout/main/components/user/user.less +12 -0
- package/layout/main/components/user/user.vue +185 -0
- package/layout/main/home/home.vue +480 -0
- package/layout/main/home/index.js +2 -0
- package/layout/main/home/toDoList.vue +32 -0
- package/layout/main/login/login.less +93 -0
- package/layout/main/login/login.vue +151 -0
- package/layout/main/main.less +81 -0
- package/layout/main/main.vue +202 -0
- package/layout/main/system/dict.vue +64 -0
- package/layout/main/system/orgManage.vue +473 -0
- package/layout/main/system/roleManage.js +755 -0
- package/layout/main/system/roleManage.vue +399 -0
- package/package.json +12 -0
- package/view/basic/error-logger.vue +74 -0
- package/view/basic/error-page/401.vue +22 -0
- package/view/basic/error-page/404.vue +22 -0
- package/view/basic/error-page/500.vue +22 -0
- package/view/basic/error-page/back-btn-group.vue +48 -0
- package/view/basic/error-page/error-content.vue +28 -0
- package/view/basic/error-page/error.less +46 -0
- package/view/config/component/confFormItem.vue +49 -0
- package/view/config/config.scss +45 -0
- package/view/config/configIndex.vue +150 -0
- package/view/config/subPage/router-config.vue +5 -0
- package/view/config/subPage/sys-config.vue +249 -0
- package/view/window/IframeFReportView.vue +28 -0
- package/view/window/windowIndex.vue +22 -0
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import dict from "yh-pub/layout/main/system/dict.vue";
|
|
2
|
+
import { deepClone } from "@/libs/util";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
name: "role-manage",
|
|
6
|
+
components: {
|
|
7
|
+
dict,
|
|
8
|
+
},
|
|
9
|
+
data() {
|
|
10
|
+
return {
|
|
11
|
+
maxHeight: 510,
|
|
12
|
+
openTip: false,
|
|
13
|
+
loading: true,
|
|
14
|
+
treeLoading: true,
|
|
15
|
+
submitPermLoading: false,
|
|
16
|
+
submitDepLoading: false,
|
|
17
|
+
searchKey: "",
|
|
18
|
+
modalType: 0,
|
|
19
|
+
roleModalVisible: false,
|
|
20
|
+
roleOrgData: {},
|
|
21
|
+
permModalVisible: false,
|
|
22
|
+
orgModalVisible: false,
|
|
23
|
+
orgData: [],
|
|
24
|
+
modalTitle: "",
|
|
25
|
+
searchForm: {
|
|
26
|
+
// 搜索框初始化对象
|
|
27
|
+
pageNumber: 1, // 当前页数
|
|
28
|
+
pageSize: 10, // 页面大小
|
|
29
|
+
sort: "createTime", // 默认排序字段
|
|
30
|
+
order: "desc", // 默认排序方式
|
|
31
|
+
key: "",
|
|
32
|
+
},
|
|
33
|
+
roleForm: {
|
|
34
|
+
ad_org_id: "",
|
|
35
|
+
name: "",
|
|
36
|
+
isAdmin: "",
|
|
37
|
+
description: "",
|
|
38
|
+
ad_role_id: "",
|
|
39
|
+
},
|
|
40
|
+
roleFormValidate: {
|
|
41
|
+
ad_org_id: [{ required: true, message: "组织机构不能为空", trigger: "change" }],
|
|
42
|
+
name: [{ required: true, message: "角色名称不能为空", trigger: "change" }],
|
|
43
|
+
},
|
|
44
|
+
submitLoading: false,
|
|
45
|
+
selectList: [],
|
|
46
|
+
columns: [
|
|
47
|
+
{
|
|
48
|
+
title: "所属机构",
|
|
49
|
+
dataIndex: "org_name",
|
|
50
|
+
width: 150,
|
|
51
|
+
sortable: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: "角色名称",
|
|
55
|
+
dataIndex: "name",
|
|
56
|
+
width: 300,
|
|
57
|
+
sortable: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: "备注",
|
|
61
|
+
dataIndex: "description",
|
|
62
|
+
minWidth: 200,
|
|
63
|
+
sortable: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
title: "操作",
|
|
67
|
+
dataIndex: "action",
|
|
68
|
+
fixed: "right",
|
|
69
|
+
width: 280,
|
|
70
|
+
scopedSlots: { customRender: "action", title: "操作" },
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
data: [],
|
|
74
|
+
listLoading: false,
|
|
75
|
+
pagination: { currentPage: 1, pageSize: 15, total: 0 },
|
|
76
|
+
permData: [],
|
|
77
|
+
editRolePermId: "",
|
|
78
|
+
selectAllFlag: false,
|
|
79
|
+
dataType: 0,
|
|
80
|
+
indeterminate: false,
|
|
81
|
+
checkAll: false,
|
|
82
|
+
checkAllGroup: [],
|
|
83
|
+
curWindowBtnList: [],
|
|
84
|
+
saveWinBtnList: [],
|
|
85
|
+
roleSavedBtnPermMap: {}, // 角色已授予的按钮权限
|
|
86
|
+
curSelectedMenuId: "", // 当前选中目录ID
|
|
87
|
+
selectedKeys: [],
|
|
88
|
+
selectedNodes: [],
|
|
89
|
+
halfSelectedNodes: [],
|
|
90
|
+
deptCheckedKeys: [],
|
|
91
|
+
timer: null,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
methods: {
|
|
95
|
+
init() {
|
|
96
|
+
this.getDataList();
|
|
97
|
+
},
|
|
98
|
+
parseOrgTreeData(curLevelData, curLevel, roleOrgData) {
|
|
99
|
+
let curVm = this;
|
|
100
|
+
let newLevelData = curLevelData;
|
|
101
|
+
newLevelData.key = curLevelData.adOrgId;
|
|
102
|
+
newLevelData.title = curLevelData.name;
|
|
103
|
+
if (roleOrgData[curLevelData.adOrgId]) {
|
|
104
|
+
if (roleOrgData[curLevelData.adOrgId].isOrgAdmin === "Y") {
|
|
105
|
+
this.deptCheckedKeys.push(curLevelData.adOrgId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
newLevelData["level"] = curLevel;
|
|
109
|
+
if (curLevelData["_childs"] && curLevelData["_childs"].length > 0) {
|
|
110
|
+
curLevelData["_childs"].forEach(function (sonTreeData) {
|
|
111
|
+
if (!newLevelData.children) {
|
|
112
|
+
newLevelData.children = [];
|
|
113
|
+
}
|
|
114
|
+
newLevelData.children.push(curVm.parseOrgTreeData(sonTreeData, curLevel + 1, roleOrgData));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return newLevelData;
|
|
118
|
+
},
|
|
119
|
+
async loadRoleOrg() {
|
|
120
|
+
let roleOrgData = {};
|
|
121
|
+
// 请求系统数据
|
|
122
|
+
this.axios
|
|
123
|
+
.post(
|
|
124
|
+
"/roleController/getRoleOrgAccess",
|
|
125
|
+
this.$qs.stringify({
|
|
126
|
+
roleId: this.editRolePermId,
|
|
127
|
+
})
|
|
128
|
+
)
|
|
129
|
+
.then((response) => {
|
|
130
|
+
if (response.data.result) {
|
|
131
|
+
if (response.data.roleOrgAccess) {
|
|
132
|
+
response.data.roleOrgAccess.forEach(function (sd) {
|
|
133
|
+
roleOrgData[sd.orgId] = sd;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return roleOrgData;
|
|
139
|
+
},
|
|
140
|
+
async editOrg(v) {
|
|
141
|
+
this.editRolePermId = v.ad_role_id;
|
|
142
|
+
this.modalTitle = "分配 " + v.name + " 的组织机构权限";
|
|
143
|
+
let roleOrgData = await this.loadRoleOrg();
|
|
144
|
+
this.roleOrgData = roleOrgData;
|
|
145
|
+
// 请求系统数据
|
|
146
|
+
this.axios.post("/orgController/getOrgData", this.$qs.stringify({})).then((response) => {
|
|
147
|
+
if (response.data.result) {
|
|
148
|
+
let newTreeData = [];
|
|
149
|
+
this.deptCheckedKeys = [];
|
|
150
|
+
response.data.orgList.forEach((e) => {
|
|
151
|
+
newTreeData.push(this.parseOrgTreeData(e, 0, roleOrgData));
|
|
152
|
+
});
|
|
153
|
+
this.orgData = newTreeData;
|
|
154
|
+
this.$nextTick(() => {
|
|
155
|
+
this.$refs.depTree.setCheckedKeys(this.deptCheckedKeys);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
this.orgModalVisible = true;
|
|
160
|
+
},
|
|
161
|
+
checkOrgTree() {
|
|
162
|
+
if (this.timer) {
|
|
163
|
+
clearTimeout(this.timer);
|
|
164
|
+
}
|
|
165
|
+
this.timer = setTimeout(() => {
|
|
166
|
+
this.deptCheckedKeys = this.$refs.depTree.getCheckedKeys();
|
|
167
|
+
}, 300);
|
|
168
|
+
},
|
|
169
|
+
submitRoleOrg() {
|
|
170
|
+
let selectedNodes = this.$refs.depTree.getCheckedKeys() || [];
|
|
171
|
+
let curVm = this;
|
|
172
|
+
let subRoleOrgData = [];
|
|
173
|
+
// 判断已提交角色机构数据
|
|
174
|
+
selectedNodes.forEach(function (e) {
|
|
175
|
+
subRoleOrgData.push({ ad_org_id: e, is_org_admin: "Y" });
|
|
176
|
+
});
|
|
177
|
+
this.axios
|
|
178
|
+
.post(
|
|
179
|
+
"/roleController/saveRoleOrgAccess",
|
|
180
|
+
this.$qs.stringify({
|
|
181
|
+
roleId: curVm.editRolePermId,
|
|
182
|
+
subJsonData: JSON.stringify(subRoleOrgData),
|
|
183
|
+
})
|
|
184
|
+
)
|
|
185
|
+
.then((response) => {
|
|
186
|
+
if (response.data.result) {
|
|
187
|
+
curVm.$message.success(response.data.msg);
|
|
188
|
+
} else {
|
|
189
|
+
curVm.$message.error(response.data.msg);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
this.orgModalVisible = false;
|
|
193
|
+
},
|
|
194
|
+
renderContent(h, { root, node, data }) {
|
|
195
|
+
let icon = "";
|
|
196
|
+
if (data.level === 0) {
|
|
197
|
+
icon = "ios-navigate";
|
|
198
|
+
} else if (data.level === 1) {
|
|
199
|
+
icon = "md-list-box";
|
|
200
|
+
} else if (data.level === 2) {
|
|
201
|
+
icon = "md-list";
|
|
202
|
+
} else if (data.level === 3) {
|
|
203
|
+
icon = "md-radio-button-on";
|
|
204
|
+
} else {
|
|
205
|
+
icon = "md-radio-button-off";
|
|
206
|
+
}
|
|
207
|
+
return h(
|
|
208
|
+
"span",
|
|
209
|
+
{
|
|
210
|
+
style: {
|
|
211
|
+
display: "inline-block",
|
|
212
|
+
cursor: "pointer",
|
|
213
|
+
},
|
|
214
|
+
on: {
|
|
215
|
+
click: () => {
|
|
216
|
+
data.checked = !data.checked;
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
[
|
|
221
|
+
h("span", [
|
|
222
|
+
h("Icon", {
|
|
223
|
+
props: {
|
|
224
|
+
type: icon,
|
|
225
|
+
size: "16",
|
|
226
|
+
},
|
|
227
|
+
style: {
|
|
228
|
+
"margin-right": "8px",
|
|
229
|
+
"margin-bottom": "3px",
|
|
230
|
+
},
|
|
231
|
+
}),
|
|
232
|
+
h("span", data.title),
|
|
233
|
+
]),
|
|
234
|
+
]
|
|
235
|
+
);
|
|
236
|
+
},
|
|
237
|
+
checkedMenuTree() {
|
|
238
|
+
if (this.timer) {
|
|
239
|
+
clearTimeout(this.timer);
|
|
240
|
+
}
|
|
241
|
+
this.timer = setTimeout(() => {
|
|
242
|
+
this.selectedNodes = this.$refs.tree.getCheckedKeys(true);
|
|
243
|
+
this.halfSelectedNodes = this.$refs.tree.getHalfCheckedKeys(true);
|
|
244
|
+
}, 300);
|
|
245
|
+
},
|
|
246
|
+
selectTree(data, node) {
|
|
247
|
+
if (data) {
|
|
248
|
+
this.curSelectedMenuId = data.sysWindowId;
|
|
249
|
+
// 加载目录树
|
|
250
|
+
this.axios
|
|
251
|
+
.post("/rolePermissionsSetting/getMenuWindowButton", { windowId: this.curSelectedMenuId })
|
|
252
|
+
.then((response) => {
|
|
253
|
+
let { result, data } = response.data;
|
|
254
|
+
if (result && data) {
|
|
255
|
+
let roleBtnData = [];
|
|
256
|
+
let tempQyBtnData = [];
|
|
257
|
+
data.forEach((tData) => {
|
|
258
|
+
if (tData.TYPE === "QY") {
|
|
259
|
+
roleBtnData.push(tData);
|
|
260
|
+
tempQyBtnData[tData.ID] = [];
|
|
261
|
+
} else {
|
|
262
|
+
if (tempQyBtnData[tData.PARENT_ID]) {
|
|
263
|
+
tempQyBtnData[tData.PARENT_ID].push(tData);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
roleBtnData.forEach((item) => {
|
|
268
|
+
item["childs"] = tempQyBtnData[item.ID];
|
|
269
|
+
// e['checkAll'] = false
|
|
270
|
+
let checkChilds = this.roleSavedBtnPermMap[this.curSelectedMenuId] || [];
|
|
271
|
+
let tcount = 0;
|
|
272
|
+
tempQyBtnData[item.ID].forEach((es) => {
|
|
273
|
+
if (checkChilds.includes(es.ID)) {
|
|
274
|
+
tcount++;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
if (tcount === tempQyBtnData[item.ID].length) {
|
|
278
|
+
item["checkAll"] = true;
|
|
279
|
+
item["indeterminate"] = false;
|
|
280
|
+
} else if (tcount > 0) {
|
|
281
|
+
item["checkAll"] = false;
|
|
282
|
+
item["indeterminate"] = true;
|
|
283
|
+
} else {
|
|
284
|
+
item["checkAll"] = false;
|
|
285
|
+
item["indeterminate"] = false;
|
|
286
|
+
}
|
|
287
|
+
item["checkChilds"] = checkChilds;
|
|
288
|
+
});
|
|
289
|
+
this.curWindowBtnList = roleBtnData;
|
|
290
|
+
// 加载角色已授权的按钮
|
|
291
|
+
this.saveWinBtnList = this.roleSavedBtnPermMap[this.curSelectedMenuId];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
resetBtnPerData() {
|
|
297
|
+
this.roleSavedBtnPermMap = {};
|
|
298
|
+
this.curWindowBtnList = [];
|
|
299
|
+
this.saveWinBtnList = [];
|
|
300
|
+
},
|
|
301
|
+
doWinBtnData(doType, btnId) {
|
|
302
|
+
if (!this.saveWinBtnList) {
|
|
303
|
+
this.saveWinBtnList = [];
|
|
304
|
+
}
|
|
305
|
+
if (doType === "add") {
|
|
306
|
+
if (this.saveWinBtnList.length !== 0) {
|
|
307
|
+
for (let i = 0; i < this.saveWinBtnList.length; i++) {
|
|
308
|
+
if (this.saveWinBtnList[i] === btnId) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
this.saveWinBtnList.push(btnId);
|
|
314
|
+
} else {
|
|
315
|
+
for (let i = 0; i < this.saveWinBtnList.length; i++) {
|
|
316
|
+
if (this.saveWinBtnList[i] === btnId) {
|
|
317
|
+
this.saveWinBtnList.splice(i, 1);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
handleCheckAll(item, key) {
|
|
324
|
+
let checkChilds = [];
|
|
325
|
+
if (!item.checkAll) {
|
|
326
|
+
// 已经全选取消全选状态
|
|
327
|
+
item.checkAll = false;
|
|
328
|
+
item.indeterminate = false;
|
|
329
|
+
item.checkChilds = checkChilds;
|
|
330
|
+
} else {
|
|
331
|
+
// 不是全选状态,获取所有ids,并设定全选状态相关参数
|
|
332
|
+
checkChilds = item.childs.map((item) => item.ID);
|
|
333
|
+
item.checkAll = true;
|
|
334
|
+
item.indeterminate = false;
|
|
335
|
+
item.checkChilds = checkChilds;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// 状态设置完成,将数据赋值到 响应对象上去
|
|
339
|
+
this.updateBtnsToList();
|
|
340
|
+
this.curWindowBtnList[key] = item;
|
|
341
|
+
},
|
|
342
|
+
checkAllGroupChange(event, key) {
|
|
343
|
+
let list = deepClone({}, this.curWindowBtnList);
|
|
344
|
+
let currentItem = list[key];
|
|
345
|
+
if (event.length > 0) {
|
|
346
|
+
// 判断是否存在值
|
|
347
|
+
let containFlag = 0; // 0 不包含 1 部分包括 2 全包括
|
|
348
|
+
let okCount = 0; // 统计包括次数
|
|
349
|
+
for (var i = 0; i < currentItem.childs.length; i++) {
|
|
350
|
+
if (event.includes(currentItem.childs[i].ID)) {
|
|
351
|
+
okCount++;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (okCount === currentItem.childs.length) {
|
|
355
|
+
containFlag = 2;
|
|
356
|
+
} else {
|
|
357
|
+
containFlag = 1;
|
|
358
|
+
}
|
|
359
|
+
// 判断是否选中
|
|
360
|
+
if (containFlag === 1) {
|
|
361
|
+
currentItem.checkAll = false;
|
|
362
|
+
if (okCount === 0) {
|
|
363
|
+
currentItem.indeterminate = false;
|
|
364
|
+
} else {
|
|
365
|
+
currentItem.indeterminate = true;
|
|
366
|
+
}
|
|
367
|
+
} else if (containFlag === 2) {
|
|
368
|
+
currentItem.checkAll = true;
|
|
369
|
+
currentItem.indeterminate = false;
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
currentItem.checkAll = false;
|
|
373
|
+
currentItem.indeterminate = false;
|
|
374
|
+
}
|
|
375
|
+
currentItem.checkChilds = event;
|
|
376
|
+
this.curWindowBtnList[key] = currentItem;
|
|
377
|
+
this.updateBtnsToList();
|
|
378
|
+
},
|
|
379
|
+
updateBtnsToList() {
|
|
380
|
+
let btns = new Set();
|
|
381
|
+
this.curWindowBtnList.forEach((item) => {
|
|
382
|
+
item.checkChilds.forEach((checkId) => {
|
|
383
|
+
btns.add(checkId);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
btns = Array.from(btns);
|
|
387
|
+
this.roleSavedBtnPermMap[this.curSelectedMenuId] = btns;
|
|
388
|
+
},
|
|
389
|
+
changePage(v) {
|
|
390
|
+
this.searchForm.pageNumber = v;
|
|
391
|
+
this.getDataList();
|
|
392
|
+
this.clearSelectAll();
|
|
393
|
+
},
|
|
394
|
+
changePageSize(v) {
|
|
395
|
+
this.searchForm.pageSize = v;
|
|
396
|
+
this.getDataList();
|
|
397
|
+
},
|
|
398
|
+
changeSort(e) {
|
|
399
|
+
this.searchForm.sort = e.key;
|
|
400
|
+
this.searchForm.order = e.order;
|
|
401
|
+
if (e.order === "normal") {
|
|
402
|
+
this.searchForm.order = "";
|
|
403
|
+
}
|
|
404
|
+
this.getDataList();
|
|
405
|
+
},
|
|
406
|
+
getDataList() {
|
|
407
|
+
this.loading = true;
|
|
408
|
+
this.axios
|
|
409
|
+
.post(
|
|
410
|
+
"/roleController/getRoleList",
|
|
411
|
+
this.$qs.stringify({
|
|
412
|
+
name: this.searchForm.key,
|
|
413
|
+
pageSize: this.pagination.pageSize,
|
|
414
|
+
pageIndex: this.pagination.current,
|
|
415
|
+
})
|
|
416
|
+
)
|
|
417
|
+
.then((response) => {
|
|
418
|
+
this.loading = false;
|
|
419
|
+
if (response.data.result) {
|
|
420
|
+
this.data = response.data.data.records;
|
|
421
|
+
this.pagination.total = response.data.data.total;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
},
|
|
425
|
+
parseTreeData(curLevelData, curLevel) {
|
|
426
|
+
let newLevelData = curLevelData;
|
|
427
|
+
newLevelData["id"] = curLevelData.adMenuId;
|
|
428
|
+
newLevelData["key"] = curLevelData.adMenuId;
|
|
429
|
+
newLevelData["title"] = curLevelData.name;
|
|
430
|
+
newLevelData["expand"] = true;
|
|
431
|
+
newLevelData["checked"] = false;
|
|
432
|
+
newLevelData["level"] = curLevel;
|
|
433
|
+
if (curLevelData["_childs"] && curLevelData["_childs"].length > 0) {
|
|
434
|
+
curLevelData["_childs"].forEach((sonTreeData) => {
|
|
435
|
+
if (!newLevelData.children) {
|
|
436
|
+
newLevelData.children = [];
|
|
437
|
+
}
|
|
438
|
+
newLevelData.children.push(this.parseTreeData(sonTreeData, curLevel + 1));
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return newLevelData;
|
|
442
|
+
},
|
|
443
|
+
getRoleMenus: async function () {
|
|
444
|
+
// 请求角色菜单数据
|
|
445
|
+
let roleMenuData = [];
|
|
446
|
+
await this.axios
|
|
447
|
+
.post("/rolePermissionsSetting/getRoleMenus", this.$qs.stringify({ roleId: this.editRolePermId }))
|
|
448
|
+
.then((response) => {
|
|
449
|
+
if (response.data.result) {
|
|
450
|
+
response.data.data.forEach(function (e) {
|
|
451
|
+
roleMenuData[e.AD_MENU_ID] = e;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
})
|
|
455
|
+
.catch((e) => {
|
|
456
|
+
console.error(e);
|
|
457
|
+
});
|
|
458
|
+
return roleMenuData;
|
|
459
|
+
},
|
|
460
|
+
// 递归标记是否选中
|
|
461
|
+
calNewTreeData(newTreeData, roleMenuData) {
|
|
462
|
+
let checkedCount = 0;
|
|
463
|
+
newTreeData.forEach((e) => {
|
|
464
|
+
if (e.level === 0 || e.level === 1) {
|
|
465
|
+
e.expand = true;
|
|
466
|
+
} else {
|
|
467
|
+
e.expand = true;
|
|
468
|
+
}
|
|
469
|
+
// 判断是否选中
|
|
470
|
+
if (roleMenuData[e.adMenuId]) {
|
|
471
|
+
e.checked = true;
|
|
472
|
+
checkedCount++;
|
|
473
|
+
}
|
|
474
|
+
if (e.children && e.children.length > 0) {
|
|
475
|
+
let sonCheckedCount = this.calNewTreeData(e.children, roleMenuData);
|
|
476
|
+
// 判断父节点是否选中
|
|
477
|
+
if (sonCheckedCount === e.children.length) {
|
|
478
|
+
e.checked = true;
|
|
479
|
+
e.indeterminate = false;
|
|
480
|
+
} else if (sonCheckedCount > 0 && sonCheckedCount < e.children.length) {
|
|
481
|
+
e.indeterminate = true;
|
|
482
|
+
e.checked = false;
|
|
483
|
+
} else {
|
|
484
|
+
e.checked = false;
|
|
485
|
+
e.indeterminate = false;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (e.checked) {
|
|
489
|
+
this.halfSelectedNodes.push(e.adMenuId);
|
|
490
|
+
}
|
|
491
|
+
if (e.checked) {
|
|
492
|
+
this.selectedNodes.push(e.adMenuId);
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
if (e.checked) {
|
|
496
|
+
// console.log('checked', e.adMenuId);
|
|
497
|
+
this.selectedNodes.push(e.adMenuId);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
return checkedCount;
|
|
502
|
+
},
|
|
503
|
+
getPermList: async function () {
|
|
504
|
+
this.treeLoading = true;
|
|
505
|
+
|
|
506
|
+
this.expandedKeys = [];
|
|
507
|
+
this.selectedNodes = [];
|
|
508
|
+
|
|
509
|
+
let roleMenuData = await this.getRoleMenus();
|
|
510
|
+
this.axios.post("/rolePermissionsSetting/getMenuList", this.$qs.stringify({})).then((response) => {
|
|
511
|
+
if (response.data.result) {
|
|
512
|
+
let newTreeData = [];
|
|
513
|
+
// 仅展开指定级数 默认后端已展开所有
|
|
514
|
+
response.data.menuList.forEach((e) => {
|
|
515
|
+
newTreeData.push(this.parseTreeData(e, 0));
|
|
516
|
+
});
|
|
517
|
+
this.calNewTreeData(newTreeData, roleMenuData);
|
|
518
|
+
this.deleteDisableNode(newTreeData);
|
|
519
|
+
this.permData = newTreeData;
|
|
520
|
+
this.treeLoading = false;
|
|
521
|
+
|
|
522
|
+
this.$nextTick(() => {
|
|
523
|
+
let checked = this.selectedNodes.filter((item) => !this.halfSelectedNodes.includes(item));
|
|
524
|
+
console.log(this.selectedNodes.length, checked.length);
|
|
525
|
+
this.$refs.tree.setCheckedKeys(checked);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
this.loading = false;
|
|
529
|
+
});
|
|
530
|
+
},
|
|
531
|
+
// 递归标记禁用节点
|
|
532
|
+
deleteDisableNode(permData) {
|
|
533
|
+
let that = this;
|
|
534
|
+
permData.forEach(function (e) {
|
|
535
|
+
if (e.status === -1) {
|
|
536
|
+
e.title = "[已禁用] " + e.title;
|
|
537
|
+
e.disabled = true;
|
|
538
|
+
}
|
|
539
|
+
if (e.children && e.children.length > 0) {
|
|
540
|
+
that.deleteDisableNode(e.children);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
},
|
|
544
|
+
cancelRole() {
|
|
545
|
+
this.roleModalVisible = false;
|
|
546
|
+
},
|
|
547
|
+
submitRole() {
|
|
548
|
+
let that = this;
|
|
549
|
+
let subForm = {
|
|
550
|
+
orgId: this.roleForm.ad_org_id,
|
|
551
|
+
adRoleId: this.roleForm.ad_role_id,
|
|
552
|
+
name: this.roleForm.name,
|
|
553
|
+
description: this.roleForm.description,
|
|
554
|
+
isAdmin: this.roleForm.isAdmin,
|
|
555
|
+
};
|
|
556
|
+
this.$refs.roleForm.validate((valid) => {
|
|
557
|
+
if (valid) {
|
|
558
|
+
this.submitLoading = true;
|
|
559
|
+
this.axios.post("/roleController/submitRole", this.$qs.stringify(subForm)).then((response) => {
|
|
560
|
+
that.submitLoading = false;
|
|
561
|
+
if (response.data.result) {
|
|
562
|
+
that.$message.success("操作成功");
|
|
563
|
+
that.getDataList();
|
|
564
|
+
that.roleModalVisible = false;
|
|
565
|
+
} else {
|
|
566
|
+
that.$message.error(response.data.msg);
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
},
|
|
572
|
+
addRole() {
|
|
573
|
+
// 处理状态
|
|
574
|
+
this.modalType = 0;
|
|
575
|
+
this.modalTitle = "添加角色";
|
|
576
|
+
// 清理表单
|
|
577
|
+
this.roleForm.ad_role_id = undefined;
|
|
578
|
+
this.roleForm.name = "";
|
|
579
|
+
this.roleForm.isAdmin = "N";
|
|
580
|
+
this.roleForm.description = "";
|
|
581
|
+
this.roleForm.ad_role_id = "";
|
|
582
|
+
// 显示弹窗
|
|
583
|
+
this.roleModalVisible = true;
|
|
584
|
+
},
|
|
585
|
+
edit(v) {
|
|
586
|
+
// 处理状态
|
|
587
|
+
this.modalType = 1;
|
|
588
|
+
this.modalTitle = "编辑角色";
|
|
589
|
+
// 填充表单
|
|
590
|
+
this.roleForm.ad_org_id = v.ad_org_id;
|
|
591
|
+
this.roleForm.name = v.name;
|
|
592
|
+
this.roleForm.isAdmin = v.is_admin == "Y";
|
|
593
|
+
this.roleForm.description = v.description;
|
|
594
|
+
this.roleForm.ad_role_id = v.ad_role_id;
|
|
595
|
+
// 显示弹窗
|
|
596
|
+
this.roleModalVisible = true;
|
|
597
|
+
},
|
|
598
|
+
deleteRole(delId) {
|
|
599
|
+
this.axios
|
|
600
|
+
.post(
|
|
601
|
+
"/roleController/delRoleByIds",
|
|
602
|
+
this.$qs.stringify({
|
|
603
|
+
ids: delId,
|
|
604
|
+
})
|
|
605
|
+
)
|
|
606
|
+
.then((response) => {
|
|
607
|
+
if (response.data.result) {
|
|
608
|
+
this.$message.success("删除成功");
|
|
609
|
+
this.clearSelectAll();
|
|
610
|
+
this.getDataList();
|
|
611
|
+
} else {
|
|
612
|
+
this.$message.success("删除失败");
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
},
|
|
616
|
+
remove(v) {
|
|
617
|
+
if (v && v.ad_role_id) {
|
|
618
|
+
this.deleteRole(v.ad_role_id);
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
clearSelectAll() {
|
|
622
|
+
this.selectList = [];
|
|
623
|
+
},
|
|
624
|
+
changeSelect(e) {
|
|
625
|
+
this.selectList = e;
|
|
626
|
+
},
|
|
627
|
+
delAll() {
|
|
628
|
+
if (this.selectList.length <= 0) {
|
|
629
|
+
this.$message.warning("您还未选择要删除的数据");
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
let ids = this.selectList.join(",");
|
|
633
|
+
// 删除按钮代码
|
|
634
|
+
this.deleteRole(ids);
|
|
635
|
+
},
|
|
636
|
+
editPerm(v) {
|
|
637
|
+
this.editRolePermId = v.ad_role_id;
|
|
638
|
+
// 获取所有菜单权限树
|
|
639
|
+
this.getPermList();
|
|
640
|
+
this.modalTitle = "分配 " + v.name + " 的菜单权限";
|
|
641
|
+
// 递归判断子节点
|
|
642
|
+
this.checkPermTree(this.permData, []);
|
|
643
|
+
// 加载所有已授予的按钮权限
|
|
644
|
+
this.axios
|
|
645
|
+
.post("/roleController/getRoleWindowButton", this.$qs.stringify({ roleId: this.editRolePermId }))
|
|
646
|
+
.then((response) => {
|
|
647
|
+
if (response.data.result && response.data.data) {
|
|
648
|
+
let roleBtnPermMap = {};
|
|
649
|
+
response.data.data.forEach(function (e) {
|
|
650
|
+
if (!roleBtnPermMap[e.WINDOW_ID]) {
|
|
651
|
+
roleBtnPermMap[e.WINDOW_ID] = [];
|
|
652
|
+
}
|
|
653
|
+
roleBtnPermMap[e.WINDOW_ID].push(e.BUTTON_ID);
|
|
654
|
+
});
|
|
655
|
+
this.roleSavedBtnPermMap = roleBtnPermMap;
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
this.permModalVisible = true;
|
|
659
|
+
},
|
|
660
|
+
// 递归判断子节点
|
|
661
|
+
checkPermTree(permData, rolePerms) {
|
|
662
|
+
let that = this;
|
|
663
|
+
permData.forEach(function (p) {
|
|
664
|
+
if (that.hasPerm(p, rolePerms) && p.status !== -1) {
|
|
665
|
+
p.checked = true;
|
|
666
|
+
} else {
|
|
667
|
+
p.checked = false;
|
|
668
|
+
}
|
|
669
|
+
if (p.children && p.children.length > 0) {
|
|
670
|
+
that.checkPermTree(p.children, rolePerms);
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
},
|
|
674
|
+
// 判断角色拥有的权限节点勾选
|
|
675
|
+
hasPerm(p, rolePerms) {
|
|
676
|
+
let flag = false;
|
|
677
|
+
for (let i = 0; i < rolePerms.length; i++) {
|
|
678
|
+
if (p.id === rolePerms[i].permissionId) {
|
|
679
|
+
flag = true;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (flag) {
|
|
684
|
+
return true;
|
|
685
|
+
}
|
|
686
|
+
return false;
|
|
687
|
+
},
|
|
688
|
+
// 全选反选
|
|
689
|
+
selectTreeAll() {
|
|
690
|
+
this.selectAllFlag = !this.selectAllFlag;
|
|
691
|
+
let select = this.selectAllFlag;
|
|
692
|
+
this.selectedTreeAll(this.permData, select);
|
|
693
|
+
},
|
|
694
|
+
// 递归全选节点
|
|
695
|
+
selectedTreeAll(permData, select) {
|
|
696
|
+
let that = this;
|
|
697
|
+
permData.forEach(function (e) {
|
|
698
|
+
e.checked = select;
|
|
699
|
+
if (!select) {
|
|
700
|
+
e.indeterminate = false;
|
|
701
|
+
}
|
|
702
|
+
if (e.children && e.children.length > 0) {
|
|
703
|
+
that.selectedTreeAll(e.children, select);
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
},
|
|
707
|
+
async submitPermEdit() {
|
|
708
|
+
let curVm = this;
|
|
709
|
+
this.submitPermLoading = true;
|
|
710
|
+
let permMenuIds = "";
|
|
711
|
+
let selectedNodes = this.selectedNodes.concat(this.halfSelectedNodes);
|
|
712
|
+
permMenuIds = selectedNodes.join(",");
|
|
713
|
+
// 所有菜单项
|
|
714
|
+
// 所有菜单窗口按钮
|
|
715
|
+
let permMenuBtnIds = {};
|
|
716
|
+
Object.keys(curVm.roleSavedBtnPermMap).forEach(function (key) {
|
|
717
|
+
permMenuBtnIds["W_" + key] = curVm.roleSavedBtnPermMap[key];
|
|
718
|
+
});
|
|
719
|
+
this.axios
|
|
720
|
+
.post(
|
|
721
|
+
"/rolePermissionsSetting/setMenus",
|
|
722
|
+
this.$qs.stringify({
|
|
723
|
+
roleId: this.editRolePermId,
|
|
724
|
+
ids: permMenuIds,
|
|
725
|
+
btns: JSON.stringify(permMenuBtnIds),
|
|
726
|
+
})
|
|
727
|
+
)
|
|
728
|
+
.then((response) => {
|
|
729
|
+
this.submitPermLoading = false;
|
|
730
|
+
if (response.data.result) {
|
|
731
|
+
this.$message.success("操作成功");
|
|
732
|
+
this.getDataList();
|
|
733
|
+
this.permModalVisible = false;
|
|
734
|
+
this.cancelPermEdit();
|
|
735
|
+
} else {
|
|
736
|
+
this.$message.error(response.data.msg);
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
},
|
|
740
|
+
cancelPermEdit() {
|
|
741
|
+
this.selectedKeys = [];
|
|
742
|
+
this.expandedKeys = [];
|
|
743
|
+
this.selectedNodes = [];
|
|
744
|
+
this.halfSelectedNodes = [];
|
|
745
|
+
this.$nextTick(() => {
|
|
746
|
+
this.permModalVisible = false;
|
|
747
|
+
this.resetBtnPerData();
|
|
748
|
+
});
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
mounted() {
|
|
752
|
+
this.maxHeight = Number(document.documentElement.clientHeight - 121) + "px";
|
|
753
|
+
this.init();
|
|
754
|
+
},
|
|
755
|
+
};
|