feat(web-admin): choose display name and brand constraint on quote/contract lines
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ba98108659
commit
cd33befa07
7 files changed
+360
-11
No files matched your search
@@ -0,0 +1,70 @@
|
||||
/** CRM 产品行:展示名 / 品牌约定(报价、合同共用) */
|
||||
|
||||
export type BrandOption = { id: string; brandName: string }
|
||||
|
||||
export function buildProductNameOptions(
|
||||
standardName?: string | null,
|
||||
aliases?: Array<{ aliasName?: string } | null> | null
|
||||
): string[] {
|
||||
const names = [String(standardName || '').trim()]
|
||||
for (const a of aliases || []) {
|
||||
const n = String(a?.aliasName || '').trim()
|
||||
if (n) names.push(n)
|
||||
}
|
||||
return [...new Set(names.filter(Boolean))]
|
||||
}
|
||||
|
||||
export function formatBrandConstraintLabel(
|
||||
brandMode?: string | null,
|
||||
brandName?: string | null
|
||||
): string {
|
||||
if (!brandMode) return '—'
|
||||
if (brandMode === 'required') return String(brandName || '').trim() || '—'
|
||||
if (brandMode === 'any') return '不限品牌'
|
||||
return '—'
|
||||
}
|
||||
|
||||
export function initLineBrandMetaFromProduct(product: {
|
||||
productName?: string
|
||||
brands?: Array<{ id?: string; brandName?: string; status?: string }>
|
||||
aliases?: Array<{ aliasName?: string }>
|
||||
}) {
|
||||
const brands = (product.brands || []).filter((b) => (b.status || 'on') === 'on' && b.id && b.brandName)
|
||||
const standardProductName = String(product.productName || '').trim()
|
||||
return {
|
||||
standardProductName,
|
||||
nameOptions: buildProductNameOptions(standardProductName, product.aliases),
|
||||
brandOptions: brands.map((b) => ({
|
||||
id: String(b.id),
|
||||
brandName: String(b.brandName)
|
||||
})) as BrandOption[],
|
||||
brandMode: brands.length ? ('any' as const) : undefined,
|
||||
brandId: undefined as string | undefined,
|
||||
brandName: undefined as string | undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function applyBrandModeChange(
|
||||
row: {
|
||||
brandMode?: string
|
||||
brandId?: string
|
||||
brandName?: string
|
||||
},
|
||||
mode: string | undefined
|
||||
) {
|
||||
row.brandMode = mode
|
||||
if (mode !== 'required') {
|
||||
row.brandId = undefined
|
||||
row.brandName = undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function applyBrandSelectChange(
|
||||
row: { brandId?: string; brandName?: string },
|
||||
brandId: string | undefined,
|
||||
options: BrandOption[]
|
||||
) {
|
||||
row.brandId = brandId
|
||||
const hit = options.find((o) => o.id === brandId)
|
||||
row.brandName = hit?.brandName
|
||||
}
|
||||
Reference in new issue
Block a user