refactor(admin): split GoodsView into dialog components; fix(GoodsView): raw member names, no primary badges, member price grid; feat(tag): 光板 maps to 不打印
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { CategoryTree } from '@/types'
|
||||
|
||||
/** 在分类树中找目标分类的祖先路径(含自身) */
|
||||
export function findCategoryPath(nodes: CategoryTree[], targetId: string): string[] {
|
||||
for (const n of nodes) {
|
||||
if (n.id === targetId) return [n.id]
|
||||
if (n.children?.length) {
|
||||
const sub = findCategoryPath(n.children, targetId)
|
||||
if (sub.length) return [n.id, ...sub]
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
export interface CascadeNode {
|
||||
value: string
|
||||
label: string
|
||||
children?: CascadeNode[]
|
||||
}
|
||||
|
||||
/** 分类树 → el-cascader 选项 */
|
||||
export function buildCascader(tree: CategoryTree[]): CascadeNode[] {
|
||||
return tree.map((n) => ({
|
||||
value: n.id,
|
||||
label: n.categoryName,
|
||||
children: n.children?.length ? buildCascader(n.children) : undefined,
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user