1
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<div class="content-view">
|
||||
<Alert type="info" show-icon closable style="margin-bottom: 12px">
|
||||
角色为<strong>全库共用</strong>,不按租户隔离;各租户用户可在「用户管理」中绑定同一角色,菜单权限以角色配置为准。
|
||||
</Alert>
|
||||
<div class="table-head-tool">
|
||||
<Button type="primary" @click="showAddWarp">新增</Button>
|
||||
</div>
|
||||
@@ -73,6 +76,23 @@ export default {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
parseRoleMenuIds(menus) {
|
||||
if (menus == null || menus === '') {
|
||||
return []
|
||||
}
|
||||
if (Array.isArray(menus)) {
|
||||
return menus.map((id) => Number(id)).filter((id) => !Number.isNaN(id))
|
||||
}
|
||||
if (typeof menus === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(menus)
|
||||
return this.parseRoleMenuIds(parsed)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
return []
|
||||
},
|
||||
async init() {
|
||||
let res = await roleServer.list()
|
||||
this.gridOption.data = res.data
|
||||
@@ -120,12 +140,8 @@ export default {
|
||||
|
||||
let res = await menuServer.list()
|
||||
let tree = uiTool.transformTree(res.data)
|
||||
if (row.menus) {
|
||||
this.expandTreeAll = JSON.parse(row.menus)
|
||||
this.treeData = this.mapTree(tree)
|
||||
} else {
|
||||
this.treeData = this.mapTree(tree)
|
||||
}
|
||||
this.expandTreeAll = this.parseRoleMenuIds(row.menus)
|
||||
this.treeData = this.mapTree(tree)
|
||||
|
||||
this.isShowPermission = true
|
||||
},
|
||||
@@ -136,7 +152,7 @@ export default {
|
||||
p.children = this.mapTree(p.children)
|
||||
}
|
||||
|
||||
let row = this.expandTreeAll.find((p2) => p2 === p.id)
|
||||
let row = this.expandTreeAll.find((p2) => Number(p2) === Number(p.id))
|
||||
if (row) {
|
||||
p.checked = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user