From c6da6e286f9a7651e5b61a55ae6583556bbb2d08 Mon Sep 17 00:00:00 2001 From: guochunsi <1595020186@qq.com> Date: Fri, 30 Jan 2026 16:29:15 +0800 Subject: [PATCH] a --- src/components/AuditState/index.vue | 9 ++- src/components/StatusTag/index.vue | 4 +- src/config/global.ts | 3 +- src/hooks/auth.ts | 30 +++++++++ .../academicqualificationsconfig/index.vue | 18 ++--- src/views/professional/outercompany/index.vue | 18 ++--- .../professional/outercompany/indexSecond.vue | 18 ++--- .../professional/outercompany/indexTrain.vue | 7 +- .../outercompanyemployee/form.vue | 4 +- .../outercompanyemployee/formTrain.vue | 4 +- .../outercompanyemployee/index.vue | 29 ++++---- .../outercompanyemployee/indexSecond.vue | 25 +++++-- .../outercompanyemployee/indexTrain.vue | 25 +++++-- .../index.vue | 17 +++-- .../index.vue | 17 +++-- .../professionalatstation/index.vue | 17 +++-- .../professionalemploymentnature/index.vue | 17 +++-- .../professionalmajorstation/index.vue | 17 +++-- .../professionalpaperconfig/index.vue | 17 +++-- .../professionalpartybranch/index.vue | 24 ++++--- .../professionalqualificationconfig/index.vue | 17 +++-- .../index.vue | 55 ++++++++-------- .../professionalstationdutylevel/index.vue | 17 +++-- .../professionalstationtype/index.vue | 17 +++-- .../index.vue | 57 ++++++++-------- .../index.vue | 17 +++-- .../index.vue | 61 ++++++++--------- .../professionalteacherhonor/index.vue | 52 +++++++-------- .../professionalteachertype/index.vue | 17 +++-- .../index.vue | 17 +++-- .../professionaltitlelevelconfig/index.vue | 17 +++-- .../professionaltitlerelation/index.vue | 66 ++++++++----------- .../professionaltopiclevelconfig/index.vue | 17 +++-- .../professionaltopicsourceconfig/index.vue | 17 +++-- .../professionalworktype/index.vue | 17 +++-- .../professionalyearbounds/index.vue | 13 ++-- .../professional/salaryexportrecord/index.vue | 15 +++-- .../teacherawardtax/importAwardTax.vue | 4 +- .../professional/teacherawardtax/index.vue | 9 ++- .../teacherpayslip/importBaseSalary.vue | 4 +- .../teacherpayslip/importTaxSalary.vue | 6 +- .../professional/teacherpayslip/index.vue | 22 ++++--- .../teachersalary/importBaseSalary.vue | 4 +- .../teachersalary/importTaxSalary.vue | 4 +- .../professional/teachersalary/index.vue | 35 +++++----- .../professional/typeofworkconfig/index.vue | 19 ++++-- .../recruit/backSchoolCheckin/statistics.vue | 5 +- .../recruit/backSchoolCheckin/tabIndex.vue | 10 +-- src/views/recruit/newstucheckin/index.vue | 10 +-- .../recruit/newstucheckin/statistics.vue | 4 +- .../recruitImitateAdjustBatch/index.vue | 16 +++-- .../recruitImitateAdjustBatch/mnTable.vue | 9 +-- src/views/recruit/recruitexampeople/index.vue | 13 ++-- src/views/recruit/recruitplanmajor/index.vue | 11 ++-- .../enrolplantemplate-form.vue | 4 +- src/views/recruit/recruitprestudent/index.vue | 15 +++-- src/views/recruit/recruitschoolcode/index.vue | 15 +++-- .../recruit/recruitstudentplan/index.vue | 9 ++- .../index.vue | 12 ++-- .../index.vue | 9 ++- .../recruit/recruitstudentplangroup/index.vue | 14 ++-- .../recruit/recruitstudentschool/index.vue | 12 ++-- .../AdmissionNoticeDialog.vue | 5 +- .../recruitstudentsignup/detaiform.vue | 10 +-- .../recruit/recruitstudentsignup/index.vue | 34 +++++----- .../recruitstudentsignup/indexClass.vue | 24 +++---- .../recruit/recruitstudentsignup/list.vue | 23 ++++--- .../recruit/recruitstudentsignup/update.vue | 11 ++-- .../recruitstudentsignupturnover/index.vue | 5 +- .../index.vue | 11 ++-- 70 files changed, 688 insertions(+), 519 deletions(-) create mode 100644 src/hooks/auth.ts 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 @@