vxe-table 3.4.3 → 3.4.4

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.
@@ -28,6 +28,71 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
28
28
  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; }
29
29
 
30
30
  var getRowid = _tools.UtilTools.getRowid;
31
+
32
+ function insertTreeRow(_vm, newRecords, isAppend) {
33
+ var treeFullData = _vm.treeFullData,
34
+ afterFullData = _vm.afterFullData,
35
+ fullDataRowIdData = _vm.fullDataRowIdData,
36
+ fullAllDataRowIdData = _vm.fullAllDataRowIdData,
37
+ treeOpts = _vm.treeOpts;
38
+ var funcName = isAppend ? 'push' : 'unshift';
39
+ newRecords.forEach(function (item) {
40
+ var parentRowId = item[treeOpts.parentField];
41
+ var rowid = getRowid(_vm, item);
42
+ var matchObj = parentRowId ? _xeUtils.default.findTree(treeFullData, function (item) {
43
+ return parentRowId === item[treeOpts.rowField];
44
+ }, treeOpts) : null;
45
+
46
+ if (matchObj) {
47
+ var parentRow = matchObj.item;
48
+ var parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)];
49
+ var parentLevel = parentRest ? parentRest.level : 0;
50
+ var parentChilds = parentRow[treeOpts.children];
51
+
52
+ if (!_xeUtils.default.isArray(parentChilds)) {
53
+ parentChilds = parentRow[treeOpts.children] = [];
54
+ }
55
+
56
+ parentChilds[funcName](item);
57
+ var rest = {
58
+ row: item,
59
+ rowid: rowid,
60
+ index: -1,
61
+ _index: -1,
62
+ $index: -1,
63
+ items: parentChilds,
64
+ parent: parent,
65
+ level: parentLevel + 1
66
+ };
67
+ fullDataRowIdData[rowid] = rest;
68
+ fullAllDataRowIdData[rowid] = rest;
69
+ } else {
70
+ if (process.env.NODE_ENV === 'development') {
71
+ if (parentRowId) {
72
+ _tools.UtilTools.warn('vxe.error.unableInsert');
73
+ }
74
+ }
75
+
76
+ afterFullData[funcName](item);
77
+ treeFullData[funcName](item);
78
+ var _rest = {
79
+ row: item,
80
+ rowid: rowid,
81
+ index: -1,
82
+ _index: -1,
83
+ $index: -1,
84
+ items: treeFullData,
85
+ parent: null,
86
+ level: 0
87
+ };
88
+ fullDataRowIdData[rowid] = _rest;
89
+ fullAllDataRowIdData[rowid] = _rest;
90
+ }
91
+ });
92
+
93
+ _vm.updateVirtualTreeData();
94
+ }
95
+
31
96
  var _default = {
32
97
  methods: {
33
98
  /**
@@ -62,6 +127,7 @@ var _default = {
62
127
  fullDataRowIdData = this.fullDataRowIdData,
63
128
  fullAllDataRowIdData = this.fullAllDataRowIdData,
64
129
  treeOpts = this.treeOpts;
130
+ var transform = treeOpts.transform;
65
131
 
66
132
  if (!_xeUtils.default.isArray(records)) {
67
133
  records = [records];
@@ -73,47 +139,8 @@ var _default = {
73
139
 
74
140
  if (!row) {
75
141
  // 如果为虚拟树
76
- if (treeConfig && treeOpts.transform) {
77
- newRecords.forEach(function (item) {
78
- var parentRowId = item[treeOpts.parentField];
79
- var rowid = getRowid(_this, item);
80
-
81
- if (parentRowId) {
82
- var matchObj = _xeUtils.default.findTree(treeFullData, function (item) {
83
- return parentRowId === item[treeOpts.rowField];
84
- }, treeOpts);
85
-
86
- if (matchObj) {
87
- var parentRow = matchObj.item;
88
- var parentRest = fullAllDataRowIdData[getRowid(_this, parentRow)];
89
- var parentLevel = parentRest ? parentRest.level : 0;
90
- var parentChilds = parentRow[treeOpts.children];
91
-
92
- if (!_xeUtils.default.isArray(parentChilds)) {
93
- parentChilds = parentRow[treeOpts.children] = [];
94
- }
95
-
96
- parentChilds.push(item);
97
- var rest = {
98
- row: item,
99
- rowid: rowid,
100
- index: -1,
101
- _index: -1,
102
- $index: -1,
103
- items: parentChilds,
104
- parent: parent,
105
- level: parentLevel + 1
106
- };
107
- fullDataRowIdData[rowid] = rest;
108
- fullAllDataRowIdData[rowid] = rest;
109
- } else {// 父节点不存在
110
- }
111
- } else {
112
- afterFullData.unshift(item);
113
- treeFullData.unshift(item);
114
- }
115
- });
116
- this.updateVirtualTreeData();
142
+ if (treeConfig && transform) {
143
+ insertTreeRow(this, newRecords, false);
117
144
  } else {
118
145
  afterFullData.unshift.apply(afterFullData, _toConsumableArray(newRecords));
119
146
  tableFullData.unshift.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
@@ -128,48 +155,103 @@ var _default = {
128
155
  }
129
156
  } else {
130
157
  if (row === -1) {
131
- afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
132
- tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
158
+ // 如果为虚拟树
159
+ if (treeConfig && transform) {
160
+ insertTreeRow(this, newRecords, true);
161
+ } else {
162
+ afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
163
+ tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
133
164
 
134
- mergeList.forEach(function (mergeItem) {
135
- var mergeRowIndex = mergeItem.row,
136
- mergeRowspan = mergeItem.rowspan;
165
+ mergeList.forEach(function (mergeItem) {
166
+ var mergeRowIndex = mergeItem.row,
167
+ mergeRowspan = mergeItem.rowspan;
137
168
 
138
- if (mergeRowIndex + mergeRowspan > afterFullData.length) {
139
- mergeItem.rowspan = mergeRowspan + newRecords.length;
140
- }
141
- });
142
- } else {
143
- if (treeConfig) {
144
- throw new Error(_tools.UtilTools.getLog('vxe.error.noTree', ['insert']));
169
+ if (mergeRowIndex + mergeRowspan > afterFullData.length) {
170
+ mergeItem.rowspan = mergeRowspan + newRecords.length;
171
+ }
172
+ });
145
173
  }
174
+ } else {
175
+ // 如果为虚拟树
176
+ if (treeConfig && transform) {
177
+ var matchObj = _xeUtils.default.findTree(treeFullData, function (item) {
178
+ return row[treeOpts.rowField] === item[treeOpts.rowField];
179
+ }, treeOpts);
146
180
 
147
- var afIndex = afterFullData.indexOf(row);
181
+ if (matchObj) {
182
+ var parentRow = matchObj.parent;
183
+ var parentChilds = matchObj.items;
184
+ var parentRest = fullAllDataRowIdData[getRowid(this, parentRow)];
185
+ var parentLevel = parentRest ? parentRest.level : 0;
186
+ newRecords.forEach(function (item, i) {
187
+ var rowid = getRowid(_this, item);
188
+
189
+ if (process.env.NODE_ENV === 'development') {
190
+ if (item[treeOpts.parentField]) {
191
+ if (parentRow && item[treeOpts.parentField] !== parentRow[treeOpts.rowField]) {
192
+ _tools.UtilTools.error('vxe.error.errProp', ["".concat(treeOpts.parentField, "=").concat(item[treeOpts.parentField]), "".concat(treeOpts.parentField, "=").concat(parentRow[treeOpts.rowField])]);
193
+ }
194
+ }
195
+ }
148
196
 
149
- if (afIndex === -1) {
150
- throw new Error(_tools.UtilTools.error('vxe.error.unableInsert'));
151
- }
197
+ if (parentRow) {
198
+ item[treeOpts.parentField] = parentRow[treeOpts.rowField];
199
+ }
200
+
201
+ parentChilds.splice(matchObj.index + i, 0, item);
202
+ var rest = {
203
+ row: item,
204
+ rowid: rowid,
205
+ index: -1,
206
+ _index: -1,
207
+ $index: -1,
208
+ items: parentChilds,
209
+ parent: parentRow,
210
+ level: parentLevel + 1
211
+ };
212
+ fullDataRowIdData[rowid] = rest;
213
+ fullAllDataRowIdData[rowid] = rest;
214
+ });
215
+ this.updateVirtualTreeData();
216
+ } else {
217
+ if (process.env.NODE_ENV === 'development') {
218
+ _tools.UtilTools.warn('vxe.error.unableInsert');
219
+ }
152
220
 
153
- afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
154
- tableFullData.splice.apply(tableFullData, [tableFullData.indexOf(row), 0].concat(_toConsumableArray(newRecords))); // 刷新单元格合并
221
+ insertTreeRow(this, newRecords, true);
222
+ }
223
+ } else {
224
+ if (treeConfig) {
225
+ throw new Error(_tools.UtilTools.getLog('vxe.error.noTree', ['insert']));
226
+ }
155
227
 
156
- mergeList.forEach(function (mergeItem) {
157
- var mergeRowIndex = mergeItem.row,
158
- mergeRowspan = mergeItem.rowspan;
228
+ var afIndex = afterFullData.indexOf(row);
159
229
 
160
- if (mergeRowIndex > afIndex) {
161
- mergeItem.row = mergeRowIndex + newRecords.length;
162
- } else if (mergeRowIndex + mergeRowspan > afIndex) {
163
- mergeItem.rowspan = mergeRowspan + newRecords.length;
230
+ if (afIndex === -1) {
231
+ throw new Error(_tools.UtilTools.error('vxe.error.unableInsert'));
164
232
  }
165
- });
233
+
234
+ afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
235
+ tableFullData.splice.apply(tableFullData, [tableFullData.indexOf(row), 0].concat(_toConsumableArray(newRecords))); // 刷新单元格合并
236
+
237
+ mergeList.forEach(function (mergeItem) {
238
+ var mergeRowIndex = mergeItem.row,
239
+ mergeRowspan = mergeItem.rowspan;
240
+
241
+ if (mergeRowIndex > afIndex) {
242
+ mergeItem.row = mergeRowIndex + newRecords.length;
243
+ } else if (mergeRowIndex + mergeRowspan > afIndex) {
244
+ mergeItem.rowspan = mergeRowspan + newRecords.length;
245
+ }
246
+ });
247
+ }
166
248
  }
167
249
  }
168
250
 
169
251
  (_editStore$insertList = editStore.insertList).unshift.apply(_editStore$insertList, _toConsumableArray(newRecords));
170
252
 
171
253
  this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length;
172
- this.handleTableData();
254
+ this.handleTableData(transform);
173
255
  this.updateFooter();
174
256
  this.cacheRowMap();
175
257
  this.checkSelectionStatus();
@@ -211,6 +293,7 @@ var _default = {
211
293
  sYOpts = this.sYOpts,
212
294
  scrollYLoad = this.scrollYLoad,
213
295
  treeOpts = this.treeOpts;
296
+ var transform = treeOpts.transform;
214
297
  var actived = editStore.actived,
215
298
  removeList = editStore.removeList,
216
299
  insertList = editStore.insertList;
@@ -248,7 +331,7 @@ var _default = {
248
331
  this.clearMergeCells();
249
332
  } else {
250
333
  // 如果为虚拟树
251
- if (treeConfig && treeOpts.transform) {
334
+ if (treeConfig && transform) {
252
335
  rows.forEach(function (row) {
253
336
  var rowid = getRowid(_this2, row);
254
337
 
@@ -312,7 +395,7 @@ var _default = {
312
395
  }
313
396
  });
314
397
  this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length;
315
- this.handleTableData();
398
+ this.handleTableData(transform);
316
399
  this.updateFooter();
317
400
  this.cacheRowMap();
318
401
  this.checkSelectionStatus();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_vXETable=_interopRequireDefault(require("../../v-x-e-table")),_tools=require("../../tools"),_dom=require("../../tools/src/dom");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}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.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}var getRowid=_tools.UtilTools.getRowid,_default={methods:{_insert:function(e){return this.insertAt(e)},_insertAt:function(e,t){var n=this,s=this.treeFullData,r=this.mergeList,a=this.afterFullData,o=this.editStore,l=this.sYOpts,i=this.scrollYLoad,u=this.tableFullData,c=this.treeConfig,d=this.fullDataRowIdData,h=this.fullAllDataRowIdData,f=this.treeOpts,m=(e=!_xeUtils.default.isArray(e)?[e]:e).map(function(e){return n.defineField(Object.assign({},e))});if(t)if(-1===t)a.push.apply(a,_toConsumableArray(m)),u.push.apply(u,_toConsumableArray(m)),r.forEach(function(e){var t=e.row,r=e.rowspan;t+r>a.length&&(e.rowspan=r+m.length)});else{if(c)throw new Error(_tools.UtilTools.getLog("vxe.error.noTree",["insert"]));var p=a.indexOf(t);if(-1===p)throw new Error(_tools.UtilTools.error("vxe.error.unableInsert"));a.splice.apply(a,[p,0].concat(_toConsumableArray(m))),u.splice.apply(u,[u.indexOf(t),0].concat(_toConsumableArray(m))),r.forEach(function(e){var t=e.row,r=e.rowspan;p<t?e.row=t+m.length:p<t+r&&(e.rowspan=r+m.length)})}else c&&f.transform?(m.forEach(function(e){var t,r,o,l=e[f.parentField],i=getRowid(n,e);l?(o=_xeUtils.default.findTree(s,function(e){return l===e[f.rowField]},f))&&(t=o.item,o=(r=h[getRowid(n,t)])?r.level:0,r=t[f.children],(r=!_xeUtils.default.isArray(r)?t[f.children]=[]:r).push(e),o={row:e,rowid:i,index:-1,_index:-1,$index:-1,items:r,parent:parent,level:o+1},d[i]=o,h[i]=o):(a.unshift(e),s.unshift(e))}),this.updateVirtualTreeData()):(a.unshift.apply(a,_toConsumableArray(m)),u.unshift.apply(u,_toConsumableArray(m)),r.forEach(function(e){var t=e.row;0<t&&(e.row=t+m.length)}));return(o=o.insertList).unshift.apply(o,_toConsumableArray(m)),this.scrollYLoad=!c&&-1<l.gt&&l.gt<u.length,this.handleTableData(),this.updateFooter(),this.cacheRowMap(),this.checkSelectionStatus(),i&&this.updateScrollYSpace(),this.$nextTick().then(function(){return n.updateCellAreas(),n.recalculate()}).then(function(){return{row:m.length?m[m.length-1]:null,rows:m}})},_remove:function(e){var o=this,l=this.afterFullData,r=this.tableFullData,i=this.treeFullData,t=this.treeConfig,n=this.mergeList,s=this.editStore,a=this.checkboxOpts,u=this.selection,c=this.isInsertByRow,d=this.sYOpts,h=this.scrollYLoad,f=this.treeOpts,m=s.actived,p=s.removeList,v=s.insertList,a=a.checkField,g=[];return e?_xeUtils.default.isArray(e)||(e=[e]):e=r,e.forEach(function(e){c(e)||p.push(e)}),a||e.forEach(function(e){e=u.indexOf(e);-1<e&&u.splice(e,1)}),r===e?(e=g=r.slice(0),this.tableFullData=[],this.afterFullData=[],this.clearMergeCells()):t&&f.transform?e.forEach(function(e){var t=getRowid(o,e),r=_xeUtils.default.findTree(i,function(e){return t===getRowid(o,e)},f);r&&(r=r.items.splice(r.index,1),g.push(r[0]));e=l.indexOf(e);-1<e&&l.splice(e,1),o.updateVirtualTreeData()}):e.forEach(function(e){var t=r.indexOf(e);-1<t&&(t=r.splice(t,1),g.push(t[0]));var o=l.indexOf(e);-1<o&&(n.forEach(function(e){var t=e.row,r=e.rowspan;o<t?e.row=t-1:o<t+r&&(e.rowspan=r-1)}),l.splice(o,1))}),m.row&&-1<e.indexOf(m.row)&&this.clearActived(),e.forEach(function(e){e=v.indexOf(e);-1<e&&v.splice(e,1)}),this.scrollYLoad=!t&&-1<d.gt&&d.gt<r.length,this.handleTableData(),this.updateFooter(),this.cacheRowMap(),this.checkSelectionStatus(),h&&this.updateScrollYSpace(),this.$nextTick().then(function(){return o.updateCellAreas(),o.recalculate()}).then(function(){return{row:g.length?g[g.length-1]:null,rows:g}})},_removeCheckboxRow:function(){var t=this;return this.remove(this.getCheckboxRecords()).then(function(e){return t.clearCheckboxRow(),e})},_removeRadioRow:function(){var t=this,e=this.getRadioRecord();return this.remove(e||[]).then(function(e){return t.clearRadioRow(),e})},_removeCurrentRow:function(){var t=this,e=this.getCurrentRecord();return this.remove(e||[]).then(function(e){return t.clearCurrentRow(),e})},_getRecordset:function(){return{insertRecords:this.getInsertRecords(),removeRecords:this.getRemoveRecords(),updateRecords:this.getUpdateRecords()}},_getInsertRecords:function(){var r=this,e=this.treeConfig,o=this.treeFullData,t=this.tableFullData,l=this.treeOpts,i=this.editStore.insertList,n=[];return i.length&&(e&&l.transform?i.forEach(function(e){var t=getRowid(r,e);_xeUtils.default.findTree(o,function(e){return t===getRowid(r,e)},l)&&n.push(e)}):i.forEach(function(e){-1<t.indexOf(e)&&n.push(e)})),n},_getRemoveRecords:function(){return this.editStore.removeList},_getUpdateRecords:function(){var e=this.keepSource,t=this.tableFullData,r=this.isUpdateByRow,o=this.treeConfig,l=this.treeOpts,i=this.editStore;if(e){e=i.actived,i=e.row,e=e.column;return(i||e)&&this._syncActivedCell(),o?_xeUtils.default.filterTree(t,function(e){return r(e)},l):t.filter(function(e){return r(e)})}return[]},handleActived:function(e,t){var r,o=this,l=this.editStore,i=this.editOpts,n=this.tableColumn,s=this.editConfig,a=this.mouseConfig,u=i.mode,c=i.activeMethod,d=l.actived,h=e.row,f=e.column,i=f.editRender,l=e.cell=e.cell||this.getCell(h,f);return(0,_tools.isEnableConf)(s)&&(0,_tools.isEnableConf)(i)&&l&&(d.row!==h||"cell"===u&&d.column!==f?(r="edit-disabled",c&&!c(e)||(a&&(this.clearSelected(t),this.clearCellAreas(t),this.clearCopyCellArea(t)),this.closeTooltip(),this.clearActived(t),r="edit-actived",f.renderHeight=l.offsetHeight,d.args=e,d.row=h,d.column=f,"row"===u?n.forEach(function(e){return o._getColumnModel(h,e)}):this._getColumnModel(h,f),this.$nextTick(function(){o.handleFocus(e,t)})),this.emitEvent(r,{row:h,rowIndex:this.getRowIndex(h),$rowIndex:this.getVMRowIndex(h),column:f,columnIndex:this.getColumnIndex(f),$columnIndex:this.getVMColumnIndex(f)},t)):(r=d.column,a&&(this.clearSelected(t),this.clearCellAreas(t),this.clearCopyCellArea(t)),r!==f&&((a=r.model).update&&_tools.UtilTools.setCellValue(h,r,a.value),this.clearValidate()),f.renderHeight=l.offsetHeight,d.args=e,d.column=f,setTimeout(function(){o.handleFocus(e,t)})),this.focus()),this.$nextTick()},_getColumnModel:function(e,t){var r=t.model;t.editRender&&(r.value=_tools.UtilTools.getCellValue(e,t),r.update=!1)},_setColumnModel:function(e,t){var r=t.model;t.editRender&&r.update&&(_tools.UtilTools.setCellValue(e,t,r.value),r.update=!1,r.value=null)},_syncActivedCell:function(){var t=this,e=this.tableColumn,r=this.editStore,o=this.editOpts,r=r.actived,l=r.row,r=r.column;(l||r)&&("row"===o.mode?e.forEach(function(e){return t._setColumnModel(l,e)}):this._setColumnModel(l,r))},_clearActived:function(e){var t=this.editStore.actived,r=t.row,o=t.column;return(r||o)&&(this._syncActivedCell(),t.args=null,t.row=null,t.column=null,this.updateFooter(),this.emitEvent("edit-closed",{row:r,rowIndex:this.getRowIndex(r),$rowIndex:this.getVMRowIndex(r),column:o,columnIndex:this.getColumnIndex(o),$columnIndex:this.getVMColumnIndex(o)},e)),(_vXETable.default._valid?this.clearValidate():this.$nextTick()).then(this.recalculate)},_getActiveRecord:function(){var e=this.$el,t=this.editStore,r=this.afterFullData,o=t.actived,t=o.args,o=o.row;return t&&-1<r.indexOf(o)&&e.querySelectorAll(".vxe-body--column.col--actived").length?Object.assign({},t):null},_isActiveByRow:function(e){return this.editStore.actived.row===e},handleFocus:function(e){var t,r,o=e.row,l=e.column,i=e.cell,n=l.editRender;(0,_tools.isEnableConf)(n)&&(t=_vXETable.default.renderer.get(n.name),e=n.autofocus,n=n.autoselect,(r=!(r=e?i.querySelector(e):r)&&t&&t.autofocus?i.querySelector(t.autofocus):r)?(r.focus(),n?r.select():_dom.browse.msie&&((r=r.createTextRange()).collapse(!1),r.select())):this.scrollToRow(o,l))},_setActiveRow:function(e){return this.setActiveCell(e,_xeUtils.default.find(this.visibleColumn,function(e){return(0,_tools.isEnableConf)(e.editRender)}))},_setActiveCell:function(t,e){var r=this,o=this.editConfig,l=_xeUtils.default.isString(e)?this.getColumnByField(e):e;return t&&l&&(0,_tools.isEnableConf)(o)&&(0,_tools.isEnableConf)(l.editRender)?this.scrollToRow(t,!0).then(function(){var e=r.getCell(t,l);e&&(r.handleActived({row:t,rowIndex:r.getRowIndex(t),column:l,columnIndex:r.getColumnIndex(l),cell:e,$table:r}),r.lastCallTime=Date.now())}):this.$nextTick()},_setSelectCell:function(e,t){var r=this.tableData,o=this.editOpts,l=this.visibleColumn,t=_xeUtils.default.isString(t)?this.getColumnByField(t):t;return e&&t&&"manual"!==o.trigger&&(-1<(o=r.indexOf(e))&&(r=this.getCell(e,t),r={row:e,rowIndex:o,column:t,columnIndex:l.indexOf(t),cell:r},this.handleSelected(r,{}))),this.$nextTick()},handleSelected:function(e,t){var r=this,o=this.mouseConfig,l=this.mouseOpts,i=this.editOpts,n=this.editStore,s=n.actived,a=n.selected,u=e.row,c=e.column,d=o&&l.selected;return!d||a.row===u&&a.column===c||(s.row!==u||"cell"===i.mode&&s.column!==c)&&(r.clearActived(t),r.clearSelected(t),r.clearCellAreas(t),r.clearCopyCellArea(t),a.args=e,a.row=u,a.column=c,d&&r.addColSdCls(),r.focus(),t&&r.emitEvent("cell-selected",e,t)),r.$nextTick()},_getSelectedCell:function(){var e=this.editStore.selected,t=e.args,e=e.column;return t&&e?Object.assign({},t):null},_clearSelected:function(){var e=this.editStore.selected;return e.row=null,e.column=null,this.reColTitleSdCls(),this.reColSdCls(),this.$nextTick()},reColTitleSdCls:function(){var e=this.elemStore["main-header-list"];e&&_xeUtils.default.arrayEach(e.querySelectorAll(".col--title-selected"),function(e){return _tools.DomTools.removeClass(e,"col--title-selected")})},reColSdCls:function(){var e=this.$el.querySelector(".col--selected");e&&_tools.DomTools.removeClass(e,"col--selected")},addColSdCls:function(){var e=this.editStore.selected,t=e.row,e=e.column;this.reColSdCls(),t&&e&&((e=this.getCell(t,e))&&_tools.DomTools.addClass(e,"col--selected"))}}};exports.default=_default;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_vXETable=_interopRequireDefault(require("../../v-x-e-table")),_tools=require("../../tools"),_dom=require("../../tools/src/dom");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}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.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}var getRowid=_tools.UtilTools.getRowid;function insertTreeRow(n,e,t){var s=n.treeFullData,a=n.afterFullData,u=n.fullDataRowIdData,c=n.fullAllDataRowIdData,d=n.treeOpts,h=t?"push":"unshift";e.forEach(function(e){var t,r,o=e[d.parentField],l=getRowid(n,e),i=o?_xeUtils.default.findTree(s,function(e){return o===e[d.rowField]},d):null;i?(t=i.item,i=(r=c[getRowid(n,t)])?r.level:0,r=t[d.children],(r=!_xeUtils.default.isArray(r)?t[d.children]=[]:r)[h](e),i={row:e,rowid:l,index:-1,_index:-1,$index:-1,items:r,parent:parent,level:i+1},u[l]=i,c[l]=i):("development"===process.env.NODE_ENV&&o&&_tools.UtilTools.warn("vxe.error.unableInsert"),a[h](e),s[h](e),e={row:e,rowid:l,index:-1,_index:-1,$index:-1,items:s,parent:null,level:0},u[l]=e,c[l]=e)}),n.updateVirtualTreeData()}var _default={methods:{_insert:function(e){return this.insertAt(e)},_insertAt:function(e,t){var o=this,r=this.treeFullData,l=this.mergeList,i=this.afterFullData,n=this.editStore,s=this.sYOpts,a=this.scrollYLoad,u=this.tableFullData,c=this.treeConfig,d=this.fullDataRowIdData,h=this.fullAllDataRowIdData,f=this.treeOpts,p=f.transform,m=(e=!_xeUtils.default.isArray(e)?[e]:e).map(function(e){return o.defineField(Object.assign({},e))});if(t)if(-1===t)c&&p?insertTreeRow(this,m,!0):(i.push.apply(i,_toConsumableArray(m)),u.push.apply(u,_toConsumableArray(m)),l.forEach(function(e){var t=e.row,r=e.rowspan;t+r>i.length&&(e.rowspan=r+m.length)}));else if(c&&p){var v,w,_,g=_xeUtils.default.findTree(r,function(e){return t[f.rowField]===e[f.rowField]},f);g?(v=g.parent,w=g.items,r=h[getRowid(this,v)],_=r?r.level:0,m.forEach(function(e,t){var r=getRowid(o,e);"development"===process.env.NODE_ENV&&e[f.parentField]&&v&&e[f.parentField]!==v[f.rowField]&&_tools.UtilTools.error("vxe.error.errProp",["".concat(f.parentField,"=").concat(e[f.parentField]),"".concat(f.parentField,"=").concat(v[f.rowField])]),v&&(e[f.parentField]=v[f.rowField]),w.splice(g.index+t,0,e);e={row:e,rowid:r,index:-1,_index:-1,$index:-1,items:w,parent:v,level:_+1};d[r]=e,h[r]=e}),this.updateVirtualTreeData()):("development"===process.env.NODE_ENV&&_tools.UtilTools.warn("vxe.error.unableInsert"),insertTreeRow(this,m,!0))}else{if(c)throw new Error(_tools.UtilTools.getLog("vxe.error.noTree",["insert"]));var C=i.indexOf(t);if(-1===C)throw new Error(_tools.UtilTools.error("vxe.error.unableInsert"));i.splice.apply(i,[C,0].concat(_toConsumableArray(m))),u.splice.apply(u,[u.indexOf(t),0].concat(_toConsumableArray(m))),l.forEach(function(e){var t=e.row,r=e.rowspan;C<t?e.row=t+m.length:C<t+r&&(e.rowspan=r+m.length)})}else c&&p?insertTreeRow(this,m,!1):(i.unshift.apply(i,_toConsumableArray(m)),u.unshift.apply(u,_toConsumableArray(m)),l.forEach(function(e){var t=e.row;0<t&&(e.row=t+m.length)}));return(n=n.insertList).unshift.apply(n,_toConsumableArray(m)),this.scrollYLoad=!c&&-1<s.gt&&s.gt<u.length,this.handleTableData(p),this.updateFooter(),this.cacheRowMap(),this.checkSelectionStatus(),a&&this.updateScrollYSpace(),this.$nextTick().then(function(){return o.updateCellAreas(),o.recalculate()}).then(function(){return{row:m.length?m[m.length-1]:null,rows:m}})},_remove:function(e){var o=this,l=this.afterFullData,r=this.tableFullData,i=this.treeFullData,t=this.treeConfig,n=this.mergeList,s=this.editStore,a=this.checkboxOpts,u=this.selection,c=this.isInsertByRow,d=this.sYOpts,h=this.scrollYLoad,f=this.treeOpts,p=f.transform,m=s.actived,v=s.removeList,w=s.insertList,a=a.checkField,_=[];return e?_xeUtils.default.isArray(e)||(e=[e]):e=r,e.forEach(function(e){c(e)||v.push(e)}),a||e.forEach(function(e){e=u.indexOf(e);-1<e&&u.splice(e,1)}),r===e?(e=_=r.slice(0),this.tableFullData=[],this.afterFullData=[],this.clearMergeCells()):t&&p?e.forEach(function(e){var t=getRowid(o,e),r=_xeUtils.default.findTree(i,function(e){return t===getRowid(o,e)},f);r&&(r=r.items.splice(r.index,1),_.push(r[0]));e=l.indexOf(e);-1<e&&l.splice(e,1),o.updateVirtualTreeData()}):e.forEach(function(e){var t=r.indexOf(e);-1<t&&(t=r.splice(t,1),_.push(t[0]));var o=l.indexOf(e);-1<o&&(n.forEach(function(e){var t=e.row,r=e.rowspan;o<t?e.row=t-1:o<t+r&&(e.rowspan=r-1)}),l.splice(o,1))}),m.row&&-1<e.indexOf(m.row)&&this.clearActived(),e.forEach(function(e){e=w.indexOf(e);-1<e&&w.splice(e,1)}),this.scrollYLoad=!t&&-1<d.gt&&d.gt<r.length,this.handleTableData(p),this.updateFooter(),this.cacheRowMap(),this.checkSelectionStatus(),h&&this.updateScrollYSpace(),this.$nextTick().then(function(){return o.updateCellAreas(),o.recalculate()}).then(function(){return{row:_.length?_[_.length-1]:null,rows:_}})},_removeCheckboxRow:function(){var t=this;return this.remove(this.getCheckboxRecords()).then(function(e){return t.clearCheckboxRow(),e})},_removeRadioRow:function(){var t=this,e=this.getRadioRecord();return this.remove(e||[]).then(function(e){return t.clearRadioRow(),e})},_removeCurrentRow:function(){var t=this,e=this.getCurrentRecord();return this.remove(e||[]).then(function(e){return t.clearCurrentRow(),e})},_getRecordset:function(){return{insertRecords:this.getInsertRecords(),removeRecords:this.getRemoveRecords(),updateRecords:this.getUpdateRecords()}},_getInsertRecords:function(){var r=this,e=this.treeConfig,o=this.treeFullData,t=this.tableFullData,l=this.treeOpts,i=this.editStore.insertList,n=[];return i.length&&(e&&l.transform?i.forEach(function(e){var t=getRowid(r,e);_xeUtils.default.findTree(o,function(e){return t===getRowid(r,e)},l)&&n.push(e)}):i.forEach(function(e){-1<t.indexOf(e)&&n.push(e)})),n},_getRemoveRecords:function(){return this.editStore.removeList},_getUpdateRecords:function(){var e=this.keepSource,t=this.tableFullData,r=this.isUpdateByRow,o=this.treeConfig,l=this.treeOpts,i=this.editStore;if(e){e=i.actived,i=e.row,e=e.column;return(i||e)&&this._syncActivedCell(),o?_xeUtils.default.filterTree(t,function(e){return r(e)},l):t.filter(function(e){return r(e)})}return[]},handleActived:function(e,t){var r,o=this,l=this.editStore,i=this.editOpts,n=this.tableColumn,s=this.editConfig,a=this.mouseConfig,u=i.mode,c=i.activeMethod,d=l.actived,h=e.row,f=e.column,i=f.editRender,l=e.cell=e.cell||this.getCell(h,f);return(0,_tools.isEnableConf)(s)&&(0,_tools.isEnableConf)(i)&&l&&(d.row!==h||"cell"===u&&d.column!==f?(r="edit-disabled",c&&!c(e)||(a&&(this.clearSelected(t),this.clearCellAreas(t),this.clearCopyCellArea(t)),this.closeTooltip(),this.clearActived(t),r="edit-actived",f.renderHeight=l.offsetHeight,d.args=e,d.row=h,d.column=f,"row"===u?n.forEach(function(e){return o._getColumnModel(h,e)}):this._getColumnModel(h,f),this.$nextTick(function(){o.handleFocus(e,t)})),this.emitEvent(r,{row:h,rowIndex:this.getRowIndex(h),$rowIndex:this.getVMRowIndex(h),column:f,columnIndex:this.getColumnIndex(f),$columnIndex:this.getVMColumnIndex(f)},t)):(r=d.column,a&&(this.clearSelected(t),this.clearCellAreas(t),this.clearCopyCellArea(t)),r!==f&&((a=r.model).update&&_tools.UtilTools.setCellValue(h,r,a.value),this.clearValidate()),f.renderHeight=l.offsetHeight,d.args=e,d.column=f,setTimeout(function(){o.handleFocus(e,t)})),this.focus()),this.$nextTick()},_getColumnModel:function(e,t){var r=t.model;t.editRender&&(r.value=_tools.UtilTools.getCellValue(e,t),r.update=!1)},_setColumnModel:function(e,t){var r=t.model;t.editRender&&r.update&&(_tools.UtilTools.setCellValue(e,t,r.value),r.update=!1,r.value=null)},_syncActivedCell:function(){var t=this,e=this.tableColumn,r=this.editStore,o=this.editOpts,r=r.actived,l=r.row,r=r.column;(l||r)&&("row"===o.mode?e.forEach(function(e){return t._setColumnModel(l,e)}):this._setColumnModel(l,r))},_clearActived:function(e){var t=this.editStore.actived,r=t.row,o=t.column;return(r||o)&&(this._syncActivedCell(),t.args=null,t.row=null,t.column=null,this.updateFooter(),this.emitEvent("edit-closed",{row:r,rowIndex:this.getRowIndex(r),$rowIndex:this.getVMRowIndex(r),column:o,columnIndex:this.getColumnIndex(o),$columnIndex:this.getVMColumnIndex(o)},e)),(_vXETable.default._valid?this.clearValidate():this.$nextTick()).then(this.recalculate)},_getActiveRecord:function(){var e=this.$el,t=this.editStore,r=this.afterFullData,o=t.actived,t=o.args,o=o.row;return t&&-1<r.indexOf(o)&&e.querySelectorAll(".vxe-body--column.col--actived").length?Object.assign({},t):null},_isActiveByRow:function(e){return this.editStore.actived.row===e},handleFocus:function(e){var t,r,o=e.row,l=e.column,i=e.cell,n=l.editRender;(0,_tools.isEnableConf)(n)&&(t=_vXETable.default.renderer.get(n.name),e=n.autofocus,n=n.autoselect,(r=!(r=e?i.querySelector(e):r)&&t&&t.autofocus?i.querySelector(t.autofocus):r)?(r.focus(),n?r.select():_dom.browse.msie&&((r=r.createTextRange()).collapse(!1),r.select())):this.scrollToRow(o,l))},_setActiveRow:function(e){return this.setActiveCell(e,_xeUtils.default.find(this.visibleColumn,function(e){return(0,_tools.isEnableConf)(e.editRender)}))},_setActiveCell:function(t,e){var r=this,o=this.editConfig,l=_xeUtils.default.isString(e)?this.getColumnByField(e):e;return t&&l&&(0,_tools.isEnableConf)(o)&&(0,_tools.isEnableConf)(l.editRender)?this.scrollToRow(t,!0).then(function(){var e=r.getCell(t,l);e&&(r.handleActived({row:t,rowIndex:r.getRowIndex(t),column:l,columnIndex:r.getColumnIndex(l),cell:e,$table:r}),r.lastCallTime=Date.now())}):this.$nextTick()},_setSelectCell:function(e,t){var r=this.tableData,o=this.editOpts,l=this.visibleColumn,t=_xeUtils.default.isString(t)?this.getColumnByField(t):t;return e&&t&&"manual"!==o.trigger&&(-1<(o=r.indexOf(e))&&(r=this.getCell(e,t),r={row:e,rowIndex:o,column:t,columnIndex:l.indexOf(t),cell:r},this.handleSelected(r,{}))),this.$nextTick()},handleSelected:function(e,t){var r=this,o=this.mouseConfig,l=this.mouseOpts,i=this.editOpts,n=this.editStore,s=n.actived,a=n.selected,u=e.row,c=e.column,d=o&&l.selected;return!d||a.row===u&&a.column===c||(s.row!==u||"cell"===i.mode&&s.column!==c)&&(r.clearActived(t),r.clearSelected(t),r.clearCellAreas(t),r.clearCopyCellArea(t),a.args=e,a.row=u,a.column=c,d&&r.addColSdCls(),r.focus(),t&&r.emitEvent("cell-selected",e,t)),r.$nextTick()},_getSelectedCell:function(){var e=this.editStore.selected,t=e.args,e=e.column;return t&&e?Object.assign({},t):null},_clearSelected:function(){var e=this.editStore.selected;return e.row=null,e.column=null,this.reColTitleSdCls(),this.reColSdCls(),this.$nextTick()},reColTitleSdCls:function(){var e=this.elemStore["main-header-list"];e&&_xeUtils.default.arrayEach(e.querySelectorAll(".col--title-selected"),function(e){return _tools.DomTools.removeClass(e,"col--title-selected")})},reColSdCls:function(){var e=this.$el.querySelector(".col--selected");e&&_tools.DomTools.removeClass(e,"col--selected")},addColSdCls:function(){var e=this.editStore.selected,t=e.row,e=e.column;this.reColSdCls(),t&&e&&((e=this.getCell(t,e))&&_tools.DomTools.addClass(e,"col--selected"))}}};exports.default=_default;
package/lib/index.umd.js CHANGED
@@ -20381,6 +20381,67 @@ var Menu = {
20381
20381
 
20382
20382
 
20383
20383
  var mixin_getRowid = UtilTools.getRowid;
20384
+
20385
+ function insertTreeRow(_vm, newRecords, isAppend) {
20386
+ var treeFullData = _vm.treeFullData,
20387
+ afterFullData = _vm.afterFullData,
20388
+ fullDataRowIdData = _vm.fullDataRowIdData,
20389
+ fullAllDataRowIdData = _vm.fullAllDataRowIdData,
20390
+ treeOpts = _vm.treeOpts;
20391
+ var funcName = isAppend ? 'push' : 'unshift';
20392
+ newRecords.forEach(function (item) {
20393
+ var parentRowId = item[treeOpts.parentField];
20394
+ var rowid = mixin_getRowid(_vm, item);
20395
+ var matchObj = parentRowId ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.findTree(treeFullData, function (item) {
20396
+ return parentRowId === item[treeOpts.rowField];
20397
+ }, treeOpts) : null;
20398
+
20399
+ if (matchObj) {
20400
+ var parentRow = matchObj.item;
20401
+ var parentRest = fullAllDataRowIdData[mixin_getRowid(_vm, parentRow)];
20402
+ var parentLevel = parentRest ? parentRest.level : 0;
20403
+ var parentChilds = parentRow[treeOpts.children];
20404
+
20405
+ if (!external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.isArray(parentChilds)) {
20406
+ parentChilds = parentRow[treeOpts.children] = [];
20407
+ }
20408
+
20409
+ parentChilds[funcName](item);
20410
+ var rest = {
20411
+ row: item,
20412
+ rowid: rowid,
20413
+ index: -1,
20414
+ _index: -1,
20415
+ $index: -1,
20416
+ items: parentChilds,
20417
+ parent: parent,
20418
+ level: parentLevel + 1
20419
+ };
20420
+ fullDataRowIdData[rowid] = rest;
20421
+ fullAllDataRowIdData[rowid] = rest;
20422
+ } else {
20423
+ if (false) {}
20424
+
20425
+ afterFullData[funcName](item);
20426
+ treeFullData[funcName](item);
20427
+ var _rest = {
20428
+ row: item,
20429
+ rowid: rowid,
20430
+ index: -1,
20431
+ _index: -1,
20432
+ $index: -1,
20433
+ items: treeFullData,
20434
+ parent: null,
20435
+ level: 0
20436
+ };
20437
+ fullDataRowIdData[rowid] = _rest;
20438
+ fullAllDataRowIdData[rowid] = _rest;
20439
+ }
20440
+ });
20441
+
20442
+ _vm.updateVirtualTreeData();
20443
+ }
20444
+
20384
20445
  /* harmony default export */ var edit_src_mixin = ({
20385
20446
  methods: {
20386
20447
  /**
@@ -20415,6 +20476,7 @@ var mixin_getRowid = UtilTools.getRowid;
20415
20476
  fullDataRowIdData = this.fullDataRowIdData,
20416
20477
  fullAllDataRowIdData = this.fullAllDataRowIdData,
20417
20478
  treeOpts = this.treeOpts;
20479
+ var transform = treeOpts.transform;
20418
20480
 
20419
20481
  if (!external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.isArray(records)) {
20420
20482
  records = [records];
@@ -20426,27 +20488,60 @@ var mixin_getRowid = UtilTools.getRowid;
20426
20488
 
20427
20489
  if (!row) {
20428
20490
  // 如果为虚拟树
20429
- if (treeConfig && treeOpts.transform) {
20430
- newRecords.forEach(function (item) {
20431
- var parentRowId = item[treeOpts.parentField];
20432
- var rowid = mixin_getRowid(_this, item);
20491
+ if (treeConfig && transform) {
20492
+ insertTreeRow(this, newRecords, false);
20493
+ } else {
20494
+ afterFullData.unshift.apply(afterFullData, _toConsumableArray(newRecords));
20495
+ tableFullData.unshift.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
20433
20496
 
20434
- if (parentRowId) {
20435
- var matchObj = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.findTree(treeFullData, function (item) {
20436
- return parentRowId === item[treeOpts.rowField];
20437
- }, treeOpts);
20497
+ mergeList.forEach(function (mergeItem) {
20498
+ var mergeRowIndex = mergeItem.row;
20499
+
20500
+ if (mergeRowIndex > 0) {
20501
+ mergeItem.row = mergeRowIndex + newRecords.length;
20502
+ }
20503
+ });
20504
+ }
20505
+ } else {
20506
+ if (row === -1) {
20507
+ // 如果为虚拟树
20508
+ if (treeConfig && transform) {
20509
+ insertTreeRow(this, newRecords, true);
20510
+ } else {
20511
+ afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
20512
+ tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
20513
+
20514
+ mergeList.forEach(function (mergeItem) {
20515
+ var mergeRowIndex = mergeItem.row,
20516
+ mergeRowspan = mergeItem.rowspan;
20438
20517
 
20439
- if (matchObj) {
20440
- var parentRow = matchObj.item;
20441
- var parentRest = fullAllDataRowIdData[mixin_getRowid(_this, parentRow)];
20442
- var parentLevel = parentRest ? parentRest.level : 0;
20443
- var parentChilds = parentRow[treeOpts.children];
20518
+ if (mergeRowIndex + mergeRowspan > afterFullData.length) {
20519
+ mergeItem.rowspan = mergeRowspan + newRecords.length;
20520
+ }
20521
+ });
20522
+ }
20523
+ } else {
20524
+ // 如果为虚拟树
20525
+ if (treeConfig && transform) {
20526
+ var matchObj = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.findTree(treeFullData, function (item) {
20527
+ return row[treeOpts.rowField] === item[treeOpts.rowField];
20528
+ }, treeOpts);
20444
20529
 
20445
- if (!external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.isArray(parentChilds)) {
20446
- parentChilds = parentRow[treeOpts.children] = [];
20530
+ if (matchObj) {
20531
+ var parentRow = matchObj.parent;
20532
+ var parentChilds = matchObj.items;
20533
+ var parentRest = fullAllDataRowIdData[mixin_getRowid(this, parentRow)];
20534
+ var parentLevel = parentRest ? parentRest.level : 0;
20535
+ newRecords.forEach(function (item, i) {
20536
+ var rowid = mixin_getRowid(_this, item);
20537
+
20538
+ if (false) {}
20539
+
20540
+ if (parentRow) {
20541
+ item[treeOpts.parentField] = parentRow[treeOpts.rowField];
20447
20542
  }
20448
20543
 
20449
- parentChilds.push(item);
20544
+ parentChilds.splice(matchObj.index + i, 0, item);
20450
20545
  var rest = {
20451
20546
  row: item,
20452
20547
  rowid: rowid,
@@ -20454,75 +20549,50 @@ var mixin_getRowid = UtilTools.getRowid;
20454
20549
  _index: -1,
20455
20550
  $index: -1,
20456
20551
  items: parentChilds,
20457
- parent: parent,
20552
+ parent: parentRow,
20458
20553
  level: parentLevel + 1
20459
20554
  };
20460
20555
  fullDataRowIdData[rowid] = rest;
20461
20556
  fullAllDataRowIdData[rowid] = rest;
20462
- } else {// 父节点不存在
20463
- }
20557
+ });
20558
+ this.updateVirtualTreeData();
20464
20559
  } else {
20465
- afterFullData.unshift(item);
20466
- treeFullData.unshift(item);
20467
- }
20468
- });
20469
- this.updateVirtualTreeData();
20470
- } else {
20471
- afterFullData.unshift.apply(afterFullData, _toConsumableArray(newRecords));
20472
- tableFullData.unshift.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
20473
-
20474
- mergeList.forEach(function (mergeItem) {
20475
- var mergeRowIndex = mergeItem.row;
20560
+ if (false) {}
20476
20561
 
20477
- if (mergeRowIndex > 0) {
20478
- mergeItem.row = mergeRowIndex + newRecords.length;
20562
+ insertTreeRow(this, newRecords, true);
20479
20563
  }
20480
- });
20481
- }
20482
- } else {
20483
- if (row === -1) {
20484
- afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
20485
- tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords)); // 刷新单元格合并
20486
-
20487
- mergeList.forEach(function (mergeItem) {
20488
- var mergeRowIndex = mergeItem.row,
20489
- mergeRowspan = mergeItem.rowspan;
20490
-
20491
- if (mergeRowIndex + mergeRowspan > afterFullData.length) {
20492
- mergeItem.rowspan = mergeRowspan + newRecords.length;
20564
+ } else {
20565
+ if (treeConfig) {
20566
+ throw new Error(UtilTools.getLog('vxe.error.noTree', ['insert']));
20493
20567
  }
20494
- });
20495
- } else {
20496
- if (treeConfig) {
20497
- throw new Error(UtilTools.getLog('vxe.error.noTree', ['insert']));
20498
- }
20499
20568
 
20500
- var afIndex = afterFullData.indexOf(row);
20569
+ var afIndex = afterFullData.indexOf(row);
20501
20570
 
20502
- if (afIndex === -1) {
20503
- throw new Error(UtilTools.error('vxe.error.unableInsert'));
20504
- }
20571
+ if (afIndex === -1) {
20572
+ throw new Error(UtilTools.error('vxe.error.unableInsert'));
20573
+ }
20505
20574
 
20506
- afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
20507
- tableFullData.splice.apply(tableFullData, [tableFullData.indexOf(row), 0].concat(_toConsumableArray(newRecords))); // 刷新单元格合并
20575
+ afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
20576
+ tableFullData.splice.apply(tableFullData, [tableFullData.indexOf(row), 0].concat(_toConsumableArray(newRecords))); // 刷新单元格合并
20508
20577
 
20509
- mergeList.forEach(function (mergeItem) {
20510
- var mergeRowIndex = mergeItem.row,
20511
- mergeRowspan = mergeItem.rowspan;
20578
+ mergeList.forEach(function (mergeItem) {
20579
+ var mergeRowIndex = mergeItem.row,
20580
+ mergeRowspan = mergeItem.rowspan;
20512
20581
 
20513
- if (mergeRowIndex > afIndex) {
20514
- mergeItem.row = mergeRowIndex + newRecords.length;
20515
- } else if (mergeRowIndex + mergeRowspan > afIndex) {
20516
- mergeItem.rowspan = mergeRowspan + newRecords.length;
20517
- }
20518
- });
20582
+ if (mergeRowIndex > afIndex) {
20583
+ mergeItem.row = mergeRowIndex + newRecords.length;
20584
+ } else if (mergeRowIndex + mergeRowspan > afIndex) {
20585
+ mergeItem.rowspan = mergeRowspan + newRecords.length;
20586
+ }
20587
+ });
20588
+ }
20519
20589
  }
20520
20590
  }
20521
20591
 
20522
20592
  (_editStore$insertList = editStore.insertList).unshift.apply(_editStore$insertList, _toConsumableArray(newRecords));
20523
20593
 
20524
20594
  this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length;
20525
- this.handleTableData();
20595
+ this.handleTableData(transform);
20526
20596
  this.updateFooter();
20527
20597
  this.cacheRowMap();
20528
20598
  this.checkSelectionStatus();
@@ -20564,6 +20634,7 @@ var mixin_getRowid = UtilTools.getRowid;
20564
20634
  sYOpts = this.sYOpts,
20565
20635
  scrollYLoad = this.scrollYLoad,
20566
20636
  treeOpts = this.treeOpts;
20637
+ var transform = treeOpts.transform;
20567
20638
  var actived = editStore.actived,
20568
20639
  removeList = editStore.removeList,
20569
20640
  insertList = editStore.insertList;
@@ -20601,7 +20672,7 @@ var mixin_getRowid = UtilTools.getRowid;
20601
20672
  this.clearMergeCells();
20602
20673
  } else {
20603
20674
  // 如果为虚拟树
20604
- if (treeConfig && treeOpts.transform) {
20675
+ if (treeConfig && transform) {
20605
20676
  rows.forEach(function (row) {
20606
20677
  var rowid = mixin_getRowid(_this2, row);
20607
20678
  var matchObj = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.findTree(treeFullData, function (item) {
@@ -20664,7 +20735,7 @@ var mixin_getRowid = UtilTools.getRowid;
20664
20735
  }
20665
20736
  });
20666
20737
  this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length;
20667
- this.handleTableData();
20738
+ this.handleTableData(transform);
20668
20739
  this.updateFooter();
20669
20740
  this.cacheRowMap();
20670
20741
  this.checkSelectionStatus();
@@ -22545,12 +22616,20 @@ function getDateQuarter(date) {
22545
22616
  return 4;
22546
22617
  }
22547
22618
 
22619
+ function toFloatValueFixed(inputValue, digitsValue) {
22620
+ if (/^-/.test('' + inputValue)) {
22621
+ return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toFixed(external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.ceil(inputValue, digitsValue), digitsValue);
22622
+ }
22623
+
22624
+ return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toFixed(external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.floor(inputValue, digitsValue), digitsValue);
22625
+ }
22626
+
22548
22627
  function getNumberValue(_vm, val) {
22549
22628
  var type = _vm.type,
22550
22629
  exponential = _vm.exponential,
22551
22630
  digitsValue = _vm.digitsValue,
22552
22631
  inpMaxlength = _vm.inpMaxlength;
22553
- var restVal = type === 'float' ? external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toFixed(external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.floor(val, digitsValue), digitsValue) : external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toValueString(val);
22632
+ var restVal = type === 'float' ? toFloatValueFixed(val, digitsValue) : external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toValueString(val);
22554
22633
 
22555
22634
  if (exponential && (val === restVal || external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toValueString(val).toLowerCase() === external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toNumber(restVal).toExponential())) {
22556
22635
  return val;
@@ -23994,7 +24073,7 @@ function renderExtraSuffixIcon(h, _vm) {
23994
24073
  this.changeValue();
23995
24074
  } else if (type === 'float') {
23996
24075
  if (inputValue) {
23997
- var validValue = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.toFixed(external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default.a.floor(inputValue, digitsValue), digitsValue);
24076
+ var validValue = toFloatValueFixed(inputValue, digitsValue);
23998
24077
 
23999
24078
  if (inputValue !== validValue) {
24000
24079
  this.emitModel(validValue, {