feat: add backend autocomplete for suppliers and users in inbound
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -350,4 +350,30 @@ class ProductInboundService:
|
||||
return {"total": pagination.total, "items": items}
|
||||
except:
|
||||
traceback.print_exc()
|
||||
return {"total": 0, "items": []}
|
||||
return {"total": 0, "items": []}
|
||||
|
||||
# ============================================================
|
||||
# 7. 系统用户搜索
|
||||
# ============================================================
|
||||
@staticmethod
|
||||
def search_system_users(keyword):
|
||||
"""搜索系统用户(活跃状态)"""
|
||||
from app.models.system import SysUser
|
||||
try:
|
||||
query = SysUser.query.filter(SysUser.status == 'active')
|
||||
if keyword:
|
||||
kw = f'%{keyword}%'
|
||||
query = query.filter(db.or_(
|
||||
SysUser.username.ilike(kw),
|
||||
SysUser.email.ilike(kw)
|
||||
))
|
||||
query = query.order_by(SysUser.username)
|
||||
users = []
|
||||
for u in query.limit(20).all():
|
||||
users.append({
|
||||
'value': u.username,
|
||||
'email': u.email
|
||||
})
|
||||
return users
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user