This commit is contained in:
zlwu committed 2026-06-25 08:06:32 +08:00
1 parent 6b6c80f182
commit 86450f38a1
53 files changed
+20800 -5339

No files matched your search

+1 -1
View File
@@ -1 +1 @@
90023
4800
+166 -239
View File
@@ -1,38 +1,32 @@
"""运输计划管理 - 运费结算 API"""
from datetime import date
from typing import Optional
import json
from fastapi import APIRouter, Depends, HTTPException, Query, status
from sqlalchemy import func
from sqlalchemy.orm import Session
from app.core.database import get_db
from app.core.db_auth import DbUserContext, get_db_current_user
from app.core.tenant_context import get_tenant_no
from app.core.utils import generate_uuid
from app.models.pl_models import (
PlFreightSettlement,
PlFreightSettlementTransport,
PlRemittanceVoucher,
PlTransport,
)
from app.models.pl_models import PlFreightSettlement
from app.schemas.pl.freight import (
FreightSettlementApprovalActionBody,
FreightSettlementCreate,
FreightSettlementListQuery,
FreightSettlementDisburseBody,
FreightSettlementListResponse,
FreightSettlementRead,
FreightSettlementSubmitApprovalBody,
FreightSettlementUpdate,
FreightSettlementWithTransports,
RemittanceVoucherCreate,
RemittanceVoucherRead,
UnsettledPlanListResponse,
)
from app.services import pl_freight_settlement_service as freight_svc
router = APIRouter(prefix="/freight", tags=["运输计划-运费结算"])
def _generate_settlement_no(db: Session) -> str:
"""生成结算单编号"""
today = date.today()
prefix = f"SXJS{today.strftime('%Y%m%d')}"
@@ -46,51 +40,55 @@ def _generate_settlement_no(db: Session) -> str:
.first()
)
if last:
last_seq = int(last.settlement_no[-4:])
seq = last_seq + 1
else:
seq = 1
seq = int(last.settlement_no[-4:]) + 1 if last else 1
return f"{prefix}{seq:04d}"
# =============================================================================
# 结算单列表
# =============================================================================
@router.get("/unsettled-plans", response_model=UnsettledPlanListResponse)
def list_unsettled_plans(
q: Optional[str] = Query(default=None),
plan_type: Optional[str] = Query(default=None, alias="planType"),
license_plate: Optional[str] = Query(default=None, alias="licensePlate"),
page: int = Query(default=1, ge=1),
page_size: int = Query(default=20, ge=1, le=100, alias="pageSize"),
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> UnsettledPlanListResponse:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
total, items = freight_svc.list_unsettled_plans(
db,
tenant_no=tenant_no,
q=q,
plan_type=plan_type,
license_plate=license_plate,
page=page,
page_size=page_size,
)
return UnsettledPlanListResponse(total=total, list=items)
@router.get("/", response_model=FreightSettlementListResponse)
def list_settlements(
q: Optional[str] = Query(default=None, description="模糊搜索"),
settlement_status: Optional[str] = Query(default=None, alias="settlementStatus", description="结算状态"),
q: Optional[str] = Query(default=None),
settlement_status: Optional[str] = Query(default=None, alias="settlementStatus"),
tab: Optional[str] = Query(default=None, description="bills|disburse|settled"),
page: int = Query(default=1, ge=1),
page_size: int = Query(default=20, ge=1, le=100, alias="pageSize"),
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementListResponse:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
query = db.query(PlFreightSettlement).filter(
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
total, items = freight_svc.list_settlements_enriched(
db,
tenant_no=tenant_no,
user_id=user.id,
q=q,
settlement_status=settlement_status,
tab=tab,
page=page,
page_size=page_size,
)
if settlement_status:
query = query.filter(PlFreightSettlement.settlement_status == settlement_status)
if q:
query = query.filter(PlFreightSettlement.settlement_no.contains(q))
total = query.count()
offset = (page - 1) * page_size
settlements = query.order_by(PlFreightSettlement.create_time.desc()).offset(offset).limit(page_size).all()
return FreightSettlementListResponse(total=total, list=settlements)
# =============================================================================
# 生成结算单
# =============================================================================
return FreightSettlementListResponse(total=total, list=items)
@router.post("/", response_model=FreightSettlementRead, status_code=status.HTTP_201_CREATED)
@@ -100,59 +98,18 @@ def create_settlement(
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
# 计算总运费
transports = (
db.query(PlTransport)
.filter(
PlTransport.id.in_(payload.transport_ids),
PlTransport.tenant_no == tenant_no,
PlTransport.del_flag == 0,
)
.all()
)
if not transports:
raise HTTPException(status_code=400, detail="请选择有效的运输单")
total_freight = sum(float(t.freight_amount or 0) for t in transports)
settlement_no = _generate_settlement_no(db)
settlement = PlFreightSettlement(
id=generate_uuid(),
settlement = freight_svc.create_settlement(
db,
tenant_no=tenant_no,
settlement_no=settlement_no,
total_freight=total_freight,
settlement_status="pending",
create_by=user.id,
create_dept_id=user.dept_id,
plan_ids=payload.plan_ids,
transport_ids=payload.transport_ids,
user_id=user.id,
dept_id=user.dept_id,
settlement_no=_generate_settlement_no(db),
)
db.add(settlement)
# 关联运输单
for t in transports:
st = PlFreightSettlementTransport(
id=generate_uuid(),
tenant_no=tenant_no,
settlement_id=settlement.id,
transport_id=t.id,
freight_amount=t.freight_amount,
create_by=user.id,
create_dept_id=user.dept_id,
)
db.add(st)
db.commit()
db.refresh(settlement)
return settlement
# =============================================================================
# 获取结算单详情
# =============================================================================
@router.get("/{id}", response_model=FreightSettlementWithTransports)
def get_settlement(
id: str,
@@ -160,34 +117,10 @@ def get_settlement(
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementWithTransports:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
settlement = _get_settlement(db, tenant_no, id)
# 获取关联的运输单
transport_links = (
db.query(PlFreightSettlementTransport)
.filter(
PlFreightSettlementTransport.settlement_id == id,
PlFreightSettlementTransport.del_flag == 0,
)
.all()
detail = freight_svc.get_settlement_detail(
db, tenant_no=tenant_no, settlement_id=id, user_id=user.id
)
transport_ids = [t.transport_id for t in transport_links]
transports = (
db.query(PlTransport)
.filter(PlTransport.id.in_(transport_ids), PlTransport.del_flag == 0)
.all()
)
result = FreightSettlementWithTransports.model_validate(settlement)
result.transports = transports
return result
# =============================================================================
# 更新结算单
# =============================================================================
return FreightSettlementWithTransports.model_validate(detail)
@router.put("/{id}", response_model=FreightSettlementRead)
@@ -198,98 +131,119 @@ def update_settlement(
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
settlement = _get_settlement(db, tenant_no, id)
update_data = payload.model_dump(exclude_unset=True)
for key, value in update_data.items():
setattr(settlement, key, value)
settlement.update_by = user.id
db.commit()
db.refresh(settlement)
return settlement
# =============================================================================
# 提交结算单
# =============================================================================
@router.post("/{id}/submit", response_model=FreightSettlementRead)
def submit_settlement(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
settlement = _get_settlement(db, tenant_no, id)
if settlement.settlement_status != "pending":
raise HTTPException(status_code=400, detail="当前状态不允许提交")
settlement.settlement_status = "submitted"
settlement.update_by = user.id
db.commit()
db.refresh(settlement)
return settlement
# =============================================================================
# 审核结算单
# =============================================================================
@router.post("/{id}/approve", response_model=FreightSettlementRead)
def approve_settlement(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
settlement = _get_settlement(db, tenant_no, id)
if settlement.settlement_status not in ("submitted",):
raise HTTPException(status_code=400, detail="当前状态不允许审核")
settlement.settlement_status = "confirmed"
settlement.update_by = user.id
db.commit()
db.refresh(settlement)
return settlement
# =============================================================================
# 汇款凭证
# =============================================================================
@router.post("/voucher", status_code=status.HTTP_201_CREATED)
def create_voucher(
payload: RemittanceVoucherCreate,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> RemittanceVoucherRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
voucher = PlRemittanceVoucher(
id=generate_uuid(),
tenant_no=tenant_no,
settlement_id=payload.settlement_id,
remittance_date=payload.remittance_date,
remittance_amount=payload.remittance_amount,
voucher_urls=json.dumps(payload.voucher_urls) if payload.voucher_urls else None,
remark=payload.remark,
create_by=user.id,
create_dept_id=user.dept_id,
return freight_svc.update_settlement_draft(
db, tenant_no=tenant_no, settlement_id=id, payload=payload, user_id=user.id
)
db.add(voucher)
db.commit()
db.refresh(voucher)
result = RemittanceVoucherRead.model_validate(voucher)
if voucher.voucher_urls:
result.voucher_urls = voucher.voucher_urls
return result
@router.delete("/{id}", status_code=status.HTTP_204_NO_CONTENT)
def delete_settlement(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> None:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
freight_svc.delete_draft_settlement(
db, tenant_no=tenant_no, settlement_id=id, user_id=user.id
)
@router.post("/{id}/submit-approval", response_model=FreightSettlementRead)
def submit_settlement_approval(
id: str,
payload: FreightSettlementSubmitApprovalBody,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
return freight_svc.submit_settlement_approval(
db,
tenant_no=tenant_no,
settlement_id=id,
body=payload,
user_id=user.id,
dept_id=user.dept_id,
)
@router.post("/approval/{approval_id}", response_model=FreightSettlementRead)
def process_settlement_approval(
approval_id: str,
payload: FreightSettlementApprovalActionBody,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
if payload.action not in ("approve", "reject"):
raise HTTPException(status_code=400, detail="action 必须为 approve 或 reject")
return freight_svc.process_settlement_approval(
db,
tenant_no=tenant_no,
approval_id=approval_id,
action=payload.action,
comment=payload.comment,
user_id=user.id,
)
@router.post("/{id}/withdraw-approval", response_model=FreightSettlementRead)
def withdraw_settlement_approval(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
return freight_svc.withdraw_settlement_approval(
db, tenant_no=tenant_no, settlement_id=id, user_id=user.id
)
@router.get("/{id}/approval-flow")
def get_settlement_approval_flow(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
):
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
freight_svc.get_settlement_row(db, tenant_no, id)
return freight_svc.get_approval_flow(db, id)
@router.post("/{id}/disburse", response_model=FreightSettlementRead)
def disburse_settlement(
id: str,
payload: FreightSettlementDisburseBody,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
return freight_svc.disburse_settlement(
db,
tenant_no=tenant_no,
settlement_id=id,
body=payload,
user_id=user.id,
dept_id=user.dept_id,
)
# 向后兼容旧接口
@router.post("/{id}/submit", response_model=FreightSettlementRead, deprecated=True)
def submit_settlement_legacy(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
raise HTTPException(status_code=400, detail="请使用 submit-approval 接口并选择审批人")
@router.post("/{id}/approve", response_model=FreightSettlementRead, deprecated=True)
def approve_settlement_legacy(
id: str,
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> FreightSettlementRead:
raise HTTPException(status_code=400, detail="请使用 approval/{approvalId} 接口审批")
@router.get("/voucher/{settlement_id}", response_model=list[RemittanceVoucherRead])
@@ -299,35 +253,8 @@ def list_vouchers(
user: DbUserContext = Depends(get_db_current_user),
) -> list[RemittanceVoucherRead]:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
vouchers = (
db.query(PlRemittanceVoucher)
.filter(
PlRemittanceVoucher.settlement_id == settlement_id,
PlRemittanceVoucher.tenant_no == tenant_no,
PlRemittanceVoucher.del_flag == 0,
)
.order_by(PlRemittanceVoucher.create_time.desc())
.all()
freight_svc.get_settlement_row(db, tenant_no, settlement_id)
detail = freight_svc.get_settlement_detail(
db, tenant_no=tenant_no, settlement_id=settlement_id, user_id=user.id
)
return vouchers
# =============================================================================
# 辅助函数
# =============================================================================
def _get_settlement(db: Session, tenant_no: str, settlement_id: str) -> PlFreightSettlement:
settlement = (
db.query(PlFreightSettlement)
.filter(
PlFreightSettlement.id == settlement_id,
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
)
.first()
)
if not settlement:
raise HTTPException(status_code=404, detail="结算单不存在")
return settlement
return detail.get("vouchers") or []
+49 -13
View File
@@ -2,7 +2,7 @@
from datetime import date
from typing import Optional
from fastapi import APIRouter, Depends, HTTPException, Query, status
from fastapi import APIRouter, Body, Depends, HTTPException, Query, status
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
@@ -27,6 +27,7 @@ from app.models.pl_models import (
from app.schemas.pl import PlanProductCreate
from app.schemas.pl.plan import (
CreateFromContractRequest,
PlanArchiveBody,
PlanCreate,
PlanCreateFull,
PlanListQuery,
@@ -43,11 +44,14 @@ from app.services.pl_inventory_link_read import build_transport_inventory_link_r
from app.services.pl_site_link_read import build_transport_site_link_read_from_row
from app.services.pl_transport_site_service import revoke_site_links_for_transport
from app.services.pl_plan_service import (
apply_archive_freight,
apply_archive_product_quantities,
apply_vehicle_prefill_to_plan,
build_plan_product,
calc_plan_total_amount,
clear_draft_transport_for_plan,
determine_plan_type,
record_plan_change,
resolve_hazard_flags_from_crm,
sync_transport_prefill_for_plan,
update_plan_product_certs,
@@ -586,10 +590,6 @@ def update_plan(
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
plan = _get_plan(db, tenant_no, id)
# 不能修改已归档的计划
if plan.archive_status == "archived":
raise HTTPException(status_code=400, detail="已归档的计划不能修改")
# 更新主表字段
update_data = payload.model_dump(exclude_unset=True, exclude={"products", "transport"})
for key, value in update_data.items():
@@ -897,24 +897,60 @@ def cancel_plan(
# =============================================================================
@router.post("/{id}/archive", response_model=PlanRead)
@router.post("/{id}/archive", response_model=PlanWithProducts)
def archive_plan(
id: str,
payload: Optional[PlanArchiveBody] = Body(default=None),
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> PlanRead:
) -> PlanWithProducts:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
plan = _get_plan(db, tenant_no, id)
if plan.archive_status == "archived":
raise HTTPException(status_code=400, detail="计划已归档")
if plan.follow_status == "cancelled":
raise HTTPException(status_code=400, detail="已作废的计划不能归档")
already_archived = plan.archive_status == "archived"
if payload is None:
if already_archived:
raise HTTPException(status_code=400, detail="计划已归档,请提交归档表单以调整内容")
plan.archive_status = "archived"
plan.complete_status = "yes"
plan.follow_status = "completed"
plan.update_by = user.id
db.commit()
return get_plan(id, db, user)
apply_archive_product_quantities(
db, tenant_no=tenant_no, plan=plan, items=payload.products, user_id=user.id
)
if payload.freight is not None:
apply_archive_freight(
db, tenant_no=tenant_no, plan=plan, freight=payload.freight, user_id=user.id
)
elif int(plan.has_freight or 0) == 1 and not already_archived:
if not plan.transport_id:
raise HTTPException(status_code=400, detail="计划有运输费用但未安排运输,请先安排运输")
if not already_archived:
plan.archive_status = "archived"
plan.complete_status = "yes"
plan.follow_status = "completed"
plan.archive_status = "archived"
plan.complete_status = "yes"
plan.update_by = user.id
record_plan_change(
db,
tenant_no=tenant_no,
plan_id=plan.id,
change_type="archive_adjust" if already_archived else "archive",
change_content="调整归档内容" if already_archived else "运输计划归档",
user_id=user.id,
user_name=user.name or None,
dept_id=user.dept_id,
)
db.commit()
db.refresh(plan)
return plan
return get_plan(id, db, user)
# =============================================================================
+27
View File
@@ -549,6 +549,33 @@ class PlFreightSettlement(Base):
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
class PlFreightSettlementApproval(Base):
"""运费结算审批 pl_freight_settlement_approval"""
__tablename__ = "pl_freight_settlement_approval"
id = Column(String(64), primary_key=True, comment="主键ID")
settlement_id = Column(String(64), nullable=False, comment="结算单ID")
step = Column(Integer, nullable=False, default=1, comment="步骤序号")
step_name = Column(String(50), nullable=True, comment="步骤名称")
approver_id = Column(String(64), nullable=False, comment="审批人ID")
approver_name = Column(String(64), nullable=True, comment="审批人姓名")
approval_type = Column(String(20), nullable=False, default="sequential", comment="审批类型")
approval_result = Column(String(20), nullable=False, default="pending", comment="审批结果")
approval_opinion = Column(String(500), nullable=True, comment="审批意见")
approval_time = Column(DateTime, nullable=True, comment="审批时间")
is_current = Column(SmallInteger, nullable=False, default=0, comment="是否当前节点")
tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
order_num = Column(Integer, nullable=True, comment="排序号")
remark = Column(String(512), nullable=True, comment="备注")
create_by = Column(String(64), nullable=True, comment="创建人id")
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
update_by = Column(String(64), nullable=True, comment="更新人id")
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
class PlFreightSettlementTransport(Base):
"""结算单-运输关联表 pl_freight_settlement_transport"""
+105 -7
View File
@@ -1,9 +1,9 @@
"""运输计划管理 - 运费结算 Schema"""
from datetime import date, datetime
from decimal import Decimal
from typing import Optional
from typing import Any, Optional
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, model_validator
# =============================================================================
@@ -21,15 +21,21 @@ class FreightSettlementBase(BaseModel):
class FreightSettlementCreate(BaseModel):
transport_ids: list[str] = Field(..., alias="transportIds", description="运输ID列表")
transport_ids: Optional[list[str]] = Field(default=None, alias="transportIds", description="运输ID列表")
plan_ids: Optional[list[str]] = Field(default=None, alias="planIds", description="计划ID列表")
model_config = {"populate_by_name": True}
@model_validator(mode="after")
def check_ids(self):
if not self.transport_ids and not self.plan_ids:
raise ValueError("transportIds 或 planIds 至少提供一个")
return self
class FreightSettlementUpdate(BaseModel):
invoice_amount: Optional[Decimal] = Field(default=None, alias="invoiceAmount")
invoice_no: Optional[str] = Field(default=None, max_length=50, alias="invoiceNo")
invoice_date: Optional[date] = Field(default=None, alias="invoiceDate")
settlement_status: Optional[str] = Field(default=None, alias="settlementStatus")
remark: Optional[str] = None
model_config = {"populate_by_name": True}
@@ -48,8 +54,18 @@ class FreightSettlementRead(FreightSettlementBase):
model_config = {"from_attributes": True, "populate_by_name": True}
class FreightSettlementWithTransports(FreightSettlementRead):
transports: list = []
class FreightSettlementListItem(FreightSettlementRead):
plan_count: int = Field(default=0, alias="planCount")
license_plate_summary: Optional[str] = Field(default=None, alias="licensePlateSummary")
current_approver_name: Optional[str] = Field(default=None, alias="currentApproverName")
can_approve: bool = Field(default=False, alias="canApprove")
can_withdraw: bool = Field(default=False, alias="canWithdraw")
current_approval_id: Optional[str] = Field(default=None, alias="currentApprovalId")
approval_finished_time: Optional[datetime] = Field(default=None, alias="approvalFinishedTime")
disburse_time: Optional[datetime] = Field(default=None, alias="disburseTime")
disburse_amount: Optional[Decimal] = Field(default=None, alias="disburseAmount")
submitter_name: Optional[str] = Field(default=None, alias="submitterName")
model_config = {"from_attributes": True, "populate_by_name": True}
class FreightSettlementTransportRead(BaseModel):
@@ -62,6 +78,85 @@ class FreightSettlementTransportRead(BaseModel):
model_config = {"from_attributes": True, "populate_by_name": True}
class UnsettledPlanItem(BaseModel):
id: str
plan_no: str = Field(alias="planNo")
plan_date: date = Field(alias="planDate")
plan_type: str = Field(alias="planType")
customer_name: Optional[str] = Field(default=None, alias="customerName")
supplier_name: Optional[str] = Field(default=None, alias="supplierName")
license_plate: Optional[str] = Field(default=None, alias="licensePlate")
transport_company: Optional[str] = Field(default=None, alias="transportCompany")
freight_amount: Decimal = Field(default=Decimal("0"), alias="freightAmount")
archive_time: Optional[datetime] = Field(default=None, alias="archiveTime")
model_config = {"populate_by_name": True}
class UnsettledPlanListResponse(BaseModel):
total: int
list: list[UnsettledPlanItem]
class SettlementPlanSummary(BaseModel):
id: str
plan_no: str = Field(alias="planNo")
plan_date: Optional[date] = Field(default=None, alias="planDate")
license_plate: Optional[str] = Field(default=None, alias="licensePlate")
freight_amount: Optional[Decimal] = Field(default=None, alias="freightAmount")
model_config = {"populate_by_name": True}
class SettlementApprovalFlowItem(BaseModel):
id: str
step: int
step_name: Optional[str] = Field(default=None, alias="stepName")
approver_id: str = Field(alias="approverId")
approver_name: Optional[str] = Field(default=None, alias="approverName")
approval_type: Optional[str] = Field(default=None, alias="approvalType")
approval_result: str = Field(alias="approvalResult")
approval_opinion: Optional[str] = Field(default=None, alias="approvalOpinion")
approval_time: Optional[datetime] = Field(default=None, alias="approvalTime")
is_current: int = Field(default=0, alias="isCurrent")
model_config = {"populate_by_name": True}
class FreightSettlementWithTransports(FreightSettlementRead):
transports: list = []
plans: list[SettlementPlanSummary] = []
approval_flow: list[SettlementApprovalFlowItem] = Field(default_factory=list, alias="approvalFlow")
vouchers: list = []
plan_count: int = Field(default=0, alias="planCount")
license_plate_summary: Optional[str] = Field(default=None, alias="licensePlateSummary")
current_approver_name: Optional[str] = Field(default=None, alias="currentApproverName")
can_approve: bool = Field(default=False, alias="canApprove")
can_withdraw: bool = Field(default=False, alias="canWithdraw")
current_approval_id: Optional[str] = Field(default=None, alias="currentApprovalId")
approval_finished_time: Optional[datetime] = Field(default=None, alias="approvalFinishedTime")
disburse_time: Optional[datetime] = Field(default=None, alias="disburseTime")
disburse_amount: Optional[Decimal] = Field(default=None, alias="disburseAmount")
submitter_name: Optional[str] = Field(default=None, alias="submitterName")
class FreightSettlementSubmitApprovalBody(BaseModel):
approval_type: str = Field(default="sequential", alias="approvalType")
approver_ids: list[str] = Field(..., alias="approverIds", min_length=1)
remark: Optional[str] = None
model_config = {"populate_by_name": True}
class FreightSettlementApprovalActionBody(BaseModel):
action: str = Field(..., description="approve|reject")
comment: Optional[str] = None
class FreightSettlementDisburseBody(BaseModel):
remittance_date: date = Field(..., alias="remittanceDate")
remittance_amount: Decimal = Field(..., alias="remittanceAmount", gt=0)
voucher_urls: list[str] = Field(..., alias="voucherUrls", min_length=1)
remark: Optional[str] = None
model_config = {"populate_by_name": True}
# =============================================================================
# 汇款凭证 Schema
# =============================================================================
@@ -83,7 +178,9 @@ class RemittanceVoucherRead(BaseModel):
remittance_date: Optional[date] = Field(default=None, alias="remittanceDate")
remittance_amount: Optional[Decimal] = Field(default=None, alias="remittanceAmount")
voucher_urls: Optional[str] = Field(default=None, alias="voucherUrls")
remark: Optional[str] = None
tenant_no: str = Field(alias="tenantNo")
create_by: Optional[str] = Field(default=None, alias="createBy")
create_time: datetime = Field(alias="createTime")
model_config = {"from_attributes": True, "populate_by_name": True}
@@ -96,6 +193,7 @@ class RemittanceVoucherRead(BaseModel):
class FreightSettlementListQuery(BaseModel):
q: Optional[str] = Field(default=None, description="模糊搜索")
settlement_status: Optional[str] = Field(default=None, alias="settlementStatus", description="结算状态")
tab: Optional[str] = Field(default=None, description="bills|disburse|settled")
page: int = Field(default=1, ge=1)
page_size: int = Field(default=20, ge=1, le=100, alias="pageSize")
model_config = {"populate_by_name": True}
@@ -103,4 +201,4 @@ class FreightSettlementListQuery(BaseModel):
class FreightSettlementListResponse(BaseModel):
total: int
list: list[FreightSettlementRead]
list: list[FreightSettlementListItem]
+23
View File
@@ -248,6 +248,29 @@ class PlanProductCertsUpdate(BaseModel):
model_config = {"populate_by_name": True}
class PlanArchiveProductItem(BaseModel):
id: str = Field(..., description="计划产品明细ID pl_plan_product.id")
actual_qty: Decimal = Field(..., alias="actualQty", ge=0, description="实际数量")
model_config = {"populate_by_name": True}
class PlanArchiveFreightBlock(BaseModel):
has_freight: int = Field(default=1, alias="hasFreight", description="是否有运输费用 0-否 1-是")
distance_km: Optional[Decimal] = Field(default=None, alias="distanceKm")
freight_type: str = Field(default="by_weight", alias="freightType")
freight_price: Optional[Decimal] = Field(default=None, alias="freightPrice")
freight_amount: Optional[Decimal] = Field(default=None, alias="freightAmount")
transport_qty: Optional[Decimal] = Field(default=None, alias="transportQty")
has_invoice: Optional[int] = Field(default=None, alias="hasInvoice")
model_config = {"populate_by_name": True}
class PlanArchiveBody(BaseModel):
products: list[PlanArchiveProductItem] = Field(..., min_length=1)
freight: Optional[PlanArchiveFreightBlock] = None
model_config = {"populate_by_name": True}
class PlanListResponse(BaseModel):
total: int
list: list[PlanWithProducts]
@@ -0,0 +1,861 @@
"""运费结算业务服务"""
from __future__ import annotations
import json
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple
from fastapi import HTTPException
from sqlalchemy import func, or_
from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.models import SysUser
from app.models.pl_models import (
PlFreightSettlement,
PlFreightSettlementApproval,
PlFreightSettlementTransport,
PlPlan,
PlRemittanceVoucher,
PlTransport,
)
from app.schemas.pl.freight import (
FreightSettlementDisburseBody,
FreightSettlementSubmitApprovalBody,
FreightSettlementUpdate,
)
_FMT = "%Y-%m-%d %H:%M:%S"
TAB_STATUS_MAP = {
"bills": ("pending", "approving"),
"disburse": ("approved",),
"settled": ("confirmed",),
}
def _resolve_user_display_name(db: Session, user_id: str) -> str:
uid = (user_id or "").strip()
if not uid:
return ""
u = db.query(SysUser).filter(SysUser.id == uid, SysUser.del_flag == 0).first()
if not u:
return ""
return (u.nick_name or u.user_no or "").strip()
def _occupied_transport_ids_subquery(db: Session, tenant_no: str):
return (
db.query(PlFreightSettlementTransport.transport_id)
.join(
PlFreightSettlement,
PlFreightSettlement.id == PlFreightSettlementTransport.settlement_id,
)
.filter(
PlFreightSettlementTransport.tenant_no == tenant_no,
PlFreightSettlementTransport.del_flag == 0,
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
)
)
def get_settlement_row(db: Session, tenant_no: str, settlement_id: str) -> PlFreightSettlement:
row = (
db.query(PlFreightSettlement)
.filter(
PlFreightSettlement.id == settlement_id,
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
)
.first()
)
if not row:
raise HTTPException(status_code=404, detail="结算单不存在")
return row
def list_unsettled_plans(
db: Session,
*,
tenant_no: str,
q: Optional[str] = None,
plan_type: Optional[str] = None,
license_plate: Optional[str] = None,
page: int = 1,
page_size: int = 20,
) -> Tuple[int, List[Dict[str, Any]]]:
occupied = _occupied_transport_ids_subquery(db, tenant_no).subquery()
query = (
db.query(PlPlan, PlTransport)
.join(PlTransport, PlTransport.id == PlPlan.transport_id)
.filter(
PlPlan.tenant_no == tenant_no,
PlPlan.del_flag == 0,
PlPlan.archive_status == "archived",
PlPlan.has_freight == 1,
PlPlan.follow_status != "cancelled",
PlPlan.transport_id.isnot(None),
PlTransport.del_flag == 0,
PlTransport.freight_amount > 0,
~PlPlan.transport_id.in_(occupied),
)
)
if q:
query = query.filter(
or_(
PlPlan.plan_no.contains(q),
PlPlan.customer_name.contains(q),
PlPlan.supplier_name.contains(q),
)
)
if plan_type:
query = query.filter(PlPlan.plan_type == plan_type)
if license_plate:
query = query.filter(PlPlan.license_plate.contains(license_plate))
total = query.count()
rows = (
query.order_by(PlPlan.update_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
items: List[Dict[str, Any]] = []
for plan, transport in rows:
items.append(
{
"id": plan.id,
"planNo": plan.plan_no,
"planDate": plan.plan_date,
"planType": plan.plan_type,
"customerName": plan.customer_name,
"supplierName": plan.supplier_name,
"licensePlate": plan.license_plate or transport.license_plate,
"transportCompany": transport.carrier_name,
"freightAmount": plan.freight_amount or transport.freight_amount,
"archiveTime": plan.update_time,
}
)
return total, items
def _resolve_transports_for_create(
db: Session, tenant_no: str, *, plan_ids: Optional[List[str]], transport_ids: Optional[List[str]]
) -> List[PlTransport]:
ids: List[str] = []
if plan_ids:
plans = (
db.query(PlPlan)
.filter(
PlPlan.id.in_(plan_ids),
PlPlan.tenant_no == tenant_no,
PlPlan.del_flag == 0,
)
.all()
)
if len(plans) != len(set(plan_ids)):
raise HTTPException(status_code=400, detail="存在无效的计划")
for p in plans:
if p.archive_status != "archived":
raise HTTPException(status_code=400, detail=f"计划 {p.plan_no} 未归档,不能结算")
if int(p.has_freight or 0) != 1:
raise HTTPException(status_code=400, detail=f"计划 {p.plan_no} 无运输费用")
if not p.transport_id:
raise HTTPException(status_code=400, detail=f"计划 {p.plan_no} 未安排运输")
ids.append(p.transport_id)
if transport_ids:
ids.extend(transport_ids)
ids = list(dict.fromkeys(ids))
if not ids:
raise HTTPException(status_code=400, detail="请选择有效的运输单")
occupied = {r[0] for r in _occupied_transport_ids_subquery(db, tenant_no).all()}
conflict = [tid for tid in ids if tid in occupied]
if conflict:
raise HTTPException(status_code=400, detail="所选运输单已纳入其他结算单")
transports = (
db.query(PlTransport)
.filter(
PlTransport.id.in_(ids),
PlTransport.tenant_no == tenant_no,
PlTransport.del_flag == 0,
)
.all()
)
if len(transports) != len(ids):
raise HTTPException(status_code=400, detail="请选择有效的运输单")
return transports
def create_settlement(
db: Session,
*,
tenant_no: str,
plan_ids: Optional[List[str]],
transport_ids: Optional[List[str]],
user_id: str,
dept_id: str,
settlement_no: str,
) -> PlFreightSettlement:
transports = _resolve_transports_for_create(
db, tenant_no, plan_ids=plan_ids, transport_ids=transport_ids
)
total_freight = sum(Decimal(str(t.freight_amount or 0)) for t in transports)
settlement = PlFreightSettlement(
id=generate_uuid(),
tenant_no=tenant_no,
settlement_no=settlement_no,
total_freight=total_freight,
settlement_status="pending",
create_by=user_id,
create_dept_id=dept_id or "",
)
db.add(settlement)
for t in transports:
db.add(
PlFreightSettlementTransport(
id=generate_uuid(),
tenant_no=tenant_no,
settlement_id=settlement.id,
transport_id=t.id,
freight_amount=t.freight_amount,
create_by=user_id,
create_dept_id=dept_id or "",
)
)
db.commit()
db.refresh(settlement)
return settlement
def delete_draft_settlement(db: Session, *, tenant_no: str, settlement_id: str, user_id: str) -> None:
settlement = get_settlement_row(db, tenant_no, settlement_id)
if settlement.settlement_status != "pending":
raise HTTPException(status_code=400, detail="仅草稿结算单可删除")
now = datetime.now()
settlement.del_flag = 1
settlement.update_by = user_id
settlement.update_time = now
links = (
db.query(PlFreightSettlementTransport)
.filter(
PlFreightSettlementTransport.settlement_id == settlement_id,
PlFreightSettlementTransport.del_flag == 0,
)
.all()
)
for link in links:
link.del_flag = 1
link.update_time = now
db.commit()
def _get_transport_ids(db: Session, settlement_id: str) -> List[str]:
return [
r.transport_id
for r in db.query(PlFreightSettlementTransport)
.filter(
PlFreightSettlementTransport.settlement_id == settlement_id,
PlFreightSettlementTransport.del_flag == 0,
)
.all()
]
def _get_plans_for_transports(db: Session, tenant_no: str, transport_ids: List[str]) -> List[PlPlan]:
if not transport_ids:
return []
return (
db.query(PlPlan)
.filter(
PlPlan.tenant_no == tenant_no,
PlPlan.del_flag == 0,
PlPlan.transport_id.in_(transport_ids),
)
.all()
)
def _approval_to_dict(row: PlFreightSettlementApproval) -> Dict[str, Any]:
return {
"id": row.id,
"step": row.step,
"stepName": row.step_name,
"approverId": row.approver_id,
"approverName": row.approver_name,
"approvalType": row.approval_type,
"approvalResult": row.approval_result,
"approvalOpinion": row.approval_opinion,
"approvalTime": row.approval_time,
"isCurrent": row.is_current,
}
def create_settlement_approval_records(
db: Session,
*,
tenant_no: str,
settlement_id: str,
approval_type: str,
approver_ids: List[str],
user_id: str,
dept_id: str,
) -> None:
approval_type = (approval_type or "sequential").strip() or "sequential"
cleaned = [aid.strip() for aid in approver_ids if (aid or "").strip()]
if not cleaned:
raise HTTPException(status_code=400, detail="请选择审批人")
if approval_type in ("parallel", "or"):
step = 1
for idx, aid in enumerate(cleaned):
nick = _resolve_user_display_name(db, aid) or f"用户{aid}"
db.add(
PlFreightSettlementApproval(
id=generate_uuid(),
settlement_id=settlement_id,
step=step,
step_name="会签审批" if approval_type == "parallel" else "或签审批",
approver_id=aid,
approver_name=nick,
approval_type=approval_type,
approval_result="pending",
is_current=1,
tenant_no=tenant_no,
create_by=user_id,
create_dept_id=dept_id or "",
)
)
else:
step = 1
for idx, aid in enumerate(cleaned):
nick = _resolve_user_display_name(db, aid) or f"用户{aid}"
db.add(
PlFreightSettlementApproval(
id=generate_uuid(),
settlement_id=settlement_id,
step=step,
step_name=f"第{step}步审批",
approver_id=aid,
approver_name=nick,
approval_type="sequential",
approval_result="pending",
is_current=1 if idx == 0 else 0,
tenant_no=tenant_no,
create_by=user_id,
create_dept_id=dept_id or "",
)
)
step += 1
db.flush()
def can_user_approve_settlement(db: Session, settlement_id: str, user_id: str) -> bool:
if not settlement_id or not user_id:
return False
approvals = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.del_flag == 0,
)
.order_by(PlFreightSettlementApproval.step.asc())
.all()
)
if not approvals:
return False
user_approval = next((a for a in approvals if a.approver_id == user_id), None)
if not user_approval or user_approval.approval_result != "pending" or user_approval.is_current != 1:
return False
approval_type = user_approval.approval_type or "sequential"
if approval_type == "sequential":
for approval in approvals:
if approval.step == user_approval.step:
break
if approval.approval_result != "approved":
return False
return True
def _settlement_all_approved(db: Session, settlement_id: str) -> bool:
pending = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.approval_result == "pending",
PlFreightSettlementApproval.del_flag == 0,
)
.count()
)
return pending == 0
def _advance_after_approval(
db: Session, settlement: PlFreightSettlement, current: PlFreightSettlementApproval, result: str
) -> None:
now = datetime.now()
if result == "rejected":
settlement.settlement_status = "pending"
settlement.update_time = now
return
approval_type = current.approval_type or "sequential"
step = current.step
if approval_type == "or":
others = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement.id,
PlFreightSettlementApproval.step == step,
PlFreightSettlementApproval.id != current.id,
PlFreightSettlementApproval.del_flag == 0,
)
.all()
)
for row in others:
if row.approval_result == "pending":
row.approval_result = "skipped"
row.is_current = 0
row.update_time = now
elif approval_type == "parallel":
step_pending = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement.id,
PlFreightSettlementApproval.step == step,
PlFreightSettlementApproval.approval_result == "pending",
PlFreightSettlementApproval.del_flag == 0,
)
.count()
)
if step_pending > 0:
return
else:
nxt = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement.id,
PlFreightSettlementApproval.approval_result == "pending",
PlFreightSettlementApproval.step > step,
PlFreightSettlementApproval.del_flag == 0,
)
.order_by(PlFreightSettlementApproval.step.asc())
.first()
)
if nxt:
nxt.is_current = 1
nxt.update_time = now
return
if _settlement_all_approved(db, settlement.id):
settlement.settlement_status = "approved"
settlement.update_time = now
def submit_settlement_approval(
db: Session,
*,
tenant_no: str,
settlement_id: str,
body: FreightSettlementSubmitApprovalBody,
user_id: str,
dept_id: str,
) -> PlFreightSettlement:
settlement = get_settlement_row(db, tenant_no, settlement_id)
if settlement.settlement_status != "pending":
raise HTTPException(status_code=400, detail="仅草稿状态可提交审批")
settlement.settlement_status = "approving"
if body.remark:
settlement.remark = body.remark
settlement.update_by = user_id
db.flush()
create_settlement_approval_records(
db,
tenant_no=tenant_no,
settlement_id=settlement_id,
approval_type=body.approval_type,
approver_ids=body.approver_ids,
user_id=user_id,
dept_id=dept_id,
)
db.commit()
db.refresh(settlement)
return settlement
def process_settlement_approval(
db: Session,
*,
tenant_no: str,
approval_id: str,
action: str,
comment: Optional[str],
user_id: str,
) -> PlFreightSettlement:
approval = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.id == approval_id,
PlFreightSettlementApproval.tenant_no == tenant_no,
PlFreightSettlementApproval.del_flag == 0,
)
.first()
)
if not approval:
raise HTTPException(status_code=404, detail="审批记录不存在")
settlement = get_settlement_row(db, tenant_no, approval.settlement_id)
if settlement.settlement_status != "approving":
raise HTTPException(status_code=400, detail="结算单不在审批中")
if approval.approver_id != user_id:
raise HTTPException(status_code=403, detail="只有审批人才能审批")
if not can_user_approve_settlement(db, settlement.id, user_id):
raise HTTPException(status_code=400, detail="当前不可审批")
result = "approved" if action == "approve" else "rejected"
now = datetime.now()
approval.approval_result = result
approval.approval_opinion = comment or ""
approval.approval_time = now
approval.is_current = 0
approval.update_by = user_id
approval.update_time = now
_advance_after_approval(db, settlement, approval, result)
settlement.update_by = user_id
db.commit()
db.refresh(settlement)
return settlement
def withdraw_settlement_approval(
db: Session, *, tenant_no: str, settlement_id: str, user_id: str
) -> PlFreightSettlement:
settlement = get_settlement_row(db, tenant_no, settlement_id)
if settlement.settlement_status != "approving":
raise HTTPException(status_code=400, detail="仅审批中可撤回")
if settlement.create_by != user_id:
raise HTTPException(status_code=403, detail="仅提交人可撤回")
now = datetime.now()
rows = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.del_flag == 0,
)
.all()
)
for row in rows:
row.del_flag = 1
row.update_time = now
settlement.settlement_status = "pending"
settlement.update_by = user_id
settlement.update_time = now
db.commit()
db.refresh(settlement)
return settlement
def disburse_settlement(
db: Session,
*,
tenant_no: str,
settlement_id: str,
body: FreightSettlementDisburseBody,
user_id: str,
dept_id: str,
) -> PlFreightSettlement:
settlement = get_settlement_row(db, tenant_no, settlement_id)
if settlement.settlement_status != "approved":
raise HTTPException(status_code=400, detail="仅待发放状态可登记")
total = Decimal(str(settlement.total_freight or 0))
amount = Decimal(str(body.remittance_amount))
if amount != total and not (body.remark or "").strip():
raise HTTPException(status_code=400, detail="汇款金额与运费合计不一致时备注必填")
db.add(
PlRemittanceVoucher(
id=generate_uuid(),
tenant_no=tenant_no,
settlement_id=settlement.id,
remittance_date=body.remittance_date,
remittance_amount=body.remittance_amount,
voucher_urls=json.dumps(body.voucher_urls),
remark=body.remark,
create_by=user_id,
create_dept_id=dept_id or "",
)
)
settlement.settlement_status = "confirmed"
settlement.update_by = user_id
db.commit()
db.refresh(settlement)
return settlement
def get_approval_flow(db: Session, settlement_id: str) -> List[Dict[str, Any]]:
rows = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.del_flag == 0,
)
.order_by(PlFreightSettlementApproval.step.asc(), PlFreightSettlementApproval.create_time.asc())
.all()
)
return [_approval_to_dict(r) for r in rows]
def _current_approver_name(db: Session, settlement_id: str) -> Optional[str]:
row = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.approval_result == "pending",
PlFreightSettlementApproval.is_current == 1,
PlFreightSettlementApproval.del_flag == 0,
)
.order_by(PlFreightSettlementApproval.step.asc())
.first()
)
return row.approver_name if row else None
def _current_approval_id(db: Session, settlement_id: str, user_id: str) -> Optional[str]:
if not can_user_approve_settlement(db, settlement_id, user_id):
return None
row = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.approver_id == user_id,
PlFreightSettlementApproval.approval_result == "pending",
PlFreightSettlementApproval.is_current == 1,
PlFreightSettlementApproval.del_flag == 0,
)
.first()
)
return row.id if row else None
def _last_approval_time(db: Session, settlement_id: str) -> Optional[datetime]:
row = (
db.query(PlFreightSettlementApproval)
.filter(
PlFreightSettlementApproval.settlement_id == settlement_id,
PlFreightSettlementApproval.approval_result == "approved",
PlFreightSettlementApproval.del_flag == 0,
)
.order_by(PlFreightSettlementApproval.approval_time.desc())
.first()
)
return row.approval_time if row else None
def enrich_settlement_list_item(
db: Session, settlement: PlFreightSettlement, user_id: str
) -> Dict[str, Any]:
transport_ids = _get_transport_ids(db, settlement.id)
plans = _get_plans_for_transports(db, settlement.tenant_no, transport_ids)
plates = [p.license_plate for p in plans if p.license_plate]
if not plates:
transports = (
db.query(PlTransport)
.filter(PlTransport.id.in_(transport_ids), PlTransport.del_flag == 0)
.all()
if transport_ids
else []
)
plates = [t.license_plate for t in transports if t.license_plate]
voucher = (
db.query(PlRemittanceVoucher)
.filter(
PlRemittanceVoucher.settlement_id == settlement.id,
PlRemittanceVoucher.del_flag == 0,
)
.order_by(PlRemittanceVoucher.create_time.desc())
.first()
)
submitter = _resolve_user_display_name(db, settlement.create_by or "")
item = {
"id": settlement.id,
"settlementNo": settlement.settlement_no,
"totalFreight": settlement.total_freight,
"invoiceAmount": settlement.invoice_amount,
"invoiceNo": settlement.invoice_no,
"invoiceDate": settlement.invoice_date,
"settlementStatus": settlement.settlement_status,
"remark": settlement.remark,
"tenantNo": settlement.tenant_no,
"orderNum": settlement.order_num,
"createBy": settlement.create_by,
"createDeptId": settlement.create_dept_id,
"createTime": settlement.create_time,
"updateBy": settlement.update_by,
"updateTime": settlement.update_time,
"delFlag": settlement.del_flag,
"planCount": len(plans),
"licensePlateSummary": "、".join(plates[:3]) + ("…" if len(plates) > 3 else ""),
"currentApproverName": _current_approver_name(db, settlement.id),
"canApprove": can_user_approve_settlement(db, settlement.id, user_id),
"canWithdraw": settlement.settlement_status == "approving" and settlement.create_by == user_id,
"currentApprovalId": _current_approval_id(db, settlement.id, user_id),
"approvalFinishedTime": _last_approval_time(db, settlement.id),
"disburseTime": voucher.create_time if voucher else None,
"disburseAmount": voucher.remittance_amount if voucher else None,
"submitterName": submitter or None,
}
return item
def list_settlements_enriched(
db: Session,
*,
tenant_no: str,
user_id: str,
q: Optional[str] = None,
settlement_status: Optional[str] = None,
tab: Optional[str] = None,
page: int = 1,
page_size: int = 20,
) -> Tuple[int, List[Dict[str, Any]]]:
query = db.query(PlFreightSettlement).filter(
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
)
if tab and tab in TAB_STATUS_MAP:
query = query.filter(PlFreightSettlement.settlement_status.in_(TAB_STATUS_MAP[tab]))
elif settlement_status:
query = query.filter(PlFreightSettlement.settlement_status == settlement_status)
if q:
query = query.filter(PlFreightSettlement.settlement_no.contains(q))
total = query.count()
rows = (
query.order_by(PlFreightSettlement.create_time.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return total, [enrich_settlement_list_item(db, r, user_id) for r in rows]
def get_settlement_detail(
db: Session, *, tenant_no: str, settlement_id: str, user_id: str
) -> Dict[str, Any]:
settlement = get_settlement_row(db, tenant_no, settlement_id)
base = enrich_settlement_list_item(db, settlement, user_id)
transport_ids = _get_transport_ids(db, settlement_id)
transports = (
db.query(PlTransport)
.filter(PlTransport.id.in_(transport_ids), PlTransport.del_flag == 0)
.all()
if transport_ids
else []
)
plans = _get_plans_for_transports(db, tenant_no, transport_ids)
plan_summaries = [
{
"id": p.id,
"planNo": p.plan_no,
"planDate": p.plan_date,
"licensePlate": p.license_plate,
"freightAmount": p.freight_amount,
}
for p in plans
]
vouchers = (
db.query(PlRemittanceVoucher)
.filter(
PlRemittanceVoucher.settlement_id == settlement_id,
PlRemittanceVoucher.del_flag == 0,
)
.order_by(PlRemittanceVoucher.create_time.desc())
.all()
)
transport_payload = []
for t in transports:
transport_payload.append(
{
"id": t.id,
"transportNo": t.transport_no,
"licensePlate": t.license_plate,
"driverName": t.driver_name,
"freightAmount": t.freight_amount,
"transportStatus": t.transport_status,
"carrierName": t.carrier_name,
}
)
voucher_payload = []
for v in vouchers:
voucher_payload.append(
{
"id": v.id,
"settlementId": v.settlement_id,
"remittanceDate": v.remittance_date,
"remittanceAmount": v.remittance_amount,
"voucherUrls": v.voucher_urls,
"remark": v.remark,
"createBy": v.create_by,
"createTime": v.create_time,
}
)
base["transports"] = transport_payload
base["plans"] = plan_summaries
base["approvalFlow"] = get_approval_flow(db, settlement_id)
base["vouchers"] = voucher_payload
return base
def update_settlement_draft(
db: Session,
*,
tenant_no: str,
settlement_id: str,
payload: FreightSettlementUpdate,
user_id: str,
) -> PlFreightSettlement:
settlement = get_settlement_row(db, tenant_no, settlement_id)
if settlement.settlement_status != "pending":
raise HTTPException(status_code=400, detail="仅草稿可编辑")
update_data = payload.model_dump(exclude_unset=True, by_alias=False)
for key, value in update_data.items():
setattr(settlement, key, value)
settlement.update_by = user_id
db.commit()
db.refresh(settlement)
return settlement
+164 -1
View File
@@ -9,15 +9,24 @@ from sqlalchemy.orm import Session
from app.core.utils import generate_uuid
from app.models.pl_models import (
PlCarrier,
PlFreightSettlement,
PlFreightSettlementTransport,
PlPersonnel,
PlPlan,
PlPlanChange,
PlPlanProduct,
PlPlanTransport,
PlTransport,
PlVehicle,
PlVehiclePersonnel,
)
from app.schemas.pl.plan import PlanCreateFull, PlanProductCreate, PlanTransportCreateBlock
from app.schemas.pl.plan import (
PlanArchiveFreightBlock,
PlanArchiveProductItem,
PlanCreateFull,
PlanProductCreate,
PlanTransportCreateBlock,
)
def determine_plan_type(supplier_name: Optional[str], destination_name: Optional[str]) -> str:
@@ -702,3 +711,157 @@ def calc_plan_total_amount(products: list[PlanProductCreate]) -> Decimal:
if prod.tax_subtotal is not None:
total += Decimal(str(prod.tax_subtotal))
return total
_LOCKED_SETTLEMENT_STATUSES = ("approving", "approved", "confirmed")
def transport_has_locked_freight_settlement(
db: Session, tenant_no: str, transport_id: Optional[str]
) -> bool:
if not transport_id:
return False
return (
db.query(PlFreightSettlementTransport.id)
.join(
PlFreightSettlement,
PlFreightSettlement.id == PlFreightSettlementTransport.settlement_id,
)
.filter(
PlFreightSettlementTransport.transport_id == transport_id,
PlFreightSettlementTransport.tenant_no == tenant_no,
PlFreightSettlementTransport.del_flag == 0,
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
PlFreightSettlement.settlement_status.in_(_LOCKED_SETTLEMENT_STATUSES),
)
.first()
is not None
)
def apply_archive_product_quantities(
db: Session,
*,
tenant_no: str,
plan: PlPlan,
items: list[PlanArchiveProductItem],
user_id: str,
) -> None:
product_map = {
row.id: row
for row in db.query(PlPlanProduct).filter(
PlPlanProduct.plan_id == plan.id,
PlPlanProduct.tenant_no == tenant_no,
PlPlanProduct.del_flag == 0,
).all()
}
for item in items:
prod = product_map.get(item.id)
if not prod:
raise HTTPException(status_code=400, detail=f"产品明细不存在: {item.id}")
actual = Decimal(str(item.actual_qty))
prod.actual_qty = actual
price_in = prod.inbound_price or prod.tax_price
price_out = prod.outbound_price or prod.tax_price
if plan.plan_type == "inbound":
prod.inbound_qty = actual
if price_in is not None:
prod.inbound_amount = actual * Decimal(str(price_in))
elif plan.plan_type == "outbound":
prod.outbound_qty = actual
if price_out is not None:
prod.outbound_amount = actual * Decimal(str(price_out))
prod.update_by = user_id
def apply_archive_freight(
db: Session,
*,
tenant_no: str,
plan: PlPlan,
freight: PlanArchiveFreightBlock,
user_id: str,
) -> None:
has_freight = int(freight.has_freight if freight.has_freight is not None else plan.has_freight or 0)
plan.has_freight = has_freight
plan.update_by = user_id
if has_freight != 1:
plan.freight_amount = Decimal("0")
if not plan.transport_id:
return
if transport_has_locked_freight_settlement(db, tenant_no, plan.transport_id):
raise HTTPException(status_code=400, detail="运输单已纳入运费结算,无法修改运费")
transport = (
db.query(PlTransport)
.filter(
PlTransport.id == plan.transport_id,
PlTransport.tenant_no == tenant_no,
PlTransport.del_flag == 0,
)
.first()
)
if not transport:
raise HTTPException(status_code=400, detail="关联运输单不存在")
transport.freight_amount = Decimal("0")
transport.freight_price = None
transport.transport_qty = None
transport.update_by = user_id
return
if not plan.transport_id:
raise HTTPException(status_code=400, detail="计划有运输费用但未安排运输,请先安排运输")
if transport_has_locked_freight_settlement(db, tenant_no, plan.transport_id):
raise HTTPException(status_code=400, detail="运输单已纳入运费结算,无法修改运费")
transport = (
db.query(PlTransport)
.filter(
PlTransport.id == plan.transport_id,
PlTransport.tenant_no == tenant_no,
PlTransport.del_flag == 0,
)
.first()
)
if not transport:
raise HTTPException(status_code=400, detail="关联运输单不存在")
transport.distance_km = freight.distance_km
transport.freight_type = freight.freight_type or "by_weight"
transport.freight_price = freight.freight_price
amount = freight.freight_amount or Decimal("0")
transport.freight_amount = amount
if freight.transport_qty is not None:
transport.transport_qty = freight.transport_qty
if freight.has_invoice is not None:
transport.has_invoice = freight.has_invoice
transport.update_by = user_id
plan.freight_amount = amount
def record_plan_change(
db: Session,
*,
tenant_no: str,
plan_id: str,
change_type: str,
change_content: str,
user_id: str,
user_name: Optional[str],
dept_id: str,
) -> None:
db.add(
PlPlanChange(
id=generate_uuid(),
tenant_no=tenant_no,
plan_id=plan_id,
change_type=change_type,
change_content=change_content,
change_user_id=user_id,
change_user_name=user_name,
create_by=user_id,
create_dept_id=dept_id,
)
)
+13 -7
View File
@@ -55,6 +55,7 @@
"53": "Community 53",
"54": "Community 54",
"55": "Community 55",
"56": "Community 56",
"57": "Community 57",
"58": "Community 58",
"59": "Community 59",
@@ -64,6 +65,7 @@
"63": "Community 63",
"64": "Community 64",
"65": "Community 65",
"66": "Community 66",
"67": "Community 67",
"68": "Community 68",
"69": "Community 69",
@@ -76,6 +78,7 @@
"76": "Community 76",
"77": "Community 77",
"78": "Community 78",
"79": "Community 79",
"80": "Community 80",
"81": "Community 81",
"82": "Community 82",
@@ -83,13 +86,18 @@
"84": "Community 84",
"85": "Community 85",
"86": "Community 86",
"87": "Community 87",
"88": "Community 88",
"89": "Community 89",
"90": "Community 90",
"91": "Community 91",
"92": "Community 92",
"93": "Community 93",
"94": "Community 94",
"95": "Community 95",
"96": "Community 96",
"97": "Community 97",
"98": "Community 98",
"99": "Community 99",
"100": "Community 100",
"101": "Community 101",
@@ -100,6 +108,7 @@
"106": "Community 106",
"107": "Community 107",
"108": "Community 108",
"109": "Community 109",
"110": "Community 110",
"111": "Community 111",
"112": "Community 112",
@@ -114,19 +123,16 @@
"121": "Community 121",
"122": "Community 122",
"123": "Community 123",
"124": "Community 124",
"125": "Community 125",
"126": "Community 126",
"127": "Community 127",
"128": "Community 128",
"129": "Community 129",
"130": "Community 130",
"131": "Community 131",
"132": "Community 132",
"133": "Community 133",
"134": "Community 134",
"135": "Community 135",
"139": "Community 139",
"142": "Community 142",
"143": "Community 143",
"146": "Community 146",
"147": "Community 147",
"148": "Community 148"
"146": "Community 146"
}
+189 -163
View File
@@ -1,16 +1,16 @@
# Graph Report - backend (2026-06-23)
# Graph Report - backend (2026-06-25)
## Corpus Check
- 197 files · ~133,522 words
- 198 files · ~136,440 words
- Verdict: corpus is large enough that graph structure adds value.
## Summary
- 3989 nodes · 30269 edges · 130 communities (128 shown, 2 thin omitted)
- Extraction: 48% EXTRACTED · 52% INFERRED · 0% AMBIGUOUS · INFERRED: 15656 edges (avg confidence: 0.5)
- 4071 nodes · 30880 edges · 136 communities (133 shown, 3 thin omitted)
- Extraction: 48% EXTRACTED · 52% INFERRED · 0% AMBIGUOUS · INFERRED: 15981 edges (avg confidence: 0.5)
- Token cost: 0 input · 0 output
## Graph Freshness
- Built from commit: `c90f72fd`
- Built from commit: `6b6c80f1`
- Run `git rev-parse HEAD` and compare to check if the graph is stale.
- Run `graphify update .` after code changes (no API cost).
@@ -71,6 +71,7 @@
- [[_COMMUNITY_Community 53|Community 53]]
- [[_COMMUNITY_Community 54|Community 54]]
- [[_COMMUNITY_Community 55|Community 55]]
- [[_COMMUNITY_Community 56|Community 56]]
- [[_COMMUNITY_Community 57|Community 57]]
- [[_COMMUNITY_Community 58|Community 58]]
- [[_COMMUNITY_Community 59|Community 59]]
@@ -80,6 +81,7 @@
- [[_COMMUNITY_Community 63|Community 63]]
- [[_COMMUNITY_Community 64|Community 64]]
- [[_COMMUNITY_Community 65|Community 65]]
- [[_COMMUNITY_Community 66|Community 66]]
- [[_COMMUNITY_Community 67|Community 67]]
- [[_COMMUNITY_Community 68|Community 68]]
- [[_COMMUNITY_Community 69|Community 69]]
@@ -92,6 +94,7 @@
- [[_COMMUNITY_Community 76|Community 76]]
- [[_COMMUNITY_Community 77|Community 77]]
- [[_COMMUNITY_Community 78|Community 78]]
- [[_COMMUNITY_Community 79|Community 79]]
- [[_COMMUNITY_Community 80|Community 80]]
- [[_COMMUNITY_Community 81|Community 81]]
- [[_COMMUNITY_Community 82|Community 82]]
@@ -99,13 +102,18 @@
- [[_COMMUNITY_Community 84|Community 84]]
- [[_COMMUNITY_Community 85|Community 85]]
- [[_COMMUNITY_Community 86|Community 86]]
- [[_COMMUNITY_Community 87|Community 87]]
- [[_COMMUNITY_Community 88|Community 88]]
- [[_COMMUNITY_Community 89|Community 89]]
- [[_COMMUNITY_Community 90|Community 90]]
- [[_COMMUNITY_Community 91|Community 91]]
- [[_COMMUNITY_Community 92|Community 92]]
- [[_COMMUNITY_Community 93|Community 93]]
- [[_COMMUNITY_Community 94|Community 94]]
- [[_COMMUNITY_Community 95|Community 95]]
- [[_COMMUNITY_Community 96|Community 96]]
- [[_COMMUNITY_Community 97|Community 97]]
- [[_COMMUNITY_Community 98|Community 98]]
- [[_COMMUNITY_Community 99|Community 99]]
- [[_COMMUNITY_Community 100|Community 100]]
- [[_COMMUNITY_Community 101|Community 101]]
@@ -116,38 +124,36 @@
- [[_COMMUNITY_Community 106|Community 106]]
- [[_COMMUNITY_Community 107|Community 107]]
- [[_COMMUNITY_Community 108|Community 108]]
- [[_COMMUNITY_Community 109|Community 109]]
- [[_COMMUNITY_Community 110|Community 110]]
- [[_COMMUNITY_Community 111|Community 111]]
- [[_COMMUNITY_Community 112|Community 112]]
- [[_COMMUNITY_Community 122|Community 122]]
- [[_COMMUNITY_Community 123|Community 123]]
- [[_COMMUNITY_Community 124|Community 124]]
- [[_COMMUNITY_Community 125|Community 125]]
- [[_COMMUNITY_Community 126|Community 126]]
- [[_COMMUNITY_Community 127|Community 127]]
- [[_COMMUNITY_Community 128|Community 128]]
- [[_COMMUNITY_Community 129|Community 129]]
- [[_COMMUNITY_Community 130|Community 130]]
- [[_COMMUNITY_Community 131|Community 131]]
- [[_COMMUNITY_Community 132|Community 132]]
- [[_COMMUNITY_Community 133|Community 133]]
- [[_COMMUNITY_Community 134|Community 134]]
- [[_COMMUNITY_Community 135|Community 135]]
- [[_COMMUNITY_Community 139|Community 139]]
- [[_COMMUNITY_Community 142|Community 142]]
- [[_COMMUNITY_Community 143|Community 143]]
- [[_COMMUNITY_Community 146|Community 146]]
- [[_COMMUNITY_Community 147|Community 147]]
- [[_COMMUNITY_Community 148|Community 148]]
## God Nodes (most connected - your core abstractions)
1. `Session` - 1123 edges
2. `BaseModel` - 373 edges
2. `BaseModel` - 383 edges
3. `int` - 336 edges
4. `Any` - 331 edges
5. `get_tenant_no()` - 259 edges
5. `get_tenant_no()` - 266 edges
6. `success_response()` - 258 edges
7. `Session` - 256 edges
8. `bool` - 255 edges
9. `error_response()` - 243 edges
10. `SysUser` - 208 edges
10. `SysUser` - 222 edges
## Surprising Connections (you probably didn't know these)
- `bool` --uses--> `DbUserContext` [INFERRED]
@@ -161,43 +167,43 @@
- `int` --uses--> `LocalStorage` [INFERRED]
scripts/run_db_auto_generate_plans.py → app/core/storage.py
## Communities (130 total, 2 thin omitted)
## Communities (136 total, 3 thin omitted)
### Community 0 - "Community 0"
Cohesion: 0.12
Nodes (128): DbUserContext, int, Session, str, date, DbUserContext, int, Session (+120 more)
Cohesion: 0.14
Nodes (101): date, DbUserContext, int, Session, str, Base, DocumentReminderRead, DocumentReminderUpdate (+93 more)
### Community 1 - "Community 1"
Cohesion: 0.11
Nodes (32): CRM 报价单 API 路由 — 挂接到 crm.router, CRM 报价单 Pydantic Schemas, QuoteAcceptBody, QuoteApprovalApproveBody, QuoteApprovalListBody, QuoteApprovalRefreshNamesBody, QuoteApprovalWithdrawBody, QuoteCreateBody (+24 more)
Cohesion: 0.09
Nodes (45): CRM 报价单 API 路由 — 挂接到 crm.router, CRM 报价单 Pydantic Schemas, BaseModel, AdvanceApplyOut, AdvanceApprovalCreate, PagedQuery, PagedResponse, ContractProductItem (+37 more)
### Community 2 - "Community 2"
Cohesion: 0.36
Nodes (217): Any, bool, str, UploadFile, CRM 线索管理 Pydantic Schemas, CRM 商机管理 Pydantic Schemas, CRM 客户公海池规则 Pydantic Schemas, CRM 产品模块 Pydantic Schemas (+209 more)
Cohesion: 0.35
Nodes (218): Any, bool, str, UploadFile, CRM 线索管理 Pydantic Schemas, CRM 客户管理 Pydantic Schemas, CRM 商机管理 Pydantic Schemas, CRM 客户公海池规则 Pydantic Schemas (+210 more)
### Community 3 - "Community 3"
Cohesion: 0.06
Nodes (169): _apply_default_invoice_info_to_customers(), category_add(), category_delete(), category_tree(), category_update(), clue_assign(), clue_check_convert(), clue_check_duplicate() (+161 more)
Nodes (171): _apply_default_invoice_info_to_customers(), category_add(), category_delete(), category_tree(), category_update(), clue_assign(), clue_check_convert(), clue_check_duplicate() (+163 more)
### Community 4 - "Community 4"
Cohesion: 0.22
Nodes (17): Session, str, str, 附件上传 bizType 与 MinIO 目录映射(对齐原 CRM oss 上传语义), 优先使用显式 folder;否则按 bizType 映射默认目录。, 优先使用显式 folder;否则按 bizType 映射默认目录。, 优先使用显式 folder;否则按 bizType 映射默认目录。, resolve_upload_folder() (+9 more)
Cohesion: 0.13
Nodes (18): 运输计划管理 - 基础数据 Schema(承运商、车辆、人员、证书), CarrierBase, CarrierCreate, CarrierRead, CarrierUpdate, DriverBase, DriverCreate, DriverUpdate (+10 more)
### Community 5 - "Community 5"
Cohesion: 0.08
Nodes (37): _error_json(), lifespan(), _mask_secret(), Exception, int, Request, str, 未捕获异常:统一 JSON 500,确保跨域场景下仍有 Access-Control-Allow-Origin (+29 more)
Nodes (36): _error_json(), lifespan(), _mask_secret(), Exception, int, Request, str, 未捕获异常:统一 JSON 500,确保跨域场景下仍有 Access-Control-Allow-Origin (+28 more)
### Community 6 - "Community 6"
Cohesion: 0.08
Nodes (93): attachment_download_url(), AttachmentDownloadUrlBody, create_dept(), create_dict_data(), create_dict_type(), create_menu(), create_post(), create_role_management() (+85 more)
Cohesion: 0.07
Nodes (104): attachment_download_url(), AttachmentDownloadUrlBody, create_dept(), create_dict_data(), create_dict_type(), create_menu(), create_post(), create_role_management() (+96 more)
### Community 7 - "Community 7"
Cohesion: 0.17
Nodes (30): date, int, Session, str, CertRead, CertRow, PlCert, PlDocumentReminder (+22 more)
Nodes (34): Any, bool, int, Session, str, SysUser, create_user(), get_user() (+26 more)
### Community 8 - "Community 8"
Cohesion: 0.16
Nodes (12): float, int, str, 微信消息通知服务 支持微信小程序模板消息推送 使用方式: from app.core.wechat_message import WechatMes, 发送订单状态通知 Args: openid: 用户openid order_n, 发送支付成功通知 Args: openid: 用户openid order_n, 发送配送通知 Args: openid: 配送员openid task_no:, 发送配送时效预警 Args: openid: 配送员openid task_n (+4 more)
Cohesion: 0.18
Nodes (37): Any, int, Session, str, WfNode, WfTransition, create_instance(), create_process_def() (+29 more)
### Community 9 - "Community 9"
Cohesion: 0.34
@@ -208,56 +214,56 @@ Cohesion: 0.23
Nodes (34): DbInboundOutbound, DbUserContext, Session, str, CreateLinkForPlanPayload, _apply_inventory_product_update(), _apply_inventory_update(), _base_query() (+26 more)
### Community 11 - "Community 11"
Cohesion: 0.18
Nodes (31): Any, bool, BxUserContext, BxWorkflowNode, float, int, ReimburseApplyOut, Session (+23 more)
Cohesion: 0.16
Nodes (35): Any, bool, BxUserContext, BxWorkflowNode, float, int, ReimburseApplyOut, Session (+27 more)
### Community 12 - "Community 12"
Cohesion: 0.06
Nodes (50): str, CRM 合同 Pydantic Schemas — 对照 CrmContractBo / CrmContractVo, ContractApprovalActionBody, ContractApprovalApproveBody, ContractApprovalByContractBody, ContractApprovalListBody, ContractApprovalPageListBody, ContractApprovalPassBody (+42 more)
Cohesion: 0.07
Nodes (52): CRM 合同 API 路由 — GET/PUT/DELETE/POST 对齐原 Java CRM, CRM 合同子模块路由 — 变更/模板/审批独立页, CRM 合同 Pydantic Schemas — 对照 CrmContractBo / CrmContractVo, 运营端角色守卫:admin / super_admin 可访问。, require_admin_or_super_admin(), ContractApprovalActionBody, ContractApprovalApproveBody, ContractApprovalByContractBody (+44 more)
### Community 13 - "Community 13"
Cohesion: 0.11
Nodes (17): Exception, bytes, int, Path, str, BytesIO, BaseStorage, convert_heic_to_jpeg() (+9 more)
Cohesion: 0.10
Nodes (17): Exception, bool, bytes, int, str, BytesIO, BaseStorage, convert_heic_to_jpeg() (+9 more)
### Community 14 - "Community 14"
Cohesion: 0.08
Nodes (69): Any, bool, CrmContract, datetime, int, Query, Session, str (+61 more)
Cohesion: 0.09
Nodes (56): register_contract_sub_routes(), Any, bool, int, Session, str, _advance_contract_after_approval(), approve_contract() (+48 more)
### Community 15 - "Community 15"
Cohesion: 0.19
Nodes (23): bool, date, datetime, int, Session, str, allocate_reimburse_title_seq(), format_reimburse_title() (+15 more)
### Community 16 - "Community 16"
Cohesion: 0.08
Nodes (40): AttachmentUploadResponse, ChangePasswordRequest, Config, LoginRequest, LoginResponse, Pydantic schemas - 用户认证, ResetPasswordRequest, UserCreate (+32 more)
Cohesion: 0.07
Nodes (41): AttachmentUploadResponse, ChangePasswordRequest, Config, LoginRequest, LoginResponse, Pydantic schemas - 用户认证, ResetPasswordRequest, UserCreate (+33 more)
### Community 17 - "Community 17"
Cohesion: 0.20
Nodes (49): Any, Any, CRM 商机 CRUD(主表 + 阶段/赢输单/统计/看板/漏斗), date, datetime, Decimal, int, Session (+41 more)
Cohesion: 0.18
Nodes (46): Any, CRM 商机 CRUD(主表 + 阶段/赢输单/统计/看板/漏斗), date, datetime, Decimal, int, Session, str (+38 more)
### Community 18 - "Community 18"
Cohesion: 0.14
Nodes (26): Any, bool, BxUserContext, BxWorkflowNode, float, int, Session, str (+18 more)
Nodes (25): Any, bool, BxUserContext, BxWorkflowNode, float, int, Session, str (+17 more)
### Community 19 - "Community 19"
Cohesion: 0.04
Nodes (150): register_quote_routes(), Any, bool, int, Session, str, Any, bool (+142 more)
Nodes (119): register_quote_routes(), Any, bool, CRM 报价单 CRUD — 对照 CrmQuoteServiceImpl.java(P2 全量), Decimal, Session, str, accept_quote() (+111 more)
### Community 20 - "Community 20"
Cohesion: 0.34
Nodes (32): AdvanceApplyCreate, AdvanceApplyOut, AdvanceApplyUpdate, AdvanceApprovalCreate, BxUserContext, int, Session, str (+24 more)
Cohesion: 0.15
Nodes (65): AdvanceApplyCreate, AdvanceApplyOut, AdvanceApplyUpdate, AdvanceApprovalCreate, BxUserContext, int, Session, str (+57 more)
### Community 21 - "Community 21"
Cohesion: 0.08
Nodes (71): DbUserContext, 运输计划管理 - 基础数据 API(承运商、车辆、人员), PlVehicle, Session, str, VehicleRead, 运输计划管理 - 基础数据 Schema(承运商、车辆、人员、证书), CarrierRead (+63 more)
Cohesion: 0.09
Nodes (101): DbUserContext, 运输计划管理 - 基础数据 API(承运商、车辆、人员), PlVehicle, Session, str, VehicleCreate, VehicleRead, VehicleUpdate (+93 more)
### Community 22 - "Community 22"
Cohesion: 0.38
Nodes (11): Any, int, Session, str, _business_type_from_path(), get_oper_log(), list_oper_logs(), _oper_status() (+3 more)
### Community 23 - "Community 23"
Cohesion: 0.25
Nodes (36): AdvanceIssueRequest, BxUserContext, int, ReimburseApplyOut, Session, str, str, BatchOffsetRequest (+28 more)
Cohesion: 0.28
Nodes (35): AdvanceIssueRequest, BxUserContext, int, ReimburseApplyOut, Session, str, str, BatchOffsetRequest (+27 more)
### Community 24 - "Community 24"
Cohesion: 0.19
@@ -268,12 +274,12 @@ Cohesion: 0.27
Nodes (18): Any, bool, int, Session, str, create_clue_follow(), delete_clue_follow(), get_clue_follow() (+10 more)
### Community 26 - "Community 26"
Cohesion: 0.15
Nodes (14): Any, int, str, get_wechat_pay_client(), get_wechat_pay_v2(), 微信支付工具模块 支持微信支付 V3 API 文档参考: https://pay.weixin.qq.com/docs/v3/apis/index.html, 统一下单接口 (V3) Args: out_trade_no: 商户订单号 total_amo, 申请退款 Args: out_trade_no: 商户订单号 total_amount: 订单 (+6 more)
Cohesion: 0.08
Nodes (42): Any, str, int, str, Any, bool, int, str (+34 more)
### Community 27 - "Community 27"
Cohesion: 0.21
Nodes (32): Any, bool, CRM 线索 CRUD(线索主表 + 转化/分配/无效/等级操作), date, datetime, int, Session, str (+24 more)
Cohesion: 0.22
Nodes (33): Any, bool, CRM 线索 CRUD(线索主表 + 转化/分配/无效/等级操作), date, datetime, int, Session, str (+25 more)
### Community 28 - "Community 28"
Cohesion: 0.16
@@ -284,68 +290,68 @@ Cohesion: 0.12
Nodes (31): Any, bool, CRM 供方信息 CRUD — 对照 CrmSupplierInfoServiceImpl.java, int, Session, str, generate_contract_no(), Java: generateContractNo — {供方编码}/X-JT + yyyyMMdd + 3位流水 (+23 more)
### Community 30 - "Community 30"
Cohesion: 0.35
Nodes (31): BxUserContext, int, Session, str, PagedData, approve_reimburse(), approved_by_me(), _build_details_data() (+23 more)
Cohesion: 0.32
Nodes (29): BxUserContext, int, Session, str, approve_reimburse(), approved_by_me(), _build_details_data(), create_reimburse() (+21 more)
### Community 31 - "Community 31"
Cohesion: 0.19
Nodes (32): Any, bool, CrmContractProductPriceTier, date, Decimal, int, Session, str (+24 more)
Cohesion: 0.15
Nodes (38): Any, bool, CrmContractProductPriceTier, date, Decimal, int, Session, str (+30 more)
### Community 32 - "Community 32"
Cohesion: 0.26
Nodes (21): approve_task(), _business_type_label(), create_process_def(), delete_process_def(), _enrich_task_list(), get_business_all_tasks(), _get_business_form_fields(), get_designer_data() (+13 more)
Cohesion: 0.22
Nodes (29): approve_task(), _business_type_label(), delete_process_def(), _enrich_task_list(), get_business_all_tasks(), _get_business_form_fields(), get_designer_data(), get_instance_detail() (+21 more)
### Community 33 - "Community 33"
Cohesion: 0.09
Nodes (75): Any, bool, date, int, Session, str, Any, int (+67 more)
Cohesion: 0.14
Nodes (48): Any, int, Session, str, Any, bool, CRM 客户 CRUD(客户主表 + 转移/成交/公海池操作), CrmCustomer (+40 more)
### Community 34 - "Community 34"
Cohesion: 0.22
Nodes (29): Engine, Path, build_id_maps(), clip_text(), count_rows(), export_mapping(), fetch_rows(), legacy_id_to_str() (+21 more)
Cohesion: 0.23
Nodes (28): Engine, build_id_maps(), clip_text(), count_rows(), export_mapping(), fetch_rows(), legacy_id_to_str(), main() (+20 more)
### Community 35 - "Community 35"
Cohesion: 0.18
Nodes (19): bytes, int, str, download_file_bytes(), file_stream(), get_access_url(), get_download_url(), get_preview_url() (+11 more)
### Community 36 - "Community 36"
Cohesion: 0.15
Nodes (37): pool_rule_delete(), Any, bool, CRM 公海池规则 CRUD + 规则执行逻辑, int, Session, str, create_pool_rule() (+29 more)
Cohesion: 0.16
Nodes (36): pool_rule_delete(), pool_rule_toggle(), pool_rule_update(), Any, bool, CRM 公海池规则 CRUD + 规则执行逻辑, int, Session (+28 more)
### Community 37 - "Community 37"
Cohesion: 0.38
Nodes (15): Any, bool, int, Session, str, create_site(), get_site(), list_sites() (+7 more)
### Community 38 - "Community 38"
Cohesion: 0.33
Nodes (5): Any, Session, str, get_db_current_user_optional(), 有 Bearer 且为 admin/super_admin 时返回上下文,否则 None(供三方 H5 无登录调用)。
Cohesion: 0.40
Nodes (3): API 路由包 — 山峡化工生产一体化门户, get_menu_list(), 运营端菜单接口(与 web-admin 前端静态路由 sqxp.ts 对齐,14 个一级菜单)
### Community 39 - "Community 39"
Cohesion: 0.18
Nodes (9): 报销(bx)API 路由聚合 — REST 风格,协议对齐 bx 原系统。, 报销(bx)Pydantic 模型 — 响应协议与 bx 原系统保持一致, bx_health(), 报销(bx)API 路由聚合 — REST 风格,协议对齐 bx 原系统。, P0 健康检查:验证 bx 路由已挂载且响应协议为 code=0。, P0 健康检查:验证 bx 路由已挂载且响应协议为 code=0。, P0 健康检查:验证 bx 路由已挂载且响应协议为 code=0。, P0 健康检查:验证 bx 路由已挂载且响应协议为 code=0。 (+1 more)
Cohesion: 0.12
Nodes (15): 报销(bx)API 路由聚合 — REST 风格,协议对齐 bx 原系统。, date, datetime, str, 报销(bx)Pydantic 模型 — 响应协议与 bx 原系统保持一致, _date_to_str(), _dt_to_str(), bx 原系统 API 响应包装(code=0 / msg / data.rows),与门户 success_response 分离。 (+7 more)
### Community 40 - "Community 40"
Cohesion: 0.20
Nodes (26): Any, bool, Decimal, int, Session, str, batch_insert_quote_products(), calculate_subtotal() (+18 more)
### Community 41 - "Community 41"
Cohesion: 0.24
Nodes (18): BxUserContext, Session, str, bool, BxUserContext, Session, str, create_expense_item() (+10 more)
Cohesion: 0.18
Nodes (16): Any, bool, int, M, Session, str, bool, BxUserContext (+8 more)
### Community 42 - "Community 42"
Cohesion: 0.08
Nodes (25): 技术栈, 1. 创建虚拟环境, 项目结构, 1. 创建虚拟环境, 2. 安装依赖, 2. 安装依赖, 3. 配置环境变量, 快速开始 (+17 more)
### Community 43 - "Community 43"
Cohesion: 0.09
Nodes (39): Any, str, Any, int, str, str, Any, str (+31 more)
Cohesion: 0.21
Nodes (16): Any, int, str, BusinessException, InvalidStatusTransitionException, log_api_request(), log_delivery_operation(), log_operation() (+8 more)
### Community 44 - "Community 44"
Cohesion: 0.25
Nodes (23): Any, bool, int, Session, str, create_role(), get_role(), get_role_data_scope() (+15 more)
### Community 45 - "Community 45"
Cohesion: 0.38
Nodes (15): Any, bool, int, Session, str, create_post(), get_post(), list_posts() (+7 more)
Cohesion: 0.12
Nodes (56): CrmContract, datetime, Query, CrmContract, CrmContractProductPriceTier, date, datetime, int (+48 more)
### Community 46 - "Community 46"
Cohesion: 0.20
@@ -353,31 +359,31 @@ Nodes (10): 导出供方列表 — Java: CrmSupplierInfoController.export, 导
### Community 47 - "Community 47"
Cohesion: 0.33
Nodes (6): PlPlanChange, 计划变更记录表 pl_plan_change, 计划变更记录表 pl_plan_change, 计划变更记录表 pl_plan_change, 计划变更记录表 pl_plan_change, 计划变更记录表 pl_plan_change
Nodes (6): generate_template_no(), Java: generateTemplateNo — TMPL{yyyyMMdd}{4位序号}, Java: generateTemplateNo — TMPL{yyyyMMdd}{4位序号}, Java: generateTemplateNo — TMPL{yyyyMMdd}{4位序号}, Java: generateTemplateNo — TMPL{yyyyMMdd}{4位序号}, Java: generateTemplateNo — TMPL{yyyyMMdd}{4位序号}
### Community 48 - "Community 48"
Cohesion: 0.16
Nodes (26): datetime, int, str, date, datetime, str, 审批轮次过滤 — 驳回后重新提交时,进度接口仅展示当前轮次。, format_datetime() (+18 more)
Cohesion: 0.17
Nodes (21): datetime, date, datetime, str, 审批轮次过滤 — 驳回后重新提交时,进度接口仅展示当前轮次。, format_datetime(), get_current_time(), parse_datetime() (+13 more)
### Community 49 - "Community 49"
Cohesion: 0.05
Nodes (138): ProcessDefCreateBody, ProcessDefUpdateBody, PublishVersionBody, 审批意见:前端传 commentText,兼容 comment。, StartInstanceBody, TaskActionBody, Any, int (+130 more)
Cohesion: 0.11
Nodes (33): bool, WfProcessInstance, Any, bool, str, WfProcessInstance, Any, bool (+25 more)
### Community 50 - "Community 50"
Cohesion: 0.16
Nodes (47): bool, Decimal, int, PlanCreateFull, PlPlan, PlPlanProduct, PlTransport, PlVehicle (+39 more)
Cohesion: 0.13
Nodes (61): bool, Decimal, int, PlanCreateFull, PlPlan, PlPlanProduct, PlTransport, PlVehicle (+53 more)
### Community 51 - "Community 51"
Cohesion: 0.17
Nodes (17): bool, BxUserContext, int, Session, str, Any, bool, int (+9 more)
Cohesion: 0.11
Nodes (100): DbUserContext, FreightSettlementDisburseBody, FreightSettlementSubmitApprovalBody, FreightSettlementUpdate, int, Session, str, Any (+92 more)
### Community 52 - "Community 52"
Cohesion: 0.34
Nodes (18): Any, bool, datetime, int, Session, str, create_opportunity_follow(), get_opportunity_follow() (+10 more)
Cohesion: 0.28
Nodes (20): Any, bool, date, int, Session, str, _contact_row_to_dict(), create_contact() (+12 more)
### Community 53 - "Community 53"
Cohesion: 0.06
Nodes (111): date, DbUserContext, int, PlanCreateFull, PlPlan, Session, str, PlTransportSiteLink (+103 more)
Nodes (115): date, DbUserContext, int, PlanCreateFull, PlPlan, Session, str, PlTransportSiteLink (+107 more)
### Community 54 - "Community 54"
Cohesion: 0.11
@@ -387,6 +393,10 @@ Nodes (19): 分页查询供方列表 — Java: CrmSupplierInfoController.list,
Cohesion: 0.11
Nodes (19): 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll, 供方全量列表(下拉)— Java: CrmSupplierInfoController.listAll (+11 more)
### Community 56 - "Community 56"
Cohesion: 0.26
Nodes (22): Any, bool, datetime, int, Session, str, BizSampleCode, batch_generate_sample_codes() (+14 more)
### Community 57 - "Community 57"
Cohesion: 0.11
Nodes (18): product_delete(), 删除产品(支持单条 body.id 和批量 body.ids), 删除产品(支持单条 body.id 和批量 body.ids), 删除产品(支持单条 body.id 和批量 body.ids), 删除产品(支持单条 body.id 和批量 body.ids), 删除产品(支持单条 body.id 和批量 body.ids), 删除产品(支持单条 body.id 和批量 body.ids), 删除产品(支持单条 body.id 和批量 body.ids) (+10 more)
@@ -408,12 +418,12 @@ Cohesion: 0.33
Nodes (5): _coerce_optional_id(), WorkflowDefCreate, WorkflowDefUpdate, WorkflowNodeCreate, WorkflowNodeOut
### Community 62 - "Community 62"
Cohesion: 0.22
Nodes (29): bool, DbInboundOutbound, int, PublicInventoryFeedback, PublicInventoryPageRead, UploadFile, bool, int (+21 more)
Cohesion: 0.12
Nodes (45): bool, DbInboundOutbound, int, PublicInventoryFeedback, PublicInventoryPageRead, Session, str, UploadFile (+37 more)
### Community 63 - "Community 63"
Cohesion: 0.11
Nodes (47): Session, str, bool, date, DbInboundOutbound, DbPurchasePlan, float, PlPlan (+39 more)
Cohesion: 0.12
Nodes (46): Session, str, bool, date, DbInboundOutbound, DbPurchasePlan, float, PlPlan (+38 more)
### Community 64 - "Community 64"
Cohesion: 0.33
@@ -423,6 +433,10 @@ Nodes (15): Any, int, Session, str, BizLeaveRequest, create_leave(), get_leave()
Cohesion: 0.23
Nodes (10): Any, bool, int, Session, str, camel_to_snake(), CRUDBase, get_model_attr() (+2 more)
### Community 66 - "Community 66"
Cohesion: 0.46
Nodes (6): BxUserContext, Session, str, 按业务类型获取工作流;已知类型不存在时自动创建空定义(无节点)。, WorkflowService, BxWorkflowDef
### Community 67 - "Community 67"
Cohesion: 0.27
Nodes (15): Any, bool, Session, str, list_share_logs(), _parse_user_agent(), CRM 报价单分享访问日志 CRUD — 对照 CrmQuoteShareLogServiceImpl.java, 简易 User-Agent 解析(替代 Hutool UserAgentUtil) (+7 more)
@@ -432,8 +446,8 @@ Cohesion: 0.12
Nodes (16): invoice_info_list(), 按客户ID查询开票信息(与 by-customer 等价), 按客户ID查询开票信息(与 by-customer 等价), 按客户ID查询开票信息(与 by-customer 等价), 按客户ID查询开票信息(与 by-customer 等价), 按客户ID查询开票信息(与 by-customer 等价), 按客户ID查询开票信息(与 by-customer 等价), 按客户ID查询开票信息(与 by-customer 等价) (+8 more)
### Community 69 - "Community 69"
Cohesion: 0.06
Nodes (47): list_roles_for_select(), 返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。, 返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。, 返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。, API 路由包 — 山峡化工生产一体化门户, create_leave(), delete_leave(), get_leave() (+39 more)
Cohesion: 0.09
Nodes (30): list_roles_for_select(), 返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。, 返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。, 返回运营端角色下拉选项(label=库中角色名,value=Web 角色码)。, get_current_user_profile(), get_web_auth_menu_codes(), logout(), public_quote_share() (+22 more)
### Community 70 - "Community 70"
Cohesion: 0.29
@@ -453,7 +467,7 @@ Nodes (13): Any, bool, Session, str, _clear_default_for_customer(), create_invoi
### Community 74 - "Community 74"
Cohesion: 0.04
Nodes (192): CRM 合同 API 路由 — GET/PUT/DELETE/POST 对齐原 Java CRM, register_contract_routes(), CRM 合同子模块路由 — 变更/模板/审批独立页, register_contract_sub_routes(), Any, bool, CRM 合同 CRUD — 对照 CrmContractServiceImpl.java(列表/详情 P1), CrmContract (+184 more)
Nodes (160): Any, register_contract_routes(), Any, bool, CRM 合同 CRUD — 对照 CrmContractServiceImpl.java(列表/详情 P1), Decimal, Session, str (+152 more)
### Community 75 - "Community 75"
Cohesion: 0.27
@@ -464,20 +478,24 @@ Cohesion: 0.18
Nodes (10): Any, Request, str, str, parse_admin_request_json(), 运营 Web(/web/admin)JSON 请求体解析。 与 ApiCryptoMiddleware 配合:中间件未改写 body 时,在路由内解密 `{, 读取 JSON body;dict 时走 resolve_request_payload(明文 / 密文 / data 包装)。 Returns:, 统一解析接口请求载荷(明文 / 密文信封)。 (+2 more)
### Community 77 - "Community 77"
Cohesion: 0.07
Nodes (29): CRM 客户管理 Pydantic Schemas, BaseModel, AdvanceApprovalCreate, AttachmentOut, ReimburseApplyCreate, ReimburseApplyUpdate, Config, PageResult (+21 more)
Cohesion: 0.06
Nodes (39): str, Config, PageResult, ResponseModel, ContactByCustomerBody, ContactDetailBody, ContactSetPrimaryBody, CRM 联系人 Pydantic Schemas (+31 more)
### Community 78 - "Community 78"
Cohesion: 0.28
Nodes (22): bool, CRM 产品模块 CRUD(产品分类 + 产品 + 附件), Session, str, barcode_exists(), category_code_exists(), create_category(), create_product() (+14 more)
### Community 79 - "Community 79"
Cohesion: 0.18
Nodes (11): float, int, str, 发送订单状态通知 Args: openid: 用户openid order_n, 发送支付成功通知 Args: openid: 用户openid order_n, 发送配送通知 Args: openid: 配送员openid task_no:, 发送配送时效预警 Args: openid: 配送员openid task_n, 发送退款结果通知 Args: openid: 用户openid order_n (+3 more)
### Community 80 - "Community 80"
Cohesion: 0.60
Nodes (10): Any, Session, str, _apply_create_range(), _base_query(), get_clue_level_statistics(), get_clue_overview_statistics(), get_clue_owner_statistics() (+2 more)
### Community 81 - "Community 81"
Cohesion: 0.29
Nodes (10): datetime, int, Session, str, BizNoKind, allocate_next_biz_no(), _format_biz_no(), _prefix_for() (+2 more)
Cohesion: 0.34
Nodes (18): Any, bool, datetime, int, Session, str, create_opportunity_follow(), get_opportunity_follow() (+10 more)
### Community 82 - "Community 82"
Cohesion: 0.29
@@ -492,44 +510,64 @@ Cohesion: 0.20
Nodes (10): 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo, 供方详情 — Java: CrmSupplierInfoController.getInfo (+2 more)
### Community 85 - "Community 85"
Cohesion: 0.21
Nodes (23): bool, Redis, Request, Session, str, decode_token(), extend_session(), get_client_ip() (+15 more)
Cohesion: 0.38
Nodes (15): Any, bool, int, Session, str, create_post(), get_post(), list_posts() (+7 more)
### Community 86 - "Community 86"
Cohesion: 0.12
Nodes (20): bool, date, Session, str, get_last_month_range(), month_range(), 地磅计划按月自动生成 — 迁移自 simple-dibang-xiaoshou/auto-create-plan/auto_create_monthly_pla, 按月自动生成采购计划。 - 默认仅在每月 1 日执行(force=True 时跳过该限制,供手动触发验收) - 遍历所有租户,按上月计划模板生 (+12 more)
Cohesion: 0.19
Nodes (14): bool, date, Session, str, get_last_month_range(), month_range(), 地磅计划按月自动生成 — 迁移自 simple-dibang-xiaoshou/auto-create-plan/auto_create_monthly_pla, 按月自动生成采购计划。 - 默认仅在每月 1 日执行(force=True 时跳过该限制,供手动触发验收) - 遍历所有租户,按上月计划模板生 (+6 more)
### Community 87 - "Community 87"
Cohesion: 0.25
Nodes (11): check_customer_protect_time(), _execute_single_rule(), _get_all_tenant_nos(), pool_recovery_job(), 公海池自动回收任务(由 APScheduler 调度) 遍历所有租户的启用规则,执行自动回收。, 每天凌晨1点:检查保护期到期客户,跟进次数不足则退回公海, 每天早上9点:保护期到期提醒(3天内到期且跟进不足), remind_customer_recycle() (+3 more)
### Community 88 - "Community 88"
Cohesion: 0.41
Nodes (13): BxUserContext, Session, str, UploadFile, bind_biz(), delete_attachment(), download_file(), list_by_biz() (+5 more)
Cohesion: 0.33
Nodes (14): BxUserContext, Session, str, UploadFile, AttachmentOut, bind_biz(), delete_attachment(), download_file() (+6 more)
### Community 89 - "Community 89"
Cohesion: 0.44
Nodes (8): bool, int, Session, str, ApiRequestLogCRUD, SysApiRequestLog, SysApiRequestLogHis, SysApiRequestLog
### Community 90 - "Community 90"
Cohesion: 0.17
Nodes (22): Any, bool, bytes, int, Request, str, bool, int (+14 more)
Cohesion: 0.23
Nodes (15): Any, bool, bytes, int, Request, str, _claims_from_auth(), _format_body_bytes() (+7 more)
### Community 91 - "Community 91"
Cohesion: 0.32
Nodes (7): str, eq_unicode(), like_unicode(), MySQL 字符串比较/模糊匹配时统一排序规则,避免 Illegal mix of collations。, 跨表字符串等值比较(JOIN / WHERE)时统一为 utf8mb4_unicode_ci。, 将列显式设为 utf8mb4_unicode_ci。, unicode_ci()
### Community 92 - "Community 92"
Cohesion: 0.41
Nodes (11): Any, str, build_quote_html(), _default_value(), _format_date(), _format_discount(), _format_money(), generate_quote_pdf() (+3 more)
### Community 93 - "Community 93"
Cohesion: 0.19
Nodes (62): InboundOutboundRead, bool, DbPurchasePlan, DbUserContext, PurchasePlanRead, PurchasePlanWithFillLink, Session, str (+54 more)
Cohesion: 0.20
Nodes (58): InboundOutboundRead, bool, DbPurchasePlan, DbUserContext, PurchasePlanRead, PurchasePlanWithFillLink, Session, str (+50 more)
### Community 94 - "Community 94"
Cohesion: 0.22
Nodes (9): generate_contract_name(), Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName (+1 more)
### Community 95 - "Community 95"
Cohesion: 0.28
Nodes (13): int, Session, str, _allocate_inbound_outbound_id(), _ensure_sequence_row(), max_numeric_inbound_outbound_id(), next_inbound_outbound_id(), 出入库单 id 生成 — 租户内纯数字自增,并发安全。 (+5 more)
Cohesion: 0.23
Nodes (14): int, Session, str, _allocate_inbound_outbound_id(), _ensure_sequence_row(), max_numeric_inbound_outbound_id(), next_inbound_outbound_id(), 出入库单 id 生成 — 租户内纯数字自增,并发安全。 (+6 more)
### Community 96 - "Community 96"
Cohesion: 0.30
Nodes (11): Session, str, apply_data_scope(), _get_child_dept_ids(), get_user_dept_id(), 数据权限过滤(V0.3:基于角色 data_scope 的查询级行级过滤) data_scope 值: 1 = 全部数据 2 = 本部门数据 3, 根据用户角色的数据权限过滤查询。 Args: query: SQLAlchemy query 对象 model: 查询, 从 SysUser 读取用户的 dept_id。 (+3 more)
Cohesion: 0.29
Nodes (7): Session, str, get_user_menu_codes(), 菜单 code 权限守卫(V0.3:通过 sys_user_role → sys_role_menu → sys_menu.perms), 读取用户授权的菜单权限标识集合(与前端 meta.menuCode / perms 对齐)。, 接口菜单权限守卫。super_admin 直接放行。, require_menu_code()
### Community 97 - "Community 97"
Cohesion: 0.34
Nodes (23): DbUserContext, DbWeighingSlip, Session, str, weighing_to_read(), apply_product_snapshot_to_weighing(), _apply_weighing_product_update(), _apply_weighing_update() (+15 more)
### Community 98 - "Community 98"
Cohesion: 0.33
Nodes (3): 地磅 API 路由聚合 — REST 风格,协议对齐原 simple-dibang-xiaoshou。, 地磅(db)Pydantic schemas — 对齐原 simple-dibang-xiaoshou 契约。, 地磅 API 路由聚合 — REST 风格,协议对齐原 simple-dibang-xiaoshou。
### Community 99 - "Community 99"
Cohesion: 0.39
Nodes (8): int, LeaveCreate, LeaveUpdate, Config, LeaveCreate, LeaveResponse, LeaveUpdate, Pydantic schemas - 请假申请
Cohesion: 0.28
Nodes (18): create_leave(), delete_leave(), get_leave(), _leave_local_callback(), leave_workflow_callback(), list_leaves(), submit_leave(), update_leave() (+10 more)
### Community 100 - "Community 100"
Cohesion: 0.38
@@ -544,16 +582,16 @@ Cohesion: 0.15
Nodes (17): Any, _build_category_tree(), _category_row_to_dict(), _collect_category_with_ancestors(), list_categories(), list_category_tree(), list_oss_by_biz(), list_product_options() (+9 more)
### Community 103 - "Community 103"
Cohesion: 0.14
Nodes (95): VehicleCreate, VehicleUpdate, bool, DbUserContext, float, int, PlPlan, PlTransport (+87 more)
Cohesion: 0.16
Nodes (75): bool, DbUserContext, float, int, PlPlan, PlTransport, Session, str (+67 more)
### Community 104 - "Community 104"
Cohesion: 0.11
Nodes (34): _avatar_url_field(), _build_user_info_payload(), get_current_user_profile(), get_web_auth_menu_codes(), _jwt_user_payload(), logout(), public_quote_share(), 公共接口(Web 登录、刷新 Token、登出;用户模型对齐 docs/sql/shanxia2.0.sql 基线) (+26 more)
Cohesion: 0.06
Nodes (69): _avatar_url_field(), _build_user_info_payload(), _jwt_user_payload(), 公共接口(Web 登录、刷新 Token、登出;用户模型对齐 docs/sql/shanxia2.0.sql 基线), 与 web-admin `userInfo` 字段约定一致。, 与 web-admin `userInfo` 字段约定一致。, Web 端登录用 RSA 公钥(PKCS#1 v1.5,与 JSEncrypt 一致), Web 端登录用 RSA 公钥(PKCS#1 v1.5,与 JSEncrypt 一致) (+61 more)
### Community 105 - "Community 105"
Cohesion: 0.39
Nodes (17): DbUserContext, Session, str, DashboardCargoStat, DashboardPartnerCargoStat, DashboardStats, _cargo_stats(), DashboardCargoStat (+9 more)
Cohesion: 0.27
Nodes (21): DbUserContext, Session, str, bool, datetime, DbWeighingSlip, Session, str (+13 more)
### Community 106 - "Community 106"
Cohesion: 0.30
@@ -567,13 +605,13 @@ Nodes (10): SysOss, int, Session, str, SysOss, create_oss(), create_oss(), get_o
Cohesion: 0.34
Nodes (16): Any, int, Session, str, _build_tree(), _cascade_soft_delete(), _collect_with_ancestors(), create_dept() (+8 more)
### Community 111 - "Community 111"
Cohesion: 0.14
Nodes (19): bool, int, Redis, Request, str, bool, bool, bool (+11 more)
### Community 109 - "Community 109"
Cohesion: 0.47
Nodes (5): OperLogDetailBody, OperLogListBody, 操作日志(兼容 RuoYi OperLog 视图), OperLogDetailBody, OperLogListBody
### Community 112 - "Community 112"
Cohesion: 0.35
Nodes (17): Any, bool, int, Session, str, _build_tree(), _cascade_soft_delete(), create_menu() (+9 more)
### Community 111 - "Community 111"
Cohesion: 0.40
Nodes (3): AdvanceApplyCreate, AdvanceApplyUpdate, _coerce_optional_id()
### Community 122 - "Community 122"
Cohesion: 0.22
@@ -584,29 +622,33 @@ Cohesion: 0.22
Nodes (9): _get_quote_item_field(), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配), Java: resolveProductIdForQuoteItem(CrmProduct 无 tax_rate,跳过税率匹配) (+1 more)
### Community 125 - "Community 125"
Cohesion: 0.15
Nodes (28): BxUserContext, int, Session, str, bool, BxUserContext, BxWorkflowNode, int (+20 more)
Cohesion: 0.35
Nodes (8): bool, BxUserContext, int, Session, str, AttachmentService, BxAttachment, BxAttachment
### Community 126 - "Community 126"
Cohesion: 0.33
Nodes (8): Decimal, str, derive_legacy_status_from_three(), derive_three_status_from_legacy(), 阶段A兼容:从旧 status 推导三字段。 约束:旧 status 本身混合了支付/配送/订单生命周期,因此只能尽力推断; 若业务侧已有更精确, 阶段A兼容:从三字段反推旧 status(用于旧前端/旧筛选参数兼容)。, ThreeStatus, _to_decimal()
### Community 127 - "Community 127"
Cohesion: 0.22
Nodes (9): generate_contract_name(), Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName, Java: generateContractName (+1 more)
Cohesion: 0.29
Nodes (10): datetime, int, Session, str, BizNoKind, allocate_next_biz_no(), _format_biz_no(), _prefix_for() (+2 more)
### Community 128 - "Community 128"
Cohesion: 0.33
Nodes (3): _coerce_id(), OffsetItem, ReimburseDetailCreate
Cohesion: 0.20
Nodes (7): _coerce_id(), OffsetItem, ReimburseApplyCreate, ReimburseApplyOut, ReimburseApplyUpdate, ReimburseApprovalCreate, ReimburseDetailCreate
### Community 129 - "Community 129"
Cohesion: 0.25
Nodes (8): create_from_quote(), _quote_products_to_contract_products(), Java: createFromQuote — 返回合同 id, Java: createFromQuote — 返回合同 id, Java: createFromQuote — 返回合同 id, Java: createFromQuote — 返回合同 id, Java: createFromQuote — 返回合同 id, Java: createFromQuote — 返回合同 id
### Community 130 - "Community 130"
Cohesion: 0.29
Nodes (7): batch_submit_contract_approval(), Java: batchSubmitApproval, Java: batchSubmitApproval, Java: batchSubmitApproval, Java: batchSubmitApproval, Java: batchSubmitApproval, Java: batchSubmitApproval
### Community 131 - "Community 131"
Cohesion: 0.33
Nodes (14): Any, int, Session, str, create_dict_data(), get_dict_data(), list_dict_data(), list_dict_data_options() (+6 more)
### Community 132 - "Community 132"
Cohesion: 0.28
Nodes (8): date, datetime, str, _date_to_str(), _dt_to_str(), PagedQuery, PagedResponse, bx 原系统 API 响应包装(code=0 / msg / data.rows),与门户 success_response 分离。
### Community 133 - "Community 133"
Cohesion: 0.25
Nodes (8): generate_auto_product_no(), Java: generateAutoProductNo — SXWL + 8位随机大写字符, Java: generateAutoProductNo — SXWL + 8位随机大写字符, Java: generateAutoProductNo — SXWL + 8位随机大写字符, Java: generateAutoProductNo — SXWL + 8位随机大写字符, Java: generateAutoProductNo — SXWL + 8位随机大写字符, Java: generateAutoProductNo — SXWL + 8位随机大写字符, Java: generateAutoProductNo — SXWL + 8位随机大写字符
@@ -615,44 +657,28 @@ Nodes (8): generate_auto_product_no(), Java: generateAutoProductNo — SXWL + 8
Cohesion: 0.33
Nodes (6): generate_barcode(), 生成唯一条码(纯数字:yyyyMMdd + 6位序号,如 20260606000001), 生成唯一条码(纯数字:yyyyMMdd + 6位序号,如 20260606000001), 生成唯一条码(纯数字:yyyyMMdd + 6位序号,如 20260606000001), 生成唯一条码(纯数字:yyyyMMdd + 6位序号,如 20260606000001), 生成唯一条码(纯数字:yyyyMMdd + 6位序号,如 20260606000001)
### Community 139 - "Community 139"
Cohesion: 0.33
Nodes (3): 地磅 API 路由聚合 — REST 风格,协议对齐原 simple-dibang-xiaoshou。, 地磅(db)Pydantic schemas — 对齐原 simple-dibang-xiaoshou 契约。, 地磅 API 路由聚合 — REST 风格,协议对齐原 simple-dibang-xiaoshou。
### Community 142 - "Community 142"
Cohesion: 0.40
Nodes (5): bool, str, get_password_hash(), 验证密码(哈希非 bcrypt 或损坏时返回 False,避免抛错), verify_password()
### Community 143 - "Community 143"
Cohesion: 0.25
Nodes (8): int, list_products(), _product_row_to_dict(), 产品 ORM 对象转 dict(camelCase 键名), 产品 ORM 对象转 dict(camelCase 键名), 产品 ORM 对象转 dict(camelCase 键名), 产品 ORM 对象转 dict(camelCase 键名), total_pages()
### Community 146 - "Community 146"
Cohesion: 0.13
Nodes (34): int, PlTransport, Session, str, UploadFile, Session, str, TransportInventoryLinkRead (+26 more)
### Community 147 - "Community 147"
Cohesion: 0.40
Nodes (3): AdvanceApplyCreate, AdvanceApplyUpdate, _coerce_optional_id()
### Community 148 - "Community 148"
Cohesion: 0.67
Nodes (3): Web 端登录用 RSA 公钥(PKCS#1 v1.5,与 JSEncrypt 一致), Web 端登录用 RSA 公钥(PKCS#1 v1.5,与 JSEncrypt 一致), web_login_rsa_public_key()
Cohesion: 0.34
Nodes (19): int, PlTransport, Session, str, UploadFile, _build_public_page(), _format_file_size(), _format_plan_date() (+11 more)
## Knowledge Gaps
- **61 isolated node(s):** `Any`, `Session`, `bool`, `bool`, `Config` (+56 more)
These have ≤1 connection - possible missing edges or undocumented components.
- **2 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
- **3 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
## Suggested Questions
_Questions this graph is uniquely positioned to answer:_
- **Why does `Session` connect `Community 3` to `Community 0`, `Community 2`, `Community 6`, `Community 9`, `Community 10`, `Community 11`, `Community 14`, `Community 15`, `Community 17`, `Community 18`, `Community 19`, `Community 20`, `Community 22`, `Community 23`, `Community 24`, `Community 25`, `Community 27`, `Community 28`, `Community 29`, `Community 30`, `Community 31`, `Community 32`, `Community 33`, `Community 36`, `Community 37`, `Community 38`, `Community 40`, `Community 41`, `Community 43`, `Community 44`, `Community 45`, `Community 46`, `Community 49`, `Community 50`, `Community 51`, `Community 52`, `Community 53`, `Community 54`, `Community 55`, `Community 57`, `Community 59`, `Community 60`, `Community 62`, `Community 63`, `Community 64`, `Community 65`, `Community 67`, `Community 68`, `Community 69`, `Community 71`, `Community 73`, `Community 74`, `Community 77`, `Community 78`, `Community 80`, `Community 81`, `Community 83`, `Community 84`, `Community 85`, `Community 86`, `Community 88`, `Community 90`, `Community 93`, `Community 95`, `Community 96`, `Community 97`, `Community 99`, `Community 102`, `Community 103`, `Community 104`, `Community 105`, `Community 107`, `Community 108`, `Community 112`, `Community 122`, `Community 123`, `Community 125`, `Community 131`, `Community 133`, `Community 135`, `Community 143`?**
_High betweenness centrality (0.232) - this node is a cross-community bridge._
- **Why does `BaseModel` connect `Community 12` to `Community 128`, `Community 1`, `Community 2`, `Community 0`, `Community 132`, `Community 134`, `Community 6`, `Community 7`, `Community 10`, `Community 11`, `Community 16`, `Community 146`, `Community 147`, `Community 20`, `Community 21`, `Community 23`, `Community 30`, `Community 41`, `Community 49`, `Community 50`, `Community 53`, `Community 61`, `Community 62`, `Community 69`, `Community 74`, `Community 77`, `Community 93`, `Community 97`, `Community 99`, `Community 100`, `Community 103`, `Community 105`, `Community 125`?**
_High betweenness centrality (0.046) - this node is a cross-community bridge._
- **Why does `int` connect `Community 20` to `Community 0`, `Community 3`, `Community 131`, `Community 5`, `Community 6`, `Community 8`, `Community 9`, `Community 11`, `Community 13`, `Community 14`, `Community 143`, `Community 17`, `Community 18`, `Community 19`, `Community 22`, `Community 23`, `Community 25`, `Community 26`, `Community 27`, `Community 28`, `Community 29`, `Community 30`, `Community 31`, `Community 32`, `Community 33`, `Community 34`, `Community 35`, `Community 36`, `Community 37`, `Community 40`, `Community 41`, `Community 43`, `Community 44`, `Community 45`, `Community 48`, `Community 49`, `Community 50`, `Community 51`, `Community 52`, `Community 53`, `Community 59`, `Community 60`, `Community 62`, `Community 64`, `Community 65`, `Community 69`, `Community 71`, `Community 74`, `Community 78`, `Community 81`, `Community 86`, `Community 90`, `Community 93`, `Community 95`, `Community 99`, `Community 103`, `Community 106`, `Community 107`, `Community 108`, `Community 111`, `Community 112`, `Community 125`?**
_High betweenness centrality (0.040) - this node is a cross-community bridge._
- **Why does `Session` connect `Community 3` to `Community 0`, `Community 2`, `Community 6`, `Community 7`, `Community 8`, `Community 9`, `Community 10`, `Community 11`, `Community 14`, `Community 15`, `Community 17`, `Community 18`, `Community 19`, `Community 20`, `Community 21`, `Community 22`, `Community 23`, `Community 24`, `Community 25`, `Community 26`, `Community 27`, `Community 28`, `Community 29`, `Community 30`, `Community 31`, `Community 32`, `Community 33`, `Community 36`, `Community 37`, `Community 40`, `Community 41`, `Community 44`, `Community 45`, `Community 46`, `Community 47`, `Community 49`, `Community 50`, `Community 51`, `Community 52`, `Community 53`, `Community 54`, `Community 55`, `Community 56`, `Community 57`, `Community 59`, `Community 60`, `Community 63`, `Community 64`, `Community 65`, `Community 66`, `Community 67`, `Community 68`, `Community 69`, `Community 71`, `Community 73`, `Community 74`, `Community 78`, `Community 80`, `Community 81`, `Community 83`, `Community 84`, `Community 85`, `Community 86`, `Community 88`, `Community 89`, `Community 93`, `Community 95`, `Community 96`, `Community 97`, `Community 99`, `Community 102`, `Community 103`, `Community 104`, `Community 105`, `Community 107`, `Community 108`, `Community 109`, `Community 122`, `Community 123`, `Community 125`, `Community 127`, `Community 129`, `Community 130`, `Community 131`, `Community 133`, `Community 135`, `Community 143`?**
_High betweenness centrality (0.234) - this node is a cross-community bridge._
- **Why does `BaseModel` connect `Community 77` to `Community 128`, `Community 1`, `Community 2`, `Community 0`, `Community 4`, `Community 6`, `Community 10`, `Community 11`, `Community 12`, `Community 16`, `Community 146`, `Community 20`, `Community 21`, `Community 23`, `Community 30`, `Community 32`, `Community 50`, `Community 53`, `Community 61`, `Community 62`, `Community 88`, `Community 93`, `Community 97`, `Community 99`, `Community 100`, `Community 103`, `Community 109`, `Community 111`?**
_High betweenness centrality (0.052) - this node is a cross-community bridge._
- **Why does `datetime` connect `Community 48` to `Community 0`, `Community 1`, `Community 2`, `Community 3`, `Community 131`, `Community 5`, `Community 4`, `Community 7`, `Community 8`, `Community 9`, `Community 10`, `Community 11`, `Community 12`, `Community 13`, `Community 14`, `Community 15`, `Community 16`, `Community 17`, `Community 146`, `Community 19`, `Community 18`, `Community 21`, `Community 22`, `Community 23`, `Community 25`, `Community 26`, `Community 27`, `Community 28`, `Community 29`, `Community 31`, `Community 33`, `Community 34`, `Community 35`, `Community 36`, `Community 37`, `Community 39`, `Community 40`, `Community 43`, `Community 44`, `Community 45`, `Community 49`, `Community 50`, `Community 51`, `Community 52`, `Community 53`, `Community 56`, `Community 59`, `Community 60`, `Community 62`, `Community 63`, `Community 64`, `Community 67`, `Community 73`, `Community 74`, `Community 77`, `Community 78`, `Community 80`, `Community 81`, `Community 85`, `Community 86`, `Community 87`, `Community 89`, `Community 92`, `Community 93`, `Community 95`, `Community 97`, `Community 103`, `Community 104`, `Community 105`, `Community 108`, `Community 127`?**
_High betweenness centrality (0.041) - this node is a cross-community bridge._
- **Are the 251 inferred relationships involving `str` (e.g. with `AdvanceApplyCreate` and `AdvanceApplyOut`) actually correct?**
_`str` has 251 INFERRED edges - model-reasoned connections that need verification._
- **Are the 248 inferred relationships involving `Session` (e.g. with `AdvanceApplyCreate` and `AdvanceApplyOut`) actually correct?**
@@ -660,4 +686,4 @@ _Questions this graph is uniquely positioned to answer:_
- **Are the 140 inferred relationships involving `int` (e.g. with `AdvanceApplyCreate` and `AdvanceApplyOut`) actually correct?**
_`int` has 140 INFERRED edges - model-reasoned connections that need verification._
- **What connects `数据库异常:返回 JSON 并保留 CORS 头,避免浏览器只报跨域错误`, `未捕获异常:统一 JSON 500,确保跨域场景下仍有 Access-Control-Allow-Origin`, `每月 1 日凌晨执行:按上月计划模板生成本月计划。` to the rest of the system?**
_855 weakly-connected nodes found - possible documentation gaps or missing edges._
_863 weakly-connected nodes found - possible documentation gaps or missing edges._
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "label": "plan.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L1"}, {"id": "pl_plan_planproductbase", "label": "PlanProductBase", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L13"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "pl_plan_planproductcreate", "label": "PlanProductCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L42"}, {"id": "pl_plan_planproductupdate", "label": "PlanProductUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L46"}, {"id": "pl_plan_planproductread", "label": "PlanProductRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L67"}, {"id": "pl_plan_planbase", "label": "PlanBase", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L81"}, {"id": "pl_plan_plancreate", "label": "PlanCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L117"}, {"id": "pl_plan_plantransportcreateblock", "label": "PlanTransportCreateBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L123"}, {"id": "pl_plan_planupdate", "label": "PlanUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L137"}, {"id": "pl_plan_planread", "label": "PlanRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L173"}, {"id": "pl_plan_planwithproducts", "label": "PlanWithProducts", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L196"}, {"id": "pl_plan_createfromcontractrequest", "label": "CreateFromContractRequest", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L205"}, {"id": "pl_plan_plancreatefull", "label": "PlanCreateFull", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L213"}, {"id": "pl_plan_planlistquery", "label": "PlanListQuery", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L224"}, {"id": "pl_plan_planproductcertitem", "label": "PlanProductCertItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L239"}, {"id": "pl_plan_planproductcertsupdate", "label": "PlanProductCertsUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L246"}, {"id": "pl_plan_planarchiveproductitem", "label": "PlanArchiveProductItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L251"}, {"id": "pl_plan_planarchivefreightblock", "label": "PlanArchiveFreightBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L257"}, {"id": "pl_plan_planarchivebody", "label": "PlanArchiveBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L268"}, {"id": "pl_plan_planlistresponse", "label": "PlanListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L274"}], "edges": [{"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "target": "datetime", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L2", "weight": 1.0}, {"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "target": "decimal", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L3", "weight": 1.0}, {"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "target": "typing", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L4", "weight": Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_freight_py", "label": "freight.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L1"}, {"id": "pl_freight_freightsettlementbase", "label": "FreightSettlementBase", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L14"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "pl_freight_freightsettlementcreate", "label": "FreightSettlementCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L23"}, {"id": "pl_freight_freightsettlementcreate_check_ids", "label": ".check_ids()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L29"}, {"id": "pl_freight_freightsettlementupdate", "label": "FreightSettlementUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L35"}, {"id": "pl_freight_freightsettlementread", "label": "FreightSettlementRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L43"}, {"id": "pl_freight_freightsettlementlistitem", "label": "FreightSettlementListItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L57"}, {"id": "pl_freight_freightsettlementtransportread", "label": "FreightSettlementTransportRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L71"}, {"id": "pl_freight_unsettledplanitem", "label": "UnsettledPlanItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L81"}, {"id": "pl_freight_unsettledplanlistresponse", "label": "UnsettledPlanListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L95"}, {"id": "pl_freight_settlementplansummary", "label": "SettlementPlanSummary", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L100"}, {"id": "pl_freight_settlementapprovalflowitem", "label": "SettlementApprovalFlowItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L109"}, {"id": "pl_freight_freightsettlementwithtransports", "label": "FreightSettlementWithTransports", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L123"}, {"id": "pl_freight_freightsettlementsubmitapprovalbody", "label": "FreightSettlementSubmitApprovalBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L140"}, {"id": "pl_freight_freightsettlementapprovalactionbody", "label": "FreightSettlementApprovalActionBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L147"}, {"id": "pl_freight_freightsettlementdisbursebody", "label": "FreightSettlementDisburseBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L152"}, {"id": "pl_freight_remittancevouchercreate", "label": "RemittanceVoucherCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L165"}, {"id": "pl_freight_remittancevoucherread", "label": "RemittanceVoucherRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L174"}, {"id": "pl_freight_freightsettlementlistquery", "label": "FreightSettlementListQuery", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L193"}, {"id": "pl_freight_freightsettlementlistresponse", "label": "FreightSettlementListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L202"}], "edges": [{"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_freight_py", "target": "datetime", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py", "source_location": "L2", "weight": 1.0}, {"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_freight_py", "target": "decimal", "relation": "imporLine truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_api_pl_freight_py", "label": "freight.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L1"}, {"id": "pl_freight_generate_settlement_no", "label": "_generate_settlement_no()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L29"}, {"id": "session", "label": "Session", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L29"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L29"}, {"id": "pl_freight_list_unsettled_plans", "label": "list_unsettled_plans()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L48"}, {"id": "int", "label": "int", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L48"}, {"id": "dbusercontext", "label": "DbUserContext", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L48"}, {"id": "unsettledplanlistresponse", "label": "UnsettledPlanListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L48"}, {"id": "pl_freight_list_settlements", "label": "list_settlements()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L71"}, {"id": "freightsettlementlistresponse", "label": "FreightSettlementListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L71"}, {"id": "pl_freight_create_settlement", "label": "create_settlement()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L95"}, {"id": "freightsettlementcreate", "label": "FreightSettlementCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L95"}, {"id": "freightsettlementread", "label": "FreightSettlementRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L95"}, {"id": "pl_freight_get_settlement", "label": "get_settlement()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L114"}, {"id": "freightsettlementwithtransports", "label": "FreightSettlementWithTransports", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L114"}, {"id": "pl_freight_update_settlement", "label": "update_settlement()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L127"}, {"id": "freightsettlementupdate", "label": "FreightSettlementUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L127"}, {"id": "pl_freight_delete_settlement", "label": "delete_settlement()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L140"}, {"id": "pl_freight_submit_settlement_approval", "label": "submit_settlement_approval()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L152"}, {"id": "freightsettlementsubmitapprovalbody", "label": "FreightSettlementSubmitApprovalBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L152"}, {"id": "pl_freight_process_settlement_approval", "label": "process_settlement_approval()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L170"}, {"id": "freightsettlementapprovalactionbody", "label": "FreightSettlementApprovalActionBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L170"}, {"id": "pl_freight_withdraw_settlement_approval", "label": "withdraw_settlement_approval()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L190"}, {"id": "pl_freight_get_settlement_approval_flow", "label": "get_settlement_approval_flow()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py", "source_location": "L202"}, {"id": "pl_freight_disburse_settlement", "label": "disburse_settlement()", "file_Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_models_pl_models_py", "label": "pl_models.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L1"}, {"id": "models_pl_models_plcarrier", "label": "PlCarrier", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L28"}, {"id": "base", "label": "Base", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "models_pl_models_plvehicle", "label": "PlVehicle", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L49"}, {"id": "models_pl_models_plpersonnel", "label": "PlPersonnel", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L74"}, {"id": "models_pl_models_plcert", "label": "PlCert", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L96"}, {"id": "models_pl_models_pldriver", "label": "PlDriver", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L121"}, {"id": "models_pl_models_plvehiclepersonnel", "label": "PlVehiclePersonnel", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L147"}, {"id": "models_pl_models_plvehicledriver", "label": "PlVehicleDriver", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L168"}, {"id": "models_pl_models_plplan", "label": "PlPlan", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L193"}, {"id": "models_pl_models_plplanproduct", "label": "PlPlanProduct", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L276"}, {"id": "models_pl_models_plplanchange", "label": "PlPlanChange", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L331"}, {"id": "models_pl_models_pltransport", "label": "PlTransport", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L358"}, {"id": "models_pl_models_pltransportdblink", "label": "PlTransportDbLink", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L418"}, {"id": "models_pl_models_plplantransport", "label": "PlPlanTransport", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L440"}, {"id": "models_pl_models_pltransportsitelink", "label": "PlTransportSiteLink", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L459"}, {"id": "models_pl_models_pltransportapproval", "label": "PlTransportApproval", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L492"}, {"id": "models_pl_models_plfreightsettlement", "label": "PlFreightSettlement", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L521"}, {"id": "models_pl_models_plfreightsettlementapproval", "label": "PlFreightSettlementApproval", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L552"}, {"id": "models_pl_models_plfreightsettlementtransport", "label": "PlFreightSettlementTransport", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L579"}, {"id": "models_pl_models_plremittancevoucher", "label": "PlRemittanceVoucher", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L599"}, {"id": "models_pl_models_plinventory", "label": "PlInventory", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L626"}, {"id": "models_pl_models_plinventorytransaction", "label": "PlInventoryTransaction", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L658"}, {"id": "models_pl_models_plinventorywarning", "label": "PlInventoryWarning", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py", "source_location": "L687"}, {"id": "models_pl_models_pldocumentreminder", "label": "PlDocumentReminder", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_api_pl_plan_py", "label": "plan.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L1"}, {"id": "pl_plan_generate_plan_no", "label": "_generate_plan_no()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L64"}, {"id": "session", "label": "Session", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L64"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L64"}, {"id": "pl_plan_determine_plan_type", "label": "_determine_plan_type()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L86"}, {"id": "pl_plan_get_plan_type_label", "label": "_get_plan_type_label()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L91"}, {"id": "pl_plan_generate_notify_message", "label": "_generate_notify_message()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L100"}, {"id": "plplan", "label": "PlPlan", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L100"}, {"id": "pl_plan_list_plans", "label": "list_plans()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L121"}, {"id": "date", "label": "date", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L121"}, {"id": "int", "label": "int", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L121"}, {"id": "dbusercontext", "label": "DbUserContext", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L121"}, {"id": "planlistresponse", "label": "PlanListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L121"}, {"id": "pl_plan_count_plans_by_contract", "label": "count_plans_by_contract()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L220"}, {"id": "pl_plan_create_plan", "label": "create_plan()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L249"}, {"id": "plancreate", "label": "PlanCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L249"}, {"id": "planread", "label": "PlanRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L249"}, {"id": "pl_plan_create_plan_full", "label": "create_plan_full()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L328"}, {"id": "plancreatefull", "label": "PlanCreateFull", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L328"}, {"id": "planwithproducts", "label": "PlanWithProducts", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L328"}, {"id": "pl_plan_create_from_contract", "label": "create_from_contract()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L432"}, {"id": "createfromcontractrequest", "label": "CreateFromContractRequest", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L432"}, {"id": "pl_plan_get_plan", "label": "get_plan()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L541"}, {"id": "pl_plan_update_plan", "label": "update_plan()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L584"}, {"id": "planupdate", "label": "PlanUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L584"}, {"id": "pl_plan_patch_plan_product_certs", "label": "patch_plan_product_certs()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py", "source_location": "L693"}, {"id": "planproductcertsupdate", "label": "PlanProductCertsUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/api/Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "label": "plan.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L1"}, {"id": "pl_plan_planproductbase", "label": "PlanProductBase", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L13"}, {"id": "basemodel", "label": "BaseModel", "file_type": "code", "source_file": "", "source_location": ""}, {"id": "pl_plan_planproductcreate", "label": "PlanProductCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L42"}, {"id": "pl_plan_planproductupdate", "label": "PlanProductUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L46"}, {"id": "pl_plan_planproductread", "label": "PlanProductRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L67"}, {"id": "pl_plan_planbase", "label": "PlanBase", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L81"}, {"id": "pl_plan_plancreate", "label": "PlanCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L117"}, {"id": "pl_plan_plantransportcreateblock", "label": "PlanTransportCreateBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L123"}, {"id": "pl_plan_planupdate", "label": "PlanUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L137"}, {"id": "pl_plan_planread", "label": "PlanRead", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L173"}, {"id": "pl_plan_planwithproducts", "label": "PlanWithProducts", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L196"}, {"id": "pl_plan_createfromcontractrequest", "label": "CreateFromContractRequest", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L205"}, {"id": "pl_plan_plancreatefull", "label": "PlanCreateFull", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L213"}, {"id": "pl_plan_planlistquery", "label": "PlanListQuery", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L224"}, {"id": "pl_plan_planproductcertitem", "label": "PlanProductCertItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L239"}, {"id": "pl_plan_planproductcertsupdate", "label": "PlanProductCertsUpdate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L246"}, {"id": "pl_plan_planarchiveproductitem", "label": "PlanArchiveProductItem", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L251"}, {"id": "pl_plan_planarchivefreightblock", "label": "PlanArchiveFreightBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L257"}, {"id": "pl_plan_planarchivebody", "label": "PlanArchiveBody", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L267"}, {"id": "pl_plan_planlistresponse", "label": "PlanListResponse", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L273"}], "edges": [{"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "target": "datetime", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L2", "weight": 1.0}, {"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "target": "decimal", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L3", "weight": 1.0}, {"source": "users_zlwu_work_00code_shanxia2_0_backend_app_schemas_pl_plan_py", "target": "typing", "relation": "imports_from", "context": "import", "confidence": "EXTRACTED", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py", "source_location": "L4", "weight": Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_services_pl_plan_service_py", "label": "pl_plan_service.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L1"}, {"id": "services_pl_plan_service_determine_plan_type", "label": "determine_plan_type()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L32"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L32"}, {"id": "services_pl_plan_service_is_ton_product_unit", "label": "is_ton_product_unit()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L40"}, {"id": "bool", "label": "bool", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L40"}, {"id": "services_pl_plan_service_product_quantity", "label": "_product_quantity()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "planproductcreate", "label": "PlanProductCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "decimal", "label": "Decimal", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "services_pl_plan_service_sum_product_quantities", "label": "sum_product_quantities()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L57"}, {"id": "services_pl_plan_service_estimate_qty_fields", "label": "_estimate_qty_fields()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L61"}, {"id": "services_pl_plan_service_build_plan_product", "label": "build_plan_product()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "int", "label": "int", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "plplanproduct", "label": "PlPlanProduct", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "services_pl_plan_service_resolve_driver", "label": "_resolve_driver()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L118"}, {"id": "session", "label": "Session", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L118"}, {"id": "services_pl_plan_service_calc_freight_amount", "label": "_calc_freight_amount()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L163"}, {"id": "services_pl_plan_service_validate_toxic_products", "label": "_validate_toxic_products()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L187"}, {"id": "services_pl_plan_service_resolve_hazard_flags_from_crm", "label": "resolve_hazard_flags_from_crm()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L198"}, {"id": "services_pl_plan_service_update_plan_product_certs", "label": "update_plan_product_certs()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L225"}, {"id": "services_pl_plan_service_generate_transport_no", "label": "_generate_transport_no()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L275"}, {"id": "services_pl_plan_service_resolve_transport_context", "label": "_resolve_transport_context()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plplan", "label": "PlPlan", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plantransportcreateblock", "label": "PlanTransportCreateBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plvehicle", "label": Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_services_pl_freight_settlement_service_py", "label": "pl_freight_settlement_service.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L1"}, {"id": "services_pl_freight_settlement_service_resolve_user_display_name", "label": "_resolve_user_display_name()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L38"}, {"id": "session", "label": "Session", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L38"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L38"}, {"id": "services_pl_freight_settlement_service_occupied_transport_ids_subquery", "label": "_occupied_transport_ids_subquery()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L48"}, {"id": "services_pl_freight_settlement_service_get_settlement_row", "label": "get_settlement_row()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L64"}, {"id": "plfreightsettlement", "label": "PlFreightSettlement", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L64"}, {"id": "services_pl_freight_settlement_service_list_unsettled_plans", "label": "list_unsettled_plans()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L79"}, {"id": "int", "label": "int", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L79"}, {"id": "any", "label": "Any", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L79"}, {"id": "services_pl_freight_settlement_service_resolve_transports_for_create", "label": "_resolve_transports_for_create()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L147"}, {"id": "pltransport", "label": "PlTransport", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L147"}, {"id": "services_pl_freight_settlement_service_create_settlement", "label": "create_settlement()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L197"}, {"id": "services_pl_freight_settlement_service_delete_draft_settlement", "label": "delete_draft_settlement()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L241"}, {"id": "services_pl_freight_settlement_service_get_transport_ids", "label": "_get_transport_ids()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L266"}, {"id": "services_pl_freight_settlement_service_get_plans_for_transports", "label": "_get_plans_for_transports()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L278"}, {"id": "plplan", "label": "PlPlan", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L278"}, {"id": "services_pl_freight_settlement_service_approval_to_dict", "label": "_approval_to_dict()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L292"}, {"id": "plfreightsettlementapproval", "label": "PlFreightSettlementApproval", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L292"}, {"id": "services_pl_freight_settlement_service_create_settlement_approval_records", "label": "create_settlement_approval_records()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py", "source_location": "L307"}, {"id": "services_pl_freight_settlement_service_can_user_approve_settlement", "label": "can_user_approve_settlement()", "file_type": "code", "source_file": "/Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_services_pl_plan_service_py", "label": "pl_plan_service.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L1"}, {"id": "services_pl_plan_service_determine_plan_type", "label": "determine_plan_type()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L32"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L32"}, {"id": "services_pl_plan_service_is_ton_product_unit", "label": "is_ton_product_unit()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L40"}, {"id": "bool", "label": "bool", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L40"}, {"id": "services_pl_plan_service_product_quantity", "label": "_product_quantity()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "planproductcreate", "label": "PlanProductCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "decimal", "label": "Decimal", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "services_pl_plan_service_sum_product_quantities", "label": "sum_product_quantities()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L57"}, {"id": "services_pl_plan_service_estimate_qty_fields", "label": "_estimate_qty_fields()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L61"}, {"id": "services_pl_plan_service_build_plan_product", "label": "build_plan_product()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "int", "label": "int", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "plplanproduct", "label": "PlPlanProduct", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "services_pl_plan_service_resolve_driver", "label": "_resolve_driver()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L118"}, {"id": "session", "label": "Session", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L118"}, {"id": "services_pl_plan_service_calc_freight_amount", "label": "_calc_freight_amount()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L163"}, {"id": "services_pl_plan_service_validate_toxic_products", "label": "_validate_toxic_products()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L187"}, {"id": "services_pl_plan_service_resolve_hazard_flags_from_crm", "label": "resolve_hazard_flags_from_crm()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L198"}, {"id": "services_pl_plan_service_update_plan_product_certs", "label": "update_plan_product_certs()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L225"}, {"id": "services_pl_plan_service_generate_transport_no", "label": "_generate_transport_no()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L275"}, {"id": "services_pl_plan_service_resolve_transport_context", "label": "_resolve_transport_context()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plplan", "label": "PlPlan", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plantransportcreateblock", "label": "PlanTransportCreateBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plvehicle", "label": Line truncated
@@ -0,0 +1 @@
{"nodes": [{"id": "users_zlwu_work_00code_shanxia2_0_backend_app_services_pl_plan_service_py", "label": "pl_plan_service.py", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L1"}, {"id": "services_pl_plan_service_determine_plan_type", "label": "determine_plan_type()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L32"}, {"id": "str", "label": "str", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L32"}, {"id": "services_pl_plan_service_is_ton_product_unit", "label": "is_ton_product_unit()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L40"}, {"id": "bool", "label": "bool", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L40"}, {"id": "services_pl_plan_service_product_quantity", "label": "_product_quantity()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "planproductcreate", "label": "PlanProductCreate", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "decimal", "label": "Decimal", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L47"}, {"id": "services_pl_plan_service_sum_product_quantities", "label": "sum_product_quantities()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L57"}, {"id": "services_pl_plan_service_estimate_qty_fields", "label": "_estimate_qty_fields()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L61"}, {"id": "services_pl_plan_service_build_plan_product", "label": "build_plan_product()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "int", "label": "int", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "plplanproduct", "label": "PlPlanProduct", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L72"}, {"id": "services_pl_plan_service_resolve_driver", "label": "_resolve_driver()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L118"}, {"id": "session", "label": "Session", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L118"}, {"id": "services_pl_plan_service_calc_freight_amount", "label": "_calc_freight_amount()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L163"}, {"id": "services_pl_plan_service_validate_toxic_products", "label": "_validate_toxic_products()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L187"}, {"id": "services_pl_plan_service_resolve_hazard_flags_from_crm", "label": "resolve_hazard_flags_from_crm()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L198"}, {"id": "services_pl_plan_service_update_plan_product_certs", "label": "update_plan_product_certs()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L225"}, {"id": "services_pl_plan_service_generate_transport_no", "label": "_generate_transport_no()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L275"}, {"id": "services_pl_plan_service_resolve_transport_context", "label": "_resolve_transport_context()", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plplan", "label": "PlPlan", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plantransportcreateblock", "label": "PlanTransportCreateBlock", "file_type": "code", "source_file": "/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py", "source_location": "L293"}, {"id": "plvehicle", "label": Line truncated
+1 -1
View File
@@ -1 +1 @@
{"/Users/zlwu/work/00code/shanxia2.0/backend/start-prod.sh":{"size":5362,"mtime_ns":1780108930820143914,"hash":"712114b9a96e370660a7d8455b0cb014b6387a352e25c114bb396bc9815d48e6"},"/Users/zlwu/work/00code/shanxia2.0/backend/start.sh":{"size":9548,"mtime_ns":1780114661446983244,"hash":"4d632863e8a0cd81194b491d83a0218a4157435ae812dec76a6f6197b4d48e57"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/__init__.py":{"size":21,"mtime_ns":1780113982281973984,"hash":"60a04ff08fd97084e83ea809fd13feda6d2848be20ebf309e31fc1dad7523230"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/main.py":{"size":5354,"mtime_ns":1782225346624994084,"hash":"8b3d7c4c4488acc6afcfb1a01ea5c6a406ac9d865048233d7e7c6dfdbe793f9c"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/tasks/__init__.py":{"size":1953,"mtime_ns":1780805101147405418,"hash":"d2a416ff9daedad88780cbe3f14ea75e8299044f8787afb60e731f43963dc405"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/auth.py":{"size":8744,"mtime_ns":1780201410112435240,"hash":"df84858ae3cea547e5ae0174a2ee76cd4df8835f4b75827843369e74ea91098b"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/api_crypto.py":{"size":1870,"mtime_ns":1780108930724444498,"hash":"c04b748aea86890a5971f749523c7b17dbad1ddd6f9f7f07a5679d159c984e33"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/login_crypto.py":{"size":3858,"mtime_ns":1780108930725155710,"hash":"b82d51afabf2293a9cb1fb2e5f994c383948e7f47ea95fe674686b4f3f3342b1"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/config.py":{"size":5942,"mtime_ns":1782225345950464035,"hash":"565a2f55964323c1a93c64fcf7ce231b14ce547d39f8cddcdc08fc7537bc9642"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/wechat_pay.py":{"size":23585,"mtime_ns":1780108930725768130,"hash":"3d52265ce65d21e7103f94afa1e8547aee0823b5ea6d65c50317436ac81fb4fc"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/api_request_log_middleware.py":{"size":8978,"mtime_ns":1780108930724617124,"hash":"198e0861bb9933a7cee510524c4802001543468727a45e779bc4684d0214ffe2"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/database.py":{"size":1173,"mtime_ns":1780108930724965209,"hash":"8c45b5a56110164f2488c9c8db27db62fe77f0997cf22c53991c0bd1dde2043a"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/security.py":{"size":728,"mtime_ns":1780108930725470004,"hash":"df0f01115064f7b8de1c81dbe9a6db39360c236610b68c33b3234a51d7f0025b"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/request_payload.py":{"size":2842,"mtime_ns":1780108930725350836,"hash":"e9937151530ab1417ef297aef59111977725cf90be2a8fa76c00a0618789aba0"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/__init__.py":{"size":61,"mtime_ns":1780108930724312414,"hash":"3dd1842ee59b0c804176b03b4b8a323bd4a252b7feb1bbc32db64f3a8928570e"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/response.py":{"size":1824,"mtime_ns":1780108930725412462,"hash":"f1739352d65ea8287d76e282a59553aa8d63c97e35764c64ac378aa5bd9c347e"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/menu_guard.py":{"size":1611,"mtime_ns":1780108930725223002,"hash":"3e26077288c3620a4780038b891a326206b45bffe00aca545bdae30172487235"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/db_collation.py":{"size":548,"mtime_ns":1780108930725025043,"hash":"0c680e25a18244ca839a7de6ed1f4313b33bc8da118d89c463aee1b6af00c6f9"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/context.py":{"size":421,"mtime_ns":1780108930724824458,"hash":"83a10aee67162374993c10a30bf8bb8bd9c4b35cf48f42c832415ccebd91660f"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/utils.py":{"size":1498,"mtime_ns":1780108930725607296,"hash":"09323693661c1d4560458b86a954128ccff82bbaf6522da0b44f24da99ddf9ea"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/storage.py":{"size":13209,"mtime_ns":1780108930725541087,"hash":"c3138253eb34f65b09f4436e037fb3179d947f84d3b5fef007ed9a8e3bb135ee"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/order_status_compat.py":{"size":2828,"mtime_ns":1780108930725284669,"hash":"5349e5a0745ee6734c4a995337779307adefc46f453906171988a77de2081540"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/exceptions.py":{"size":4946,"mtime_ns":1780108930725084335,"hash":"79c997d964bca1a4f12f2b92fb1f181fdb9e2b3cf72eae39f4cc164d23794fd7"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/data_scope.py":{"size":5949,"mtime_ns":1780108930724890709,"hash":"c92a7dbcfe3d7440bfafc83a76e9ed431e2b054ddd95bc4bfac52b241635ab17"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/admin_request_json.py":{"size":2669,"mtime_ns":1780108930724378914,"hash":"4f68b3cf84291e7bddad6ecf4bb4d29ca5e1ec246a9f7f9c4cf5909d0ec1174a"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/api_crypto_middleware.py":{"size":11243,"mtime_ns":1780108930724537332,"hash":"0c2045d182138ec8e333356d36d418004a53948e2eda494cd419a36365ebbfae"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/wechat_message.py":{"size":11194,"mtime_ns":1780108930725684255,"hash":"5086070deb14d99d1a69e419b2299ec4eLine truncated
{"/Users/zlwu/work/00code/shanxia2.0/backend/start-prod.sh":{"size":5362,"mtime_ns":1780108930820143914,"hash":"712114b9a96e370660a7d8455b0cb014b6387a352e25c114bb396bc9815d48e6"},"/Users/zlwu/work/00code/shanxia2.0/backend/start.sh":{"size":9548,"mtime_ns":1780114661446983244,"hash":"4d632863e8a0cd81194b491d83a0218a4157435ae812dec76a6f6197b4d48e57"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/__init__.py":{"size":21,"mtime_ns":1780113982281973984,"hash":"60a04ff08fd97084e83ea809fd13feda6d2848be20ebf309e31fc1dad7523230"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/main.py":{"size":5354,"mtime_ns":1782225346624994084,"hash":"8b3d7c4c4488acc6afcfb1a01ea5c6a406ac9d865048233d7e7c6dfdbe793f9c"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/tasks/__init__.py":{"size":1953,"mtime_ns":1780805101147405418,"hash":"d2a416ff9daedad88780cbe3f14ea75e8299044f8787afb60e731f43963dc405"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/auth.py":{"size":8744,"mtime_ns":1780201410112435240,"hash":"df84858ae3cea547e5ae0174a2ee76cd4df8835f4b75827843369e74ea91098b"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/api_crypto.py":{"size":1870,"mtime_ns":1780108930724444498,"hash":"c04b748aea86890a5971f749523c7b17dbad1ddd6f9f7f07a5679d159c984e33"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/login_crypto.py":{"size":3858,"mtime_ns":1780108930725155710,"hash":"b82d51afabf2293a9cb1fb2e5f994c383948e7f47ea95fe674686b4f3f3342b1"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/config.py":{"size":5942,"mtime_ns":1782225345950464035,"hash":"565a2f55964323c1a93c64fcf7ce231b14ce547d39f8cddcdc08fc7537bc9642"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/wechat_pay.py":{"size":23585,"mtime_ns":1780108930725768130,"hash":"3d52265ce65d21e7103f94afa1e8547aee0823b5ea6d65c50317436ac81fb4fc"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/api_request_log_middleware.py":{"size":8978,"mtime_ns":1780108930724617124,"hash":"198e0861bb9933a7cee510524c4802001543468727a45e779bc4684d0214ffe2"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/database.py":{"size":1173,"mtime_ns":1780108930724965209,"hash":"8c45b5a56110164f2488c9c8db27db62fe77f0997cf22c53991c0bd1dde2043a"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/security.py":{"size":728,"mtime_ns":1780108930725470004,"hash":"df0f01115064f7b8de1c81dbe9a6db39360c236610b68c33b3234a51d7f0025b"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/request_payload.py":{"size":2842,"mtime_ns":1780108930725350836,"hash":"e9937151530ab1417ef297aef59111977725cf90be2a8fa76c00a0618789aba0"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/__init__.py":{"size":61,"mtime_ns":1780108930724312414,"hash":"3dd1842ee59b0c804176b03b4b8a323bd4a252b7feb1bbc32db64f3a8928570e"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/response.py":{"size":1824,"mtime_ns":1780108930725412462,"hash":"f1739352d65ea8287d76e282a59553aa8d63c97e35764c64ac378aa5bd9c347e"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/menu_guard.py":{"size":1611,"mtime_ns":1780108930725223002,"hash":"3e26077288c3620a4780038b891a326206b45bffe00aca545bdae30172487235"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/db_collation.py":{"size":548,"mtime_ns":1780108930725025043,"hash":"0c680e25a18244ca839a7de6ed1f4313b33bc8da118d89c463aee1b6af00c6f9"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/context.py":{"size":421,"mtime_ns":1780108930724824458,"hash":"83a10aee67162374993c10a30bf8bb8bd9c4b35cf48f42c832415ccebd91660f"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/utils.py":{"size":1498,"mtime_ns":1780108930725607296,"hash":"09323693661c1d4560458b86a954128ccff82bbaf6522da0b44f24da99ddf9ea"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/storage.py":{"size":13209,"mtime_ns":1780108930725541087,"hash":"c3138253eb34f65b09f4436e037fb3179d947f84d3b5fef007ed9a8e3bb135ee"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/order_status_compat.py":{"size":2828,"mtime_ns":1780108930725284669,"hash":"5349e5a0745ee6734c4a995337779307adefc46f453906171988a77de2081540"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/exceptions.py":{"size":4946,"mtime_ns":1780108930725084335,"hash":"79c997d964bca1a4f12f2b92fb1f181fdb9e2b3cf72eae39f4cc164d23794fd7"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/data_scope.py":{"size":5949,"mtime_ns":1780108930724890709,"hash":"c92a7dbcfe3d7440bfafc83a76e9ed431e2b054ddd95bc4bfac52b241635ab17"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/admin_request_json.py":{"size":2669,"mtime_ns":1780108930724378914,"hash":"4f68b3cf84291e7bddad6ecf4bb4d29ca5e1ec246a9f7f9c4cf5909d0ec1174a"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/api_crypto_middleware.py":{"size":11243,"mtime_ns":1780108930724537332,"hash":"0c2045d182138ec8e333356d36d418004a53948e2eda494cd419a36365ebbfae"},"/Users/zlwu/work/00code/shanxia2.0/backend/app/core/wechat_message.py":{"size":11194,"mtime_ns":1780108930725684255,"hash":"5086070deb14d99d1a69e419b2299ec4eLine truncated
+4 -4
View File
@@ -63,12 +63,12 @@
</div>
<div id="legend"></div>
</div>
<div id="stats">3989 nodes &middot; 30269 edges &middot; 130 communities</div>
<div id="stats">4071 nodes &middot; 30880 edges &middot; 136 communities</div>
</div>
<script>
const RAW_NODES = [{"id": "start_prod_sh", "label": "start-prod.sh", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.3, "font": {"size": 0, "color": "#ffffff"}, "title": "start-prod.sh", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 13}, {"id": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "label": "start-prod.sh script", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.2, "font": {"size": 0, "color": "#ffffff"}, "title": "start-prod.sh script", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 7}, {"id": "backend_start_prod_log_info", "label": "log_info()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "log_info()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_log_warn", "label": "log_warn()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "log_warn()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 5}, {"id": "backend_start_prod_log_error", "label": "log_error()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "log_error()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 5}, {"id": "backend_start_prod_show_help", "label": "show_help()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "show_help()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 2}, {"id": "backend_start_prod_ensure_dirs", "label": "ensure_dirs()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "ensure_dirs()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 3}, {"id": "backend_start_prod_check_python", "label": "check_python()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "check_python()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_ensure_venv_and_runtime", "label": "ensure_venv_and_runtime()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "ensure_venv_and_runtime()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_is_running", "label": "is_running()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "is_running()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_start_server", "label": "start_server()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.2, "font": {"size": 0, "color": "#ffffff"}, "title": "start_server()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 9}, {"id": "backend_start_prod_stop_server", "label": "stop_server()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "stop_server()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 5}, {"id": "backend_start_prod_status_server", "label": "status_server()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "status_server()", "community": 72, "community_name": "Community 72", "source_fiLine truncated
const RAW_EDGES = [{"from": "start_prod_sh", "to": "backend_start_prod_check_python", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_ensure_dirs", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_ensure_venv_and_runtime", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_is_running", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_log_error", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_log_info", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_log_warn", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_show_help", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_show_logs", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_start_server", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_status_server", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_stop_server", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "label": "contains", "title": "contains [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_log_error", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_show_help", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_show_logs", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_start_server", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_status_server", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_stop_server", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_check_python", "to": "backend_start_prod_log_info", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_start_server", "to": "backend_start_prod_log_info", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_stop_server", "to": "backend_start_prod_log_info", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_ensure_venv_and_runtime", "to": "backend_start_prod_log_warn", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "conLine truncated
const LEGEND = [{"cid": 0, "color": "#4E79A7", "label": "Community 0", "count": 133}, {"cid": 1, "color": "#F28E2B", "label": "Community 1", "count": 34}, {"cid": 2, "color": "#E15759", "label": "Community 2", "count": 228}, {"cid": 3, "color": "#76B7B2", "label": "Community 3", "count": 170}, {"cid": 4, "color": "#59A14F", "label": "Community 4", "count": 19}, {"cid": 5, "color": "#EDC948", "label": "Community 5", "count": 41}, {"cid": 6, "color": "#B07AA1", "label": "Community 6", "count": 94}, {"cid": 7, "color": "#FF9DA7", "label": "Community 7", "count": 31}, {"cid": 8, "color": "#9C755F", "label": "Community 8", "count": 22}, {"cid": 9, "color": "#BAB0AC", "label": "Community 9", "count": 21}, {"cid": 10, "color": "#4E79A7", "label": "Community 10", "count": 35}, {"cid": 11, "color": "#F28E2B", "label": "Community 11", "count": 60}, {"cid": 12, "color": "#E15759", "label": "Community 12", "count": 53}, {"cid": 13, "color": "#76B7B2", "label": "Community 13", "count": 42}, {"cid": 14, "color": "#59A14F", "label": "Community 14", "count": 71}, {"cid": 15, "color": "#EDC948", "label": "Community 15", "count": 25}, {"cid": 16, "color": "#B07AA1", "label": "Community 16", "count": 47}, {"cid": 17, "color": "#FF9DA7", "label": "Community 17", "count": 50}, {"cid": 18, "color": "#9C755F", "label": "Community 18", "count": 51}, {"cid": 19, "color": "#BAB0AC", "label": "Community 19", "count": 152}, {"cid": 20, "color": "#4E79A7", "label": "Community 20", "count": 33}, {"cid": 21, "color": "#F28E2B", "label": "Community 21", "count": 74}, {"cid": 22, "color": "#E15759", "label": "Community 22", "count": 12}, {"cid": 23, "color": "#76B7B2", "label": "Community 23", "count": 39}, {"cid": 24, "color": "#59A14F", "label": "Community 24", "count": 23}, {"cid": 25, "color": "#EDC948", "label": "Community 25", "count": 19}, {"cid": 26, "color": "#B07AA1", "label": "Community 26", "count": 32}, {"cid": 27, "color": "#FF9DA7", "label": "Community 27", "count": 33}, {"cid": 28, "color": "#9C755F", "label": "Community 28", "count": 33}, {"cid": 29, "color": "#BAB0AC", "label": "Community 29", "count": 32}, {"cid": 30, "color": "#4E79A7", "label": "Community 30", "count": 32}, {"cid": 31, "color": "#F28E2B", "label": "Community 31", "count": 33}, {"cid": 32, "color": "#E15759", "label": "Community 32", "count": 22}, {"cid": 33, "color": "#76B7B2", "label": "Community 33", "count": 78}, {"cid": 34, "color": "#59A14F", "label": "Community 34", "count": 30}, {"cid": 35, "color": "#EDC948", "label": "Community 35", "count": 23}, {"cid": 36, "color": "#B07AA1", "label": "Community 36", "count": 40}, {"cid": 37, "color": "#FF9DA7", "label": "Community 37", "count": 16}, {"cid": 38, "color": "#9C755F", "label": "Community 38", "count": 6}, {"cid": 39, "color": "#BAB0AC", "label": "Community 39", "count": 11}, {"cid": 40, "color": "#4E79A7", "label": "Community 40", "count": 27}, {"cid": 41, "color": "#F28E2B", "label": "Community 41", "count": 27}, {"cid": 42, "color": "#E15759", "label": "Community 42", "count": 26}, {"cid": 43, "color": "#76B7B2", "label": "Community 43", "count": 51}, {"cid": 44, "color": "#59A14F", "label": "Community 44", "count": 24}, {"cid": 45, "color": "#EDC948", "label": "Community 45", "count": 16}, {"cid": 46, "color": "#B07AA1", "label": "Community 46", "count": 10}, {"cid": 47, "color": "#FF9DA7", "label": "Community 47", "count": 6}, {"cid": 48, "color": "#9C755F", "label": "Community 48", "count": 29}, {"cid": 49, "color": "#BAB0AC", "label": "Community 49", "count": 160}, {"cid": 50, "color": "#4E79A7", "label": "Community 50", "count": 48}, {"cid": 51, "color": "#F28E2B", "label": "Community 51", "count": 31}, {"cid": 52, "color": "#E15759", "label": "Community 52", "count": 19}, {"cid": 53, "color": "#76B7B2", "label": "Community 53", "count": 115}, {"cid": 54, "color": "#59A14F", "label": "Community 54", "count": 19}, {"cid": 55, "color": "#EDC948", "label": "Community 55", "count": 19}, {"cid": 57, "color": "#FF9DA7", "label": "Community 57", "count": 18}, {"cid": 58, "color": "#9C755F", "label": "Community 58", "count": 18}, {"cid": 59, "color": "#BAB0AC", "label": "Community 59", "count": 17}, {"cid": 60, "color": "#4E79A7", "label": "Community 60", "count": 17}, {"cid": 61, "color": "#F28E2B", "label": "Community 61", "count": 7}, {"cid": 62, "color": "#E15759", "label": "Community 62", "count": 31}, {"cid": 63, "color": "#76B7B2", "label": "Community 63", "count": 50}, {"cid": 64, "color": "#59A14F", "label": "Community 64", "count": 16}, {"cid": 65, "color": "#EDC948", "label": "Community 65", "count": 23}, {"cid": 67, "color": "#FF9DA7", "label": "Community 67", "count": 16}, {"cid": 68, "color": "#9C755F", "label": "Community 68", "count": 16}, {"cid": 69, "color": "#BAB0AC", "label": "Community 69", "count": 55}, {"cid": 70, "color": "#4E79A7", "label": "Community 70", "count": 15}, {"cid": 71, "color": "#F28E2B", "label": "Community 71", "count": 11}, {"cid": 72, "color": "#E15759"Line truncated
const RAW_NODES = [{"id": "start_prod_sh", "label": "start-prod.sh", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.3, "font": {"size": 0, "color": "#ffffff"}, "title": "start-prod.sh", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 13}, {"id": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "label": "start-prod.sh script", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.2, "font": {"size": 0, "color": "#ffffff"}, "title": "start-prod.sh script", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 7}, {"id": "backend_start_prod_log_info", "label": "log_info()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "log_info()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_log_warn", "label": "log_warn()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "log_warn()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 5}, {"id": "backend_start_prod_log_error", "label": "log_error()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "log_error()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 5}, {"id": "backend_start_prod_show_help", "label": "show_help()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "show_help()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 2}, {"id": "backend_start_prod_ensure_dirs", "label": "ensure_dirs()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "ensure_dirs()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 3}, {"id": "backend_start_prod_check_python", "label": "check_python()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "check_python()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_ensure_venv_and_runtime", "label": "ensure_venv_and_runtime()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "ensure_venv_and_runtime()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_is_running", "label": "is_running()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "is_running()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 4}, {"id": "backend_start_prod_start_server", "label": "start_server()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.2, "font": {"size": 0, "color": "#ffffff"}, "title": "start_server()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 9}, {"id": "backend_start_prod_stop_server", "label": "stop_server()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "stop_server()", "community": 72, "community_name": "Community 72", "source_file": "start-prod.sh", "file_type": "code", "degree": 5}, {"id": "backend_start_prod_status_server", "label": "status_server()", "color": {"background": "#E15759", "border": "#E15759", "highlight": {"background": "#ffffff", "border": "#E15759"}}, "size": 10.1, "font": {"size": 0, "color": "#ffffff"}, "title": "status_server()", "community": 72, "community_name": "Community 72", "source_fiLine truncated
const RAW_EDGES = [{"from": "start_prod_sh", "to": "backend_start_prod_check_python", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_ensure_dirs", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_ensure_venv_and_runtime", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_is_running", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_log_error", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_log_info", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_log_warn", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_show_help", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_show_logs", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_start_server", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_status_server", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "backend_start_prod_stop_server", "label": "defines", "title": "defines [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "start_prod_sh", "to": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "label": "contains", "title": "contains [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_log_error", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_show_help", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_show_logs", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_start_server", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_status_server", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "users_zlwu_work_00code_shanxia2_0_backend_start_prod_sh__entry", "to": "backend_start_prod_stop_server", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_check_python", "to": "backend_start_prod_log_info", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_start_server", "to": "backend_start_prod_log_info", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_stop_server", "to": "backend_start_prod_log_info", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "confidence": "EXTRACTED"}, {"from": "backend_start_prod_ensure_venv_and_runtime", "to": "backend_start_prod_log_warn", "label": "calls", "title": "calls [EXTRACTED]", "dashes": false, "width": 2, "color": {"opacity": 0.7}, "conLine truncated
const LEGEND = [{"cid": 0, "color": "#4E79A7", "label": "Community 0", "count": 105}, {"cid": 1, "color": "#F28E2B", "label": "Community 1", "count": 47}, {"cid": 2, "color": "#E15759", "label": "Community 2", "count": 230}, {"cid": 3, "color": "#76B7B2", "label": "Community 3", "count": 173}, {"cid": 4, "color": "#59A14F", "label": "Community 4", "count": 19}, {"cid": 5, "color": "#EDC948", "label": "Community 5", "count": 39}, {"cid": 6, "color": "#B07AA1", "label": "Community 6", "count": 106}, {"cid": 7, "color": "#FF9DA7", "label": "Community 7", "count": 37}, {"cid": 8, "color": "#9C755F", "label": "Community 8", "count": 38}, {"cid": 9, "color": "#BAB0AC", "label": "Community 9", "count": 21}, {"cid": 10, "color": "#4E79A7", "label": "Community 10", "count": 35}, {"cid": 11, "color": "#F28E2B", "label": "Community 11", "count": 65}, {"cid": 12, "color": "#E15759", "label": "Community 12", "count": 55}, {"cid": 13, "color": "#76B7B2", "label": "Community 13", "count": 45}, {"cid": 14, "color": "#59A14F", "label": "Community 14", "count": 57}, {"cid": 15, "color": "#EDC948", "label": "Community 15", "count": 25}, {"cid": 16, "color": "#B07AA1", "label": "Community 16", "count": 48}, {"cid": 17, "color": "#FF9DA7", "label": "Community 17", "count": 47}, {"cid": 18, "color": "#9C755F", "label": "Community 18", "count": 50}, {"cid": 19, "color": "#BAB0AC", "label": "Community 19", "count": 120}, {"cid": 20, "color": "#4E79A7", "label": "Community 20", "count": 71}, {"cid": 21, "color": "#F28E2B", "label": "Community 21", "count": 106}, {"cid": 22, "color": "#E15759", "label": "Community 22", "count": 12}, {"cid": 23, "color": "#76B7B2", "label": "Community 23", "count": 37}, {"cid": 24, "color": "#59A14F", "label": "Community 24", "count": 23}, {"cid": 25, "color": "#EDC948", "label": "Community 25", "count": 19}, {"cid": 26, "color": "#B07AA1", "label": "Community 26", "count": 65}, {"cid": 27, "color": "#FF9DA7", "label": "Community 27", "count": 34}, {"cid": 28, "color": "#9C755F", "label": "Community 28", "count": 33}, {"cid": 29, "color": "#BAB0AC", "label": "Community 29", "count": 32}, {"cid": 30, "color": "#4E79A7", "label": "Community 30", "count": 30}, {"cid": 31, "color": "#F28E2B", "label": "Community 31", "count": 39}, {"cid": 32, "color": "#E15759", "label": "Community 32", "count": 30}, {"cid": 33, "color": "#76B7B2", "label": "Community 33", "count": 50}, {"cid": 34, "color": "#59A14F", "label": "Community 34", "count": 29}, {"cid": 35, "color": "#EDC948", "label": "Community 35", "count": 23}, {"cid": 36, "color": "#B07AA1", "label": "Community 36", "count": 37}, {"cid": 37, "color": "#FF9DA7", "label": "Community 37", "count": 16}, {"cid": 38, "color": "#9C755F", "label": "Community 38", "count": 5}, {"cid": 39, "color": "#BAB0AC", "label": "Community 39", "count": 18}, {"cid": 40, "color": "#4E79A7", "label": "Community 40", "count": 27}, {"cid": 41, "color": "#F28E2B", "label": "Community 41", "count": 30}, {"cid": 42, "color": "#E15759", "label": "Community 42", "count": 26}, {"cid": 43, "color": "#76B7B2", "label": "Community 43", "count": 24}, {"cid": 44, "color": "#59A14F", "label": "Community 44", "count": 24}, {"cid": 45, "color": "#EDC948", "label": "Community 45", "count": 59}, {"cid": 46, "color": "#B07AA1", "label": "Community 46", "count": 10}, {"cid": 47, "color": "#FF9DA7", "label": "Community 47", "count": 6}, {"cid": 48, "color": "#9C755F", "label": "Community 48", "count": 25}, {"cid": 49, "color": "#BAB0AC", "label": "Community 49", "count": 49}, {"cid": 50, "color": "#4E79A7", "label": "Community 50", "count": 62}, {"cid": 51, "color": "#F28E2B", "label": "Community 51", "count": 102}, {"cid": 52, "color": "#E15759", "label": "Community 52", "count": 21}, {"cid": 53, "color": "#76B7B2", "label": "Community 53", "count": 119}, {"cid": 54, "color": "#59A14F", "label": "Community 54", "count": 19}, {"cid": 55, "color": "#EDC948", "label": "Community 55", "count": 19}, {"cid": 56, "color": "#B07AA1", "label": "Community 56", "count": 23}, {"cid": 57, "color": "#FF9DA7", "label": "Community 57", "count": 18}, {"cid": 58, "color": "#9C755F", "label": "Community 58", "count": 18}, {"cid": 59, "color": "#BAB0AC", "label": "Community 59", "count": 17}, {"cid": 60, "color": "#4E79A7", "label": "Community 60", "count": 17}, {"cid": 61, "color": "#F28E2B", "label": "Community 61", "count": 7}, {"cid": 62, "color": "#E15759", "label": "Community 62", "count": 49}, {"cid": 63, "color": "#76B7B2", "label": "Community 63", "count": 48}, {"cid": 64, "color": "#59A14F", "label": "Community 64", "count": 16}, {"cid": 65, "color": "#EDC948", "label": "Community 65", "count": 23}, {"cid": 66, "color": "#B07AA1", "label": "Community 66", "count": 15}, {"cid": 67, "color": "#FF9DA7", "label": "Community 67", "count": 16}, {"cid": 68, "color": "#9C755F", "label": "Community 68", "count": 16}, {"cid": 69, "color": "#BAB0AC", "label": "Community 69", "count": 31}, {"cid": 70, "color": "#4E79ALine truncated
// HTML-escape helper — prevents XSS when injecting graph data into innerHTML
function esc(s) {
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,135 @@
-- =============================================================================
-- 运费结算完善 · 审批表 + 字典 + 按钮权限
-- 执行库:shanxia2.0 门户库
-- 说明:可重复执行
-- =============================================================================
SET NAMES utf8mb4;
-- -----------------------------------------------------------------------------
-- 1. 审批记录表
-- -----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `pl_freight_settlement_approval` (
`id` varchar(64) NOT NULL COMMENT '主键ID',
`settlement_id` varchar(64) NOT NULL COMMENT '结算单ID',
`step` int(11) NOT NULL DEFAULT 1 COMMENT '步骤序号',
`step_name` varchar(50) DEFAULT NULL COMMENT '步骤名称',
`approver_id` varchar(64) NOT NULL COMMENT '审批人ID',
`approver_name` varchar(64) DEFAULT NULL COMMENT '审批人姓名',
`approval_type` varchar(20) NOT NULL DEFAULT 'sequential' COMMENT 'sequential/parallel/or',
`approval_result` varchar(20) NOT NULL DEFAULT 'pending' COMMENT 'pending/approved/rejected/skipped',
`approval_opinion` varchar(500) DEFAULT NULL COMMENT '审批意见',
`approval_time` datetime DEFAULT NULL COMMENT '审批时间',
`is_current` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否当前节点',
`tenant_no` varchar(64) NOT NULL DEFAULT 'shanxia2.0' COMMENT '租户编号',
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人id',
`create_dept_id` varchar(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人id',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除标记:0-正常 1-已删除',
PRIMARY KEY (`id`),
KEY `idx_pl_fsa_settlement` (`settlement_id`, `del_flag`),
KEY `idx_pl_fsa_approver` (`approver_id`, `approval_result`, `is_current`, `del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运费结算审批记录';
-- -----------------------------------------------------------------------------
-- 2. 结算状态字典
-- -----------------------------------------------------------------------------
INSERT INTO `sys_dict_data` (
`id`, `dict_label`, `dict_value`, `tag_type`, `dict_type`, `tenant_no`, `order_num`,
`remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(
'PL_SETTLEMENT_STATUS_PENDING', '草稿', 'pending', 'info', 'pl_settlement_status', 'shanxia2.0', 1,
NULL, 'system', '', NOW(), NULL, NOW(), 0
),
(
'PL_SETTLE_APPROVING', '审批中', 'approving', 'warning', 'pl_settlement_status', 'shanxia2.0', 2,
NULL, 'system', '', NOW(), NULL, NOW(), 0
),
(
'PL_SETTLE_APPROVED', '待发放', 'approved', 'primary', 'pl_settlement_status', 'shanxia2.0', 3,
NULL, 'system', '', NOW(), NULL, NOW(), 0
),
(
'PL_SETTLEMENT_STATUS_CONFIRMED', '已结算', 'confirmed', 'success', 'pl_settlement_status', 'shanxia2.0', 4,
NULL, 'system', '', NOW(), NULL, NOW(), 0
)
ON DUPLICATE KEY UPDATE
`dict_label` = VALUES(`dict_label`),
`tag_type` = VALUES(`tag_type`),
`order_num` = VALUES(`order_num`),
`update_time` = NOW(),
`del_flag` = 0;
UPDATE `sys_dict_data`
SET `del_flag` = 1, `update_time` = NOW()
WHERE `dict_type` = 'pl_settlement_status'
AND `dict_value` IN ('submitted')
AND `del_flag` = 0;
-- -----------------------------------------------------------------------------
-- 3. 运费结算按钮权限(parent PL_FREIGHT)
-- -----------------------------------------------------------------------------
INSERT INTO `sys_menu` (
`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
`is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
('PL_FREIGHT_Q', '查询', 'PL_FREIGHT', 'F', '', '', 'pl:freight:query', 1, '1', '1', 'shanxia2.0', 1, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_FREIGHT_C', '组单', 'PL_FREIGHT', 'F', '', '', 'pl:freight:create', 1, '1', '1', 'shanxia2.0', 2, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_FREIGHT_E', '编辑', 'PL_FREIGHT', 'F', '', '', 'pl:freight:edit', 1, '1', '1', 'shanxia2.0', 3, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_FREIGHT_S', '提交审批', 'PL_FREIGHT', 'F', '', '', 'pl:freight:submit', 1, '1', '1', 'shanxia2.0', 4, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_FREIGHT_A', '审批', 'PL_FREIGHT', 'F', '', '', 'pl:freight:approve', 1, '1', '1', 'shanxia2.0', 5, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_FREIGHT_W', '撤回', 'PL_FREIGHT', 'F', '', '', 'pl:freight:withdraw', 1, '1', '1', 'shanxia2.0', 6, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_FREIGHT_D', '发放登记', 'PL_FREIGHT', 'F', '', '', 'pl:freight:disburse', 1, '1', '1', 'shanxia2.0', 7, NULL, 'system', '', NOW(), NULL, NOW(), 0)
ON DUPLICATE KEY UPDATE
`menu_name` = VALUES(`menu_name`),
`parent_id` = VALUES(`parent_id`),
`perms` = VALUES(`perms`),
`update_time` = NOW(),
`del_flag` = 0;
-- 可选:为已有运费结算菜单的角色自动授权按钮
INSERT INTO `sys_role_menu` (
`id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
)
SELECT
REPLACE(UUID(), '-', ''),
rm.`role_id`,
m.`menu_id`,
rm.`tenant_no`,
m.`order_num`,
'pl freight buttons auto grant',
'system',
'',
NOW(),
NULL,
NOW(),
0
FROM `sys_role_menu` rm
INNER JOIN (
SELECT 'PL_FREIGHT_Q' AS menu_id, 1 AS order_num UNION ALL
SELECT 'PL_FREIGHT_C', 2 UNION ALL
SELECT 'PL_FREIGHT_E', 3 UNION ALL
SELECT 'PL_FREIGHT_S', 4 UNION ALL
SELECT 'PL_FREIGHT_A', 5 UNION ALL
SELECT 'PL_FREIGHT_W', 6 UNION ALL
SELECT 'PL_FREIGHT_D', 7
) m ON 1 = 1
WHERE rm.`menu_id` = 'PL_FREIGHT'
AND rm.`del_flag` = 0
AND NOT EXISTS (
SELECT 1 FROM `sys_role_menu` x
WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = m.`menu_id` AND x.`del_flag` = 0
);
SELECT `id`, `menu_name`, `perms` FROM `sys_menu`
WHERE `id` LIKE 'PL_FREIGHT%' AND `del_flag` = 0 ORDER BY `order_num`;
+114
View File
@@ -0,0 +1,114 @@
-- =============================================================================
-- 运输计划归档 · 菜单与按钮权限
-- 执行库:shanxia2.0 门户库(与 web-admin 同库)
-- 说明:可重复执行(ON DUPLICATE KEY UPDATE / NOT EXISTS)
-- 执行后:重新登录或刷新菜单缓存,侧栏「运输管理」下出现「运输计划归档」
-- =============================================================================
SET NAMES utf8mb4;
-- -----------------------------------------------------------------------------
-- 1. 菜单(C)+ 按钮权限(F)
-- 路由:/#/pl/plan-archive
-- -----------------------------------------------------------------------------
INSERT INTO `sys_menu` (
`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
`is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(
'PL_PLAN_ARCHIVE', '运输计划归档', 'PL_MENU_ROOT', 'C',
'plan-archive', 'pl/plan-archive/index', 'pl:plan-archive:list',
1, '1', '1', 'shanxia2.0', 11, NULL,
'system', '', NOW(), NULL, NOW(), 0
),
(
'PL_PLAN_ARCHIVE_Q', '查询', 'PL_PLAN_ARCHIVE', 'F',
'', '', 'pl:plan-archive:query',
1, '1', '1', 'shanxia2.0', 1, NULL,
'system', '', NOW(), NULL, NOW(), 0
),
(
'PL_PLAN_ARCHIVE_E', '编辑', 'PL_PLAN_ARCHIVE', 'F',
'', '', 'pl:plan-archive:edit',
1, '1', '1', 'shanxia2.0', 2, NULL,
'system', '', NOW(), NULL, NOW(), 0
),
(
'PL_PLAN_ARCHIVE_A', '归档', 'PL_PLAN_ARCHIVE', 'F',
'', '', 'pl:plan-archive:archive',
1, '1', '1', 'shanxia2.0', 3, NULL,
'system', '', NOW(), NULL, NOW(), 0
)
ON DUPLICATE KEY UPDATE
`menu_name` = VALUES(`menu_name`),
`parent_id` = VALUES(`parent_id`),
`menu_type` = VALUES(`menu_type`),
`path` = VALUES(`path`),
`component` = VALUES(`component`),
`perms` = VALUES(`perms`),
`visible` = VALUES(`visible`),
`status` = VALUES(`status`),
`order_num` = VALUES(`order_num`),
`update_time` = NOW(),
`del_flag` = 0;
-- -----------------------------------------------------------------------------
-- 2. 调整「危化品证上传」排序,排在归档菜单之后
-- -----------------------------------------------------------------------------
UPDATE `sys_menu`
SET `order_num` = 12, `update_time` = NOW()
WHERE `id` = 'PL_PLAN_CERT'
AND `del_flag` = 0
AND (`order_num` IS NULL OR `order_num` <> 12);
-- -----------------------------------------------------------------------------
-- 3.(可选)角色授权:为已拥有「运输计划」菜单的角色,自动勾选归档菜单及按钮
-- 若需手工在「系统管理 → 角色管理」里分配,可注释掉本节
-- -----------------------------------------------------------------------------
INSERT INTO `sys_role_menu` (
`id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
)
SELECT
REPLACE(UUID(), '-', ''),
rm.`role_id`,
m.`menu_id`,
rm.`tenant_no`,
m.`order_num`,
'pl plan archive auto grant',
'system',
'',
NOW(),
NULL,
NOW(),
0
FROM `sys_role_menu` rm
INNER JOIN (
SELECT 'PL_PLAN_ARCHIVE' AS menu_id, 11 AS order_num UNION ALL
SELECT 'PL_PLAN_ARCHIVE_Q', 1 UNION ALL
SELECT 'PL_PLAN_ARCHIVE_E', 2 UNION ALL
SELECT 'PL_PLAN_ARCHIVE_A', 3
) m ON 1 = 1
WHERE rm.`menu_id` = 'PL_PLAN'
AND rm.`del_flag` = 0
AND NOT EXISTS (
SELECT 1
FROM `sys_role_menu` x
WHERE x.`role_id` = rm.`role_id`
AND x.`menu_id` = m.`menu_id`
AND x.`del_flag` = 0
);
-- -----------------------------------------------------------------------------
-- 4. 校验(执行后可查看结果)
-- -----------------------------------------------------------------------------
SELECT `id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `order_num`
FROM `sys_menu`
WHERE `id` IN ('PL_PLAN_ARCHIVE', 'PL_PLAN_ARCHIVE_Q', 'PL_PLAN_ARCHIVE_E', 'PL_PLAN_ARCHIVE_A')
AND `del_flag` = 0
ORDER BY `id`;
+30
View File
@@ -457,6 +457,36 @@ CREATE TABLE `pl_freight_settlement_transport` (
KEY `idx_tenant` (`tenant_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='结算单-运输关联表';
-- ----------------------------
-- Table structure for pl_freight_settlement_approval (运费结算审批记录)
-- ----------------------------
DROP TABLE IF EXISTS `pl_freight_settlement_approval`;
CREATE TABLE `pl_freight_settlement_approval` (
`id` varchar(64) NOT NULL COMMENT '主键ID',
`settlement_id` varchar(64) NOT NULL COMMENT '结算单ID',
`step` int(11) NOT NULL DEFAULT 1 COMMENT '步骤序号',
`step_name` varchar(50) DEFAULT NULL COMMENT '步骤名称',
`approver_id` varchar(64) NOT NULL COMMENT '审批人ID',
`approver_name` varchar(64) DEFAULT NULL COMMENT '审批人姓名',
`approval_type` varchar(20) NOT NULL DEFAULT 'sequential' COMMENT 'sequential/parallel/or',
`approval_result` varchar(20) NOT NULL DEFAULT 'pending' COMMENT 'pending/approved/rejected/skipped',
`approval_opinion` varchar(500) DEFAULT NULL COMMENT '审批意见',
`approval_time` datetime DEFAULT NULL COMMENT '审批时间',
`is_current` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否当前节点',
`tenant_no` varchar(64) NOT NULL DEFAULT 'shanxia2.0' COMMENT '租户编号',
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人id',
`create_dept_id` varchar(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人id',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除标记:0-正常 1-已删除',
PRIMARY KEY (`id`),
KEY `idx_pl_fsa_settlement` (`settlement_id`, `del_flag`),
KEY `idx_pl_fsa_approver` (`approver_id`, `approval_result`, `is_current`, `del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运费结算审批记录';
-- ----------------------------
-- Table structure for pl_remittance_voucher (汇款凭证表)
-- ----------------------------
+5 -1
View File
@@ -8494,7 +8494,11 @@ INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `co
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_INVENTORY', '盘存统计', 'PL_MENU_ROOT', 'C', 'inventory', 'pl/inventory/ledger', 'pl:inventory:list', 1, '0', '1', 'shanxia2.0', 40, NULL, 'system', '', '2026-06-11 05:17:13', NULL, '2026-06-20 21:42:04', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_MENU_ROOT', '运输管理', '2', 'M', '/pl', NULL, '', 1, '1', '1', 'shanxia2.0', 8, '运输管理父菜单', 'system', '', '2026-06-11 05:17:12', NULL, '2026-06-20 21:42:04', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN', '运输计划', 'PL_MENU_ROOT', 'C', 'plan', 'pl/plan/index', 'pl:plan:list', 1, '1', '1', 'shanxia2.0', 10, NULL, 'system', '', '2026-06-11 05:17:12', NULL, '2026-06-11 05:17:12', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN_CERT', '危化品证上传', 'PL_MENU_ROOT', 'C', 'plan-cert', 'pl/plan-cert/index', 'pl:plan-cert:list', 1, '1', '1', 'shanxia2.0', 11, '危化品购买证/运输证上传', 'system', '', '2026-06-20 18:18:10', NULL, '2026-06-20 18:18:10', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN_ARCHIVE', '运输计划归档', 'PL_MENU_ROOT', 'C', 'plan-archive', 'pl/plan-archive/index', 'pl:plan-archive:list', 1, '1', '1', 'shanxia2.0', 11, NULL, 'system', '', '2026-06-25 12:00:00', NULL, '2026-06-25 12:00:00', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN_ARCHIVE_Q', '查询', 'PL_PLAN_ARCHIVE', 'F', '', '', 'pl:plan-archive:query', 1, '1', '1', 'shanxia2.0', 1, NULL, 'system', '', '2026-06-25 12:00:00', NULL, '2026-06-25 12:00:00', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN_ARCHIVE_E', '编辑', 'PL_PLAN_ARCHIVE', 'F', '', '', 'pl:plan-archive:edit', 1, '1', '1', 'shanxia2.0', 2, NULL, 'system', '', '2026-06-25 12:00:00', NULL, '2026-06-25 12:00:00', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN_ARCHIVE_A', '归档', 'PL_PLAN_ARCHIVE', 'F', '', '', 'pl:plan-archive:archive', 1, '1', '1', 'shanxia2.0', 3, NULL, 'system', '', '2026-06-25 12:00:00', NULL, '2026-06-25 12:00:00', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_PLAN_CERT', '危化品证上传', 'PL_MENU_ROOT', 'C', 'plan-cert', 'pl/plan-cert/index', 'pl:plan-cert:list', 1, '1', '1', 'shanxia2.0', 12, '危化品购买证/运输证上传', 'system', '', '2026-06-20 18:18:10', NULL, '2026-06-20 18:18:10', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_SELF_VEHICLE', '山峡自有车辆', 'PL_MENU_ROOT', 'C', 'self-vehicle', 'pl/self-vehicle/index', 'pl:self-vehicle:list', 1, '1', '1', 'shanxia2.0', 4, '展示全部自有类型车辆', 'system', '', '2026-06-20 08:07:00', NULL, '2026-06-20 08:07:00', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_TRANSPORT', '运输管理', 'PL_MENU_ROOT', 'C', 'transport', 'pl/transport/index', 'pl:transport:list', 1, '0', '1', 'shanxia2.0', 20, NULL, 'system', '', '2026-06-11 05:17:13', NULL, '2026-06-20 21:42:04', 0);
INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`, `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('PL_VEHICLE', '车辆管理', 'PL_MENU_ROOT', 'C', 'vehicle', 'pl/vehicle/index', 'pl:vehicle:list', 1, '1', '1', 'shanxia2.0', 2, NULL, 'system', '', '2026-06-11 05:17:12', NULL, '2026-06-11 05:17:12', 0);
@@ -0,0 +1,543 @@
# 运费结算完善 — Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** 将运费结算重构为四 Tab(未结算计划 / 结算单 / 待财务发放 / 已结算),支持多计划组单、合同式多级审批、财务发放登记。
**Architecture:** 新建 `pl_freight_settlement_approval` 与 `pl_freight_settlement_service.py`(审批链 CRUD 对齐 `contract_approval.py`);`freight.py` 路由薄层调用 service;前端 `freight/index.vue` 改为 Tab 容器 + 四个 Panel 子组件 + 三个业务弹窗(查看/审批/发放)。
**Tech Stack:** FastAPI + SQLAlchemy + Pydantic v2;Vue 3 + Element Plus + 字典 Store
**Spec:** `docs/superpowers/specs/2026-06-25-pl-freight-settlement-design.md`
---
## 文件结构
| 文件 | 职责 |
|------|------|
| `docs/sql/20260625_pl_freight_settlement_approval.sql` | 审批表 DDL + 字典 + 按钮权限 |
| `backend/app/models/pl_models.py` | `PlFreightSettlementApproval` |
| `backend/app/schemas/pl/freight.py` | 组单/审批/发放/列表扩展 Schema |
| `backend/app/services/pl_freight_settlement_service.py` | 未结算查询、组单、审批、发放 |
| `backend/app/api/pl/freight.py` | 新路由;废弃旧 submit/approve |
| `backend/app/services/pl_plan_service.py` | 更新 `_LOCKED_SETTLEMENT_STATUSES` |
| `web-admin/src/api/pl/index.ts` | `freightApi` 扩展 |
| `web-admin/src/views/pl/freight/index.vue` | Tab 容器 |
| `web-admin/src/views/pl/freight/components/UnsettledPlanPanel.vue` | Tab1 |
| `web-admin/src/views/pl/freight/components/SettlementBillPanel.vue` | Tab2 |
| `web-admin/src/views/pl/freight/components/DisbursePanel.vue` | Tab3 |
| `web-admin/src/views/pl/freight/components/SettledPanel.vue` | Tab4 |
| `web-admin/src/components/business/pl-freight-settlement-view-dialog/index.vue` | 查看 |
| `web-admin/src/components/business/pl-freight-settlement-form-dialog/index.vue` | 草稿编辑 |
| `web-admin/src/components/business/pl-freight-approval-dialog/index.vue` | 提交/审批 |
| `web-admin/src/components/business/pl-freight-disburse-dialog/index.vue` | 财务发放 |
---
### Task 1: 数据库 DDL + 字典 + 菜单权限
**Files:**
- Create: `docs/sql/20260625_pl_freight_settlement_approval.sql`
- Modify: `docs/sql/pl_tables.sql`(同步表结构)
- Modify: `docs/sql/shanxia2.0.sql`(全量快照,可选后续导出)
- [ ] **Step 1:** 创建独立 SQL 脚本,含:
```sql
-- pl_freight_settlement_approval
CREATE TABLE IF NOT EXISTS pl_freight_settlement_approval (
id VARCHAR(64) NOT NULL COMMENT '主键ID',
settlement_id VARCHAR(64) NOT NULL COMMENT '结算单ID',
step INT NOT NULL DEFAULT 1 COMMENT '步骤序号',
step_name VARCHAR(50) NULL COMMENT '步骤名称',
approver_id VARCHAR(64) NOT NULL COMMENT '审批人ID',
approver_name VARCHAR(64) NULL COMMENT '审批人姓名',
approval_type VARCHAR(20) NOT NULL DEFAULT 'sequential' COMMENT 'sequential/parallel/or',
approval_result VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT 'pending/approved/rejected',
approval_opinion VARCHAR(500) NULL COMMENT '审批意见',
approval_time DATETIME NULL COMMENT '审批时间',
is_current TINYINT NOT NULL DEFAULT 0 COMMENT '是否当前节点',
tenant_no VARCHAR(64) NOT NULL DEFAULT 'shanxia2.0',
order_num INT NULL,
remark VARCHAR(512) NULL,
create_by VARCHAR(64) NULL,
create_dept_id VARCHAR(64) NOT NULL DEFAULT '',
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_by VARCHAR(64) NULL,
update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
del_flag TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY idx_pl_fsa_settlement (settlement_id, del_flag),
KEY idx_pl_fsa_approver (approver_id, approval_result, is_current, del_flag)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运费结算审批记录';
```
- [ ] **Step 2:** 同一脚本更新 `pl_settlement_status` 字典:
```sql
-- 新增/更新
INSERT INTO sys_dict_data (...) VALUES
('PL_SETTLE_APPROVING', '审批中', 'approving', 'warning', 'pl_settlement_status', ...),
('PL_SETTLE_APPROVED', '待发放', 'approved', 'primary', 'pl_settlement_status', ...);
-- 更新 pending 标签为「草稿」、confirmed 为「已结算」
```
- [ ] **Step 3:** 按钮权限(parent `PL_FREIGHT`):
| id | menu_name | perms |
|----|-----------|-------|
| PL_FREIGHT_Q | 查询 | pl:freight:query |
| PL_FREIGHT_C | 组单 | pl:freight:create |
| PL_FREIGHT_E | 编辑 | pl:freight:edit |
| PL_FREIGHT_S | 提交审批 | pl:freight:submit |
| PL_FREIGHT_A | 审批 | pl:freight:approve |
| PL_FREIGHT_W | 撤回 | pl:freight:withdraw |
| PL_FREIGHT_D | 发放登记 | pl:freight:disburse |
- [ ] **Step 4:** 在目标库执行脚本并验证表存在
Run: `mysql ... -e "SHOW TABLES LIKE 'pl_freight_settlement_approval';"`
Expected: 1 row
---
### Task 2: ORM 模型
**Files:**
- Modify: `backend/app/models/pl_models.py`
- [ ] **Step 1:** 在 `PlRemittanceVoucher` 之前追加:
```python
class PlFreightSettlementApproval(Base):
"""运费结算审批 pl_freight_settlement_approval"""
__tablename__ = "pl_freight_settlement_approval"
id = Column(String(64), primary_key=True)
settlement_id = Column(String(64), nullable=False)
step = Column(Integer, nullable=False, default=1)
step_name = Column(String(50), nullable=True)
approver_id = Column(String(64), nullable=False)
approver_name = Column(String(64), nullable=True)
approval_type = Column(String(20), nullable=False, default="sequential")
approval_result = Column(String(20), nullable=False, default="pending")
approval_opinion = Column(String(500), nullable=True)
approval_time = Column(DateTime, nullable=True)
is_current = Column(SmallInteger, nullable=False, default=0)
# ... 公共字段 tenant_no ~ del_flag 与其他 pl 表一致
```
- [ ] **Step 2:** 验证 import
Run: `cd backend && python3 -c "from app.models.pl_models import PlFreightSettlementApproval; print('ok')"`
Expected: `ok`
---
### Task 3: Pydantic Schema 扩展
**Files:**
- Modify: `backend/app/schemas/pl/freight.py`
- [ ] **Step 1:** 扩展 `FreightSettlementCreate` 支持 `planIds`:
```python
class FreightSettlementCreate(BaseModel):
transport_ids: Optional[list[str]] = Field(default=None, alias="transportIds")
plan_ids: Optional[list[str]] = Field(default=None, alias="planIds")
model_config = {"populate_by_name": True}
@model_validator(mode="after")
def check_ids(self):
if not self.transport_ids and not self.plan_ids:
raise ValueError("transportIds 或 planIds 至少提供一个")
return self
```
- [ ] **Step 2:** 列表项扩展 `FreightSettlementListItem`:
```python
class FreightSettlementListItem(FreightSettlementRead):
plan_count: int = Field(default=0, alias="planCount")
license_plate_summary: Optional[str] = Field(default=None, alias="licensePlateSummary")
current_approver_name: Optional[str] = Field(default=None, alias="currentApproverName")
can_approve: bool = Field(default=False, alias="canApprove")
can_withdraw: bool = Field(default=False, alias="canWithdraw")
approval_finished_time: Optional[datetime] = Field(default=None, alias="approvalFinishedTime")
disburse_time: Optional[datetime] = Field(default=None, alias="disburseTime")
disburse_amount: Optional[Decimal] = Field(default=None, alias="disburseAmount")
```
- [ ] **Step 3:** 审批/发放 body:
```python
class FreightSettlementSubmitApprovalBody(BaseModel):
approval_type: str = Field(default="sequential", alias="approvalType") # sequential|parallel|or
approver_ids: list[str] = Field(..., alias="approverIds", min_length=1)
remark: Optional[str] = None
model_config = {"populate_by_name": True}
class FreightSettlementApprovalActionBody(BaseModel):
action: str = Field(..., description="approve|reject")
comment: Optional[str] = None
class FreightSettlementDisburseBody(BaseModel):
remittance_date: date = Field(..., alias="remittanceDate")
remittance_amount: Decimal = Field(..., alias="remittanceAmount", gt=0)
voucher_urls: list[str] = Field(..., alias="voucherUrls", min_length=1)
remark: Optional[str] = None
model_config = {"populate_by_name": True}
```
- [ ] **Step 4:** `FreightSettlementWithTransports` 增加 `plans`, `approvalFlow`, `vouchers`, `canApprove`
Run: `python3 -c "from app.schemas.pl.freight import FreightSettlementDisburseBody; print('ok')"`
---
### Task 4: Service — 未结算计划 + 组单
**Files:**
- Create: `backend/app/services/pl_freight_settlement_service.py`
- [ ] **Step 1:** 实现 `list_unsettled_plans(db, tenant_no, query, page, page_size)`:
逻辑(spec D5):
```python
def list_unsettled_plans(...):
# pl_plan JOIN pl_transport ON plan.transport_id = transport.id
# WHERE archive_status='archived' AND has_freight=1 AND follow_status!='cancelled'
# AND transport.freight_amount > 0
# AND transport_id NOT IN (
# SELECT st.transport_id FROM pl_freight_settlement_transport st
# JOIN pl_freight_settlement s ON s.id=st.settlement_id
# WHERE s.del_flag=0 AND st.del_flag=0
# ) -- 任何 pending 或非 pending 占用均排除;删草稿后重新可见
```
- [ ] **Step 2:** 实现 `create_settlement_from_plan_ids(db, tenant_no, plan_ids, user)`:
```python
def create_settlement_from_plan_ids(...):
plans = ... # 校验全部 archived + has_freight + transport_id
transport_ids = [p.transport_id for p in plans]
_assert_transports_not_occupied(db, tenant_no, transport_ids)
total = sum(transport.freight_amount)
settlement = PlFreightSettlement(settlement_status="pending", ...)
for t in transports:
db.add(PlFreightSettlementTransport(...))
db.commit()
return settlement
```
- [ ] **Step 3:** 实现 `delete_draft_settlement` — 仅 `pending`,软删 settlement + transport links
- [ ] **Step 4:** 实现 `_assert_transports_not_occupied` — 被任何未删 settlement 占用则 400
---
### Task 5: Service — 审批链(对齐 contract_approval)
**Files:**
- Modify: `backend/app/services/pl_freight_settlement_service.py`
- [ ] **Step 1:** `create_settlement_approval_records(db, settlement_id, approval_type, approver_ids, user)`
参考 `contract_approval.create_approval_records`:
- sequential:step 递增,首个 `is_current=1`
- parallel:同 step 多人,`is_current=1` 全部
- or:同 step 多人,任一通过即可
- [ ] **Step 2:** `can_user_approve_settlement(db, settlement_id, user_id) -> bool`
- [ ] **Step 3:** `submit_settlement_approval(...)` — `pending → approving`,写审批记录
- [ ] **Step 4:** `process_settlement_approval(db, approval_id, action, comment, user)`:
通过:推进下一节点 / 会签计数 / 或签短路 → 全部完成则 `settlement_status='approved'`
驳回:`settlement_status='pending'`,当前链 `approval_result='rejected'`,`is_current=0`
- [ ] **Step 5:** `withdraw_settlement_approval(...)` — 仅提交人、`approving` 态,软删 pending 记录,回 `pending`
- [ ] **Step 6:** `get_settlement_approval_flow(db, settlement_id) -> list[dict]`
---
### Task 6: Service — 财务发放 + 列表 enrich
**Files:**
- Modify: `backend/app/services/pl_freight_settlement_service.py`
- [ ] **Step 1:** `disburse_settlement(db, settlement_id, body, user)`:
```python
def disburse_settlement(...):
settlement = _get_settlement(...)
if settlement.settlement_status != "approved":
raise HTTPException(400, "仅待发放状态可登记")
if body.remittance_amount != settlement.total_freight and not (body.remark or "").strip():
raise HTTPException(400, "汇款金额与运费合计不一致时备注必填")
voucher = PlRemittanceVoucher(
settlement_id=settlement.id,
remittance_date=body.remittance_date,
remittance_amount=body.remittance_amount,
voucher_urls=json.dumps(body.voucher_urls),
remark=body.remark,
create_by=user.id,
...
)
settlement.settlement_status = "confirmed"
settlement.update_by = user.id
db.commit()
```
- [ ] **Step 2:** `list_settlements_enriched(...)` — 按 `settlement_status` 或 `tab` 过滤,附加 planCount、canApprove、currentApproverName
- [ ] **Step 3:** `get_settlement_detail(...)` — transports + 关联 plans + approvalFlow + vouchers
---
### Task 7: 更新运费锁定状态
**Files:**
- Modify: `backend/app/services/pl_plan_service.py`
- [ ] **Step 1:** 替换 `_LOCKED_SETTLEMENT_STATUSES`:
```python
_LOCKED_SETTLEMENT_STATUSES = ("approving", "approved", "confirmed")
```
- [ ] **Step 2:** 组单占用逻辑:任何 `del_flag=0` 的 settlement 关联均视为占用(含 pending),与 Tab1 查询一致
---
### Task 8: API 路由重构
**Files:**
- Modify: `backend/app/api/pl/freight.py`
- [ ] **Step 1:** 新增路由:
| 路由 | 处理函数 |
|------|----------|
| `GET /unsettled-plans` | `list_unsettled_plans` |
| `GET /` | `list_settlements_enriched`,query: `tab=bills|disburse|settled` 或 `settlementStatus` |
| `POST /` | body `planIds` → `create_settlement_from_plan_ids` |
| `DELETE /{id}` | `delete_draft_settlement` |
| `POST /{id}/submit-approval` | `submit_settlement_approval` |
| `POST /approval/{approval_id}` | `process_settlement_approval` |
| `POST /{id}/withdraw-approval` | `withdraw_settlement_approval` |
| `GET /{id}/approval-flow` | `get_settlement_approval_flow` |
| `POST /{id}/disburse` | `disburse_settlement` |
- [ ] **Step 2:** 保留旧 `POST /{id}/submit`、`POST /{id}/approve` 为 deprecated 别名(内部转新逻辑或 410),避免破坏未知调用
- [ ] **Step 3:** `GET /{id}` 返回 enrich 详情
Run: `python3 -c "from app.main import app; print('ok')"`
---
### Task 9: 前端 API 类型
**Files:**
- Modify: `web-admin/src/api/pl/index.ts`
- [ ] **Step 1:** 扩展 `FreightSettlement` 类型字段:`planCount`, `licensePlateSummary`, `currentApproverName`, `canApprove`, `canWithdraw`, `approvalFinishedTime`, `disburseTime`, `disburseAmount`
- [ ] **Step 2:** 新增 `UnsettledPlan` 类型与 `freightApi.unsettledPlans(params)`
- [ ] **Step 3:** 更新 freightApi 方法:
```typescript
export const freightApi = {
unsettledPlans: (params) => request.get('/transport/freight/unsettled-plans', { params }),
list: (params: { tab?: 'bills' | 'disburse' | 'settled'; ... }) => ...,
create: (data: { planIds: string[] }) => request.post('/transport/freight/', data),
remove: (id: string) => request.delete(`/transport/freight/${id}`),
submitApproval: (id, data) => request.post(`/transport/freight/${id}/submit-approval`, data),
processApproval: (approvalId, data) => request.post(`/transport/freight/approval/${approvalId}`, data),
withdrawApproval: (id) => request.post(`/transport/freight/${id}/withdraw-approval`),
approvalFlow: (id) => request.get(`/transport/freight/${id}/approval-flow`),
disburse: (id, data) => request.post(`/transport/freight/${id}/disburse`, data),
// get, update 保留
}
```
---
### Task 10: Tab 容器 `freight/index.vue`
**Files:**
- Modify: `web-admin/src/views/pl/freight/index.vue`
- [ ] **Step 1:** 重构为 P08 结构:
```vue
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top"><h2 class="title-bar-heading">运费结算</h2></div>
<el-tabs v-model="activeTab" class="freight-tabs" @tab-change="handleTabChange">
<el-tab-pane label="未结算计划" name="unsettled" />
<el-tab-pane label="结算单" name="bills" />
<el-tab-pane label="待财务发放" name="disburse" />
<el-tab-pane label="已结算" name="settled" />
</el-tabs>
<UnsettledPlanPanel v-if="activeTab === 'unsettled'" @created="onSettlementCreated" />
<SettlementBillPanel v-else-if="activeTab === 'bills'" ref="billsRef" />
<DisbursePanel v-else-if="activeTab === 'disburse'" />
<SettledPanel v-else-if="activeTab === 'settled'" />
</section>
</div>
</template>
```
- [ ] **Step 2:** `onSettlementCreated` 切换 `activeTab='bills'` 并 refresh
- [ ] **Step 3:** 删除原单列表逻辑(迁移到 Panel)
---
### Task 11: Tab1 `UnsettledPlanPanel.vue`
**Files:**
- Create: `web-admin/src/views/pl/freight/components/UnsettledPlanPanel.vue`
- [ ] **Step 1:** 筛选:计划编号、日期范围、车牌、单据类型(参考 `plan/index.vue` subset)
- [ ] **Step 2:** 表格 + selection + 工具栏「生成结算单」`type="primary"` + 已选 N 项
- [ ] **Step 3:** `handleCreateSettlement` → `freightApi.create({ planIds })` → emit `created`
- [ ] **Step 4:** 行操作「查看」→ `PlPlanViewDialog` 或现有 plan 查看组件
---
### Task 12: Tab2 `SettlementBillPanel.vue` + 草稿/查看弹窗
**Files:**
- Create: `web-admin/src/views/pl/freight/components/SettlementBillPanel.vue`
- Create: `web-admin/src/components/business/pl-freight-settlement-form-dialog/index.vue`
- Create: `web-admin/src/components/business/pl-freight-settlement-view-dialog/index.vue`
- [ ] **Step 1:** 列表 `freightApi.list({ tab: 'bills' })`,列按 spec §3.2
- [ ] **Step 2:** 行操作:
- `pending`:查看、编辑、提交审批、删除
- `approving`:查看、撤回(`canWithdraw`)、审批(`canApprove`)
- [ ] **Step 3:** 编辑弹窗 — 发票字段 + 只读明细表 + footer 取消/保存
- [ ] **Step 4:** 查看弹窗 — Hero + 结算信息 + 关联计划/运输表 + 审批时间线(无凭证)
- [ ] **Step 5:** 注册 `pl_settlement_status` 到 dictStore,Tag 渲染
---
### Task 13: 审批弹窗 `PlFreightApprovalDialog`
**Files:**
- Create: `web-admin/src/components/business/pl-freight-approval-dialog/index.vue`
- [ ] **Step 1:** Fork `crm/contract/components/ApprovalDialog.vue` 结构与样式
- [ ] **Step 2:** `actionType`: `submit` | `approve` | `reject`
- [ ] **Step 3:** submit → `freightApi.submitApproval(id, { approvalType, approverIds, remark })`
- [ ] **Step 4:** approve/reject → 先 `GET approval-flow` 取当前用户 pending 记录 id → `freightApi.processApproval(approvalId, { action, comment })`
- [ ] **Step 5:** SettlementBillPanel 打开弹窗;**禁止**顶栏批量审批
---
### Task 14: Tab3 `DisbursePanel` + 发放弹窗
**Files:**
- Create: `web-admin/src/views/pl/freight/components/DisbursePanel.vue`
- Create: `web-admin/src/components/business/pl-freight-disburse-dialog/index.vue`
- [ ] **Step 1:** 列表 `tab: 'disburse'`,列:结算单号、运费合计、审批完成时间、提交人、车牌摘要
- [ ] **Step 2:** 行操作:查看、发放登记(`v-hasPermi` 或 menuCode 校验 `pl:freight:disburse`)
- [ ] **Step 3:** 发放弹窗:
- 只读区:结算单号、合计、明细摘要、审批流
- 表单:汇款日期、汇款金额、附件卡片上传(`fetchUploadAttachment`)、备注
- 金额 ≠ 合计时前端校验备注必填
- [ ] **Step 4:** 提交 → `freightApi.disburse` → 刷新 Tab3;可选提示切换 Tab4
---
### Task 15: Tab4 `SettledPanel.vue`
**Files:**
- Create: `web-admin/src/views/pl/freight/components/SettledPanel.vue`
- [ ] **Step 1:** 列表 `tab: 'settled'`,增加汇款日期/金额/确认人/时间列
- [ ] **Step 2:** 仅「查看」— 复用 view-dialog,展示 voucher 附件预览/下载
---
### Task 16: 菜单权限 SQL(独立脚本)
**Files:**
- Create: `docs/sql/20260625_pl_freight_menu_permissions.sql`
- [ ] **Step 1:** 与 Task 1 Step 3 按钮权限一致,`ON DUPLICATE KEY UPDATE`
- [ ] **Step 2:** 可选:为已有 `PL_FREIGHT` 角色自动授权新按钮(仿 plan-archive 脚本)
---
### Task 17: 验证与图谱
- [ ] **Step 1:** 后端 smoke
Run: `cd backend && python3 -c "from app.main import app; print('backend ok')"`
- [ ] **Step 2:** 前端 lint(改动文件)
Run: `cd web-admin && pnpm exec eslint src/views/pl/freight src/components/business/pl-freight-* --max-warnings 0`
- [ ] **Step 3:** 更新图谱
Run: `./scripts/update-graph.sh all`
- [ ] **Step 4:** 手工验收 spec V1–V13
---
## Spec 覆盖自检
| Spec 章节 | Task |
|-----------|------|
| 四 Tab D1 | Task 10–15 |
| 审批 D2 | Task 5, 8, 13 |
| 财务 Tab D3 | Task 14 |
| 计划展示/运输落库 D4 | Task 4, 11 |
| 未结算准入 D5 | Task 4, 11 |
| 状态机 §6 | Task 1, 5, 6, 7 |
| 权限 §1.3 | Task 1, 16 |
| 验收 V1–V13 | Task 17 |
---
## 执行顺序建议
```
Task 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 (后端闭环)
Task 9 → 10 → 11 → 12 → 13 → 14 → 15 (前端)
Task 16 → 17 (权限 + 验收)
```
Phase 可分批合并 PR:P1=Task1-8+9-11,P2=12-13,P3=14-17。
@@ -0,0 +1,658 @@
# 运输计划归档 — Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** 新增「运输计划归档」菜单与归档/调整弹窗,支持填写 actualQty、调整运费并归档;已归档计划仍可编辑与调整;原运输计划页移除归档入口。
**Architecture:** 后端在 `archive_plan` 单事务内编排产品数量同步 → 运费更新(含结算阻断)→ 首次归档改状态 / 已归档仅调数据;前端新建 `plan-archive` 列表 + `PlPlanArchiveDialog`(布局对齐 `PlPlanArrangeDialog`),列表逻辑抽取 `usePlPlanList` 与运输计划共用。
**Tech Stack:** FastAPI + SQLAlchemy + Pydantic v2;Vue 3 + Element Plus + `usePlFreightCalc`
**Spec:** `docs/superpowers/specs/2026-06-25-pl-plan-archive-design.md`
---
## 文件结构
| 文件 | 职责 |
|------|------|
| `backend/app/schemas/pl/plan.py` | `PlanArchiveBody` 等请求 Schema |
| `backend/app/services/pl_plan_service.py` | `apply_archive_product_quantities`、`apply_archive_freight`、`transport_has_locked_freight_settlement`、`record_plan_change` |
| `backend/app/api/pl/plan.py` | 增强 `archive_plan`;`update_plan` 允许已归档编辑 |
| `web-admin/src/api/pl/index.ts` | `PlanArchiveBody` 类型 + `planApi.archive(id, body?)` |
| `web-admin/src/composables/usePlPlanList.ts` | 列表查询/分页/筛选共享逻辑 |
| `web-admin/src/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue` | 新增 `editableActualQtyOnly` |
| `web-admin/src/components/business/pl-plan-archive-dialog/index.vue` | 归档/调整弹窗 |
| `web-admin/src/views/pl/plan-archive/index.vue` | 归档列表页 |
| `web-admin/src/router/modules/pl.ts` | 路由 |
| `docs/sql/shanxia2.0.sql` | 菜单 + 按钮权限 |
| `web-admin/src/utils/router/menu-icon.ts` | 菜单图标 |
| `web-admin/src/views/pl/plan/index.vue` | 删除批量归档 |
| `web-admin/src/views/pl/plan/detail.vue` | 删除归档按钮 |
---
### Task 1: 归档请求 Schema
**Files:**
- Modify: `backend/app/schemas/pl/plan.py`
- Modify: `backend/app/schemas/pl/__init__.py`(若需 export)
- [ ] **Step 1:** 在 `plan.py` 末尾、`PlanListResponse` 之前追加:
```python
class PlanArchiveProductItem(BaseModel):
id: str = Field(..., description="计划产品明细ID pl_plan_product.id")
actual_qty: Decimal = Field(..., alias="actualQty", ge=0, description="实际数量")
model_config = {"populate_by_name": True}
class PlanArchiveFreightBlock(BaseModel):
distance_km: Optional[Decimal] = Field(default=None, alias="distanceKm")
freight_type: str = Field(default="by_weight", alias="freightType")
freight_price: Optional[Decimal] = Field(default=None, alias="freightPrice")
freight_amount: Optional[Decimal] = Field(default=None, alias="freightAmount")
transport_qty: Optional[Decimal] = Field(default=None, alias="transportQty")
has_invoice: Optional[int] = Field(default=None, alias="hasInvoice")
model_config = {"populate_by_name": True}
class PlanArchiveBody(BaseModel):
products: list[PlanArchiveProductItem] = Field(..., min_length=1)
freight: Optional[PlanArchiveFreightBlock] = None
model_config = {"populate_by_name": True}
```
- [ ] **Step 2:** 验证 import 无循环
Run: `cd backend && source venv/bin/activate && python -c "from app.schemas.pl.plan import PlanArchiveBody; print('ok')"`
Expected: `ok`
---
### Task 2: 归档业务 Service
**Files:**
- Modify: `backend/app/services/pl_plan_service.py`
- [ ] **Step 1:** 新增 import:
```python
from app.models.pl_models import PlFreightSettlement, PlFreightSettlementTransport, PlPlanChange, PlTransport
from app.schemas.pl.plan import PlanArchiveFreightBlock, PlanArchiveProductItem
```
- [ ] **Step 2:** 追加 `transport_has_locked_freight_settlement`:
```python
_LOCKED_SETTLEMENT_STATUSES = ("submitted", "approved", "confirmed")
def transport_has_locked_freight_settlement(
db: Session, tenant_no: str, transport_id: Optional[str]
) -> bool:
if not transport_id:
return False
return (
db.query(PlFreightSettlementTransport.id)
.join(
PlFreightSettlement,
PlFreightSettlement.id == PlFreightSettlementTransport.settlement_id,
)
.filter(
PlFreightSettlementTransport.transport_id == transport_id,
PlFreightSettlementTransport.tenant_no == tenant_no,
PlFreightSettlementTransport.del_flag == 0,
PlFreightSettlement.tenant_no == tenant_no,
PlFreightSettlement.del_flag == 0,
PlFreightSettlement.settlement_status.in_(_LOCKED_SETTLEMENT_STATUSES),
)
.first()
is not None
)
```
- [ ] **Step 3:** 追加 `apply_archive_product_quantities`:
```python
def apply_archive_product_quantities(
db: Session,
*,
tenant_no: str,
plan: PlPlan,
items: list[PlanArchiveProductItem],
user_id: str,
) -> None:
product_map = {
row.id: row
for row in db.query(PlPlanProduct).filter(
PlPlanProduct.plan_id == plan.id,
PlPlanProduct.tenant_no == tenant_no,
PlPlanProduct.del_flag == 0,
).all()
}
for item in items:
prod = product_map.get(item.id)
if not prod:
raise HTTPException(status_code=400, detail=f"产品明细不存在: {item.id}")
actual = Decimal(str(item.actual_qty))
prod.actual_qty = actual
price_in = prod.inbound_price or prod.tax_price
price_out = prod.outbound_price or prod.tax_price
if plan.plan_type == "inbound":
prod.inbound_qty = actual
if price_in is not None:
prod.inbound_amount = actual * Decimal(str(price_in))
elif plan.plan_type == "outbound":
prod.outbound_qty = actual
if price_out is not None:
prod.outbound_amount = actual * Decimal(str(price_out))
prod.update_by = user_id
```
- [ ] **Step 4:** 追加 `apply_archive_freight`:
```python
def apply_archive_freight(
db: Session,
*,
tenant_no: str,
plan: PlPlan,
freight: PlanArchiveFreightBlock,
user_id: str,
) -> None:
if int(plan.has_freight or 0) != 1:
return
if not plan.transport_id:
raise HTTPException(status_code=400, detail="计划有运输费用但未安排运输,请先安排运输")
if transport_has_locked_freight_settlement(db, tenant_no, plan.transport_id):
raise HTTPException(status_code=400, detail="运输单已纳入运费结算,无法修改运费")
transport = (
db.query(PlTransport)
.filter(
PlTransport.id == plan.transport_id,
PlTransport.tenant_no == tenant_no,
PlTransport.del_flag == 0,
)
.first()
)
if not transport:
raise HTTPException(status_code=400, detail="关联运输单不存在")
transport.distance_km = freight.distance_km
transport.freight_type = freight.freight_type or "by_weight"
transport.freight_price = freight.freight_price
amount = freight.freight_amount or Decimal("0")
transport.freight_amount = amount
if freight.transport_qty is not None:
transport.transport_qty = freight.transport_qty
if freight.has_invoice is not None:
transport.has_invoice = freight.has_invoice
transport.update_by = user_id
plan.freight_amount = amount
plan.update_by = user_id
```
- [ ] **Step 5:** 追加 `record_plan_change`:
```python
def record_plan_change(
db: Session,
*,
tenant_no: str,
plan_id: str,
change_type: str,
change_content: str,
user_id: str,
user_name: Optional[str],
dept_id: str,
) -> None:
db.add(
PlPlanChange(
id=generate_uuid(),
tenant_no=tenant_no,
plan_id=plan_id,
change_type=change_type,
change_content=change_content,
change_user_id=user_id,
change_user_name=user_name,
create_by=user_id,
create_dept_id=dept_id,
)
)
```
- [ ] **Step 6:** 验证 import
Run: `cd backend && python -c "from app.services.pl_plan_service import apply_archive_product_quantities; print('ok')"`
Expected: `ok`
---
### Task 3: 增强 `archive_plan` + 放宽 `update_plan`
**Files:**
- Modify: `backend/app/api/pl/plan.py`
- [ ] **Step 1:** 扩展 import(在文件顶部 `from fastapi import ...` 增加 `Body`):
```python
from app.schemas.pl.plan import PlanArchiveBody, PlanWithProducts
from app.services.pl_plan_service import (
apply_archive_freight,
apply_archive_product_quantities,
record_plan_change,
)
```
- [ ] **Step 2:** 在 `update_plan` 中**删除**以下阻断(约 L589–591):
```python
if plan.archive_status == "archived":
raise HTTPException(status_code=400, detail="已归档的计划不能修改")
```
- [ ] **Step 3:** 替换 `archive_plan` 为:
```python
@router.post("/{id}/archive", response_model=PlanWithProducts)
def archive_plan(
id: str,
payload: Optional[PlanArchiveBody] = Body(default=None),
db: Session = Depends(get_db),
user: DbUserContext = Depends(get_db_current_user),
) -> PlanWithProducts:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
plan = _get_plan(db, tenant_no, id)
if plan.follow_status == "cancelled":
raise HTTPException(status_code=400, detail="已作废的计划不能归档")
already_archived = plan.archive_status == "archived"
# 无 body:向后兼容,仅首次改状态
if payload is None:
if already_archived:
raise HTTPException(status_code=400, detail="计划已归档,请提交归档表单以调整内容")
plan.archive_status = "archived"
plan.complete_status = "yes"
plan.follow_status = "completed"
plan.update_by = user.id
db.commit()
return get_plan(id, db, user)
apply_archive_product_quantities(
db, tenant_no=tenant_no, plan=plan, items=payload.products, user_id=user.id
)
if payload.freight is not None:
apply_archive_freight(
db, tenant_no=tenant_no, plan=plan, freight=payload.freight, user_id=user.id
)
elif int(plan.has_freight or 0) == 1 and not already_archived:
if not plan.transport_id:
raise HTTPException(status_code=400, detail="计划有运输费用但未安排运输,请先安排运输")
if not already_archived:
plan.archive_status = "archived"
plan.complete_status = "yes"
plan.follow_status = "completed"
plan.update_by = user.id
record_plan_change(
db,
tenant_no=tenant_no,
plan_id=plan.id,
change_type="archive_adjust" if already_archived else "archive",
change_content="调整归档内容" if already_archived else "运输计划归档",
user_id=user.id,
user_name=user.real_name or user.username,
dept_id=user.dept_id,
)
db.commit()
return get_plan(id, db, user)
```
- [ ] **Step 4:** 确认 `get_plan` 在同文件已存在且返回 `PlanWithProducts`(复用现有 GET 逻辑)
- [ ] **Step 5:** 验证路由加载
Run: `cd backend && python -c "from app.api.pl.plan import archive_plan; print('ok')"`
Expected: `ok`
---
### Task 4: 前端 API 类型
**Files:**
- Modify: `web-admin/src/api/pl/index.ts`
- [ ] **Step 1:** 追加类型:
```typescript
export interface PlanArchiveProductItem {
id: string
actualQty: number
}
export interface PlanArchiveFreightBlock {
distanceKm?: number
freightType?: string
freightPrice?: number
freightAmount?: number
transportQty?: number
hasInvoice?: number
}
export interface PlanArchiveBody {
products: PlanArchiveProductItem[]
freight?: PlanArchiveFreightBlock
}
```
- [ ] **Step 2:** 扩展 `PlanQuery`(若尚未有):
```typescript
archiveStatus?: string
```
- [ ] **Step 3:** 修改 `planApi.archive`:
```typescript
archive: (id: string, data?: PlanArchiveBody) =>
request.post<Plan>(`/transport/plan/${id}/archive`, data),
```
---
### Task 5: 产品表 `editableActualQtyOnly`
**Files:**
- Modify: `web-admin/src/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue`
- [ ] **Step 1:** props 增加:
```typescript
/** 仅实际数量可编辑,计划数量只读(归档弹窗) */
editableActualQtyOnly?: boolean
```
- [ ] **Step 2:** 计划数量列 template 改为:
```vue
<el-input-number
v-if="editableQty && !editableActualQtyOnly"
v-model="row.quantity"
...
/>
```
- [ ] **Step 3:** 实际数量列 template 改为:
```vue
<el-input-number
v-if="(editableQty && showActualQty) || editableActualQtyOnly"
v-model="row.actualQty"
...
/>
```
---
### Task 6: `PlPlanArchiveDialog`
**Files:**
- Create: `web-admin/src/components/business/pl-plan-archive-dialog/index.vue`
- Reference: `web-admin/src/components/business/pl-plan-arrange-dialog/index.vue`(布局 SCSS 类 `pl-arrange-layout` 等可复用)
- [ ] **Step 1:** 创建弹窗骨架(props: `visible`, `planId`;emit: `update:visible`, `success`)
- [ ] **Step 2:** 上区表单:
- `PlPlanFormProductTable`:`show-actual-qty` + `editable-actual-qty-only`
- 运费区块:从 arrange-dialog 复制 L189–236 结构,绑定 `formData` + `freightCalc`
- `usePlFreightCalc({ products: productRows, hasFreight, freightType })`
- [ ] **Step 3:** 下区:`PlPlanViewTabs ref="tabsRef" :plan-id="planId" embedded`
- [ ] **Step 4:** 计算属性:
```typescript
const isAdjustMode = computed(() => plan.value.archiveStatus === 'archived')
const dialogTitle = computed(() => {
const no = plan.value.planNo || ''
return isAdjustMode.value
? no ? `调整归档内容 · ${no}` : '调整归档内容'
: no ? `运输计划归档 · ${no}` : '运输计划归档'
})
const submitLabel = computed(() => (isAdjustMode.value ? '确认保存' : '确认归档'))
```
- [ ] **Step 5:** `handleOpened`:加载 `planApi.get(planId)`,映射 products → `productRows`,从 plan/transport 预填运费字段
- [ ] **Step 6:** `handleSubmit`:
```typescript
const body: PlanArchiveBody = {
products: productRows.value.map(row => ({
id: row.productId, // 注意:用 pl_plan_product.id,不是 CRM productId
actualQty: Number(row.actualQty ?? 0)
})),
freight: formData.hasFreight === 1 ? {
distanceKm: formData.distanceKm ?? undefined,
freightType: formData.freightType,
freightPrice: freightCalc.freightPrice.value ?? undefined,
freightAmount: freightCalc.freightAmount.value ?? undefined,
transportQty: freightCalc.transportQty.value ?? undefined,
hasInvoice: formData.hasInvoice
} : undefined
}
await planApi.archive(props.planId, body)
ElMessage.success(isAdjustMode.value ? '保存成功' : '归档成功')
tabsRef.value?.reload?.()
emit('success')
innerVisible.value = false
```
> **注意:** `productRows` 映射时必须保留 `pl_plan_product.id`(从 API `PlanProduct.id`),勿与 `productId` 混淆。
- [ ] **Step 7:** 样式:复用 arrange-dialog 的 `pl-arrange-layout` / `pl-arrange-form-panel` / `pl-arrange-view-panel`(可在 scoped 中 `@use` 或复制最小 SCSS)
---
### Task 7: `usePlPlanList` composable
**Files:**
- Create: `web-admin/src/composables/usePlPlanList.ts`
- Modify: `web-admin/src/views/pl/plan/index.vue`(可选,YAGNI:若时间紧可只在 plan-archive 复制,后续再抽)
- [ ] **Step 1:** 抽取共享状态与方法:
```typescript
export function usePlPlanList(options?: { extraSearchFields?: () => Record<string, unknown> }) {
const loading = ref(false)
const planList = ref<Plan[]>([])
const selectedRows = ref<Plan[]>([])
const dateRange = ref<string[]>([])
const filterExpanded = ref(false)
const searchForm = reactive({
planNo: '',
planType: '',
followStatus: '',
transportStatus: '',
customerName: '',
archiveStatus: '' // 归档页使用
})
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
async function fetchData() { /* planApi.list 参数组装 */ }
function handleSearch() { pagination.page = 1; fetchData() }
function handleReset() { /* 清空 + fetchData */ }
// ... handleSelectionChange, handlePageChange, handleSizeChange
return { loading, planList, selectedRows, dateRange, filterExpanded, searchForm, pagination, fetchData, handleSearch, handleReset, ... }
}
```
- [ ] **Step 2:** (可选)`plan/index.vue` 改用 composable,确保行为不变
---
### Task 8: 归档列表页
**Files:**
- Create: `web-admin/src/views/pl/plan-archive/index.vue`
- [ ] **Step 1:** 复制 `plan/index.vue` 筛选区 + 表格列,标题改为 `运输计划归档`
- [ ] **Step 2:** 展开区增加「归档状态」:
```vue
<el-form-item label="归档状态">
<el-select v-model="searchForm.archiveStatus" placeholder="全部" clearable>
<el-option label="未归档" value="unarchived" />
<el-option label="已归档" value="archived" />
</el-select>
</el-form-item>
```
- [ ] **Step 3:** 工具栏:保留「已选 N 项」;**不放置「批量归档」**(归档必须经弹窗填写 actualQty/运费,无法无表单批量)
- [ ] **Step 4:** 操作列(`min-width="260"`):
```vue
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button
v-if="row.followStatus !== 'cancelled'"
link type="primary"
@click="handleEdit(row)"
>
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button
v-if="row.followStatus !== 'cancelled'"
link type="success"
@click="handleArchive(row)"
>
<el-icon><FolderChecked /></el-icon>{{ row.archiveStatus === 'archived' ? '调整' : '归档' }}
</el-button>
```
- [ ] **Step 5:** 挂载 `PlPlanViewDialog`、`PlPlanFormDialog`、`PlPlanArchiveDialog`
- [ ] **Step 6:** `handleBatchArchive`:**不实现**(见 Step 3)
- [ ] **Step 7:** `onMounted` → `fetchData()`
---
### Task 9: 路由、菜单、标题竖条
**Files:**
- Modify: `web-admin/src/router/modules/pl.ts`
- Modify: `docs/sql/shanxia2.0.sql`
- Modify: `web-admin/src/utils/router/menu-icon.ts`
- Modify: `web-admin/src/App.vue`(若存在 `panelTitleBarTextRules`)或确认 `app.scss` 对 `运输计划归档` 标题生效
- [ ] **Step 1:** `pl.ts` 在 `PlPlan` 后插入:
```typescript
{
id: 'PL00000000000000000000000000016',
name: 'PlPlanArchive',
path: 'plan-archive',
component: '/pl/plan-archive/index',
meta: { title: '运输计划归档', keepAlive: true, menuCode: 'pl:plan-archive:list' }
}
```
- [ ] **Step 2:** `shanxia2.0.sql` 追加菜单与按钮(`order_num=12`,危化品证上传改为 13):
```sql
INSERT INTO `sys_menu` (...) VALUES
('PL_PLAN_ARCHIVE', '运输计划归档', 'PL_MENU_ROOT', 'C', 'plan-archive', 'pl/plan-archive/index', 'pl:plan-archive:list', 1, '1', '1', 'shanxia2.0', 12, NULL, 'system', '', NOW(), NULL, NOW(), 0);
INSERT INTO `sys_menu` (...) VALUES
('PL_PLAN_ARCHIVE_Q', '查询', 'PL_PLAN_ARCHIVE', 'F', '', '', 'pl:plan-archive:query', 1, '1', '1', 'shanxia2.0', 1, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_PLAN_ARCHIVE_E', '编辑', 'PL_PLAN_ARCHIVE', 'F', '', '', 'pl:plan-archive:edit', 1, '1', '1', 'shanxia2.0', 2, NULL, 'system', '', NOW(), NULL, NOW(), 0),
('PL_PLAN_ARCHIVE_A', '归档', 'PL_PLAN_ARCHIVE', 'F', '', '', 'pl:plan-archive:archive', 1, '1', '1', 'shanxia2.0', 3, NULL, 'system', '', NOW(), NULL, NOW(), 0);
```
- [ ] **Step 3:** `menu-icon.ts`:
```typescript
'pl:plan-archive:list': 'ri:folder-check-line',
```
- [ ] **Step 4:** 页面 `h2.title-bar-heading` 文案为 **运输计划归档**(与规范竖条一致)
---
### Task 10: 原运输计划页移除归档
**Files:**
- Modify: `web-admin/src/views/pl/plan/index.vue`
- Modify: `web-admin/src/views/pl/plan/detail.vue`
- [ ] **Step 1:** `plan/index.vue` 删除工具栏「批量归档」按钮、`handleBatchArchive`、`FolderChecked` import(无其他引用时)
- [ ] **Step 2:** `plan/detail.vue` 删除「归档」按钮、`handleArchive` 函数、`FolderChecked` import(无其他引用时)
---
### Task 11: 联调验收
- [ ] **V1** 打开 `/#/pl/plan-archive` — 列表与筛选正常,含归档状态筛选项
- [ ] **V2** 未归档行 — 查看 / 编辑 / 归档可用
- [ ] **V3** 已归档行 — 查看 / 编辑 / 调整可用
- [ ] **V5** 首次归档 — actualQty、运费、状态变为 archived/completed
- [ ] **V6** 已归档调整 — 仅数据更新,状态保持 archived
- [ ] **V6a** 已归档编辑 — `PlPlanFormDialog` 保存成功
- [ ] **V7** `/#/pl/plan` 无批量归档;详情无归档按钮
- [ ] **V9** 有运费未安排运输 — 归档 400
- [ ] **V10** 按重量 — actualQty 变更联动运输量
- [ ] **V11** 下区司机/现场链接可复制
Run frontend lint(改动文件):
```bash
cd web-admin && pnpm lint
```
Run backend import check:
```bash
cd backend && python -c "from app.main import app; print('ok')"
```
Run graphify update:
```bash
cd /Users/zlwu/work/00code/shanxia2.0 && ./scripts/update-graph.sh all
```
---
## Spec 覆盖自检
| Spec 条目 | Task |
|-----------|------|
| D1 全部计划列表 | Task 8 |
| D2 已归档可调整 | Task 3, 6, 8 |
| D2a 已归档可编辑 | Task 3, 8 |
| D3 原页移除归档 | Task 10 |
| D4 弹窗布局 | Task 6 |
| D5 增强 API | Task 1–3 |
| D6 筛选一致 + 归档状态 | Task 7–8 |
| V1–V12 验收 | Task 11 |
---
## 执行顺序建议
1. Task 1 → 2 → 3(后端可先联调 Swagger)
2. Task 4 → 5 → 6(归档弹窗)
3. Task 7 → 8 → 9(列表 + 路由菜单)
4. Task 10 → 11(清理 + 验收)
@@ -0,0 +1,449 @@
# 运费结算完善 — 设计文档
> **日期**: 2026-06-25
> **状态**: 已确认(2026-06-25)
> **前置**: `docs/运输计划管理-需求说明文档.md`(§10、BR-26~29、BR-40,**BR-27 由本设计 supersede**)、`docs/superpowers/specs/2026-06-25-pl-plan-archive-design.md`
> **界面模式**: P08 页内 Tab + P02 状态驱动列表 + P22 行内审批 + P13 财务确认发放
## 目标
完善【运输管理 → 运费结算】模块:按业务阶段拆分为 **四个 Tab**,支持从未结算计划组单、结算单多级审批(对齐合同管理)、审批完成后财务独立 Tab 登记发放,最终进入已结算归档态。
---
## 已确认决策(2026-06-25)
| # | 决策 | 说明 |
|---|------|------|
| D1 | **四 Tab 独立** | 未结算计划 / 结算单(草稿+审批中)/ 待财务发放 / 已结算 — 四个 Tab 各自独立,不用子筛选合并 |
| D2 | **审批对齐合同管理** | 提交时选审批人 + 顺序/会签/或签;独立审批记录表;**审批按钮仅在「待我审批」时出现在行操作列** |
| D3 | **财务发放独立 Tab** | `approved` 状态的结算单进入 Tab3「待财务发放」;财务在此 Tab 做发放登记(附件+备注),完成后 `confirmed` 进入 Tab4 |
| D4 | **组单以计划展示、运输落库** | Tab1 列表以**运输计划**维度展示(可含多车牌);生成结算单时落库关联 **transport_id**(复用 `pl_freight_settlement_transport`) |
| D5 | **未结算准入:已归档 + 有运费** | Tab1 仅展示 `archive_status=archived` 且 `has_freight=1`、且运输单尚未被非草稿结算单占用的计划 |
| D6 | **Supersede BR-27** | 原「不走工作流、计划专员 C 直接确认」作废;改为合同式多级审批 + 财务发放两阶段 |
---
## 非目标(本期不做)
- 接入通用 Python 工作流引擎(OpenSpec workflow 目标设计尚未落地)
- 结算单驳回后自动拆单/释放部分运输单(驳回整单回到草稿,关联运输单一并释放)
- 邮件/短信通知审批人(仅系统内操作)
- 运费结算报表导出
- 按归属公司隔离数据(延续 BR-51)
---
## 一、页面结构(四 Tab)
### 1.1 路由与菜单
| 项 | 值 |
|----|-----|
| 菜单名 | 运费结算(沿用) |
| Hash | `/#/pl/freight` |
| 组件 | `web-admin/src/views/pl/freight/index.vue`(重构为 Tab 容器 + 子面板) |
| menuCode | `pl:freight:list` |
### 1.2 Tab 定义
```
┌─────────────┬─────────────┬───────────────┬─────────────┐
│ 未结算计划 │ 结算单 │ 待财务发放 │ 已结算 │
│ Tab unsettled│ Tab bills │ Tab disburse │ Tab settled │
└─────────────┴─────────────┴───────────────┴─────────────┘
```
| Tab | `name` | 标题 | 结算状态 filter | 主要角色 |
|-----|--------|------|-----------------|----------|
| 1 | `unsettled` | 未结算计划 | —(查计划,非结算单) | 计划专员 |
| 2 | `bills` | 结算单 | `pending`, `approving` | 计划专员、审批人 |
| 3 | `disburse` | 待财务发放 | `approved` | 财务 |
| 4 | `settled` | 已结算 | `confirmed` | 全员只读 |
Tab 切换不走路由 query;默认激活 Tab1。各 Tab 独立筛选、分页、列表刷新。
### 1.3 权限按钮(新增/调整)
| 权限码 | 用途 |
|--------|------|
| `pl:freight:list` | 菜单 + 四 Tab 列表(已有) |
| `pl:freight:query` | 查看结算单/计划详情 |
| `pl:freight:create` | Tab1 多选组单 |
| `pl:freight:edit` | Tab2 草稿编辑、发票信息 |
| `pl:freight:submit` | Tab2 提交审批 |
| `pl:freight:approve` | Tab2 行内审批(后端校验是否当前节点审批人) |
| `pl:freight:withdraw` | Tab2 撤回审批(提交人) |
| `pl:freight:disburse` | Tab3 财务发放登记 |
| `pl:freight:disburse:list` | Tab3 列表(可选:与 disburse 合并,无 list 则 finance 角色仅见 Tab3 需菜单子权限设计 — **实现时 Tab3/4 仍受 list 控制,按钮用 disburse**) |
---
## 二、Tab1 — 未结算计划
### 2.1 数据范围(D5)
同时满足:
1. `pl_plan.archive_status = 'archived'`
2. `pl_plan.has_freight = 1`
3. `pl_plan.follow_status != 'cancelled'`
4. 计划已关联运输单(`transport_id` 非空)且 `pl_transport.freight_amount > 0`
5. 该 `transport_id` **未**出现在任何 `settlement_status NOT IN ('pending')` 且 `del_flag=0` 的结算单关联中
(若仅在 `pending` 草稿结算单中,视为「占用中」:Tab1 不展示,Tab2 草稿可编辑/删除后释放)
### 2.2 列表列(建议)
| 列 | 来源 |
|----|------|
| 多选 | `type="selection"` |
| 计划编号 | `planNo` |
| 计划日期 | `planDate` |
| 单据类型 | `planType` Tag |
| 客户/供应商 | `customerName` / `supplierName` |
| 车牌号 | `licensePlate` |
| 运输公司 | `transportCompany` |
| 运费(元) | `freightAmount` |
| 归档时间 | `updateTime` 或归档变更记录 |
筛选:计划编号、日期范围、客户、车牌号、单据类型(与运输计划列表 subset 对齐)。
### 2.3 工具栏与操作
| 控件 | 规则 |
|------|------|
| 已选 N 项 | 最前 |
| **生成结算单** | 唯一主色按钮;至少选 1 条;调用 `POST /transport/freight/` |
| 查看 | 行操作,打开计划只读查看(`PlPlanViewDialog` 或跳转 plan detail) |
**组单规则**:
- 一次多选生成 **一张** 结算单
- 后端校验:所有 plan 的 transport 均未锁定;租户一致
- `total_freight = sum(transport.freight_amount)`
- 创建后跳转/激活 **Tab2**,定位到新结算单
---
## 三、Tab2 — 结算单(草稿 + 审批中)
### 3.1 数据范围
`settlement_status IN ('pending', 'approving')`
可选 Tab 内筛选:结算单号、创建时间、提交人、状态(草稿/审批中)。
### 3.2 列表列
| 列 | 说明 |
|----|------|
| 结算单号 | 链接打开查看弹窗 |
| 运费合计 | `totalFreight` |
| 关联计划数 | 聚合 count |
| 车牌摘要 | 多车牌逗号分隔,tooltip 全量 |
| 结算状态 | Tag:`pending` 草稿 / `approving` 审批中 |
| 当前审批人 | `approving` 时展示当前节点审批人姓名 |
| 创建人 / 时间 | |
### 3.3 行操作(操作列 `fixed="right"`,`min-width ≥ 280`)
| 状态 | 查看 | 编辑 | 提交审批 | 撤回 | 审批 |
|------|------|------|----------|------|------|
| `pending` | ✅ | ✅(创建人或有 edit 权限) | ✅ | — | — |
| `approving` | ✅ | ❌ | — | ✅(提交人) | ✅ **仅 `canApprove=true`** |
**约束(D2)**:
- **禁止**在列表顶栏放批量审批
- 「审批」按钮必须带 `<el-icon>`,与规范一致
- `canApprove` 由列表/详情 API 返回(后端 `can_user_approve_settlement`)
### 3.4 草稿编辑弹窗
- 只读:结算单号、合计
- 可编辑:发票号、开票日期、发票金额、备注(`FreightSettlementUpdate` 已有字段)
- 明细区:关联计划/运输表格(只读);**本期不支持**草稿中增删关联行(需删单重建)
- 删除草稿:软删结算单 + 释放 transport 占用(新增 `DELETE /freight/{id}`,仅 `pending`)
### 3.5 提交审批弹窗
复用/抽取合同 `ApprovalDialog` 交互(`web-admin/src/views/crm/contract/components/ApprovalDialog.vue`):
| 字段 | 说明 |
|------|------|
| 审批类型 | 顺序 / 会签 / 或签 |
| 审批人 | 多选远程搜索用户 |
| 提交说明 | 可选 |
提交后:`pending → approving`,创建 `pl_freight_settlement_approval` 记录。
### 3.6 审批弹窗
- 审批意见(必填/选填与合同一致)
- 通过 / 驳回
- 驳回:`approving → pending`,审批记录置 rejected,**释放为可重新编辑草稿**(审批记录保留历史)
### 3.7 查看弹窗
- Hero:结算单号 + 状态 Tag + 运费合计
- Section:发票信息、关联运输/计划明细表
- Section:**审批流时间线**(对齐合同 `ContractDetailDialog` 审批区)
- Section:汇款凭证(`confirmed` 后在 Tab4 查看;Tab2 仅已发放前为空)
---
## 四、Tab3 — 待财务发放
### 4.1 数据范围
`settlement_status = 'approved'`
### 4.2 列表列
| 列 | 说明 |
|----|------|
| 结算单号 | |
| 运费合计 | |
| 审批完成时间 | 最后一节点 `approval_time` |
| 提交人 | |
| 关联计划数 / 车牌摘要 | |
| 状态 | Tag:待发放 |
### 4.3 行操作
| 操作 | 权限 | 说明 |
|------|------|------|
| 查看 | query | 只读详情 + 完整审批流 |
| **发放登记** | disburse | 打开财务确认弹窗 |
**无**审批按钮。
### 4.4 发放登记弹窗(P13 财务确认)
```
┌─────────────────────────────────────────────┐
│ 财务发放登记 · {settlementNo} [×] │
├─────────────────────────────────────────────┤
│ [只读] 结算单号、运费合计、关联明细摘要 │
│ [只读] 审批流时间线(已通过) │
├─────────────────────────────────────────────┤
│ 汇款日期 * │
│ 汇款金额 * │
│ 汇款凭证 * 附件卡片上传(多文件) │
│ 发放备注 textarea │
├─────────────────────────────────────────────┤
│ 取消 │ 确认发放 │
└─────────────────────────────────────────────┘
```
提交逻辑(单事务):
1. 校验 `settlement_status == approved`
2. 写入 `pl_remittance_voucher`(`voucher_urls` JSON 数组、`remittance_date`、`remittance_amount`、`remark`)
3. `settlement_status → confirmed`
4. `update_by` 当前财务用户
---
## 五、Tab4 — 已结算
### 5.1 数据范围
`settlement_status = 'confirmed'`
### 5.2 列表列
在 Tab3 基础上增加:汇款日期、汇款金额、财务确认人、确认时间。
### 5.3 行操作
仅 **查看**(含汇款凭证预览/下载)。
---
## 六、状态机
```
┌──────────┐
组单 │ pending │ 草稿 (Tab2)
───────────────▶│ │
└────┬─────┘
│ submit
▼
┌──────────┐
│approving │ 审批中 (Tab2)
└────┬─────┘
reject │ │ all approved
┌─────┘ └─────┐
▼ ▼
┌──────────┐ ┌──────────┐
│ pending │ │ approved │ 待财务发放 (Tab3)
└──────────┘ └────┬─────┘
│ disburse
▼
┌──────────┐
│confirmed │ 已结算 (Tab4)
└──────────┘
```
### 6.1 字典 `pl_settlement_status`(更新)
| dict_value | dict_label | tag_type | 所在 Tab |
|------------|------------|----------|----------|
| `pending` | 草稿 | info | Tab2 |
| `approving` | 审批中 | warning | Tab2 |
| `approved` | 待发放 | primary | Tab3 |
| `confirmed` | 已结算 | success | Tab4 |
| `rejected` | 已驳回 | danger | 仅审批记录,结算单回到 pending |
移除或废弃旧标签「已提交」「已审核」与 API 中 `submitted` 的直接终态跳转。
### 6.2 运费锁定(与归档模块一致)
以下状态的结算单关联 transport **锁定运费修改**(`transport_has_locked_freight_settlement`):
`approving`, `approved`, `confirmed`
`pending` 草稿不锁定(删单可释放)。
---
## 七、后端设计
### 7.1 新表 `pl_freight_settlement_approval`
| 字段 | 类型 | 说明 |
|------|------|------|
| id | varchar(64) | PK |
| settlement_id | varchar(64) | 结算单 ID |
| step | int | 步骤序号 |
| approver_id | varchar(64) | 审批人 |
| approver_name | varchar(64) | 冗余 |
| approval_type | varchar(20) | sequential / parallel / or |
| approval_result | varchar(20) | pending / approved / rejected |
| approval_opinion | varchar(500) | |
| approval_time | datetime | |
| is_current | tinyint | 当前节点 |
| tenant_no + 公共字段 | | |
索引:`(settlement_id, del_flag)`, `(approver_id, approval_result, is_current)`
### 7.2 Service 层(新建 `pl_freight_settlement_service.py`)
| 函数 | 职责 |
|------|------|
| `list_unsettled_plans` | Tab1 查询 |
| `create_settlement_from_transports` | 组单 + 占用校验 |
| `submit_settlement_approval` | 创建审批链,`pending→approving` |
| `approve_settlement_step` | 单步通过/驳回 + 推进 |
| `withdraw_settlement_approval` | 撤回 |
| `can_user_approve_settlement` | 当前用户是否可审 |
| `disburse_settlement` | 财务发放 + voucher |
| `delete_draft_settlement` | 软删草稿 |
CRUD 参考:`backend/app/crud/crm/contract_approval.py`(勿直接依赖 CRM 表)。
### 7.3 API 清单
| Method | Path | 说明 |
|--------|------|------|
| GET | `/transport/freight/unsettled-plans` | Tab1 分页列表 |
| GET | `/transport/freight/` | Tab2/3/4;增加 `tab` 或 `settlementStatus` 多值 |
| POST | `/transport/freight/` | 组单 `{ planIds }` 或 `{ transportIds }`(**推荐 planIds**,服务端解析 transport) |
| GET | `/transport/freight/{id}` | 详情 + transports + plans 摘要 + `canApprove` |
| PUT | `/transport/freight/{id}` | 更新草稿 |
| DELETE | `/transport/freight/{id}` | 删除草稿 |
| POST | `/transport/freight/{id}/submit-approval` | 提交审批 body 同合同 |
| POST | `/transport/freight/approval/{approvalId}` | 通过/驳回 |
| POST | `/transport/freight/{id}/withdraw-approval` | 撤回 |
| GET | `/transport/freight/{id}/approval-flow` | 审批时间线 |
| POST | `/transport/freight/{id}/disburse` | 财务发放 body: remittanceDate, amount, voucherUrls, remark |
**废弃/替换**:
- `POST /{id}/submit` → 由 `submit-approval` 替代
- `POST /{id}/approve` → 由 `approval/{id}` 替代
- `POST /voucher` → 合并进 `disburse` 或内部调用
列表项返回 `canApprove: boolean`(当前用户 + 当前 settlement)。
### 7.4 审批规则(对齐合同)
| 类型 | 规则 |
|------|------|
| sequential | 按选择顺序,仅 `is_current=1` 且 pending 的一人可审 |
| parallel | 所有 pending 节点需全部通过 |
| or | 任一人通过即通过 |
全部通过后:`settlement_status → approved`,进入 Tab3。
---
## 八、前端文件规划
| 文件 | 动作 |
|------|------|
| `views/pl/freight/index.vue` | 重构为 Tab 容器 |
| `views/pl/freight/components/UnsettledPlanPanel.vue` | Tab1 |
| `views/pl/freight/components/SettlementBillPanel.vue` | Tab2 |
| `views/pl/freight/components/DisbursePanel.vue` | Tab3 |
| `views/pl/freight/components/SettledPanel.vue` | Tab4 |
| `components/business/pl-freight-settlement-view-dialog/index.vue` | 查看弹窗 |
| `components/business/pl-freight-settlement-form-dialog/index.vue` | 草稿编辑 |
| `components/business/pl-freight-approval-dialog/index.vue` | 提交/审批(可 fork 合同 ApprovalDialog) |
| `components/business/pl-freight-disburse-dialog/index.vue` | 财务发放 |
| `api/pl/index.ts` | 扩展 freightApi |
---
## 九、与现有模块衔接
| 模块 | 衔接点 |
|------|--------|
| 运输计划归档 | Tab1 要求已归档;归档弹窗改运费仍受结算锁定约束 |
| 合同管理 | 审批 UX、API 语义对齐 |
| 运输计划列表 | 不新增结算入口,结算统一在 freight 模块 |
| 需求文档 | 实现后更新 §10.1、BR-27、BR-40、附录 C |
---
## 十、验收清单
| # | 场景 | 预期 |
|---|------|------|
| V1 | 四 Tab 切换 | 各自列表/筛选/分页独立正常 |
| V2 | Tab1 仅已归档有运费且未占用计划 | 不符合不出现 |
| V3 | 多选组单 | 生成一张草稿,出现在 Tab2,Tab1 对应行消失 |
| V4 | Tab2 草稿编辑发票 | 保存成功 |
| V5 | 提交审批 | 进入 approving,审批流生成 |
| V6 | 非当前审批人 | Tab2 **无**审批按钮 |
| V7 | 当前审批人 | 行操作列出现审批,通过后流转 |
| V8 | 全部审批通过 | 结算单出现在 Tab3,Tab2 消失 |
| V9 | Tab3 发放登记 | 上传凭证+备注,进入 Tab4 |
| V10 | Tab4 查看 | 只读,含凭证与审批流 |
| V11 | 审批中锁定 | 归档页不可改关联 plan 运费 |
| V12 | 驳回 | 回 Tab2 草稿,可再提交 |
| V13 | 权限 | 无 `disburse` 不见 Tab3 发放按钮 |
---
## 十一、实施阶段建议
| Phase | 范围 |
|-------|------|
| **P1** | 四 Tab 骨架 + Tab1 未结算 + 组单 + Tab4 只读列表 |
| **P2** | Tab2 草稿 CRUD + 查看弹窗 |
| **P3** | 审批表 + 提交/审批/撤回 + `canApprove` 行按钮 |
| **P4** | Tab3 财务发放 + voucher + 状态 confirmed |
| **P5** | 菜单权限 SQL、字典更新、归档锁定联调、文档修订 |
---
## 十二、Open Questions(实现前默认可按本文)
| # | 问题 | 默认 |
|---|------|------|
| Q1 | Tab1 是否必须已归档 | **是**(D5) |
| Q2 | 草稿能否删单 | **是**,仅 pending |
| Q3 | 驳回后审批历史 | **保留**记录,结算单回 pending |
| Q4 | 发放金额是否必须等于运费合计 | **允许差异**,备注必填当不等 |
@@ -0,0 +1,318 @@
# 运输计划归档 — 设计文档
> **日期**: 2026-06-25
> **状态**: 待审阅
> **前置**: `docs/运输计划管理-需求说明文档.md`、`docs/superpowers/specs/2026-06-21-pl-arrange-transport-refine-design.md`、`openspec/changes/transport-plan-management/specs/transport-plan/spec.md`
> **界面模式**: P06 复杂业务列表 + 弹窗表单;归档弹窗上区编辑、下区只读对照(对齐 `PlPlanArrangeDialog`)
## 目标
在【运输管理】下新增菜单【运输计划归档】,提供与【运输计划】相同结构的列表与检索;操作列仅 **查看 / 编辑 / 归档**。归档通过专用弹窗一次性完成:**填写产品实际数量 → 调整运费 → 执行归档**。原【运输计划】页移除全部归档入口,归档职责集中到本菜单。
---
## 已确认决策(2026-06-25)
| # | 决策 | 说明 |
|---|------|------|
| D1 | **列表展示全部计划** | 默认不过滤 `archiveStatus`;已归档计划仍保留在列表中作为历史可查 |
| D2 | **已归档也可调整** | 已归档行仍显示「查看 / 编辑 / 调整」;「归档」按钮在已归档时文案改为「调整」,打开同一弹窗修改 actualQty 与运费 |
| D2a | **归档页编辑不受归档态限制** | 本菜单内 `PlPlanFormDialog` 对已归档计划可打开;后端 `update_plan` 移除「已归档不可修改」阻断(运输计划页仍通过 UI 隐藏已归档行的编辑入口) |
| D3 | **原页移除归档入口** | `views/pl/plan/index.vue` 去掉「批量归档」;`views/pl/plan/detail.vue` 去掉「归档」按钮;归档只在新区操作 |
| D4 | **弹窗布局对齐安排运输** | 上区:归档表单;下区:完整 `PlPlanViewTabs`(计划概况 / 运输信息含司机·现场链接 / 合同信息) |
| D5 | **归档 API 增强** | 单次请求原子完成:写 `actual_qty` + 同步入库/出库数与金额 + 更新运费 + 改归档/完成状态 |
| D6 | **列表/筛选与运输计划一致** | 列、筛选字段、分页行为与 `/#/pl/plan` 相同;可额外增加「归档状态」筛选项(展开区) |
---
## 非目标(本期不做)
- 跟进状态 12 态完整流转(仍用现有 `draft/processing/completed/cancelled` 简化枚举;归档时将 `follow_status` 置为 `completed`)
- 归档后允许反归档 / 撤销
- 运费结算单已生成后的运费修订流程(见约束:有关联结算且非草稿则阻断改运费)
- OpenSpec 独立 change 归档(可在实现后补 `openspec/changes/` 条目)
---
## 一、页面与路由
### 1.1 新菜单
| 项 | 值 |
|----|-----|
| 菜单名 | 运输计划归档 |
| 路由 path | `plan-archive` |
| Hash | `/#/pl/plan-archive` |
| 组件 | `web-admin/src/views/pl/plan-archive/index.vue` |
| 列表标题 | `运输计划归档`(写入 `App.vue` → `panelTitleBarTextRules`) |
| menuCode | `pl:plan-archive:list` |
| 排序 | 紧接「运输计划」之后,`order_num=10.5` 或 `11`(危化品证上传顺延) |
### 1.2 权限按钮
| 权限码 | 用途 |
|--------|------|
| `pl:plan-archive:list` | 菜单 + 列表 |
| `pl:plan-archive:query` | 查看弹窗 |
| `pl:plan-archive:edit` | 编辑弹窗(含已归档) |
| `pl:plan-archive:archive` | 打开归档/调整弹窗 + 提交(含已归档调整) |
编辑可复用现有 `PlPlanFormDialog` + `pl:plan:edit` 或映射到 `pl:plan-archive:edit`(实现时二选一,推荐归档页独立权限,后端 update 仍走 `/transport/plan/{id}`)。
### 1.3 列表行为(D1 / D2)
- **数据范围**:调用同一 `planApi.list`,默认不传 `archiveStatus`(全部)。
- **筛选**:与运输计划相同 6 项;**展开区增加「归档状态」**(未归档 / 已归档 / 全部)。
- **表格列**:与 `views/pl/plan/index.vue` 一致(计划编号、日期、类型、客户、产品、证书、跟进/运输状态、金额、车牌、司机、跟进人等)。
- **操作列** `min-width` 约 260(3 个 link 按钮),`fixed="right"`。
| 条件 | 查看 | 编辑 | 归档 / 调整 |
|------|------|------|-------------|
| `followStatus !== 'cancelled'` | ✅ | ✅ | ✅(未归档文案「归档」,已归档文案「调整」) |
| `followStatus === 'cancelled'` | ✅ | ❌ | ❌ |
### 1.4 工具栏
| 按钮 | 规则 |
|------|------|
| 已选 N 项 | 保留 |
| 批量归档 | 保留;仅对选中行中未归档且未作废的执行;已归档跳过并汇总提示 |
| 新增 / 删除 / 证书 / 安排 | **不出现** |
### 1.5 原运输计划页改动(D3)
| 文件 | 改动 |
|------|------|
| `views/pl/plan/index.vue` | 删除「批量归档」按钮及 `handleBatchArchive`;删除 `FolderChecked` 导入(若无他用) |
| `views/pl/plan/detail.vue` | 删除「归档」按钮及 `handleArchive` |
---
## 二、归档弹窗(`PlPlanArchiveDialog`)
### 2.1 布局
```
┌──────────────────────────────────────────────────────────────┐
│ 运输计划归档 · {planNo} [×] │
├──────────────────────────────────────────────────────────────┤
│ ▲ 上区:归档操作(max-height ~42vh,可滚动) │
│ [产品实际数量] PlPlanFormProductTable │
│ showActualQty + editableQty(仅 actualQty) │
│ [运费信息] 复用安排运输区块(只读 hasFreight 来自计划)│
│ [归档说明] 可选 remark(写入 plan.remark 或仅展示) │
├──────────────────────────────────────────────────────────────┤
│ ▼ 下区:计划单查看(flex:1,min-height 280px) │
│ PlPlanViewTabs embedded — 三 Tab 与查看/安排弹窗一致 │
└──────────────────────────────────────────────────────────────┘
│ 取消 │ 确认归档 / 确认保存 │
```
**模式切换**:
| 模式 | 标题后缀 | 主按钮 | 提交语义 |
|------|----------|--------|----------|
| 首次归档 | `运输计划归档 · {planNo}` | 确认归档 | 写数量/运费 + 置 `archived` |
| 已归档调整 | `调整归档内容 · {planNo}` | 确认保存 | 仅写数量/运费,**不改变** `archive_status` / `complete_status` |
**尺寸与规范**:`dialog-form-layout`、`align-center`、`width: min(1680px, calc(100vw - 80px))`、`modal-class: order-module-dialog-mask`、`backdrop-filter: none`、表单 `label-position="top"`;底栏 Close / Check 图标间距 6px。
### 2.2 上区 — 产品实际数量
- 使用 `PlPlanFormProductTable`:`show-actual-qty`、`editable-qty`;**计划数量列只读**(不传 editable 到 quantity 或单独 prop `editableActualQtyOnly`)。
- 初始值:`actualQty ?? quantity ?? inboundEstimateQty ?? outboundEstimateQty ?? 0`(与 `usePlPlanViewDetail` 一致)。
- 校验:每行 `actualQty >= 0` 必填;至少一行有有效数量。
- 提交后后端按 `plan_type` 同步:
- `inbound`:`inbound_qty = actual_qty`,`inbound_amount = inbound_qty × inbound_price`(价缺省用 `tax_price`)
- `outbound`:`outbound_qty = actual_qty`,`outbound_amount = outbound_qty × outbound_price`
- `direct`:仅写 `actual_qty`,重算 `tax_subtotal` 若业务需要(按 quantity 单价比例,或保持计划金额不变 — **本期以 actual_qty 落库为主,金额字段按 inbound/outbound 规则**)
### 2.3 上区 — 运费信息
复用 `PlPlanArrangeDialog` 运费区块 + `usePlFreightCalc`:
| 字段 | 规则 |
|------|------|
| `hasFreight` | 来自计划,只读 |
| `distanceKm` | 可编辑;预填 transport / plan |
| `freightType` | `by_weight` / `by_trip` |
| 运输量 | `by_weight` 时默认 **actualQty 汇总**(`sumProductActualQuantities`) |
| `freightPrice` / `freightAmount` | 可编辑;联动计算可手动覆盖 |
| `hasInvoice` | 可编辑 |
`hasFreight=0` 时显示「本计划无运输费用」,跳过运费写入。
### 2.4 下区 — 只读对照
- 完整嵌入 `PlPlanViewTabs`(`embedded`),含:
- 计划概况(含产品 actualQty 展示列)
- 运输信息(车辆、物流、运费、**司机链接复制**、**现场链接复制**、回传、地磅)
- 合同信息
- 提交成功后 `tabsRef.reload()` 刷新下区。
### 2.5 入口与禁用
- `followStatus !== 'cancelled'` 均可打开(**含已归档**)。
- 打开时 `planApi.get` + 若已安排则读 transport 运费预填;已归档时进入「调整」模式。
---
## 三、后端 API
### 3.1 增强归档接口
**方案**:扩展 `POST /transport/plan/{id}/archive`,请求体可选;无 body 时保持向后兼容(仅改状态,供脚本/旧调用),**前端归档弹窗必须带 body**。
**Request `PlanArchiveBody`**:
```json
{
"products": [
{ "id": "计划产品明细ID", "actualQty": 4.7 }
],
"freight": {
"distanceKm": 120.5,
"freightType": "by_weight",
"freightPrice": 50,
"freightAmount": 235,
"hasInvoice": 1
}
}
```
**处理顺序(单事务)**:
1. 校验:计划存在、租户、`follow_status != cancelled`
2. 校验:每个 `products[].id` 属于该计划
3. 更新 `pl_plan_product.actual_qty`;按 `plan_type` 写 `inbound_qty/outbound_qty` 及金额
4. 若 `plan.has_freight == 1` 且 body.freight 存在:
- 若存在 `plan.transport_id` → 更新 `pl_transport` 运费字段 + `transport_qty`
- 更新 `plan.freight_amount`
- **若运输单已纳入非草稿运费结算** → 400 阻断(查 `pl_freight_settlement` 关联)
5. **状态分支**:
- 若 `archive_status != archived`:置 `archive_status=archived`、`complete_status=yes`、`follow_status=completed`
- 若 **已归档**:跳过状态字段,仅更新业务数据(D2)
6. 写 `pl_plan_change`:`change_type=archive`(首次)或 `archive_adjust`(已归档调整)
7. commit
**`update_plan`(编辑弹窗)**:移除 `archive_status == archived` 时的 400 阻断;已归档计划允许通过 PUT 修改计划主表/产品(与归档弹窗互补:表单改计划信息,归档弹窗改 actualQty/运费)。
**Response**:`PlanWithProducts`(与 get 一致)
### 3.2 Schema 新增
文件:`backend/app/schemas/pl/plan.py`
- `PlanArchiveProductItem`:`id`, `actualQty`
- `PlanArchiveFreightBlock`:与 transport arrange 运费字段子集一致
- `PlanArchiveBody`:`products`, `freight?`
### 3.3 Service 抽取
在 `pl_plan_service.py` 新增:
- `apply_archive_product_quantities(plan, products_payload)` — 写 actual + inbound/outbound
- `apply_archive_freight(plan, transport, freight_payload, products)` — 运费同步
便于单测与 `archive_plan` 路由保持薄。
---
## 四、前端文件清单
| 文件 | 动作 |
|------|------|
| `views/pl/plan-archive/index.vue` | **新建** — 列表页 |
| `components/business/pl-plan-archive-dialog/index.vue` | **新建** — 归档弹窗 |
| `composables/usePlPlanList.ts` | **新建(推荐)** — 从 plan/index 抽取 list/search/pagination |
| `views/pl/plan/index.vue` | 删除批量归档;可选改用 composable |
| `views/pl/plan/detail.vue` | 删除归档按钮 |
| `router/modules/pl.ts` | 新增 plan-archive 路由 |
| `api/pl/index.ts` | `planApi.archive(id, body)` 扩展 |
| `utils/router/menu-icon.ts` | `pl:plan-archive:list` 图标 |
| `App.vue` | `panelTitleBarTextRules` 增加「运输计划归档」 |
| `docs/sql/shanxia2.0.sql` | `sys_menu` 插入归档菜单 + 按钮权限 |
| `backend/app/api/pl/plan.py` | 增强 `archive_plan`;`update_plan` 允许已归档编辑 |
| `backend/app/schemas/pl/plan.py` | Archive body schema |
| `backend/app/services/pl_plan_service.py` | archive 业务函数 |
### 4.1 组件复用策略
| 组件 | 用途 |
|------|------|
| `PlPlanViewDialog` | 查看 |
| `PlPlanFormDialog` | 编辑 |
| `PlPlanViewTabs` | 归档弹窗下区 |
| `PlPlanFormProductTable` | 归档弹窗 actualQty(可增 prop `actualQtyEditableOnly`) |
| `usePlFreightCalc` | 归档弹窗运费 |
---
## 五、数据库与菜单 SQL
```sql
-- 菜单(示例 ID,实现时按现有 PL_* 规范)
INSERT INTO sys_menu (...) VALUES
('PL_PLAN_ARCHIVE', '运输计划归档', 'PL_MENU_ROOT', 'C', 'plan-archive', 'pl/plan-archive/index', 'pl:plan-archive:list', ...);
-- 按钮权限(F 类型,parent=PL_PLAN_ARCHIVE)
-- pl:plan-archive:query | edit | archive
```
---
## 六、安全与约束
| 项 | 规则 |
|----|------|
| 已归档 | 可继续「编辑」与「调整」actualQty/运费;不可反归档(`archive_status` 不回退为 `unarchived`) |
| 已作废 | 不可归档 / 不可调整 |
| 运费结算 | 运输单若已在「已提交/审核通过/已确认」结算单中,禁止归档时改运费 |
| 无 transport | `has_freight=1` 但无 `transport_id` 时,仅更新 `plan.freight_amount`,并 warn 日志(或 400 要求先安排运输 — **推荐 400:有运费必须先安排运输**) |
| 租户 | 所有读写 `tenant_no` |
| 事务 | 产品 + 运费 + 归档同一 commit |
---
## 七、验收标准
| # | 场景 | 预期 |
|---|------|------|
| V1 | 打开归档列表 | 展示全部计划;筛选与运输计划一致;多「归档状态」筛选项 |
| V2 | 未归档行 | 查看 / 编辑 / 归档 均可用 |
| V3 | 已归档行 | 查看 / 编辑 / 「调整」均可用 |
| V4 | 打开归档/调整弹窗 | 上区 actualQty、运费可编辑;下区三 Tab 完整 |
| V5 | 首次提交归档 | actual_qty、运费、archive/complete 状态一次成功 |
| V6 | 已归档后再次「调整」 | 仅更新 actual_qty/运费/金额;`archive_status` 保持 `archived` |
| V6a | 已归档「编辑」 | `PlPlanFormDialog` 可保存计划主表/产品变更 |
| V7 | 原运输计划页 | 无批量归档、详情无归档按钮 |
| V8 | 批量归档 | 仅处理未归档行;已归档跳过有提示 |
| V9 | 有运费未安排运输 | 归档 400,提示先安排运输 |
| V10 | 按重量运费 | 运输量默认 actualQty 合计,改 actualQty 后运费量联动 |
| V11 | 下区链接 | 司机/现场链接可复制(与安排运输下区一致) |
| V12 | 权限 | 无 `pl:plan-archive:archive` 不显示归档按钮 |
---
## 八、实施分期
| Phase | 内容 |
|-------|------|
| **P1** | 后端:`PlanArchiveBody` + service + 增强 `archive_plan` |
| **P2** | 前端:`PlPlanArchiveDialog` + `plan-archive/index.vue` + 路由/菜单/API |
| **P3** | 原页移除归档入口;抽取 `usePlPlanList`(可选) |
| **P4** | 联调验收 V1–V12 |
---
## 九、参考路径
| 说明 | 路径 |
|------|------|
| 运输计划列表 | `web-admin/src/views/pl/plan/index.vue` |
| 安排运输弹窗(布局基准) | `web-admin/src/components/business/pl-plan-arrange-dialog/index.vue` |
| 下区三 Tab | `web-admin/src/components/business/pl-plan-view-tabs/index.vue` |
| 产品表 | `web-admin/src/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue` |
| 运费计算 | `web-admin/src/composables/usePlFreightCalc.ts` |
| 现归档 API | `backend/app/api/pl/plan.py` → `archive_plan` |
| 需求 BR-15/32/42 | `docs/运输计划管理-需求说明文档.md` |
+92 -32
View File
@@ -280,7 +280,7 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/crm/contract.py": {
"mtime": 1782227658.1235394,
"mtime": 1782339857.019929,
"ast_hash": "6553f54ca1fd19086c170095f402a628",
"semantic_hash": ""
},
@@ -395,7 +395,7 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/crud/crm/contract_product.py": {
"mtime": 1782227658.122161,
"mtime": 1782339857.019929,
"ast_hash": "d2e1538af2d36ecc9daf28a3b135bd0f",
"semantic_hash": ""
},
@@ -475,7 +475,7 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/crud/crm/clue_statistics.py": {
"mtime": 1782227658.1214137,
"mtime": 1782339857.0200894,
"ast_hash": "9a026c628764467e4d1398900105dc78",
"semantic_hash": ""
},
@@ -495,7 +495,7 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/crud/crm/contract.py": {
"mtime": 1782227658.122736,
"mtime": 1782339857.0200615,
"ast_hash": "3cd90455687d8cc24d4b664d1fd5eaa2",
"semantic_hash": ""
},
@@ -5835,13 +5835,13 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/models/pl_models.py": {
"mtime": 1782225150.0775347,
"ast_hash": "46edb12165a858dcb062b5d061df5c1f",
"mtime": 1782340128.6408458,
"ast_hash": "a5ef5bf93ca8f6ab90f2c9881345053c",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/plan.py": {
"mtime": 1781959945.4725616,
"ast_hash": "861435bc45b7459a3c43bd857e96e5f1",
"mtime": 1782345903.7304206,
"ast_hash": "6bdf42cdfce8369bf5f732fb32a2f549",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/transport.py": {
@@ -5855,8 +5855,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/freight.py": {
"mtime": 1781838563.015057,
"ast_hash": "a7e7f923d3d97dd63d7654a4740b9f7d",
"mtime": 1782340227.1574829,
"ast_hash": "acf18445f3c459e27da8b4e01d824768",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/schemas/pl/inventory.py": {
@@ -5865,8 +5865,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/plan.py": {
"mtime": 1782227856.5602984,
"ast_hash": "3aa9f34619098d44e0a9a30242245ce7",
"mtime": 1782345916.4050782,
"ast_hash": "53dc8f79c6bd58e8bc714c18a33119a0",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/transport.py": {
@@ -5880,8 +5880,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/freight.py": {
"mtime": 1781838521.5632806,
"ast_hash": "fd3cf984b3569b059c122dfc62ed6ec7",
"mtime": 1782340178.9086406,
"ast_hash": "de6684befc2dfdeca413541a867d9471",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/api/pl/base_data.py": {
@@ -5895,8 +5895,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/api/pl/index.ts": {
"mtime": 1782225501.3368037,
"ast_hash": "a48f024527c73ad4a420c7cddef369d2",
"mtime": 1782340226.0761817,
"ast_hash": "0d4962deb0aae53c3946d0b5a75ce220",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/transport/index.vue": {
@@ -5915,13 +5915,13 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/plan/index.vue": {
"mtime": 1782051687.7538297,
"ast_hash": "2bef84796dd05ba3ae9a81a87df9e459",
"mtime": 1782339078.745338,
"ast_hash": "76cdde0b7042ebde534d401329f9654e",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/freight/index.vue": {
"mtime": 1781838802.3867817,
"ast_hash": "0cccff711d61f157481609de656c08e0",
"mtime": 1782340284.1234188,
"ast_hash": "608aa7be11e0183f607ce8ae897d3aea",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/carrier/index.vue": {
@@ -5930,8 +5930,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/router/modules/pl.ts": {
"mtime": 1781962903.5958958,
"ast_hash": "dfdb40561ed1724185a0294208f16f8d",
"mtime": 1782339067.698384,
"ast_hash": "47be42a748130aa9aecf32aba703fdbb",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/plan/arrange.vue": {
@@ -5940,8 +5940,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/plan/detail.vue": {
"mtime": 1782051696.388785,
"ast_hash": "12ab45c186e3544057f877a5628d45ec",
"mtime": 1782339088.6469374,
"ast_hash": "39f11be29d8d65f90e9d39dedeaa102d",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/plan/form.vue": {
@@ -6035,8 +6035,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_plan_service.py": {
"mtime": 1782172613.9907932,
"ast_hash": "224c79bd8caf5fc315dedd2b2a49bf89",
"mtime": 1782345906.077653,
"ast_hash": "57ae5fe3b8e6cea65addb4c0af2381e0",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/composables/usePlFreightCalc.ts": {
@@ -6045,13 +6045,13 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/composables/usePlContractToPlan.ts": {
"mtime": 1782171645.6735218,
"ast_hash": "fdfc0e9f05256f17727d9fe55c486ae3",
"mtime": 1782227856.001049,
"ast_hash": "d32843b31c7bc0d66a435a7e9690a469",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue": {
"mtime": 1782046239.2915168,
"ast_hash": "8321224653dba2e3a5f0e2e075387b7d",
"mtime": 1782339041.4692602,
"ast_hash": "dbedc7ad400a54dc280c3e17a2e92ab2",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/contract-selector/index.vue": {
@@ -6170,8 +6170,8 @@
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/utils/router/menu-icon.ts": {
"mtime": 1782011194.2261364,
"ast_hash": "8b789e6751acc9f9c09d9cbf2fb4188a",
"mtime": 1782339070.0598602,
"ast_hash": "fdded879fac7f0927c5b5caadc8c6d7d",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/utils/view-field-layout.ts": {
@@ -6288,5 +6288,65 @@
"mtime": 1782225248.1758678,
"ast_hash": "06e0148020b0aff404bb75017d63a6f4",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/pl-plan-archive-dialog/index.vue": {
"mtime": 1782339054.2780187,
"ast_hash": "dc71dcb430871cc9aff346f65165eee6",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/plan-archive/index.vue": {
"mtime": 1782339066.851674,
"ast_hash": "47f3a4afc16af7306ed616806902c01e",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/pl-freight-settlement-form-dialog/index.vue": {
"mtime": 1782340240.241134,
"ast_hash": "ea0576d4e64369be53e55d9a11d8436c",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/pl-freight-disburse-dialog/index.vue": {
"mtime": 1782340243.4274037,
"ast_hash": "1122485350b3b644fc5059b0fca923ad",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/pl-freight-approval-dialog/index.vue": {
"mtime": 1782340236.3395534,
"ast_hash": "80304f7846a9491d3ec8a90112fe729a",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/components/business/pl-freight-settlement-view-dialog/index.vue": {
"mtime": 1782340253.624033,
"ast_hash": "f4308bc64e94548819c68a2c1a79a6b4",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/freight/freight-status.ts": {
"mtime": 1782340228.4163783,
"ast_hash": "60ebbec6131257b65e9364977909f514",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/freight/components/UnsettledPlanPanel.vue": {
"mtime": 1782340259.3238244,
"ast_hash": "6ef88b04547278cfe74a5ab131aaca4f",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/freight/components/DisbursePanel.vue": {
"mtime": 1782340283.4019988,
"ast_hash": "fbceb29a77132b67b31f9791a402916f",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/freight/components/SettledPanel.vue": {
"mtime": 1782340277.7217212,
"ast_hash": "f0b1fba4acdb6da9d5d03503333ae8da",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/web-admin/src/views/pl/freight/components/SettlementBillPanel.vue": {
"mtime": 1782340269.2034261,
"ast_hash": "3d08385a4797deeccae370908dbbf55f",
"semantic_hash": ""
},
"/Users/zlwu/work/00code/shanxia2.0/backend/app/services/pl_freight_settlement_service.py": {
"mtime": 1782340192.5334978,
"ast_hash": "7bf54366daed4088e6cad01f64b8a9bb",
"semantic_hash": ""
}
}
+6 -7
View File
@@ -433,11 +433,9 @@
"431": "Community 431",
"432": "Community 432",
"433": "Community 433",
"434": "Community 434",
"435": "Community 435",
"436": "Community 436",
"437": "Community 437",
"438": "Community 438",
"439": "Community 439",
"440": "Community 440",
"441": "Community 441",
@@ -610,7 +608,6 @@
"608": "Community 608",
"609": "Community 609",
"610": "Community 610",
"611": "Community 611",
"612": "Community 612",
"613": "Community 613",
"614": "Community 614",
@@ -628,7 +625,6 @@
"626": "Community 626",
"627": "Community 627",
"628": "Community 628",
"629": "Community 629",
"630": "Community 630",
"631": "Community 631",
"633": "Community 633",
@@ -654,8 +650,8 @@
"653": "Community 653",
"654": "Community 654",
"655": "Community 655",
"656": "Community 656",
"657": "Community 657",
"659": "Community 659",
"660": "Community 660",
"661": "Community 661",
"662": "Community 662",
@@ -663,12 +659,14 @@
"665": "Community 665",
"666": "Community 666",
"667": "Community 667",
"668": "Community 668",
"669": "Community 669",
"670": "Community 670",
"671": "Community 671",
"672": "Community 672",
"673": "Community 673",
"674": "Community 674",
"675": "Community 675",
"676": "Community 676",
"677": "Community 677",
"678": "Community 678",
@@ -679,13 +677,14 @@
"684": "Community 684",
"685": "Community 685",
"686": "Community 686",
"687": "Community 687",
"688": "Community 688",
"690": "Community 690",
"691": "Community 691",
"692": "Community 692",
"693": "Community 693",
"694": "Community 694",
"695": "Community 695",
"697": "Community 697",
"698": "Community 698",
"700": "Community 700",
"704": "Community 704"
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+130 -3
View File
@@ -385,6 +385,26 @@ export interface PlanCreateFullPayload {
export type PlanUpdatePayload = Partial<Omit<PlanCreateFullPayload, 'contractId'>>
export interface PlanArchiveProductItem {
id: string
actualQty: number
}
export interface PlanArchiveFreightBlock {
hasFreight: number
distanceKm?: number
freightType?: string
freightPrice?: number
freightAmount?: number
transportQty?: number
hasInvoice?: number
}
export interface PlanArchiveBody {
products: PlanArchiveProductItem[]
freight?: PlanArchiveFreightBlock
}
export const planApi = {
list: (params?: PlanQuery) => request.get<PlanListResponse>('/transport/plan/', { params }),
get: (id: string) => request.get<Plan>(`/transport/plan/${id}`),
@@ -401,7 +421,8 @@ export const planApi = {
) => request.patch<Plan>(`/transport/plan/${id}/product-certs`, { products }),
cancel: (id: string) => request.post<Plan>(`/transport/plan/${id}/cancel`),
getArrangeInfo: (id: string) => request.get<PlanArrangeInfo>(`/transport/plan/${id}/arrange-info`),
archive: (id: string) => request.post<Plan>(`/transport/plan/${id}/archive`),
archive: (id: string, data?: PlanArchiveBody) =>
request.post<Plan>(`/transport/plan/${id}/archive`, data),
delete: (id: string) => request.delete(`/transport/plan/${id}`),
createFromContract: (data: { contractId: string; planDate: string; followUserId?: string; followUserName?: string }) =>
request.post<Plan>('/transport/plan/create-from-contract', data)
@@ -539,6 +560,63 @@ export const transportApi = {
// 运费结算 API
// =============================================================================
export interface UnsettledPlanItem {
id: string
planNo: string
planDate: string
planType: string
customerName?: string
supplierName?: string
licensePlate?: string
transportCompany?: string
freightAmount: number
archiveTime?: string
}
export interface UnsettledPlanQuery {
q?: string
planType?: string
licensePlate?: string
page?: number
pageSize?: number
}
export interface UnsettledPlanListResponse {
total: number
list: UnsettledPlanItem[]
}
export interface SettlementPlanSummary {
id: string
planNo: string
planDate?: string
licensePlate?: string
freightAmount?: number
}
export interface SettlementApprovalFlowItem {
id: string
step: number
stepName?: string
approverId: string
approverName?: string
approvalType?: string
approvalResult: string
approvalOpinion?: string
approvalTime?: string
isCurrent: number
}
export interface RemittanceVoucher {
id: string
settlementId: string
remittanceDate?: string
remittanceAmount?: number
voucherUrls?: string
remark?: string
createTime?: string
}
export interface FreightSettlement {
id: string
settlementNo: string
@@ -548,13 +626,29 @@ export interface FreightSettlement {
invoiceDate?: string
settlementStatus: string
remark?: string
createBy?: string
createTime: string
updateTime?: string
planCount?: number
licensePlateSummary?: string
currentApproverName?: string
canApprove?: boolean
canWithdraw?: boolean
currentApprovalId?: string
approvalFinishedTime?: string
disburseTime?: string
disburseAmount?: number
submitterName?: string
transports?: Transport[]
plans?: SettlementPlanSummary[]
approvalFlow?: SettlementApprovalFlowItem[]
vouchers?: RemittanceVoucher[]
}
export interface FreightSettlementQuery {
q?: string
settlementStatus?: string
tab?: 'bills' | 'disburse' | 'settled'
page?: number
pageSize?: number
}
@@ -564,15 +658,48 @@ export interface FreightSettlementListResponse {
list: FreightSettlement[]
}
export interface FreightSettlementSubmitBody {
approvalType: 'sequential' | 'parallel' | 'or'
approverIds: string[]
remark?: string
}
export interface FreightSettlementApprovalBody {
action: 'approve' | 'reject'
comment?: string
}
export interface FreightSettlementDisburseBody {
remittanceDate: string
remittanceAmount: number
voucherUrls: string[]
remark?: string
}
export const freightApi = {
listUnsettledPlans: (params?: UnsettledPlanQuery) =>
request.get<UnsettledPlanListResponse>('/transport/freight/unsettled-plans', { params }),
list: (params?: FreightSettlementQuery) =>
request.get<FreightSettlementListResponse>('/transport/freight/', { params }),
get: (id: string) => request.get<FreightSettlement>(`/transport/freight/${id}`),
create: (transportIds: string[]) =>
request.post<FreightSettlement>('/transport/freight/', { transportIds }),
create: (data: { planIds?: string[]; transportIds?: string[] }) =>
request.post<FreightSettlement>('/transport/freight/', data),
update: (id: string, data: Partial<FreightSettlement>) =>
request.put<FreightSettlement>(`/transport/freight/${id}`, data),
delete: (id: string) => request.delete(`/transport/freight/${id}`),
submitApproval: (id: string, data: FreightSettlementSubmitBody) =>
request.post<FreightSettlement>(`/transport/freight/${id}/submit-approval`, data),
processApproval: (approvalId: string, data: FreightSettlementApprovalBody) =>
request.post<FreightSettlement>(`/transport/freight/approval/${approvalId}`, data),
withdrawApproval: (id: string) =>
request.post<FreightSettlement>(`/transport/freight/${id}/withdraw-approval`),
getApprovalFlow: (id: string) =>
request.get<SettlementApprovalFlowItem[]>(`/transport/freight/${id}/approval-flow`),
disburse: (id: string, data: FreightSettlementDisburseBody) =>
request.post<FreightSettlement>(`/transport/freight/${id}/disburse`, data),
/** @deprecated 请使用 submitApproval */
submit: (id: string) => request.post<FreightSettlement>(`/transport/freight/${id}/submit`),
/** @deprecated 请使用 processApproval */
approve: (id: string) => request.post<FreightSettlement>(`/transport/freight/${id}/approve`)
}
@@ -0,0 +1,310 @@
<template>
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="640px"
align-center
append-to-body
destroy-on-close
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
>
<el-form
ref="formRef"
:model="form"
:rules="rules"
label-position="top"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item v-if="actionType === 'submit'" label="审批类型" class="form-col-span-2">
<el-radio-group v-model="form.approvalType">
<el-radio value="sequential">顺序审批</el-radio>
<el-radio value="parallel">会签审批</el-radio>
<el-radio value="or">或签审批</el-radio>
</el-radio-group>
<div class="form-label-tip form-tip-block">
顺序审批:按顺序依次审批;会签:所有人都需审批;或签:任一人审批即可
</div>
</el-form-item>
<el-form-item v-if="actionType === 'submit'" prop="approverIds" class="form-col-span-2">
<template #label>
选择审批人<span class="form-label-tip">支持搜索用户姓名</span>
</template>
<el-select
v-model="form.approverIds"
multiple
filterable
remote
reserve-keyword
placeholder="请选择审批人"
:remote-method="handleSearchUser"
:loading="userLoading"
style="width: 100%"
>
<el-option
v-for="user in approverList"
:key="user.userId"
:label="`${user.nickName}(${user.userName})`"
:value="String(user.userId)"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="actionType === 'approve' || actionType === 'reject'"
label="审批意见"
prop="comment"
class="form-col-span-2"
>
<el-input
v-model="form.comment"
type="textarea"
:rows="5"
placeholder="请输入审批意见"
maxlength="500"
show-word-limit
/>
</el-form-item>
<el-form-item v-if="actionType === 'submit'" prop="remark" class="form-col-span-2">
<template #label>
提交说明<span class="form-label-tip">可选</span>
</template>
<el-input
v-model="form.remark"
type="textarea"
:rows="5"
placeholder="请输入提交说明"
maxlength="500"
show-word-limit
/>
</el-form-item>
</div>
</el-form>
<section v-if="actionType === 'submit' && form.approverIds.length > 0" class="approval-dialog-section">
<h3 class="approval-section-title">审批流程预览</h3>
<div class="approval-flow">
<el-steps :active="0" align-center>
<el-step
v-for="(approverId, index) in form.approverIds"
:key="index"
:title="getApproverName(approverId)"
/>
</el-steps>
</div>
</section>
<template #footer>
<div class="approval-dialog-actions">
<el-button @click="handleClose">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button type="primary" :loading="submitLoading" @click="handleConfirm">
<el-icon><Check /></el-icon>{{ confirmButtonText }}
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close } from '@element-plus/icons-vue'
import { freightApi } from '@/api/pl'
import { fetchUserOptions } from '@/api/admin'
interface ApproverUser {
userId: string
nickName: string
userName: string
}
const emit = defineEmits<{ success: [] }>()
const dialogVisible = ref(false)
const actionType = ref<'submit' | 'approve' | 'reject'>('submit')
const settlementId = ref('')
const approvalId = ref('')
const form = ref({
approvalType: 'sequential' as 'sequential' | 'parallel' | 'or',
approverIds: [] as string[],
comment: '',
remark: ''
})
const approverList = ref<ApproverUser[]>([])
const submitLoading = ref(false)
const userLoading = ref(false)
const formRef = ref<ElFormInstance>()
const rules = computed(() => {
const baseRules: Record<string, unknown[]> = {}
if (actionType.value === 'submit') {
baseRules.approverIds = [{ required: true, message: '请选择审批人', trigger: 'change' }]
}
if (actionType.value === 'approve' || actionType.value === 'reject') {
baseRules.comment = [{ required: true, message: '请输入审批意见', trigger: 'blur' }]
}
return baseRules
})
const dialogTitle = computed(() => {
const titleMap = {
submit: '提交审批',
approve: '审批通过',
reject: '审批驳回'
}
return titleMap[actionType.value]
})
const confirmButtonText = computed(() => {
const textMap = {
submit: '提交',
approve: '通过',
reject: '驳回'
}
return textMap[actionType.value]
})
function openSubmit(id: string) {
settlementId.value = id
approvalId.value = ''
actionType.value = 'submit'
dialogVisible.value = true
resetForm()
loadApproverList()
}
function openApprove(id: string, currentApprovalId: string) {
settlementId.value = id
approvalId.value = currentApprovalId
actionType.value = 'approve'
dialogVisible.value = true
resetForm()
}
function openReject(id: string, currentApprovalId: string) {
settlementId.value = id
approvalId.value = currentApprovalId
actionType.value = 'reject'
dialogVisible.value = true
resetForm()
}
async function loadApproverList(nickName?: string) {
userLoading.value = true
try {
const res = await fetchUserOptions()
const options = (res as { data?: unknown })?.data ?? res ?? []
let list = (Array.isArray(options) ? options : []).map((item: Record<string, unknown>) => ({
userId: String(item.value ?? item.userId ?? item.id ?? ''),
nickName: String(item.label ?? item.nickName ?? item.userName ?? ''),
userName: String(item.userNo ?? item.userName ?? '')
}))
if (nickName) {
const q = nickName.toLowerCase()
list = list.filter(
(u) => u.nickName.toLowerCase().includes(q) || u.userName.toLowerCase().includes(q)
)
}
approverList.value = list
} catch {
ElMessage.error('获取审批人列表失败')
approverList.value = []
} finally {
userLoading.value = false
}
}
function handleSearchUser(query: string) {
loadApproverList(query || undefined)
}
function getApproverName(approverId: string): string {
const approver = approverList.value.find((item) => item.userId === approverId)
return approver ? approver.nickName : ''
}
async function handleConfirm() {
await formRef.value?.validate()
submitLoading.value = true
try {
if (actionType.value === 'submit') {
await freightApi.submitApproval(settlementId.value, {
approvalType: form.value.approvalType,
approverIds: form.value.approverIds,
remark: form.value.remark || undefined
})
ElMessage.success('提交成功')
} else if (actionType.value === 'approve') {
await freightApi.processApproval(approvalId.value, {
action: 'approve',
comment: form.value.comment
})
ElMessage.success('审批通过')
} else if (actionType.value === 'reject') {
await freightApi.processApproval(approvalId.value, {
action: 'reject',
comment: form.value.comment
})
ElMessage.success('已驳回')
}
dialogVisible.value = false
emit('success')
} finally {
submitLoading.value = false
}
}
function handleClose() {
dialogVisible.value = false
resetForm()
}
function resetForm() {
form.value = {
approvalType: 'sequential',
approverIds: [],
comment: '',
remark: ''
}
formRef.value?.clearValidate()
}
defineExpose({ openSubmit, openApprove, openReject })
</script>
<style scoped lang="scss">
.form-tip-block {
display: block;
margin-top: 6px;
}
.approval-dialog-section {
margin-top: 8px;
padding-top: 16px;
border-top: 1px solid var(--border, #d9e8e2);
}
.approval-section-title {
margin: 0 0 12px;
font-size: 14px;
font-weight: 600;
color: var(--text, #1e293b);
}
.approval-flow {
padding: 8px 0;
}
.approval-dialog-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
}
</style>
@@ -0,0 +1,163 @@
<template>
<el-dialog
v-model="visible"
title="财务发放登记"
width="640px"
align-center
append-to-body
destroy-on-close
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
>
<el-form
ref="formRef"
v-loading="loading"
:model="form"
:rules="rules"
label-position="top"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="结算单号">
<el-input :model-value="settlement?.settlementNo" disabled />
</el-form-item>
<el-form-item label="运费合计(元)">
<el-input :model-value="formatAmount(settlement?.totalFreight)" disabled />
</el-form-item>
<el-form-item label="汇款日期" prop="remittanceDate">
<el-date-picker
v-model="form.remittanceDate"
type="date"
value-format="YYYY-MM-DD"
placeholder="选择汇款日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="汇款金额(元)" prop="remittanceAmount">
<el-input-number
v-model="form.remittanceAmount"
:min="0.01"
:precision="2"
:controls="false"
placeholder="请输入汇款金额"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="汇款凭证" prop="voucherUrls" class="form-col-span-2">
<AttachmentUploadField
v-model="voucherUrlsStr"
folder="pl/freight-voucher"
hint="请上传汇款凭证,至少 1 个附件"
/>
</el-form-item>
<el-form-item label="备注" prop="remark" class="form-col-span-2">
<el-input
v-model="form.remark"
type="textarea"
:rows="3"
placeholder="请输入备注"
maxlength="500"
show-word-limit
/>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button @click="visible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
<el-icon><Check /></el-icon>确认发放
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close } from '@element-plus/icons-vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
import { formatMoneyDisplay } from '@/utils/money-format'
const emit = defineEmits<{ success: [] }>()
const visible = ref(false)
const loading = ref(false)
const submitLoading = ref(false)
const settlement = ref<FreightSettlement | null>(null)
const formRef = ref<ElFormInstance>()
const voucherUrlsStr = ref('')
const form = reactive({
remittanceDate: '',
remittanceAmount: undefined as number | undefined,
remark: ''
})
const rules = {
remittanceDate: [{ required: true, message: '请选择汇款日期', trigger: 'change' }],
remittanceAmount: [{ required: true, message: '请输入汇款金额', trigger: 'blur' }],
voucherUrls: [
{
validator: (_rule: unknown, _value: unknown, callback: (err?: Error) => void) => {
const urls = voucherUrlsStr.value
.split(',')
.map((s) => s.trim())
.filter(Boolean)
if (!urls.length) callback(new Error('请上传至少一个汇款凭证'))
else callback()
},
trigger: 'change'
}
]
}
function formatAmount(amount?: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function open(id: string) {
visible.value = true
loading.value = true
form.remittanceDate = ''
form.remittanceAmount = undefined
form.remark = ''
voucherUrlsStr.value = ''
try {
const res = await freightApi.get(id)
settlement.value = (res.data ?? res) as FreightSettlement
form.remittanceAmount = settlement.value.totalFreight
} finally {
loading.value = false
}
}
async function handleSubmit() {
if (!settlement.value) return
await formRef.value?.validate()
const voucherUrls = voucherUrlsStr.value
.split(',')
.map((s) => s.trim())
.filter(Boolean)
submitLoading.value = true
try {
await freightApi.disburse(settlement.value.id, {
remittanceDate: form.remittanceDate,
remittanceAmount: form.remittanceAmount!,
voucherUrls,
remark: form.remark || undefined
})
ElMessage.success('发放登记成功')
visible.value = false
emit('success')
} finally {
submitLoading.value = false
}
}
defineExpose({ open })
</script>
@@ -0,0 +1,162 @@
<template>
<el-dialog
v-model="visible"
title="编辑结算单"
width="720px"
align-center
append-to-body
destroy-on-close
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
>
<el-form
ref="formRef"
v-loading="loading"
:model="form"
:rules="rules"
label-position="top"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="结算单号">
<el-input :model-value="settlement?.settlementNo" disabled />
</el-form-item>
<el-form-item label="运费合计(元)">
<el-input :model-value="formatAmount(settlement?.totalFreight)" disabled />
</el-form-item>
<el-form-item label="发票号" prop="invoiceNo">
<el-input v-model="form.invoiceNo" placeholder="请输入发票号" clearable />
</el-form-item>
<el-form-item label="开票日期" prop="invoiceDate">
<el-date-picker
v-model="form.invoiceDate"
type="date"
value-format="YYYY-MM-DD"
placeholder="选择开票日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="发票金额(元)" prop="invoiceAmount">
<el-input-number
v-model="form.invoiceAmount"
:min="0"
:precision="2"
:controls="false"
placeholder="请输入发票金额"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="备注" prop="remark" class="form-col-span-2">
<el-input
v-model="form.remark"
type="textarea"
:rows="3"
placeholder="请输入备注"
maxlength="500"
show-word-limit
/>
</el-form-item>
</div>
</el-form>
<section class="dialog-section">
<h3 class="dialog-section-title">关联运输明细</h3>
<div class="list-body list-wrap dialog-list-body-only">
<el-table :data="settlement?.transports || []" class="list-table" stripe empty-text="暂无数据">
<el-table-column type="index" label="序号" min-width="60" align="center" />
<el-table-column prop="transportNo" label="运输编号" min-width="160" show-overflow-tooltip />
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
</el-table-column>
</el-table>
</div>
</section>
<template #footer>
<el-button @click="visible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
<el-icon><Check /></el-icon>保存
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close } from '@element-plus/icons-vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import { formatMoneyDisplay } from '@/utils/money-format'
const emit = defineEmits<{ success: [] }>()
const visible = ref(false)
const loading = ref(false)
const submitLoading = ref(false)
const settlement = ref<FreightSettlement | null>(null)
const formRef = ref<ElFormInstance>()
const form = reactive({
invoiceNo: '',
invoiceDate: '',
invoiceAmount: undefined as number | undefined,
remark: ''
})
const rules = {}
function formatAmount(amount?: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function open(id: string) {
visible.value = true
loading.value = true
try {
const res = await freightApi.get(id)
settlement.value = (res.data ?? res) as FreightSettlement
form.invoiceNo = settlement.value.invoiceNo || ''
form.invoiceDate = settlement.value.invoiceDate || ''
form.invoiceAmount = settlement.value.invoiceAmount
form.remark = settlement.value.remark || ''
} finally {
loading.value = false
}
}
async function handleSubmit() {
if (!settlement.value) return
submitLoading.value = true
try {
await freightApi.update(settlement.value.id, {
invoiceNo: form.invoiceNo || undefined,
invoiceDate: form.invoiceDate || undefined,
invoiceAmount: form.invoiceAmount,
remark: form.remark || undefined
})
ElMessage.success('保存成功')
visible.value = false
emit('success')
} finally {
submitLoading.value = false
}
}
defineExpose({ open })
</script>
<style scoped lang="scss">
.dialog-section {
margin-top: 16px;
}
.dialog-section-title {
margin: 0 0 12px;
font-size: 14px;
font-weight: 600;
}
</style>
@@ -0,0 +1,230 @@
<template>
<el-dialog
v-model="visible"
:title="settlement?.settlementNo || '结算单详情'"
width="calc(100vw - 100px)"
align-center
append-to-body
destroy-on-close
class="dialog-form-layout pl-freight-view-dialog"
modal-class="order-module-dialog-mask"
>
<div v-loading="loading" class="view-dialog-body">
<div v-if="settlement" class="view-hero">
<div class="view-hero-main">
<h3 class="view-hero-title">{{ settlement.settlementNo }}</h3>
<el-tag :type="getSettlementStatusTagType(settlement.settlementStatus)" size="small">
{{ getSettlementStatusLabel(settlement.settlementStatus) }}
</el-tag>
</div>
<div class="view-hero-summary">
<span class="view-hero-label">运费合计</span>
<span class="view-hero-amount">{{ formatAmount(settlement.totalFreight) }}</span>
</div>
</div>
<section v-if="settlement" class="view-section">
<h4 class="view-section-title">发票信息</h4>
<div class="view-kv-grid">
<div class="view-kv-item">
<span class="view-kv-label">发票号</span>
<span class="view-kv-value">{{ settlement.invoiceNo || '—' }}</span>
</div>
<div class="view-kv-item">
<span class="view-kv-label">开票日期</span>
<span class="view-kv-value">{{ settlement.invoiceDate || '—' }}</span>
</div>
<div class="view-kv-item">
<span class="view-kv-label">发票金额</span>
<span class="view-kv-value">{{
settlement.invoiceAmount ? formatAmount(settlement.invoiceAmount) : '—'
}}</span>
</div>
<div class="view-kv-item">
<span class="view-kv-label">创建时间</span>
<span class="view-kv-value">{{ formatDateTime(settlement.createTime) }}</span>
</div>
<div class="view-kv-item view-kv-item--full">
<span class="view-kv-label">备注</span>
<span class="view-kv-value">{{ settlement.remark || '—' }}</span>
</div>
</div>
</section>
<section v-if="settlement" class="view-section">
<h4 class="view-section-title">关联运输明细</h4>
<div class="list-body list-wrap dialog-list-body-only">
<el-table :data="settlement.transports || []" class="list-table" stripe empty-text="暂无数据">
<el-table-column type="index" label="序号" min-width="60" align="center" />
<el-table-column prop="transportNo" label="运输编号" min-width="160" show-overflow-tooltip />
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
<el-table-column prop="driverName" label="司机" min-width="100" align="center" />
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
</el-table-column>
</el-table>
</div>
</section>
<section v-if="settlement?.approvalFlow?.length" class="view-section">
<h4 class="view-section-title">审批流程</h4>
<ApprovalFlowView :nodes="approvalNodes" :loading="false" />
</section>
<section
v-if="settlement?.settlementStatus === 'confirmed' && settlement.vouchers?.length"
class="view-section"
>
<h4 class="view-section-title">汇款凭证</h4>
<div class="list-body list-wrap dialog-list-body-only">
<el-table :data="settlement.vouchers" class="list-table" stripe>
<el-table-column prop="remittanceDate" label="汇款日期" min-width="120" align="center" />
<el-table-column prop="remittanceAmount" label="汇款金额" min-width="120" align="right">
<template #default="{ row }">{{ formatAmount(row.remittanceAmount) }}</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip />
<el-table-column prop="createTime" label="登记时间" min-width="160" align="center">
<template #default="{ row }">{{ formatDateTime(row.createTime) }}</template>
</el-table-column>
</el-table>
</div>
</section>
</div>
<template #footer>
<el-button @click="visible = false">
<el-icon><Close /></el-icon>关闭
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Close } from '@element-plus/icons-vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
import {
getSettlementStatusLabel,
getSettlementStatusTagType,
mapApprovalFlowToNodes
} from '@/views/pl/freight/freight-status'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatDateTime } from '@/utils/format'
const visible = ref(false)
const loading = ref(false)
const settlement = ref<FreightSettlement | null>(null)
const approvalNodes = computed(() =>
mapApprovalFlowToNodes(settlement.value?.approvalFlow || [])
)
function formatAmount(amount?: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function open(id: string) {
visible.value = true
loading.value = true
try {
const res = await freightApi.get(id)
settlement.value = (res.data ?? res) as FreightSettlement
} finally {
loading.value = false
}
}
defineExpose({ open })
</script>
<style scoped lang="scss">
.view-dialog-body {
min-height: 120px;
}
.view-hero {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
padding: 16px;
margin-bottom: 16px;
border-radius: 10px;
background: var(--primary-bg, #ecfdf5);
border: 1px solid #a7f3d0;
}
.view-hero-main {
display: flex;
align-items: center;
gap: 10px;
}
.view-hero-title {
margin: 0;
font-size: 18px;
font-weight: 600;
}
.view-hero-summary {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 4px;
}
.view-hero-label {
font-size: 12px;
color: var(--text-muted, #64748b);
}
.view-hero-amount {
font-size: 20px;
font-weight: 700;
color: var(--primary-dark, #059669);
}
.view-section {
margin-bottom: 20px;
}
.view-section-title {
margin: 0 0 12px;
font-size: 14px;
font-weight: 600;
}
.view-kv-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px 24px;
}
.view-kv-item {
display: flex;
flex-direction: column;
gap: 4px;
}
.view-kv-item--full {
grid-column: 1 / -1;
}
.view-kv-label {
font-size: 12px;
color: var(--text-muted, #64748b);
}
.view-kv-value {
font-size: 14px;
color: var(--text, #1e293b);
word-break: break-all;
}
@media (max-width: 640px) {
.view-kv-grid {
grid-template-columns: 1fr;
}
}
</style>
@@ -0,0 +1,400 @@
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<el-dialog
v-model="innerVisible"
:title="dialogTitle"
align-center
destroy-on-close
append-to-body
class="dialog-form-layout pl-plan-archive-dialog"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
style="backdrop-filter: none"
@closed="handleClosed"
@opened="handleOpened"
>
<div class="pl-arrange-layout">
<section class="pl-arrange-form-panel">
<div v-loading="loading" class="pl-arrange-form-scroll">
<section class="pl-plan-form-section">
<h3 class="pl-plan-form-section-title">产品实际数量</h3>
<PlPlanFormProductTable
:products="productRows"
show-actual-qty
editable-actual-qty-only
/>
</section>
<section class="pl-plan-form-section">
<h4 class="pl-plan-subtitle">运费信息</h4>
<div class="form-grid-4">
<el-form-item label="是否有运输费用">
<el-switch v-model="formData.hasFreight" :active-value="1" :inactive-value="0" />
</el-form-item>
<template v-if="formData.hasFreight === 1">
<el-form-item label="运输公里数">
<el-input-number
v-model="formData.distanceKm"
:min="0"
:precision="2"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="运费计算方式">
<el-select v-model="formData.freightType">
<el-option label="按重量" value="by_weight" />
<el-option label="按趟" value="by_trip" />
</el-select>
</el-form-item>
<el-form-item
v-if="formData.freightType === 'by_weight'"
:label="`运输量(${freightUnitLabel})`"
>
<el-input-number
v-model="freightCalc.transportQty.value"
:min="0"
:precision="3"
style="width: 100%"
@change="freightCalc.markTransportQtyTouched()"
/>
</el-form-item>
<el-form-item
v-if="formData.freightType === 'by_weight'"
:label="`运输单价(元/${freightUnitLabel})`"
>
<el-input-number
v-model="freightCalc.freightPrice.value"
:min="0"
:precision="2"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="运费金额(元)">
<el-input-number
v-model="freightCalc.freightAmount.value"
:min="0"
:precision="2"
style="width: 100%"
@change="freightCalc.markFreightAmountTouched()"
/>
</el-form-item>
<el-form-item label="是否开票">
<el-switch v-model="formData.hasInvoice" :active-value="1" :inactive-value="0" />
</el-form-item>
</template>
</div>
</section>
</div>
</section>
<section class="pl-arrange-view-panel">
<h3 class="pl-arrange-view-title">计划单查看</h3>
<PlPlanViewTabs v-if="planId" ref="tabsRef" :plan-id="planId" embedded />
</section>
</div>
<template #footer>
<div class="dialog-footer pl-arrange-footer">
<el-button @click="innerVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
<el-icon><Check /></el-icon>{{ submitLabel }}
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close } from '@element-plus/icons-vue'
import {
planApi,
transportApi,
type Plan,
type PlanArchiveBody,
type PlanProduct,
type Transport
} from '@/api/pl'
import PlPlanFormProductTable from '@/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue'
import PlPlanViewTabs from '@/components/business/pl-plan-view-tabs/index.vue'
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
import { usePlFreightCalc, resolveFreightUnitLabel } from '@/composables/usePlFreightCalc'
import { pickBxData } from '@/utils/http/bx'
const props = defineProps<{
visible: boolean
planId: string
}>()
const emit = defineEmits<{
'update:visible': [value: boolean]
success: []
}>()
const innerVisible = computed({
get: () => props.visible,
set: value => emit('update:visible', value)
})
const loading = ref(false)
const submitLoading = ref(false)
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
const plan = ref<Partial<Plan>>({})
const productRows = ref<PlanFormProductRow[]>([])
const formData = reactive({
hasFreight: 0,
distanceKm: null as number | null,
freightType: 'by_weight',
hasInvoice: 0
})
const hasFreightRef = computed(() => formData.hasFreight)
const freightTypeRef = computed(() => formData.freightType)
const freightCalc = usePlFreightCalc({
products: productRows,
hasFreight: hasFreightRef,
freightType: freightTypeRef
})
const freightUnitLabel = computed(() => resolveFreightUnitLabel(productRows.value))
const isAdjustMode = computed(() => plan.value.archiveStatus === 'archived')
const dialogTitle = computed(() => {
const no = plan.value.planNo || ''
return isAdjustMode.value
? no
? `调整归档内容 · ${no}`
: '调整归档内容'
: no
? `运输计划归档 · ${no}`
: '运输计划归档'
})
const submitLabel = computed(() => (isAdjustMode.value ? '确认保存' : '确认归档'))
function mapPlanProducts(products: PlanProduct[]): PlanFormProductRow[] {
return products.map((item, index) => ({
id: item.id,
productId: String(item.productId || index),
productNo: item.productNo || String(item.productId || index),
productName: item.productName || '',
model: item.model,
categoryName: item.categoryName,
unit: item.unit || '吨',
quantity: Number(item.quantity ?? item.inboundEstimateQty ?? item.outboundEstimateQty ?? 0),
actualQty: Number(
item.actualQty ?? item.quantity ?? item.inboundEstimateQty ?? item.outboundEstimateQty ?? 0
),
packageSpec: item.packageSpec,
deliveryMethod: item.deliveryMethod,
taxPrice: item.taxPrice != null ? Number(item.taxPrice) : undefined,
taxAmount: item.taxAmount != null ? Number(item.taxAmount) : undefined,
taxSubtotal: item.taxSubtotal != null ? Number(item.taxSubtotal) : undefined,
remark: item.remark,
isExplosive: Number(item.isExplosive ?? 0),
isToxic: Number(item.isToxic ?? 0)
}))
}
function resetState() {
plan.value = {}
productRows.value = []
Object.assign(formData, {
hasFreight: 0,
distanceKm: null,
freightType: 'by_weight',
hasInvoice: 0
})
freightCalc.resetFreightCalc()
}
async function applyFreightPrefill(data: Plan) {
formData.hasFreight = data.hasFreight ?? 0
freightCalc.resetFreightCalc()
if (data.freightAmount != null && data.hasFreight === 1) {
freightCalc.freightAmount.value = Number(data.freightAmount)
freightCalc.freightAmountTouched.value = true
}
if (!data.transportId) return
try {
const transportRes = await transportApi.get(data.transportId)
const transport = pickBxData<Transport>(transportRes)
formData.distanceKm = transport.distanceKm != null ? Number(transport.distanceKm) : null
formData.freightType = transport.freightType || 'by_weight'
formData.hasInvoice = transport.hasInvoice ?? 0
if (transport.transportQty != null) {
freightCalc.transportQty.value = Number(transport.transportQty)
freightCalc.transportQtyTouched.value = true
}
if (transport.freightPrice != null) {
freightCalc.freightPrice.value = Number(transport.freightPrice)
}
if (transport.freightAmount != null) {
freightCalc.freightAmount.value = Number(transport.freightAmount)
freightCalc.freightAmountTouched.value = true
}
} catch {
// 回退计划主表冗余字段
}
}
async function handleOpened() {
if (!props.planId) return
loading.value = true
resetState()
try {
const res = await planApi.get(props.planId)
const data = pickBxData<Plan>(res)
if (!data?.id) {
throw new Error('运输计划数据无效')
}
plan.value = data
productRows.value = mapPlanProducts(Array.isArray(data.products) ? data.products : [])
await applyFreightPrefill(data)
} catch (error) {
innerVisible.value = false
const message = error instanceof Error ? error.message : '加载运输计划失败'
ElMessage.error(message.includes('加载') ? message : `加载运输计划失败:${message}`)
} finally {
loading.value = false
}
}
function handleClosed() {
resetState()
}
async function handleSubmit() {
if (!productRows.value.length) {
ElMessage.warning('暂无产品明细')
return
}
if (productRows.value.some(row => !row.id)) {
ElMessage.error('产品明细缺少行 ID,无法提交')
return
}
if (productRows.value.some(row => row.actualQty == null || Number(row.actualQty) < 0)) {
ElMessage.warning('请填写有效的实际数量')
return
}
if (formData.hasFreight === 1 && !plan.value.transportId) {
ElMessage.warning('计划有运输费用但未安排运输,请先安排运输')
return
}
submitLoading.value = true
try {
const body: PlanArchiveBody = {
products: productRows.value.map(row => ({
id: row.id!,
actualQty: Number(row.actualQty ?? 0)
})),
freight: {
hasFreight: formData.hasFreight,
...(formData.hasFreight === 1
? {
distanceKm: formData.distanceKm ?? undefined,
freightType: formData.freightType,
freightPrice:
formData.freightType === 'by_weight'
? freightCalc.freightPrice.value ?? undefined
: undefined,
freightAmount:
freightCalc.calculatedFreight.value || freightCalc.freightAmount.value || undefined,
transportQty:
formData.freightType === 'by_weight'
? freightCalc.transportQty.value ?? undefined
: undefined,
hasInvoice: formData.hasInvoice
}
: {})
}
}
await planApi.archive(props.planId, body)
ElMessage.success(isAdjustMode.value ? '保存成功' : '归档成功')
tabsRef.value?.reload()
emit('success')
innerVisible.value = false
} catch (e: unknown) {
const message = e instanceof Error ? e.message : isAdjustMode.value ? '保存失败' : '归档失败'
ElMessage.error(message)
} finally {
submitLoading.value = false
}
}
</script>
<style scoped lang="scss">
.pl-arrange-layout {
display: flex;
flex-direction: column;
gap: 16px;
min-height: 480px;
}
.pl-arrange-form-panel {
flex: 0 0 auto;
max-height: 52vh;
overflow: hidden;
}
.pl-arrange-form-scroll {
max-height: 52vh;
overflow-y: auto;
padding-right: 4px;
}
.pl-arrange-view-panel {
flex: 1 1 auto;
min-height: 280px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.pl-arrange-view-title {
margin: 0 0 12px;
font-size: 14px;
font-weight: 600;
color: #1e293b;
}
.pl-plan-subtitle {
margin: 16px 0 10px;
font-size: 13px;
font-weight: 600;
color: #475569;
}
.pl-plan-subtitle:first-of-type {
margin-top: 0;
}
.pl-arrange-freight-muted {
margin-bottom: 12px;
font-size: 13px;
color: #64748b;
}
.pl-arrange-footer {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: flex-end;
}
</style>
<style lang="scss">
.el-dialog.pl-plan-archive-dialog.dialog-form-layout {
width: min(1680px, calc(100vw - 80px)) !important;
max-height: calc(100vh - 48px);
}
</style>
@@ -27,7 +27,7 @@
<el-table-column label="计划数量" min-width="110" align="right">
<template #default="{ row }">
<el-input-number
v-if="editableQty"
v-if="editableQty && !editableActualQtyOnly"
v-model="row.quantity"
:min="0"
:precision="3"
@@ -40,7 +40,7 @@
<el-table-column v-if="showActualQty" label="实际数量" min-width="110" align="right">
<template #default="{ row }">
<el-input-number
v-if="editableQty"
v-if="(editableQty && showActualQty) || editableActualQtyOnly"
v-model="row.actualQty"
:min="0"
:precision="3"
@@ -98,6 +98,8 @@ defineProps<{
editableQty?: boolean
/** 新增/编辑弹窗默认不展示实际数量 */
showActualQty?: boolean
/** 仅实际数量可编辑,计划数量只读(归档弹窗) */
editableActualQtyOnly?: boolean
}>()
const emit = defineEmits<{
+7
View File
@@ -53,6 +53,13 @@ export const plRoutes: AppRouteRecord[] = [
component: '/pl/plan/index',
meta: { title: '运输计划', keepAlive: true, menuCode: 'pl:plan:list' }
},
{
id: 'PL00000000000000000000000000016',
name: 'PlPlanArchive',
path: 'plan-archive',
component: '/pl/plan-archive/index',
meta: { title: '运输计划归档', keepAlive: true, menuCode: 'pl:plan-archive:list' }
},
{
id: 'PL00000000000000000000000000015',
name: 'PlPlanCert',
+1
View File
@@ -117,6 +117,7 @@ export const SIDEBAR_MENU_ICON_BY_CODE: Record<string, string> = {
'pl:self-vehicle:list': 'ri:car-line',
'pl:driver:list': 'ri:user-settings-line',
'pl:plan:list': 'ri:route-line',
'pl:plan-archive:list': 'ri:folder-check-line',
'pl:plan-cert:list': 'ri:shield-check-line',
'pl:freight:list': 'ri:money-cny-box-line',
'pl:document:list': 'ri:alarm-warning-line'
@@ -0,0 +1,171 @@
<template>
<div class="freight-tab-panel">
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="结算单号">
<el-input
v-model="searchForm.q"
placeholder="搜索结算单号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
</div>
<div class="filter-actions">
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
</div>
</div>
<div class="list-body list-wrap">
<el-table class="list-table" :data="settlementList" v-loading="loading" stripe row-key="id">
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
</template>
</el-table-column>
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="130" align="right">
<template #default="{ row }">{{ formatAmount(row.totalFreight) }}</template>
</el-table-column>
<el-table-column prop="planCount" label="关联计划数" min-width="110" align="center" />
<el-table-column prop="licensePlateSummary" label="车牌摘要" min-width="140" show-overflow-tooltip />
<el-table-column prop="approvalFinishedTime" label="审批完成时间" min-width="160" align="center">
<template #default="{ row }">{{
row.approvalFinishedTime ? formatDateTime(row.approvalFinishedTime) : '—'
}}</template>
</el-table-column>
<el-table-column prop="submitterName" label="提交人" min-width="100" align="center">
<template #default="{ row }">{{ row.submitterName || '—' }}</template>
</el-table-column>
<el-table-column label="操作" min-width="200" fixed="right" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button link type="primary" @click="handleDisburse(row)">
<el-icon><Money /></el-icon>发放登记
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
<PlFreightSettlementViewDialog ref="viewDialogRef" />
<PlFreightDisburseDialog ref="disburseDialogRef" @success="handleDisburseSuccess" />
</div>
</template>
<script setup lang="ts">
import { Money, RefreshLeft, Search, View } from '@element-plus/icons-vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import PlFreightDisburseDialog from '@/components/business/pl-freight-disburse-dialog/index.vue'
import PlFreightSettlementViewDialog from '@/components/business/pl-freight-settlement-view-dialog/index.vue'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatDateTime } from '@/utils/format'
const emit = defineEmits<{ disbursed: [] }>()
const loading = ref(false)
const settlementList = ref<FreightSettlement[]>([])
const viewDialogRef = ref<InstanceType<typeof PlFreightSettlementViewDialog>>()
const disburseDialogRef = ref<InstanceType<typeof PlFreightDisburseDialog>>()
const searchForm = reactive({ q: '' })
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
function formatAmount(amount: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function fetchData() {
loading.value = true
try {
const res = await freightApi.list({
tab: 'disburse',
q: searchForm.q || undefined,
page: pagination.page,
pageSize: pagination.pageSize
})
const data = res.data ?? res
settlementList.value = data.list || []
pagination.total = data.total || 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchData()
}
function handleReset() {
searchForm.q = ''
pagination.page = 1
fetchData()
}
function handlePageChange() {
fetchData()
}
function handleSizeChange() {
pagination.page = 1
fetchData()
}
function handleView(row: FreightSettlement) {
viewDialogRef.value?.open(row.id)
}
function handleDisburse(row: FreightSettlement) {
disburseDialogRef.value?.open(row.id)
}
function handleDisburseSuccess() {
fetchData()
emit('disbursed')
}
function refresh() {
fetchData()
}
onMounted(() => {
fetchData()
})
defineExpose({ refresh })
</script>
@@ -0,0 +1,165 @@
<template>
<div class="freight-tab-panel">
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="结算单号">
<el-input
v-model="searchForm.q"
placeholder="搜索结算单号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
</div>
<div class="filter-actions">
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
</div>
</div>
<div class="list-body list-wrap">
<el-table class="list-table" :data="settlementList" v-loading="loading" stripe row-key="id">
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
</template>
</el-table-column>
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="130" align="right">
<template #default="{ row }">{{ formatAmount(row.totalFreight) }}</template>
</el-table-column>
<el-table-column prop="disburseAmount" label="发放金额(元)" min-width="130" align="right">
<template #default="{ row }">{{
row.disburseAmount ? formatAmount(row.disburseAmount) : '—'
}}</template>
</el-table-column>
<el-table-column prop="disburseTime" label="发放时间" min-width="160" align="center">
<template #default="{ row }">{{
row.disburseTime ? formatDateTime(row.disburseTime) : '—'
}}</template>
</el-table-column>
<el-table-column prop="settlementStatus" label="结算状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getSettlementStatusTagType(row.settlementStatus)" size="small">
{{ getSettlementStatusLabel(row.settlementStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" min-width="120" fixed="right" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
<PlFreightSettlementViewDialog ref="viewDialogRef" />
</div>
</template>
<script setup lang="ts">
import { RefreshLeft, Search, View } from '@element-plus/icons-vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import PlFreightSettlementViewDialog from '@/components/business/pl-freight-settlement-view-dialog/index.vue'
import {
getSettlementStatusLabel,
getSettlementStatusTagType
} from '@/views/pl/freight/freight-status'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatDateTime } from '@/utils/format'
const loading = ref(false)
const settlementList = ref<FreightSettlement[]>([])
const viewDialogRef = ref<InstanceType<typeof PlFreightSettlementViewDialog>>()
const searchForm = reactive({ q: '' })
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
function formatAmount(amount: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function fetchData() {
loading.value = true
try {
const res = await freightApi.list({
tab: 'settled',
q: searchForm.q || undefined,
page: pagination.page,
pageSize: pagination.pageSize
})
const data = res.data ?? res
settlementList.value = data.list || []
pagination.total = data.total || 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchData()
}
function handleReset() {
searchForm.q = ''
pagination.page = 1
fetchData()
}
function handlePageChange() {
fetchData()
}
function handleSizeChange() {
pagination.page = 1
fetchData()
}
function handleView(row: FreightSettlement) {
viewDialogRef.value?.open(row.id)
}
function refresh() {
fetchData()
}
onMounted(() => {
fetchData()
})
defineExpose({ refresh })
</script>
@@ -0,0 +1,274 @@
<template>
<div class="freight-tab-panel">
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="结算单号">
<el-input
v-model="searchForm.q"
placeholder="搜索结算单号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="结算状态">
<el-select v-model="searchForm.settlementStatus" placeholder="全部" clearable>
<el-option label="草稿" value="pending" />
<el-option label="审批中" value="approving" />
</el-select>
</el-form-item>
</div>
<div class="filter-actions">
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
</div>
</div>
<div class="list-body list-wrap">
<el-table class="list-table" :data="settlementList" v-loading="loading" stripe row-key="id">
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
</template>
</el-table-column>
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="130" align="right">
<template #default="{ row }">{{ formatAmount(row.totalFreight) }}</template>
</el-table-column>
<el-table-column prop="planCount" label="关联计划数" min-width="110" align="center" />
<el-table-column prop="licensePlateSummary" label="车牌摘要" min-width="140" show-overflow-tooltip />
<el-table-column prop="settlementStatus" label="结算状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getSettlementStatusTagType(row.settlementStatus)" size="small">
{{ getSettlementStatusLabel(row.settlementStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="currentApproverName" label="当前审批人" min-width="110" align="center">
<template #default="{ row }">{{ row.currentApproverName || '—' }}</template>
</el-table-column>
<el-table-column prop="submitterName" label="创建人" min-width="100" align="center">
<template #default="{ row }">{{ row.submitterName || '—' }}</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center">
<template #default="{ row }">{{ formatDateTime(row.createTime) }}</template>
</el-table-column>
<el-table-column label="操作" min-width="320" fixed="right" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button
v-if="row.settlementStatus === 'pending'"
link
type="primary"
@click="handleEdit(row)"
>
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button
v-if="row.settlementStatus === 'pending'"
link
type="primary"
@click="handleSubmit(row)"
>
<el-icon><Promotion /></el-icon>提交审批
</el-button>
<el-button
v-if="row.settlementStatus === 'pending'"
link
type="danger"
@click="handleDelete(row)"
>
<el-icon><Delete /></el-icon>删除
</el-button>
<el-button
v-if="row.canWithdraw"
link
type="warning"
@click="handleWithdraw(row)"
>
<el-icon><RefreshLeft /></el-icon>撤回
</el-button>
<el-button
v-if="row.canApprove && row.currentApprovalId"
link
type="success"
@click="handleApprove(row)"
>
<el-icon><CircleCheck /></el-icon>审批
</el-button>
<el-button
v-if="row.canApprove && row.currentApprovalId"
link
type="danger"
@click="handleReject(row)"
>
<el-icon><CircleClose /></el-icon>驳回
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
<PlFreightSettlementViewDialog ref="viewDialogRef" />
<PlFreightSettlementFormDialog ref="formDialogRef" @success="fetchData" />
<PlFreightApprovalDialog ref="approvalDialogRef" @success="fetchData" />
</div>
</template>
<script setup lang="ts">
import {
CircleCheck,
CircleClose,
Delete,
Edit,
Promotion,
RefreshLeft,
Search,
View
} from '@element-plus/icons-vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import PlFreightApprovalDialog from '@/components/business/pl-freight-approval-dialog/index.vue'
import PlFreightSettlementFormDialog from '@/components/business/pl-freight-settlement-form-dialog/index.vue'
import PlFreightSettlementViewDialog from '@/components/business/pl-freight-settlement-view-dialog/index.vue'
import {
getSettlementStatusLabel,
getSettlementStatusTagType
} from '@/views/pl/freight/freight-status'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatDateTime } from '@/utils/format'
const loading = ref(false)
const settlementList = ref<FreightSettlement[]>([])
const viewDialogRef = ref<InstanceType<typeof PlFreightSettlementViewDialog>>()
const formDialogRef = ref<InstanceType<typeof PlFreightSettlementFormDialog>>()
const approvalDialogRef = ref<InstanceType<typeof PlFreightApprovalDialog>>()
const searchForm = reactive({
q: '',
settlementStatus: ''
})
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
function formatAmount(amount: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function fetchData() {
loading.value = true
try {
const res = await freightApi.list({
tab: 'bills',
q: searchForm.q || undefined,
settlementStatus: searchForm.settlementStatus || undefined,
page: pagination.page,
pageSize: pagination.pageSize
})
const data = res.data ?? res
settlementList.value = data.list || []
pagination.total = data.total || 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchData()
}
function handleReset() {
searchForm.q = ''
searchForm.settlementStatus = ''
pagination.page = 1
fetchData()
}
function handlePageChange() {
fetchData()
}
function handleSizeChange() {
pagination.page = 1
fetchData()
}
function handleView(row: FreightSettlement) {
viewDialogRef.value?.open(row.id)
}
function handleEdit(row: FreightSettlement) {
formDialogRef.value?.open(row.id)
}
function handleSubmit(row: FreightSettlement) {
approvalDialogRef.value?.openSubmit(row.id)
}
function handleApprove(row: FreightSettlement) {
if (!row.currentApprovalId) return
approvalDialogRef.value?.openApprove(row.id, row.currentApprovalId)
}
function handleReject(row: FreightSettlement) {
if (!row.currentApprovalId) return
approvalDialogRef.value?.openReject(row.id, row.currentApprovalId)
}
async function handleWithdraw(row: FreightSettlement) {
await ElMessageBox.confirm('确定撤回该结算单的审批吗?', '提示', { type: 'warning' })
await freightApi.withdrawApproval(row.id)
ElMessage.success('已撤回')
fetchData()
}
async function handleDelete(row: FreightSettlement) {
await ElMessageBox.confirm('确定删除该草稿结算单吗?关联运输单将释放。', '提示', {
type: 'warning'
})
await freightApi.delete(row.id)
ElMessage.success('删除成功')
fetchData()
}
function refresh() {
fetchData()
}
onMounted(() => {
fetchData()
})
defineExpose({ refresh })
</script>
@@ -0,0 +1,229 @@
<template>
<div class="freight-tab-panel">
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="计划编号">
<el-input
v-model="searchForm.q"
placeholder="搜索计划编号/客户"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="单据类型">
<el-select v-model="searchForm.planType" placeholder="全部" clearable>
<el-option label="直销单" value="direct" />
<el-option label="入库单" value="inbound" />
<el-option label="出库单" value="outbound" />
</el-select>
</el-form-item>
<el-form-item label="车牌号">
<el-input v-model="searchForm.licensePlate" placeholder="搜索车牌号" clearable />
</el-form-item>
</div>
<div class="filter-actions">
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
<el-button
class="btn-main"
type="primary"
:disabled="!selectedRows.length"
:loading="createLoading"
@click="handleCreateSettlement"
>
<el-icon><DocumentAdd /></el-icon>生成结算单
</el-button>
</div>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="planList"
v-loading="loading"
stripe
row-key="id"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" min-width="48" align="center" />
<el-table-column prop="planNo" label="计划编号" min-width="160" show-overflow-tooltip />
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center" />
<el-table-column prop="planType" label="单据类型" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getPlanTypeTagType(row.planType)" size="small">
{{ getPlanTypeLabel(row.planType) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="客户/供应商" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
{{ row.customerName || row.supplierName || '—' }}
</template>
</el-table-column>
<el-table-column prop="licensePlate" label="车牌号" min-width="110" align="center" />
<el-table-column prop="transportCompany" label="运输公司" min-width="140" show-overflow-tooltip />
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
</el-table-column>
<el-table-column prop="archiveTime" label="归档时间" min-width="160" align="center">
<template #default="{ row }">{{
row.archiveTime ? formatDateTime(row.archiveTime) : '—'
}}</template>
</el-table-column>
<el-table-column label="操作" min-width="100" fixed="right" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="handleViewPlan(row)">
<el-icon><View /></el-icon>查看
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
<PlPlanViewDialog v-model:visible="planViewVisible" :plan-id="viewPlanId" />
</div>
</template>
<script setup lang="ts">
import { DocumentAdd, RefreshLeft, Search, View } from '@element-plus/icons-vue'
import { freightApi, type UnsettledPlanItem } from '@/api/pl'
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
import { getPlanTypeLabel, getPlanTypeTagType } from '@/views/pl/freight/freight-status'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatDateTime } from '@/utils/format'
const emit = defineEmits<{ created: [settlementId: string] }>()
const loading = ref(false)
const createLoading = ref(false)
const planList = ref<UnsettledPlanItem[]>([])
const selectedRows = ref<UnsettledPlanItem[]>([])
const planViewVisible = ref(false)
const viewPlanId = ref('')
const searchForm = reactive({
q: '',
planType: '',
licensePlate: ''
})
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
function formatAmount(amount: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function fetchData() {
loading.value = true
try {
const res = await freightApi.listUnsettledPlans({
q: searchForm.q || undefined,
planType: searchForm.planType || undefined,
licensePlate: searchForm.licensePlate || undefined,
page: pagination.page,
pageSize: pagination.pageSize
})
const data = res.data ?? res
planList.value = data.list || []
pagination.total = data.total || 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchData()
}
function handleReset() {
searchForm.q = ''
searchForm.planType = ''
searchForm.licensePlate = ''
pagination.page = 1
fetchData()
}
function handlePageChange() {
fetchData()
}
function handleSizeChange() {
pagination.page = 1
fetchData()
}
function handleSelectionChange(rows: UnsettledPlanItem[]) {
selectedRows.value = rows
}
function handleViewPlan(row: UnsettledPlanItem) {
viewPlanId.value = row.id
planViewVisible.value = true
}
async function handleCreateSettlement() {
if (!selectedRows.value.length) return
await ElMessageBox.confirm(
`确定将选中的 ${selectedRows.value.length} 条计划生成一张结算单吗?`,
'提示',
{ type: 'warning' }
)
createLoading.value = true
try {
const res = await freightApi.create({
planIds: selectedRows.value.map((r) => r.id)
})
const settlement = (res.data ?? res) as { id: string; settlementNo?: string }
ElMessage.success(`结算单 ${settlement.settlementNo || ''} 创建成功`)
selectedRows.value = []
emit('created', settlement.id)
fetchData()
} finally {
createLoading.value = false
}
}
function refresh() {
fetchData()
}
onMounted(() => {
fetchData()
})
defineExpose({ refresh })
</script>
@@ -0,0 +1,63 @@
export type SettlementStatus = 'pending' | 'approving' | 'approved' | 'confirmed'
export function getSettlementStatusTagType(
status: string
): 'info' | 'warning' | 'success' | 'primary' {
const map: Record<string, 'info' | 'warning' | 'success' | 'primary'> = {
pending: 'info',
approving: 'warning',
approved: 'primary',
confirmed: 'success'
}
return map[status] || 'info'
}
export function getSettlementStatusLabel(status: string) {
const map: Record<string, string> = {
pending: '草稿',
approving: '审批中',
approved: '待发放',
confirmed: '已结算'
}
return map[status] || status
}
export function getPlanTypeTagType(planType: string): 'primary' | 'success' | 'warning' | 'info' {
const map: Record<string, 'primary' | 'success' | 'warning' | 'info'> = {
direct: 'primary',
inbound: 'success',
outbound: 'warning'
}
return map[planType] || 'info'
}
export function getPlanTypeLabel(planType: string) {
const map: Record<string, string> = {
direct: '直销单',
inbound: '入库单',
outbound: '出库单'
}
return map[planType] || planType
}
export function mapApprovalFlowToNodes(
flow: Array<{
id: string
step: number
stepName?: string
approverName?: string
approvalResult: string
approvalOpinion?: string
approvalTime?: string
}>
) {
return flow.map((item) => ({
id: item.id as unknown as number,
nodeName: item.stepName || item.approverName || `步骤${item.step}`,
nodeOrder: item.step,
approvalStatus: item.approvalResult,
approvalOpinion: item.approvalOpinion,
approverName: item.approverName || '',
approvalTime: item.approvalTime
}))
}
+40 -334
View File
@@ -3,356 +3,62 @@
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运费结算列表</h2>
<h2 class="title-bar-heading">运费结算</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="结算单号">
<el-input
v-model="searchForm.q"
placeholder="搜索结算单号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="结算状态">
<el-select v-model="searchForm.settlementStatus" placeholder="全部" clearable>
<el-option label="待提交" value="pending" />
<el-option label="已提交" value="submitted" />
<el-option label="已审核" value="confirmed" />
</el-select>
</el-form-item>
</div>
<div class="filter-actions">
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
</div>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="settlementList"
v-loading="loading"
stripe
row-key="id"
>
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
</template>
</el-table-column>
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="140" align="right">
<template #default="{ row }">
{{ formatAmount(row.totalFreight) }}
</template>
</el-table-column>
<el-table-column prop="invoiceNo" label="发票号" min-width="140" align="center" />
<el-table-column prop="invoiceAmount" label="发票金额" min-width="120" align="right">
<template #default="{ row }">
{{ row.invoiceAmount ? formatAmount(row.invoiceAmount) : '-' }}
</template>
</el-table-column>
<el-table-column prop="settlementStatus" label="结算状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getStatusTagType(row.settlementStatus)" size="small">
{{ getStatusLabel(row.settlementStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center">
<template #default="{ row }">
{{ formatDateTime(row.createTime) }}
</template>
</el-table-column>
<el-table-column label="操作" min-width="260" fixed="right" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button
v-if="row.settlementStatus === 'pending'"
link
type="primary"
@click="handleSubmit(row)"
>
<el-icon><Promotion /></el-icon>提交
</el-button>
<el-button
v-if="row.settlementStatus === 'submitted'"
link
type="success"
@click="handleApprove(row)"
>
<el-icon><CircleCheck /></el-icon>审核
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
<div class="panel-tabs">
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
<el-tab-pane label="未结算计划" name="unsettled">
<UnsettledPlanPanel ref="unsettledRef" @created="handleSettlementCreated" />
</el-tab-pane>
<el-tab-pane label="结算单" name="bills">
<SettlementBillPanel ref="billsRef" />
</el-tab-pane>
<el-tab-pane label="待财务发放" name="disburse">
<DisbursePanel ref="disburseRef" @disbursed="handleDisbursed" />
</el-tab-pane>
<el-tab-pane label="已结算" name="settled">
<SettledPanel ref="settledRef" />
</el-tab-pane>
</el-tabs>
</div>
</section>
<SystemViewDialog
v-model:visible="detailVisible"
:title="currentSettlement?.settlementNo || '结算单详情'"
:icon="Wallet"
:code="currentSettlement?.settlementNo"
code-label="结算单号"
:sections="viewSections"
:loading="detailLoading"
width="calc(100vw - 100px)"
modal-class="order-module-dialog-mask"
append-to-body
>
<template #transports>
<div class="panel dialog-list-panel">
<div class="list-body list-wrap dialog-list-body-only">
<el-table
:data="currentSettlement?.transports || []"
class="list-table"
stripe
empty-text="暂无关联运输单"
>
<el-table-column type="index" label="序号" min-width="60" align="center" />
<el-table-column prop="transportNo" label="运输编号" min-width="160" show-overflow-tooltip />
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
<el-table-column prop="driverName" label="司机" min-width="100" align="center" />
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
<template #default="{ row }">
{{ formatAmount(row.freightAmount) }}
</template>
</el-table-column>
<el-table-column prop="transportStatus" label="运输状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getTransportStatusTagType(row.transportStatus)" size="small">
{{ getTransportStatusLabel(row.transportStatus) }}
</el-tag>
</template>
</el-table-column>
</el-table>
</div>
</div>
</template>
</SystemViewDialog>
</div>
</template>
<script setup lang="ts">
import {
CircleCheck,
Promotion,
RefreshLeft,
Search,
View,
Wallet
} from '@element-plus/icons-vue'
import SystemViewDialog, {
type ViewSection
} from '@/components/business/system-view-dialog/index.vue'
import { freightApi, type FreightSettlement } from '@/api/pl'
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatDateTime } from '@/utils/format'
import UnsettledPlanPanel from './components/UnsettledPlanPanel.vue'
import SettlementBillPanel from './components/SettlementBillPanel.vue'
import DisbursePanel from './components/DisbursePanel.vue'
import SettledPanel from './components/SettledPanel.vue'
const loading = ref(false)
const detailLoading = ref(false)
const settlementList = ref<FreightSettlement[]>([])
const detailVisible = ref(false)
const currentSettlement = ref<FreightSettlement | null>(null)
type FreightTab = 'unsettled' | 'bills' | 'disburse' | 'settled'
const searchForm = reactive({
q: '',
settlementStatus: ''
})
const activeTab = ref<FreightTab>('unsettled')
const unsettledRef = ref<InstanceType<typeof UnsettledPlanPanel>>()
const billsRef = ref<InstanceType<typeof SettlementBillPanel>>()
const disburseRef = ref<InstanceType<typeof DisbursePanel>>()
const settledRef = ref<InstanceType<typeof SettledPanel>>()
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
const viewSections = computed<ViewSection[]>(() => {
const s = currentSettlement.value
if (!s) return []
return [
{
title: '结算信息',
fields: [
{
label: '结算状态',
value: getStatusLabel(s.settlementStatus),
tagType: getStatusTagType(s.settlementStatus)
},
{
label: '运费合计',
value: formatAmount(s.totalFreight),
money: true
},
{ label: '发票号', value: s.invoiceNo },
{
label: '发票金额',
value: s.invoiceAmount ? formatAmount(s.invoiceAmount) : undefined,
money: Boolean(s.invoiceAmount)
},
{ label: '发票日期', value: s.invoiceDate },
{ label: '创建时间', value: formatDateTime(s.createTime) },
{ label: '备注', value: s.remark, span: true }
]
},
{
title: '关联运输单',
fields: [],
slot: 'transports'
}
]
})
function getStatusTagType(status: string) {
const map: Record<string, 'info' | 'warning' | 'success'> = {
pending: 'info',
submitted: 'warning',
confirmed: 'success'
}
return map[status] || 'info'
function refreshTab(name: FreightTab) {
if (name === 'unsettled') unsettledRef.value?.refresh()
else if (name === 'bills') billsRef.value?.refresh()
else if (name === 'disburse') disburseRef.value?.refresh()
else if (name === 'settled') settledRef.value?.refresh()
}
function getStatusLabel(status: string) {
const map: Record<string, string> = {
pending: '待提交',
submitted: '已提交',
confirmed: '已审核'
}
return map[status] || status
function handleTabChange(name: string | number) {
refreshTab(String(name) as FreightTab)
}
function getTransportStatusTagType(status: string) {
const map: Record<string, 'info' | 'warning' | 'primary' | 'success' | 'danger'> = {
draft: 'info',
pending: 'warning',
executing: 'primary',
completed: 'success',
cancelled: 'danger'
}
return map[status] || 'info'
function handleSettlementCreated() {
activeTab.value = 'bills'
nextTick(() => {
billsRef.value?.refresh()
})
}
function getTransportStatusLabel(status: string) {
const map: Record<string, string> = {
draft: '草稿',
pending: '待执行',
executing: '执行中',
completed: '已完成',
cancelled: '已取消'
}
return map[status] || status
function handleDisbursed() {
settledRef.value?.refresh()
}
function formatAmount(amount: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function fetchData() {
loading.value = true
try {
const res = await freightApi.list({
q: searchForm.q || undefined,
settlementStatus: searchForm.settlementStatus || undefined,
page: pagination.page,
pageSize: pagination.pageSize
})
const data = res.data ?? res
settlementList.value = data.list || []
pagination.total = data.total || 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchData()
}
function handleReset() {
searchForm.q = ''
searchForm.settlementStatus = ''
pagination.page = 1
fetchData()
}
function handlePageChange() {
fetchData()
}
function handleSizeChange() {
pagination.page = 1
fetchData()
}
async function handleView(row: FreightSettlement) {
detailVisible.value = true
detailLoading.value = true
currentSettlement.value = row
try {
const res = await freightApi.get(row.id)
currentSettlement.value = (res.data ?? res) as FreightSettlement
} finally {
detailLoading.value = false
}
}
async function handleSubmit(row: FreightSettlement) {
await ElMessageBox.confirm('确定提交该结算单吗?', '提示', { type: 'warning' })
await freightApi.submit(row.id)
ElMessage.success('提交成功')
fetchData()
}
async function handleApprove(row: FreightSettlement) {
await ElMessageBox.confirm('确定审核通过该结算单吗?', '提示', { type: 'warning' })
await freightApi.approve(row.id)
ElMessage.success('审核成功')
fetchData()
}
useDbInstantSearch(
() => ({
q: searchForm.q,
settlementStatus: searchForm.settlementStatus
}),
handleSearch
)
onMounted(() => {
fetchData()
})
</script>
@@ -0,0 +1,398 @@
<!-- 运输计划归档 -->
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运输计划归档</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="计划编号">
<el-input
v-model="searchForm.planNo"
placeholder="搜索计划编号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="单据类型">
<el-select v-model="searchForm.planType" placeholder="全部" clearable>
<el-option label="直销单" value="direct" />
<el-option label="入库单" value="inbound" />
<el-option label="出库单" value="outbound" />
</el-select>
</el-form-item>
<el-form-item label="跟进状态">
<el-select v-model="searchForm.followStatus" placeholder="全部" clearable>
<el-option label="草稿" value="draft" />
<el-option label="进行中" value="processing" />
<el-option label="已完成" value="completed" />
<el-option label="已取消" value="cancelled" />
</el-select>
</el-form-item>
<el-form-item label="运输状态">
<el-select v-model="searchForm.transportStatus" placeholder="全部" clearable>
<el-option label="待安排" value="pending" />
<el-option label="已安排" value="arranged" />
</el-select>
</el-form-item>
</div>
<div v-show="filterExpanded" id="pl-plan-archive-filter-extra" class="filter-extra">
<div class="filter-grid">
<el-form-item label="客户名称">
<el-input
v-model="searchForm.customerName"
placeholder="搜索客户名称"
clearable
/>
</el-form-item>
<el-form-item label="计划日期">
<el-date-picker
v-model="dateRange"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="归档状态">
<el-select v-model="searchForm.archiveStatus" placeholder="全部" clearable>
<el-option label="未归档" value="unarchived" />
<el-option label="已归档" value="archived" />
</el-select>
</el-form-item>
</div>
</div>
<div class="filter-actions">
<div class="filter-actions-start">
<button
v-if="showFilterToggle"
type="button"
class="btn-link btn-filter-toggle"
:aria-expanded="filterExpanded"
aria-controls="pl-plan-archive-filter-extra"
@click="filterExpanded = !filterExpanded"
>
{{ filterExpanded ? '收起更多' : '展开更多' }}
<el-icon>
<ArrowUpBold v-if="filterExpanded" />
<ArrowDownBold v-else />
</el-icon>
</button>
</div>
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
</div>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="planList"
v-loading="loading"
stripe
row-key="id"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
<el-table-column prop="planNo" label="计划编号" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleView(row)">{{ row.planNo }}</el-link>
</template>
</el-table-column>
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center" />
<el-table-column prop="planType" label="单据类型" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getPlanTypeTagType(row.planType)" size="small">
{{ getPlanTypeLabel(row.planType) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="customerName" label="客户名称" min-width="180" show-overflow-tooltip />
<el-table-column label="产品信息" min-width="240">
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" />
</template>
</el-table-column>
<el-table-column label="计划附件" min-width="400">
<template #default="{ row }">
<PlPlanListCertCell :products="row.products" />
</template>
</el-table-column>
<el-table-column prop="archiveStatus" label="归档状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getPlPlanArchiveStatusTagType(row.archiveStatus)" size="small">
{{ getPlPlanArchiveStatusLabel(row.archiveStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="followStatus" label="跟进状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="getFollowStatusTagType(row.followStatus)" size="small">
{{ getFollowStatusLabel(row.followStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="transportStatus" label="运输状态" min-width="100" align="center">
<template #default="{ row }">
<el-tag :type="row.transportStatus === 'arranged' ? 'success' : 'info'" size="small">
{{ row.transportStatus === 'arranged' ? '已安排' : '待安排' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="totalAmount" label="计划金额" min-width="120" align="right">
<template #default="{ row }">
{{ formatAmount(row.totalAmount) }}
</template>
</el-table-column>
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
<el-table-column prop="driverName" label="司机" min-width="100" align="center" />
<el-table-column prop="followUserName" label="跟进人" min-width="100" align="center" />
<el-table-column label="操作" min-width="260" fixed="right" align="center" class-name="col-actions">
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button
v-if="row.followStatus !== 'cancelled'"
link
type="primary"
@click="handleEdit(row)"
>
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button
v-if="row.followStatus !== 'cancelled'"
link
type="success"
@click="handleArchive(row)"
>
<el-icon><FolderChecked /></el-icon>{{ row.archiveStatus === 'archived' ? '调整' : '归档' }}
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
</section>
<PlPlanFormDialog
v-model:visible="formDialogVisible"
:plan-id="editingPlanId"
@success="fetchData"
/>
<PlPlanViewDialog v-model:visible="viewVisible" :plan-id="viewPlanId" />
<PlPlanArchiveDialog
v-model:visible="archiveDialogVisible"
:plan-id="archivePlanId"
@success="fetchData"
/>
</div>
</template>
<script setup lang="ts">
import {
ArrowDownBold,
ArrowUpBold,
Edit,
FolderChecked,
RefreshLeft,
Search,
View
} from '@element-plus/icons-vue'
import { planApi, type Plan } from '@/api/pl'
import PlPlanArchiveDialog from '@/components/business/pl-plan-archive-dialog/index.vue'
import PlPlanFormDialog from '@/components/business/pl-plan-form-dialog/index.vue'
import PlPlanListCertCell from '@/components/business/pl-plan-list-cert-cell/index.vue'
import PlPlanListProductCell from '@/components/business/pl-plan-list-product-cell/index.vue'
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
import {
getPlPlanArchiveStatusLabel,
getPlPlanArchiveStatusTagType
} from '@/utils/pl-display'
import { formatMoneyDisplay } from '@/utils/money-format'
const loading = ref(false)
const formDialogVisible = ref(false)
const editingPlanId = ref('')
const viewVisible = ref(false)
const viewPlanId = ref('')
const archiveDialogVisible = ref(false)
const archivePlanId = ref('')
const filterExpanded = ref(false)
const planList = ref<Plan[]>([])
const selectedRows = ref<Plan[]>([])
const dateRange = ref<string[]>([])
const searchForm = reactive({
planNo: '',
planType: '',
followStatus: '',
transportStatus: '',
customerName: '',
archiveStatus: ''
})
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
const PLAN_FILTER_FIELD_COUNT = 7
const showFilterToggle = computed(() => PLAN_FILTER_FIELD_COUNT > 4)
function getPlanTypeTagType(type: string) {
const map: Record<string, string> = { direct: 'primary', inbound: 'success', outbound: 'warning' }
return map[type] || 'info'
}
function getPlanTypeLabel(type: string) {
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
return map[type] || type
}
function getFollowStatusTagType(status: string) {
const map: Record<string, string> = {
draft: 'info',
processing: 'warning',
completed: 'success',
cancelled: 'danger'
}
return map[status] || 'info'
}
function getFollowStatusLabel(status: string) {
const map: Record<string, string> = {
draft: '草稿',
processing: '进行中',
completed: '已完成',
cancelled: '已取消'
}
return map[status] || status
}
function formatAmount(amount: number) {
if (!amount) return '¥0.00'
return formatMoneyDisplay(amount)
}
async function fetchData() {
loading.value = true
try {
const res = await planApi.list({
planNo: searchForm.planNo || undefined,
planType: searchForm.planType || undefined,
followStatus: searchForm.followStatus || undefined,
transportStatus: searchForm.transportStatus || undefined,
customerName: searchForm.customerName || undefined,
archiveStatus: searchForm.archiveStatus || undefined,
planDateFrom: dateRange.value?.[0] || undefined,
planDateTo: dateRange.value?.[1] || undefined,
page: pagination.page,
pageSize: pagination.pageSize
})
const data = res.data ?? res
planList.value = data.list || []
pagination.total = data.total || 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchData()
}
function handleReset() {
searchForm.planNo = ''
searchForm.planType = ''
searchForm.followStatus = ''
searchForm.transportStatus = ''
searchForm.customerName = ''
searchForm.archiveStatus = ''
dateRange.value = []
filterExpanded.value = false
pagination.page = 1
fetchData()
}
function handleSelectionChange(selection: Plan[]) {
selectedRows.value = selection
}
function handlePageChange() {
fetchData()
}
function handleSizeChange() {
pagination.page = 1
fetchData()
}
function handleView(row: Plan) {
viewPlanId.value = row.id
viewVisible.value = true
}
function handleEdit(row: Plan) {
editingPlanId.value = row.id
formDialogVisible.value = true
}
function handleArchive(row: Plan) {
archivePlanId.value = row.id
archiveDialogVisible.value = true
}
useDbInstantSearch(
() => ({
planNo: searchForm.planNo,
planType: searchForm.planType,
followStatus: searchForm.followStatus,
transportStatus: searchForm.transportStatus,
customerName: searchForm.customerName,
archiveStatus: searchForm.archiveStatus,
dateRange: dateRange.value
}),
handleSearch
)
onMounted(() => {
fetchData()
})
</script>
-11
View File
@@ -187,9 +187,6 @@
>
<el-icon><Van /></el-icon>{{ plan.transportStatus === 'arranged' ? '调整运输' : '安排运输' }}
</el-button>
<el-button v-if="plan.archiveStatus !== 'archived'" type="info" @click="handleArchive">
<el-icon><FolderChecked /></el-icon>归档
</el-button>
<el-button v-if="plan.followStatus !== 'cancelled'" type="danger" @click="handleCancel">
<el-icon><CircleClose /></el-icon>取消
</el-button>
@@ -209,7 +206,6 @@ import {
CircleClose,
Close,
Edit,
FolderChecked,
Van
} from '@element-plus/icons-vue'
import { planApi, type Plan, type PlanProduct } from '@/api/pl'
@@ -285,13 +281,6 @@ function handleArrange() {
arrangeDialogVisible.value = true
}
async function handleArchive() {
await ElMessageBox.confirm('确定归档该计划吗?', '提示', { type: 'warning' })
await planApi.archive(planId.value)
ElMessage.success('归档成功')
fetchDetail()
}
async function handleCancel() {
await ElMessageBox.confirm('确定取消该计划吗?', '提示', { type: 'warning' })
await planApi.cancel(planId.value)
-17
View File
@@ -100,9 +100,6 @@
<el-button class="btn-main" type="primary" @click="handleAdd">
<el-icon><Plus /></el-icon>新增计划
</el-button>
<el-button class="btn-ghost" :disabled="multiple" @click="handleBatchArchive">
<el-icon><FolderChecked /></el-icon>批量归档
</el-button>
<el-button
class="btn-ghost"
type="danger"
@@ -254,7 +251,6 @@ import {
CircleClose,
Delete,
Edit,
FolderChecked,
Plus,
RefreshLeft,
Search,
@@ -457,19 +453,6 @@ function handleArrange(row: Plan) {
arrangeDialogVisible.value = true
}
async function handleBatchArchive() {
const ids = selectedRows.value.map(r => r.id)
try {
for (const id of ids) {
await planApi.archive(id)
}
ElMessage.success('归档成功')
fetchData()
} catch (e) {
console.error(e)
}
}
async function handleDelete(row: Plan) {
await ElMessageBox.confirm(`确定删除运输计划「${row.planNo}」吗?`, '提示', { type: 'warning' })
deleteLoading.value = true