fix: 🐛 pageSearch组件,权限校验不生效修复

This commit is contained in:
超凡
2025-04-13 22:45:25 +08:00
parent 6bed716c0a
commit 8afa82f911
3 changed files with 11 additions and 9 deletions

View File

@@ -1,5 +1,10 @@
<template>
<el-card v-show="visible" v-bind="cardAttrs" class="mb-2.5!">
<el-card
v-show="visible"
v-hasPerm="searchConfig?.pageName ? `${searchConfig.pageName}:query` : '*:*:*'"
v-bind="cardAttrs"
class="mb-2.5!"
>
<el-form ref="queryFormRef" :model="queryParams" :inline="true" :class="isGrid">
<template v-for="(item, index) in formItems" :key="item.prop">
<el-form-item
@@ -94,12 +99,9 @@ const showNumber = computed(() =>
);
// 卡片组件自定义属性(累名、阴影、权限等)
const cardAttrs = computed<IObject>(() => {
let auth = props.searchConfig?.pageName
? { "v-hasPerm": [`${props.searchConfig.pageName}:query`] }
: {};
return props.searchConfig?.cardAttrs && props.searchConfig.cardAttrs instanceof Object
? { shadow: "never", ...auth, ...props.searchConfig.cardAttrs }
: { shadow: "never", ...auth };
? { shadow: "never", ...props.searchConfig.cardAttrs }
: { shadow: "never" };
});
// 是否使用自适应网格布局
const isGrid = computed(() =>

View File

@@ -41,7 +41,7 @@ export type ComponentType =
| "cascader";
export interface ISearchConfig {
// 页面名称(参与组成权限标识,如sys:user:xxx)
// 页面名称(参与组成权限标识,如sys:user:xxx),不填则不进行权限校验
pageName?: string;
// 标签冒号(默认false)
colon?: boolean;

View File

@@ -18,8 +18,8 @@ export const hasPerm: Directive = {
const { roles, perms } = useUserStore().userInfo;
// 超级管理员拥有所有权限
if (roles.includes("ROOT")) {
// 超级管理员拥有所有权限,如果是”*:*:*”权限标识,则不需要进行权限校验
if (roles.includes("ROOT") || requiredPerms.includes("*:*:*")) {
return;
}