fix(borrow,outbound): 普通用户记录只看本人——按领用人/借用人姓名(不含账号前缀)匹配
- 出库记录/借还记录:非管理者视角时按 领用人(consumer_name)/借用人(borrower_name) 过滤 - 匹配取登录名 username.split(/)[0] 的姓名;兼容库里存“姓名/xiaolongxia”全名(姓名+/前缀) - 修复:管理员替员工创建、领用人=员工 的单,员工登录可见
This commit is contained in:
@ -175,8 +175,22 @@ def get_outbound_list():
|
||||
search_type = request.args.get('search_type', 'all')
|
||||
company = request.args.get('company', '')
|
||||
|
||||
# ★ 数据权限:普通用户只看“领用人=本人姓名(不含账号前缀)”的出库记录;管理者看全部
|
||||
consumer_name = None
|
||||
if not is_privileged_viewer():
|
||||
_identity = get_jwt_identity()
|
||||
if _identity:
|
||||
from app.models.system import SysUser
|
||||
_u = SysUser.query.get(int(_identity))
|
||||
# username 形如 “中文名/xiaolongxia” → 取“/”前的领用人姓名
|
||||
_uname = _u.username if _u else ''
|
||||
consumer_name = _uname.split('/')[0].strip() if _uname else None
|
||||
|
||||
# ★ [修改] 调用分组查询服务,支持搜索类型
|
||||
result = OutboundService.get_grouped_list(page, limit, keyword, search_type=search_type, company=company)
|
||||
result = OutboundService.get_grouped_list(
|
||||
page, limit, keyword, search_type=search_type,
|
||||
company=company, consumer_name=consumer_name
|
||||
)
|
||||
|
||||
# 字段级脱敏
|
||||
user_permissions = get_current_user_permissions()
|
||||
|
||||
Reference in New Issue
Block a user