This commit is contained in:
张成
2026-04-13 11:16:22 +08:00
parent 75149f994f
commit c73afd2325
13 changed files with 421 additions and 30 deletions

View File

@@ -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
}