feat: 统一后端分页查询与前端服务层适配
后端新增通用分页模块,为报销单、员工、预算、agent 资产等 端点统一接入分页参数和游标查询,优化 repository 层分页实 现,前端服务层适配分页响应结构,完善预算图表和全局样式, 优化侧边栏和企业选择器组件,引入 Element Plus 插件注册。
This commit is contained in:
@@ -21,11 +21,12 @@ from app.schemas.budget import (
|
||||
BudgetTransactionRead,
|
||||
)
|
||||
from app.services.budget_expense_control import BudgetExpenseControlModel
|
||||
from app.services.budget_pagination import BudgetPaginationMixin
|
||||
from app.services.budget_support import BudgetSupportMixin
|
||||
from app.services.budget_types import BudgetControlError, SUPPORTED_BUDGET_SUBJECT_CODES
|
||||
from app.services.budget_types import BudgetControlError
|
||||
|
||||
|
||||
class BudgetService(BudgetSupportMixin):
|
||||
class BudgetService(BudgetPaginationMixin, BudgetSupportMixin):
|
||||
def __init__(self, db: Session) -> None:
|
||||
self.db = db
|
||||
|
||||
@@ -46,22 +47,13 @@ class BudgetService(BudgetSupportMixin):
|
||||
cost_center: str | None = None,
|
||||
) -> list[BudgetAllocationRead]:
|
||||
self.ensure_budget_ready()
|
||||
stmt = select(BudgetAllocation).order_by(
|
||||
BudgetAllocation.fiscal_year.desc(),
|
||||
BudgetAllocation.period_key.asc(),
|
||||
BudgetAllocation.department_name.asc(),
|
||||
BudgetAllocation.subject_code.asc(),
|
||||
).where(BudgetAllocation.subject_code.in_(SUPPORTED_BUDGET_SUBJECT_CODES))
|
||||
if fiscal_year is not None:
|
||||
stmt = stmt.where(BudgetAllocation.fiscal_year == fiscal_year)
|
||||
if period_key:
|
||||
stmt = stmt.where(BudgetAllocation.period_key == period_key)
|
||||
if department_id:
|
||||
stmt = stmt.where(BudgetAllocation.department_id == department_id)
|
||||
if department_name:
|
||||
stmt = stmt.where(BudgetAllocation.department_name == department_name)
|
||||
if cost_center:
|
||||
stmt = stmt.where(BudgetAllocation.cost_center == cost_center)
|
||||
stmt = self.build_allocation_stmt(
|
||||
fiscal_year=fiscal_year,
|
||||
period_key=period_key,
|
||||
department_id=department_id,
|
||||
department_name=department_name,
|
||||
cost_center=cost_center,
|
||||
)
|
||||
return [self.serialize_allocation(row) for row in self.db.scalars(stmt).all()]
|
||||
|
||||
def get_summary(
|
||||
|
||||
Reference in New Issue
Block a user