diff --git a/server/src/services/skuMappingService.ts b/server/src/services/skuMappingService.ts index 4fd7f1c..57b0360 100644 --- a/server/src/services/skuMappingService.ts +++ b/server/src/services/skuMappingService.ts @@ -433,10 +433,28 @@ export async function listLocalSkuMappings(input: { LIMIT $${params.length}`, params ); + /** + * FE-3(2026-10-19):summary 必须与**当前筛选**(status/keyword)同口径, + * 否则「只看未映射」时表头仍显示全表数字。WHERE 与上面的列表查询逐条一致、参数同序。 + */ + const countParams: unknown[] = []; + const countWhere: string[] = []; + if (status) { + countParams.push(status); + countWhere.push(`status = $${countParams.length}`); + } + if (keyword) { + countParams.push(`%${keyword}%`); + countWhere.push( + `(supplier_sku_code ILIKE $${countParams.length} OR supplier_sku_name ILIKE $${countParams.length} OR delivery_sku_code ILIKE $${countParams.length} OR delivery_sku_name ILIKE $${countParams.length})` + ); + } const counts = await pool.query<{ total: number; mapped: number }>( `SELECT count(*)::int AS total, count(*) FILTER (WHERE status = 'active' AND delivery_sku_code IS NOT NULL)::int AS mapped - FROM main_system_sku_mappings` + FROM main_system_sku_mappings + ${countWhere.length ? `WHERE ${countWhere.join(' AND ')}` : ''}`, + countParams ); const total = Number(counts.rows[0]?.total) || 0; const mapped = Number(counts.rows[0]?.mapped) || 0; @@ -587,6 +605,13 @@ export async function bindMappingForDeliverySku(input: { const deliverySkuName = remote && remote.delivery_sku_name != null ? String(remote.delivery_sku_name) : null; await runWithTenantDbContext(branchCode, async () => { + // 改绑:同一配送 SKU 原先挂在别的我方 SKU 上时,先把旧镜像行清空(partial unique 要求同一时刻只有一个 active) + await pool.query( + `UPDATE main_system_sku_mappings + SET status = 'pending', delivery_sku_code = NULL, delivery_sku_name = NULL, updated_at = NOW() + WHERE delivery_sku_code = $1 AND supplier_sku_code <> $2`, + [deliverySkuCode, supplierSkuCode] + ); await pool.query( `INSERT INTO main_system_sku_mappings (supplier_sku_code, supplier_sku_name, supplier_unit, delivery_sku_code, delivery_sku_name, status, synced_at, updated_at) diff --git a/src/i18n/locales/en/quotes.ts b/src/i18n/locales/en/quotes.ts index 04cad52..f5cc3b0 100644 --- a/src/i18n/locales/en/quotes.ts +++ b/src/i18n/locales/en/quotes.ts @@ -190,6 +190,7 @@ export const quotes: MessageDict = { 'priceProposal.col.itemCount': 'Items', 'priceProposal.col.status': 'Status', 'priceProposal.col.priceChange': 'Before → After', + 'priceProposal.action.remap': 'Change mapping', 'priceProposal.action.pickProduct': 'Pick item', 'priceProposal.autoMatched': 'Auto-matched: {name}', 'priceProposal.action.useSuggestion': 'Use', diff --git a/src/i18n/locales/id/quotes.ts b/src/i18n/locales/id/quotes.ts index 0e245e8..64a594b 100644 --- a/src/i18n/locales/id/quotes.ts +++ b/src/i18n/locales/id/quotes.ts @@ -195,6 +195,7 @@ export const quotes: MessageDict = { 'priceProposal.col.itemCount': 'Item', 'priceProposal.col.status': 'Status', 'priceProposal.col.priceChange': 'Sebelum → Sesudah', + 'priceProposal.action.remap': 'Ubah pemetaan', 'priceProposal.action.pickProduct': 'Pilih item', 'priceProposal.autoMatched': 'Cocok otomatis: {name}', 'priceProposal.action.useSuggestion': 'Pakai', diff --git a/src/i18n/locales/zh-CN/quotes.ts b/src/i18n/locales/zh-CN/quotes.ts index 6ed8109..1b437f4 100644 --- a/src/i18n/locales/zh-CN/quotes.ts +++ b/src/i18n/locales/zh-CN/quotes.ts @@ -186,6 +186,7 @@ export const quotes: MessageDict = { 'priceProposal.col.itemCount': '商品数', 'priceProposal.col.status': '状态', 'priceProposal.col.priceChange': '原价 → 新价', + 'priceProposal.action.remap': '改映射', 'priceProposal.action.pickProduct': '选择商品', 'priceProposal.autoMatched': '自动匹配:{name}', 'priceProposal.action.useSuggestion': '采用', diff --git a/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx b/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx index e92b5e9..473760f 100644 --- a/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx +++ b/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx @@ -409,6 +409,19 @@ export const QuoteDeliveryPriceProposalsPanel: React.FC {line.supplier_sku_code || line.sku_code} + {canApprove && line.delivery_sku_code ? ( + + ) : null} )}