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