@jetlinks-web/components 3.1.15 → 3.2.1

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.
Files changed (57) hide show
  1. package/es/EditTable/CellRender.js +69 -3
  2. package/es/EditTable/EditTable.js +108 -165
  3. package/es/EditTable/FormItem.js +234 -95
  4. package/es/EditTable/consts.js +13 -13
  5. package/es/EditTable/context.js +3 -2
  6. package/es/EditTable/fieldPool.js +166 -0
  7. package/es/EditTable/hooks/index.js +4 -2
  8. package/es/EditTable/hooks/useValidate.js +121 -51
  9. package/es/EditTable/hooks/useVirtualTreeTable.js +111 -0
  10. package/es/EditTable/index.js +0 -4
  11. package/es/EditTable/style/body.js +15 -2
  12. package/es/EditTable/style/form.js +2 -2
  13. package/es/EditTable/style/header.js +2 -2
  14. package/es/EditTable/style/table.js +2 -1
  15. package/es/Icon/icon.js +3 -3
  16. package/es/ProTable/ProTable.js +5 -0
  17. package/es/Search/Advanced/index.js +1 -1
  18. package/es/Search/Item.js +13 -1
  19. package/es/Search/util.js +1 -1
  20. package/es/VirtualTable/Table.js +367 -0
  21. package/es/VirtualTable/VirtualBody.js +94 -0
  22. package/es/VirtualTable/index.js +1 -1
  23. package/es/VirtualTable/useTreeData.js +243 -0
  24. package/es/VirtualTable/useVirtualScroll.js +159 -0
  25. package/lib/EditTable/CellRender.js +69 -3
  26. package/lib/EditTable/EditTable.js +108 -165
  27. package/lib/EditTable/FormItem.js +234 -95
  28. package/lib/EditTable/consts.js +13 -13
  29. package/lib/EditTable/context.js +3 -2
  30. package/lib/EditTable/fieldPool.js +173 -0
  31. package/lib/EditTable/hooks/index.js +15 -2
  32. package/lib/EditTable/hooks/useValidate.js +120 -50
  33. package/lib/EditTable/hooks/useVirtualTreeTable.js +117 -0
  34. package/lib/EditTable/index.js +0 -4
  35. package/lib/EditTable/style/body.js +15 -2
  36. package/lib/EditTable/style/form.js +2 -2
  37. package/lib/EditTable/style/header.js +2 -2
  38. package/lib/EditTable/style/table.js +2 -1
  39. package/lib/Icon/icon.js +3 -3
  40. package/lib/ProTable/ProTable.js +5 -0
  41. package/lib/Search/Advanced/index.js +1 -1
  42. package/lib/Search/Item.js +13 -1
  43. package/lib/Search/util.js +1 -1
  44. package/lib/VirtualTable/Table.js +374 -0
  45. package/lib/VirtualTable/VirtualBody.js +100 -0
  46. package/lib/VirtualTable/index.js +4 -4
  47. package/lib/VirtualTable/useTreeData.js +250 -0
  48. package/lib/VirtualTable/useVirtualScroll.js +165 -0
  49. package/package.json +3 -3
  50. package/es/EditTable/Body.js +0 -312
  51. package/es/EditTable/Header.js +0 -164
  52. package/es/EditTable/HeaderRender.js +0 -12
  53. package/es/VirtualTable/VirtualTable.js +0 -482
  54. package/lib/EditTable/Body.js +0 -312
  55. package/lib/EditTable/Header.js +0 -164
  56. package/lib/EditTable/HeaderRender.js +0 -12
  57. package/lib/VirtualTable/VirtualTable.js +0 -482
@@ -1,11 +1,77 @@
1
+ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
+ const op = ops[i];
3
+ const fn = ops[i + 1];
4
+ i += 2;
5
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
6
+ return undefined;
7
+ }
8
+ if (op === 'access' || op === 'optionalAccess') {
9
+ lastAccessLHS = value;
10
+ value = fn(value);
11
+ }
12
+ else if (op === 'call' || op === 'optionalCall') {
13
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
14
+ lastAccessLHS = undefined;
15
+ }
16
+ } return value; }
1
17
  /* Analyzed bindings: {} */
2
- import { defineComponent } from 'vue';
18
+ import { defineComponent, h, shallowRef, } from 'vue';
19
+ /**
20
+ * CellRender - 优化的单元格渲染组件
21
+ * 使用 shallowRef 和手动更新检查来避免不必要的重渲染
22
+ */
3
23
  const __sfc_main__ = defineComponent({
4
24
  name: "CellRender",
5
- props: ['renderFn', 'value', 'record', 'index'],
25
+ props: {
26
+ renderFn: {
27
+ type: Function,
28
+ required: true
29
+ },
30
+ value: null,
31
+ record: {
32
+ type: Object,
33
+ required: true
34
+ },
35
+ index: {
36
+ type: Number,
37
+ required: true
38
+ }
39
+ },
6
40
  setup(props) {
41
+ // 使用 shallowRef 避免深度响应式
42
+ const cachedResult = shallowRef(null);
43
+ const lastValue = shallowRef(undefined);
44
+ const lastRecordId = shallowRef(undefined);
45
+ // 手动检查是否需要重新渲染
46
+ const shouldUpdate = () => {
47
+ // 检查 value 是否变化
48
+ if (props.value !== lastValue.value) {
49
+ return true;
50
+ }
51
+ // 检查 record 的关键属性是否变化(假设有 id 或 key)
52
+ const currentRecordId = _optionalChain([(props.record), 'optionalAccess', _ => _.id]) || _optionalChain([(props.record), 'optionalAccess', _2 => _2.key]);
53
+ if (currentRecordId !== lastRecordId.value) {
54
+ return true;
55
+ }
56
+ return false;
57
+ };
58
+ // 执行渲染函数
59
+ const render = () => {
60
+ if (shouldUpdate() || cachedResult.value === null) {
61
+ lastValue.value = props.value;
62
+ lastRecordId.value = _optionalChain([(props.record), 'optionalAccess', _3 => _3.id]) || _optionalChain([(props.record), 'optionalAccess', _4 => _4.key]);
63
+ try {
64
+ cachedResult.value = props.renderFn(props.value, props.record, props.index);
65
+ }
66
+ catch (error) {
67
+ console.error('[CellRender] Render error:', error);
68
+ cachedResult.value = null;
69
+ }
70
+ }
71
+ return cachedResult.value;
72
+ };
7
73
  return () => {
8
- return props.renderFn(props.value, props.record, props.index);
74
+ return h('div', { class: 'cell-render-wrapper' }, [render()]);
9
75
  };
10
76
  }
11
77
  });
@@ -30,9 +30,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
30
30
  "TABLE_OPEN_GROUP": "setup-maybe-ref",
31
31
  "TABLE_TOOL": "setup-maybe-ref",
32
32
  "TABLE_WRAPPER": "setup-maybe-ref",
33
- "handleColumnsWidth": "setup-maybe-ref",
34
33
  "useGroup": "setup-maybe-ref",
35
- "useResizeObserver": "setup-maybe-ref",
36
34
  "useValidate": "setup-maybe-ref",
37
35
  "tableProps": "setup-maybe-ref",
38
36
  "useFormContext": "setup-maybe-ref",
@@ -47,9 +45,8 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
47
45
  "findIndex": "setup-maybe-ref",
48
46
  "get": "setup-maybe-ref",
49
47
  "sortBy": "setup-maybe-ref",
50
- "Header": "setup-const",
51
- "Body": "setup-const",
52
48
  "Group": "setup-const",
49
+ "VirtualTable": "setup-maybe-ref",
53
50
  "useLocaleReceiver": "setup-maybe-ref",
54
51
  "useEditTableStyle": "setup-maybe-ref",
55
52
  "emit": "setup-const",
@@ -59,15 +56,10 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
59
56
  "wrapSSR": "setup-maybe-ref",
60
57
  "hashId": "setup-maybe-ref",
61
58
  "slots": "setup-maybe-ref",
62
- "myColumns": "setup-ref",
63
59
  "tableWrapper": "setup-ref",
64
- "tableBody": "setup-ref",
65
- "scrollBarRef": "setup-ref",
66
- "tableStyle": "setup-reactive-const",
67
- "showScroll": "setup-ref",
68
- "horizontalScrollWidth": "setup-ref",
60
+ "virtualTableRef": "setup-ref",
69
61
  "horizontalScrollLeft": "setup-ref",
70
- "fields": "setup-const",
62
+ "fields": "setup-maybe-ref",
71
63
  "defaultGroupId": "literal-const",
72
64
  "fieldsErrMap": "setup-ref",
73
65
  "fieldsGroupError": "setup-ref",
@@ -81,6 +73,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
81
73
  "updateGroupOptions": "setup-maybe-ref",
82
74
  "_dataSource": "setup-ref",
83
75
  "bodyDataSource": "setup-ref",
76
+ "scroll": "setup-ref",
84
77
  "isFullscreen": "setup-maybe-ref",
85
78
  "toggle": "setup-maybe-ref",
86
79
  "rules": "setup-maybe-ref",
@@ -93,9 +86,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
93
86
  "removeFieldError": "setup-const",
94
87
  "addFieldError": "setup-const",
95
88
  "scrollWidth": "setup-ref",
96
- "handleColumns": "setup-const",
97
- "onResize": "setup-const",
98
- "onScrollDown": "setup-const",
89
+ "newColumns": "setup-ref",
99
90
  "rightMenu": "setup-const",
100
91
  "scrollToById": "setup-const",
101
92
  "scrollToByIndex": "setup-const",
@@ -103,33 +94,34 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
103
94
  "groupDelete": "setup-const",
104
95
  "groupEdit": "setup-const",
105
96
  "getGroupActive": "setup-const",
106
- "onHorizontalScroll": "setup-const"
97
+ "onScrollDown": "setup-const"
107
98
  } */
108
- import { unref as _unref, renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, createVNode as _createVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createBlock as _createBlock, normalizeClass as _normalizeClass } from "vue";
99
+ import { defineComponent as _defineComponent } from 'vue';
100
+ import { unref as _unref, renderSlot as _renderSlot, createElementVNode as _createElementVNode, mergeProps as _mergeProps, withCtx as _withCtx, createVNode as _createVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createBlock as _createBlock, normalizeClass as _normalizeClass } from "vue";
109
101
  const _hoisted_1 = { class: "jetlinks-edit-table-extra" };
110
102
  const _hoisted_2 = { class: "jetlinks-edit-table" };
111
- const _hoisted_3 = {
103
+ const _hoisted_3 = { class: "jetlinks-edit-table-body" };
104
+ const _hoisted_4 = {
112
105
  key: 0,
113
- class: "jetlinks-table-horizontal-scroll"
106
+ class: "readonly-mask"
114
107
  };
115
108
  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';
116
- import { handleColumnsWidth } from './utils';
117
- import { useGroup, useResizeObserver, useValidate } from './hooks';
109
+ import { useGroup, useValidate } from './hooks';
118
110
  import { tableProps } from 'ant-design-vue/lib/table';
119
111
  import { useFormContext } from './context';
120
112
  import { useFullscreen } from '@vueuse/core';
121
113
  import { provide, useSlots, ref, reactive, computed, watch } from 'vue';
122
114
  import { bodyProps } from "./props";
123
115
  import { findIndex, get, sortBy } from 'lodash-es';
124
- import Header from './Header.js';
125
- import Body from './Body.js';
126
116
  import Group from './group.js';
117
+ import VirtualTable from '../VirtualTable/Table';
127
118
  import { useLocaleReceiver } from "../LocaleReciver";
128
119
  import useEditTableStyle from './style';
129
120
  const defaultGroupId = 'group_1';
130
- const __sfc_main__ = Object.assign({
131
- name: 'JEditTable'
132
- }, {
121
+ const __sfc_main__ = _defineComponent({
122
+ ...{
123
+ name: 'JEditTable'
124
+ },
133
125
  props: {
134
126
  ...tableProps(),
135
127
  ...bodyProps(),
@@ -140,7 +132,7 @@ const __sfc_main__ = Object.assign({
140
132
  serial: {
141
133
  type: [Object, Boolean],
142
134
  default: () => ({
143
- width: 66,
135
+ width: 70,
144
136
  title: ''
145
137
  })
146
138
  },
@@ -153,7 +145,7 @@ const __sfc_main__ = Object.assign({
153
145
  default: false
154
146
  }
155
147
  },
156
- emits: ['scrollDown', 'rightMenuClick', 'editChange', 'searchVisibleChange'],
148
+ emits: ['scrollDown', 'rightMenuClick', 'editChange', 'searchVisibleChange', 'groupDelete', 'groupEdit'],
157
149
  setup(__props, { expose: __expose, emit: __emit }) {
158
150
  const emit = __emit;
159
151
  const [contextLocale] = useLocaleReceiver('EditTable');
@@ -161,18 +153,11 @@ const __sfc_main__ = Object.assign({
161
153
  const prefixCls = computed(() => 'jetlinks-edit-table');
162
154
  const [wrapSSR, hashId] = useEditTableStyle(prefixCls);
163
155
  const slots = useSlots();
164
- const myColumns = ref([]);
165
156
  const tableWrapper = ref();
166
- const tableBody = ref();
167
- const scrollBarRef = ref();
168
- const tableStyle = reactive({
169
- width: '100%',
170
- height: props.height
171
- });
172
- const showScroll = ref(false);
173
- const horizontalScrollWidth = ref(0);
157
+ const virtualTableRef = ref();
174
158
  const horizontalScrollLeft = ref(0);
175
- const fields = {};
159
+ // 使用 Map 管理字段,性能优于普通对象
160
+ const fields = new Map();
176
161
  const fieldsErrMap = ref({});
177
162
  const fieldsGroupError = ref({});
178
163
  const scrollDefaultWidth = ref(17);
@@ -183,15 +168,17 @@ const __sfc_main__ = Object.assign({
183
168
  dataIndex: undefined
184
169
  });
185
170
  const { groupActive, groupOptions, addGroup, removeGroup, updateGroupActive, updateGroupOptions } = useGroup(props.openGroup);
171
+ // 处理数据源
186
172
  const _dataSource = computed(() => {
187
173
  const _options = new Map();
188
- const sortDataSource = sortData.key ?
189
- sortBy(props.dataSource, (val) => {
174
+ const sortDataSource = sortData.key
175
+ ? sortBy(props.dataSource, (val) => {
190
176
  if (!val.id)
191
177
  return 99999999;
192
- const index = findIndex(sortData.orderKeys, val2 => get(val, sortData.key) === val2);
178
+ const index = findIndex(sortData.orderKeys, (val2) => get(val, sortData.key) === val2);
193
179
  return sortData.order === 'desc' ? index : ~index + 1;
194
- }) : props.dataSource;
180
+ })
181
+ : props.dataSource;
195
182
  sortDataSource.forEach((item, index) => {
196
183
  item.__dataIndex = index;
197
184
  if (props.openGroup) {
@@ -206,7 +193,7 @@ const __sfc_main__ = Object.assign({
206
193
  value: _optionalChain([item, 'access', _4 => _4.expands, 'optionalAccess', _5 => _5.groupId]),
207
194
  label: _optionalChain([item, 'access', _6 => _6.expands, 'optionalAccess', _7 => _7.groupName]),
208
195
  effective: item.id ? 1 : 0,
209
- len: 1 // 分组数据总长度
196
+ len: 1
210
197
  });
211
198
  }
212
199
  else {
@@ -227,22 +214,30 @@ const __sfc_main__ = Object.assign({
227
214
  }
228
215
  return sortDataSource;
229
216
  });
217
+ // 按分组过滤的数据
230
218
  const bodyDataSource = computed(() => {
231
219
  if (props.openGroup) {
232
- return _dataSource.value.filter(item => {
220
+ return _dataSource.value.filter((item) => {
233
221
  return item.expands.groupId === groupActive.value;
234
222
  });
235
223
  }
236
224
  return _dataSource.value;
237
225
  });
238
- useResizeObserver(tableWrapper, onResize);
226
+ const scroll = computed(() => {
227
+ const _scroll = {
228
+ y: props.height
229
+ };
230
+ if (_optionalChain([props, 'access', _9 => _9.scroll, 'optionalAccess', _10 => _10.x])) {
231
+ _scroll.x = props.scroll.x;
232
+ }
233
+ return _scroll;
234
+ });
239
235
  const { isFullscreen, toggle } = useFullscreen(tableWrapper);
240
236
  const { rules, validateItem, validate, errorMap } = useValidate(_dataSource, props.columns, props.rowKey, {
241
237
  onError: (err) => {
242
238
  fieldsErrMap.value = {};
243
239
  fieldsGroupError.value = {};
244
240
  const errMap = {};
245
- // 显示全部err红标
246
241
  err.forEach((item, errIndex) => {
247
242
  item.forEach((e, eIndex) => {
248
243
  const field = findField(e.__dataIndex, e.field);
@@ -257,7 +252,7 @@ const __sfc_main__ = Object.assign({
257
252
  updateGroupActive(expands.groupId, expands.groupName);
258
253
  }
259
254
  setTimeout(() => {
260
- tableBody.value.scrollTo(e.__serial - 1);
255
+ scrollToByIndex(e.__serial - 1);
261
256
  }, 10);
262
257
  }
263
258
  });
@@ -272,6 +267,7 @@ const __sfc_main__ = Object.assign({
272
267
  },
273
268
  validateRowKey: props.validateRowKey
274
269
  });
270
+ // Provide context
275
271
  provide(TABLE_WRAPPER, tableWrapper);
276
272
  provide(FULL_SCREEN, isFullscreen);
277
273
  provide(RIGHT_MENU, { click: rightMenu, getPopupContainer: () => tableWrapper.value });
@@ -286,11 +282,11 @@ const __sfc_main__ = Object.assign({
286
282
  updateGroupActive(expands.groupId, expands.groupName);
287
283
  }
288
284
  setTimeout(() => {
289
- tableBody.value.scrollTo(record.__serial);
285
+ scrollToByIndex(record.__serial);
290
286
  }, 10);
291
287
  },
292
288
  selected: (keys) => {
293
- tableBody.value.updateSelectedKeys(keys);
289
+ // VirtualTable 通过 rowSelection.selectedRowKeys 控制选中
294
290
  },
295
291
  order: (type, key, orderKeys, dataIndex) => {
296
292
  sortData.key = key;
@@ -310,17 +306,20 @@ const __sfc_main__ = Object.assign({
310
306
  provide(TABLE_GROUP_ACTIVE, groupActive);
311
307
  provide(TABLE_H_SCROLL, horizontalScrollLeft);
312
308
  const addField = (key, field) => {
313
- fields[key] = field;
309
+ fields.set(key, field);
314
310
  };
315
311
  const removeField = (key) => {
316
- delete fields[key];
312
+ fields.delete(key);
317
313
  };
318
314
  function findField(index, name) {
319
- const fieldId = Object.keys(fields).find(key => {
320
- const { names } = fields[key];
321
- return names[0] === index && names[1] === name;
322
- });
323
- return fields[fieldId];
315
+ // 使用 Map 的迭代器,性能更好
316
+ for (const [key, field] of fields.entries()) {
317
+ const { names } = field;
318
+ if (names[0] === index && names[1] === name) {
319
+ return field;
320
+ }
321
+ }
322
+ return undefined;
324
323
  }
325
324
  function removeFieldError(key) {
326
325
  delete fieldsErrMap.value[key];
@@ -331,53 +330,39 @@ const __sfc_main__ = Object.assign({
331
330
  const scrollWidth = computed(() => {
332
331
  return (props.dataSource.length * props.cellHeight) > props.height ? scrollDefaultWidth.value : 0;
333
332
  });
334
- const handleColumns = () => {
335
- let newColumns = [...props.columns];
333
+ const newColumns = computed(() => {
334
+ const _columns = [];
336
335
  if (props.serial) {
337
336
  const serial = {
338
337
  dataIndex: '__serial',
339
- title: props.serial.title || contextLocale.value.serial,
338
+ title: (props.serial).title || contextLocale.value.serial,
340
339
  customRender: (customData) => {
341
- if (_optionalChain([props, 'access', _9 => _9.serial, 'optionalAccess', _10 => _10.customRender])) {
342
- return _optionalChain([props, 'access', _11 => _11.serial, 'optionalAccess', _12 => _12.customRender, 'call', _13 => _13(customData)]);
340
+ const record = customData.record;
341
+ if (_optionalChain([(props.serial), 'optionalAccess', _11 => _11.customRender])) {
342
+ return _optionalChain([(props.serial), 'optionalAccess', _12 => _12.customRender, 'call', _13 => _13(customData)]);
343
343
  }
344
- return customData.index + 1;
344
+ return record.__serial;
345
345
  },
346
- width: _optionalChain([props, 'access', _14 => _14.serial, 'optionalAccess', _15 => _15.width]),
346
+ width: _optionalChain([(props.serial), 'optionalAccess', _14 => _14.width]),
347
347
  fixed: 'left'
348
348
  };
349
- newColumns = [serial, ...props.columns];
349
+ _columns.push(serial);
350
350
  }
351
- myColumns.value = handleColumnsWidth(newColumns, tableStyle.width - scrollWidth.value);
352
- horizontalScrollWidth.value = myColumns.value.reduce((prev, next) => {
353
- prev += next.width;
354
- return prev;
355
- }, 0);
356
- if (horizontalScrollWidth.value > tableStyle.width) {
357
- showScroll.value = true;
358
- }
359
- };
360
- function onResize({ width = 0 }) {
361
- const _width = width - scrollWidth.value;
362
- tableStyle.width = width || '100%';
363
- // const viewportDom = document.querySelector('.jetlinks-edit-table-body-viewport')
364
- // const viewportDivDom = viewportDom.querySelector('div')
365
- //
366
- // scrollDefaultWidth.value = viewportDom.offsetWidth - viewportDivDom.offsetWidth
367
- handleColumns();
368
- }
369
- const onScrollDown = (len) => {
370
- emit('scrollDown', len);
371
- };
351
+ _columns.push(...props.columns);
352
+ return _columns;
353
+ });
372
354
  function rightMenu(menuType, record, copyValue) {
373
355
  emit('rightMenuClick', menuType, record, copyValue);
374
356
  }
375
357
  const scrollToById = (key) => {
376
- const _index = _dataSource.value.findIndex(item => item[props.rowKey] === key);
377
- tableBody.value.scrollTo(_index);
358
+ const _index = _dataSource.value.findIndex((item) => item[props.rowKey] === key);
359
+ scrollToByIndex(_index);
378
360
  };
379
361
  const scrollToByIndex = (index) => {
380
- tableBody.value.scrollTo(index);
362
+ // 通过 VirtualTable 暴露的方法滚动
363
+ if (virtualTableRef.value) {
364
+ virtualTableRef.value.scrollToIndex(index);
365
+ }
381
366
  };
382
367
  const getTableWrapperRef = () => {
383
368
  return tableWrapper.value;
@@ -385,9 +370,9 @@ const __sfc_main__ = Object.assign({
385
370
  const groupDelete = (id, index) => {
386
371
  removeGroup(index);
387
372
  Object.keys(fieldsErrMap.value).forEach(errorKey => {
388
- const [index] = errorKey.split('-');
389
- const dataSourceItem = _dataSource.value[index];
390
- const groupId = _optionalChain([dataSourceItem, 'access', _16 => _16.expands, 'optionalAccess', _17 => _17.groupId]);
373
+ const [idx] = errorKey.split('-');
374
+ const dataSourceItem = _dataSource.value[parseInt(idx)];
375
+ const groupId = _optionalChain([dataSourceItem, 'optionalAccess', _15 => _15.expands, 'optionalAccess', _16 => _16.groupId]);
391
376
  if (groupId === id) {
392
377
  removeFieldError(errorKey);
393
378
  removeField(errorKey);
@@ -401,9 +386,11 @@ const __sfc_main__ = Object.assign({
401
386
  const getGroupActive = () => {
402
387
  return groupActive.value;
403
388
  };
404
- const onHorizontalScroll = (e) => {
405
- horizontalScrollLeft.value = scrollBarRef.value.scrollLeft;
389
+ // VirtualTable 滚动到底部事件
390
+ const onScrollDown = () => {
391
+ emit('scrollDown');
406
392
  };
393
+ // 监听错误变化
407
394
  watch(() => fieldsErrMap.value, (errorMap) => {
408
395
  fieldsGroupError.value = {};
409
396
  if (props.openGroup) {
@@ -411,8 +398,8 @@ const __sfc_main__ = Object.assign({
411
398
  const groupErrorMap = {};
412
399
  Object.keys(_errorObj).forEach(errorKey => {
413
400
  const [index] = errorKey.split('-');
414
- const dataSourceItem = _dataSource.value[index];
415
- const groupId = _optionalChain([dataSourceItem, 'access', _18 => _18.expands, 'optionalAccess', _19 => _19.groupId]);
401
+ const dataSourceItem = _dataSource.value[parseInt(index)];
402
+ const groupId = _optionalChain([dataSourceItem, 'optionalAccess', _17 => _17.expands, 'optionalAccess', _18 => _18.groupId]);
416
403
  const groupError = groupErrorMap[groupId];
417
404
  const groupErrorItem = {
418
405
  [errorKey]: {
@@ -431,16 +418,8 @@ const __sfc_main__ = Object.assign({
431
418
  fieldsGroupError.value = groupErrorMap;
432
419
  }
433
420
  }, { deep: true });
434
- watch(() => scrollWidth.value, () => {
435
- onResize({ width: tableStyle.width });
436
- });
437
- watch(() => [JSON.stringify(props.columns), tableStyle.width], () => {
438
- handleColumns();
439
- });
440
421
  useFormContext({
441
- dataSource: computed(() => {
442
- return props.dataSource;
443
- }),
422
+ dataSource: computed(() => props.dataSource),
444
423
  errorMap,
445
424
  rules,
446
425
  addField,
@@ -474,72 +453,36 @@ const __sfc_main__ = Object.assign({
474
453
  })
475
454
  ]),
476
455
  _createElementVNode("div", _hoisted_2, [
477
- _createElementVNode("div", {
478
- class: "jetlinks-edit-table-header",
479
- style: _normalizeStyle([{ "height": "50px" }, { paddingRight: scrollWidth.value + 'px' }])
480
- }, [
481
- _createVNode(Header, {
482
- columns: myColumns.value,
483
- searchColumns: __props.searchColumns,
484
- style: _normalizeStyle({ width: tableStyle.width, transform: `translateX(-${horizontalScrollLeft.value}px)` })
485
- }, null, 8 /* PROPS */, ["columns", "searchColumns", "style"])
486
- ], 4 /* STYLE */),
487
- _createElementVNode("div", {
488
- class: "jetlinks-edit-table-body",
489
- style: _normalizeStyle({ width: tableStyle.width, height: `${_ctx.height}px` })
490
- }, [
491
- _createVNode(Body, {
492
- ref_key: "tableBody",
493
- ref: tableBody,
494
- dataSource: bodyDataSource.value,
495
- columns: myColumns.value,
496
- cellHeight: _ctx.cellHeight,
497
- height: _ctx.height,
498
- disableMenu: _ctx.disableMenu,
499
- rowKey: _ctx.rowKey,
500
- groupKey: _unref(groupActive).value,
501
- openGroup: _ctx.openGroup,
502
- rowSelection: _ctx.rowSelection,
503
- readonly: __props.readonly,
504
- width: horizontalScrollWidth.value,
505
- onScrollDown: onScrollDown
506
- }, _createSlots({ _: 2 /* DYNAMIC */ }, [
507
- _renderList(_unref(slots), (_, name) => {
508
- return {
509
- name: name,
510
- fn: _withCtx((slotData) => [
511
- _renderSlot(_ctx.$slots, name, _normalizeProps(_guardReactiveProps(slotData || {})))
512
- ])
513
- };
514
- })
515
- ]), 1032 /* PROPS, DYNAMIC_SLOTS */, ["dataSource", "columns", "cellHeight", "height", "disableMenu", "rowKey", "groupKey", "openGroup", "rowSelection", "readonly", "width"]),
456
+ _createElementVNode("div", _hoisted_3, [
457
+ _createVNode(_unref(VirtualTable), _mergeProps(props, {
458
+ "data-source": bodyDataSource.value,
459
+ columns: newColumns.value,
460
+ scroll: scroll.value,
461
+ pagination: false,
462
+ virtual: {
463
+ itemHeight: props.cellHeight,
464
+ overscan: 1,
465
+ threshold: props.height / props.cellHeight
466
+ }
467
+ }), {
468
+ bodyCell: _withCtx(({ column, record }) => [
469
+ _renderSlot(_ctx.$slots, column.dataIndex, {
470
+ column: column,
471
+ record: record
472
+ })
473
+ ]),
474
+ _: 3 /* FORWARDED */
475
+ }, 16 /* FULL_PROPS */, ["data-source", "columns", "scroll", "virtual"]),
476
+ (__props.readonly)
477
+ ? (_openBlock(), _createElementBlock("div", _hoisted_4))
478
+ : _createCommentVNode("v-if", true),
516
479
  _renderSlot(_ctx.$slots, "bodyExtra")
517
- ], 4 /* STYLE */),
518
- (showScroll.value)
519
- ? (_openBlock(), _createElementBlock("div", _hoisted_3, [
520
- _createElementVNode("div", {
521
- class: "jetlinks-table-horizontal-scroll-bar",
522
- ref_key: "scrollBarRef",
523
- ref: scrollBarRef,
524
- style: {
525
- width: 'calc(100% - 15px)',
526
- height: '100%',
527
- overflowX: 'scroll'
528
- },
529
- onScroll: onHorizontalScroll
530
- }, [
531
- _createElementVNode("div", {
532
- style: _normalizeStyle({ minWidth: horizontalScrollWidth.value + 'px', maxWidth: horizontalScrollWidth.value + 'px', height: '100%' })
533
- }, null, 4 /* STYLE */)
534
- ], 544 /* NEED_HYDRATION, NEED_PATCH */),
535
- _cache[1] || (_cache[1] = _createElementVNode("div", { style: { "width": "15px", "height": "100%", "overflow-x": "hidden" } }, null, -1 /* CACHED */))
536
- ]))
537
- : _createCommentVNode("v-if", true),
480
+ ]),
538
481
  (_ctx.dataSource.length && _ctx.openGroup)
539
482
  ? (_openBlock(), _createBlock(Group, {
540
- key: 1,
483
+ key: 0,
541
484
  activeKey: _unref(groupActive).value,
542
- "onUpdate:activeKey": _cache[0] || (_cache[0] = $event => ((_unref(groupActive).value) = $event)),
485
+ "onUpdate:activeKey": _cache[0] || (_cache[0] = ($event) => ((_unref(groupActive).value) = $event)),
543
486
  options: _unref(groupOptions),
544
487
  readonly: __props.readonly,
545
488
  onAdd: _unref(addGroup),