vxe-table 3.7.0-beta.9 → 3.7.0

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 (103) hide show
  1. package/README.md +1 -1
  2. package/helper/vetur/attributes.json +26 -2
  3. package/helper/vetur/tags.json +6 -0
  4. package/lib/button/style/style.css +2 -3
  5. package/lib/button/style/style.min.css +1 -1
  6. package/lib/edit/src/mixin.js +265 -214
  7. package/lib/edit/src/mixin.min.js +1 -1
  8. package/lib/export/src/mixin.js +11 -7
  9. package/lib/export/src/mixin.min.js +1 -1
  10. package/lib/form/src/form-config-item.js +5 -1
  11. package/lib/form/src/form-config-item.min.js +1 -1
  12. package/lib/form/src/form-item.js +9 -1
  13. package/lib/form/src/form-item.min.js +1 -1
  14. package/lib/form/src/form.js +4 -0
  15. package/lib/form/src/form.min.js +1 -1
  16. package/lib/form/style/style.css +12 -0
  17. package/lib/form/style/style.min.css +1 -1
  18. package/lib/icon/style/style.css +1 -1
  19. package/lib/icon/style/style.min.css +1 -1
  20. package/lib/index.css +1 -1
  21. package/lib/index.umd.js +1151 -716
  22. package/lib/index.umd.min.js +1 -1
  23. package/lib/input/src/input.js +24 -1
  24. package/lib/input/src/input.min.js +1 -1
  25. package/lib/input/style/style.css +21 -0
  26. package/lib/input/style/style.min.css +1 -1
  27. package/lib/keyboard/src/mixin.js +4 -1
  28. package/lib/keyboard/src/mixin.min.js +1 -1
  29. package/lib/style.css +1 -1
  30. package/lib/style.min.css +1 -1
  31. package/lib/table/src/body.js +17 -14
  32. package/lib/table/src/body.min.js +1 -1
  33. package/lib/table/src/cell.js +38 -34
  34. package/lib/table/src/cell.min.js +1 -1
  35. package/lib/table/src/methods.js +641 -421
  36. package/lib/table/src/methods.min.js +1 -1
  37. package/lib/table/src/table.js +27 -19
  38. package/lib/table/src/table.min.js +1 -1
  39. package/lib/table/src/util.js +4 -2
  40. package/lib/table/src/util.min.js +1 -1
  41. package/lib/table/style/style.css +2 -2
  42. package/lib/table/style/style.min.css +1 -1
  43. package/lib/tools/log.js +1 -1
  44. package/lib/tools/log.min.js +1 -1
  45. package/lib/tools/utils.js +3 -5
  46. package/lib/tools/utils.min.js +1 -1
  47. package/lib/v-x-e-table/index.js +15 -12
  48. package/lib/v-x-e-table/index.min.js +1 -1
  49. package/lib/v-x-e-table/src/commands.js +7 -7
  50. package/lib/v-x-e-table/src/commands.min.js +1 -1
  51. package/lib/v-x-e-table/src/conf.js +2 -2
  52. package/lib/v-x-e-table/src/conf.min.js +1 -1
  53. package/lib/v-x-e-table/src/{setup.js → config.js} +3 -3
  54. package/lib/v-x-e-table/src/config.min.js +1 -0
  55. package/lib/v-x-e-table/src/formats.js +7 -7
  56. package/lib/v-x-e-table/src/formats.min.js +1 -1
  57. package/lib/v-x-e-table/src/menus.js +7 -7
  58. package/lib/v-x-e-table/src/menus.min.js +1 -1
  59. package/lib/v-x-e-table/src/renderer.js +4 -4
  60. package/lib/v-x-e-table/src/renderer.min.js +1 -1
  61. package/lib/validator/src/mixin.js +4 -1
  62. package/lib/validator/src/mixin.min.js +1 -1
  63. package/package.json +7 -8
  64. package/packages/edit/src/mixin.js +185 -142
  65. package/packages/export/src/mixin.js +9 -7
  66. package/packages/form/src/form-config-item.js +4 -2
  67. package/packages/form/src/form-item.js +8 -2
  68. package/packages/form/src/form.js +4 -0
  69. package/packages/input/src/input.js +24 -1
  70. package/packages/keyboard/src/mixin.js +2 -1
  71. package/packages/table/src/body.js +17 -14
  72. package/packages/table/src/cell.js +32 -23
  73. package/packages/table/src/methods.js +476 -230
  74. package/packages/table/src/table.js +25 -17
  75. package/packages/table/src/util.js +4 -2
  76. package/packages/tools/utils.js +3 -6
  77. package/packages/v-x-e-table/index.js +7 -4
  78. package/packages/v-x-e-table/src/commands.js +6 -6
  79. package/packages/v-x-e-table/src/conf.js +2 -2
  80. package/packages/v-x-e-table/src/{setup.js → config.js} +2 -2
  81. package/packages/v-x-e-table/src/formats.js +6 -6
  82. package/packages/v-x-e-table/src/menus.js +6 -6
  83. package/packages/v-x-e-table/src/renderer.js +4 -4
  84. package/packages/validator/src/mixin.js +2 -1
  85. package/styles/button.scss +5 -3
  86. package/styles/css-variable.scss +3 -3
  87. package/styles/form.scss +14 -0
  88. package/styles/input.scss +25 -0
  89. package/styles/table.scss +6 -2
  90. package/styles/textarea.scss +3 -3
  91. package/styles/variable.scss +3 -3
  92. package/types/form-item.d.ts +1 -0
  93. package/types/form.d.ts +1 -0
  94. package/types/table.d.ts +16 -1
  95. package/types/v-x-e-table/index.d.ts +22 -10
  96. package/lib/v-x-e-table/src/setup.min.js +0 -1
  97. /package/lib/icon/style/{iconfont.1690761747506.ttf → iconfont.1694737793729.ttf} +0 -0
  98. /package/lib/icon/style/{iconfont.1690761747506.woff → iconfont.1694737793729.woff} +0 -0
  99. /package/lib/icon/style/{iconfont.1690761747506.woff2 → iconfont.1694737793729.woff2} +0 -0
  100. /package/lib/{iconfont.1690761747506.ttf → iconfont.1694737793729.ttf} +0 -0
  101. /package/lib/{iconfont.1690761747506.woff → iconfont.1694737793729.woff} +0 -0
  102. /package/lib/{iconfont.1690761747506.woff2 → iconfont.1694737793729.woff2} +0 -0
  103. /package/types/v-x-e-table/{setup.d.ts → config.d.ts} +0 -0
@@ -16,13 +16,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
17
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
18
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
19
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
20
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
21
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
22
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
24
23
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
24
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
26
  function insertTreeRow(_vm, newRecords, isAppend) {
27
27
  var tableFullTreeData = _vm.tableFullTreeData,
28
28
  afterFullData = _vm.afterFullData,
@@ -31,9 +31,8 @@ function insertTreeRow(_vm, newRecords, isAppend) {
31
31
  treeOpts = _vm.treeOpts;
32
32
  var rowField = treeOpts.rowField,
33
33
  parentField = treeOpts.parentField,
34
- childrenField = treeOpts.childrenField,
35
- children = treeOpts.children,
36
34
  mapChildrenField = treeOpts.mapChildrenField;
35
+ var childrenField = treeOpts.children || treeOpts.childrenField;
37
36
  var funcName = isAppend ? 'push' : 'unshift';
38
37
  newRecords.forEach(function (item) {
39
38
  var parentRowId = item[parentField];
@@ -47,11 +46,16 @@ function insertTreeRow(_vm, newRecords, isAppend) {
47
46
  var parentRow = matchObj.item;
48
47
  var parentRest = fullAllDataRowIdData[(0, _util.getRowid)(_vm, parentRow)];
49
48
  var parentLevel = parentRest ? parentRest.level : 0;
50
- var parentChilds = parentRow[childrenField || children];
49
+ var parentChilds = parentRow[childrenField];
50
+ var mapChilds = parentRow[mapChildrenField];
51
51
  if (!_xeUtils["default"].isArray(parentChilds)) {
52
- parentChilds = parentRow[childrenField || children] = [];
52
+ parentChilds = parentRow[childrenField] = [];
53
+ }
54
+ if (!_xeUtils["default"].isArray(mapChilds)) {
55
+ mapChilds = parentRow[childrenField] = [];
53
56
  }
54
57
  parentChilds[funcName](item);
58
+ mapChilds[funcName](item);
55
59
  var rest = {
56
60
  row: item,
57
61
  rowid: rowid,
@@ -89,6 +93,189 @@ function insertTreeRow(_vm, newRecords, isAppend) {
89
93
  }
90
94
  });
91
95
  }
96
+ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
97
+ var tableFullTreeData = _vm.tableFullTreeData,
98
+ mergeList = _vm.mergeList,
99
+ afterFullData = _vm.afterFullData,
100
+ editStore = _vm.editStore,
101
+ tableFullData = _vm.tableFullData,
102
+ treeConfig = _vm.treeConfig,
103
+ fullDataRowIdData = _vm.fullDataRowIdData,
104
+ fullAllDataRowIdData = _vm.fullAllDataRowIdData,
105
+ treeOpts = _vm.treeOpts;
106
+ var transform = treeOpts.transform,
107
+ rowField = treeOpts.rowField,
108
+ mapChildrenField = treeOpts.mapChildrenField;
109
+ var childrenField = treeOpts.children || treeOpts.childrenField;
110
+ if (!_xeUtils["default"].isArray(records)) {
111
+ records = [records];
112
+ }
113
+ var newRecords = _vm.defineField(records.map(function (record) {
114
+ var _ref;
115
+ return Object.assign(treeConfig && transform ? (_ref = {}, _defineProperty(_ref, mapChildrenField, []), _defineProperty(_ref, childrenField, []), _ref) : {}, record);
116
+ }));
117
+ if (!row) {
118
+ // 如果为虚拟树
119
+ if (treeConfig && transform) {
120
+ insertTreeRow(_vm, newRecords, false);
121
+ } else {
122
+ afterFullData.unshift.apply(afterFullData, _toConsumableArray(newRecords));
123
+ tableFullData.unshift.apply(tableFullData, _toConsumableArray(newRecords));
124
+ // 刷新单元格合并
125
+ mergeList.forEach(function (mergeItem) {
126
+ var mergeRowIndex = mergeItem.row;
127
+ if (mergeRowIndex > 0) {
128
+ mergeItem.row = mergeRowIndex + newRecords.length;
129
+ }
130
+ });
131
+ }
132
+ } else {
133
+ if (row === -1) {
134
+ // 如果为虚拟树
135
+ if (treeConfig && transform) {
136
+ insertTreeRow(_vm, newRecords, true);
137
+ } else {
138
+ afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
139
+ tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords));
140
+ // 刷新单元格合并
141
+ mergeList.forEach(function (mergeItem) {
142
+ var mergeRowIndex = mergeItem.row,
143
+ mergeRowspan = mergeItem.rowspan;
144
+ if (mergeRowIndex + mergeRowspan > afterFullData.length) {
145
+ mergeItem.rowspan = mergeRowspan + newRecords.length;
146
+ }
147
+ });
148
+ }
149
+ } else {
150
+ // 如果为虚拟树
151
+ if (treeConfig && transform) {
152
+ var matchMapObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
153
+ return row[rowField] === item[rowField];
154
+ }, {
155
+ children: mapChildrenField
156
+ });
157
+ if (matchMapObj) {
158
+ var parentRow = matchMapObj.parent;
159
+ var parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData;
160
+ var parentRest = fullAllDataRowIdData[(0, _util.getRowid)(_vm, parentRow)];
161
+ var parentLevel = parentRest ? parentRest.level : 0;
162
+ newRecords.forEach(function (item, i) {
163
+ var rowid = (0, _util.getRowid)(_vm, item);
164
+ if (process.env.NODE_ENV === 'development') {
165
+ if (item[treeOpts.parentField]) {
166
+ if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
167
+ (0, _log.errLog)('vxe.error.errProp', ["".concat(treeOpts.parentField, "=").concat(item[treeOpts.parentField]), "".concat(treeOpts.parentField, "=").concat(parentRow[rowField])]);
168
+ }
169
+ }
170
+ }
171
+ if (parentRow) {
172
+ item[treeOpts.parentField] = parentRow[rowField];
173
+ }
174
+ var targetIndex = matchMapObj.index + i;
175
+ if (isInsertNextRow) {
176
+ targetIndex = targetIndex + 1;
177
+ }
178
+ parentMapChilds.splice(targetIndex, 0, item);
179
+ var rest = {
180
+ row: item,
181
+ rowid: rowid,
182
+ seq: -1,
183
+ index: -1,
184
+ _index: -1,
185
+ $index: -1,
186
+ items: parentMapChilds,
187
+ parent: parentRow,
188
+ level: parentLevel + 1
189
+ };
190
+ fullDataRowIdData[rowid] = rest;
191
+ fullAllDataRowIdData[rowid] = rest;
192
+ });
193
+
194
+ // 源
195
+ if (parentRow) {
196
+ var matchObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
197
+ return row[rowField] === item[rowField];
198
+ }, {
199
+ children: childrenField
200
+ });
201
+ if (matchObj) {
202
+ var parentChilds = matchObj.items;
203
+ var targetIndex = matchObj.index;
204
+ if (isInsertNextRow) {
205
+ targetIndex = targetIndex + 1;
206
+ }
207
+ parentChilds.splice.apply(parentChilds, [targetIndex, 0].concat(_toConsumableArray(newRecords)));
208
+ }
209
+ }
210
+ } else {
211
+ if (process.env.NODE_ENV === 'development') {
212
+ (0, _log.warnLog)('vxe.error.unableInsert');
213
+ }
214
+ insertTreeRow(_vm, newRecords, true);
215
+ }
216
+ } else {
217
+ if (treeConfig) {
218
+ throw new Error((0, _log.getLog)('vxe.error.noTree', ['insert']));
219
+ }
220
+ var afIndex = -1;
221
+ // 如果是可视索引
222
+ if (_xeUtils["default"].isNumber(row)) {
223
+ if (row < afterFullData.length) {
224
+ afIndex = row;
225
+ }
226
+ } else {
227
+ afIndex = _vm.findRowIndexOf(afterFullData, row);
228
+ }
229
+ // 如果是插入指定行的下一行
230
+ if (isInsertNextRow) {
231
+ afIndex = Math.max(afterFullData.length, afIndex + 1);
232
+ }
233
+ if (afIndex === -1) {
234
+ throw new Error((0, _log.errLog)('vxe.error.unableInsert'));
235
+ }
236
+ afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
237
+ tableFullData.splice.apply(tableFullData, [_vm.findRowIndexOf(tableFullData, row), 0].concat(_toConsumableArray(newRecords)));
238
+ // 刷新单元格合并
239
+ mergeList.forEach(function (mergeItem) {
240
+ var mergeRowIndex = mergeItem.row,
241
+ mergeRowspan = mergeItem.rowspan;
242
+ if (mergeRowIndex > afIndex) {
243
+ mergeItem.row = mergeRowIndex + newRecords.length;
244
+ } else if (mergeRowIndex + mergeRowspan > afIndex) {
245
+ mergeItem.rowspan = mergeRowspan + newRecords.length;
246
+ }
247
+ });
248
+ }
249
+ }
250
+ }
251
+ var insertList = editStore.insertList,
252
+ insertMaps = editStore.insertMaps;
253
+ newRecords.forEach(function (newRow) {
254
+ var rowid = (0, _util.getRowid)(_vm, newRow);
255
+ insertMaps[rowid] = newRow;
256
+ });
257
+ insertList.unshift.apply(insertList, _toConsumableArray(newRecords));
258
+ _vm.cacheRowMap();
259
+ _vm.updateScrollYStatus();
260
+ _vm.handleTableData(treeConfig && transform);
261
+ if (!(treeConfig && transform)) {
262
+ _vm.updateAfterDataIndex();
263
+ }
264
+ _vm.updateFooter();
265
+ _vm.checkSelectionStatus();
266
+ if (_vm.scrollYLoad) {
267
+ _vm.updateScrollYSpace();
268
+ }
269
+ return _vm.$nextTick().then(function () {
270
+ _vm.updateCellAreas();
271
+ return _vm.recalculate();
272
+ }).then(function () {
273
+ return {
274
+ row: newRecords.length ? newRecords[newRecords.length - 1] : null,
275
+ rows: newRecords
276
+ };
277
+ });
278
+ }
92
279
  var _default = {
93
280
  methods: {
94
281
  /**
@@ -97,7 +284,7 @@ var _default = {
97
284
  * @param {*} records
98
285
  */
99
286
  _insert: function _insert(records) {
100
- return this.insertAt(records);
287
+ return handleInsertRowAt(this, records, null);
101
288
  },
102
289
  /**
103
290
  * 往表格指定行中插入临时数据
@@ -106,163 +293,13 @@ var _default = {
106
293
  * 如果 row 为有效行则插入到该行的位置
107
294
  * @param {Object/Array} records 新的数据
108
295
  * @param {Row} row 指定行
296
+ * @returns
109
297
  */
110
298
  _insertAt: function _insertAt(records, row) {
111
- var _this = this;
112
- var tableFullTreeData = this.tableFullTreeData,
113
- mergeList = this.mergeList,
114
- afterFullData = this.afterFullData,
115
- editStore = this.editStore,
116
- tableFullData = this.tableFullData,
117
- treeConfig = this.treeConfig,
118
- fullDataRowIdData = this.fullDataRowIdData,
119
- fullAllDataRowIdData = this.fullAllDataRowIdData,
120
- treeOpts = this.treeOpts;
121
- var transform = treeOpts.transform,
122
- rowField = treeOpts.rowField,
123
- mapChildrenField = treeOpts.mapChildrenField;
124
- if (!_xeUtils["default"].isArray(records)) {
125
- records = [records];
126
- }
127
- var newRecords = this.defineField(records.map(function (record) {
128
- return Object.assign({}, record);
129
- }));
130
- if (!row) {
131
- // 如果为虚拟树
132
- if (treeConfig && transform) {
133
- insertTreeRow(this, newRecords, false);
134
- } else {
135
- afterFullData.unshift.apply(afterFullData, _toConsumableArray(newRecords));
136
- tableFullData.unshift.apply(tableFullData, _toConsumableArray(newRecords));
137
- // 刷新单元格合并
138
- mergeList.forEach(function (mergeItem) {
139
- var mergeRowIndex = mergeItem.row;
140
- if (mergeRowIndex > 0) {
141
- mergeItem.row = mergeRowIndex + newRecords.length;
142
- }
143
- });
144
- }
145
- } else {
146
- if (row === -1) {
147
- // 如果为虚拟树
148
- if (treeConfig && transform) {
149
- insertTreeRow(this, newRecords, true);
150
- } else {
151
- afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
152
- tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords));
153
- // 刷新单元格合并
154
- mergeList.forEach(function (mergeItem) {
155
- var mergeRowIndex = mergeItem.row,
156
- mergeRowspan = mergeItem.rowspan;
157
- if (mergeRowIndex + mergeRowspan > afterFullData.length) {
158
- mergeItem.rowspan = mergeRowspan + newRecords.length;
159
- }
160
- });
161
- }
162
- } else {
163
- // 如果为虚拟树
164
- if (treeConfig && transform) {
165
- var matchObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
166
- return row[rowField] === item[rowField];
167
- }, {
168
- children: mapChildrenField
169
- });
170
- if (matchObj) {
171
- var parentRow = matchObj.parent;
172
- var parentChilds = matchObj.items;
173
- var parentRest = fullAllDataRowIdData[(0, _util.getRowid)(this, parentRow)];
174
- var parentLevel = parentRest ? parentRest.level : 0;
175
- newRecords.forEach(function (item, i) {
176
- var rowid = (0, _util.getRowid)(_this, item);
177
- if (process.env.NODE_ENV === 'development') {
178
- if (item[treeOpts.parentField]) {
179
- if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
180
- (0, _log.errLog)('vxe.error.errProp', ["".concat(treeOpts.parentField, "=").concat(item[treeOpts.parentField]), "".concat(treeOpts.parentField, "=").concat(parentRow[rowField])]);
181
- }
182
- }
183
- }
184
- if (parentRow) {
185
- item[treeOpts.parentField] = parentRow[rowField];
186
- }
187
- parentChilds.splice(matchObj.index + i, 0, item);
188
- var rest = {
189
- row: item,
190
- rowid: rowid,
191
- seq: -1,
192
- index: -1,
193
- _index: -1,
194
- $index: -1,
195
- items: parentChilds,
196
- parent: parentRow,
197
- level: parentLevel + 1
198
- };
199
- fullDataRowIdData[rowid] = rest;
200
- fullAllDataRowIdData[rowid] = rest;
201
- });
202
- } else {
203
- if (process.env.NODE_ENV === 'development') {
204
- (0, _log.warnLog)('vxe.error.unableInsert');
205
- }
206
- insertTreeRow(this, newRecords, true);
207
- }
208
- } else {
209
- if (treeConfig) {
210
- throw new Error((0, _log.getLog)('vxe.error.noTree', ['insert']));
211
- }
212
- var afIndex = -1;
213
- // 如果是可视索引
214
- if (_xeUtils["default"].isNumber(row)) {
215
- if (row < afterFullData.length) {
216
- afIndex = row;
217
- }
218
- } else {
219
- afIndex = this.findRowIndexOf(afterFullData, row);
220
- }
221
- if (afIndex === -1) {
222
- throw new Error((0, _log.errLog)('vxe.error.unableInsert'));
223
- }
224
- afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
225
- tableFullData.splice.apply(tableFullData, [this.findRowIndexOf(tableFullData, row), 0].concat(_toConsumableArray(newRecords)));
226
- // 刷新单元格合并
227
- mergeList.forEach(function (mergeItem) {
228
- var mergeRowIndex = mergeItem.row,
229
- mergeRowspan = mergeItem.rowspan;
230
- if (mergeRowIndex > afIndex) {
231
- mergeItem.row = mergeRowIndex + newRecords.length;
232
- } else if (mergeRowIndex + mergeRowspan > afIndex) {
233
- mergeItem.rowspan = mergeRowspan + newRecords.length;
234
- }
235
- });
236
- }
237
- }
238
- }
239
- var insertList = editStore.insertList,
240
- insertMaps = editStore.insertMaps;
241
- newRecords.forEach(function (newRow) {
242
- var rowid = (0, _util.getRowid)(_this, newRow);
243
- insertMaps[rowid] = newRow;
244
- });
245
- insertList.unshift.apply(insertList, _toConsumableArray(newRecords));
246
- this.cacheRowMap();
247
- this.updateScrollYStatus();
248
- this.handleTableData(treeConfig && transform);
249
- if (!(treeConfig && transform)) {
250
- this.updateAfterDataIndex();
251
- }
252
- this.updateFooter();
253
- this.checkSelectionStatus();
254
- if (this.scrollYLoad) {
255
- this.updateScrollYSpace();
256
- }
257
- return this.$nextTick().then(function () {
258
- _this.updateCellAreas();
259
- return _this.recalculate();
260
- }).then(function () {
261
- return {
262
- row: newRecords.length ? newRecords[newRecords.length - 1] : null,
263
- rows: newRecords
264
- };
265
- });
299
+ return handleInsertRowAt(this, records, row);
300
+ },
301
+ _insertNextAt: function _insertNextAt(records, row) {
302
+ return handleInsertRowAt(this, records, row, true);
266
303
  },
267
304
  /**
268
305
  * 删除指定行数据
@@ -271,7 +308,7 @@ var _default = {
271
308
  * 如果为空则删除所有
272
309
  */
273
310
  _remove: function _remove(rows) {
274
- var _this2 = this;
311
+ var _this = this;
275
312
  var afterFullData = this.afterFullData,
276
313
  tableFullData = this.tableFullData,
277
314
  tableFullTreeData = this.tableFullTreeData,
@@ -279,16 +316,18 @@ var _default = {
279
316
  mergeList = this.mergeList,
280
317
  editStore = this.editStore,
281
318
  checkboxOpts = this.checkboxOpts,
282
- selectCheckboxRows = this.selectCheckboxRows,
319
+ selectCheckboxMaps = this.selectCheckboxMaps,
283
320
  isInsertByRow = this.isInsertByRow,
284
321
  treeOpts = this.treeOpts;
285
- var transform = treeOpts.transform;
322
+ var transform = treeOpts.transform,
323
+ mapChildrenField = treeOpts.mapChildrenField;
324
+ var childrenField = treeOpts.children || treeOpts.childrenField;
286
325
  var actived = editStore.actived,
287
326
  removeList = editStore.removeList,
288
327
  insertList = editStore.insertList,
289
328
  insertMaps = editStore.insertMaps;
290
329
  var checkField = checkboxOpts.checkField;
291
- var rest = [];
330
+ var delList = [];
292
331
  if (!rows) {
293
332
  rows = tableFullData;
294
333
  } else if (!_xeUtils["default"].isArray(rows)) {
@@ -302,16 +341,18 @@ var _default = {
302
341
  });
303
342
  // 如果绑定了多选属性,则更新状态
304
343
  if (!checkField) {
344
+ var selectRowMaps = _objectSpread({}, selectCheckboxMaps);
305
345
  rows.forEach(function (row) {
306
- var sIndex = _this2.findRowIndexOf(selectCheckboxRows, row);
307
- if (sIndex > -1) {
308
- selectCheckboxRows.splice(sIndex, 1);
346
+ var rowid = (0, _util.getRowid)(_this, row);
347
+ if (selectRowMaps[rowid]) {
348
+ delete selectRowMaps[rowid];
309
349
  }
310
350
  });
351
+ this.selectCheckboxMaps = selectRowMaps;
311
352
  }
312
353
  // 从数据源中移除
313
354
  if (tableFullData === rows) {
314
- rows = rest = tableFullData.slice(0);
355
+ rows = delList = tableFullData.slice(0);
315
356
  this.tableFullData = [];
316
357
  this.afterFullData = [];
317
358
  this.clearMergeCells();
@@ -319,27 +360,37 @@ var _default = {
319
360
  // 如果为虚拟树
320
361
  if (treeConfig && transform) {
321
362
  rows.forEach(function (row) {
322
- var rowid = (0, _util.getRowid)(_this2, row);
363
+ var rowid = (0, _util.getRowid)(_this, row);
364
+ var matchMapObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
365
+ return rowid === (0, _util.getRowid)(_this, item);
366
+ }, {
367
+ children: mapChildrenField
368
+ });
369
+ if (matchMapObj) {
370
+ var rItems = matchMapObj.items.splice(matchMapObj.index, 1);
371
+ delList.push(rItems[0]);
372
+ }
323
373
  var matchObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
324
- return rowid === (0, _util.getRowid)(_this2, item);
325
- }, treeOpts);
374
+ return rowid === (0, _util.getRowid)(_this, item);
375
+ }, {
376
+ children: childrenField
377
+ });
326
378
  if (matchObj) {
327
- var rItems = matchObj.items.splice(matchObj.index, 1);
328
- rest.push(rItems[0]);
379
+ matchObj.items.splice(matchObj.index, 1);
329
380
  }
330
- var afIndex = _this2.findRowIndexOf(afterFullData, row);
381
+ var afIndex = _this.findRowIndexOf(afterFullData, row);
331
382
  if (afIndex > -1) {
332
383
  afterFullData.splice(afIndex, 1);
333
384
  }
334
385
  });
335
386
  } else {
336
387
  rows.forEach(function (row) {
337
- var tfIndex = _this2.findRowIndexOf(tableFullData, row);
388
+ var tfIndex = _this.findRowIndexOf(tableFullData, row);
338
389
  if (tfIndex > -1) {
339
390
  var rItems = tableFullData.splice(tfIndex, 1);
340
- rest.push(rItems[0]);
391
+ delList.push(rItems[0]);
341
392
  }
342
- var afIndex = _this2.findRowIndexOf(afterFullData, row);
393
+ var afIndex = _this.findRowIndexOf(afterFullData, row);
343
394
  if (afIndex > -1) {
344
395
  // 刷新单元格合并
345
396
  mergeList.forEach(function (mergeItem) {
@@ -362,8 +413,8 @@ var _default = {
362
413
  }
363
414
  // 从新增中移除已删除的数据
364
415
  rows.forEach(function (row) {
365
- var rowid = (0, _util.getRowid)(_this2, row);
366
- var iIndex = _this2.findRowIndexOf(insertList, row);
416
+ var rowid = (0, _util.getRowid)(_this, row);
417
+ var iIndex = _this.findRowIndexOf(insertList, row);
367
418
  if (iIndex > -1) {
368
419
  insertList.splice(iIndex, 1);
369
420
  }
@@ -380,12 +431,12 @@ var _default = {
380
431
  this.updateScrollYSpace();
381
432
  }
382
433
  return this.$nextTick().then(function () {
383
- _this2.updateCellAreas();
384
- return _this2.recalculate();
434
+ _this.updateCellAreas();
435
+ return _this.recalculate();
385
436
  }).then(function () {
386
437
  return {
387
- row: rest.length ? rest[rest.length - 1] : null,
388
- rows: rest
438
+ row: delList.length ? delList[delList.length - 1] : null,
439
+ rows: delList
389
440
  };
390
441
  });
391
442
  },
@@ -393,9 +444,9 @@ var _default = {
393
444
  * 删除复选框选中的数据
394
445
  */
395
446
  _removeCheckboxRow: function _removeCheckboxRow() {
396
- var _this3 = this;
447
+ var _this2 = this;
397
448
  return this.remove(this.getCheckboxRecords()).then(function (params) {
398
- _this3.clearCheckboxRow();
449
+ _this2.clearCheckboxRow();
399
450
  return params;
400
451
  });
401
452
  },
@@ -403,10 +454,10 @@ var _default = {
403
454
  * 删除单选框选中的数据
404
455
  */
405
456
  _removeRadioRow: function _removeRadioRow() {
406
- var _this4 = this;
457
+ var _this3 = this;
407
458
  var radioRecord = this.getRadioRecord();
408
459
  return this.remove(radioRecord || []).then(function (params) {
409
- _this4.clearRadioRow();
460
+ _this3.clearRadioRow();
410
461
  return params;
411
462
  });
412
463
  },
@@ -414,10 +465,10 @@ var _default = {
414
465
  * 删除当前行选中的数据
415
466
  */
416
467
  _removeCurrentRow: function _removeCurrentRow() {
417
- var _this5 = this;
468
+ var _this4 = this;
418
469
  var currentRecord = this.getCurrentRecord();
419
470
  return this.remove(currentRecord || []).then(function (params) {
420
- _this5.clearCurrentRow();
471
+ _this4.clearCurrentRow();
421
472
  return params;
422
473
  });
423
474
  },
@@ -435,12 +486,12 @@ var _default = {
435
486
  * 获取新增的临时数据
436
487
  */
437
488
  _getInsertRecords: function _getInsertRecords() {
438
- var _this6 = this;
489
+ var _this5 = this;
439
490
  var fullAllDataRowIdData = this.fullAllDataRowIdData;
440
491
  var insertList = this.editStore.insertList;
441
492
  var insertRecords = [];
442
493
  insertList.forEach(function (row) {
443
- var rowid = (0, _util.getRowid)(_this6, row);
494
+ var rowid = (0, _util.getRowid)(_this5, row);
444
495
  if (fullAllDataRowIdData[rowid]) {
445
496
  insertRecords.push(row);
446
497
  }
@@ -487,7 +538,7 @@ var _default = {
487
538
  * 处理激活编辑
488
539
  */
489
540
  handleActived: function handleActived(params, evnt) {
490
- var _this7 = this;
541
+ var _this6 = this;
491
542
  var editStore = this.editStore,
492
543
  editOpts = this.editOpts,
493
544
  tableColumn = this.tableColumn,
@@ -523,13 +574,13 @@ var _default = {
523
574
  actived.column = column;
524
575
  if (mode === 'row') {
525
576
  tableColumn.forEach(function (column) {
526
- return _this7._getColumnModel(row, column);
577
+ return _this6._getColumnModel(row, column);
527
578
  });
528
579
  } else {
529
580
  this._getColumnModel(row, column);
530
581
  }
531
582
  this.$nextTick(function () {
532
- _this7.handleFocus(params, evnt);
583
+ _this6.handleFocus(params, evnt);
533
584
  });
534
585
  }
535
586
  this.emitEvent(type, {
@@ -558,7 +609,7 @@ var _default = {
558
609
  actived.args = params;
559
610
  actived.column = column;
560
611
  setTimeout(function () {
561
- _this7.handleFocus(params, evnt);
612
+ _this6.handleFocus(params, evnt);
562
613
  });
563
614
  }
564
615
  this.focus();
@@ -583,7 +634,7 @@ var _default = {
583
634
  }
584
635
  },
585
636
  _syncActivedCell: function _syncActivedCell() {
586
- var _this8 = this;
637
+ var _this7 = this;
587
638
  var tableColumn = this.tableColumn,
588
639
  editStore = this.editStore,
589
640
  editOpts = this.editOpts;
@@ -593,7 +644,7 @@ var _default = {
593
644
  if (row || column) {
594
645
  if (editOpts.mode === 'row') {
595
646
  tableColumn.forEach(function (column) {
596
- return _this8._setColumnModel(row, column);
647
+ return _this7._setColumnModel(row, column);
597
648
  });
598
649
  } else {
599
650
  this._setColumnModel(row, column);
@@ -736,22 +787,22 @@ var _default = {
736
787
  * 激活单元格编辑
737
788
  */
738
789
  _setEditCell: function _setEditCell(row, fieldOrColumn) {
739
- var _this9 = this;
790
+ var _this8 = this;
740
791
  var editConfig = this.editConfig;
741
792
  var column = _xeUtils["default"].isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
742
793
  if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender)) {
743
794
  return this.scrollToRow(row, true).then(function () {
744
- var cell = _this9.getCell(row, column);
795
+ var cell = _this8.getCell(row, column);
745
796
  if (cell) {
746
- _this9.handleActived({
797
+ _this8.handleActived({
747
798
  row: row,
748
- rowIndex: _this9.getRowIndex(row),
799
+ rowIndex: _this8.getRowIndex(row),
749
800
  column: column,
750
- columnIndex: _this9.getColumnIndex(column),
801
+ columnIndex: _this8.getColumnIndex(column),
751
802
  cell: cell,
752
- $table: _this9
803
+ $table: _this8
753
804
  });
754
- _this9.lastCallTime = Date.now();
805
+ _this8.lastCallTime = Date.now();
755
806
  }
756
807
  });
757
808
  }
@@ -785,7 +836,7 @@ var _default = {
785
836
  * 处理选中源
786
837
  */
787
838
  handleSelected: function handleSelected(params, evnt) {
788
- var _this10 = this;
839
+ var _this9 = this;
789
840
  var mouseConfig = this.mouseConfig,
790
841
  mouseOpts = this.mouseOpts,
791
842
  editOpts = this.editOpts,
@@ -798,23 +849,23 @@ var _default = {
798
849
  var selectMethod = function selectMethod() {
799
850
  if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
800
851
  if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
801
- _this10.clearActived(evnt);
802
- _this10.clearSelected(evnt);
803
- _this10.clearCellAreas(evnt);
804
- _this10.clearCopyCellArea(evnt);
852
+ _this9.clearActived(evnt);
853
+ _this9.clearSelected(evnt);
854
+ _this9.clearCellAreas(evnt);
855
+ _this9.clearCopyCellArea(evnt);
805
856
  selected.args = params;
806
857
  selected.row = row;
807
858
  selected.column = column;
808
859
  if (isMouseSelected) {
809
- _this10.addColSdCls();
860
+ _this9.addColSdCls();
810
861
  }
811
- _this10.focus();
862
+ _this9.focus();
812
863
  if (evnt) {
813
- _this10.emitEvent('cell-selected', params, evnt);
864
+ _this9.emitEvent('cell-selected', params, evnt);
814
865
  }
815
866
  }
816
867
  }
817
- return _this10.$nextTick();
868
+ return _this9.$nextTick();
818
869
  };
819
870
  return selectMethod();
820
871
  },