feat(报价单): 重复商品行标红提示(含文案),并修正契约测试假绿断言
This commit is contained in:
@@ -117,6 +117,7 @@ export const quotes: MessageDict = {
|
||||
'form.col.saleYuan': 'Sale price (¥)',
|
||||
'form.col.saleRatio': 'Sale ratio (%)',
|
||||
'form.col.actions': 'Actions',
|
||||
'form.duplicateSku': 'Duplicate item (only the last row is submitted)',
|
||||
'form.skuPh': 'Search product name',
|
||||
'form.skuEmptyPh': 'No products available',
|
||||
'form.unitPh': 'jin',
|
||||
|
||||
@@ -120,6 +120,7 @@ export const quotes: MessageDict = {
|
||||
'form.col.saleYuan': 'Harga jual (¥)',
|
||||
'form.col.saleRatio': 'Rasio harga jual (%)',
|
||||
'form.col.actions': 'Aksi',
|
||||
'form.duplicateSku': 'Item duplikat (hanya baris terakhir yang dikirim)',
|
||||
'form.skuPh': 'Cari nama produk',
|
||||
'form.skuEmptyPh': 'Tidak ada produk',
|
||||
'form.unitPh': 'jin',
|
||||
|
||||
@@ -115,6 +115,7 @@ export const quotes: MessageDict = {
|
||||
'form.col.saleYuan': '销售价(元)',
|
||||
'form.col.saleRatio': '销售比例(%)',
|
||||
'form.col.actions': '操作',
|
||||
'form.duplicateSku': '重复商品(提交时只保留最后一行)',
|
||||
'form.skuPh': '搜索商品名称',
|
||||
'form.skuEmptyPh': '暂无商品可选',
|
||||
'form.unitPh': '斤',
|
||||
|
||||
@@ -16,9 +16,11 @@ describe('报价单页 · 双向价格传递接线', () => {
|
||||
expect(page).toContain("t('quotes.action.submitForDeliveryReview')");
|
||||
expect(page).toMatch(/\{isActiveSheet\(row\) && canManageQuotes && \(/);
|
||||
expect(page).toContain('submitQuotePriceProposalApi(row.quote_sheet_code)');
|
||||
expect(page).toContain("notify.success(t('quotes.toast.submittedForDeliveryReview'))");
|
||||
// 2026-10-19:提交成功后跳到统一的「供需变更审核」页
|
||||
expect(page).toMatch(/navigate\('\/customers\/supply-review'\)/);
|
||||
// 2026-10-20:成功提示改为按实际提交结果报数(提交 N 个 / 跳过 M 个无变化)
|
||||
expect(page).toContain("t('quotes.toast.submittedForDeliveryReviewCount'");
|
||||
// 2026-10-20:本仓库没有 /customers/supply-review 路由,提交后**不得**跳过去
|
||||
// (旧断言会匹配到注释里的字样,等于假绿;这里改为断言"不存在真实的 navigate 调用")
|
||||
expect(page).not.toMatch(/^\s*navigate\('\/customers\/supply-review'\)/m);
|
||||
expect(page).toContain("notify.error(error?.message || t('quotes.toast.submitForDeliveryFail'))");
|
||||
// 防连点:同一时刻只允许一条在途
|
||||
expect(page).toContain('submittingProposalCode');
|
||||
|
||||
@@ -233,6 +233,10 @@ interface QuoteLineEditorRowProps {
|
||||
line: QuoteLineDraft;
|
||||
skuOptions: SearchableSelectOption[];
|
||||
isFocused: boolean;
|
||||
/** 该行 SKU 在本次编辑里重复出现(2026-10-20:重复商品标红提示) */
|
||||
isDuplicateSku?: boolean;
|
||||
/** 重复提示文案(由父级用 t() 传入,memo 组件内部不持有 i18n) */
|
||||
duplicateLabel?: string;
|
||||
canRemove: boolean;
|
||||
skuPlaceholder: string;
|
||||
unitPlaceholder: string;
|
||||
@@ -249,6 +253,8 @@ const QuoteLineEditorRow = React.memo<QuoteLineEditorRowProps>(({
|
||||
line,
|
||||
skuOptions,
|
||||
isFocused,
|
||||
isDuplicateSku = false,
|
||||
duplicateLabel = '',
|
||||
canRemove,
|
||||
skuPlaceholder,
|
||||
unitPlaceholder,
|
||||
@@ -262,7 +268,13 @@ const QuoteLineEditorRow = React.memo<QuoteLineEditorRowProps>(({
|
||||
}) => (
|
||||
<tr
|
||||
data-quote-edit-sku={line.sku_code || undefined}
|
||||
className={isFocused ? 'bg-amber-50/80 dark:bg-amber-900/20' : undefined}
|
||||
className={
|
||||
isDuplicateSku
|
||||
? 'bg-red-50 dark:bg-red-950/40 ring-1 ring-inset ring-red-300 dark:ring-red-800'
|
||||
: isFocused
|
||||
? 'bg-amber-50/80 dark:bg-amber-900/20'
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<td className="px-3 py-2 align-top overflow-visible relative">
|
||||
<SearchableSelect
|
||||
@@ -277,6 +289,11 @@ const QuoteLineEditorRow = React.memo<QuoteLineEditorRowProps>(({
|
||||
portal
|
||||
portalZIndex={10100}
|
||||
/>
|
||||
{isDuplicateSku ? (
|
||||
<p className="mt-1 text-[11px] font-medium text-red-600 dark:text-red-400">
|
||||
{duplicateLabel}
|
||||
</p>
|
||||
) : null}
|
||||
</td>
|
||||
<td className="px-3 py-2 align-top min-w-[112px]">
|
||||
<input value={line.unit} onChange={(event) => onUpdate(line.key, { unit: event.target.value })} className={inputClass} placeholder={unitPlaceholder} />
|
||||
@@ -391,6 +408,22 @@ export const QuoteVersionManagement: React.FC = () => {
|
||||
const [selectedCustomers, setSelectedCustomers] = useState<CustomerOption[]>([]);
|
||||
const [form, setForm] = useState(initialForm);
|
||||
const [lines, setLines] = useState<QuoteLineDraft[]>([emptyLine()]);
|
||||
/**
|
||||
* 重复商品集合(2026-10-20 开发者需求:重复商品标红提示)。
|
||||
* 判定按 `sku_code`;出现 ≥2 次即标红 —— 提交时后端会按 SKU 去重只保留最后一行,
|
||||
* 所以这里必须提前让用户看到"哪几行是重复的"。
|
||||
*/
|
||||
const duplicateSkuSet = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
const dup = new Set<string>();
|
||||
for (const line of lines) {
|
||||
const code = String(line.sku_code || '').trim();
|
||||
if (!code) continue;
|
||||
if (seen.has(code)) dup.add(code);
|
||||
else seen.add(code);
|
||||
}
|
||||
return dup;
|
||||
}, [lines]);
|
||||
const [importingLines, setImportingLines] = useState(false);
|
||||
const [showExcelImportModal, setShowExcelImportModal] = useState(false);
|
||||
const { categoryRows } = useCategoryRows({ enabledOnly: false });
|
||||
@@ -1750,6 +1783,8 @@ export const QuoteVersionManagement: React.FC = () => {
|
||||
<QuoteLineEditorRow
|
||||
key={line.key}
|
||||
line={line}
|
||||
isDuplicateSku={duplicateSkuSet.has(String(line.sku_code || '').trim())}
|
||||
duplicateLabel={t('quotes.form.duplicateSku')}
|
||||
skuOptions={quoteSkuOptions}
|
||||
isFocused={!!focusSkuCode && line.sku_code === focusSkuCode}
|
||||
canRemove={lines.length > 1}
|
||||
|
||||
Reference in New Issue
Block a user