Remove supervisor.log and update uWSGI configuration paths to reflect new directory structure; enhance filtering options in work order views and improve CSS styles for better UI responsiveness.
This commit is contained in:
Executable → Regular
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Binary file not shown.
+65
-19
@@ -132,14 +132,26 @@ def init_work_order_routes(app):
|
||||
device_type = request.args.get('device_type', '')
|
||||
project_type = request.args.get('project_type', '')
|
||||
|
||||
# 基础查询
|
||||
query = WorkOrder.query.filter_by(status='待处理')
|
||||
# 基础查询,直接join Device表
|
||||
query = WorkOrder.query.join(Device).filter(WorkOrder.status == '待处理')
|
||||
|
||||
# 根据用户权限筛选工单
|
||||
if current_user.branch != '交付中心':
|
||||
query = query.join(Device).filter(Device.branch == current_user.branch)
|
||||
query = query.filter(Device.branch == current_user.branch)
|
||||
|
||||
# 获取总数统计
|
||||
# 应用分支筛选(仅交付中心可用)
|
||||
if branch and current_user.branch == '交付中心':
|
||||
query = query.filter(Device.branch == branch)
|
||||
|
||||
# 应用设备类型筛选
|
||||
if device_type:
|
||||
query = query.filter(Device.device_type == device_type)
|
||||
|
||||
# 应用项目类型筛选
|
||||
if project_type:
|
||||
query = query.filter(Device.project_type == project_type)
|
||||
|
||||
# 获取总数统计(使用相同的筛选条件)
|
||||
total_orders = query.count()
|
||||
|
||||
# 获取各支局统计
|
||||
@@ -154,21 +166,17 @@ def init_work_order_routes(app):
|
||||
|
||||
branch_stats = dict(branch_counts)
|
||||
|
||||
# 应用分支筛选(仅交付中心可用)
|
||||
if branch and current_user.branch == '交付中心':
|
||||
query = query.join(Device).filter(Device.branch == branch)
|
||||
|
||||
# 应用设备类型筛选
|
||||
if device_type:
|
||||
query = query.join(Device).filter(Device.device_type == device_type)
|
||||
|
||||
# 应用项目类型筛选
|
||||
if project_type:
|
||||
query = query.join(Device).filter(Device.project_type == project_type)
|
||||
|
||||
# 获取筛选选项
|
||||
device_types_query = db.session.query(Device.device_type).distinct().join(WorkOrder).filter(WorkOrder.status == '待处理')
|
||||
project_types_query = db.session.query(Device.project_type).distinct().join(WorkOrder).filter(WorkOrder.status == '待处理')
|
||||
# 获取筛选选项 - 修正查询方向
|
||||
device_types_query = db.session.query(Device.device_type).distinct().filter(
|
||||
Device.device_id.in_(
|
||||
db.session.query(WorkOrder.device_id).filter(WorkOrder.status == '待处理')
|
||||
)
|
||||
)
|
||||
project_types_query = db.session.query(Device.project_type).distinct().filter(
|
||||
Device.device_id.in_(
|
||||
db.session.query(WorkOrder.device_id).filter(WorkOrder.status == '待处理')
|
||||
)
|
||||
)
|
||||
|
||||
# 根据用户权限进一步筛选选项
|
||||
if current_user.branch != '交付中心':
|
||||
@@ -181,6 +189,42 @@ def init_work_order_routes(app):
|
||||
device_types = [dt[0] for dt in device_types_query.all() if dt[0]]
|
||||
project_types = [pt[0] for pt in project_types_query.all() if pt[0]]
|
||||
|
||||
# 获取设备类型统计
|
||||
device_type_stats = {}
|
||||
if device_types:
|
||||
device_type_counts = db.session.query(
|
||||
Device.device_type,
|
||||
db.func.count(WorkOrder.order_id)
|
||||
).join(WorkOrder, WorkOrder.device_id == Device.device_id
|
||||
).filter(WorkOrder.status == '待处理')
|
||||
|
||||
# 应用同样的权限筛选
|
||||
if current_user.branch != '交付中心':
|
||||
device_type_counts = device_type_counts.filter(Device.branch == current_user.branch)
|
||||
elif branch:
|
||||
device_type_counts = device_type_counts.filter(Device.branch == branch)
|
||||
|
||||
device_type_counts = device_type_counts.group_by(Device.device_type).all()
|
||||
device_type_stats = dict(device_type_counts)
|
||||
|
||||
# 获取项目类型统计
|
||||
project_type_stats = {}
|
||||
if project_types:
|
||||
project_type_counts = db.session.query(
|
||||
Device.project_type,
|
||||
db.func.count(WorkOrder.order_id)
|
||||
).join(WorkOrder, WorkOrder.device_id == Device.device_id
|
||||
).filter(WorkOrder.status == '待处理')
|
||||
|
||||
# 应用同样的权限筛选
|
||||
if current_user.branch != '交付中心':
|
||||
project_type_counts = project_type_counts.filter(Device.branch == current_user.branch)
|
||||
elif branch:
|
||||
project_type_counts = project_type_counts.filter(Device.branch == branch)
|
||||
|
||||
project_type_counts = project_type_counts.group_by(Device.project_type).all()
|
||||
project_type_stats = dict(project_type_counts)
|
||||
|
||||
# 获取分页数据
|
||||
work_orders = query.paginate(page=page, per_page=per_page)
|
||||
|
||||
@@ -195,6 +239,8 @@ def init_work_order_routes(app):
|
||||
work_orders=work_orders,
|
||||
total_orders=total_orders,
|
||||
branch_stats=branch_stats,
|
||||
device_type_stats=device_type_stats,
|
||||
project_type_stats=project_type_stats,
|
||||
show_filter=current_user.branch == '交付中心', # 只有交付中心可以看到筛选
|
||||
branches=get_branches() if current_user.branch == '交付中心' else [], # 只有交付中心可以看到支局列表
|
||||
selected_branch=branch,
|
||||
|
||||
Reference in New Issue
Block a user