fix(consignment): 修复寄卖层级树默认展开不生效
This commit is contained in:
@@ -31,7 +31,9 @@ type TemplateOption = {
|
||||
}
|
||||
|
||||
type TemplateTreeNode = {
|
||||
key: string
|
||||
// rc-tree 以节点的 value 作为内部 key(fieldNames.key 默认指向 value),
|
||||
// 自定义 key 必须与 value 完全一致,否则 treeExpandedKeys 无法命中。
|
||||
key: number
|
||||
value: number
|
||||
title: string
|
||||
selectable: boolean
|
||||
@@ -188,7 +190,7 @@ export default function ConsignmentTemplateCopyModal({
|
||||
const root = group.root
|
||||
const rootLabel = root?.label || group.groupName || '未命名分类'
|
||||
const childNodes: TemplateTreeNode[] = group.children.map((option) => ({
|
||||
key: `child-${option.value}`,
|
||||
key: option.value,
|
||||
value: option.value,
|
||||
title: option.label,
|
||||
selectable: true,
|
||||
@@ -199,7 +201,7 @@ export default function ConsignmentTemplateCopyModal({
|
||||
if (root && childNodes.length === 0) {
|
||||
return [
|
||||
{
|
||||
key: `root-${root.value}`,
|
||||
key: root.value,
|
||||
value: root.value,
|
||||
title: root.label,
|
||||
selectable: true,
|
||||
@@ -212,7 +214,7 @@ export default function ConsignmentTemplateCopyModal({
|
||||
if (!root) {
|
||||
if (childNodes.length === 0) return []
|
||||
const groupNode: TemplateTreeNode = {
|
||||
key: `group-${group.groupCategoryId}`,
|
||||
key: -group.groupCategoryId,
|
||||
value: -group.groupCategoryId,
|
||||
title: rootLabel,
|
||||
selectable: false,
|
||||
@@ -224,7 +226,7 @@ export default function ConsignmentTemplateCopyModal({
|
||||
}
|
||||
return [
|
||||
{
|
||||
key: `group-${group.groupCategoryId}`,
|
||||
key: root.value,
|
||||
value: root.value,
|
||||
title: root.label,
|
||||
selectable: !root.disabled,
|
||||
@@ -237,7 +239,7 @@ export default function ConsignmentTemplateCopyModal({
|
||||
})
|
||||
}, [options, categoryNames])
|
||||
const treeGroupKeys = useMemo(
|
||||
() => treeData.filter((node) => node.children?.length).map((node) => node.key),
|
||||
() => treeData.filter((node) => node.children?.length).map((node) => node.value),
|
||||
[treeData],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user