feat(录单/独立进货): 不展示「销售价」输入框(开发者 2026-10-12)
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s

开发者:「选择了独立进货 你就别给他展示销售价输入框」。

实现(共享组件用**可选开关**,不动其它使用方):
  · `OrderParsedItemRow` 新增 `hidePriceInput?: boolean`(默认 false)——为真时**不渲染**
    `OrderItemPriceInput`,金额(只读)仍显示(恒为 ¥0.00);
  · 录单页只在"客户=独立进货"时传 `hidePriceInput`;其它页面/其它客户行为完全不变。

顺带解决界面上的一处噪声:独立进货的销售价恒为 0,此前那个输入框一直显示**红框必填态**。

测试:新增 OrderParsedItemRow.independentInbound(3 例)+ i18n 42 例 全绿;前端 tsc ✅。
This commit is contained in:
Ubuntu
2026-10-13 08:51:11 +08:00
parent 734641b502
commit 594509eb04
3 changed files with 50 additions and 10 deletions
@@ -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)}');
});
});
+18 -10
View File
@@ -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<OrderParsedItemRowProps> = ({
onStartEditQuantity,
onUnitChange,
onPriceChange,
hidePriceInput = false,
onPriceCommit,
onProcessingMethodChange,
onProcessingOwnerChange,
@@ -392,16 +398,18 @@ const OrderParsedItemRowInner: React.FC<OrderParsedItemRowProps> = ({
title={t('orders.unit')}
placeholder={t('orders.unit')}
/>
<div className="shrink-0 w-[4.5rem]" title={t('orders.unitPrice')}>
<OrderItemPriceInput
price={item.price}
onPriceChange={(price) => onPriceChange(item.id, price)}
onPriceCommit={
onPriceCommit ? (price) => onPriceCommit(item.skuCode, price) : undefined
}
normalClassName={isCustomer ? undefined : 'app-input focus:ring-black text-xs'}
/>
</div>
{hidePriceInput ? null : (
<div className="shrink-0 w-[4.5rem]" title={t('orders.unitPrice')}>
<OrderItemPriceInput
price={item.price}
onPriceChange={(price) => onPriceChange(item.id, price)}
onPriceCommit={
onPriceCommit ? (price) => onPriceCommit(item.skuCode, price) : undefined
}
normalClassName={isCustomer ? undefined : 'app-input focus:ring-black text-xs'}
/>
</div>
)}
<span className="app-foreground-muted text-xs tabular-nums shrink-0 w-14 text-right" title={t('orders.subtotal')}>
¥{formatOrderAmount(item.amount)}
</span>
+2
View File
@@ -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}