vxe-table 3.7.0-beta.12 → 3.7.0-beta.13
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.
- package/lib/edit/src/mixin.js +252 -207
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.umd.js +245 -199
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/src/methods.js +1 -1
- package/lib/table/src/methods.min.js +1 -1
- package/package.json +1 -1
- package/packages/edit/src/mixin.js +169 -134
- package/packages/table/src/methods.js +1 -1
- package/types/table.d.ts +9 -0
- /package/lib/icon/style/{iconfont.1692433325378.ttf → iconfont.1692439110338.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1692433325378.woff → iconfont.1692439110338.woff} +0 -0
- /package/lib/icon/style/{iconfont.1692433325378.woff2 → iconfont.1692439110338.woff2} +0 -0
- /package/lib/{iconfont.1692433325378.ttf → iconfont.1692439110338.ttf} +0 -0
- /package/lib/{iconfont.1692433325378.woff → iconfont.1692439110338.woff} +0 -0
- /package/lib/{iconfont.1692433325378.woff2 → iconfont.1692439110338.woff2} +0 -0
package/lib/edit/src/mixin.js
CHANGED
|
@@ -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,
|
|
@@ -93,6 +93,189 @@ function insertTreeRow(_vm, newRecords, isAppend) {
|
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
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
|
+
}
|
|
96
279
|
var _default = {
|
|
97
280
|
methods: {
|
|
98
281
|
/**
|
|
@@ -101,7 +284,7 @@ var _default = {
|
|
|
101
284
|
* @param {*} records
|
|
102
285
|
*/
|
|
103
286
|
_insert: function _insert(records) {
|
|
104
|
-
return this
|
|
287
|
+
return handleInsertRowAt(this, records, null);
|
|
105
288
|
},
|
|
106
289
|
/**
|
|
107
290
|
* 往表格指定行中插入临时数据
|
|
@@ -110,163 +293,13 @@ var _default = {
|
|
|
110
293
|
* 如果 row 为有效行则插入到该行的位置
|
|
111
294
|
* @param {Object/Array} records 新的数据
|
|
112
295
|
* @param {Row} row 指定行
|
|
296
|
+
* @returns
|
|
113
297
|
*/
|
|
114
298
|
_insertAt: function _insertAt(records, row) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
editStore = this.editStore,
|
|
120
|
-
tableFullData = this.tableFullData,
|
|
121
|
-
treeConfig = this.treeConfig,
|
|
122
|
-
fullDataRowIdData = this.fullDataRowIdData,
|
|
123
|
-
fullAllDataRowIdData = this.fullAllDataRowIdData,
|
|
124
|
-
treeOpts = this.treeOpts;
|
|
125
|
-
var transform = treeOpts.transform,
|
|
126
|
-
rowField = treeOpts.rowField,
|
|
127
|
-
mapChildrenField = treeOpts.mapChildrenField;
|
|
128
|
-
if (!_xeUtils["default"].isArray(records)) {
|
|
129
|
-
records = [records];
|
|
130
|
-
}
|
|
131
|
-
var newRecords = this.defineField(records.map(function (record) {
|
|
132
|
-
return Object.assign({}, record);
|
|
133
|
-
}));
|
|
134
|
-
if (!row) {
|
|
135
|
-
// 如果为虚拟树
|
|
136
|
-
if (treeConfig && transform) {
|
|
137
|
-
insertTreeRow(this, newRecords, false);
|
|
138
|
-
} else {
|
|
139
|
-
afterFullData.unshift.apply(afterFullData, _toConsumableArray(newRecords));
|
|
140
|
-
tableFullData.unshift.apply(tableFullData, _toConsumableArray(newRecords));
|
|
141
|
-
// 刷新单元格合并
|
|
142
|
-
mergeList.forEach(function (mergeItem) {
|
|
143
|
-
var mergeRowIndex = mergeItem.row;
|
|
144
|
-
if (mergeRowIndex > 0) {
|
|
145
|
-
mergeItem.row = mergeRowIndex + newRecords.length;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
if (row === -1) {
|
|
151
|
-
// 如果为虚拟树
|
|
152
|
-
if (treeConfig && transform) {
|
|
153
|
-
insertTreeRow(this, newRecords, true);
|
|
154
|
-
} else {
|
|
155
|
-
afterFullData.push.apply(afterFullData, _toConsumableArray(newRecords));
|
|
156
|
-
tableFullData.push.apply(tableFullData, _toConsumableArray(newRecords));
|
|
157
|
-
// 刷新单元格合并
|
|
158
|
-
mergeList.forEach(function (mergeItem) {
|
|
159
|
-
var mergeRowIndex = mergeItem.row,
|
|
160
|
-
mergeRowspan = mergeItem.rowspan;
|
|
161
|
-
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
162
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
// 如果为虚拟树
|
|
168
|
-
if (treeConfig && transform) {
|
|
169
|
-
var matchObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
|
|
170
|
-
return row[rowField] === item[rowField];
|
|
171
|
-
}, {
|
|
172
|
-
children: mapChildrenField
|
|
173
|
-
});
|
|
174
|
-
if (matchObj) {
|
|
175
|
-
var parentRow = matchObj.parent;
|
|
176
|
-
var parentChilds = matchObj.items;
|
|
177
|
-
var parentRest = fullAllDataRowIdData[(0, _util.getRowid)(this, parentRow)];
|
|
178
|
-
var parentLevel = parentRest ? parentRest.level : 0;
|
|
179
|
-
newRecords.forEach(function (item, i) {
|
|
180
|
-
var rowid = (0, _util.getRowid)(_this, item);
|
|
181
|
-
if (process.env.NODE_ENV === 'development') {
|
|
182
|
-
if (item[treeOpts.parentField]) {
|
|
183
|
-
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
184
|
-
(0, _log.errLog)('vxe.error.errProp', ["".concat(treeOpts.parentField, "=").concat(item[treeOpts.parentField]), "".concat(treeOpts.parentField, "=").concat(parentRow[rowField])]);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (parentRow) {
|
|
189
|
-
item[treeOpts.parentField] = parentRow[rowField];
|
|
190
|
-
}
|
|
191
|
-
parentChilds.splice(matchObj.index + i, 0, item);
|
|
192
|
-
var rest = {
|
|
193
|
-
row: item,
|
|
194
|
-
rowid: rowid,
|
|
195
|
-
seq: -1,
|
|
196
|
-
index: -1,
|
|
197
|
-
_index: -1,
|
|
198
|
-
$index: -1,
|
|
199
|
-
items: parentChilds,
|
|
200
|
-
parent: parentRow,
|
|
201
|
-
level: parentLevel + 1
|
|
202
|
-
};
|
|
203
|
-
fullDataRowIdData[rowid] = rest;
|
|
204
|
-
fullAllDataRowIdData[rowid] = rest;
|
|
205
|
-
});
|
|
206
|
-
} else {
|
|
207
|
-
if (process.env.NODE_ENV === 'development') {
|
|
208
|
-
(0, _log.warnLog)('vxe.error.unableInsert');
|
|
209
|
-
}
|
|
210
|
-
insertTreeRow(this, newRecords, true);
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
if (treeConfig) {
|
|
214
|
-
throw new Error((0, _log.getLog)('vxe.error.noTree', ['insert']));
|
|
215
|
-
}
|
|
216
|
-
var afIndex = -1;
|
|
217
|
-
// 如果是可视索引
|
|
218
|
-
if (_xeUtils["default"].isNumber(row)) {
|
|
219
|
-
if (row < afterFullData.length) {
|
|
220
|
-
afIndex = row;
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
afIndex = this.findRowIndexOf(afterFullData, row);
|
|
224
|
-
}
|
|
225
|
-
if (afIndex === -1) {
|
|
226
|
-
throw new Error((0, _log.errLog)('vxe.error.unableInsert'));
|
|
227
|
-
}
|
|
228
|
-
afterFullData.splice.apply(afterFullData, [afIndex, 0].concat(_toConsumableArray(newRecords)));
|
|
229
|
-
tableFullData.splice.apply(tableFullData, [this.findRowIndexOf(tableFullData, row), 0].concat(_toConsumableArray(newRecords)));
|
|
230
|
-
// 刷新单元格合并
|
|
231
|
-
mergeList.forEach(function (mergeItem) {
|
|
232
|
-
var mergeRowIndex = mergeItem.row,
|
|
233
|
-
mergeRowspan = mergeItem.rowspan;
|
|
234
|
-
if (mergeRowIndex > afIndex) {
|
|
235
|
-
mergeItem.row = mergeRowIndex + newRecords.length;
|
|
236
|
-
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
237
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
var insertList = editStore.insertList,
|
|
244
|
-
insertMaps = editStore.insertMaps;
|
|
245
|
-
newRecords.forEach(function (newRow) {
|
|
246
|
-
var rowid = (0, _util.getRowid)(_this, newRow);
|
|
247
|
-
insertMaps[rowid] = newRow;
|
|
248
|
-
});
|
|
249
|
-
insertList.unshift.apply(insertList, _toConsumableArray(newRecords));
|
|
250
|
-
this.cacheRowMap();
|
|
251
|
-
this.updateScrollYStatus();
|
|
252
|
-
this.handleTableData(treeConfig && transform);
|
|
253
|
-
if (!(treeConfig && transform)) {
|
|
254
|
-
this.updateAfterDataIndex();
|
|
255
|
-
}
|
|
256
|
-
this.updateFooter();
|
|
257
|
-
this.checkSelectionStatus();
|
|
258
|
-
if (this.scrollYLoad) {
|
|
259
|
-
this.updateScrollYSpace();
|
|
260
|
-
}
|
|
261
|
-
return this.$nextTick().then(function () {
|
|
262
|
-
_this.updateCellAreas();
|
|
263
|
-
return _this.recalculate();
|
|
264
|
-
}).then(function () {
|
|
265
|
-
return {
|
|
266
|
-
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
267
|
-
rows: newRecords
|
|
268
|
-
};
|
|
269
|
-
});
|
|
299
|
+
return handleInsertRowAt(this, records, row);
|
|
300
|
+
},
|
|
301
|
+
_insertNextAt: function _insertNextAt(records, row) {
|
|
302
|
+
return handleInsertRowAt(this, records, row, true);
|
|
270
303
|
},
|
|
271
304
|
/**
|
|
272
305
|
* 删除指定行数据
|
|
@@ -275,7 +308,7 @@ var _default = {
|
|
|
275
308
|
* 如果为空则删除所有
|
|
276
309
|
*/
|
|
277
310
|
_remove: function _remove(rows) {
|
|
278
|
-
var
|
|
311
|
+
var _this = this;
|
|
279
312
|
var afterFullData = this.afterFullData,
|
|
280
313
|
tableFullData = this.tableFullData,
|
|
281
314
|
tableFullTreeData = this.tableFullTreeData,
|
|
@@ -286,13 +319,15 @@ var _default = {
|
|
|
286
319
|
selectCheckboxRows = this.selectCheckboxRows,
|
|
287
320
|
isInsertByRow = this.isInsertByRow,
|
|
288
321
|
treeOpts = this.treeOpts;
|
|
289
|
-
var transform = treeOpts.transform
|
|
322
|
+
var transform = treeOpts.transform,
|
|
323
|
+
mapChildrenField = treeOpts.mapChildrenField;
|
|
324
|
+
var childrenField = treeOpts.children || treeOpts.childrenField;
|
|
290
325
|
var actived = editStore.actived,
|
|
291
326
|
removeList = editStore.removeList,
|
|
292
327
|
insertList = editStore.insertList,
|
|
293
328
|
insertMaps = editStore.insertMaps;
|
|
294
329
|
var checkField = checkboxOpts.checkField;
|
|
295
|
-
var
|
|
330
|
+
var delList = [];
|
|
296
331
|
if (!rows) {
|
|
297
332
|
rows = tableFullData;
|
|
298
333
|
} else if (!_xeUtils["default"].isArray(rows)) {
|
|
@@ -307,7 +342,7 @@ var _default = {
|
|
|
307
342
|
// 如果绑定了多选属性,则更新状态
|
|
308
343
|
if (!checkField) {
|
|
309
344
|
rows.forEach(function (row) {
|
|
310
|
-
var sIndex =
|
|
345
|
+
var sIndex = _this.findRowIndexOf(selectCheckboxRows, row);
|
|
311
346
|
if (sIndex > -1) {
|
|
312
347
|
selectCheckboxRows.splice(sIndex, 1);
|
|
313
348
|
}
|
|
@@ -315,7 +350,7 @@ var _default = {
|
|
|
315
350
|
}
|
|
316
351
|
// 从数据源中移除
|
|
317
352
|
if (tableFullData === rows) {
|
|
318
|
-
rows =
|
|
353
|
+
rows = delList = tableFullData.slice(0);
|
|
319
354
|
this.tableFullData = [];
|
|
320
355
|
this.afterFullData = [];
|
|
321
356
|
this.clearMergeCells();
|
|
@@ -323,27 +358,37 @@ var _default = {
|
|
|
323
358
|
// 如果为虚拟树
|
|
324
359
|
if (treeConfig && transform) {
|
|
325
360
|
rows.forEach(function (row) {
|
|
326
|
-
var rowid = (0, _util.getRowid)(
|
|
361
|
+
var rowid = (0, _util.getRowid)(_this, row);
|
|
362
|
+
var matchMapObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
|
|
363
|
+
return rowid === (0, _util.getRowid)(_this, item);
|
|
364
|
+
}, {
|
|
365
|
+
children: mapChildrenField
|
|
366
|
+
});
|
|
367
|
+
if (matchMapObj) {
|
|
368
|
+
var rItems = matchMapObj.items.splice(matchMapObj.index, 1);
|
|
369
|
+
delList.push(rItems[0]);
|
|
370
|
+
}
|
|
327
371
|
var matchObj = _xeUtils["default"].findTree(tableFullTreeData, function (item) {
|
|
328
|
-
return rowid === (0, _util.getRowid)(
|
|
329
|
-
},
|
|
372
|
+
return rowid === (0, _util.getRowid)(_this, item);
|
|
373
|
+
}, {
|
|
374
|
+
children: childrenField
|
|
375
|
+
});
|
|
330
376
|
if (matchObj) {
|
|
331
|
-
|
|
332
|
-
rest.push(rItems[0]);
|
|
377
|
+
matchObj.items.splice(matchObj.index, 1);
|
|
333
378
|
}
|
|
334
|
-
var afIndex =
|
|
379
|
+
var afIndex = _this.findRowIndexOf(afterFullData, row);
|
|
335
380
|
if (afIndex > -1) {
|
|
336
381
|
afterFullData.splice(afIndex, 1);
|
|
337
382
|
}
|
|
338
383
|
});
|
|
339
384
|
} else {
|
|
340
385
|
rows.forEach(function (row) {
|
|
341
|
-
var tfIndex =
|
|
386
|
+
var tfIndex = _this.findRowIndexOf(tableFullData, row);
|
|
342
387
|
if (tfIndex > -1) {
|
|
343
388
|
var rItems = tableFullData.splice(tfIndex, 1);
|
|
344
|
-
|
|
389
|
+
delList.push(rItems[0]);
|
|
345
390
|
}
|
|
346
|
-
var afIndex =
|
|
391
|
+
var afIndex = _this.findRowIndexOf(afterFullData, row);
|
|
347
392
|
if (afIndex > -1) {
|
|
348
393
|
// 刷新单元格合并
|
|
349
394
|
mergeList.forEach(function (mergeItem) {
|
|
@@ -366,8 +411,8 @@ var _default = {
|
|
|
366
411
|
}
|
|
367
412
|
// 从新增中移除已删除的数据
|
|
368
413
|
rows.forEach(function (row) {
|
|
369
|
-
var rowid = (0, _util.getRowid)(
|
|
370
|
-
var iIndex =
|
|
414
|
+
var rowid = (0, _util.getRowid)(_this, row);
|
|
415
|
+
var iIndex = _this.findRowIndexOf(insertList, row);
|
|
371
416
|
if (iIndex > -1) {
|
|
372
417
|
insertList.splice(iIndex, 1);
|
|
373
418
|
}
|
|
@@ -384,12 +429,12 @@ var _default = {
|
|
|
384
429
|
this.updateScrollYSpace();
|
|
385
430
|
}
|
|
386
431
|
return this.$nextTick().then(function () {
|
|
387
|
-
|
|
388
|
-
return
|
|
432
|
+
_this.updateCellAreas();
|
|
433
|
+
return _this.recalculate();
|
|
389
434
|
}).then(function () {
|
|
390
435
|
return {
|
|
391
|
-
row:
|
|
392
|
-
rows:
|
|
436
|
+
row: delList.length ? delList[delList.length - 1] : null,
|
|
437
|
+
rows: delList
|
|
393
438
|
};
|
|
394
439
|
});
|
|
395
440
|
},
|
|
@@ -397,9 +442,9 @@ var _default = {
|
|
|
397
442
|
* 删除复选框选中的数据
|
|
398
443
|
*/
|
|
399
444
|
_removeCheckboxRow: function _removeCheckboxRow() {
|
|
400
|
-
var
|
|
445
|
+
var _this2 = this;
|
|
401
446
|
return this.remove(this.getCheckboxRecords()).then(function (params) {
|
|
402
|
-
|
|
447
|
+
_this2.clearCheckboxRow();
|
|
403
448
|
return params;
|
|
404
449
|
});
|
|
405
450
|
},
|
|
@@ -407,10 +452,10 @@ var _default = {
|
|
|
407
452
|
* 删除单选框选中的数据
|
|
408
453
|
*/
|
|
409
454
|
_removeRadioRow: function _removeRadioRow() {
|
|
410
|
-
var
|
|
455
|
+
var _this3 = this;
|
|
411
456
|
var radioRecord = this.getRadioRecord();
|
|
412
457
|
return this.remove(radioRecord || []).then(function (params) {
|
|
413
|
-
|
|
458
|
+
_this3.clearRadioRow();
|
|
414
459
|
return params;
|
|
415
460
|
});
|
|
416
461
|
},
|
|
@@ -418,10 +463,10 @@ var _default = {
|
|
|
418
463
|
* 删除当前行选中的数据
|
|
419
464
|
*/
|
|
420
465
|
_removeCurrentRow: function _removeCurrentRow() {
|
|
421
|
-
var
|
|
466
|
+
var _this4 = this;
|
|
422
467
|
var currentRecord = this.getCurrentRecord();
|
|
423
468
|
return this.remove(currentRecord || []).then(function (params) {
|
|
424
|
-
|
|
469
|
+
_this4.clearCurrentRow();
|
|
425
470
|
return params;
|
|
426
471
|
});
|
|
427
472
|
},
|
|
@@ -439,12 +484,12 @@ var _default = {
|
|
|
439
484
|
* 获取新增的临时数据
|
|
440
485
|
*/
|
|
441
486
|
_getInsertRecords: function _getInsertRecords() {
|
|
442
|
-
var
|
|
487
|
+
var _this5 = this;
|
|
443
488
|
var fullAllDataRowIdData = this.fullAllDataRowIdData;
|
|
444
489
|
var insertList = this.editStore.insertList;
|
|
445
490
|
var insertRecords = [];
|
|
446
491
|
insertList.forEach(function (row) {
|
|
447
|
-
var rowid = (0, _util.getRowid)(
|
|
492
|
+
var rowid = (0, _util.getRowid)(_this5, row);
|
|
448
493
|
if (fullAllDataRowIdData[rowid]) {
|
|
449
494
|
insertRecords.push(row);
|
|
450
495
|
}
|
|
@@ -491,7 +536,7 @@ var _default = {
|
|
|
491
536
|
* 处理激活编辑
|
|
492
537
|
*/
|
|
493
538
|
handleActived: function handleActived(params, evnt) {
|
|
494
|
-
var
|
|
539
|
+
var _this6 = this;
|
|
495
540
|
var editStore = this.editStore,
|
|
496
541
|
editOpts = this.editOpts,
|
|
497
542
|
tableColumn = this.tableColumn,
|
|
@@ -527,13 +572,13 @@ var _default = {
|
|
|
527
572
|
actived.column = column;
|
|
528
573
|
if (mode === 'row') {
|
|
529
574
|
tableColumn.forEach(function (column) {
|
|
530
|
-
return
|
|
575
|
+
return _this6._getColumnModel(row, column);
|
|
531
576
|
});
|
|
532
577
|
} else {
|
|
533
578
|
this._getColumnModel(row, column);
|
|
534
579
|
}
|
|
535
580
|
this.$nextTick(function () {
|
|
536
|
-
|
|
581
|
+
_this6.handleFocus(params, evnt);
|
|
537
582
|
});
|
|
538
583
|
}
|
|
539
584
|
this.emitEvent(type, {
|
|
@@ -562,7 +607,7 @@ var _default = {
|
|
|
562
607
|
actived.args = params;
|
|
563
608
|
actived.column = column;
|
|
564
609
|
setTimeout(function () {
|
|
565
|
-
|
|
610
|
+
_this6.handleFocus(params, evnt);
|
|
566
611
|
});
|
|
567
612
|
}
|
|
568
613
|
this.focus();
|
|
@@ -587,7 +632,7 @@ var _default = {
|
|
|
587
632
|
}
|
|
588
633
|
},
|
|
589
634
|
_syncActivedCell: function _syncActivedCell() {
|
|
590
|
-
var
|
|
635
|
+
var _this7 = this;
|
|
591
636
|
var tableColumn = this.tableColumn,
|
|
592
637
|
editStore = this.editStore,
|
|
593
638
|
editOpts = this.editOpts;
|
|
@@ -597,7 +642,7 @@ var _default = {
|
|
|
597
642
|
if (row || column) {
|
|
598
643
|
if (editOpts.mode === 'row') {
|
|
599
644
|
tableColumn.forEach(function (column) {
|
|
600
|
-
return
|
|
645
|
+
return _this7._setColumnModel(row, column);
|
|
601
646
|
});
|
|
602
647
|
} else {
|
|
603
648
|
this._setColumnModel(row, column);
|
|
@@ -740,22 +785,22 @@ var _default = {
|
|
|
740
785
|
* 激活单元格编辑
|
|
741
786
|
*/
|
|
742
787
|
_setEditCell: function _setEditCell(row, fieldOrColumn) {
|
|
743
|
-
var
|
|
788
|
+
var _this8 = this;
|
|
744
789
|
var editConfig = this.editConfig;
|
|
745
790
|
var column = _xeUtils["default"].isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
746
791
|
if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender)) {
|
|
747
792
|
return this.scrollToRow(row, true).then(function () {
|
|
748
|
-
var cell =
|
|
793
|
+
var cell = _this8.getCell(row, column);
|
|
749
794
|
if (cell) {
|
|
750
|
-
|
|
795
|
+
_this8.handleActived({
|
|
751
796
|
row: row,
|
|
752
|
-
rowIndex:
|
|
797
|
+
rowIndex: _this8.getRowIndex(row),
|
|
753
798
|
column: column,
|
|
754
|
-
columnIndex:
|
|
799
|
+
columnIndex: _this8.getColumnIndex(column),
|
|
755
800
|
cell: cell,
|
|
756
|
-
$table:
|
|
801
|
+
$table: _this8
|
|
757
802
|
});
|
|
758
|
-
|
|
803
|
+
_this8.lastCallTime = Date.now();
|
|
759
804
|
}
|
|
760
805
|
});
|
|
761
806
|
}
|
|
@@ -789,7 +834,7 @@ var _default = {
|
|
|
789
834
|
* 处理选中源
|
|
790
835
|
*/
|
|
791
836
|
handleSelected: function handleSelected(params, evnt) {
|
|
792
|
-
var
|
|
837
|
+
var _this9 = this;
|
|
793
838
|
var mouseConfig = this.mouseConfig,
|
|
794
839
|
mouseOpts = this.mouseOpts,
|
|
795
840
|
editOpts = this.editOpts,
|
|
@@ -802,23 +847,23 @@ var _default = {
|
|
|
802
847
|
var selectMethod = function selectMethod() {
|
|
803
848
|
if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
|
|
804
849
|
if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
850
|
+
_this9.clearActived(evnt);
|
|
851
|
+
_this9.clearSelected(evnt);
|
|
852
|
+
_this9.clearCellAreas(evnt);
|
|
853
|
+
_this9.clearCopyCellArea(evnt);
|
|
809
854
|
selected.args = params;
|
|
810
855
|
selected.row = row;
|
|
811
856
|
selected.column = column;
|
|
812
857
|
if (isMouseSelected) {
|
|
813
|
-
|
|
858
|
+
_this9.addColSdCls();
|
|
814
859
|
}
|
|
815
|
-
|
|
860
|
+
_this9.focus();
|
|
816
861
|
if (evnt) {
|
|
817
|
-
|
|
862
|
+
_this9.emitEvent('cell-selected', params, evnt);
|
|
818
863
|
}
|
|
819
864
|
}
|
|
820
865
|
}
|
|
821
|
-
return
|
|
866
|
+
return _this9.$nextTick();
|
|
822
867
|
};
|
|
823
868
|
return selectMethod();
|
|
824
869
|
},
|