vxe-table 4.16.0 → 4.16.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 (37) hide show
  1. package/es/grid/src/grid.js +1 -1
  2. package/es/style.css +1 -1
  3. package/es/table/module/edit/hook.js +55 -17
  4. package/es/table/src/emits.js +2 -0
  5. package/es/table/src/store.js +8 -0
  6. package/es/table/src/table.js +322 -36
  7. package/es/ui/index.js +1 -1
  8. package/es/ui/src/log.js +1 -1
  9. package/lib/grid/src/grid.js +1 -1
  10. package/lib/grid/src/grid.min.js +1 -1
  11. package/lib/index.umd.js +91 -34
  12. package/lib/index.umd.min.js +1 -1
  13. package/lib/style.css +1 -1
  14. package/lib/table/module/edit/hook.js +54 -15
  15. package/lib/table/module/edit/hook.min.js +1 -1
  16. package/lib/table/src/emits.js +1 -1
  17. package/lib/table/src/emits.min.js +1 -1
  18. package/lib/table/src/store.js +15 -0
  19. package/lib/table/src/store.min.js +1 -0
  20. package/lib/table/src/table.js +24 -15
  21. package/lib/table/src/table.min.js +1 -1
  22. package/lib/ui/index.js +1 -1
  23. package/lib/ui/index.min.js +1 -1
  24. package/lib/ui/src/log.js +1 -1
  25. package/lib/ui/src/log.min.js +1 -1
  26. package/package.json +2 -2
  27. package/packages/grid/src/grid.ts +1 -1
  28. package/packages/table/module/edit/hook.ts +55 -19
  29. package/packages/table/src/emits.ts +2 -0
  30. package/packages/table/src/store.ts +14 -0
  31. package/packages/table/src/table.ts +325 -33
  32. /package/es/{iconfont.1756083655214.ttf → iconfont.1756272578850.ttf} +0 -0
  33. /package/es/{iconfont.1756083655214.woff → iconfont.1756272578850.woff} +0 -0
  34. /package/es/{iconfont.1756083655214.woff2 → iconfont.1756272578850.woff2} +0 -0
  35. /package/lib/{iconfont.1756083655214.ttf → iconfont.1756272578850.ttf} +0 -0
  36. /package/lib/{iconfont.1756083655214.woff → iconfont.1756272578850.woff} +0 -0
  37. /package/lib/{iconfont.1756083655214.woff2 → iconfont.1756272578850.woff2} +0 -0
@@ -98,14 +98,18 @@ hooks.add('tableEditModule', {
98
98
  const handleInsertRowAt = (records, targetRow, isInsertNextRow) => {
99
99
  const { treeConfig } = props;
100
100
  const { isRowGroupStatus } = reactData;
101
- const { tableFullTreeData, afterFullData, mergeBodyList, tableFullData, fullDataRowIdData, fullAllDataRowIdData, insertRowMaps } = internalData;
101
+ const { tableFullTreeData, afterFullData, mergeBodyList, tableFullData, fullDataRowIdData, fullAllDataRowIdData, insertRowMaps, removeRowMaps } = internalData;
102
102
  const treeOpts = computeTreeOpts.value;
103
- const { transform, rowField, mapChildrenField } = treeOpts;
103
+ const { transform, parentField, rowField, mapChildrenField } = treeOpts;
104
104
  const childrenField = treeOpts.children || treeOpts.childrenField;
105
105
  if (!XEUtils.isArray(records)) {
106
106
  records = [records];
107
107
  }
108
108
  const newRecords = reactive($xeTable.defineField(records.map((record) => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record))));
109
+ let treeRecords = [];
110
+ if (treeConfig && transform) {
111
+ treeRecords = XEUtils.toArrayTree(newRecords, { key: rowField, parentKey: parentField, children: childrenField });
112
+ }
109
113
  if (XEUtils.eqNull(targetRow)) {
110
114
  // 如果为虚拟树
111
115
  if (treeConfig && transform) {
@@ -171,25 +175,34 @@ hooks.add('tableEditModule', {
171
175
  const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData;
172
176
  const parentRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)];
173
177
  const parentLevel = parentRest ? parentRest.level : 0;
174
- newRecords.forEach((item, i) => {
175
- const rowid = getRowid($xeTable, item);
176
- if (item[treeOpts.parentField]) {
177
- if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
178
- errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`]);
178
+ treeRecords.forEach((row, i) => {
179
+ if (parentRow) {
180
+ if (row[parentField] !== parentRow[rowField]) {
181
+ row[parentField] = parentRow[rowField];
182
+ errLog('vxe.error.errProp', [`${parentField}=${row[parentField]}`, `${parentField}=${parentRow[rowField]}`]);
179
183
  }
180
184
  }
181
- if (parentRow) {
182
- item[treeOpts.parentField] = parentRow[rowField];
185
+ else {
186
+ if (row[parentField] !== null) {
187
+ row[parentField] = null;
188
+ errLog('vxe.error.errProp', [`${parentField}=${row[parentField]}`, 'null']);
189
+ }
183
190
  }
184
191
  let targetIndex = matchMapObj.index + i;
185
192
  if (isInsertNextRow) {
186
193
  targetIndex = targetIndex + 1;
187
194
  }
188
- parentMapChilds.splice(targetIndex, 0, item);
195
+ parentMapChilds.splice(targetIndex, 0, row);
196
+ });
197
+ XEUtils.eachTree(treeRecords, (item) => {
198
+ const rowid = getRowid($xeTable, item);
189
199
  const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
200
+ if (item[childrenField]) {
201
+ item[mapChildrenField] = item[childrenField];
202
+ }
190
203
  fullDataRowIdData[rowid] = rest;
191
204
  fullAllDataRowIdData[rowid] = rest;
192
- });
205
+ }, { children: childrenField });
193
206
  // 源
194
207
  if (parentRow) {
195
208
  const matchObj = XEUtils.findTree(tableFullTreeData, item => targetRow[rowField] === item[rowField], { children: childrenField });
@@ -199,7 +212,7 @@ hooks.add('tableEditModule', {
199
212
  if (isInsertNextRow) {
200
213
  targetIndex = targetIndex + 1;
201
214
  }
202
- parentChilds.splice(targetIndex, 0, ...newRecords);
215
+ parentChilds.splice(targetIndex, 0, ...treeRecords);
203
216
  }
204
217
  }
205
218
  }
@@ -257,10 +270,27 @@ hooks.add('tableEditModule', {
257
270
  }
258
271
  }
259
272
  }
260
- newRecords.forEach(newRow => {
273
+ const handleStatus = (newRow) => {
261
274
  const rowid = getRowid($xeTable, newRow);
262
- insertRowMaps[rowid] = newRow;
263
- });
275
+ // 如果是被删除的数据,则还原状态
276
+ if (removeRowMaps[rowid]) {
277
+ delete removeRowMaps[rowid];
278
+ if (insertRowMaps[rowid]) {
279
+ delete insertRowMaps[rowid];
280
+ }
281
+ }
282
+ else {
283
+ insertRowMaps[rowid] = newRow;
284
+ }
285
+ };
286
+ // 如果为虚拟树
287
+ if (treeConfig && transform) {
288
+ XEUtils.eachTree(treeRecords, handleStatus, { children: mapChildrenField });
289
+ }
290
+ else {
291
+ newRecords.forEach(handleStatus);
292
+ }
293
+ reactData.removeRowFlag++;
264
294
  reactData.insertRowFlag++;
265
295
  $xeTable.cacheRowMap(false);
266
296
  $xeTable.updateScrollYStatus();
@@ -736,7 +766,12 @@ hooks.add('tableEditModule', {
736
766
  const { editStore } = reactData;
737
767
  const { row, column } = editStore.actived;
738
768
  if (column && row) {
739
- return { row, column };
769
+ return {
770
+ row,
771
+ rowIndex: $xeTable.getRowIndex(row),
772
+ column,
773
+ columnIndex: $xeTable.getColumnIndex(column)
774
+ };
740
775
  }
741
776
  return null;
742
777
  },
@@ -747,7 +782,10 @@ hooks.add('tableEditModule', {
747
782
  const { editStore } = reactData;
748
783
  const { row, column } = editStore.selected;
749
784
  if (row && column) {
750
- return { row, column };
785
+ return {
786
+ row,
787
+ column
788
+ };
751
789
  }
752
790
  return null;
753
791
  },
@@ -51,6 +51,8 @@ export const tableEmits = [
51
51
  'row-dragstart',
52
52
  'row-dragover',
53
53
  'row-dragend',
54
+ 'row-remove-dragend',
55
+ 'row-insert-dragend',
54
56
  'column-dragstart',
55
57
  'column-dragover',
56
58
  'column-dragend',
@@ -0,0 +1,8 @@
1
+ import { reactive } from 'vue';
2
+ // 跨表拖拽
3
+ export const crossTableDragRowInfo = reactive({
4
+ row: null
5
+ });
6
+ export function getCrossTableDragRowInfo() {
7
+ return crossTableDragRowInfo;
8
+ }