diff --git a/src/components/order/OrderParsedItemRow.independentInbound.test.ts b/src/components/order/OrderParsedItemRow.independentInbound.test.ts new file mode 100644 index 0000000..86585f2 --- /dev/null +++ b/src/components/order/OrderParsedItemRow.independentInbound.test.ts @@ -0,0 +1,30 @@ +import { describe, expect, it } from 'vitest'; +import { readFileSync } from 'node:fs'; +import path from 'node:path'; + +/** + * 独立进货单不展示「销售价」输入框(开发者 2026-10-12:「选择了独立进货 你就别给他展示销售价输入框」)。 + * 用**可选开关**实现,只由录单页在"客户=独立进货"时传 true ⇒ 其它页面/其它客户不受影响。 + */ +const row = readFileSync(path.join(__dirname, 'OrderParsedItemRow.tsx'), 'utf8'); +const page = readFileSync(path.join(__dirname, '../../pages/orders/CustomerOrder.tsx'), 'utf8'); + +describe('录单页:独立进货隐藏销售价输入框', () => { + it('① 行组件有可选开关,且默认 false(不影响其它使用方)', () => { + expect(row).toContain('hidePriceInput?: boolean;'); + expect(row).toContain('hidePriceInput = false,'); + }); + + it('② 开关为真时不渲染价格输入(OrderItemPriceInput 在条件分支内)', () => { + const idx = row.indexOf('{hidePriceInput ? null : ('); + expect(idx).toBeGreaterThan(-1); + const body = row.slice(idx, idx + 600); + expect(body).toContain('OrderItemPriceInput'); + // 金额(只读展示)仍在 + expect(row).toContain('¥{formatOrderAmount(item.amount)}'); + }); + + it('③ 录单页按"客户=独立进货"传开关', () => { + expect(page).toContain('hidePriceInput={isIndependentInboundCustomer(selectedCustomer?.customer_code)}'); + }); +}); diff --git a/src/components/order/OrderParsedItemRow.tsx b/src/components/order/OrderParsedItemRow.tsx index fbe5040..d030f27 100644 --- a/src/components/order/OrderParsedItemRow.tsx +++ b/src/components/order/OrderParsedItemRow.tsx @@ -48,6 +48,11 @@ export interface OrderParsedItemRowProps { onStartEditQuantity: (id: string, quantity: number) => void; onUnitChange: (id: string, unit: string) => void; onPriceChange: (id: string, price: number) => void; + /** + * 不渲染「销售价」输入框(2026-10-12 开发者:独立进货单**没有销售价**,别给他展示这一栏)。 + * 只由录单页在"客户=独立进货"时传 true;其它页面/其它客户行为不变(默认 false)。 + */ + hidePriceInput?: boolean; /** 可选:售价 blur 时回调(商品档案已无销售价字段,录单页可不传) */ onPriceCommit?: (skuCode: string, price: number) => void; onProcessingMethodChange?: (id: string, method: string) => void; @@ -90,6 +95,7 @@ const OrderParsedItemRowInner: React.FC = ({ onStartEditQuantity, onUnitChange, onPriceChange, + hidePriceInput = false, onPriceCommit, onProcessingMethodChange, onProcessingOwnerChange, @@ -392,16 +398,18 @@ const OrderParsedItemRowInner: React.FC = ({ title={t('orders.unit')} placeholder={t('orders.unit')} /> -
- onPriceChange(item.id, price)} - onPriceCommit={ - onPriceCommit ? (price) => onPriceCommit(item.skuCode, price) : undefined - } - normalClassName={isCustomer ? undefined : 'app-input focus:ring-black text-xs'} - /> -
+ {hidePriceInput ? null : ( +
+ onPriceChange(item.id, price)} + onPriceCommit={ + onPriceCommit ? (price) => onPriceCommit(item.skuCode, price) : undefined + } + normalClassName={isCustomer ? undefined : 'app-input focus:ring-black text-xs'} + /> +
+ )} ¥{formatOrderAmount(item.amount)} diff --git a/src/pages/orders/CustomerOrder.tsx b/src/pages/orders/CustomerOrder.tsx index 2ac4731..e4a12ac 100644 --- a/src/pages/orders/CustomerOrder.tsx +++ b/src/pages/orders/CustomerOrder.tsx @@ -2536,6 +2536,8 @@ export const CustomerOrder: React.FC = () => { onUnitChange={updateItemUnit} onRemarkChange={updateItemRemark} onPriceChange={updateItemPrice} + // 独立进货:没有销售价,不展示价格输入框(金额仍显示,恒为 0) + hidePriceInput={isIndependentInboundCustomer(selectedCustomer?.customer_code)} onProcessingMethodChange={updateItemProcessingMethod} onProcessingOwnerChange={updateItemProcessingOwner} onProcessUnitPriceChange={updateItemProcessUnitPrice}