Browse Source
fix(tree): onCheck event lose origin param (#636)
修复Tree的onCheck事件缺少节点参数的问题
pull/640/head
Netfan
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
18 additions and
5 deletions
-
src/components/Tree/src/index.vue
-
src/components/Tree/src/types.ts
-
src/views/demo/tree/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, |
|
|
|
}; |
|
|
|
|
|
|
|
@ -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; |
|
|
|
|
|
|
|
@ -3,7 +3,13 @@ |
|
|
|
<div class="flex"> |
|
|
|
<BasicTree :treeData="treeData" title="基础示例" class="w-1/3" /> |
|
|
|
|
|
|
|
<BasicTree :treeData="treeData" title="可勾选" :checkable="true" class="w-1/3 mx-4" /> |
|
|
|
<BasicTree |
|
|
|
:treeData="treeData" |
|
|
|
title="可勾选" |
|
|
|
:checkable="true" |
|
|
|
class="w-1/3 mx-4" |
|
|
|
@check="handleCheck" |
|
|
|
/> |
|
|
|
|
|
|
|
<BasicTree |
|
|
|
title="默认展开/勾选示例" |
|
|
|
@ -25,7 +31,10 @@ |
|
|
|
export default defineComponent({ |
|
|
|
components: { BasicTree, PageWrapper }, |
|
|
|
setup() { |
|
|
|
return { treeData }; |
|
|
|
function handleCheck(checkedKeys, e) { |
|
|
|
console.log('onChecked', checkedKeys, e); |
|
|
|
} |
|
|
|
return { treeData, handleCheck }; |
|
|
|
}, |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|