@robot-admin/naive-ui-components 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +3 -1
- package/README_EN.md +3 -1
- package/dist/C_OrgChart.cjs +1 -1
- package/dist/C_OrgChart.css +67 -158
- package/dist/C_OrgChart.d.cts +22 -2
- package/dist/C_OrgChart.d.ts +22 -2
- package/dist/C_OrgChart.js +1 -1
- package/dist/C_OrgChart2.cjs +1 -1
- package/dist/C_OrgChart2.js +1 -1
- package/dist/C_Table.d.cts +1 -1
- package/dist/C_Table.d.ts +1 -1
- package/dist/C_Tree.d.cts +2 -2
- package/dist/C_Tree.d.ts +2 -2
- package/dist/C_Tree2.cjs +1 -1
- package/dist/C_Tree2.js +1 -1
- package/dist/constants.d.cts +3 -3
- package/dist/constants.d.ts +3 -3
- package/dist/constants2.d.cts +2 -2
- package/dist/constants2.d.ts +2 -2
- package/dist/constants4.d.cts +5 -5
- package/dist/constants4.d.ts +5 -5
- package/dist/data2.d.cts +4 -4
- package/dist/data2.d.ts +4 -4
- package/dist/editors.d.cts +36 -19
- package/dist/editors.d.ts +36 -19
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +23 -22
- package/dist/index.d.ts +23 -22
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +4 -4
- package/dist/index.vue.d.ts +4 -4
- package/dist/index10.vue.d.cts +2 -2
- package/dist/index10.vue.d.ts +1 -1
- package/dist/index11.vue.d.cts +1 -1
- package/dist/index11.vue.d.ts +4 -4
- package/dist/index12.vue.d.cts +4 -4
- package/dist/index13.vue.d.ts +4 -4
- package/dist/index14.vue.d.cts +4 -4
- package/dist/index16.vue.d.ts +3 -3
- package/dist/index17.vue.d.cts +3 -3
- package/dist/index17.vue.d.ts +5 -5
- package/dist/index18.vue.d.cts +5 -5
- package/dist/index18.vue.d.ts +2 -2
- package/dist/index19.vue.d.cts +2 -2
- package/dist/index20.vue.d.ts +1 -1
- package/dist/index21.vue.d.cts +1 -1
- package/dist/index21.vue.d.ts +5 -5
- package/dist/index22.vue.d.cts +5 -5
- package/dist/index22.vue.d.ts +2 -2
- package/dist/index23.vue.d.cts +76 -43
- package/dist/index23.vue.d.ts +76 -43
- package/dist/index24.vue.d.cts +1 -1
- package/dist/index24.vue.d.ts +1 -1
- package/dist/index28.vue.d.cts +1 -1
- package/dist/index28.vue.d.ts +1 -1
- package/dist/index3.vue.d.cts +3 -3
- package/dist/index3.vue.d.ts +3 -3
- package/dist/index30.vue.d.cts +1 -1
- package/dist/index30.vue.d.ts +1 -1
- package/dist/index31.vue.d.cts +5 -5
- package/dist/index31.vue.d.ts +5 -5
- package/dist/index32.vue.d.cts +2 -2
- package/dist/index32.vue.d.ts +2 -2
- package/dist/index4.vue.d.cts +4 -4
- package/dist/index4.vue.d.ts +4 -4
- package/dist/index6.vue.d.cts +2 -2
- package/dist/index7.vue.d.ts +2 -2
- package/dist/index8.vue.d.cts +2 -2
- package/dist/index8.vue.d.ts +3 -3
- package/dist/index9.vue.d.cts +3 -3
- package/dist/index9.vue.d.ts +2 -2
- package/dist/mapUtils.d.cts +2 -2
- package/dist/mapUtils.d.ts +2 -2
- package/dist/style.css +67 -158
- package/dist/useCalendarEvents.d.cts +1 -1
- package/dist/useCalendarEvents.d.ts +1 -1
- package/dist/useCollapsePanel.d.cts +2 -2
- package/dist/useCollapsePanel.d.ts +2 -2
- package/dist/useComponentLocale.cjs +1 -1
- package/dist/useComponentLocale.js +1 -1
- package/dist/useCropperCore.d.cts +7 -7
- package/dist/useCropperCore.d.ts +7 -7
- package/dist/useDynamicFormState.d.cts +2 -2
- package/dist/useDynamicFormState.d.ts +2 -2
- package/dist/useEdgeInteraction.d.cts +2 -2
- package/dist/useEdgeInteraction.d.ts +2 -2
- package/dist/useFullscreen.d.cts +2 -2
- package/dist/useFullscreen.d.ts +2 -2
- package/dist/useInfiniteScroll.d.cts +1 -1
- package/dist/useInfiniteScroll.d.ts +1 -1
- package/dist/useQRCode.d.cts +3 -3
- package/dist/useQRCode.d.ts +3 -3
- package/dist/useSignatureHistory.d.cts +4 -4
- package/dist/useSignatureHistory.d.ts +4 -4
- package/dist/useSplitResize.d.cts +9 -9
- package/dist/useSplitResize.d.ts +9 -9
- package/dist/useWorkflowValidation.d.cts +7 -7
- package/dist/useWorkflowValidation.d.ts +7 -7
- package/dist/verification.d.cts +4 -4
- package/dist/verification.d.ts +4 -4
- package/docs/guides/org-chart.md +133 -0
- package/docs/guides/tree-org-examples.md +145 -0
- package/docs/guides/tree.en.md +50 -0
- package/docs/guides/tree.md +53 -1
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# C_OrgChart:组织卡片与汇报关系
|
|
2
|
+
|
|
3
|
+
`C_OrgChart` 展示单根、单父级的组织树:部门、负责人、岗位和下级关系。卡片布局、视窗和连线由组件管理。部门目录、授权勾选和虚拟滚动使用 `C_Tree mode="org"`;部门/人员表单选择使用 TreeSelect、Select 或 DataPicker。
|
|
4
|
+
|
|
5
|
+
## 最小接入
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { C_OrgChart } from '@robot-admin/naive-ui-components/C_OrgChart'
|
|
10
|
+
import '@robot-admin/naive-ui-components/C_OrgChart/style.css'
|
|
11
|
+
|
|
12
|
+
const company = {
|
|
13
|
+
id: 0,
|
|
14
|
+
label: '研发中心',
|
|
15
|
+
subtitle: '负责人:陈经理',
|
|
16
|
+
children: [{ id: 1, label: '平台部', subtitle: '6 人' }],
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div style="height: 480px">
|
|
22
|
+
<C_OrgChart
|
|
23
|
+
:data="company"
|
|
24
|
+
fit-on-init
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
默认字段继续使用 `id/label/children/subtitle/avatar`。数字 `0` 是有效键,不与字符串 `"0"` 混淆。`className`、`collapsed` 和旧 `OrgChartNode.data` 均保留。键在整棵树中必须唯一;无效键、重复键和循环引用的分支会跳过,避免无限递归。
|
|
31
|
+
|
|
32
|
+
默认点击只触发 `node-click`,保留旧版没有选择背景的行为。传入 `selectedKey`、`defaultSelectedKey`,或显式调用 `locate()` 才启用选择反馈。原有 `node-click/node-expand/node-collapse` 事件继续返回原节点。
|
|
33
|
+
|
|
34
|
+
## 直接消费业务节点
|
|
35
|
+
|
|
36
|
+
业务 interface 不需要添加 `Record` 索引签名,也不需要先转成 `OrgChartNode`。`data` 推导插槽与事件中的业务类型,字段名由配置映射。
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { ref } from 'vue'
|
|
41
|
+
import {
|
|
42
|
+
C_OrgChart,
|
|
43
|
+
type OrgChartExpose,
|
|
44
|
+
type OrgChartKey,
|
|
45
|
+
} from '@robot-admin/naive-ui-components/C_OrgChart'
|
|
46
|
+
|
|
47
|
+
interface Department {
|
|
48
|
+
code: number
|
|
49
|
+
title: string
|
|
50
|
+
leader: string
|
|
51
|
+
portrait?: string
|
|
52
|
+
headcount: number
|
|
53
|
+
units?: Department[]
|
|
54
|
+
}
|
|
55
|
+
const department: Department = {
|
|
56
|
+
code: 0,
|
|
57
|
+
title: '研发中心',
|
|
58
|
+
leader: '陈经理',
|
|
59
|
+
headcount: 12,
|
|
60
|
+
units: [{ code: 1, title: '平台部', leader: '张经理', headcount: 6 }],
|
|
61
|
+
}
|
|
62
|
+
const chart = ref<OrgChartExpose<Department>>()
|
|
63
|
+
const selected = ref<OrgChartKey | null>(0)
|
|
64
|
+
const expanded = ref<OrgChartKey[]>([0])
|
|
65
|
+
const locatePlatform = () => chart.value?.locate(1)
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
@click="locatePlatform"
|
|
72
|
+
>定位平台部</button
|
|
73
|
+
>
|
|
74
|
+
<C_OrgChart
|
|
75
|
+
ref="chart"
|
|
76
|
+
v-model:selected-key="selected"
|
|
77
|
+
v-model:expanded-keys="expanded"
|
|
78
|
+
:data="department"
|
|
79
|
+
key-field="code"
|
|
80
|
+
label-field="title"
|
|
81
|
+
children-field="units"
|
|
82
|
+
subtitle-field="leader"
|
|
83
|
+
avatar-field="portrait"
|
|
84
|
+
>
|
|
85
|
+
<template #node="{ node, isSelected, select }">
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
:aria-pressed="isSelected"
|
|
89
|
+
@click="select"
|
|
90
|
+
>
|
|
91
|
+
{{ node.title }} · {{ node.headcount }} 人
|
|
92
|
+
</button>
|
|
93
|
+
<div>{{ node.leader }}</div>
|
|
94
|
+
</template>
|
|
95
|
+
</C_OrgChart>
|
|
96
|
+
</template>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`#node` 在每一层生效,提供 `{ node, key, isLeaf, isExpanded, isSelected, select, toggle }`。`node` 是原业务对象,负责人、状态、人数等业务字段直接读取。自定义内容负责自身的可访问性;用原生按钮绑定 `select()` 可直接获得 Enter/Space 操作。独立的详情/管理按钮不会误触发节点选择,避免把按钮嵌套在另一个按钮内。
|
|
100
|
+
|
|
101
|
+
## 展开、选择和定位
|
|
102
|
+
|
|
103
|
+
| 配置/方法 | 行为 |
|
|
104
|
+
| -------------------------------------- | ---------------------------------------------------------------------- |
|
|
105
|
+
| `selectedKey` / `defaultSelectedKey` | 受控/初始选择;`null` 表示不选中 |
|
|
106
|
+
| `expandedKeys` / `defaultExpandedKeys` | 受控/初始展开键集合,空数组表示全部折叠 |
|
|
107
|
+
| 未配置展开属性 | 延续节点 `collapsed` 语义,默认展开;节点的 `collapsed` 后续改变会同步 |
|
|
108
|
+
| `update:selectedKey(key, node)` | 点击或定位提出的选择变更,第二参数是原业务节点 |
|
|
109
|
+
| `update:expandedKeys(keys, node)` | 展开/折叠或定位提出的完整展开集合;定位时第二参数是目标节点 |
|
|
110
|
+
| `getNode(key)` | 在已提供的数据中查找原业务节点,未找到返回 `null` |
|
|
111
|
+
| `locate(key)` | 展开祖先、建议选中目标并居中,返回 `Promise<boolean>` |
|
|
112
|
+
|
|
113
|
+
组件不修改传入节点、子数组或受控键集合。受控模式只发出变更建议,父组件接受后才更新图。`locate()` 在父组件同步接受展开后会完成定位;目标不存在、仍被折叠、容器没有可测量尺寸、数据已被替换或操作被取消时返回 `false`。异步业务拒绝/延迟展开时,应在接受状态后再次调用定位。
|
|
114
|
+
|
|
115
|
+
`default*` 属性只负责初始化。显式 `defaultExpandedKeys` 使用键集合管理展开,不再跟随各节点 `collapsed`;二者不混用。非受控内部状态仍按稳定键保留,替换数据不会把手动展开写回业务对象。
|
|
116
|
+
|
|
117
|
+
## 布局、连线与主题
|
|
118
|
+
|
|
119
|
+
- `direction="vertical | horizontal"`:上下或左右层级。
|
|
120
|
+
- `lineStyle="straight | rounded | stepped"`:边缘锚点之间的直线、圆角折线、直角折线,默认 `rounded`。
|
|
121
|
+
- `nodeSpacing/levelSpacing`:兄弟间距/层级间距;`lineColor/lineWidth`:可选连线样式。
|
|
122
|
+
- 连线读取真实卡片尺寸;卡片内容、头像、方向和容器尺寸变化后按帧合并测量,缩放时与卡片共用坐标系。
|
|
123
|
+
- 默认卡片、选择态、连线与控件跟随 `NConfigProvider` 的明暗主题,变量限定在组件根内。
|
|
124
|
+
|
|
125
|
+
视窗支持滚轮缩放、空白区域拖动、`zoomIn()/zoomOut()/resetView()`、`fitView()`,并公开当前 `zoom`。`initialZoom/minZoom/maxZoom` 控制缩放范围。`fitOnInit` 会在初次显示和后续布局变化时适配内容;手动缩放、平移或定位后暂停自动全景适配,防止覆盖当前阅读位置。显式 `fitView()`、替换根数据或切换方向后恢复自动适配。`resetView()` 回到初始比例与位移。
|
|
126
|
+
|
|
127
|
+
## 能力边界
|
|
128
|
+
|
|
129
|
+
这是 DOM 卡片组织树,折叠会卸载隐藏子树,**没有图节点窗口化或懒加载请求引擎**。大组织建议先限制展示层级、按业务范围给数据,目录检索交给具备虚拟滚动/远程路径能力的 `C_Tree`。不要一次展开数千张复杂卡片。
|
|
130
|
+
|
|
131
|
+
组件不负责人员权限、部门负责人解析、后端组织变更、拖拽重组、多父级矩阵关系或审批引擎。本轮也未加入导出 API。需要复杂关系图时使用专门图能力,保持组织目录、表单选择和架构图之间的边界。
|
|
132
|
+
|
|
133
|
+
公开类型包括 `OrgChartNode/OrgChartProps/OrgChartKey/OrgChartDirection/OrgChartLineStyle/OrgChartSlots/OrgChartNodeSlotProps/OrgChartEmits/OrgChartExpose`。旧 `InstanceType<typeof C_OrgChart>` 实例引用仍可使用;业务节点实例可直接使用 `OrgChartExpose<Department>`。
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# 组织目录与架构图
|
|
2
|
+
|
|
3
|
+
`C_Tree` 适合侧栏检索、层级选择和节点操作;`C_OrgChart` 适合展示组织关系、折叠分支和画布定位。两者独立导入、独立持有状态。需要联动时由页面组合公开事件和 `locate()`,组件之间没有依赖。
|
|
4
|
+
|
|
5
|
+
库内演示使用独立页面,不改动业务项目:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun run build
|
|
9
|
+
bun run dev:search-workflows
|
|
10
|
+
# http://127.0.0.1:4188/organization.html
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
演示通过发布包子路径导入构建产物。新增或修改组件实现后,先更新 `dist`;`check:search-workflows` 会检查演示类型并构建所有独立 HTML 入口。
|
|
14
|
+
|
|
15
|
+
## 先用配置,复杂展示再用插槽
|
|
16
|
+
|
|
17
|
+
目录中的公司、部门、负责人和人员可以直接使用原业务字段。`type-field` 负责读取节点类型;`icon-config.resolve` 可以根据展开、选中、叶子和加载状态决定图标,不需要把这些状态复制到业务节点。
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<C_Tree
|
|
21
|
+
:data="departments"
|
|
22
|
+
key-field="code"
|
|
23
|
+
label-field="name"
|
|
24
|
+
children-field="nodes"
|
|
25
|
+
type-field="kind"
|
|
26
|
+
density="compact"
|
|
27
|
+
:addable="false"
|
|
28
|
+
:refreshable="false"
|
|
29
|
+
:icon-config="{
|
|
30
|
+
typeMap: { company: 'mdi:office-building-outline' },
|
|
31
|
+
resolve: ({ option, expanded }) => {
|
|
32
|
+
if (option.kind !== 'department') return undefined
|
|
33
|
+
return {
|
|
34
|
+
name: expanded ? 'mdi:folder-open-outline' : 'mdi:folder-outline',
|
|
35
|
+
color: '#16837b',
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
}"
|
|
39
|
+
/>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`undefined` 沿用 `icon-field`、`typeMap` 和默认图标;`null` 明确隐藏图标。`resolve` 也可以直接返回图标名。业务状态由 `option` 读取,例如用待入职、已停用等状态切换人员图标。
|
|
43
|
+
|
|
44
|
+
需要头像时使用 `#prefix`;需要人数等复合文字时使用 `#label`。插槽接管对应展示位置,因此 `#prefix` 会替代默认图标,`#suffix` 会替代默认操作区。演示仅在启用“人员头像”时提供 prefix,并在该插槽中保留部门状态图标。默认关闭头像时完全使用图标配置。
|
|
45
|
+
|
|
46
|
+
`prefix`、`label`、`suffix` 与 `tree-props` 的节点 renderer 均可读取 `option`、`selected`、`checked`、`expanded`、`isLeaf`、`loading`,其中 `option` 根据 `data` 推导业务类型。纯展示无需额外声明一套组件节点类型。
|
|
47
|
+
|
|
48
|
+
## 节点操作保留业务边界
|
|
49
|
+
|
|
50
|
+
权限和请求由页面管理,组件只呈现并拦截禁用或忙碌的操作:
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<C_Tree
|
|
54
|
+
:data="departments"
|
|
55
|
+
:actions="[
|
|
56
|
+
{
|
|
57
|
+
key: 'sync',
|
|
58
|
+
text: '同步',
|
|
59
|
+
icon: 'mdi:refresh',
|
|
60
|
+
disabled: node => !canManage || node.locked,
|
|
61
|
+
loading: node => busyKey === node.id,
|
|
62
|
+
},
|
|
63
|
+
]"
|
|
64
|
+
@node-action="handleAction"
|
|
65
|
+
/>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`disabled` 和 `loading` 也接受布尔值。`loading` 自动阻止重复触发;带确认框的操作在确认时仍检查当前权限与忙碌状态。隐藏操作使用原有 `show(node)`。前端按钮状态不能代替服务端鉴权。
|
|
69
|
+
|
|
70
|
+
## 架构图直接消费原模型
|
|
71
|
+
|
|
72
|
+
默认字段为 `id / label / children / subtitle / avatar`,只传 `data` 即可展示默认卡片。不同业务字段使用扁平 props 映射,无需接入侧递归转换:
|
|
73
|
+
|
|
74
|
+
```vue
|
|
75
|
+
<C_OrgChart
|
|
76
|
+
ref="chart"
|
|
77
|
+
v-model:selected-key="selectedKey"
|
|
78
|
+
v-model:expanded-keys="expandedKeys"
|
|
79
|
+
:data="company"
|
|
80
|
+
key-field="code"
|
|
81
|
+
label-field="title"
|
|
82
|
+
children-field="nodes"
|
|
83
|
+
subtitle-field="role"
|
|
84
|
+
avatar-field="picture"
|
|
85
|
+
direction="vertical"
|
|
86
|
+
line-style="rounded"
|
|
87
|
+
fit-on-init
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`selected-key` 是单个 `string | number | null`;`expanded-keys` 是展开节点键数组。两者都是可选受控能力,不传时保持原有默认选择展示与节点 `collapsed` 行为。受控状态由使用侧接收更新,组件不修改传入节点或数组。
|
|
92
|
+
|
|
93
|
+
- `direction`:`vertical` 或 `horizontal`。
|
|
94
|
+
- `line-style`:`straight` 直线、`rounded` 圆角折线、`stepped` 直角折线。
|
|
95
|
+
- `fit-on-init`:按真实内容适配画布;公开 `fitView()` 可再次适配。
|
|
96
|
+
- `locate(key)`:展开祖先、选择并居中目标,返回 `Promise<boolean>`。受控展开时需要页面接受组件发出的更新;未接受且目标仍隐藏时返回 `false`。
|
|
97
|
+
- `getNode(key)`、节点事件与插槽均保留原业务节点,不附加 UI 状态。
|
|
98
|
+
|
|
99
|
+
复杂卡片可使用节点插槽。使用插槽提供的 `select()` 和 `toggle()`,避免接入侧重新实现选择或展开协议:
|
|
100
|
+
|
|
101
|
+
```vue
|
|
102
|
+
<C_OrgChart
|
|
103
|
+
:data="company"
|
|
104
|
+
key-field="code"
|
|
105
|
+
label-field="title"
|
|
106
|
+
children-field="nodes"
|
|
107
|
+
>
|
|
108
|
+
<template #node="{ node, isSelected, select }">
|
|
109
|
+
<article>
|
|
110
|
+
<button type="button" :aria-pressed="isSelected" @click="select">
|
|
111
|
+
{{ node.title }}
|
|
112
|
+
</button>
|
|
113
|
+
<span>{{ node.memberTotal }} 人</span>
|
|
114
|
+
</article>
|
|
115
|
+
</template>
|
|
116
|
+
</C_OrgChart>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
插槽自行提供键盘可访问的主操作;原生按钮支持 Enter 和空格。不要嵌套按钮。默认卡片已有选择与折叠的键盘操作。
|
|
120
|
+
|
|
121
|
+
## 离线演示的业务边界
|
|
122
|
+
|
|
123
|
+
- 共 10 个演示节点,组织成员为 128 人。成员数来自独立业务统计,不能由当前 `children.length` 推断;成员明细不代表完整花名册。
|
|
124
|
+
- 两种数据模型在进入组件前冻结。选择、折叠、定位、权限开关和 busy 状态都由页面单独持有,交互回执检查原始数据未被改写。
|
|
125
|
+
- 所有头像使用本地生成 SVG 或 CSS,图标注册本地 MDI 子集。没有远程头像、Iconify API 或后端请求。
|
|
126
|
+
- “同步”只模拟约 1 秒的忙碌操作,用于验证按钮状态;不实现组织编辑、权限系统、成员查询或审批流程。
|
|
127
|
+
|
|
128
|
+
## 手动验收
|
|
129
|
+
|
|
130
|
+
1. 打开独立页面,目录显示公司、3 个部门和成员;总人数与实际展示节点数分别显示,卡片与目录的负责人、状态、人数一致。
|
|
131
|
+
2. 切换人员头像与紧凑模式;关闭头像后,部门图标随展开变化,待入职与停用人员使用对应状态图标。切换深色主题,文字、卡片、连线和操作均清晰可读。
|
|
132
|
+
3. 搜索部门或成员,选择结果;右侧展开对应祖先并定位。清空搜索后目录恢复,选择状态仍可理解。
|
|
133
|
+
4. 悬停或用键盘进入节点操作,执行同步;按钮出现 loading 并阻止重复触发。关闭管理权限后同步禁用;公司和停用人员始终禁用。查看资料仍可用。
|
|
134
|
+
5. 切换默认模型与业务字段卡片,分别切换横纵方向和三种连线;检查多个兄弟节点的连线完整且无断裂。点击“适应视野”可恢复完整可见范围。
|
|
135
|
+
6. 全部收起后定位“陆言”;工程研发部祖先展开,目标选中并居中。点击卡片标题或用 Enter / 空格选择,左侧目录与下方选择信息同步更新。
|
|
136
|
+
7. 滚轮缩放、拖动画布空白平移;节点选择与折叠按钮不误触平移。重复操作后回执仍显示“原始数据未改写”,网络面板无外部业务、图片或图标请求。
|
|
137
|
+
|
|
138
|
+
## 0.34.0 发布验证
|
|
139
|
+
|
|
140
|
+
- 完整 `bun run verify` 通过:525 项单测、692 项组件回归,以及源码、组件、消费者类型、公开导出、代码质量、构建和打包消费检查。Tree 专项包括 55 项挂载回归。
|
|
141
|
+
- 最低与最新依赖均全新安装验证。最低组合的原生 Node ESM 限制沿用既有说明;最低浏览器构建纳入 8 个公开组件和样式入口,双格式声明按 Node16/NodeNext 检查。
|
|
142
|
+
- 独立入口实测(含 Vue 等运行依赖):Tree 首屏 JS gzip 约 125.5 KiB、CSS 1.1 KiB;OrgChart 约 38.4 KiB、CSS 1.6 KiB。新增 135/45 KiB 的 JS 门槛及双向依赖隔离断言,其他入口预算不变。双格式物理产物比 0.33.0 增加约 22 KiB,使用原有余量后追加 16 KiB 总包限额。
|
|
143
|
+
- 浏览器已操作图标/头像切换、节点折叠、操作 busy 与权限禁用、深层节点定位、横纵布局、三种 SVG 路径、旧默认数据、自定义卡片空格选择、明暗主题和 390px 视口;控制台无错误或警告。窄屏概况区域采用独立标题行与三列统计,页面没有横向溢出。
|
|
144
|
+
|
|
145
|
+
组织图仍是 DOM 卡片布局;大规模节点的窗口化、组织关系编辑及真实后端接入不在本轮范围。生产接入应继续按业务范围和展示层级控制数据量。
|
package/docs/guides/tree.en.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
`checkable`, `multiple`, `cascade`, `checkStrategy`, `selectable`, `disabled`, `virtualScroll`, `accordion` and `expandOnClick` are optional direct props. Omitted values retain `treeProps` and existing defaults; explicit false wins. All remaining native features stay in `treeProps`. A virtual tree needs a definite height. Change the native `themeOverrides.nodeHeight`, rather than adding row margins that disagree with virtual measurements.
|
|
4
4
|
|
|
5
|
+
## Stateful node presentation and organization trees
|
|
6
|
+
|
|
7
|
+
The existing `prefix/label/suffix` slots and native renderers receive `{ option, selected, checked, expanded, isLeaf, loading }`, with the business node inferred from `data`. `expanded` follows the effective keys, including native local-filter updates; a controlled parent that rejects expansion keeps it false. `isLeaf` honors the explicit native field first, then the configured children/getChildren. `loading` covers the current node's valid native `onLoad` or `searchSource.load` attempt, rather than the whole search request.
|
|
8
|
+
|
|
9
|
+
The original three-field `TreeRenderContext` remains constructible. Use the exported `TreeNodeRenderContext<Node>` only when separately declaring a callback that needs the additional states.
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<C_Tree
|
|
13
|
+
:data="departments"
|
|
14
|
+
mode="org"
|
|
15
|
+
key-field="code"
|
|
16
|
+
label-field="title"
|
|
17
|
+
children-field="items"
|
|
18
|
+
type-field="category"
|
|
19
|
+
:icon-config="{
|
|
20
|
+
resolve: ({ option, expanded, selected }) =>
|
|
21
|
+
option.category === 'department'
|
|
22
|
+
? {
|
|
23
|
+
name: expanded ? 'mdi:folder-open-outline' : 'mdi:domain',
|
|
24
|
+
color: selected ? '#2080f0' : undefined,
|
|
25
|
+
}
|
|
26
|
+
: undefined,
|
|
27
|
+
}"
|
|
28
|
+
:actions="[
|
|
29
|
+
{
|
|
30
|
+
key: 'edit',
|
|
31
|
+
text: 'Edit',
|
|
32
|
+
icon: 'mdi:pencil',
|
|
33
|
+
disabled: node => !node.editable,
|
|
34
|
+
loading: node => savingIds.has(node.code),
|
|
35
|
+
},
|
|
36
|
+
]"
|
|
37
|
+
>
|
|
38
|
+
<template #label="{ option, loading }">
|
|
39
|
+
<span :aria-busy="loading">{{ option.title }}</span>
|
|
40
|
+
<NTag v-if="option.memberCount != null" size="small">
|
|
41
|
+
{{ option.memberCount }} members
|
|
42
|
+
</NTag>
|
|
43
|
+
</template>
|
|
44
|
+
</C_Tree>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`org` presets department/user/manager icons and add/edit actions. `typeField` defaults to `type`. Use `iconConfig.resolve` for stateful icons without replacing the prefix slot. It returns a string, a narrow `{ name, size?, color? }` descriptor, `null` to hide, or `undefined` to fall back to the existing `iconField` (default `icon`) → `typeMap` → `default` priority. Missing size/color use the existing size 16 and type color mapping. The renderer reuses `C_Icon`; no new icon dependency is introduced.
|
|
48
|
+
|
|
49
|
+
Rendering priority remains slot → native renderer → native node `prefix()/suffix()` → wrapper default. Native node functions are still called without arguments. A custom suffix replaces preset actions; a custom label keeps default prefix icons. The icon resolver runs only within the default prefix path.
|
|
50
|
+
|
|
51
|
+
Action `disabled/loading` each accept a boolean or `(node) => boolean`. Global, native node and per-action disabling all apply; loading shows busy feedback and blocks repeated dispatch. Confirmation rechecks current show/disabled/loading. Replacing the node, rebuilding a remote projection or changing source scope invalidates an old confirmation even when keys are reused. Reactive properties of the same node are read again. The component emits events; callers own the asynchronous request and maintain `loading` for its full duration.
|
|
52
|
+
|
|
53
|
+
Compose member counts, positions and tags in the label or existing `statusConfigs`, and avatars in the prefix slot. Keep content within the unchanged single-line height; multiline cards need a nonvirtual tree or an appropriate fixed native nodeHeight. Use `C_Tree` for hierarchical selection/management and the separate `C_OrgChart` for connected organization cards; their layout and state engines remain independent.
|
|
54
|
+
|
|
5
55
|
## Remote search over a partially loaded tree
|
|
6
56
|
|
|
7
57
|
Pass an optional `searchSource` when matches may be outside the loaded subtree:
|
package/docs/guides/tree.md
CHANGED
|
@@ -80,7 +80,59 @@
|
|
|
80
80
|
</C_Tree>
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
`label/prefix/suffix` 插槽优先于 `treeProps.renderLabel/renderPrefix/renderSuffix
|
|
83
|
+
`label/prefix/suffix` 插槽优先于 `treeProps.renderLabel/renderPrefix/renderSuffix`,再使用节点自身的 `prefix()/suffix()`,最后使用包装层默认渲染。节点函数继续按原生协议无参数调用。状态标签和预设按钮属于默认渲染,自定义插槽可完全接管;例如自定义 suffix 会替换预设按钮,自定义 label 不影响默认前缀图标。
|
|
84
|
+
|
|
85
|
+
## 状态图标与组织树展示
|
|
86
|
+
|
|
87
|
+
已有插槽和三个 renderer 统一提供 `{ option, selected, checked, expanded, isLeaf, loading }`,业务节点类型从 `data` 推导,不需要类型断言。`expanded` 跟随实际生效的展开 keys,受控父组件拒绝展开建议时仍为 false;本地过滤产生的展开也沿用原生更新协议。`isLeaf` 遵循原生语义:节点显式字段优先,否则使用有效的 `children/getChildren`。`loading` 表示当前节点的有效子项加载,涵盖 `treeProps.onLoad` 和 `searchSource.load`,不等同于整树搜索请求状态。
|
|
88
|
+
|
|
89
|
+
旧的 `TreeRenderContext` 保持三个字段,已有手工构造及回调类型继续可用;需要单独声明完整状态时使用导出的 `TreeNodeRenderContext<Node>`。
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<C_Tree
|
|
93
|
+
:data="departments"
|
|
94
|
+
mode="org"
|
|
95
|
+
key-field="code"
|
|
96
|
+
label-field="title"
|
|
97
|
+
children-field="items"
|
|
98
|
+
type-field="category"
|
|
99
|
+
:icon-config="{
|
|
100
|
+
resolve: ({ option, expanded, selected }) =>
|
|
101
|
+
option.category === 'department'
|
|
102
|
+
? {
|
|
103
|
+
name: expanded ? 'mdi:folder-open-outline' : 'mdi:domain',
|
|
104
|
+
color: selected ? '#2080f0' : undefined,
|
|
105
|
+
}
|
|
106
|
+
: undefined,
|
|
107
|
+
}"
|
|
108
|
+
:actions="[
|
|
109
|
+
{
|
|
110
|
+
key: 'edit',
|
|
111
|
+
text: '编辑',
|
|
112
|
+
icon: 'mdi:pencil',
|
|
113
|
+
disabled: node => !node.editable,
|
|
114
|
+
loading: node => savingIds.has(node.code),
|
|
115
|
+
},
|
|
116
|
+
]"
|
|
117
|
+
>
|
|
118
|
+
<template #label="{ option, loading }">
|
|
119
|
+
<span :aria-busy="loading">{{ option.title }}</span>
|
|
120
|
+
<NTag v-if="option.memberCount != null" size="small">
|
|
121
|
+
{{ option.memberCount }} 人
|
|
122
|
+
</NTag>
|
|
123
|
+
</template>
|
|
124
|
+
</C_Tree>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`mode="org"` 提供 department/user/manager 图标与新增下级、编辑操作;`typeField` 默认仍为 `type`,可映射业务分类字段。只需要状态图标时配置 `iconConfig.resolve`,无需接管 prefix 插槽。返回值规则:
|
|
128
|
+
|
|
129
|
+
- 字符串:图标名称;`{ name, size?, color? }`:名称及可选尺寸、颜色,复用 `C_Icon`,默认尺寸仍为 16。
|
|
130
|
+
- `undefined`:完整回退旧的 `iconField`(默认 `icon`)→ `typeMap` → `default`;`colorMap` 仍按类型生效。描述符省略颜色/尺寸时同样使用旧默认。
|
|
131
|
+
- `null`:明确隐藏默认前缀图标。解析器仅在默认前缀路径运行,不抢占插槽、原生 renderer 或节点自身的 prefix 函数。
|
|
132
|
+
|
|
133
|
+
`actions[].disabled/loading` 均支持布尔值或 `(node) => boolean`。全树禁用、节点的原生 disabledField、操作禁用和忙碌状态共同约束按钮;忙碌时显示等待并阻止重复操作。弹层确认时重新检查最新 show/disabled/loading,节点被替换、远程投影重建或来源 scope 改变后,旧确认不能操作复用相同 key 的另一个节点。同一响应式节点属性更新仍按最新值判断。组件只发出一次事件,不接管异步业务;使用侧通过 `loading` 维护实际请求周期。
|
|
134
|
+
|
|
135
|
+
部门人数、岗位、状态可通过 label 和已有 `statusConfigs` 组合;头像使用 prefix 插槽。自定义内容应保持在现有单行高度内;多行卡片需选择非虚拟树或明确设置合适的固定 nodeHeight。树状选择/管理使用 `C_Tree`,连线卡片式组织架构图使用独立 `C_OrgChart`,不混合两套布局和状态引擎。
|
|
84
136
|
|
|
85
137
|
## 异步加载:保持官方协议和数据所有权
|
|
86
138
|
|