Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tree): onCheck event lose origin param. fixed: #315 #636

Merged
merged 1 commit into from
May 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/Tree/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import { basicProps } from './props';
import { CreateContextOptions } from '/@/components/ContextMenu';

import { CheckEvent } from './types';

interface State {
expandedKeys: Keys;
selectedKeys: Keys;
Expand Down Expand Up @@ -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,
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/Tree/src/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -47,3 +47,5 @@ export interface ContextMenuOptions {
styles?: any;
items?: ContextMenuItem[];
}

export type CheckEvent = CheckEventOrigin;
13 changes: 11 additions & 2 deletions src/views/demo/tree/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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="默认展开/勾选示例"
Expand All @@ -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>