@a2simcode/ui 0.0.68 → 0.0.69

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.
@@ -125,6 +125,19 @@
125
125
  </template>
126
126
  </Demo>
127
127
 
128
+ ## 树形异步数据加载(懒加载)
129
+
130
+ 当数据量较大时,可以将记录的 `children` 设置为 `true` 作为懒加载标识;展开该行时,组件会调用 `loadChildren(record)` 异步获取子节点并写入。
131
+
132
+ <Demo :source-code="tableTreeLazyCode">
133
+ <template #source>
134
+ <table-tree-lazy />
135
+ </template>
136
+ <template #description>
137
+ 设置 <code>isTree</code> 并在某些行上标记 <code>children: true</code>。展开时将调用 <code>loadChildren(record)</code> 获取并填充该行的子节点。
138
+ </template>
139
+ </Demo>
140
+
128
141
  ## 子表
129
142
 
130
143
  通过 `subColumns` 属性配置子表列信息(Master-Detail)。
@@ -272,6 +285,7 @@ import TableFrozenColumn from '../examples/table/frozen-column.vue'
272
285
  import TableHeightMode from '../examples/table/height-mode.vue'
273
286
  import TableTreeColumn from '../examples/table/tree-column.vue'
274
287
  import TableTreeData from '../examples/table/tree-data.vue'
288
+ import TableTreeLazy from '../examples/table/tree-lazy.vue'
275
289
  import TableSubTable from '../examples/table/sub-table.vue'
276
290
  import TableSubTableLazy from '../examples/table/sub-table-lazy.vue'
277
291
  import TableMultiple from '../examples/table/multiple.vue'
@@ -292,6 +306,7 @@ import tableFrozenColumnCode from '../examples/table/frozen-column.vue?raw'
292
306
  import tableHeightModeCode from '../examples/table/height-mode.vue?raw'
293
307
  import tableTreeColumnCode from '../examples/table/tree-column.vue?raw'
294
308
  import tableTreeDataCode from '../examples/table/tree-data.vue?raw'
309
+ import tableTreeLazyCode from '../examples/table/tree-lazy.vue?raw'
295
310
  import tableSubTableCode from '../examples/table/sub-table.vue?raw'
296
311
  import tableSubTableLazyCode from '../examples/table/sub-table-lazy.vue?raw'
297
312
  import tableMultipleCode from '../examples/table/multiple.vue?raw'
@@ -0,0 +1,80 @@
1
+ <template>
2
+ <div style="position: relative; width: 100%; height: 500px">
3
+ <j-table
4
+ :columns="columns"
5
+ :records="records"
6
+ is-tree
7
+ :load-children="loadChildren"
8
+ />
9
+ </div>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { ref } from 'vue'
14
+
15
+ const columns = ref([
16
+ {
17
+ id: 'category',
18
+ config: {
19
+ label: '类别',
20
+ width: 200,
21
+ },
22
+ },
23
+ {
24
+ id: 'amount',
25
+ config: {
26
+ label: '销售额',
27
+ width: 'auto',
28
+ },
29
+ },
30
+ {
31
+ id: 'profit',
32
+ config: {
33
+ label: '利润',
34
+ width: 120,
35
+ },
36
+ },
37
+ ])
38
+
39
+ const records = ref([
40
+ {
41
+ category: '办公用品',
42
+ amount: '129.70',
43
+ profit: '-60.70',
44
+ children: [
45
+ { category: '信封', amount: '125.44', profit: '42.56' },
46
+ { category: '器具', amount: '1375.92', profit: '550.2' },
47
+ ],
48
+ },
49
+ {
50
+ category: '技术',
51
+ amount: '229.70',
52
+ profit: '90.70',
53
+ children: true,
54
+ },
55
+ {
56
+ category: '家具',
57
+ amount: '329.00',
58
+ profit: '120.30',
59
+ children: [
60
+ { category: '桌子', amount: '125.44', profit: '42.56' },
61
+ { category: '椅子', amount: '1375.92', profit: '550.2' },
62
+ ],
63
+ },
64
+ ])
65
+
66
+ const delay = (ms: number) => new Promise((r) => setTimeout(r, ms))
67
+
68
+ const loadChildren = async (record: any) => {
69
+ await delay(600)
70
+ if (record.category === '技术') {
71
+ return [
72
+ { category: '设备', amount: '225.44', profit: '462.56' },
73
+ { category: '配件', amount: '375.92', profit: '550.2' },
74
+ { category: '电话', amount: '175.92', profit: '750.2' },
75
+ ]
76
+ }
77
+ return []
78
+ }
79
+ </script>
80
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2simcode/ui",
3
- "version": "0.0.68",
3
+ "version": "0.0.69",
4
4
  "description": "A Vue 3 UI Component Library",
5
5
  "type": "module",
6
6
  "main": "./dist/simcode-ui.umd.js",