页面按钮权限

This commit is contained in:
huhao
2026-08-11 14:09:26 +08:00
parent 94ec5e65ca
commit c6836b402a
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -38,13 +38,15 @@ export const useMenuStore = defineStore('menu', () => {
/** /**
* 取岗位某功能的数据权限级别(仅按 WorkPostName) * 取岗位某功能的数据权限级别(仅按 WorkPostName)
* @returns {'view'|'edit'|null} null 表示无菜单权限 * @returns {'view'|'edit'|null} null 表示无菜单权限
* - WorkPostName 在权限表中:按表配置 * - WorkPostName 为空:仅可查看(view)
* - 不在表中:不限制(edit) * - 在权限表中:按表配置
* - 有岗位名但不在表中:不限制(edit)
*/ */
const getPostFuncLevel = (funcKey) => { const getPostFuncLevel = (funcKey) => {
if (!funcKey) return null if (!funcKey) return null
const userStore = useUserStore() const userStore = useUserStore()
const postName = String(userStore.userInfo?.WorkPostName || '').trim() const postName = String(userStore.userInfo?.WorkPostName || '').trim()
if (!postName) return 'view'
const map = postMenuPermissions[postName] const map = postMenuPermissions[postName]
if (!map) return 'edit' if (!map) return 'edit'
return map[funcKey] || null return map[funcKey] || null
+1 -1
View File
@@ -113,7 +113,7 @@ const ALL_EDIT = {
} }
// 岗位权限,仅按 WorkPostName 硬编码(来源:岗位权限表) // 岗位权限,仅按 WorkPostName 硬编码(来源:岗位权限表)
// value 为 { [funcKey]: 'view'|'edit' };未列出的岗位不限制扫码类功能 // value 为 { [funcKey]: 'view'|'edit' };WorkPostName 为空时仅可查看;未列出的岗位名不限制
// pipe 管理类应用(无 funcKey)不按岗位拦截,由后端 menuId 控制 // pipe 管理类应用(无 funcKey)不按岗位拦截,由后端 menuId 控制
export const postMenuPermissions = { export const postMenuPermissions = {
// —— 全部菜单 · 可查看 —— // —— 全部菜单 · 可查看 ——