feat: 样板库整合材料系列选择(商家选材闭环: 预览对话框系列选择器+offer-price系列成本估算+QuoteDialog选材参考面板)

This commit is contained in:
HHY
2026-10-06 05:28:27 -07:00
parent 64bda5e97b
commit 07eda3ff35
5 changed files with 84 additions and 6 deletions
+17
View File
@@ -14,6 +14,7 @@ class QuoteRequest(BaseModel):
drawing_data: str | dict | None = Field(default=None, description="画布 drawing_data(与 template_id/order_id 三选一)")
template_id: int | None = Field(default=None, description="或直接指定样板")
order_id: int | None = Field(default=None, description="或对已有订单报价")
series_id: int | None = Field(default=None, description="材料系列(成本系列模板): 附加该系列的成本估算供商家选材")
prices: dict | None = Field(default=None, description="价格本覆盖 {frame,mullion,sash,glass,hardware}")
use_price_book: bool = Field(default=False, description="从产品管理价格本取价(按材料类别均价)")
use_scripts: bool = Field(default=False, description="启用价格脚本计价(公司启用脚本覆盖默认单价/总价)")
@@ -79,4 +80,20 @@ async def offer_price(body: QuoteRequest, user: CurrentUser, db: DbSession):
except Exception as e: # 公式/图纸解析错误 → 用户可读失败
msg = str(e) if "公式" in str(e) or "未知变量" in str(e) else "图纸数据解析失败"
return fail(msg)
# 材料系列成本参考:商家选材依据(系列模板八分区估算, 按图纸实际尺寸)
if body.series_id:
from huamenchuang.models.business import CostSeriesTemplate
from huamenchuang.services import costbook_service as _svc
tpl = await db.get(CostSeriesTemplate, body.series_id)
if tpl is not None and tpl.company_id == user.company_id:
w = result.get("width_mm") or 1600
h = result.get("height_mm") or 1600
est = _svc.estimate(tpl, w, h, 1)
result["series"] = {"id": tpl.id, "name": tpl.name, "series": tpl.series, "wall_thick": tpl.wall_thick}
result["series_estimate"] = {
"width": w, "height": h, "total": est["total"], "per_sqm": est["per_sqm"],
"profile_cost": est["profile_cost"], "glass_cost": est["glass_cost"],
"hardware_cost": est["hardware_cost"], "labor_cost": est["labor_cost"],
"margin_ladder": est["margin_ladder"],
}
return ok(data=result, message="报价成功")