From 74a30cd78d49af51204e5fce0d62a04bf127b873 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Wed, 25 Nov 2026 09:57:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=A5=E4=BB=B7=E8=A1=A8=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=9B=BD=E5=AE=B6=E5=AD=90=E5=8C=BA=E4=B8=8E=E5=B7=A6?= =?UTF-8?q?=E5=BC=80=E5=8F=B3=E9=97=AD=E9=87=8D=E9=87=8F=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 国家列续填并拼澳大利亚一区等子区;按行生成重量段并消掉 0.301 类微间隙,避免跨国串段。 Co-authored-by: Cursor --- .../skills/oms-channel-quote-extract/SKILL.md | 3 +- .../pricingWorkbench/channelQuoteAiSkill.ts | 30 +++- .../pricingWorkbench/channelQuoteApply.ts | 162 ++++++++++------- .../pricingWorkbench/channelQuoteCandidate.ts | 52 ++++-- .../channelQuoteLocalParse.ts | 163 ++++++++++++++++-- .../components/ChannelQuoteImportPanel.vue | 20 ++- 6 files changed, 330 insertions(+), 100 deletions(-) diff --git a/.cursor/skills/oms-channel-quote-extract/SKILL.md b/.cursor/skills/oms-channel-quote-extract/SKILL.md index 575b4b3..0dd6007 100644 --- a/.cursor/skills/oms-channel-quote-extract/SKILL.md +++ b/.cursor/skills/oms-channel-quote-extract/SKILL.md @@ -62,8 +62,9 @@ description: >- ### 重量 -- 区间 `0-0.1` / `0.101-0.2` → `weightStart` + `weightEnd` +- 区间 `0-0.1` / `0.101-0.2` → `weightStart` + `weightEnd`(按表内原样提取即可) - 单点一口价 `0.5` → 至少填 `weightEnd=0.5`;`weightStart` 可留空由前端按有序上界补成 `(prev-end]` +- OMS 存左开右闭:前端会把 `0.05-0.3` + `0.301-1` 收成 `(0.05-0.3]`、`(0.3-1]` - 不要输出偏远邮编清单或条款长文 ## 硬规则 diff --git a/src/views/channel/pricingWorkbench/channelQuoteAiSkill.ts b/src/views/channel/pricingWorkbench/channelQuoteAiSkill.ts index efc454e..4cdc8eb 100644 --- a/src/views/channel/pricingWorkbench/channelQuoteAiSkill.ts +++ b/src/views/channel/pricingWorkbench/channelQuoteAiSkill.ts @@ -54,9 +54,12 @@ const SKILL_CORE = `你是 OMS「渠道报价表提取」助手:从单个 Exce - flat:一口价(包裹重量点/段 → 总价),填 flatTotal;freightPerKg/handling* 为 null - unit_plus_fee:运费 RMB/KG + 处理费/挂号费 RMB/票,填 freightPerKg / handlingPerShipment / registrationPerShipment -## 重量 +## 重量与分区 - 区间 0-0.1 → weightStart=0, weightEnd=0.1 - 单点 0.5 → 至少 weightEnd=0.5;weightStart 可空 +- 表内写成 0.05-0.3 / 0.301-1 时,仍按单元格提取起止;前端会收成左开右闭连续段 (0.05-0.3]、(0.3-1] +- 国家列向下合并时要续填;澳大利亚旁有「一区/二区」时 zoneHint 写成「澳大利亚一区」「澳大利亚二区」 +- 各国重量段互不借用:英国不要输出澳大利亚的 0.02-0.25 ## JSON schema { @@ -349,6 +352,28 @@ export type WorkbookSheetPreview = { colCount: number } +/** 裁掉 Excel 错误 used-range 造成的超宽空列(如 A1:XDT48) */ +function trimSparseMatrixColumns( + matrix: (string | number | null)[][], +): (string | number | null)[][] { + if (!matrix?.length) return matrix + let last = 0 + const probe = Math.min(matrix.length, 80) + for (let r = 0; r < probe; r++) { + const row = matrix[r] || [] + for (let c = 0; c < row.length; c++) { + const v = row[c] + if (v != null && String(v).trim() !== '') last = Math.max(last, c) + } + } + const width = last + 1 + if (width <= 0) return [] + // 仅当明显稀疏膨胀时裁剪 + const maxLen = matrix.reduce((m, r) => Math.max(m, (r || []).length), 0) + if (maxLen <= width + 8) return matrix + return matrix.map((r) => (r || []).slice(0, width)) +} + /** 浏览器端解析 xlsx → 各 sheet 预览 */ export async function parseQuoteWorkbook(file: File | ArrayBuffer): Promise { const XLSX = await import('xlsx') @@ -357,11 +382,12 @@ export async function parseQuoteWorkbook(file: File | ArrayBuffer): Promise 0 && + start > fallbackPrevEnd && + start - fallbackPrevEnd <= WEIGHT_SEGMENT_MICRO_GAP + ) { + start = fallbackPrevEnd + } + if (!(end > start)) { + start = end > fallbackPrevEnd ? fallbackPrevEnd : 0 + if (!(end > start)) start = 0 + } + return formatWeightIntervalLeftOpenRightClosed(start, end) +} + +/** + * 将报价行重量规范为有序区间列表 (start-end]。 + * 按分区各自保留声明起止,再并集去重——避免英国吃到澳大利亚的 (0.02-0.25]。 + */ export function buildWeightIntervalsFromQuoteRows( rows: ChannelQuotePriceRow[], ): { intervals: string[]; ends: number[] } { - const ends = [ - ...new Set( - rows - .map((r) => Number(r.weightEnd)) - .filter((n) => Number.isFinite(n) && n > 0), - ), - ].sort((a, b) => a - b) + const byZone = new Map() + for (const r of rows || []) { + const z = String(r.zoneHint || '').trim() || '_' + if (!byZone.has(z)) byZone.set(z, []) + byZone.get(z)!.push(r) + } - const intervals = ends.map((end, idx) => { - // 优先使用同行声明的 start(按 end 匹配最近一行) - const withStart = rows.find( - (r) => - Number(r.weightEnd) === end && - r.weightStart != null && - Number.isFinite(Number(r.weightStart)), - ) - const start = - withStart != null - ? Number(withStart.weightStart) - : idx > 0 - ? ends[idx - 1]! - : 0 - return formatWeightIntervalLeftOpenRightClosed(start, end) + const intervalList: string[] = [] + const ends: number[] = [] + const pushInterval = (seg: string) => { + if (intervalList.includes(seg)) return + const bounds = parseWeightIntervalBounds(seg) + if (!bounds) return + intervalList.push(seg) + if (!ends.some((e) => nearlyEqualWeight(e, bounds.end))) ends.push(bounds.end) + } + + for (const [, zoneRows] of byZone) { + const sorted = [...zoneRows].sort((a, b) => Number(a.weightEnd) - Number(b.weightEnd)) + let prevEnd = 0 + for (const row of sorted) { + const seg = formatQuoteRowWeightSegment(row, prevEnd) + if (!seg) continue + pushInterval(seg) + const bounds = parseWeightIntervalBounds(seg) + if (bounds) prevEnd = bounds.end + } + } + + intervalList.sort((a, b) => { + const pa = parseWeightIntervalBounds(a) + const pb = parseWeightIntervalBounds(b) + if (pa && pb) { + if (pa.end !== pb.end) return pa.end - pb.end + return pa.start - pb.start + } + return a.localeCompare(b, 'zh', { numeric: true }) }) - return { intervals, ends } + ends.sort((a, b) => a - b) + return { intervals: intervalList, ends } } function parseFactorValuesJson(raw: unknown): Record { @@ -348,42 +402,32 @@ export function buildChannelPriceApplyPreview(input: { : [null] for (const zoneValue of zones) { - const zoneHint = - zoneMaps.find((z) => z.zoneValue === zoneValue)?.zoneHint || - zoneLabelOf(zoneMaps, zoneValue) - for (const weightSegment of weightIntervals) { + const zoneMap = + zoneMaps.find((z) => z.zoneValue === zoneValue) || + null + const zoneHint = zoneMap?.zoneHint || zoneLabelOf(zoneMaps, zoneValue) + const zoneRows = (quote.rows || []).filter((r) => { + const rh = String(r.zoneHint || '').trim() + if (!rh) return false + if (!zoneMap) return false + return ( + zoneMap.zoneHint === rh || + zoneMap.zoneLabel.includes(rh) || + rh.includes(zoneMap.zoneLabel) || + zoneMap.zoneHint.includes(rh) + ) + }) + const sortedZoneRows = [...zoneRows].sort( + (a, b) => Number(a.weightEnd) - Number(b.weightEnd), + ) + let prevEnd = 0 + for (const picked of sortedZoneRows) { + const weightSegment = formatQuoteRowWeightSegment(picked, prevEnd) + if (!weightSegment) continue + const bounds = parseWeightIntervalBounds(weightSegment) + if (bounds) prevEnd = bounds.end + for (const cargo of cargos) { - const bounds = parseWeightIntervalBounds(weightSegment) - const quoteRows = quote.rows.filter((r) => { - const end = Number(r.weightEnd) - if (!bounds || !Number.isFinite(end)) return false - if (Math.abs(end - bounds.end) > 1e-9) return false - const rh = String(r.zoneHint || quote.destinationHints?.[0] || '').trim() - if (!rh) return true - // 行 zoneHint 需能映射到当前 zoneValue - const mapHit = zoneMaps.find( - (z) => - z.zoneValue === zoneValue && - (z.zoneHint === rh || - z.zoneLabel.includes(rh) || - rh.includes(z.zoneLabel) || - z.zoneHint.includes(rh)), - ) - return Boolean(mapHit) || (!zoneMaps.length && !rh) - }) - // 若按 zoneHint 滤空,放宽:任意同重量行 - const candidates = - quoteRows.length > 0 - ? quoteRows - : quote.rows.filter((r) => { - const end = Number(r.weightEnd) - return bounds && Number.isFinite(end) && Math.abs(end - bounds.end) < 1e-9 - }) - - // 子类型:若报价带 serviceSubtype 且当前 cargo 不匹配则跳过金额(保留空?)——首期同一 cargo 绑定写全段 - const picked = candidates[0] - if (!picked) continue - const { value, formula } = resolveAmountForItem(kind, quote.mode, picked) if (value == null) continue diff --git a/src/views/channel/pricingWorkbench/channelQuoteCandidate.ts b/src/views/channel/pricingWorkbench/channelQuoteCandidate.ts index 7582969..932288f 100644 --- a/src/views/channel/pricingWorkbench/channelQuoteCandidate.ts +++ b/src/views/channel/pricingWorkbench/channelQuoteCandidate.ts @@ -6,6 +6,7 @@ import type { ChannelQuoteExtracted, ChannelQuoteMode } from './channelQuoteAiSk import { buildWeightIntervalsFromQuoteRows, collectZoneHints, + formatQuoteRowWeightSegment, type CostItemKind, } from './channelQuoteApply' @@ -149,21 +150,32 @@ export function buildCandidateBuyPrice(card: QuoteModelCard): CandidateBuyPrice const pushKind = (kind: CostItemKind, label: string, code: string) => { const cells: CandidateFeeCell[] = [] - for (const weightSegment of intervals) { + // 按行生成:分区各自用自己的重量起止,避免英国吃到澳大利亚段 + const prevEndByZone = new Map() + const zoneOrder = zoneHints.length ? zoneHints : [defaultZone] + const rowsSorted = [...(quote.rows || [])].sort((a, b) => { + const za = String(a.zoneHint || defaultZone).trim() || defaultZone + const zb = String(b.zoneHint || defaultZone).trim() || defaultZone + const zi = zoneOrder.indexOf(za) + const zj = zoneOrder.indexOf(zb) + const zcmp = + (zi < 0 ? 999 : zi) - (zj < 0 ? 999 : zj) || za.localeCompare(zb, 'zh') + if (zcmp !== 0) return zcmp + return Number(a.weightEnd) - Number(b.weightEnd) + }) + for (const row of rowsSorted) { + const zh = String(row.zoneHint || defaultZone).trim() || defaultZone + const prev = prevEndByZone.get(zh) ?? 0 + const weightSegment = formatQuoteRowWeightSegment(row, prev) + if (!weightSegment) continue const bounds = parseWeightIntervalBounds(weightSegment) - if (!bounds) continue - for (const row of quote.rows || []) { - const end = Number(row.weightEnd) - if (!Number.isFinite(end) || Math.abs(end - bounds.end) > 1e-6) continue - const zh = String(row.zoneHint || defaultZone).trim() || defaultZone - const cell = cellFor(kind, quote.mode, zh, weightSegment, row) - if (!cell) continue - // 同 zone+weight 去重保留首个 - if (cells.some((c) => c.zoneHint === cell.zoneHint && c.weightSegment === cell.weightSegment)) { - continue - } - cells.push(cell) + if (bounds) prevEndByZone.set(zh, bounds.end) + const cell = cellFor(kind, quote.mode, zh, weightSegment, row) + if (!cell) continue + if (cells.some((c) => c.zoneHint === cell.zoneHint && c.weightSegment === cell.weightSegment)) { + continue } + cells.push(cell) } if (!cells.length) return const formula = cells[0]!.formula @@ -216,7 +228,12 @@ export function candidateDisplayFullTitle(c: CandidateBuyPrice): string { return sub ? `${name}(${sub})` : String(name) } -/** 候选明细展平,供表格预览 */ +function weightSegmentSortKey(seg: string): number { + const bounds = parseWeightIntervalBounds(seg) + return bounds?.end ?? Number.POSITIVE_INFINITY +} + +/** 候选明细展平,供表格预览(同费用项内:国家 → 重量段) */ export function flattenCandidateCells(c: CandidateBuyPrice): Array<{ feeLabel: string kind: CostItemKind @@ -245,5 +262,12 @@ export function flattenCandidateCells(c: CandidateBuyPrice): Array<{ }) } } + rows.sort((a, b) => { + if (a.feeLabel !== b.feeLabel) return a.feeLabel.localeCompare(b.feeLabel, 'zh') + if (a.zoneHint !== b.zoneHint) return a.zoneHint.localeCompare(b.zoneHint, 'zh') + const dw = weightSegmentSortKey(a.weightSegment) - weightSegmentSortKey(b.weightSegment) + if (dw !== 0) return dw + return a.weightSegment.localeCompare(b.weightSegment, 'zh', { numeric: true }) + }) return rows } diff --git a/src/views/channel/pricingWorkbench/channelQuoteLocalParse.ts b/src/views/channel/pricingWorkbench/channelQuoteLocalParse.ts index 9e95a26..645ece3 100644 --- a/src/views/channel/pricingWorkbench/channelQuoteLocalParse.ts +++ b/src/views/channel/pricingWorkbench/channelQuoteLocalParse.ts @@ -49,25 +49,103 @@ function parseWeightBounds(raw: Cell): { start: number | null; end: number } | n if (typeof raw === 'number' && Number.isFinite(raw) && raw > 0) { return { start: null, end: raw } } - const s = cellStr(raw).replace(/,/g, '').replace(/kg/gi, '').trim() + let s = cellStr(raw) + .replace(/,/g, '') + .replace(/(/g, '(') + .replace(/)/g, ')') + .replace(/kg|公斤|千克/gi, '') + .replace(/\s+/g, '') + .trim() if (!s) return null + // ≤0.5 / <0.5 / 0.5以下 / 0.5以内 + const upperOnly = s.match(/^(?:≤|<=|<|<)?(\d+(?:\.\d+)?)(?:以下|以内|及以下)?$/) + if (upperOnly && /≤|<=|<|<|以下|以内/.test(s)) { + const end = Number(upperOnly[1]) + if (Number.isFinite(end) && end > 0) return { start: 0, end } + } const range = s.match(/^(\d+(?:\.\d+)?)\s*[-~~—–到至]\s*(\d+(?:\.\d+)?)$/) if (range) { const a = Number(range[1]) const b = Number(range[2]) if (!Number.isFinite(a) || !Number.isFinite(b) || b <= 0) return null - return { start: a, end: b } + return { start: Math.min(a, b), end: Math.max(a, b) } } const n = Number(s) if (!Number.isFinite(n) || n <= 0) return null return { start: null, end: n } } +/** 真正的重量列表头(排除「重量KG/分区」这类轴标题;保留「分区/重量段」) */ +function isWeightHeader(h: string): boolean { + if (!h) return false + if (/重量段/.test(h)) return true + if (/重量kg.?分区|重量.?分区|分区.?重量/.test(h)) return false + return /包裹重量|计费重量|^重量kg$|^重量$/.test(h) +} + +/** 一区 / Zone1 等国家内子分区 */ +function looksLikeSubZoneLabel(raw: string): boolean { + const s = cellStr(raw).trim() + if (!s || s.length > 12) return false + if (/^[一二三四五六七八九十]+区$/.test(s)) return true + if (/^\d+区$/.test(s)) return true + if (/^Zone\s*\d+$/i.test(s)) return true + if (/^[A-D]区$/i.test(s)) return true + return false +} + +function composeZoneHint(country: string, subZone: string): string { + const c = country.trim() + const s = subZone.trim() + if (!c) return s + if (!s) return c + if (c.includes(s) || s.includes(c)) return c.length >= s.length ? c : s + return `${c}${s}` +} + +/** 国家旁空列 /「分区」列:数据里出现多次「一区」则视为子分区列 */ +function findSubZoneColumn( + matrix: Matrix, + headerIndex: number, + map: RoleMap, + countryIdx: number, + weightIdx: number, +): number { + const header = matrix[headerIndex] || [] + const probeEnd = Math.min(matrix.length, headerIndex + 80) + let best = -1 + let bestHits = 0 + for (let c = 0; c < Math.max(header.length, 12); c++) { + if (c === countryIdx || c === weightIdx) continue + const role = map.roles[c] || 'ignore' + if (role !== 'ignore' && role !== 'country') continue + if (role === 'country' && c === countryIdx) continue + const h = normHeader(header[c]) + if (h && /重量|运费|挂号|处理|操作|对接|时效|备注|说明/.test(h)) continue + let hits = 0 + for (let r = headerIndex + 1; r < probeEnd; r++) { + if (looksLikeSubZoneLabel(cellStr(matrix[r]?.[c]))) hits += 1 + } + const headerBonus = h && /^(分区|子区|区域|zone)$/.test(h) ? 2 : 0 + const emptyHeaderBonus = !h && countryIdx >= 0 && Math.abs(c - countryIdx) === 1 ? 1 : 0 + const score = hits + headerBonus + emptyHeaderBonus + if (hits >= 2 && score > bestHits) { + bestHits = score + best = c + } + } + return best +} + +function isSectionTitleCountry(raw: string): boolean { + return /渠道说明|计费方式|走货属性|禁限运|附加费|返回目录|备注说明/.test(raw) +} + function isHeaderLike(h: string): boolean { if (!h) return false return ( /对接代码|渠道代码|渠道编码|产品代码|服务代码/.test(h) || - /重量段|包裹重量|计费重量|重量kg|^重量$/.test(h) || + isWeightHeader(h) || /运费|处理费|操作费|挂号费|一口价|总价/.test(h) || /国家名称|^国家$|目的地|分区|zone/.test(h) ) @@ -86,7 +164,7 @@ type ColRole = function classifyHeader(h: string): ColRole { if (!h) return 'ignore' if (/对接代码|渠道代码|渠道编码|产品代码|服务代码/.test(h)) return 'dock' - if (/重量段|包裹重量|计费重量|重量kg|^重量$/.test(h)) return 'weight' + if (isWeightHeader(h)) return 'weight' if (/挂号费/.test(h)) return 'registration' if (/处理费|操作费/.test(h)) return 'handling' if (/运费/.test(h) && (/kg|公斤|千克/.test(h) || /rmb\/?kg|元\/?kg/.test(h))) return 'freightKg' @@ -97,13 +175,15 @@ function classifyHeader(h: string): ColRole { return 'ignore' } -/** 国家/分区名:短中文或常见英文区名,且不是表头关键字 */ +/** 国家/分区名:短中文或常见英文区名,且不是表头关键字 / 说明文案 */ function looksLikeZoneName(raw: string): boolean { const s = cellStr(raw) if (!s || s.length > 24) return false if (isHeaderLike(normHeader(s))) return false if (/^(pak|wpx|doc|信封|文件)$/i.test(s.trim())) return false if (/条款|附加费|操作指南|目录|邮编/.test(s)) return false + // 服务说明 / 非国家列 + if (/妥投|自然日|工作日|住宅|含.*费|时效|尺寸|要求|属性|走货|参考/.test(s)) return false // 纯数字不当 zone if (/^[\d.\-]+$/.test(s)) return false return /[\u4e00-\u9fffA-Za-z]/.test(s) @@ -192,13 +272,16 @@ function findHeaderRow(matrix: Matrix): { index: number; map: RoleMap } | null { if (map.roles.includes('handling')) score += 3 if (map.roles.includes('flat') || map.zoneByCol.size) score += 3 if (map.roles.includes('country')) score += 2 - score += map.roles.filter((r) => r === 'weight').length + const weightCols = map.roles.filter((r) => r === 'weight').length + score += weightCols * 2 + // 并排「包裹重量|国家|…|包裹重量|国家」明显优于「重量KG/分区」轴标题行 + if (weightCols >= 2) score += 3 if (!best || score > best.score) best = { index: i, map, score } } return best ? { index: best.index, map: best.map } : null } -/** 公斤+票费:对接代码 + 重量段 + 运费/处理费 */ +/** 公斤+票费:对接代码 + 重量段 + 运费/处理费(支持国家列向下填充 + 澳大利亚一区) */ function parseUnitPlusFee( matrix: Matrix, sheetName: string, @@ -215,6 +298,8 @@ function parseUnitPlusFee( if (weightIdx < 0) return null if (freightIdx < 0 && handlingIdx < 0 && regIdx < 0) return null + const subZoneIdx = findSubZoneColumn(matrix, headerIndex, map, countryIdx, weightIdx) + type Bucket = { code: string name: string | null @@ -229,6 +314,8 @@ function parseUnitPlusFee( 'UNKNOWN' let currentSubtype: string | null = null let currentName: string | null = null + let currentCountry = '' + let currentSubZone = '' const ensure = (code: string) => { const key = `${code}::${currentSubtype || ''}` @@ -259,13 +346,40 @@ function parseUnitPlusFee( currentName = dock } } + + if (countryIdx >= 0) { + const rawCountry = cellStr(row[countryIdx]) + if (rawCountry) { + if (isSectionTitleCountry(rawCountry)) break + if (!looksLikeSubZoneLabel(rawCountry)) { + currentCountry = rawCountry + currentSubZone = '' + } else if (!currentCountry) { + // 极少见:国家列直接写「一区」 + currentSubZone = rawCountry + } + } + } + if (subZoneIdx >= 0) { + const rawSub = cellStr(row[subZoneIdx]) + if (rawSub && looksLikeSubZoneLabel(rawSub)) { + currentSubZone = rawSub + } + } + const w = parseWeightBounds(row[weightIdx]) if (!w) continue const freight = freightIdx >= 0 ? cellNum(row[freightIdx]) : null const handling = handlingIdx >= 0 ? cellNum(row[handlingIdx]) : null const registration = regIdx >= 0 ? cellNum(row[regIdx]) : null if (freight == null && handling == null && registration == null) continue - const zone = countryIdx >= 0 ? cellStr(row[countryIdx]) || null : null + + const zone = + countryIdx >= 0 || subZoneIdx >= 0 + ? composeZoneHint(currentCountry, currentSubZone) || null + : null + if (!zone && countryIdx >= 0) continue + const b = ensure(currentCode) if (zone) b.destinations.add(zone) b.rows.push({ @@ -322,22 +436,30 @@ function parseFlatBlocks( let i = 0 while (i < headers.length) { const h = normHeader(headers[i]) - if (/重量段|包裹重量|计费重量|重量kg|^重量$/.test(h)) { + if (isWeightHeader(h)) { const priceCols: Array<{ col: number; zone: string }> = [] let j = i + 1 while (j < headers.length) { const hj = normHeader(headers[j]) - if (/重量段|包裹重量|计费重量|重量kg|^重量$/.test(hj)) break + if (isWeightHeader(hj)) break const zoneRaw = cellStr(headers[j]) const role = classifyHeader(hj) if (role === 'ignore' && looksLikeZoneName(zoneRaw)) { priceCols.push({ col: j, zone: zoneRaw }) } else if (role === 'flat' || role === 'country') { - // 「一口价」列:zone 可能在上一格或 sheet 名 - priceCols.push({ - col: j, - zone: role === 'country' ? '' : zoneRaw || guessZoneFromSheet(sheetName) || '默认', - }) + // 「一口价」列:zone 可能在上一格或 sheet 名;假 zone(说明文案)跳过 + const zone = + role === 'country' + ? '' + : looksLikeZoneName(zoneRaw) + ? zoneRaw + : guessZoneFromSheet(sheetName) || '默认' + // buildRoleMap 可能把说明列标成 flat,这里再拦一次 + if (role === 'flat' && zoneRaw && !looksLikeZoneName(zoneRaw) && !/一口价|总价|报价|单价|价格|金额/.test(hj)) { + j += 1 + continue + } + priceCols.push({ col: j, zone }) } else if (role !== 'ignore') { break } @@ -449,6 +571,7 @@ function parseFlatLong( const codeHint = guessChannelCodeFromSheetName(sheetName) let currentSubtype: string | null = null + let currentCountry = '' const rows: ChannelQuoteRowRow[] = [] for (let r = headerIndex + 1; r < matrix.length; r++) { @@ -459,12 +582,20 @@ function parseFlatLong( currentSubtype = subtype continue } + if (countryIdx >= 0) { + const rawCountry = cellStr(row[countryIdx]) + if (rawCountry) { + if (isSectionTitleCountry(rawCountry)) break + currentCountry = rawCountry + } + } const w = parseWeightBounds(row[weightIdx]) if (!w) continue if (countryIdx >= 0 && flatIdx >= 0) { - const zone = cellStr(row[countryIdx]) || null + const zone = currentCountry || null const price = cellNum(row[flatIdx]) if (price == null) continue + if (!zone) continue rows.push({ weightStart: w.start, weightEnd: w.end, diff --git a/src/views/channel/pricingWorkbench/components/ChannelQuoteImportPanel.vue b/src/views/channel/pricingWorkbench/components/ChannelQuoteImportPanel.vue index d4932e3..24ba11e 100644 --- a/src/views/channel/pricingWorkbench/components/ChannelQuoteImportPanel.vue +++ b/src/views/channel/pricingWorkbench/components/ChannelQuoteImportPanel.vue @@ -266,11 +266,10 @@ {{ activeCandidate.feeItems.length }} 个费用项 · {{ activeCandidate.weightIntervals.length }} 个重量段
- 重量段 - + 重量段({{ activeCandidate.weightIntervals.length }}) + {{ w }} - …
  • {{ w }}
  • @@ -1705,14 +1704,16 @@ onMounted(() => { .cq-upload-dragger { width: 100%; height: 100%; - min-height: 72px; + min-height: 96px; border: 1px dashed #c9cdd4; border-radius: 8px; background: #f7f8fa; display: flex; + flex-direction: column; align-items: center; - gap: 10px; - padding: 8px 12px; + justify-content: center; + gap: 6px; + padding: 12px 16px; cursor: pointer; transition: all 0.2s; box-sizing: border-box; @@ -1723,12 +1724,14 @@ onMounted(() => { } } .cq-upload-content { - flex: 1; + width: 100%; min-width: 0; - text-align: left; + text-align: center; } .cq-upload-excel-icon { + display: block; flex-shrink: 0; + margin: 0 auto; filter: drop-shadow(0 3px 8px rgba(22, 142, 45, 0.16)); } .cq-upload-text { @@ -1761,6 +1764,7 @@ onMounted(() => { margin-top: 4px; display: flex; align-items: center; + justify-content: center; gap: 4px; } .cq-native-file-input {