|
@@ -1,41 +1,65 @@
|
|
<template>
|
|
<template>
|
|
<PageWrapper title="Tree函数操作示例">
|
|
<PageWrapper title="Tree函数操作示例">
|
|
- <div class="flex">
|
|
|
|
- <BasicTree
|
|
|
|
- class="w-1/3"
|
|
|
|
- title="右侧操作按钮/自定义图标"
|
|
|
|
- helpMessage="帮助信息"
|
|
|
|
- :treeData="treeData"
|
|
|
|
- :actionList="actionList"
|
|
|
|
- :renderIcon="createIcon"
|
|
|
|
- />
|
|
|
|
- <BasicTree
|
|
|
|
- class="w-1/3 mx-4"
|
|
|
|
- title="右键菜单"
|
|
|
|
- :treeData="treeData"
|
|
|
|
- :beforeRightClick="getRightMenuList"
|
|
|
|
- />
|
|
|
|
- <BasicTree
|
|
|
|
- class="w-1/3"
|
|
|
|
- title="工具栏使用"
|
|
|
|
- toolbar
|
|
|
|
- checkable
|
|
|
|
- search
|
|
|
|
- :treeData="treeData"
|
|
|
|
- :beforeRightClick="getRightMenuList"
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
|
|
+ <Row :gutter="[16, 16]">
|
|
|
|
+ <Col :span="8">
|
|
|
|
+ <BasicTree
|
|
|
|
+ title="右侧操作按钮/自定义图标"
|
|
|
|
+ helpMessage="帮助信息"
|
|
|
|
+ :treeData="treeData"
|
|
|
|
+ :actionList="actionList"
|
|
|
|
+ :renderIcon="createIcon"
|
|
|
|
+ />
|
|
|
|
+ </Col>
|
|
|
|
+ <Col :span="8">
|
|
|
|
+ <BasicTree title="右键菜单" :treeData="treeData" :beforeRightClick="getRightMenuList" />
|
|
|
|
+ </Col>
|
|
|
|
+ <Col :span="8">
|
|
|
|
+ <BasicTree
|
|
|
|
+ title="工具栏使用"
|
|
|
|
+ toolbar
|
|
|
|
+ checkable
|
|
|
|
+ search
|
|
|
|
+ :treeData="treeData"
|
|
|
|
+ :beforeRightClick="getRightMenuList"
|
|
|
|
+ />
|
|
|
|
+ </Col>
|
|
|
|
+ <Col :span="8">
|
|
|
|
+ <BasicTree title="没有fieldNames,插槽有效" helpMessage="正确的示例" :treeData="treeData3">
|
|
|
|
+ <template #title="item"> 插槽:{{ item.name }} </template>
|
|
|
|
+ </BasicTree>
|
|
|
|
+ </Col>
|
|
|
|
+ <Col :span="8">
|
|
|
|
+ <BasicTree
|
|
|
|
+ title="有fieldNames后,插槽失效"
|
|
|
|
+ helpMessage="错误的示例, 应该显示插槽的内容才对"
|
|
|
|
+ :fieldNames="{ key: 'id', title: 'name' }"
|
|
|
|
+ :treeData="treeData2"
|
|
|
|
+ >
|
|
|
|
+ <template #title="item"> 插槽:{{ item.title }} </template>
|
|
|
|
+ </BasicTree>
|
|
|
|
+ </Col>
|
|
|
|
+ <Col :span="8">
|
|
|
|
+ <BasicTree
|
|
|
|
+ title="有fieldNames后,actionList失效"
|
|
|
|
+ helpMessage="错误的示例,应该在鼠标移上去时,显示新增和删除按钮才对"
|
|
|
|
+ :treeData="treeData3"
|
|
|
|
+ :actionList="actionList"
|
|
|
|
+ :fieldNames="{ key: 'key', title: 'name' }"
|
|
|
|
+ />
|
|
|
|
+ </Col>
|
|
|
|
+ </Row>
|
|
</PageWrapper>
|
|
</PageWrapper>
|
|
</template>
|
|
</template>
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
import { defineComponent, h } from 'vue';
|
|
import { defineComponent, h } from 'vue';
|
|
- import { BasicTree, ActionItem, ContextMenuItem } from '/@/components/Tree/index';
|
|
|
|
- import { treeData } from './data';
|
|
|
|
|
|
+ import { Row, Col } from 'ant-design-vue';
|
|
|
|
+ import { BasicTree, TreeActionItem, ContextMenuItem } from '/@/components/Tree/index';
|
|
|
|
+ import { treeData, treeData2, treeData3 } from './data';
|
|
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
|
import { PageWrapper } from '/@/components/Page';
|
|
import { PageWrapper } from '/@/components/Page';
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
- components: { BasicTree, PageWrapper },
|
|
|
|
|
|
+ components: { BasicTree, PageWrapper, Row, Col },
|
|
setup() {
|
|
setup() {
|
|
function handlePlus(node: any) {
|
|
function handlePlus(node: any) {
|
|
console.log(node);
|
|
console.log(node);
|
|
@@ -59,7 +83,7 @@
|
|
},
|
|
},
|
|
];
|
|
];
|
|
}
|
|
}
|
|
- const actionList: ActionItem[] = [
|
|
|
|
|
|
+ const actionList: TreeActionItem[] = [
|
|
{
|
|
{
|
|
// show:()=>boolean;
|
|
// show:()=>boolean;
|
|
render: (node) => {
|
|
render: (node) => {
|
|
@@ -90,7 +114,7 @@
|
|
}
|
|
}
|
|
return '';
|
|
return '';
|
|
}
|
|
}
|
|
- return { treeData, actionList, getRightMenuList, createIcon };
|
|
|
|
|
|
+ return { treeData, treeData2, treeData3, actionList, getRightMenuList, createIcon };
|
|
},
|
|
},
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|