mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-24 02:00:22 +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 { 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>
|
||||
|
Loading…
Reference in New Issue
Block a user