From d8ff30d9ece53e006e5e58894461adeeb3b273e0 Mon Sep 17 00:00:00 2001 From: Netfan Date: Sat, 22 May 2021 22:36:19 +0800 Subject: [PATCH] fix(tree): onCheck event lose origin param (#636) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复Tree的onCheck事件缺少节点参数的问题 --- src/components/Tree/src/index.vue | 6 ++++-- src/components/Tree/src/types.ts | 4 +++- src/views/demo/tree/index.vue | 13 +++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/Tree/src/index.vue b/src/components/Tree/src/index.vue index 9d379a8d249..d21d7ff89fc 100644 --- a/src/components/Tree/src/index.vue +++ b/src/components/Tree/src/index.vue @@ -30,6 +30,8 @@ import { basicProps } from './props'; import { CreateContextOptions } from '/@/components/ContextMenu'; + import { CheckEvent } from './types'; + interface State { expandedKeys: Keys; selectedKeys: Keys; @@ -87,11 +89,11 @@ state.selectedKeys = v; emit('update:selectedKeys', v); }, - onCheck: (v: CheckKeys) => { + onCheck: (v: CheckKeys, e: CheckEvent) => { state.checkedKeys = v; const rawVal = toRaw(v); emit('update:value', rawVal); - emit('check', rawVal); + emit('check', rawVal, e); }, onRightClick: handleRightClick, }; diff --git a/src/components/Tree/src/types.ts b/src/components/Tree/src/types.ts index 4183f204934..a847e6f4fa6 100644 --- a/src/components/Tree/src/types.ts +++ b/src/components/Tree/src/types.ts @@ -1,4 +1,4 @@ -import type { TreeDataItem } from 'ant-design-vue/es/tree/Tree'; +import type { TreeDataItem, CheckEvent as CheckEventOrigin } from 'ant-design-vue/es/tree/Tree'; import { ContextMenuItem } from '/@/hooks/web/useContextMenu'; export interface ActionItem { render: (record: Recordable) => any; @@ -47,3 +47,5 @@ export interface ContextMenuOptions { styles?: any; items?: ContextMenuItem[]; } + +export type CheckEvent = CheckEventOrigin; diff --git a/src/views/demo/tree/index.vue b/src/views/demo/tree/index.vue index e82f8323cc5..c6ecea626a3 100644 --- a/src/views/demo/tree/index.vue +++ b/src/views/demo/tree/index.vue @@ -3,7 +3,13 @@
- +