From a33898c2a0374c249862a2b996e33352e30c8caf Mon Sep 17 00:00:00 2001 From: KonBAI <1527468660@qq.com> Date: 星期六, 02 四月 2022 13:02:56 +0800 Subject: [PATCH] !167 update 修改角色"菜单树选择项"和"部门树选择项"是否关联显示字段为Boolean类型 * fix 修改 postgres sql脚本,处理角色表字段类型错误问题。 * fix 修复postgreSQL新增或更新角色信息报错。修改角色"菜单树选择项"和"部门树选择项"是否关联显示字段为Boolean类型。 --- ruoyi-ui/src/utils/permission.js | 75 +++++++++++++++++++++++++------------ 1 files changed, 51 insertions(+), 24 deletions(-) diff --git a/ruoyi-ui/src/utils/permission.js b/ruoyi-ui/src/utils/permission.js index efb4cc8..bd4c066 100644 --- a/ruoyi-ui/src/utils/permission.js +++ b/ruoyi-ui/src/utils/permission.js @@ -1,24 +1,51 @@ -import store from '@/store' - -/** - * @param {Array} value - * @returns {Boolean} - */ -export default function checkPermission(value) { - if (value && value instanceof Array && value.length > 0) { - const roles = store.getters && store.getters.roles - const permissionRoles = value - - const hasPermission = roles.some(role => { - return permissionRoles.includes(role) - }) - - if (!hasPermission) { - return false - } - return true - } else { - console.error(`need roles! Like v-permission="['admin','editor']"`) - return false - } -} +import store from '@/store' + +/** + * 瀛楃鏉冮檺鏍¢獙 + * @param {Array} value 鏍¢獙鍊� + * @returns {Boolean} + */ +export function checkPermi(value) { + if (value && value instanceof Array && value.length > 0) { + const permissions = store.getters && store.getters.permissions + const permissionDatas = value + const all_permission = "*:*:*"; + + const hasPermission = permissions.some(permission => { + return all_permission === permission || permissionDatas.includes(permission) + }) + + if (!hasPermission) { + return false + } + return true + } else { + console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) + return false + } +} + +/** + * 瑙掕壊鏉冮檺鏍¢獙 + * @param {Array} value 鏍¢獙鍊� + * @returns {Boolean} + */ +export function checkRole(value) { + if (value && value instanceof Array && value.length > 0) { + const roles = store.getters && store.getters.roles + const permissionRoles = value + const super_admin = "admin"; + + const hasRole = roles.some(role => { + return super_admin === role || permissionRoles.includes(role) + }) + + if (!hasRole) { + return false + } + return true + } else { + console.error(`need roles! Like checkRole="['admin','editor']"`) + return false + } +} -- Gitblit v1.9.3