tribiani-vue-tools
数据结构 OrgTree 说明
778
| Install | |
|---|---|
npm install tribiani-vue-tools |
|
| Latest Version: | 0.0.40 |
| Vue: | 3 |
| Last Updated: | Nov 27, 2023 |
| Links: | npm |
Maintainer: shufei_han
tribiani-vue-tools
数据结构 OrgTree 说明
OrgTree 的数据结构如下:
export interface OrgTree<T = string | number> {
label?: string;
id?: T;
type?: string;
collapsed?: boolean;
hasChild?: boolean;
isEmpty?: boolean;
pid?: string;
children?: OrgTree<T>[];
}
注: 这里是这个组件定义的 OrgTree 这个数据类型,如果后端返回的数据结构和该数据结构有差别或者说关键的字段名称对不上,则可以通过在使用组件的时候传入 fieldNmaes 属性来实现数据结构的匹配。该参数的数据结构如下:
export interface OrgFieldNames {
id?: string;
label?: string;
children?: string;
type?: string;
isEmptyItem?: string;
}
我们可以对存在于改数据结构的属性名进行自定义,比如后台定义的子节点字段不是 children 而是 nodes,那么我们可以传入如下参数:
<OrgLaneChart :fieldNames="{children:'nodes'}"></OrgLaneChart>
其他字段以此类推。
但是这样子我们在用 data.nodes这种方式去访问 OrgTree 的属性时不会有语法提示,因此我们需要重新声明这个 interface:
declare module "tribiani-vue-tools" {
interface OrgTree {
nodes: OrgTree[];
}
}
同样的,如果后台又返回其他对前端有用的字段,都可以用同样的方式去声明。
props
| 属性 | 数据类型 | 是否必须 | 说明 |
|---|---|---|---|
| treeData | OrgTree[] | true | 传入的数据源 |
| fieldNames | FieldNames | false | FieldNames, 字段名配置,类似于 arco 封装的 tree 组件的 fieldNames 属性 |
| defaultDisplayedLevel | number | false | 默认展示多少层级,如果默认展开全部则不传该值 |
插槽
这个组件有提供很多插槽,插槽说明如下:
| 插槽名 | 参数传递 | 说明 |
|---|---|---|
| levelData | data | 该插槽是泳道图头部的 title,并且该插槽会把这条泳道的关键信息通过 data 属性传递过来。 |
| title | data | 该插槽是每个树节点的 title 部分,我们可以通过这个插槽来自定义 title,同样的,该插槽通过 data 属性将这个**节点的数据(类型为 OrgTree)**传递回来,供我们使用。 |
| content | data | 用于自定义每一项的内容区域,每一项的内容通过 data 参数传递过来。 |
| expand-icon | - | 用于自定义展开图标。 |
| collapse-icon | - | 用于自定义收起图标。 |
| 默认插槽 | data | 自定义整个节点,节点的数据内容通过 data 参数传递过来。注意:如果使用了默认不具名插槽,上面的插槽将无效。 |
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.0.40 | ^3.3.4 | ||
| 0.0.39 | ^3.3.4 | ||
| 0.0.38 | ^3.3.4 | ||
| 0.0.37 | ^3.3.4 | ||
| 0.0.36 | ^3.3.4 | ||
| 0.0.35 | ^3.3.4 | ||
| 0.0.34 | ^3.3.4 | ||
| 0.0.33 | ^3.3.4 | ||
| 0.0.32 | ^3.3.4 | ||
| 0.0.31 | ^3.3.4 | ||
| 0.0.30 | ^3.3.4 | ||
| 0.0.29 | ^3.3.4 | ||
| 0.0.28 | ^3.3.4 | ||
| 0.0.27 | ^3.3.4 | ||
| 0.0.26 | ^3.3.4 | ||
| 0.0.25 | ^3.3.4 | ||
| 0.0.24 | ^3.3.4 | ||
| 0.0.23 | ^3.3.4 | ||
| 0.0.22 | ^3.3.4 | ||
| 0.0.21 | ^3.3.4 | ||
| 0.0.20 | ^3.3.4 | ||
| 0.0.19 | ^3.3.4 | ||
| 0.0.18 | ^3.3.4 | ||
| 0.0.17 | ^3.3.4 | ||
| 0.0.16 | ^3.3.4 | ||
| 0.0.15 | ^3.3.4 | ||
| 0.0.14 | ^3.3.4 | ||
| 0.0.13 | ^3.3.4 | ||
| 0.0.12 | ^3.3.4 | ||
| 0.0.11 | ^3.3.4 |
Showing the latest 30 of 32. See every release on npm