feat(admin): expandable family members with per-link tag config + SKU pricing dims columns
This commit is contained in:
@@ -52,6 +52,35 @@ export function cleanLinkName(name: string | null | undefined): string {
|
||||
|
||||
const CRAFT_KEYWORDS = ['直喷', '不打印', '光板'] as const;
|
||||
|
||||
/** 链接的定价维度(SKU 表展示用):物流备注 / 工艺 / 印花数量 */
|
||||
export interface LinkDims {
|
||||
logistics: string | null;
|
||||
crafts: string[];
|
||||
printCount: string | null;
|
||||
}
|
||||
|
||||
/** 从链接名称解析定价维度;工艺无命中时默认烫画(与派生标签规则一致) */
|
||||
export function linkDims(name: string | null | undefined): LinkDims {
|
||||
if (!name) return { logistics: null, crafts: [], printCount: null };
|
||||
const head = name.split('-')[0] ?? '';
|
||||
const openCandidates = [head.indexOf('('), head.indexOf('(')].filter((i) => i >= 0);
|
||||
const openIdx = openCandidates.length ? Math.min(...openCandidates) : -1;
|
||||
const closeIdx = Math.max(head.lastIndexOf(')'), head.lastIndexOf(')'));
|
||||
const logistics =
|
||||
openIdx >= 0 && closeIdx > openIdx ? head.slice(openIdx + 1, closeIdx).trim() || null : null;
|
||||
const craftHits = CRAFT_KEYWORDS.filter((k) => name.includes(k));
|
||||
const printCount = name.includes('双面印花')
|
||||
? '双面印花'
|
||||
: name.includes('单面印花')
|
||||
? '单面印花'
|
||||
: null;
|
||||
return {
|
||||
logistics,
|
||||
crafts: craftHits.length > 0 ? craftHits : ['烫画'],
|
||||
printCount,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 由链接名称派生标签名(与 api 端 auto-tag-rules.ts 规则一致,仅用于成员行只读展示):
|
||||
* 印花数量:双面印花 优先于 单面印花;工艺:直喷/不打印/光板,皆无则默认烫画;
|
||||
|
||||
Reference in New Issue
Block a user