diff --git a/apps/web-antdv-next/src/views/mes/md/item/type/components/tree.vue b/apps/web-antdv-next/src/views/mes/md/item/type/components/tree.vue index 347e87b6a..acb3ad22b 100644 --- a/apps/web-antdv-next/src/views/mes/md/item/type/components/tree.vue +++ b/apps/web-antdv-next/src/views/mes/md/item/type/components/tree.vue @@ -54,8 +54,17 @@ function handleSearch(value: string) { } /** 处理节点点击:支持点击同一节点取消选中 */ -function handleSelect(_selectedKeys: any[], info: any) { - const row = info.node.dataRef as MesMdItemTypeApi.ItemType; +function handleSelect(selectedNodeKeys: any[], info: any) { + const selectedKey = selectedNodeKeys[0] ?? info.node?.id ?? info.node?.key; + const row = itemTypeList.value.find( + (item) => String(item.id) === String(selectedKey), + ); + if (!row) { + currentNodeId.value = undefined; + selectedKeys.value = []; + emit('nodeClick', undefined); + return; + } if (currentNodeId.value === row.id) { currentNodeId.value = undefined; selectedKeys.value = []; diff --git a/apps/web-antdv-next/src/views/system/dept/components/tree-select.vue b/apps/web-antdv-next/src/views/system/dept/components/tree-select.vue index cf66a0733..7054d3c82 100644 --- a/apps/web-antdv-next/src/views/system/dept/components/tree-select.vue +++ b/apps/web-antdv-next/src/views/system/dept/components/tree-select.vue @@ -38,8 +38,12 @@ function handleSearch(e: any) { } /** 选中部门:点击已选中的节点时取消选中 */ -function handleSelect(_selectedKeys: any[], info: any) { - emit('select', info.selected ? info.node.dataRef : undefined); +function handleSelect(selectedNodeKeys: any[], info: any) { + const selectedKey = selectedNodeKeys[0]; + const dept = info.selected + ? deptList.value.find((item) => String(item.id) === String(selectedKey)) + : undefined; + emit('select', dept); } /** 重置选中状态(供外部重置按钮调用) */ diff --git a/apps/web-antdv-next/src/views/system/user/modules/dept-tree.vue b/apps/web-antdv-next/src/views/system/user/modules/dept-tree.vue index beea3f314..48ffe69c4 100644 --- a/apps/web-antdv-next/src/views/system/user/modules/dept-tree.vue +++ b/apps/web-antdv-next/src/views/system/user/modules/dept-tree.vue @@ -32,8 +32,12 @@ function handleSearch(e: any) { } /** 选中部门 */ -function handleSelect(_selectedKeys: any[], info: any) { - emit('select', info.node.dataRef); +function handleSelect(selectedNodeKeys: any[], info: any) { + const selectedKey = selectedNodeKeys[0] ?? info.node?.id ?? info.node?.key; + const dept = info.selected + ? deptList.value.find((item) => String(item.id) === String(selectedKey)) + : undefined; + emit('select', dept); } /** 初始化 */ diff --git a/apps/web-antdv-next/src/views/wms/md/item/category/components/tree.vue b/apps/web-antdv-next/src/views/wms/md/item/category/components/tree.vue index 7954aea91..e682d58c9 100644 --- a/apps/web-antdv-next/src/views/wms/md/item/category/components/tree.vue +++ b/apps/web-antdv-next/src/views/wms/md/item/category/components/tree.vue @@ -55,8 +55,17 @@ function handleSearch(value: string) { } /** 处理节点点击:支持点击同一节点取消选中 */ -function handleSelect(_selectedKeys: any[], info: any) { - const row = info.node.dataRef as WmsItemCategoryApi.ItemCategory; +function handleSelect(selectedNodeKeys: any[], info: any) { + const selectedKey = selectedNodeKeys[0] ?? info.node?.id ?? info.node?.key; + const row = categoryList.value.find( + (item) => String(item.id) === String(selectedKey), + ); + if (!row) { + currentNodeId.value = undefined; + selectedKeys.value = []; + emit('nodeClick', undefined); + return; + } if (currentNodeId.value === row.id) { currentNodeId.value = undefined; selectedKeys.value = [];