vxe-table 3.12.13 → 3.12.15

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 (64) hide show
  1. package/es/index.css +1 -1
  2. package/es/index.min.css +1 -1
  3. package/es/style.css +1 -1
  4. package/es/style.min.css +1 -1
  5. package/es/table/module/edit/mixin.js +36 -21
  6. package/es/table/module/export/mixin.js +3 -2
  7. package/es/table/module/validator/mixin.js +18 -1
  8. package/es/table/render/index.js +104 -43
  9. package/es/table/src/body.js +1 -0
  10. package/es/table/src/header.js +4 -2
  11. package/es/table/src/methods.js +158 -116
  12. package/es/table/src/table.js +44 -7
  13. package/es/table/style.css +33 -2
  14. package/es/table/style.min.css +1 -1
  15. package/es/ui/index.js +1 -1
  16. package/es/ui/src/log.js +1 -1
  17. package/es/vxe-table/style.css +33 -2
  18. package/es/vxe-table/style.min.css +1 -1
  19. package/lib/index.css +1 -1
  20. package/lib/index.min.css +1 -1
  21. package/lib/index.umd.js +434 -248
  22. package/lib/index.umd.min.js +1 -1
  23. package/lib/style.css +1 -1
  24. package/lib/style.min.css +1 -1
  25. package/lib/table/module/edit/mixin.js +42 -21
  26. package/lib/table/module/edit/mixin.min.js +1 -1
  27. package/lib/table/module/export/mixin.js +3 -2
  28. package/lib/table/module/export/mixin.min.js +1 -1
  29. package/lib/table/module/validator/mixin.js +26 -4
  30. package/lib/table/module/validator/mixin.min.js +1 -1
  31. package/lib/table/render/index.js +109 -41
  32. package/lib/table/render/index.min.js +1 -1
  33. package/lib/table/src/body.js +1 -0
  34. package/lib/table/src/body.min.js +1 -1
  35. package/lib/table/src/header.js +4 -2
  36. package/lib/table/src/header.min.js +1 -1
  37. package/lib/table/src/methods.js +207 -169
  38. package/lib/table/src/methods.min.js +1 -1
  39. package/lib/table/src/table.js +40 -7
  40. package/lib/table/src/table.min.js +1 -1
  41. package/lib/table/style/style.css +33 -2
  42. package/lib/table/style/style.min.css +1 -1
  43. package/lib/ui/index.js +1 -1
  44. package/lib/ui/index.min.js +1 -1
  45. package/lib/ui/src/log.js +1 -1
  46. package/lib/ui/src/log.min.js +1 -1
  47. package/lib/vxe-table/style/style.css +33 -2
  48. package/lib/vxe-table/style/style.min.css +1 -1
  49. package/package.json +2 -2
  50. package/packages/table/module/edit/mixin.ts +42 -21
  51. package/packages/table/module/export/mixin.ts +3 -2
  52. package/packages/table/module/validator/mixin.ts +20 -2
  53. package/packages/table/render/index.ts +120 -51
  54. package/packages/table/src/body.ts +1 -0
  55. package/packages/table/src/header.ts +4 -2
  56. package/packages/table/src/methods.ts +169 -114
  57. package/packages/table/src/table.ts +47 -7
  58. package/styles/components/table.scss +31 -2
  59. /package/es/{iconfont.1739152166680.ttf → iconfont.1739257460253.ttf} +0 -0
  60. /package/es/{iconfont.1739152166680.woff → iconfont.1739257460253.woff} +0 -0
  61. /package/es/{iconfont.1739152166680.woff2 → iconfont.1739257460253.woff2} +0 -0
  62. /package/lib/{iconfont.1739152166680.ttf → iconfont.1739257460253.ttf} +0 -0
  63. /package/lib/{iconfont.1739152166680.woff → iconfont.1739257460253.woff} +0 -0
  64. /package/lib/{iconfont.1739152166680.woff2 → iconfont.1739257460253.woff2} +0 -0
@@ -5,6 +5,15 @@ import { getCellValue, setCellValue, getRowid } from '../../src/util';
5
5
  import { browse, removeClass, addClass } from '../../../ui/src/dom';
6
6
  import { warnLog, errLog } from '../../../ui/src/log';
7
7
  const { getConfig, renderer, getI18n } = VxeUI;
8
+ function removeCellSelectedClass($xeTable) {
9
+ const el = $xeTable.$refs.refElem;
10
+ if (el) {
11
+ const cell = el.querySelector('.col--selected');
12
+ if (cell) {
13
+ removeClass(cell, 'col--selected');
14
+ }
15
+ }
16
+ }
8
17
  function insertTreeRow(_vm, newRecords, isAppend) {
9
18
  const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm;
10
19
  const { rowField, parentField, mapChildrenField } = treeOpts;
@@ -293,7 +302,7 @@ export default {
293
302
  const treeOpts = $xeTable.computeTreeOpts;
294
303
  const { transform, mapChildrenField } = treeOpts;
295
304
  const childrenField = treeOpts.children || treeOpts.childrenField;
296
- const { actived, removeList, insertMaps } = editStore;
305
+ const { actived, removeMaps, insertMaps } = editStore;
297
306
  const { checkField } = checkboxOpts;
298
307
  let delList = [];
299
308
  if (!rows) {
@@ -305,7 +314,8 @@ export default {
305
314
  // 如果是新增,则保存记录
306
315
  rows.forEach(row => {
307
316
  if (!$xeTable.isInsertByRow(row)) {
308
- removeList.push(row);
317
+ const rowid = getRowid($xeTable, row);
318
+ removeMaps[rowid] = row;
309
319
  }
310
320
  });
311
321
  // 如果绑定了多选属性,则更新状态
@@ -467,7 +477,15 @@ export default {
467
477
  * 获取已删除的数据
468
478
  */
469
479
  _getRemoveRecords() {
470
- return this.editStore.removeList;
480
+ const $xeTable = this;
481
+ const reactData = $xeTable;
482
+ const { editStore } = reactData;
483
+ const { removeMaps } = editStore;
484
+ const removeRecords = [];
485
+ XEUtils.each(removeMaps, (row) => {
486
+ removeRecords.push(row);
487
+ });
488
+ return removeRecords;
471
489
  },
472
490
  /**
473
491
  * 获取更新数据
@@ -649,11 +667,6 @@ export default {
649
667
  }
650
668
  focused.row = null;
651
669
  focused.column = null;
652
- $xeTable.$nextTick(() => {
653
- if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
654
- return $xeTable.handleRecalculateCellAreas();
655
- }
656
- });
657
670
  if (validOpts.autoClear) {
658
671
  if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
659
672
  if ($xeTable.clearValidate) {
@@ -661,7 +674,11 @@ export default {
661
674
  }
662
675
  }
663
676
  }
664
- return $xeTable.$nextTick();
677
+ return $xeTable.$nextTick().then(() => {
678
+ if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
679
+ return $xeTable.handleRecalculateCellAreas();
680
+ }
681
+ });
665
682
  },
666
683
  _getActiveRecord() {
667
684
  if (process.env.NODE_ENV === 'development') {
@@ -830,7 +847,7 @@ export default {
830
847
  selected.row = row;
831
848
  selected.column = column;
832
849
  if (isMouseSelected) {
833
- this.addColSdCls();
850
+ this.addCellSelectedClass();
834
851
  }
835
852
  this.focus();
836
853
  if (evnt) {
@@ -856,11 +873,12 @@ export default {
856
873
  * 清除所选中源状态
857
874
  */
858
875
  _clearSelected() {
876
+ const $xeTable = this;
859
877
  const { selected } = this.editStore;
860
878
  selected.row = null;
861
879
  selected.column = null;
862
880
  this.reColTitleSdCls();
863
- this.reColSdCls();
881
+ removeCellSelectedClass($xeTable);
864
882
  return this.$nextTick();
865
883
  },
866
884
  reColTitleSdCls() {
@@ -869,18 +887,15 @@ export default {
869
887
  XEUtils.arrayEach(headerElem.querySelectorAll('.col--title-selected'), elem => removeClass(elem, 'col--title-selected'));
870
888
  }
871
889
  },
872
- reColSdCls() {
873
- const cell = this.$el.querySelector('.col--selected');
874
- if (cell) {
875
- removeClass(cell, 'col--selected');
876
- }
877
- },
878
- addColSdCls() {
879
- const { selected } = this.editStore;
890
+ addCellSelectedClass() {
891
+ const $xeTable = this;
892
+ const reactData = $xeTable;
893
+ const { editStore } = reactData;
894
+ const { selected } = editStore;
880
895
  const { row, column } = selected;
881
- this.reColSdCls();
896
+ removeCellSelectedClass($xeTable);
882
897
  if (row && column) {
883
- const cell = this.getCellElement(row, column);
898
+ const cell = $xeTable.getCellElement(row, column);
884
899
  if (cell) {
885
900
  addClass(cell, 'col--selected');
886
901
  }
@@ -2,6 +2,7 @@ import XEUtils from 'xe-utils';
2
2
  import { VxeUI } from '../../../ui';
3
3
  import { isColumnInfo, mergeBodyMethod, getCellValue } from '../../src/util';
4
4
  import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils';
5
+ import { hasClass } from '../../../ui/src/dom';
5
6
  import { createHtmlPage, getExportBlobByContent } from './util';
6
7
  import { warnLog, errLog } from '../../../ui/src/log';
7
8
  const { getI18n, renderer } = VxeUI;
@@ -121,7 +122,7 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
121
122
  }
122
123
  else {
123
124
  const cell = $xeTable.getCellElement(row, column);
124
- if (cell) {
125
+ if (cell && !hasClass(cell, 'is--progress')) {
125
126
  cellValue = cell.innerText.trim();
126
127
  }
127
128
  }
@@ -182,7 +183,7 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
182
183
  }
183
184
  else {
184
185
  const cell = $xeTable.getCellElement(row, column);
185
- if (cell) {
186
+ if (cell && !hasClass(cell, 'is--progress')) {
186
187
  cellValue = cell.innerText.trim();
187
188
  }
188
189
  }
@@ -147,8 +147,16 @@ export default {
147
147
  * 返回 Promise 对象,或者使用回调方式
148
148
  */
149
149
  beginValidate(rows, cols, cb, isFull) {
150
+ const $xeTable = this;
151
+ const props = $xeTable;
152
+ const reactData = $xeTable;
153
+ const internalData = $xeTable;
150
154
  const validRest = {};
151
- const { editRules, afterFullData, treeConfig, treeOpts } = this;
155
+ const { editRules, treeConfig } = props;
156
+ const { editStore, pendingRowMaps } = reactData;
157
+ const { afterFullData } = internalData;
158
+ const { removeMaps } = editStore;
159
+ const treeOpts = $xeTable.computeTreeOpts;
152
160
  const childrenField = treeOpts.children || treeOpts.childrenField;
153
161
  let validList;
154
162
  if (rows === true) {
@@ -173,6 +181,15 @@ export default {
173
181
  if (editRules) {
174
182
  const columns = cols && cols.length ? cols : this.getColumns();
175
183
  const handleVaild = (row) => {
184
+ const rowid = getRowid($xeTable, row);
185
+ // 是否删除
186
+ if (removeMaps[rowid]) {
187
+ return;
188
+ }
189
+ // 是否标记删除
190
+ if (pendingRowMaps[rowid]) {
191
+ return;
192
+ }
176
193
  if (isFull || !this.validRuleErr) {
177
194
  const colVailds = [];
178
195
  columns.forEach((column) => {
@@ -92,10 +92,11 @@ function getCellLabelVNs(h, renderOpts, params, cellLabel) {
92
92
  * @param modelFunc
93
93
  * @param changeFunc
94
94
  */
95
- function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
95
+ function getNativeElementOns(renderOpts, params, eFns) {
96
96
  const { events } = renderOpts;
97
97
  const modelEvent = getModelEvent(renderOpts);
98
98
  const changeEvent = getChangeEvent(renderOpts);
99
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
99
100
  const isSameEvent = changeEvent === modelEvent;
100
101
  const ons = {};
101
102
  if (events) {
@@ -117,15 +118,24 @@ function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
117
118
  };
118
119
  }
119
120
  if (!isSameEvent && changeFunc) {
120
- ons[getOnName(changeEvent)] = function (...args) {
121
- changeFunc(...args);
121
+ ons[getOnName(changeEvent)] = function (evnt) {
122
+ changeFunc(evnt);
122
123
  if (events && events[changeEvent]) {
123
- events[changeEvent](params, ...args);
124
+ events[changeEvent](params, evnt);
125
+ }
126
+ };
127
+ }
128
+ if (blurFunc) {
129
+ ons[getOnName(blurEvent)] = function (evnt) {
130
+ blurFunc(evnt);
131
+ if (events && events[blurEvent]) {
132
+ events[blurEvent](params, evnt);
124
133
  }
125
134
  };
126
135
  }
127
136
  return ons;
128
137
  }
138
+ const blurEvent = 'blur';
129
139
  /**
130
140
  * 组件事件处理
131
141
  * @param renderOpts
@@ -133,10 +143,11 @@ function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
133
143
  * @param modelFunc
134
144
  * @param changeFunc
135
145
  */
136
- function getComponentOns(renderOpts, params, modelFunc, changeFunc) {
146
+ function getComponentOns(renderOpts, params, eFns) {
137
147
  const { events } = renderOpts;
138
148
  const modelEvent = getModelEvent(renderOpts);
139
149
  const changeEvent = getChangeEvent(renderOpts);
150
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
140
151
  const ons = {};
141
152
  XEUtils.objectEach(events, (func, key) => {
142
153
  ons[getOnName(key)] = function (...args) {
@@ -164,6 +175,14 @@ function getComponentOns(renderOpts, params, modelFunc, changeFunc) {
164
175
  }
165
176
  };
166
177
  }
178
+ if (blurFunc) {
179
+ ons[getOnName(blurEvent)] = function (...args) {
180
+ blurFunc(...args);
181
+ if (events && events[blurEvent]) {
182
+ events[blurEvent](params, ...args);
183
+ }
184
+ };
185
+ }
167
186
  return ons;
168
187
  }
169
188
  function getEditOns(renderOpts, params) {
@@ -171,59 +190,101 @@ function getEditOns(renderOpts, params) {
171
190
  const { name } = renderOpts;
172
191
  const { model } = column;
173
192
  const isImmediate = isImmediateCell(renderOpts, params);
174
- return getComponentOns(renderOpts, params, (cellValue) => {
175
- // 处理 model 值双向绑定
176
- model.update = true;
177
- model.value = cellValue;
178
- if (isImmediate) {
179
- setCellValue(row, column, cellValue);
180
- }
181
- }, (eventParams) => {
182
- // 处理 change 事件相关逻辑
183
- if (!isImmediate && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
184
- const cellValue = eventParams.value;
193
+ return getComponentOns(renderOpts, params, {
194
+ model(cellValue) {
195
+ // 处理 model 值双向绑定
185
196
  model.update = true;
186
197
  model.value = cellValue;
187
- $table.updateStatus(params, cellValue);
188
- }
189
- else {
190
- $table.updateStatus(params);
198
+ if (isImmediate) {
199
+ setCellValue(row, column, cellValue);
200
+ }
201
+ },
202
+ change(eventParams) {
203
+ // 处理 change 事件相关逻辑
204
+ if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
205
+ const cellValue = eventParams.value;
206
+ model.update = true;
207
+ model.value = cellValue;
208
+ $table.updateStatus(params, cellValue);
209
+ }
210
+ else {
211
+ $table.updateStatus(params);
212
+ }
213
+ },
214
+ blur() {
215
+ if (isImmediate) {
216
+ $table.handleCellRuleUpdateStatus('blur', params);
217
+ }
218
+ else {
219
+ $table.handleCellRuleUpdateStatus('blur', params, model.value);
220
+ }
191
221
  }
192
222
  });
193
223
  }
194
224
  function getFilterOns(renderOpts, params, option) {
195
- return getComponentOns(renderOpts, params, (value) => {
196
- // 处理 model 值双向绑定
197
- option.data = value;
198
- }, () => {
199
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
225
+ return getComponentOns(renderOpts, params, {
226
+ model(value) {
227
+ // 处理 model 值双向绑定
228
+ option.data = value;
229
+ },
230
+ change() {
231
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
232
+ },
233
+ blur() {
234
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
235
+ }
200
236
  });
201
237
  }
202
238
  function getNativeEditOns(renderOpts, params) {
203
239
  const { $table, row, column } = params;
204
240
  const { model } = column;
205
- return getNativeElementOns(renderOpts, params, (evnt) => {
206
- // 处理 model 值双向绑定
207
- const cellValue = evnt.target.value;
208
- if (isImmediateCell(renderOpts, params)) {
209
- setCellValue(row, column, cellValue);
210
- }
211
- else {
212
- model.update = true;
213
- model.value = cellValue;
241
+ return getNativeElementOns(renderOpts, params, {
242
+ model(evnt) {
243
+ // 处理 model 值双向绑定
244
+ const targetEl = evnt.target;
245
+ if (targetEl) {
246
+ const cellValue = targetEl.value;
247
+ if (isImmediateCell(renderOpts, params)) {
248
+ setCellValue(row, column, cellValue);
249
+ }
250
+ else {
251
+ model.update = true;
252
+ model.value = cellValue;
253
+ }
254
+ }
255
+ },
256
+ change(evnt) {
257
+ // 处理 change 事件相关逻辑
258
+ const targetEl = evnt.target;
259
+ if (targetEl) {
260
+ const cellValue = targetEl.value;
261
+ $table.updateStatus(params, cellValue);
262
+ }
263
+ },
264
+ blur(evnt) {
265
+ const targetEl = evnt.target;
266
+ if (targetEl) {
267
+ const cellValue = targetEl.value;
268
+ $table.updateStatus(params, cellValue);
269
+ }
214
270
  }
215
- }, (evnt) => {
216
- // 处理 change 事件相关逻辑
217
- const cellValue = evnt.target.value;
218
- $table.updateStatus(params, cellValue);
219
271
  });
220
272
  }
221
273
  function getNativeFilterOns(renderOpts, params, option) {
222
- return getNativeElementOns(renderOpts, params, (evnt) => {
223
- // 处理 model 值双向绑定
224
- option.data = evnt.target.value;
225
- }, () => {
226
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
274
+ return getNativeElementOns(renderOpts, params, {
275
+ model(evnt) {
276
+ // 处理 model 值双向绑定
277
+ const targetEl = evnt.target;
278
+ if (targetEl) {
279
+ option.data = targetEl.value;
280
+ }
281
+ },
282
+ change() {
283
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
284
+ },
285
+ blur() {
286
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
287
+ }
227
288
  });
228
289
  }
229
290
  /**
@@ -357,6 +357,7 @@ function renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel,
357
357
  'fixed--width': !isAutoCellWidth,
358
358
  'fixed--hidden': fixedHiddenColumn,
359
359
  'is--padding': isCellPadding,
360
+ 'is--progress': (fixedHiddenColumn && isAllOverflow) || isVNPreEmptyStatus,
360
361
  'is--drag-cell': isRowDragCell && (isCrossDrag || isPeerDrag || !rowLevel),
361
362
  'is--drag-disabled': isDisabledDrag,
362
363
  'col--dirty': isDirty,
@@ -81,8 +81,10 @@ const renderRows = (h, _vm, isGroup, isOptimizeMode, cols, $rowIndex) => {
81
81
  const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable));
82
82
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
83
83
  let isVNPreEmptyStatus = false;
84
- if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
85
- isVNPreEmptyStatus = true;
84
+ if (!isGroup) {
85
+ if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
86
+ isVNPreEmptyStatus = true;
87
+ }
86
88
  }
87
89
  const tcStyle = {};
88
90
  if (hasEllipsis) {