From a547d6b1647ad6528b56c9c02522600d2d8bca66 Mon Sep 17 00:00:00 2001 From: dxc Date: Fri, 27 Feb 2026 10:57:30 +0800 Subject: [PATCH] fix: restore strict column permission control Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) --- inventory-web/src/views/material/list.vue | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/inventory-web/src/views/material/list.vue b/inventory-web/src/views/material/list.vue index cf40c14..0cc1460 100644 --- a/inventory-web/src/views/material/list.vue +++ b/inventory-web/src/views/material/list.vue @@ -515,8 +515,8 @@ const permissionMap: Record = { type: 'material_list:type', spec: 'material_list:spec', unit: 'material_list:unit', - inventory: 'material_list:inventoryCount', // 前端变量是 inventory,数据库Code是 inventoryCount - available: 'material_list:availableCount', // 前端变量是 available,数据库Code是 availableCount + inventory: 'material_list:inventoryCount', + available: 'material_list:availableCount', files: 'material_list:files', isEnabled: 'material_list:isEnabled' }; @@ -528,16 +528,14 @@ const initColumnPermissions = () => { return; } - // 普通用户:不再根据权限隐藏列,而是显示所有列,由后端控制字段值 - // 所以这里不做任何操作,保持columns的默认visible(true) - // 但是,我们也可以选择性地根据权限隐藏列,但用户要求列显示,所以不隐藏 - // 因此,注释掉下面的代码 - // Object.keys(columns).forEach(key => { - // const code = permissionMap[key]; - // if (code) { - // columns[key].visible = !!userStore.hasPermission(code); - // } - // }); + // 普通用户:严格执行列级权限控制,没有权限的列必须隐藏 + Object.keys(columns).forEach(key => { + const code = permissionMap[key]; + if (code) { + // 如果不具备该权限,必须设为 false + columns[key].visible = !!userStore.hasPermission(code); + } + }); }; const companyOptions = ref([]);