统一寄卖仓库与提报审核规格展示
- 规格标签只显示值,0 璀璨不再显示「无」 - 仓库列表长规格文本改为纯值一行 - 列表物品名展示层清理历史 0 璀璨残留 - 补充规格展示回归测试
This commit is contained in:
@@ -72,6 +72,56 @@ export function formatLegacyConsignmentSpec(record: ConsignmentLegacySpecRecord)
|
||||
return parts.join(' / ')
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表用规格标签:只保留值,0 璀璨属于默认值,不占标签位。
|
||||
* 详情/审核弹窗需要字段名时仍用 resolveConsignmentSpecDisplayItems。
|
||||
*/
|
||||
export function resolveConsignmentSpecTagItems(
|
||||
specs: ConsignmentSpecField[] | null | undefined,
|
||||
values: ConsignmentSpecValues | null | undefined,
|
||||
): ConsignmentSpecDisplayItem[] {
|
||||
return resolveConsignmentSpecDisplayItems(specs, values).filter((item) => {
|
||||
if (item.key !== 'brillianceCount') return true
|
||||
if (item.value === '无') return false
|
||||
const raw = String(values?.[item.key] ?? '').trim()
|
||||
const numeric = Number(raw)
|
||||
return !(raw && Number.isFinite(numeric) && numeric <= 0)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表用纯值规格文本:不带字段名,方便和物品名并排扫读;0 璀璨省略。
|
||||
* 没有动态规格的历史数据回退旧 5 项(本身也是纯值)。
|
||||
*/
|
||||
export function resolveConsignmentSpecValueText(
|
||||
input: {
|
||||
specs?: ConsignmentSpecField[] | null
|
||||
specValues?: ConsignmentSpecValues | null
|
||||
} & ConsignmentLegacySpecRecord,
|
||||
options: { omitZeroBrilliance?: boolean } = {},
|
||||
): string {
|
||||
const items = options.omitZeroBrilliance
|
||||
? resolveConsignmentSpecTagItems(input.specs, input.specValues)
|
||||
: resolveConsignmentSpecDisplayItems(input.specs, input.specValues)
|
||||
if (items.length > 0) return items.map((item) => item.value).join(' / ')
|
||||
return formatLegacyConsignmentSpec(input)
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表展示用物品名:历史 0 璀璨数据会留下「N钻璀璨」这种断尾单位,
|
||||
* 只在展示层去掉,不改库;详情仍显示原始 item_name。
|
||||
* 只匹配「钻」后面紧跟的「璀璨」,避免误伤系列名里真实包含的「璀璨」。
|
||||
*/
|
||||
export function resolveConsignmentDisplayItemName(input: {
|
||||
itemName?: string | null
|
||||
brillianceCount?: number | null
|
||||
}): string {
|
||||
const name = String(input.itemName || '').trim()
|
||||
if (!name) return ''
|
||||
if (Number(input.brillianceCount || 0) > 0) return name
|
||||
return name.replace(/(\d+\s*钻)\s*(?:0\s*)?璀璨/g, '$1').trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情页规格文本:后端 specText 优先(已含选项名称),其次按模板现拼,最后回退旧字段。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user