fix: 三个模块 update endpoint 统一 Default Deny + 权限码全量对齐 sys_element

This commit is contained in:
yueli
2026-07-20 14:26:22 +08:00
parent 3dca2b9254
commit d80edc961c
3 changed files with 84 additions and 13 deletions

View File

@ -143,9 +143,47 @@ def update_semi(id):
data = request.get_json()
user_permissions = get_current_user_permissions()
if 'inbound_semi:*' not in user_permissions:
for field in ('raw_material_cost', 'manual_cost', 'unit_total_cost', 'total_price'):
perm_code = f'inbound_semi:{field}'
if field in data and perm_code not in user_permissions:
field_to_perm = {
'id': 'inbound_semi:id',
'base_id': 'inbound_semi:base_id',
'company_name': 'material_list:companyName',
'material_name': 'material_list:name',
'spec_model': 'material_list:spec',
'category': 'material_list:category',
'material_type': 'material_list:type',
'unit': 'material_list:unit',
'sku': 'inbound_semi:sku',
'in_date': 'inbound_semi:inbound_date',
'barcode': 'inbound_semi:barcode',
'serial_number': 'inbound_semi:sn_bn',
'batch_number': 'inbound_semi:sn_bn',
'warehouse_location': 'inbound_semi:warehouse_loc',
'status': 'inbound_semi:status',
'quality_status': 'inbound_semi:quality_status',
'in_quantity': 'inbound_semi:in_quantity',
'stock_quantity': 'inbound_semi:stock_quantity',
'available_quantity': 'inbound_semi:available_quantity',
'bom_code': 'inbound_semi:bom_code',
'bom_version': 'inbound_semi:bom_version',
'work_order_code': 'inbound_semi:work_order_code',
'raw_material_cost': 'inbound_semi:raw_material_cost',
'manual_cost': 'inbound_semi:manual_cost',
'unit_total_cost': 'inbound_semi:unit_total_cost',
'total_price': 'inbound_semi:total_price',
'production_manager': 'inbound_semi:production_manager',
'production_start_time': 'inbound_semi:production_start_time',
'production_end_time': 'inbound_semi:production_end_time',
'arrival_photo': 'inbound_semi:arrival_photo',
'quality_report_link': 'inbound_semi:quality_report_link',
'detail_link': 'inbound_semi:detail_link',
'remark': 'inbound_semi:remark',
'print_copies': 'inbound_semi:print_copies',
}
for field in list(data.keys()):
perm_code = field_to_perm.get(field)
if perm_code is None:
data.pop(field, None) # Default Deny
elif perm_code not in user_permissions:
data.pop(field, None)
SemiInboundService.update_inbound(id, data)
return jsonify({"code": 200, "msg": "更新成功"})