From 4371eca6c45c9865631d0a9186d0da6dea1cf69e Mon Sep 17 00:00:00 2001 From: fuenmao <980740792@qq.com> Date: Thu, 10 Sep 2026 16:43:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E7=9B=B8=E5=85=B3=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/biz/onboarding.ts | 9 ++ src/directives/modules/auth.ts | 3 + src/utils/onboardingPermission.ts | 45 +++++++++ src/views/biz/onboarding/contract/index.vue | 53 +++++++++- src/views/biz/onboarding/employee/index.vue | 34 ++++++- .../components/OnboardingTemplatePanel.vue | 23 ++++- .../components/VariableDefinitionPanel.vue | 18 +++- .../biz/onboarding/entry-config/index.vue | 27 +++++- src/views/biz/onboarding/setup/index.vue | 69 +++++++++++-- src/views/biz/onboarding/task/index.vue | 97 +++++++++++++++++-- .../sys/limit/button/components/form.vue | 5 + 11 files changed, 347 insertions(+), 36 deletions(-) create mode 100644 src/utils/onboardingPermission.ts diff --git a/src/api/modules/biz/onboarding.ts b/src/api/modules/biz/onboarding.ts index f480231..9c9e40e 100644 --- a/src/api/modules/biz/onboarding.ts +++ b/src/api/modules/biz/onboarding.ts @@ -59,6 +59,7 @@ async function requestContractPreview( export interface OnboardingTask { id: number; + createUserId?: number | string; taskNo: string; companyId: number; companyName?: string; @@ -190,6 +191,7 @@ export interface OnboardingPositionOption { } export interface OnboardingCompany extends OnboardingCompanyOption { + createUserId?: number | string; companyCode: string; legalName: string; unifiedSocialCreditCode?: string; @@ -203,6 +205,7 @@ export interface OnboardingCompany extends OnboardingCompanyOption { } export interface OnboardingDepartment extends OnboardingDepartmentOption { + createUserId?: number | string; companyId: number; companyName?: string; departmentCode: string; @@ -213,6 +216,7 @@ export interface OnboardingDepartment extends OnboardingDepartmentOption { } export interface OnboardingPosition extends OnboardingPositionOption { + createUserId?: number | string; companyId: number; companyName?: string; departmentId?: number; @@ -226,6 +230,7 @@ export interface OnboardingPosition extends OnboardingPositionOption { export interface OnboardingContractTemplate { id: number; + createUserId?: number | string; companyId?: number; companyName?: string; departmentId?: number; @@ -287,6 +292,7 @@ export interface OnboardingTaskContractVariableGroup { export interface OnboardingEmployee { id: number; + createUserId?: number | string; employeeNo?: string; employeeName: string; companyId: number; @@ -309,6 +315,7 @@ export interface OnboardingEmployee { export interface OnboardingFormField { id: number; + createUserId?: number | string; fieldCode: string; fieldName: string; dataType: string; @@ -320,6 +327,7 @@ export interface OnboardingFormField { export interface OnboardingMaterialType { id: number; + createUserId?: number | string; materialCode: string; materialName: string; allowedExtensions?: string; @@ -350,6 +358,7 @@ export interface OnboardingTemplateMaterialConfig { export interface OnboardingTemplate { id: number; + createUserId?: number | string; templateCode: string; templateName: string; companyId: number; diff --git a/src/directives/modules/auth.ts b/src/directives/modules/auth.ts index 796003d..eed72bc 100644 --- a/src/directives/modules/auth.ts +++ b/src/directives/modules/auth.ts @@ -13,6 +13,7 @@ * @see https://gitee.com/dotnetmoyu/SimpleAdmin */ import { useAuthStore } from "@/stores/modules/auth"; +import { useUserStore } from "@/stores/modules/user"; import type { Directive, DirectiveBinding } from "vue"; /** @@ -32,6 +33,8 @@ const auth: Directive = { const { value, arg } = binding; // 获取authStore const authStore = useAuthStore(); + const userStore = useUserStore(); + if ((userStore.userInfoGet?.roleCodeList || []).includes("superAdmin")) return; // 获取用户权限按钮列表 const currentPageRoles = authStore.authButtonListGet ?? []; // 如果传入的值是数组,并且数组的长度大于0 diff --git a/src/utils/onboardingPermission.ts b/src/utils/onboardingPermission.ts new file mode 100644 index 0000000..71c821e --- /dev/null +++ b/src/utils/onboardingPermission.ts @@ -0,0 +1,45 @@ +import { computed } from "vue"; +import { useAuthStore } from "@/stores/modules/auth"; +import { useUserStore } from "@/stores/modules/user"; + +export interface OnboardingOwnedRecord { + createUserId?: number | string | null; +} + +/** + * 入职业务页面统一权限判断:按钮权限控制功能入口,创建人/管理全部权限控制数据操作范围。 + */ +export function useOnboardingPermission(manageAllCode: string) { + const authStore = useAuthStore(); + const userStore = useUserStore(); + + const isSuperAdmin = computed(() => + (userStore.userInfoGet?.roleCodeList || []).includes("superAdmin") + ); + const canManageAll = computed( + () => + isSuperAdmin.value || + authStore.authButtonListGet.includes(manageAllCode) + ); + + const hasAction = (code: string) => + isSuperAdmin.value || authStore.authButtonListGet.includes(code); + + const canManage = (record?: OnboardingOwnedRecord | null) => { + if (canManageAll.value) return true; + if (record?.createUserId == null || userStore.userInfoGet?.id == null) + return false; + return String(record.createUserId) === String(userStore.userInfoGet.id); + }; + + const disabledReason = (record?: OnboardingOwnedRecord | null) => + canManage(record) ? "" : "只能操作本人创建的数据"; + + return { + isSuperAdmin, + canManageAll, + hasAction, + canManage, + disabledReason + }; +} diff --git a/src/views/biz/onboarding/contract/index.vue b/src/views/biz/onboarding/contract/index.vue index 5b5fb6a..6043290 100644 --- a/src/views/biz/onboarding/contract/index.vue +++ b/src/views/biz/onboarding/contract/index.vue @@ -7,7 +7,7 @@ :request-api="onboardingTaskApi.templatePage" > - + 新增签署材料模板 @@ -50,11 +50,27 @@ 版本与配置 - + 编辑 - + 删除 @@ -184,7 +200,14 @@ - + 上传新版本 DOCX @@ -233,29 +256,38 @@ 启用 停用 删除 @@ -405,7 +437,15 @@ - + 检查调整 @@ -501,6 +541,9 @@ import { } from "@/api/modules/biz/onboarding"; import type { ColumnProps, ProTableInstance } from "@/components/ProTable/interface"; import { isMessageBoxConfirmed } from "@/utils/messageBox"; +import { useOnboardingPermission } from "@/utils/onboardingPermission"; + +const { canManage, disabledReason } = useOnboardingPermission("onboardingContractManageAll"); const templateTable = ref(); const selectedTemplate = ref(); diff --git a/src/views/biz/onboarding/employee/index.vue b/src/views/biz/onboarding/employee/index.vue index c3850ad..1dd8c8f 100644 --- a/src/views/biz/onboarding/employee/index.vue +++ b/src/views/biz/onboarding/employee/index.vue @@ -2,19 +2,30 @@ - + 导出当前筛选结果 查看档案 - 编辑人事信息 编辑人事信息 + 办理转正 @@ -372,19 +383,33 @@ - 编辑人事信息 编辑人事信息 + 办理转正 撤销转正 @@ -510,6 +535,9 @@ import { } from "@/api/modules/biz/onboarding"; import type { ColumnProps, ProTableInstance } from "@/components/ProTable/interface"; import { getMessageBoxPromptResult, isMessageBoxConfirmed } from "@/utils/messageBox"; +import { useOnboardingPermission } from "@/utils/onboardingPermission"; + +const { canManage, disabledReason } = useOnboardingPermission("onboardingEmployeeManageAll"); const proTable = ref(); const detailVisible = ref(false); diff --git a/src/views/biz/onboarding/entry-config/components/OnboardingTemplatePanel.vue b/src/views/biz/onboarding/entry-config/components/OnboardingTemplatePanel.vue index 9586ec9..47a744f 100644 --- a/src/views/biz/onboarding/entry-config/components/OnboardingTemplatePanel.vue +++ b/src/views/biz/onboarding/entry-config/components/OnboardingTemplatePanel.vue @@ -57,7 +57,7 @@ 查询 重置 - 新增入职模板 + 新增入职模板 - 编辑 - 删除 + 编辑 + 删除 @@ -293,6 +307,9 @@ import { onboardingTaskApi } from "@/api/modules/biz/onboarding"; import { isMessageBoxConfirmed } from "@/utils/messageBox"; +import { useOnboardingPermission } from "@/utils/onboardingPermission"; + +const { canManage, disabledReason } = useOnboardingPermission("onboardingEntryConfigManageAll"); const loading = ref(false); const saving = ref(false); diff --git a/src/views/biz/onboarding/entry-config/components/VariableDefinitionPanel.vue b/src/views/biz/onboarding/entry-config/components/VariableDefinitionPanel.vue index 4131738..672fbd2 100644 --- a/src/views/biz/onboarding/entry-config/components/VariableDefinitionPanel.vue +++ b/src/views/biz/onboarding/entry-config/components/VariableDefinitionPanel.vue @@ -25,7 +25,7 @@ 查询 重置 - 新增自定义变量 + 新增自定义变量 - 编辑 编辑 + 删除 @@ -171,6 +182,9 @@ import { ref, reactive, onMounted } from "vue"; import { ElMessage, ElMessageBox, FormInstance, FormRules } from "element-plus"; import { onboardingTaskApi } from "@/api/modules/biz/onboarding"; import { isMessageBoxConfirmed } from "@/utils/messageBox"; +import { useOnboardingPermission } from "@/utils/onboardingPermission"; + +const { canManage, disabledReason } = useOnboardingPermission("onboardingEntryConfigManageAll"); const loading = ref(false); const saving = ref(false); diff --git a/src/views/biz/onboarding/entry-config/index.vue b/src/views/biz/onboarding/entry-config/index.vue index 709b41e..031214d 100644 --- a/src/views/biz/onboarding/entry-config/index.vue +++ b/src/views/biz/onboarding/entry-config/index.vue @@ -10,7 +10,7 @@ - + 新增资料类型 @@ -35,11 +35,27 @@ - + 编辑 - + 删除 @@ -104,6 +120,9 @@ import { import { isMessageBoxConfirmed } from "@/utils/messageBox"; import OnboardingTemplatePanel from "./components/OnboardingTemplatePanel.vue"; import VariableDefinitionPanel from "./components/VariableDefinitionPanel.vue"; +import { useOnboardingPermission } from "@/utils/onboardingPermission"; + +const { canManage, disabledReason } = useOnboardingPermission("onboardingEntryConfigManageAll"); const activeTab = ref("variables"); const materialTypes = ref([]); @@ -225,4 +244,4 @@ onMounted(() => { .toolbar { margin-bottom: 12px; } - \ No newline at end of file + diff --git a/src/views/biz/onboarding/setup/index.vue b/src/views/biz/onboarding/setup/index.vue index 653d732..5091a6d 100644 --- a/src/views/biz/onboarding/setup/index.vue +++ b/src/views/biz/onboarding/setup/index.vue @@ -12,7 +12,7 @@ :search-col="5" > - + 新增入职公司 @@ -33,11 +33,27 @@ - + 编辑 - + 删除 @@ -56,7 +72,7 @@ :search-col="5" > - + 新增入职部门 @@ -74,11 +90,27 @@ - + 编辑 - + 删除 @@ -97,7 +129,7 @@ :search-col="5" > - + 新增入职岗位 @@ -122,11 +154,27 @@ - + 编辑 - + 删除 @@ -377,6 +425,9 @@ import { } from "@/api/modules/biz/onboarding"; import type { ColumnProps, ProTableInstance, EnumProps } from "@/components/ProTable/interface"; import { isMessageBoxConfirmed } from "@/utils/messageBox"; +import { useOnboardingPermission } from "@/utils/onboardingPermission"; + +const { canManage, disabledReason } = useOnboardingPermission("onboardingSetupManageAll"); const activeTab = ref("company"); diff --git a/src/views/biz/onboarding/task/index.vue b/src/views/biz/onboarding/task/index.vue index 507fba5..d483950 100644 --- a/src/views/biz/onboarding/task/index.vue +++ b/src/views/biz/onboarding/task/index.vue @@ -10,7 +10,7 @@ > - + 发起入职任务 @@ -63,59 +63,77 @@ 签署材料参数 复制任务 复制链接 通过 退回 归档 @@ -132,20 +150,26 @@ 撤销 删除 @@ -813,19 +837,23 @@ 合格 需补充 @@ -854,11 +882,14 @@ 生成DOCX签署材料 @@ -911,25 +942,34 @@ - + 获取并复制链接 @@ -1329,10 +1390,12 @@