优化合同个管理和产品管理相关功能

This commit is contained in:
2026-09-12 23:29:45 +08:00
parent 2b1874943f
commit 4455b95e37
92 changed files with 5367 additions and 3144 deletions
@@ -13,6 +13,36 @@
const round2 = (n) => Math.round((Number(n) || 0) * 100) / 100;
/**
* 软件开发模块树节点售价合计:
* - 含子节点 → 汇总子节点;
* - 叶子节点 → 人天 × 统一人天单价。
*/
export function treeSellTotal(nodes, unitPrice = 0) {
const list = Array.isArray(nodes) ? nodes : [];
const up = Number(unitPrice) || 0;
return round2(
list.reduce((sum, n) => {
if (Array.isArray(n.children) && n.children.length) {
return sum + treeSellTotal(n.children, up);
}
return sum + round2((Number(n.man_days) || 0) * up);
}, 0)
);
}
/** 单行金额:成品 = 数量×单价;软件开发 = 模块树售价合计(人天×统一人天单价) */
export function lineAmount(row) {
if (row?.line_type === "dev") return treeSellTotal(row.dev_tree, row.dev_unit_price);
return round2((Number(row?.quantity) || 0) * (Number(row?.price) || 0));
}
/** 单行成本:成品 = 数量×成本单价;软件开发不计成本 */
export function lineCost(row) {
if (row?.line_type === "dev") return 0;
return round2((Number(row?.quantity) || 0) * (Number(row?.cost_price) || 0));
}
export function buildSummary(products) {
const rows = Array.isArray(products) ? products : [];
let hardware = 0;
@@ -20,6 +50,11 @@ export function buildSummary(products) {
let other = 0;
let totalCost = 0;
rows.forEach((row) => {
if (row?.line_type === "dev") {
const amount = treeSellTotal(row.dev_tree, row.dev_unit_price);
software += amount; // 软件开发计入软件部分,不计成本
return;
}
const qty = Number(row?.quantity) || 0;
const price = Number(row?.price) || 0;
const costPrice = Number(row?.cost_price) || 0;