@a2simcode/ui 0.0.88 → 0.0.90

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.
@@ -12,6 +12,12 @@ export default {
12
12
  "type": "boolean",
13
13
  "default": "false"
14
14
  },
15
+ {
16
+ "name": "parentKey",
17
+ "description": "父级字段名(isTree 为 true 时用于将扁平数据转换成树形数据)",
18
+ "type": "string",
19
+ "default": "''"
20
+ },
15
21
  {
16
22
  "name": "isShowNumber",
17
23
  "description": "是否显示序号",
@@ -15,6 +15,19 @@
15
15
  </template>
16
16
  </Demo>
17
17
 
18
+ ## 树形数据
19
+
20
+ 当 `isTree` 为 `true` 时,可配合 `parentKey` 将扁平数据自动转换为树形结构展示。
21
+
22
+ <Demo :source-code="tablePanelTreeParentKeyCode">
23
+ <template #source>
24
+ <table-panel-tree-parent-key />
25
+ </template>
26
+ <template #description>
27
+ 设置 `is-tree` 和 `parent-key`,在 `loadData` 返回的扁平数据中通过 `parent-key` 指定的字段建立父子关系。
28
+ </template>
29
+ </Demo>
30
+
18
31
  ## 筛选功能
19
32
 
20
33
  支持多条件筛选,可以针对不同字段类型选择不同的筛选方式。
@@ -201,6 +214,7 @@ interface LoadDataParams {
201
214
 
202
215
  <script setup>
203
216
  import TablePanelBasic from '../examples/table-panel/basic.vue'
217
+ import TablePanelTreeParentKey from '../examples/table-panel/tree-parent-key.vue'
204
218
  import TablePanelFilter from '../examples/table-panel/filter.vue'
205
219
  import TablePanelPagination from '../examples/table-panel/pagination.vue'
206
220
  import TablePanelMultipleSelection from '../examples/table-panel/multiple-selection.vue'
@@ -211,6 +225,7 @@ import TablePanelButtonVisibility from '../examples/table-panel/button-visibilit
211
225
  import tablePanelApi from './meta/table-panel'
212
226
 
213
227
  import tablePanelBasicCode from '../examples/table-panel/basic.vue?raw'
228
+ import tablePanelTreeParentKeyCode from '../examples/table-panel/tree-parent-key.vue?raw'
214
229
  import tablePanelFilterCode from '../examples/table-panel/filter.vue?raw'
215
230
  import tablePanelPaginationCode from '../examples/table-panel/pagination.vue?raw'
216
231
  import tablePanelMultipleSelectionCode from '../examples/table-panel/multiple-selection.vue?raw'
@@ -57,6 +57,19 @@
57
57
  </template>
58
58
  </Demo>
59
59
 
60
+ ## Checkbox 交互布局
61
+
62
+ 通过列类型 `checkbox` 可以渲染一个内置的交互布局:两行内容(like/collect + normal/special),点击会实时更新当前行的数据并刷新显示。
63
+
64
+ <Demo :source-code="tableCheckboxLayoutCode">
65
+ <template #source>
66
+ <table-checkbox-layout />
67
+ </template>
68
+ <template #description>
69
+ 在 `columns` 中设置 `type: 'checkbox'`,并在对应字段里存储 `{ like, collect, type }`。
70
+ </template>
71
+ </Demo>
72
+
60
73
  ## 自定义布局
61
74
 
62
75
  通过列配置中的 `customLayout` 属性,可以使用 VTable 的 CustomLayout 功能自定义单元格渲染。
@@ -280,6 +293,7 @@ import TableBasic from '../examples/table/basic.vue'
280
293
  import TableTag from '../examples/table/tag.vue'
281
294
  import TableIcon from '../examples/table/icon.vue'
282
295
  import TableLink from '../examples/table/link.vue'
296
+ import TableCheckboxLayout from '../examples/table/checkbox-layout.vue'
283
297
  import TableCustomLayout from '../examples/table/custom-layout.vue'
284
298
  import TableFrozenColumn from '../examples/table/frozen-column.vue'
285
299
  import TableHeightMode from '../examples/table/height-mode.vue'
@@ -301,6 +315,7 @@ import tableBasicCode from '../examples/table/basic.vue?raw'
301
315
  import tableTagCode from '../examples/table/tag.vue?raw'
302
316
  import tableIconCode from '../examples/table/icon.vue?raw'
303
317
  import tableLinkCode from '../examples/table/link.vue?raw'
318
+ import tableCheckboxLayoutCode from '../examples/table/checkbox-layout.vue?raw'
304
319
  import tableCustomLayoutCode from '../examples/table/custom-layout.vue?raw'
305
320
  import tableFrozenColumnCode from '../examples/table/frozen-column.vue?raw'
306
321
  import tableHeightModeCode from '../examples/table/height-mode.vue?raw'
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <div style="position: relative; width: 100%; height: 400px">
3
+ <j-table :columns="columns" :records="records" />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ref } from 'vue'
9
+
10
+ const columns = ref([
11
+ {
12
+ id: 'name',
13
+ config: {
14
+ label: '用户',
15
+ width: 120,
16
+ align: 'left',
17
+ },
18
+ },
19
+ {
20
+ id: 'settings',
21
+ type: 'checkbox',
22
+ config: {
23
+ label: '设置',
24
+ width: 240,
25
+ align: 'center',
26
+ },
27
+ },
28
+ {
29
+ id: 'settingsText',
30
+ config: {
31
+ label: '当前值',
32
+ width: 'auto',
33
+ align: 'left',
34
+ fieldFormat: (row: any) => {
35
+ return JSON.stringify(row.settings)
36
+ },
37
+ },
38
+ },
39
+ ])
40
+
41
+ const records = ref([
42
+ {
43
+ id: '1',
44
+ name: '张三',
45
+ settings: [
46
+ { label: 'like', value: 'like', checked: true },
47
+ { label: 'collect', value: 'collect', checked: false },
48
+ ],
49
+ },
50
+ {
51
+ id: '2',
52
+ name: '李四',
53
+ settings: [
54
+ { label: 'like', value: 'like', checked: false },
55
+ { label: 'collect', value: 'collect', checked: true },
56
+ { label: 'notify', value: 'notify', checked: true },
57
+ ],
58
+ },
59
+ {
60
+ id: '3',
61
+ name: '王五',
62
+ settings: [
63
+ { label: 'like', value: 'like', checked: false },
64
+ { label: 'collect', value: 'collect', checked: false },
65
+ ],
66
+ },
67
+ ])
68
+ </script>
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <div style="position: relative; width: 100%; height: 500px">
3
+ <j-table-panel
4
+ row-key="id"
5
+ :columns="columns"
6
+ :load-data="loadData"
7
+ :is-tree="true"
8
+ parent-key="pid"
9
+ />
10
+ </div>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { ref } from 'vue'
15
+
16
+ const columns = ref([
17
+ {
18
+ id: 'name',
19
+ type: '',
20
+ config: {
21
+ label: '名称',
22
+ width: 240,
23
+ },
24
+ },
25
+ {
26
+ id: 'id',
27
+ type: '',
28
+ config: {
29
+ label: 'ID',
30
+ width: 160,
31
+ },
32
+ },
33
+ {
34
+ id: 'pid',
35
+ type: '',
36
+ config: {
37
+ label: '父ID',
38
+ width: 160,
39
+ },
40
+ },
41
+ {
42
+ id: 'value',
43
+ type: '',
44
+ config: {
45
+ label: '值',
46
+ width: 120,
47
+ align: 'right',
48
+ },
49
+ },
50
+ ])
51
+
52
+ const flatData = [
53
+ { id: '1', pid: '', name: '父节点 1', value: 10 },
54
+ { id: '1-1', pid: '1', name: '子节点 1-1', value: 11 },
55
+ { id: '1-2', pid: '1', name: '子节点 1-2', value: 12 },
56
+ { id: '1-2-1', pid: '1-2', name: '子节点 1-2-1', value: 121 },
57
+ { id: '2', pid: '', name: '父节点 2', value: 20 },
58
+ { id: '2-1', pid: '2', name: '子节点 2-1', value: 21 },
59
+ ]
60
+
61
+ const loadData = async (_params: Record<string, any>) => {
62
+ return new Promise((resolve) => {
63
+ setTimeout(() => resolve(flatData), 200)
64
+ })
65
+ }
66
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2simcode/ui",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "description": "A Vue 3 UI Component Library",
5
5
  "type": "module",
6
6
  "main": "./dist/simcode-ui.umd.js",