@a2simcode/ui 0.0.87 → 0.0.89
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/dist/components/dialog/index.d.ts +3 -3
- package/dist/components/dialog/src/index.vue.d.ts +1 -1
- package/dist/components/input-layer/index.d.ts +60 -0
- package/dist/components/input-layer/src/input-layer.vue.d.ts +60 -0
- package/dist/components/table/index.d.ts +15 -0
- package/dist/components/table/src/table.vue.d.ts +15 -0
- package/dist/components/table-panel/index.d.ts +90 -0
- package/dist/components/table-panel/src/table-panel.vue.d.ts +90 -0
- package/dist/simcode-ui.es.js +4370 -4272
- package/dist/simcode-ui.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/docs/components/meta/table-panel.ts +36 -0
- package/docs/components/table-panel.md +46 -28
- package/docs/components/table.md +15 -0
- package/docs/examples/table/checkbox-layout.vue +68 -0
- package/docs/examples/table-panel/button-visibility.vue +88 -0
- package/docs/examples/table-panel/get-selection.vue +111 -0
- package/docs/examples/table-panel/tree-parent-key.vue +66 -0
- package/package.json +1 -1
|
@@ -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": "是否显示序号",
|
|
@@ -127,6 +133,36 @@ export default {
|
|
|
127
133
|
"description": "高亮模式 cross 十字 row 行 column 列 cell 单元格",
|
|
128
134
|
"type": "'cross' | 'row' | 'column' | 'cell'",
|
|
129
135
|
"default": "'row'"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "showFilterButton",
|
|
139
|
+
"description": "是否显示筛选按钮(包含右侧固定筛选面板)",
|
|
140
|
+
"type": "boolean",
|
|
141
|
+
"default": "true"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "showOrderButton",
|
|
145
|
+
"description": "是否显示排序按钮",
|
|
146
|
+
"type": "boolean",
|
|
147
|
+
"default": "true"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "showColumnButton",
|
|
151
|
+
"description": "是否显示列管理按钮",
|
|
152
|
+
"type": "boolean",
|
|
153
|
+
"default": "true"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "showRefreshButton",
|
|
157
|
+
"description": "是否显示刷新按钮",
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"default": "true"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "showFullscreenButton",
|
|
163
|
+
"description": "是否显示全屏按钮",
|
|
164
|
+
"type": "boolean",
|
|
165
|
+
"default": "true"
|
|
130
166
|
}
|
|
131
167
|
],
|
|
132
168
|
"events": [
|
|
@@ -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
|
支持多条件筛选,可以针对不同字段类型选择不同的筛选方式。
|
|
@@ -59,7 +72,6 @@
|
|
|
59
72
|
</template>
|
|
60
73
|
</Demo>
|
|
61
74
|
|
|
62
|
-
|
|
63
75
|
## 多选功能
|
|
64
76
|
|
|
65
77
|
通过 `is-multiple` 属性开启多选功能。多选功能支持两种使用场景:
|
|
@@ -118,42 +130,42 @@
|
|
|
118
130
|
- 如果数据被刷新或重新加载,有批处理按钮时会清空选中状态,无批处理按钮时会尝试保留仍然存在的记录
|
|
119
131
|
|
|
120
132
|
3. **获取选中数据**:
|
|
121
|
-
|
|
122
|
-
<template>
|
|
123
|
-
|
|
133
|
+
<Demo :source-code="tablePanelGetSelectionCode">
|
|
134
|
+
<template #source>
|
|
135
|
+
<table-panel-get-selection />
|
|
124
136
|
</template>
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// 方式1: 通过事件监听
|
|
131
|
-
const handleSelect = (selectedRecords) => {
|
|
132
|
-
console.log('选中的记录:', selectedRecords)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// 方式2: 通过组件实例方法
|
|
136
|
-
const getSelected = () => {
|
|
137
|
-
const selected = tablePanelRef.value?.getSelection()
|
|
138
|
-
console.log('选中的记录:', selected)
|
|
139
|
-
}
|
|
140
|
-
</script>
|
|
141
|
-
```
|
|
137
|
+
<template #description>
|
|
138
|
+
通过 `@select` 监听选中变化;通过组件实例方法 `getSelection()` 获取选中数据,`clearSelection()` 清空选中。
|
|
139
|
+
</template>
|
|
140
|
+
</Demo>
|
|
142
141
|
|
|
143
142
|
4. **两种模式的区别**:
|
|
144
143
|
|
|
145
|
-
| 特性
|
|
146
|
-
|
|
147
|
-
| 工具栏按钮
|
|
148
|
-
| 查询设置按钮
|
|
149
|
-
| 选中状态保持
|
|
150
|
-
| 仅显示选中模式 | 支持
|
|
151
|
-
| 适用场景
|
|
144
|
+
| 特性 | 无批处理按钮 | 有批处理按钮 |
|
|
145
|
+
| -------------- | ---------------------------------------- | ------------------------ |
|
|
146
|
+
| 工具栏按钮 | 始终显示 | 选中后切换为选中控制按钮 |
|
|
147
|
+
| 查询设置按钮 | 选中后仍显示,进入"仅显示选中"模式后隐藏 | 选中后立即隐藏 |
|
|
148
|
+
| 选中状态保持 | 跨页保持,刷新后尝试保留 | 跨页保持,刷新后清空 |
|
|
149
|
+
| 仅显示选中模式 | 支持 | 支持 |
|
|
150
|
+
| 适用场景 | 需要获取选中数据,但操作在外部处理 | 需要批量操作功能 |
|
|
152
151
|
|
|
153
152
|
## 批量操作
|
|
154
153
|
|
|
155
154
|
批量操作是多选功能的一种扩展使用方式,详见上面的"多选功能"章节中的"带批处理按钮的多选"部分。
|
|
156
155
|
|
|
156
|
+
## 按钮显示控制
|
|
157
|
+
|
|
158
|
+
可以通过属性控制右上角功能按钮是否显示。
|
|
159
|
+
|
|
160
|
+
<Demo :source-code="tablePanelButtonVisibilityCode">
|
|
161
|
+
<template #source>
|
|
162
|
+
<table-panel-button-visibility />
|
|
163
|
+
</template>
|
|
164
|
+
<template #description>
|
|
165
|
+
通过 `showFilterButton / showOrderButton / showColumnButton / showRefreshButton / showFullscreenButton` 控制按钮显示。
|
|
166
|
+
</template>
|
|
167
|
+
</Demo>
|
|
168
|
+
|
|
157
169
|
## API
|
|
158
170
|
|
|
159
171
|
<ApiTable :data="tablePanelApi" componentName="table-panel" />
|
|
@@ -202,17 +214,23 @@ interface LoadDataParams {
|
|
|
202
214
|
|
|
203
215
|
<script setup>
|
|
204
216
|
import TablePanelBasic from '../examples/table-panel/basic.vue'
|
|
217
|
+
import TablePanelTreeParentKey from '../examples/table-panel/tree-parent-key.vue'
|
|
205
218
|
import TablePanelFilter from '../examples/table-panel/filter.vue'
|
|
206
219
|
import TablePanelPagination from '../examples/table-panel/pagination.vue'
|
|
207
220
|
import TablePanelMultipleSelection from '../examples/table-panel/multiple-selection.vue'
|
|
208
221
|
import TablePanelBatchOperations from '../examples/table-panel/batch-operations.vue'
|
|
209
222
|
import TablePanelSubTableLazy from '../examples/table-panel/sub-table-lazy.vue'
|
|
223
|
+
import TablePanelGetSelection from '../examples/table-panel/get-selection.vue'
|
|
224
|
+
import TablePanelButtonVisibility from '../examples/table-panel/button-visibility.vue'
|
|
210
225
|
import tablePanelApi from './meta/table-panel'
|
|
211
226
|
|
|
212
227
|
import tablePanelBasicCode from '../examples/table-panel/basic.vue?raw'
|
|
228
|
+
import tablePanelTreeParentKeyCode from '../examples/table-panel/tree-parent-key.vue?raw'
|
|
213
229
|
import tablePanelFilterCode from '../examples/table-panel/filter.vue?raw'
|
|
214
230
|
import tablePanelPaginationCode from '../examples/table-panel/pagination.vue?raw'
|
|
215
231
|
import tablePanelMultipleSelectionCode from '../examples/table-panel/multiple-selection.vue?raw'
|
|
216
232
|
import tablePanelBatchOperationsCode from '../examples/table-panel/batch-operations.vue?raw'
|
|
217
233
|
import tablePanelSubTableLazyCode from '../examples/table-panel/sub-table-lazy.vue?raw'
|
|
234
|
+
import tablePanelGetSelectionCode from '../examples/table-panel/get-selection.vue?raw'
|
|
235
|
+
import tablePanelButtonVisibilityCode from '../examples/table-panel/button-visibility.vue?raw'
|
|
218
236
|
</script>
|
package/docs/components/table.md
CHANGED
|
@@ -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,88 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="position: relative; width: 100%; height: 620px">
|
|
3
|
+
<div style="margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px">
|
|
4
|
+
<label style="display: flex; align-items: center; gap: 6px">
|
|
5
|
+
<input v-model="showFilterButton" type="checkbox" />
|
|
6
|
+
筛选
|
|
7
|
+
</label>
|
|
8
|
+
<label style="display: flex; align-items: center; gap: 6px">
|
|
9
|
+
<input v-model="showOrderButton" type="checkbox" />
|
|
10
|
+
排序
|
|
11
|
+
</label>
|
|
12
|
+
<label style="display: flex; align-items: center; gap: 6px">
|
|
13
|
+
<input v-model="showColumnButton" type="checkbox" />
|
|
14
|
+
列管理
|
|
15
|
+
</label>
|
|
16
|
+
<label style="display: flex; align-items: center; gap: 6px">
|
|
17
|
+
<input v-model="showRefreshButton" type="checkbox" />
|
|
18
|
+
刷新
|
|
19
|
+
</label>
|
|
20
|
+
<label style="display: flex; align-items: center; gap: 6px">
|
|
21
|
+
<input v-model="showFullscreenButton" type="checkbox" />
|
|
22
|
+
全屏
|
|
23
|
+
</label>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<j-table-panel
|
|
27
|
+
row-key="orderId"
|
|
28
|
+
:columns="columns"
|
|
29
|
+
:load-data="loadData"
|
|
30
|
+
:show-filter-button="showFilterButton"
|
|
31
|
+
:show-order-button="showOrderButton"
|
|
32
|
+
:show-column-button="showColumnButton"
|
|
33
|
+
:show-refresh-button="showRefreshButton"
|
|
34
|
+
:show-fullscreen-button="showFullscreenButton"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { ref } from 'vue'
|
|
41
|
+
|
|
42
|
+
const showFilterButton = ref(true)
|
|
43
|
+
const showOrderButton = ref(true)
|
|
44
|
+
const showColumnButton = ref(true)
|
|
45
|
+
const showRefreshButton = ref(true)
|
|
46
|
+
const showFullscreenButton = ref(true)
|
|
47
|
+
|
|
48
|
+
const columns = ref([
|
|
49
|
+
{
|
|
50
|
+
id: 'orderId',
|
|
51
|
+
type: '',
|
|
52
|
+
config: {
|
|
53
|
+
label: '订单号',
|
|
54
|
+
width: 150,
|
|
55
|
+
filter: { isSearchKeyword: true },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'customerId',
|
|
60
|
+
type: '',
|
|
61
|
+
config: {
|
|
62
|
+
label: '客户编号',
|
|
63
|
+
width: 120,
|
|
64
|
+
filter: { isSearchKeyword: true },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'productName',
|
|
69
|
+
type: '',
|
|
70
|
+
config: {
|
|
71
|
+
label: '产品名称',
|
|
72
|
+
filter: { isSearchKeyword: true },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
const mockData = [
|
|
78
|
+
{ orderId: 'CA-2016-152156', customerId: 'CG-12520', productName: 'Canon ImageCLASS 2200' },
|
|
79
|
+
{ orderId: 'CA-2017-152157', customerId: 'DV-13045', productName: 'Logitech Mouse' },
|
|
80
|
+
{ orderId: 'US-2017-108966', customerId: 'SO-20335', productName: 'HON Mesh Task Chair' },
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
const loadData = async () => {
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
setTimeout(() => resolve(mockData), 200)
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
</script>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="position: relative; width: 100%; height: 560px">
|
|
3
|
+
<div style="margin-bottom: 8px; display: flex; gap: 8px; align-items: center">
|
|
4
|
+
<j-button type="primary" label="获取选中" @click="handleGetSelection" />
|
|
5
|
+
<j-button type="text" label="清空选中" @click="handleClearSelection" />
|
|
6
|
+
<div style="font-size: 12px; color: var(--j-color-text-tertiary)">
|
|
7
|
+
当前选中:{{ selectedRecords.length }} 条
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<j-table-panel
|
|
12
|
+
ref="tablePanelRef"
|
|
13
|
+
row-key="orderId"
|
|
14
|
+
:columns="columns"
|
|
15
|
+
:load-data="loadData"
|
|
16
|
+
is-multiple
|
|
17
|
+
@select="handleSelect"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { ref } from 'vue'
|
|
24
|
+
import { ElMessage } from 'element-plus'
|
|
25
|
+
|
|
26
|
+
const tablePanelRef = ref<any>()
|
|
27
|
+
const selectedRecords = ref<Record<string, any>[]>([])
|
|
28
|
+
|
|
29
|
+
const columns = ref([
|
|
30
|
+
{
|
|
31
|
+
id: 'orderId',
|
|
32
|
+
type: '',
|
|
33
|
+
config: {
|
|
34
|
+
label: '订单号',
|
|
35
|
+
width: 150,
|
|
36
|
+
filter: { isSearchKeyword: true },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'customerId',
|
|
41
|
+
type: '',
|
|
42
|
+
config: {
|
|
43
|
+
label: '客户编号',
|
|
44
|
+
width: 120,
|
|
45
|
+
filter: { isSearchKeyword: true },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'productName',
|
|
50
|
+
type: '',
|
|
51
|
+
config: {
|
|
52
|
+
label: '产品名称',
|
|
53
|
+
filter: { isSearchKeyword: true },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'category',
|
|
58
|
+
type: '',
|
|
59
|
+
config: {
|
|
60
|
+
label: '类别',
|
|
61
|
+
width: 120,
|
|
62
|
+
dataType: 'options',
|
|
63
|
+
options: [
|
|
64
|
+
{ label: '办公用品', value: '办公用品' },
|
|
65
|
+
{ label: '科技产品', value: '科技产品' },
|
|
66
|
+
{ label: '家具', value: '家具' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
const mockData = [
|
|
73
|
+
{
|
|
74
|
+
orderId: 'CA-2016-152156',
|
|
75
|
+
customerId: 'CG-12520',
|
|
76
|
+
productName: 'Canon ImageCLASS 2200 Advanced Copier',
|
|
77
|
+
category: '办公用品',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
orderId: 'CA-2017-152157',
|
|
81
|
+
customerId: 'DV-13045',
|
|
82
|
+
productName: 'Logitech Wireless Mouse',
|
|
83
|
+
category: '科技产品',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
orderId: 'US-2017-108966',
|
|
87
|
+
customerId: 'SO-20335',
|
|
88
|
+
productName: 'HON Mesh Task Chair',
|
|
89
|
+
category: '家具',
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
const loadData = async () => {
|
|
94
|
+
return new Promise((resolve) => {
|
|
95
|
+
setTimeout(() => resolve(mockData), 200)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const handleSelect = (records: Record<string, any>[]) => {
|
|
100
|
+
selectedRecords.value = records || []
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const handleGetSelection = () => {
|
|
104
|
+
const selection = tablePanelRef.value?.getSelection?.() || []
|
|
105
|
+
ElMessage.info(`当前选中 ${selection.length} 条`)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleClearSelection = () => {
|
|
109
|
+
tablePanelRef.value?.clearSelection?.()
|
|
110
|
+
}
|
|
111
|
+
</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>
|