From b78d120f9ed4ffba53ed065c6f1896fc706e81fc Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 27 Oct 2026 21:15:22 +0800 Subject: [PATCH] =?UTF-8?q?style(=E6=88=90=E6=9C=AC=E6=8E=92=E8=A1=8C):=20?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=8C=BA=E5=AF=B9=E9=BD=90=E6=8A=A5=E4=BB=B7?= =?UTF-8?q?=E5=8D=95=E7=9B=AE=E6=A0=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 有价格目标时只显示目标行:报价单/商品库标记、报价单名+客户名、当前销售价、右侧输入;隐藏通用成本明细;补客户名与当前价文案。 --- server/src/services/marginQueryService.ts | 7 +- .../tests/skuCostQuoteSheetReadonly.test.ts | 2 +- src/i18n/locales/en/finance.ts | 1 + src/i18n/locales/id/finance.ts | 1 + src/i18n/locales/zh-CN/finance.ts | 1 + .../costAccounting/CostAccountingPanel.tsx | 180 +++++++++--------- src/pages/finance/costAccounting/types.ts | 1 + 7 files changed, 106 insertions(+), 87 deletions(-) diff --git a/server/src/services/marginQueryService.ts b/server/src/services/marginQueryService.ts index 135d74c..53891d3 100644 --- a/server/src/services/marginQueryService.ts +++ b/server/src/services/marginQueryService.ts @@ -1253,6 +1253,7 @@ export interface SkuDirectCostRow { code: string; title: string | null; customer_code: string; + customer_name?: string | null; sale_price: number; }>; /** 只读:按客户去重的价格目标(报价单优先,其次客户商品库) */ @@ -1303,10 +1304,12 @@ export async function getSkuDirectCosts( const customer = customerCode ? String(customerCode).trim() : null; const branch = ctx?.branchCode ? String(ctx.branchCode).trim() : null; const quoteRows = await pool.query( - `SELECT qs.quote_sheet_code AS code, qs.title, qsc.customer_code, qsi.sku_code, + `SELECT qs.quote_sheet_code AS code, qs.title, qsc.customer_code, + c.company_name AS customer_name, qsi.sku_code, COALESCE(NULLIF(qsi.sale_price, 0), qsi.price)::float AS sale_price FROM customer_quote_sheets qs JOIN customer_quote_sheet_customers qsc ON qsc.quote_sheet_code = qs.quote_sheet_code + LEFT JOIN customers c ON c.customer_code = qsc.customer_code JOIN customer_quote_sheet_items qsi ON qsi.quote_sheet_code = qs.quote_sheet_code WHERE qs.status = 1 AND qs.approval_status = 30 AND (qs.expires_at IS NULL OR qs.expires_at > NOW()) @@ -1341,6 +1344,7 @@ export async function getSkuDirectCosts( code: String(q.code || ''), title: q.title ? String(q.title) : null, customer_code: customerCodeValue, + customer_name: q.customer_name ? String(q.customer_name) : null, sale_price: price, }; const options = optionsBySku.get(sku) || []; @@ -1353,6 +1357,7 @@ export async function getSkuDirectCosts( customer_code: customerCodeValue, quote_sheet_code: String(q.code || ''), title: q.title ? String(q.title) : null, + customer_name: q.customer_name ? String(q.customer_name) : null, sale_price: price, }); } diff --git a/server/tests/skuCostQuoteSheetReadonly.test.ts b/server/tests/skuCostQuoteSheetReadonly.test.ts index dd403db..21ad7f6 100644 --- a/server/tests/skuCostQuoteSheetReadonly.test.ts +++ b/server/tests/skuCostQuoteSheetReadonly.test.ts @@ -27,7 +27,7 @@ describe('成本排行只读报价单展示', () => { expect(types).toContain('sale_price_targets'); expect(page).toContain('quoteMin'); expect(page).toContain('quoteMax'); - expect(page).toContain("t('finance.cost.rank.sourceQuoteLabel'"); + expect(page).toContain("'finance.cost.rank.sourceQuoteLabel'"); expect(page).toContain("target.closest('input, button, a, label')"); expect(page).toContain("setExpandedSkuCode((cur) => (cur === sku.sku_code ? null : sku.sku_code))"); expect(page).not.toContain("t('finance.cost.rank.grossAmt')\n }`}"); diff --git a/src/i18n/locales/en/finance.ts b/src/i18n/locales/en/finance.ts index 115a9b8..c8dac32 100644 --- a/src/i18n/locales/en/finance.ts +++ b/src/i18n/locales/en/finance.ts @@ -152,6 +152,7 @@ export const finance: MessageDict = { 'cost.rank.sourceQuote': 'Quote sale price {price}', 'cost.rank.quoteSheets': 'Quote sheets', 'cost.rank.sourceCustomerSkuLabel': 'Product library', + 'cost.rank.currentSalePrice': 'Current price: ¥{amount}', 'cost.rank.priceTargets': 'Price targets', 'cost.rank.editSalePrice': 'Edit sale price', 'cost.rank.invalidSalePrice': 'Invalid sale price', diff --git a/src/i18n/locales/id/finance.ts b/src/i18n/locales/id/finance.ts index ffb654e..e2c2598 100644 --- a/src/i18n/locales/id/finance.ts +++ b/src/i18n/locales/id/finance.ts @@ -152,6 +152,7 @@ export const finance: MessageDict = { 'cost.rank.sourceQuote': 'Harga jual penawaran {price}', 'cost.rank.quoteSheets': 'Lembar penawaran', 'cost.rank.sourceCustomerSkuLabel': 'Katalog produk', + 'cost.rank.currentSalePrice': 'Harga saat ini: ¥{amount}', 'cost.rank.priceTargets': 'Target harga', 'cost.rank.editSalePrice': 'Ubah harga jual', 'cost.rank.invalidSalePrice': 'Harga jual tidak valid', diff --git a/src/i18n/locales/zh-CN/finance.ts b/src/i18n/locales/zh-CN/finance.ts index 5cc6ee9..8dc18f5 100644 --- a/src/i18n/locales/zh-CN/finance.ts +++ b/src/i18n/locales/zh-CN/finance.ts @@ -152,6 +152,7 @@ export const finance: MessageDict = { 'cost.rank.sourceQuote': '报价单 销售价 {price}', 'cost.rank.quoteSheets': '报价单', 'cost.rank.sourceCustomerSkuLabel': '商品库', + 'cost.rank.currentSalePrice': '当前销售价:¥{amount}', 'cost.rank.priceTargets': '价格目标', 'cost.rank.editSalePrice': '修改销售价', 'cost.rank.invalidSalePrice': '销售价无效', diff --git a/src/pages/finance/costAccounting/CostAccountingPanel.tsx b/src/pages/finance/costAccounting/CostAccountingPanel.tsx index 3bea863..7aec6d6 100644 --- a/src/pages/finance/costAccounting/CostAccountingPanel.tsx +++ b/src/pages/finance/costAccounting/CostAccountingPanel.tsx @@ -2936,94 +2936,104 @@ export const CostAccountingPanel: React.FC = ({ {rowExpanded ? ( -
-
-

{t('finance.cost.rank.skuCode')}

-

{sku.sku_code}

-
-
-

{t('finance.cost.col.category')}

-

{sku.category_name || '-'}

-
-
-

{t('finance.cost.col.quantity')}

-

{sku.quantity.toLocaleString()}

-
-
-

{t('finance.cost.col.revenue')}

-

¥{sku.sales_amount.toLocaleString()}

-
-
-

{t('finance.cost.col.purchaseCost')}

-

¥{sku.purchase_cost.toLocaleString()}

-
-
-

{t('finance.cost.rank.loss')}

-

¥{sku.loss_cost.toLocaleString()}

-
-
-

{t('finance.cost.rank.directTotal')}

-

¥{sku.total_cost.toLocaleString()}

-
+
{(sku.sale_price_targets?.length ?? 0) > 0 ? ( -
-

{t('finance.cost.rank.priceTargets')}

-
- {sku.sale_price_targets!.map((target) => { - const key = `${sku.sku_code}:${target.customer_code}`; - return ( -
- - {target.customer_name || target.customer_code} - {target.target_type === 'quote_sheet' - ? ` · ${target.title || target.quote_sheet_code || t('finance.cost.rank.sourceQuoteLabel')}` - : ` · ${t('finance.cost.rank.sourceCustomerSkuLabel')}`} - - e.stopPropagation()} - onKeyDown={(e) => { - if (e.key === 'Enter') e.currentTarget.blur(); - }} - onBlur={(e) => { - const input = e.currentTarget; - const old = Number(target.sale_price); - const next = Number(input.value); - if (input.value.trim() === '' || next === old) { - input.value = old.toFixed(2); - return; - } - void saveSkuPrice( - target.customer_code, - sku.sku_code, - input.value, - target.target_type, - target.quote_sheet_code - ).then((ok) => { - if (!ok) input.value = old.toFixed(2); - }); - }} - className="w-24 px-1 py-0.5 text-xs border rounded" - /> -
- ); - })} +
+ {sku.sale_price_targets!.map((target) => { + const key = `${sku.sku_code}:${target.customer_code}`; + return ( +
+ + {t( + target.target_type === 'quote_sheet' + ? 'finance.cost.rank.sourceQuoteLabel' + : 'finance.cost.rank.sourceCustomerSkuLabel' + )} + + + {target.target_type === 'quote_sheet' + ? `${target.title || target.quote_sheet_code || ''}${ + target.customer_name ? `(${target.customer_name})` : '' + }` + : target.customer_name || target.customer_code} + + + {t('finance.cost.rank.currentSalePrice', { + amount: Number(target.sale_price).toFixed(2), + })} + + e.stopPropagation()} + onKeyDown={(e) => { + if (e.key === 'Enter') e.currentTarget.blur(); + }} + onBlur={(e) => { + const input = e.currentTarget; + const old = Number(target.sale_price); + const next = Number(input.value); + if (input.value.trim() === '' || next === old) { + input.value = old.toFixed(2); + return; + } + void saveSkuPrice( + target.customer_code, + sku.sku_code, + input.value, + target.target_type, + target.quote_sheet_code + ).then((ok) => { + if (!ok) input.value = old.toFixed(2); + }); + }} + className="w-20 shrink-0 px-1 py-0.5 text-xs border rounded" + /> +
+ ); + })} +
+ ) : ( +
+
+

{t('finance.cost.rank.skuCode')}

+

{sku.sku_code}

+
+
+

{t('finance.cost.col.category')}

+

{sku.category_name || '-'}

+
+
+

{t('finance.cost.col.quantity')}

+

{sku.quantity.toLocaleString()}

+
+
+

{t('finance.cost.col.revenue')}

+

¥{sku.sales_amount.toLocaleString()}

+
+
+

{t('finance.cost.col.purchaseCost')}

+

¥{sku.purchase_cost.toLocaleString()}

+
+
+

{t('finance.cost.rank.loss')}

+

¥{sku.loss_cost.toLocaleString()}

+
+
+

{t('finance.cost.rank.directTotal')}

+

¥{sku.total_cost.toLocaleString()}

+
+
+

{t('finance.cost.rank.grossAmt')}

+

¥{sku.gross_profit.toLocaleString()}

- ) : null} -
-

{t('finance.cost.rank.grossAmt')}

-

- ¥{sku.gross_profit.toLocaleString()} -

-
+ )}
) : null}
diff --git a/src/pages/finance/costAccounting/types.ts b/src/pages/finance/costAccounting/types.ts index 259f817..44e594a 100644 --- a/src/pages/finance/costAccounting/types.ts +++ b/src/pages/finance/costAccounting/types.ts @@ -134,6 +134,7 @@ export interface SkuCostDetail { code: string; title: string | null; customer_code: string; + customer_name?: string | null; sale_price: number; }>; sale_price_targets?: Array<{