权限相关调整

This commit is contained in:
fuenmao
2026-09-10 16:43:23 +08:00
parent 0db1848b10
commit 4371eca6c4
11 changed files with 347 additions and 36 deletions
+45
View File
@@ -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
};
}