7-3 修复老订单成本核算及业务员尺寸传递

- 定价引擎始终重算cost_price(移除cost==0限制)
- 业务员表单calcDemandResult设置length_m/width_m
- 管理员编辑表格补上需求规格列

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wsb1224 2026-07-03 18:15:21 +08:00
parent 073fe0a2ac
commit a859f490d9
3 changed files with 5 additions and 3 deletions

View File

@ -237,8 +237,8 @@ class OrderService:
"price_tier": getattr(item, "price_tier", None),
}
# cost_price 为 0 且有定价规则时,尝试用引擎重算
if item_dict["cost_price"] == 0 and item.product_id and item.product_id in rules_map:
# 有定价规则且有尺寸数据时,用定价引擎重算 cost_price
if item.product_id and item.product_id in rules_map:
rule = rules_map[item.product_id]
product = products_map.get(item.product_id)
product_attrs = {}
@ -251,7 +251,6 @@ class OrderService:
product_attrs["default_width_m"] = float(product.default_width_m)
user_inputs = {}
# 优先使用已存储的 length_m/width_m否则从 demand_specification 解析
lm = getattr(item, "length_m", None)
wm = getattr(item, "width_m", None)
if lm and wm:

View File

@ -350,6 +350,7 @@
style="margin-top: 4px;"/>
</td>
<td><input v-model="item.specification" type="text" placeholder="规格" class="inline-input"/></td>
<td><input v-model="item.demand_specification" type="text" placeholder="如: 25cm×25cm" class="inline-input"/></td>
<td><input v-model="item.unit" type="text" placeholder="单位" class="inline-input"
style="width: 60px;"/></td>
<td><input v-model.number="item.quantity" type="number" min="1" class="inline-input"

View File

@ -806,6 +806,8 @@ function calcDemandResult(row) {
const toM = (v, u) => u === "m" ? v : u === "mm" ? v / 1000 : v / 100;
const m1 = toM(v1, u1);
const m2 = toM(v2, u2);
row.length_m = m2;
row.width_m = m1;
const area = m1 * m2;
row._demandResult = `${area.toFixed(4)}`;
row._demandCalcHint = `${v1}${u1} × ${v2}${u2} = ${m1}m × ${m2}m = ${area.toFixed(4)}`;