mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-24 10:33:47 +08:00
fix(tree): onCheck event lose origin param (#636)
修复Tree的onCheck事件缺少节点参数的问题
This commit is contained in:
parent
3ef5087be6
commit
d8ff30d9ec
@ -30,6 +30,8 @@
|
|||||||
import { basicProps } from './props';
|
import { basicProps } from './props';
|
||||||
import { CreateContextOptions } from '/@/components/ContextMenu';
|
import { CreateContextOptions } from '/@/components/ContextMenu';
|
||||||
|
|
||||||
|
import { CheckEvent } from './types';
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
expandedKeys: Keys;
|
expandedKeys: Keys;
|
||||||
selectedKeys: Keys;
|
selectedKeys: Keys;
|
||||||
@ -87,11 +89,11 @@
|
|||||||
state.selectedKeys = v;
|
state.selectedKeys = v;
|
||||||
emit('update:selectedKeys', v);
|
emit('update:selectedKeys', v);
|
||||||
},
|
},
|
||||||
onCheck: (v: CheckKeys) => {
|
onCheck: (v: CheckKeys, e: CheckEvent) => {
|
||||||
state.checkedKeys = v;
|
state.checkedKeys = v;
|
||||||
const rawVal = toRaw(v);
|
const rawVal = toRaw(v);
|
||||||
emit('update:value', rawVal);
|
emit('update:value', rawVal);
|
||||||
emit('check', rawVal);
|
emit('check', rawVal, e);
|
||||||
},
|
},
|
||||||
onRightClick: handleRightClick,
|
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';
|
import { ContextMenuItem } from '/@/hooks/web/useContextMenu';
|
||||||
export interface ActionItem {
|
export interface ActionItem {
|
||||||
render: (record: Recordable) => any;
|
render: (record: Recordable) => any;
|
||||||
@ -47,3 +47,5 @@ export interface ContextMenuOptions {
|
|||||||
styles?: any;
|
styles?: any;
|
||||||
items?: ContextMenuItem[];
|
items?: ContextMenuItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CheckEvent = CheckEventOrigin;
|
||||||
|
@ -3,7 +3,13 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<BasicTree :treeData="treeData" title="基础示例" class="w-1/3" />
|
<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
|
<BasicTree
|
||||||
title="默认展开/勾选示例"
|
title="默认展开/勾选示例"
|
||||||
@ -25,7 +31,10 @@
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { BasicTree, PageWrapper },
|
components: { BasicTree, PageWrapper },
|
||||||
setup() {
|
setup() {
|
||||||
return { treeData };
|
function handleCheck(checkedKeys, e) {
|
||||||
|
console.log('onChecked', checkedKeys, e);
|
||||||
|
}
|
||||||
|
return { treeData, handleCheck };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user