diff --git a/inventory-backend/app/api/v1/inbound/base.py b/inventory-backend/app/api/v1/inbound/base.py index 14b647d..b80c317 100644 --- a/inventory-backend/app/api/v1/inbound/base.py +++ b/inventory-backend/app/api/v1/inbound/base.py @@ -25,8 +25,8 @@ def get_current_user_permissions(): return [] # 超级管理员返回所有字段权限 if user_role == 'super_admin': - return ['id', 'companyName', 'name', 'commonName', 'category', 'type', - 'spec', 'unit', 'inventoryCount', 'availableCount', 'files', 'isEnabled'] + return ['material_list:id', 'material_list:companyName', 'material_list:name', 'material_list:commonName', 'material_list:category', 'material_list:type', + 'material_list:spec', 'material_list:unit', 'material_list:inventoryCount', 'material_list:availableCount', 'material_list:files', 'material_list:isEnabled'] perm_dict = AuthService.get_user_permissions(user_role) # 合并菜单和元素权限 perms = perm_dict.get('menus', []) + perm_dict.get('elements', []) @@ -39,19 +39,19 @@ def filter_item_by_permissions(item_dict, user_permissions): """ # 字段名到权限码的映射(与前端 permissionMap 保持一致) field_to_perm = { - 'id': 'id', - 'companyName': 'companyName', - 'name': 'name', - 'commonName': 'commonName', - 'category': 'category', - 'type': 'type', - 'spec': 'spec', - 'unit': 'unit', - 'inventoryCount': 'inventoryCount', - 'availableCount': 'availableCount', - 'generalManual': 'files', - 'generalImage': 'files', - 'isEnabled': 'isEnabled' + 'id': 'material_list:id', + 'companyName': 'material_list:companyName', + 'name': 'material_list:name', + 'commonName': 'material_list:commonName', + 'category': 'material_list:category', + 'type': 'material_list:type', + 'spec': 'material_list:spec', + 'unit': 'material_list:unit', + 'inventoryCount': 'material_list:inventoryCount', + 'availableCount': 'material_list:availableCount', + 'generalManual': 'material_list:files', + 'generalImage': 'material_list:files', + 'isEnabled': 'material_list:isEnabled' } for field, perm_code in field_to_perm.items(): if field in item_dict and perm_code not in user_permissions: @@ -163,7 +163,7 @@ def export_data(): # 3. 新增接口 (POST /api/v1/inbound/base/) # ============================================================================== @inbound_base_bp.route('/', methods=['POST']) -@permission_required('operation') +@permission_required('material_list:operation') def create(): try: data = request.get_json() @@ -185,7 +185,7 @@ def create(): # 4. 修改接口 (PUT /api/v1/inbound/base/) # ============================================================================== @inbound_base_bp.route('/', methods=['PUT']) -@permission_required('operation') +@permission_required('material_list:operation') def update(id): try: data = request.get_json() @@ -200,7 +200,7 @@ def update(id): # 5. 删除接口 (DELETE /api/v1/inbound/base/) # ============================================================================== @inbound_base_bp.route('/', methods=['DELETE']) -@permission_required('operation') +@permission_required('material_list:operation') def delete(id): try: MaterialBaseService.delete_material(id) diff --git a/inventory-web/src/views/material/list.vue b/inventory-web/src/views/material/list.vue index 3cdb42d..f867e6d 100644 --- a/inventory-web/src/views/material/list.vue +++ b/inventory-web/src/views/material/list.vue @@ -71,7 +71,7 @@ 导出库存统计 - + 新增 @@ -210,15 +210,15 @@ :active-value="1" :inactive-value="0" :loading="scope.row.statusLoading" - :disabled="!userStore.hasPermission('material:base:write')" + :disabled="!userStore.hasPermission('material_list:operation')" @change="handleStatusChange(scope.row)" /> - + @@ -507,18 +507,18 @@ const columns = reactive({ // 列与权限Code的映射关系(数据库中的code) const permissionMap: Record = { - id: 'id', - companyName: 'companyName', - name: 'name', - commonName: 'commonName', - category: 'category', - type: 'type', - spec: 'spec', - unit: 'unit', - inventory: 'inventoryCount', // 前端变量是 inventory,数据库Code是 inventoryCount - available: 'availableCount', // 前端变量是 available,数据库Code是 availableCount - files: 'files', - isEnabled: 'isEnabled' + id: 'material_list:id', + companyName: 'material_list:companyName', + name: 'material_list:name', + commonName: 'material_list:commonName', + category: 'material_list:category', + 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 + files: 'material_list:files', + isEnabled: 'material_list:isEnabled' }; // 根据用户权限初始化列显示状态