@meethive/components 0.0.3 → 0.0.4
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/es/AutoComplete/AutoComplete.js +71 -80
- package/es/BadgeStatus/Badge.js +38 -47
- package/es/CardSelect/CardSelect.js +115 -137
- package/es/CheckButton/CheckButton.js +102 -118
- package/es/ConfigProvider/ConfigProvider.js +44 -68
- package/es/DragModal/DragModal.js +191 -212
- package/es/EditTable/Body.js +158 -189
- package/es/EditTable/CellRender.js +10 -12
- package/es/EditTable/EditTable.js +385 -434
- package/es/EditTable/FormItem.js +140 -169
- package/es/EditTable/Group.js +171 -204
- package/es/EditTable/Header.js +57 -63
- package/es/EditTable/HeaderRender.js +10 -12
- package/es/EditTable/components/ContextMenu/Menu.js +78 -86
- package/es/EditTable/components/Search/Search.js +151 -163
- package/es/EditTable/components/Search/Sort.js +104 -119
- package/es/Ellipsis/Ellipsis.js +144 -148
- package/es/Empty/Empty.js +51 -57
- package/es/FullPage/FullPage.js +20 -19
- package/es/Icon/Icon.js +42 -49
- package/es/LocaleProvider/LocaleProvider.js +32 -38
- package/es/Markdown/Markdown.js +101 -118
- package/es/PermissionButton/PermissionButton.js +118 -118
- package/es/ProLayout/Basic/BasicLayout.js +301 -418
- package/es/ProLayout/Basic/Header.js +91 -111
- package/es/ProLayout/PageContainer/index.js +267 -344
- package/es/ProLayout/SiderMenu/BaseMenu.js +186 -240
- package/es/ProTable/Alert.js +39 -40
- package/es/ProTable/Content.js +84 -97
- package/es/ProTable/Header.js +32 -33
- package/es/ProTable/Pagination.js +56 -55
- package/es/ProTable/ProTable.js +256 -276
- package/es/RadioButton/RadioButton.js +48 -53
- package/es/Scrollbar/Bar.js +65 -76
- package/es/Scrollbar/Scrollbar.js +129 -161
- package/es/Scrollbar/Thumb.js +101 -150
- package/es/Search/Item.js +208 -236
- package/es/Search/Search.js +90 -90
- package/es/Skeleton/Skeleton.js +26 -27
- package/es/Skeleton/components/DashBoardCard.js +26 -27
- package/es/Skeleton/components/DashBoardChart.js +26 -27
- package/es/Skeleton/components/Detail.js +26 -27
- package/es/Skeleton/components/Drawer.js +26 -27
- package/es/Skeleton/components/Item.js +55 -54
- package/es/Skeleton/components/List.js +29 -27
- package/es/Skeleton/components/ListCard.js +28 -28
- package/es/Skeleton/components/ListCardItem.js +20 -20
- package/es/Skeleton/components/ListTable.js +26 -27
- package/es/Skeleton/components/Page.js +27 -26
- package/es/Skeleton/components/Search.js +16 -16
- package/es/Skeleton/components/Tree.js +26 -27
- package/es/TimeFormat/TimeFormat.js +32 -36
- package/es/Title/Title.js +23 -26
- package/es/ValueItem/ValueItem.js +100 -113
- package/es/VirtualTable/VirtualTable.js +235 -271
- package/lib/AutoComplete/AutoComplete.js +71 -80
- package/lib/BadgeStatus/Badge.js +38 -47
- package/lib/CardSelect/CardSelect.js +115 -137
- package/lib/CheckButton/CheckButton.js +102 -118
- package/lib/ConfigProvider/ConfigProvider.js +44 -68
- package/lib/DragModal/DragModal.js +191 -212
- package/lib/EditTable/Body.js +158 -189
- package/lib/EditTable/CellRender.js +10 -12
- package/lib/EditTable/EditTable.js +385 -434
- package/lib/EditTable/FormItem.js +140 -169
- package/lib/EditTable/Group.js +171 -204
- package/lib/EditTable/Header.js +57 -63
- package/lib/EditTable/HeaderRender.js +10 -12
- package/lib/EditTable/components/ContextMenu/Menu.js +78 -86
- package/lib/EditTable/components/Search/Search.js +151 -163
- package/lib/EditTable/components/Search/Sort.js +104 -119
- package/lib/Ellipsis/Ellipsis.js +144 -148
- package/lib/Empty/Empty.js +51 -57
- package/lib/FullPage/FullPage.js +20 -19
- package/lib/Icon/Icon.js +42 -49
- package/lib/LocaleProvider/LocaleProvider.js +32 -38
- package/lib/Markdown/Markdown.js +101 -118
- package/lib/PermissionButton/PermissionButton.js +118 -118
- package/lib/ProLayout/Basic/BasicLayout.js +301 -418
- package/lib/ProLayout/Basic/Header.js +91 -111
- package/lib/ProLayout/PageContainer/index.js +267 -344
- package/lib/ProLayout/SiderMenu/BaseMenu.js +186 -240
- package/lib/ProTable/Alert.js +39 -40
- package/lib/ProTable/Content.js +84 -97
- package/lib/ProTable/Header.js +32 -33
- package/lib/ProTable/Pagination.js +56 -55
- package/lib/ProTable/ProTable.js +256 -276
- package/lib/RadioButton/RadioButton.js +48 -53
- package/lib/Scrollbar/Bar.js +65 -76
- package/lib/Scrollbar/Scrollbar.js +129 -161
- package/lib/Scrollbar/Thumb.js +101 -150
- package/lib/Search/Item.js +208 -236
- package/lib/Search/Search.js +90 -90
- package/lib/Skeleton/Skeleton.js +26 -27
- package/lib/Skeleton/components/DashBoardCard.js +26 -27
- package/lib/Skeleton/components/DashBoardChart.js +26 -27
- package/lib/Skeleton/components/Detail.js +26 -27
- package/lib/Skeleton/components/Drawer.js +26 -27
- package/lib/Skeleton/components/Item.js +55 -54
- package/lib/Skeleton/components/List.js +29 -27
- package/lib/Skeleton/components/ListCard.js +28 -28
- package/lib/Skeleton/components/ListCardItem.js +20 -20
- package/lib/Skeleton/components/ListTable.js +26 -27
- package/lib/Skeleton/components/Page.js +27 -26
- package/lib/Skeleton/components/Search.js +16 -16
- package/lib/Skeleton/components/Tree.js +26 -27
- package/lib/TimeFormat/TimeFormat.js +32 -36
- package/lib/Title/Title.js +23 -26
- package/lib/ValueItem/ValueItem.js +100 -113
- package/lib/VirtualTable/VirtualTable.js +235 -271
- package/package.json +1 -1
|
@@ -1,434 +1,385 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
emit('
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
)
|
|
388
|
-
|
|
389
|
-
useFormContext({
|
|
390
|
-
dataSource: computed(() => props.dataSource),
|
|
391
|
-
errorMap,
|
|
392
|
-
rules,
|
|
393
|
-
addField,
|
|
394
|
-
removeField,
|
|
395
|
-
removeFieldError,
|
|
396
|
-
addFieldError,
|
|
397
|
-
validateItem
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
expose({
|
|
401
|
-
validate,
|
|
402
|
-
tableWrapper,
|
|
403
|
-
scrollToById,
|
|
404
|
-
scrollToByIndex,
|
|
405
|
-
getTableWrapperRef,
|
|
406
|
-
getGroupActive
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
return {
|
|
410
|
-
slots,
|
|
411
|
-
hashId,
|
|
412
|
-
isFullscreen,
|
|
413
|
-
toggle,
|
|
414
|
-
tableWrapper,
|
|
415
|
-
tableBody,
|
|
416
|
-
scrollBarRef,
|
|
417
|
-
myColumns,
|
|
418
|
-
tableStyle,
|
|
419
|
-
showScroll,
|
|
420
|
-
horizontalScrollWidth,
|
|
421
|
-
horizontalScrollLeft,
|
|
422
|
-
scrollWidth,
|
|
423
|
-
bodyDataSource,
|
|
424
|
-
groupActive,
|
|
425
|
-
groupOptions,
|
|
426
|
-
addGroup,
|
|
427
|
-
updateGroupActive,
|
|
428
|
-
onScrollDown,
|
|
429
|
-
groupDelete,
|
|
430
|
-
groupEdit,
|
|
431
|
-
onHorizontalScroll
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
})
|
|
1
|
+
import { defineComponent, ref, reactive, computed, watch, provide, useSlots } from 'vue';
|
|
2
|
+
import { tableProps } from 'ant-design-vue/lib/table';
|
|
3
|
+
import { useFullscreen } from '@vueuse/core';
|
|
4
|
+
import { findIndex, get, sortBy } from 'lodash-es';
|
|
5
|
+
import { FULL_SCREEN, RIGHT_MENU, TABLE_DATA_SOURCE, TABLE_ERROR, TABLE_GROUP_ACTIVE, TABLE_GROUP_ERROR, TABLE_GROUP_OPTIONS, TABLE_H_SCROLL, TABLE_OPEN_GROUP, TABLE_TOOL, TABLE_WRAPPER } from './consts';
|
|
6
|
+
import { handleColumnsWidth } from './utils';
|
|
7
|
+
import { useGroup, useResizeObserver, useValidate } from './hooks';
|
|
8
|
+
import { useFormContext } from './context';
|
|
9
|
+
import { bodyProps } from './props';
|
|
10
|
+
import Header from './Header.js';
|
|
11
|
+
import Body from './Body.js';
|
|
12
|
+
import Group from './Group.js';
|
|
13
|
+
import { useLocaleReceiver } from '../LocaleReciver';
|
|
14
|
+
import useEditTableStyle from './style';
|
|
15
|
+
const defaultGroupId = 'group_1';
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
name: 'JEditTable',
|
|
18
|
+
components: {
|
|
19
|
+
Header,
|
|
20
|
+
Body,
|
|
21
|
+
Group
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
...tableProps(),
|
|
25
|
+
...bodyProps(),
|
|
26
|
+
searchColumns: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: undefined
|
|
29
|
+
},
|
|
30
|
+
serial: {
|
|
31
|
+
type: [Object, Boolean],
|
|
32
|
+
default: () => ({
|
|
33
|
+
width: 66,
|
|
34
|
+
title: ''
|
|
35
|
+
})
|
|
36
|
+
},
|
|
37
|
+
validateRowKey: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
readonly: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
emits: ['scrollDown', 'rightMenuClick', 'editChange', 'searchVisibleChange'],
|
|
47
|
+
setup(props, {
|
|
48
|
+
emit,
|
|
49
|
+
expose
|
|
50
|
+
}) {
|
|
51
|
+
const [contextLocale] = useLocaleReceiver('EditTable');
|
|
52
|
+
const prefixCls = computed(() => 'jetlinks-edit-table');
|
|
53
|
+
const [wrapSSR, hashId] = useEditTableStyle(prefixCls);
|
|
54
|
+
const slots = useSlots();
|
|
55
|
+
const myColumns = ref([]);
|
|
56
|
+
const tableWrapper = ref();
|
|
57
|
+
const tableBody = ref();
|
|
58
|
+
const scrollBarRef = ref();
|
|
59
|
+
const tableStyle = reactive({
|
|
60
|
+
width: '100%',
|
|
61
|
+
height: props.height
|
|
62
|
+
});
|
|
63
|
+
const showScroll = ref(false);
|
|
64
|
+
const horizontalScrollWidth = ref(0);
|
|
65
|
+
const horizontalScrollLeft = ref(0);
|
|
66
|
+
const fields = {};
|
|
67
|
+
const fieldsErrMap = ref({});
|
|
68
|
+
const fieldsGroupError = ref({});
|
|
69
|
+
const scrollDefaultWidth = ref(17);
|
|
70
|
+
const sortData = reactive({
|
|
71
|
+
key: undefined,
|
|
72
|
+
order: undefined,
|
|
73
|
+
orderKeys: [],
|
|
74
|
+
dataIndex: undefined
|
|
75
|
+
});
|
|
76
|
+
const {
|
|
77
|
+
groupActive,
|
|
78
|
+
groupOptions,
|
|
79
|
+
addGroup,
|
|
80
|
+
removeGroup,
|
|
81
|
+
updateGroupActive,
|
|
82
|
+
updateGroupOptions
|
|
83
|
+
} = useGroup(props.openGroup);
|
|
84
|
+
const _dataSource = computed(() => {
|
|
85
|
+
const _options = new Map();
|
|
86
|
+
const sortDataSource = sortData.key ? sortBy(props.dataSource, val => {
|
|
87
|
+
if (!val.id) return 99999999;
|
|
88
|
+
const index = findIndex(sortData.orderKeys, val2 => get(val, sortData.key) === val2);
|
|
89
|
+
return sortData.order === 'desc' ? index : ~index + 1;
|
|
90
|
+
}) : props.dataSource;
|
|
91
|
+
sortDataSource.forEach((item, index) => {
|
|
92
|
+
item.__dataIndex = index;
|
|
93
|
+
if (props.openGroup) {
|
|
94
|
+
const _groupId = item?.expands?.groupId;
|
|
95
|
+
if (!_groupId) {
|
|
96
|
+
item.expands.groupId = groupActive.value || defaultGroupId;
|
|
97
|
+
item.expands.groupName = groupActive.label || contextLocale.value.Group.one + '1';
|
|
98
|
+
}
|
|
99
|
+
const _optionsItem = _options.get(item.expands.groupId);
|
|
100
|
+
if (!_optionsItem) {
|
|
101
|
+
_options.set(item.expands.groupId, {
|
|
102
|
+
value: item?.expands?.groupId,
|
|
103
|
+
label: item?.expands?.groupName,
|
|
104
|
+
effective: item.id ? 1 : 0,
|
|
105
|
+
len: 1
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
if (item.id) {
|
|
109
|
+
_optionsItem.effective += 1;
|
|
110
|
+
}
|
|
111
|
+
_optionsItem.len += 1;
|
|
112
|
+
_options.set(item.expands.groupId, _optionsItem);
|
|
113
|
+
}
|
|
114
|
+
item.__serial = _optionsItem?.len || 1;
|
|
115
|
+
} else {
|
|
116
|
+
item.__serial = index + 1;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (props.openGroup) {
|
|
120
|
+
updateGroupOptions([..._options.values()]);
|
|
121
|
+
}
|
|
122
|
+
return sortDataSource;
|
|
123
|
+
});
|
|
124
|
+
const bodyDataSource = computed(() => {
|
|
125
|
+
if (props.openGroup) {
|
|
126
|
+
return _dataSource.value.filter(item => item.expands.groupId === groupActive.value);
|
|
127
|
+
}
|
|
128
|
+
return _dataSource.value;
|
|
129
|
+
});
|
|
130
|
+
useResizeObserver(tableWrapper, onResize);
|
|
131
|
+
const {
|
|
132
|
+
isFullscreen,
|
|
133
|
+
toggle
|
|
134
|
+
} = useFullscreen(tableWrapper);
|
|
135
|
+
const {
|
|
136
|
+
rules,
|
|
137
|
+
validateItem,
|
|
138
|
+
validate,
|
|
139
|
+
errorMap
|
|
140
|
+
} = useValidate(_dataSource, props.columns, props.rowKey, {
|
|
141
|
+
onError: err => {
|
|
142
|
+
fieldsErrMap.value = {};
|
|
143
|
+
fieldsGroupError.value = {};
|
|
144
|
+
const errMap = {};
|
|
145
|
+
err.forEach((item, errIndex) => {
|
|
146
|
+
item.forEach((e, eIndex) => {
|
|
147
|
+
const field = findField(e.__dataIndex, e.field);
|
|
148
|
+
const _eventKey = field ? field.eventKey : `${e.__dataIndex}-${e.field}`;
|
|
149
|
+
if (field) {
|
|
150
|
+
field.showErrorTip(e.message);
|
|
151
|
+
}
|
|
152
|
+
errMap[_eventKey] = e.message;
|
|
153
|
+
if (errIndex === 0 && eIndex === 0) {
|
|
154
|
+
if (props.openGroup) {
|
|
155
|
+
const expands = _dataSource.value[e.__dataIndex].expands;
|
|
156
|
+
updateGroupActive(expands.groupId, expands.groupName);
|
|
157
|
+
}
|
|
158
|
+
setTimeout(() => {
|
|
159
|
+
tableBody.value.scrollTo(e.__serial - 1);
|
|
160
|
+
}, 10);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
fieldsErrMap.value = errMap;
|
|
165
|
+
},
|
|
166
|
+
onSuccess: () => {
|
|
167
|
+
fieldsErrMap.value = {};
|
|
168
|
+
},
|
|
169
|
+
onEdit: () => {
|
|
170
|
+
emit('editChange', true);
|
|
171
|
+
},
|
|
172
|
+
validateRowKey: props.validateRowKey
|
|
173
|
+
});
|
|
174
|
+
provide(TABLE_WRAPPER, tableWrapper);
|
|
175
|
+
provide(FULL_SCREEN, isFullscreen);
|
|
176
|
+
provide(RIGHT_MENU, {
|
|
177
|
+
click: rightMenu,
|
|
178
|
+
getPopupContainer: () => tableWrapper.value
|
|
179
|
+
});
|
|
180
|
+
provide(TABLE_ERROR, fieldsErrMap);
|
|
181
|
+
provide(TABLE_GROUP_ERROR, fieldsGroupError);
|
|
182
|
+
provide(TABLE_DATA_SOURCE, _dataSource);
|
|
183
|
+
provide(TABLE_OPEN_GROUP, props.openGroup);
|
|
184
|
+
provide(TABLE_TOOL, {
|
|
185
|
+
scrollTo: record => {
|
|
186
|
+
if (props.openGroup) {
|
|
187
|
+
const expands = record.expands;
|
|
188
|
+
updateGroupActive(expands.groupId, expands.groupName);
|
|
189
|
+
}
|
|
190
|
+
setTimeout(() => {
|
|
191
|
+
tableBody.value.scrollTo(record.__serial);
|
|
192
|
+
}, 10);
|
|
193
|
+
},
|
|
194
|
+
selected: keys => {
|
|
195
|
+
tableBody.value.updateSelectedKeys(keys);
|
|
196
|
+
},
|
|
197
|
+
order: (type, key, orderKeys, dataIndex) => {
|
|
198
|
+
sortData.key = key;
|
|
199
|
+
sortData.order = type;
|
|
200
|
+
sortData.orderKeys = orderKeys;
|
|
201
|
+
sortData.dataIndex = dataIndex;
|
|
202
|
+
},
|
|
203
|
+
cleanOrder: () => {
|
|
204
|
+
sortData.key = undefined;
|
|
205
|
+
sortData.order = undefined;
|
|
206
|
+
sortData.orderKeys = [];
|
|
207
|
+
sortData.dataIndex = undefined;
|
|
208
|
+
},
|
|
209
|
+
sortData
|
|
210
|
+
});
|
|
211
|
+
provide(TABLE_GROUP_OPTIONS, groupOptions);
|
|
212
|
+
provide(TABLE_GROUP_ACTIVE, groupActive);
|
|
213
|
+
provide(TABLE_H_SCROLL, horizontalScrollLeft);
|
|
214
|
+
const addField = (key, field) => {
|
|
215
|
+
fields[key] = field;
|
|
216
|
+
};
|
|
217
|
+
const removeField = key => {
|
|
218
|
+
delete fields[key];
|
|
219
|
+
};
|
|
220
|
+
function findField(index, name) {
|
|
221
|
+
const fieldId = Object.keys(fields).find(key => {
|
|
222
|
+
const {
|
|
223
|
+
names
|
|
224
|
+
} = fields[key];
|
|
225
|
+
return names[0] === index && names[1] === name;
|
|
226
|
+
});
|
|
227
|
+
return fields[fieldId];
|
|
228
|
+
}
|
|
229
|
+
function removeFieldError(key) {
|
|
230
|
+
delete fieldsErrMap.value[key];
|
|
231
|
+
}
|
|
232
|
+
function addFieldError(key, message) {
|
|
233
|
+
fieldsErrMap.value[key] = message;
|
|
234
|
+
}
|
|
235
|
+
const scrollWidth = computed(() => {
|
|
236
|
+
return props.dataSource.length * props.cellHeight > props.height ? scrollDefaultWidth.value : 0;
|
|
237
|
+
});
|
|
238
|
+
const handleColumns = () => {
|
|
239
|
+
let newColumns = [...props.columns];
|
|
240
|
+
if (props.serial) {
|
|
241
|
+
const serial = {
|
|
242
|
+
dataIndex: '__serial',
|
|
243
|
+
title: props.serial.title || contextLocale.value.serial,
|
|
244
|
+
customRender: customData => {
|
|
245
|
+
if (props.serial?.customRender) {
|
|
246
|
+
return props.serial.customRender(customData);
|
|
247
|
+
}
|
|
248
|
+
return customData.index + 1;
|
|
249
|
+
},
|
|
250
|
+
width: props.serial?.width,
|
|
251
|
+
fixed: 'left'
|
|
252
|
+
};
|
|
253
|
+
newColumns = [serial, ...props.columns];
|
|
254
|
+
}
|
|
255
|
+
myColumns.value = handleColumnsWidth(newColumns, tableStyle.width - scrollWidth.value);
|
|
256
|
+
horizontalScrollWidth.value = myColumns.value.reduce((prev, next) => {
|
|
257
|
+
prev += next.width;
|
|
258
|
+
return prev;
|
|
259
|
+
}, 0);
|
|
260
|
+
if (horizontalScrollWidth.value > tableStyle.width) {
|
|
261
|
+
showScroll.value = true;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
function onResize({
|
|
265
|
+
width = 0
|
|
266
|
+
}) {
|
|
267
|
+
tableStyle.width = width || '100%';
|
|
268
|
+
handleColumns();
|
|
269
|
+
}
|
|
270
|
+
const onScrollDown = len => {
|
|
271
|
+
emit('scrollDown', len);
|
|
272
|
+
};
|
|
273
|
+
function rightMenu(menuType, record, copyValue) {
|
|
274
|
+
emit('rightMenuClick', menuType, record, copyValue);
|
|
275
|
+
}
|
|
276
|
+
const scrollToById = key => {
|
|
277
|
+
const _index = _dataSource.value.findIndex(item => item[props.rowKey] === key);
|
|
278
|
+
tableBody.value.scrollTo(_index);
|
|
279
|
+
};
|
|
280
|
+
const scrollToByIndex = index => {
|
|
281
|
+
tableBody.value.scrollTo(index);
|
|
282
|
+
};
|
|
283
|
+
const getTableWrapperRef = () => {
|
|
284
|
+
return tableWrapper.value;
|
|
285
|
+
};
|
|
286
|
+
const groupDelete = (id, index) => {
|
|
287
|
+
removeGroup(index);
|
|
288
|
+
Object.keys(fieldsErrMap.value).forEach(errorKey => {
|
|
289
|
+
const [idx] = errorKey.split('-');
|
|
290
|
+
const dataSourceItem = _dataSource.value[Number(idx)];
|
|
291
|
+
const groupId = dataSourceItem?.expands?.groupId;
|
|
292
|
+
if (groupId === id) {
|
|
293
|
+
removeFieldError(errorKey);
|
|
294
|
+
removeField(errorKey);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
emit('groupDelete', id);
|
|
298
|
+
};
|
|
299
|
+
const groupEdit = record => {
|
|
300
|
+
emit('groupEdit', record);
|
|
301
|
+
};
|
|
302
|
+
const getGroupActive = () => {
|
|
303
|
+
return groupActive.value;
|
|
304
|
+
};
|
|
305
|
+
const onHorizontalScroll = () => {
|
|
306
|
+
horizontalScrollLeft.value = scrollBarRef.value.scrollLeft;
|
|
307
|
+
};
|
|
308
|
+
watch(() => fieldsErrMap.value, errorMapVal => {
|
|
309
|
+
fieldsGroupError.value = {};
|
|
310
|
+
if (props.openGroup) {
|
|
311
|
+
const groupErrorMap = {};
|
|
312
|
+
Object.keys(errorMapVal).forEach(errorKey => {
|
|
313
|
+
const [idx] = errorKey.split('-');
|
|
314
|
+
const dataSourceItem = _dataSource.value[Number(idx)];
|
|
315
|
+
const groupId = dataSourceItem?.expands?.groupId;
|
|
316
|
+
const groupErrorItem = {
|
|
317
|
+
[errorKey]: {
|
|
318
|
+
message: errorMapVal[errorKey],
|
|
319
|
+
index: idx,
|
|
320
|
+
serial: dataSourceItem.__serial
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
if (groupErrorMap[groupId]) {
|
|
324
|
+
groupErrorMap[groupId].push(groupErrorItem);
|
|
325
|
+
} else {
|
|
326
|
+
groupErrorMap[groupId] = [groupErrorItem];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
fieldsGroupError.value = groupErrorMap;
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
deep: true
|
|
333
|
+
});
|
|
334
|
+
watch(() => scrollWidth.value, () => {
|
|
335
|
+
onResize({
|
|
336
|
+
width: tableStyle.width
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
watch(() => [JSON.stringify(props.columns), tableStyle.width], () => {
|
|
340
|
+
handleColumns();
|
|
341
|
+
});
|
|
342
|
+
useFormContext({
|
|
343
|
+
dataSource: computed(() => props.dataSource),
|
|
344
|
+
errorMap,
|
|
345
|
+
rules,
|
|
346
|
+
addField,
|
|
347
|
+
removeField,
|
|
348
|
+
removeFieldError,
|
|
349
|
+
addFieldError,
|
|
350
|
+
validateItem
|
|
351
|
+
});
|
|
352
|
+
expose({
|
|
353
|
+
validate,
|
|
354
|
+
tableWrapper,
|
|
355
|
+
scrollToById,
|
|
356
|
+
scrollToByIndex,
|
|
357
|
+
getTableWrapperRef,
|
|
358
|
+
getGroupActive
|
|
359
|
+
});
|
|
360
|
+
return {
|
|
361
|
+
slots,
|
|
362
|
+
hashId,
|
|
363
|
+
isFullscreen,
|
|
364
|
+
toggle,
|
|
365
|
+
tableWrapper,
|
|
366
|
+
tableBody,
|
|
367
|
+
scrollBarRef,
|
|
368
|
+
myColumns,
|
|
369
|
+
tableStyle,
|
|
370
|
+
showScroll,
|
|
371
|
+
horizontalScrollWidth,
|
|
372
|
+
horizontalScrollLeft,
|
|
373
|
+
scrollWidth,
|
|
374
|
+
bodyDataSource,
|
|
375
|
+
groupActive,
|
|
376
|
+
groupOptions,
|
|
377
|
+
addGroup,
|
|
378
|
+
updateGroupActive,
|
|
379
|
+
onScrollDown,
|
|
380
|
+
groupDelete,
|
|
381
|
+
groupEdit,
|
|
382
|
+
onHorizontalScroll
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
});
|