diff --git a/src/components/AuditState/index.vue b/src/components/AuditState/index.vue index 3ec8879..59419f2 100644 --- a/src/components/AuditState/index.vue +++ b/src/components/AuditState/index.vue @@ -41,14 +41,13 @@ const props = withDefaults(defineProps(), { emptyText: '-' }) -// 根据 state 值查找对应的配置 +// 根据 state 值查找对应的配置(统一转字符串比较,兼容数字 10 与字符串 '10') const currentOption = computed(() => { - if (!props.state && props.state !== 0 && props.state !== '0') { + if (props.state == null || props.state === '') { return null } - return props.options.find(option => { - return String(option.value) === String(props.state) - }) || null + const stateStr = String(props.state) + return props.options.find(option => String(option.value) === stateStr) || null }) diff --git a/src/components/StatusTag/index.vue b/src/components/StatusTag/index.vue index 5916a7b..b75be03 100644 --- a/src/components/StatusTag/index.vue +++ b/src/components/StatusTag/index.vue @@ -37,13 +37,13 @@ const props = withDefaults(defineProps(), { // 默认的类型映射(只使用字符串键) const defaultTypeMap: Record = { - '1': { type: 'warning', effect: 'dark' }, + '1': { type: 'danger', effect: 'dark' }, '0': { type: 'primary', effect: 'light' } } // 默认的颜色映射(只使用字符串键) const defaultColorMap: Record = { - '1': 'var(--el-color-warning)', + '1': 'var(--el-color-danger)', '0': 'var(--el-color-primary)' } diff --git a/src/config/global.ts b/src/config/global.ts index 8cf1b2f..26294c2 100644 --- a/src/config/global.ts +++ b/src/config/global.ts @@ -149,7 +149,8 @@ import type { StateOption } from '/@/components/AuditState/index.vue' export const PROFESSIONAL_AUDIT_STATE_OPTIONS: StateOption[] = [ { value: '1', label: '已通过', type: 'success', icon: 'fa-solid fa-circle-check', effect: 'dark' }, { value: '-2', label: '已驳回', type: 'danger', icon: 'fa-solid fa-circle-xmark', effect: 'dark' }, - { value: '0', label: '待审核', type: 'warning', icon: 'fa-regular fa-clock', effect: 'light' } + { value: '0', label: '待审核', type: 'warning', icon: 'fa-regular fa-clock', effect: 'light' }, + { value: '10', label: '部门通过', type: 'warning', icon: 'fa-regular fa-clock' ,effect:"dark" } ]; /** diff --git a/src/hooks/auth.ts b/src/hooks/auth.ts new file mode 100644 index 0000000..525ad27 --- /dev/null +++ b/src/hooks/auth.ts @@ -0,0 +1,30 @@ +import { storeToRefs } from 'pinia' +import { useUserInfo } from '/@/stores/userInfo' +import { judementSameArr } from '/@/utils/arrayOperation' + +/** + * 权限 composable:用于「无权限即无节点」场景(v-if + hasAuth),替代 v-auth + * 多页面复用,保证响应式(权限变更后模板会更新) + * + * @example + * const { hasAuth, hasAuths, hasAuthAll } = useAuth() + * // 模板:v-if="hasAuth('xxx')" v-if="hasAuths(['a','b'])" v-if="hasAuthAll(['a','b'])" + */ +export function useAuth() { + const { userInfos } = storeToRefs(useUserInfo()) + const list = () => userInfos.value?.authBtnList ?? [] + + /** 单个权限:有该权限返回 true */ + const hasAuth = (code: string) => list().includes(code) + + /** 多个权限满足其一即返回 true */ + const hasAuths = (codes: string[]) => { + const btnList = list() + return codes.some((c) => btnList.includes(c)) + } + + /** 多个权限全部满足才返回 true */ + const hasAuthAll = (codes: string[]) => judementSameArr(codes, list()) + + return { hasAuth, hasAuths, hasAuthAll } +} diff --git a/src/views/professional/academicqualificationsconfig/index.vue b/src/views/professional/academicqualificationsconfig/index.vue index 9521d1f..240a295 100755 --- a/src/views/professional/academicqualificationsconfig/index.vue +++ b/src/views/professional/academicqualificationsconfig/index.vue @@ -4,11 +4,11 @@
- 新 增 + icon="FolderAdd" + @click="handleAdd">新 增
@@ -18,6 +18,7 @@ :data="state.dataList" v-loading="state.loading" border + row-key="id" :cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle" > @@ -33,15 +34,15 @@