vxe-pc-ui 3.15.25 → 3.15.26
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/es/icon/style.css +1 -1
- package/es/list/src/list.js +560 -13
- package/es/list/src/util.js +8 -0
- package/es/list/style.css +10 -4
- package/es/list/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +4 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-list/style.css +10 -4
- package/es/vxe-list/style.min.css +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +652 -16
- package/lib/index.umd.min.js +1 -1
- package/lib/list/src/list.js +605 -11
- package/lib/list/src/list.min.js +1 -1
- package/lib/list/src/util.js +14 -0
- package/lib/list/src/util.min.js +1 -0
- package/lib/list/style/style.css +10 -4
- package/lib/list/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +4 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-list/style/style.css +10 -4
- package/lib/vxe-list/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/list/src/list.ts +588 -13
- package/packages/list/src/util.ts +11 -0
- package/packages/ui/index.ts +3 -0
- package/styles/components/list.scss +8 -4
- package/types/components/list.d.ts +120 -4
- package/types/components/tree.d.ts +3 -7
- package/types/ui/menus.d.ts +13 -1
- /package/es/icon/{iconfont.1783247770465.ttf → iconfont.1783301643461.ttf} +0 -0
- /package/es/icon/{iconfont.1783247770465.woff → iconfont.1783301643461.woff} +0 -0
- /package/es/icon/{iconfont.1783247770465.woff2 → iconfont.1783301643461.woff2} +0 -0
- /package/es/{iconfont.1783247770465.ttf → iconfont.1783301643461.ttf} +0 -0
- /package/es/{iconfont.1783247770465.woff → iconfont.1783301643461.woff} +0 -0
- /package/es/{iconfont.1783247770465.woff2 → iconfont.1783301643461.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1783247770465.ttf → iconfont.1783301643461.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1783247770465.woff → iconfont.1783301643461.woff} +0 -0
- /package/lib/icon/style/{iconfont.1783247770465.woff2 → iconfont.1783301643461.woff2} +0 -0
- /package/lib/{iconfont.1783247770465.ttf → iconfont.1783301643461.ttf} +0 -0
- /package/lib/{iconfont.1783247770465.woff → iconfont.1783301643461.woff} +0 -0
- /package/lib/{iconfont.1783247770465.woff2 → iconfont.1783301643461.woff2} +0 -0
package/es/list/src/list.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
2
2
|
import XEUtils from 'xe-utils';
|
|
3
|
-
import { getConfig, getIcon, getI18n, globalEvents, globalResize, createEvent, globalMixins, renderEmptyElement } from '../../ui';
|
|
3
|
+
import { VxeUI, getConfig, getIcon, getI18n, menus, globalEvents, globalResize, createEvent, globalMixins, renderEmptyElement } from '../../ui';
|
|
4
4
|
import { crossListDragRowGlobal, getCrossListDragRowInfo } from './store';
|
|
5
5
|
import { addClass, getTpImg, isScale, removeClass, toCssUnit } from '../../ui/src/dom';
|
|
6
6
|
import { isEnableConf, getText, enModelValue, deModelValue } from '../../ui/src/utils';
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn';
|
|
8
8
|
import { createComponentLog } from '../../ui/src/log';
|
|
9
9
|
import { moveRowAnimateToTb, clearRowAnimate } from '../../ui/src/anime';
|
|
10
|
+
import { getItemCacheObj } from './util';
|
|
10
11
|
import VxeLoadingComponent from '../../loading/src/loading';
|
|
11
|
-
const { errLog } = createComponentLog('tree');
|
|
12
|
+
const { warnLog, errLog } = createComponentLog('tree');
|
|
13
|
+
let crossListDragRowObj = null;
|
|
12
14
|
function eqRowKey(rowKey1, rowKey2) {
|
|
13
15
|
return ('' + rowKey1) === ('' + rowKey2);
|
|
14
16
|
}
|
|
@@ -38,15 +40,20 @@ function createReactData() {
|
|
|
38
40
|
updateCheckboxFlag: 1,
|
|
39
41
|
isAllChecked: false,
|
|
40
42
|
isAllIndeterminate: false,
|
|
43
|
+
insertRowFlag: 1,
|
|
44
|
+
removeRowFlag: 1,
|
|
41
45
|
dragRow: null,
|
|
42
|
-
dragTipText: ''
|
|
46
|
+
dragTipText: '',
|
|
47
|
+
isCrossDragRow: false
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
function createInternalData() {
|
|
46
51
|
return {
|
|
47
52
|
resizeObserver: undefined,
|
|
48
53
|
fullData: [],
|
|
54
|
+
afterList: [],
|
|
49
55
|
fullKeyMaps: {},
|
|
56
|
+
rowMaps: {},
|
|
50
57
|
lastScrollLeft: 0,
|
|
51
58
|
lastScrollTop: 0,
|
|
52
59
|
scrollYStore: {
|
|
@@ -57,7 +64,9 @@ function createInternalData() {
|
|
|
57
64
|
rowHeight: 0
|
|
58
65
|
},
|
|
59
66
|
currentRow: null,
|
|
60
|
-
selectCheckboxMaps: {}
|
|
67
|
+
selectCheckboxMaps: {},
|
|
68
|
+
insertRowMaps: {},
|
|
69
|
+
removeRowMaps: {}
|
|
61
70
|
// prevDragRow: null,
|
|
62
71
|
// prevDragPos: ''
|
|
63
72
|
};
|
|
@@ -82,6 +91,10 @@ export default {
|
|
|
82
91
|
default: () => getConfig().list.autoResize
|
|
83
92
|
},
|
|
84
93
|
syncResize: [Boolean, String, Number],
|
|
94
|
+
showSeq: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: () => getConfig().list.showSeq
|
|
97
|
+
},
|
|
85
98
|
showRadio: {
|
|
86
99
|
type: Boolean,
|
|
87
100
|
default: () => getConfig().list.showRadio
|
|
@@ -96,6 +109,7 @@ export default {
|
|
|
96
109
|
checkboxConfig: Object,
|
|
97
110
|
rowConfig: Object,
|
|
98
111
|
dragConfig: Object,
|
|
112
|
+
menuConfig: Object,
|
|
99
113
|
virtualYConfig: Object,
|
|
100
114
|
scrollY: Object
|
|
101
115
|
},
|
|
@@ -149,6 +163,11 @@ export default {
|
|
|
149
163
|
const props = $xeList;
|
|
150
164
|
return Object.assign({ showIcon: true }, getConfig().list.checkboxConfig, props.checkboxConfig);
|
|
151
165
|
},
|
|
166
|
+
computeMenuOpts() {
|
|
167
|
+
const $xeList = this;
|
|
168
|
+
const props = $xeList;
|
|
169
|
+
return Object.assign({}, getConfig().list.menuConfig, props.menuConfig);
|
|
170
|
+
},
|
|
152
171
|
computeWrapperStyles() {
|
|
153
172
|
const $xeList = this;
|
|
154
173
|
const rowHeight = $xeList.computeRowHeight;
|
|
@@ -243,6 +262,30 @@ export default {
|
|
|
243
262
|
internalData.selectCheckboxMaps = selectMaps;
|
|
244
263
|
$xeList.updateCheckboxStatus();
|
|
245
264
|
},
|
|
265
|
+
updateAfterDataIndex() {
|
|
266
|
+
const $xeList = this;
|
|
267
|
+
const internalData = $xeList.internalData;
|
|
268
|
+
const { afterList, rowMaps } = internalData;
|
|
269
|
+
const keyField = $xeList.computeKeyField;
|
|
270
|
+
let vtIndex = 0;
|
|
271
|
+
afterList.forEach((item, index) => {
|
|
272
|
+
const roweid = getRowIdByField(item, keyField);
|
|
273
|
+
const rowRest = rowMaps[roweid];
|
|
274
|
+
if (rowRest) {
|
|
275
|
+
rowRest._index = vtIndex;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
const rest = {
|
|
279
|
+
item,
|
|
280
|
+
index,
|
|
281
|
+
$index: -1,
|
|
282
|
+
_index: vtIndex
|
|
283
|
+
};
|
|
284
|
+
rowMaps[roweid] = rest;
|
|
285
|
+
}
|
|
286
|
+
vtIndex++;
|
|
287
|
+
});
|
|
288
|
+
},
|
|
246
289
|
cacheRowMap() {
|
|
247
290
|
const $xeList = this;
|
|
248
291
|
const internalData = $xeList.internalData;
|
|
@@ -265,17 +308,21 @@ export default {
|
|
|
265
308
|
const internalData = $xeList.internalData;
|
|
266
309
|
const { scrollYStore } = internalData;
|
|
267
310
|
const sYOpts = $xeList.computeSYOpts;
|
|
268
|
-
const fullData = datas
|
|
311
|
+
const fullData = datas ? datas.slice(0) : [];
|
|
269
312
|
Object.assign(scrollYStore, {
|
|
270
313
|
startIndex: 0,
|
|
271
314
|
endIndex: 1,
|
|
272
315
|
visibleSize: 0
|
|
273
316
|
});
|
|
274
317
|
internalData.fullData = fullData;
|
|
318
|
+
internalData.insertRowMaps = {};
|
|
319
|
+
reactData.insertRowFlag++;
|
|
320
|
+
internalData.removeRowMaps = {};
|
|
321
|
+
reactData.removeRowFlag++;
|
|
275
322
|
// 如果gt为0,则总是启用
|
|
276
323
|
reactData.scrollYLoad = !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt <= fullData.length);
|
|
277
324
|
$xeList.cacheRowMap();
|
|
278
|
-
$xeList.handleData();
|
|
325
|
+
$xeList.handleData(true);
|
|
279
326
|
$xeList.updateRadioModeValue();
|
|
280
327
|
$xeList.updateCheckboxModeValue();
|
|
281
328
|
return $xeList.computeScrollLoad().then(() => {
|
|
@@ -339,13 +386,35 @@ export default {
|
|
|
339
386
|
reactData.bodyHeight = scrollYLoad ? fullData.length * scrollYStore.rowHeight : 0;
|
|
340
387
|
reactData.topSpaceHeight = scrollYLoad ? Math.max(scrollYStore.startIndex * scrollYStore.rowHeight, 0) : 0;
|
|
341
388
|
},
|
|
342
|
-
|
|
389
|
+
updateAfterFullData() {
|
|
390
|
+
const $xeList = this;
|
|
391
|
+
const internalData = $xeList.internalData;
|
|
392
|
+
const { fullData } = internalData;
|
|
393
|
+
internalData.afterList = fullData.slice(0);
|
|
394
|
+
$xeList.updateAfterDataIndex();
|
|
395
|
+
},
|
|
396
|
+
handleData(force) {
|
|
343
397
|
const $xeList = this;
|
|
344
398
|
const reactData = $xeList.reactData;
|
|
345
399
|
const internalData = $xeList.internalData;
|
|
346
400
|
const { scrollYLoad } = reactData;
|
|
347
|
-
const { fullData, scrollYStore } = internalData;
|
|
348
|
-
|
|
401
|
+
const { fullData, scrollYStore, rowMaps } = internalData;
|
|
402
|
+
const keyField = $xeList.computeKeyField;
|
|
403
|
+
if (force) {
|
|
404
|
+
// 更新数据,处理筛选和排序
|
|
405
|
+
$xeList.updateAfterFullData();
|
|
406
|
+
}
|
|
407
|
+
const rowList = scrollYLoad ? fullData.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullData.slice(0);
|
|
408
|
+
if (keyField) {
|
|
409
|
+
rowList.forEach((item, $index) => {
|
|
410
|
+
const rowid = getRowIdByField(item, keyField);
|
|
411
|
+
const rowRest = rowMaps[rowid];
|
|
412
|
+
if (rowRest) {
|
|
413
|
+
rowRest.$index = $index;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
reactData.rowList = rowList;
|
|
349
418
|
return $xeList.$nextTick();
|
|
350
419
|
},
|
|
351
420
|
updateYData() {
|
|
@@ -887,6 +956,12 @@ export default {
|
|
|
887
956
|
$xeList.emitRadioMode(value);
|
|
888
957
|
$xeList.dispatchEvent('radio-change', { row, value, checked: isChecked }, evnt);
|
|
889
958
|
},
|
|
959
|
+
handleRowDragEndClearStatus() {
|
|
960
|
+
const $xeList = this;
|
|
961
|
+
$xeList.clearRowDragData();
|
|
962
|
+
$xeList.clearCrossListDragStatus();
|
|
963
|
+
$xeList.recalculate();
|
|
964
|
+
},
|
|
890
965
|
clearRowDropOrigin() {
|
|
891
966
|
const $xeList = this;
|
|
892
967
|
const el = $xeList.$refs.refElem;
|
|
@@ -945,7 +1020,7 @@ export default {
|
|
|
945
1020
|
clearCrossListDragStatus() {
|
|
946
1021
|
const $xeList = this;
|
|
947
1022
|
const crossListDragRowInfo = getCrossListDragRowInfo($xeList);
|
|
948
|
-
|
|
1023
|
+
crossListDragRowObj = null;
|
|
949
1024
|
crossListDragRowInfo.row = null;
|
|
950
1025
|
},
|
|
951
1026
|
clearDragStatus() {
|
|
@@ -962,10 +1037,11 @@ export default {
|
|
|
962
1037
|
handleRowDragMousedownEvent(evnt, params) {
|
|
963
1038
|
const $xeList = this;
|
|
964
1039
|
const reactData = $xeList.reactData;
|
|
1040
|
+
const crossListDragRowInfo = getCrossListDragRowInfo($xeList);
|
|
965
1041
|
evnt.stopPropagation();
|
|
966
1042
|
const { row } = params;
|
|
967
1043
|
const dragConfig = $xeList.computeDragOpts;
|
|
968
|
-
const { trigger, dragStartMethod } = dragConfig;
|
|
1044
|
+
const { isCrossListDrag, trigger, dragStartMethod } = dragConfig;
|
|
969
1045
|
const dragEl = evnt.currentTarget;
|
|
970
1046
|
const rowEl = trigger === 'row' ? dragEl : dragEl.parentElement.parentElement;
|
|
971
1047
|
$xeList.clearRowDropOrigin();
|
|
@@ -975,6 +1051,10 @@ export default {
|
|
|
975
1051
|
$xeList.hideDropTip();
|
|
976
1052
|
return;
|
|
977
1053
|
}
|
|
1054
|
+
if (isCrossListDrag) {
|
|
1055
|
+
crossListDragRowInfo.row = row;
|
|
1056
|
+
crossListDragRowObj = { $oldList: $xeList, $newList: null };
|
|
1057
|
+
}
|
|
978
1058
|
const dragstartEventParams = {
|
|
979
1059
|
row
|
|
980
1060
|
};
|
|
@@ -1191,6 +1271,16 @@ export default {
|
|
|
1191
1271
|
const internalData = $xeList.internalData;
|
|
1192
1272
|
const { dragRow } = reactData;
|
|
1193
1273
|
const { prevDragRow, prevDragPos } = internalData;
|
|
1274
|
+
const dragConfig = $xeList.computeDragOpts;
|
|
1275
|
+
const { isCrossListDrag } = dragConfig;
|
|
1276
|
+
// 跨列表拖拽
|
|
1277
|
+
if (isCrossListDrag && crossListDragRowObj) {
|
|
1278
|
+
const { $newList } = crossListDragRowObj;
|
|
1279
|
+
if ($newList && $newList.xID !== $xeList.xID) {
|
|
1280
|
+
$newList.handleCrossListRowDragInsertEvent(evnt);
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1194
1284
|
$xeList.handleRowDragSwapEvent(evnt, dragRow, prevDragRow, prevDragPos);
|
|
1195
1285
|
},
|
|
1196
1286
|
handleRowDragDragoverEvent(evnt) {
|
|
@@ -1278,6 +1368,445 @@ export default {
|
|
|
1278
1368
|
const $xeList = this;
|
|
1279
1369
|
$xeList.dispatchEvent('row-dblclick', { row }, evnt);
|
|
1280
1370
|
},
|
|
1371
|
+
insertListRow(newRecords, isAppend) {
|
|
1372
|
+
const $xeList = this;
|
|
1373
|
+
const internalData = $xeList.internalData;
|
|
1374
|
+
const { fullData, rowMaps } = internalData;
|
|
1375
|
+
const keyField = $xeList.computeKeyField;
|
|
1376
|
+
const funcName = isAppend ? 'push' : 'unshift';
|
|
1377
|
+
newRecords.forEach((item) => {
|
|
1378
|
+
const rowid = getRowIdByField(item, keyField);
|
|
1379
|
+
const rowRest = getItemCacheObj(item);
|
|
1380
|
+
fullData[funcName](item);
|
|
1381
|
+
rowMaps[rowid] = rowRest;
|
|
1382
|
+
});
|
|
1383
|
+
},
|
|
1384
|
+
handleInsertRowAt(records, targetRowOrRowKey, isInsertNextRow) {
|
|
1385
|
+
const $xeList = this;
|
|
1386
|
+
const reactData = $xeList.reactData;
|
|
1387
|
+
const internalData = $xeList.internalData;
|
|
1388
|
+
const { fullData, rowMaps, removeRowMaps, insertRowMaps } = internalData;
|
|
1389
|
+
const keyField = $xeList.computeKeyField;
|
|
1390
|
+
if (!keyField) {
|
|
1391
|
+
errLog('vxe.error.reqSupportProp', ['insert() | insertAt() | insertNextAt()', 'row-config.keyField']);
|
|
1392
|
+
return Promise.resolve({ row: null, rows: [] });
|
|
1393
|
+
}
|
|
1394
|
+
if (!XEUtils.isArray(records)) {
|
|
1395
|
+
records = [records];
|
|
1396
|
+
}
|
|
1397
|
+
let targetRow = targetRowOrRowKey;
|
|
1398
|
+
if (XEUtils.isString(targetRowOrRowKey) || XEUtils.isNumber(targetRowOrRowKey)) {
|
|
1399
|
+
const rowRest = rowMaps[targetRowOrRowKey];
|
|
1400
|
+
if (rowRest) {
|
|
1401
|
+
targetRow = rowRest.item;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
if (!records.length) {
|
|
1405
|
+
return Promise.resolve({ row: null, rows: [] });
|
|
1406
|
+
}
|
|
1407
|
+
const newRecords = records.map(record => XEUtils.assign({}, record));
|
|
1408
|
+
if (XEUtils.eqNull(targetRow)) {
|
|
1409
|
+
$xeList.insertListRow(newRecords, false);
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
if (targetRow === -1) {
|
|
1413
|
+
$xeList.insertListRow(newRecords, true);
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
const rowIndex = fullData.findIndex(item => targetRow[keyField] === item[keyField]);
|
|
1417
|
+
if (rowIndex > -1) {
|
|
1418
|
+
newRecords.forEach(item => {
|
|
1419
|
+
const rowid = getRowIdByField(item, keyField);
|
|
1420
|
+
const rowRest = getItemCacheObj(item);
|
|
1421
|
+
rowMaps[rowid] = rowRest;
|
|
1422
|
+
});
|
|
1423
|
+
let targetIndex = rowIndex;
|
|
1424
|
+
if (isInsertNextRow) {
|
|
1425
|
+
targetIndex = targetIndex + 1;
|
|
1426
|
+
}
|
|
1427
|
+
fullData.splice(targetIndex, 0, ...newRecords);
|
|
1428
|
+
}
|
|
1429
|
+
else {
|
|
1430
|
+
warnLog('vxe.error.unableInsert');
|
|
1431
|
+
$xeList.insertListRow(newRecords, true);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
newRecords.forEach((newItem) => {
|
|
1436
|
+
const rowid = getRowIdByField(newItem, keyField);
|
|
1437
|
+
// 如果是被删除的数据,则还原状态
|
|
1438
|
+
if (removeRowMaps[rowid]) {
|
|
1439
|
+
delete removeRowMaps[rowid];
|
|
1440
|
+
if (insertRowMaps[rowid]) {
|
|
1441
|
+
delete insertRowMaps[rowid];
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
insertRowMaps[rowid] = newItem;
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
reactData.removeRowFlag++;
|
|
1449
|
+
reactData.insertRowFlag++;
|
|
1450
|
+
$xeList.cacheRowMap();
|
|
1451
|
+
$xeList.handleData(true);
|
|
1452
|
+
$xeList.updateAfterDataIndex();
|
|
1453
|
+
$xeList.updateCheckboxStatus();
|
|
1454
|
+
if (reactData.scrollYLoad) {
|
|
1455
|
+
$xeList.updateYSpace();
|
|
1456
|
+
}
|
|
1457
|
+
return $xeList.$nextTick().then(() => {
|
|
1458
|
+
return {
|
|
1459
|
+
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
1460
|
+
rows: newRecords
|
|
1461
|
+
};
|
|
1462
|
+
});
|
|
1463
|
+
},
|
|
1464
|
+
insert(records) {
|
|
1465
|
+
const $xeList = this;
|
|
1466
|
+
return $xeList.handleInsertRowAt(records, null);
|
|
1467
|
+
},
|
|
1468
|
+
insertAt(records, targetRowOrRowKey) {
|
|
1469
|
+
const $xeList = this;
|
|
1470
|
+
return $xeList.handleInsertRowAt(records, targetRowOrRowKey);
|
|
1471
|
+
},
|
|
1472
|
+
insertNextAt(records, targetRowOrRowKey) {
|
|
1473
|
+
const $xeList = this;
|
|
1474
|
+
return $xeList.handleInsertRowAt(records, targetRowOrRowKey, true);
|
|
1475
|
+
},
|
|
1476
|
+
getInsertRecords() {
|
|
1477
|
+
const $xeList = this;
|
|
1478
|
+
const internalData = $xeList.internalData;
|
|
1479
|
+
const { insertRowMaps } = internalData;
|
|
1480
|
+
const insertRecords = [];
|
|
1481
|
+
XEUtils.each(insertRowMaps, (item) => {
|
|
1482
|
+
insertRecords.push(item);
|
|
1483
|
+
});
|
|
1484
|
+
return insertRecords;
|
|
1485
|
+
},
|
|
1486
|
+
isInsertByRow(row) {
|
|
1487
|
+
const $xeList = this;
|
|
1488
|
+
const reactData = $xeList.reactData;
|
|
1489
|
+
const internalData = $xeList.internalData;
|
|
1490
|
+
const rowid = $xeList.getRowId(row);
|
|
1491
|
+
return !!reactData.insertRowFlag && !!internalData.insertRowMaps[rowid];
|
|
1492
|
+
},
|
|
1493
|
+
remove(rows) {
|
|
1494
|
+
const $xeList = this;
|
|
1495
|
+
const reactData = $xeList.reactData;
|
|
1496
|
+
const internalData = $xeList.internalData;
|
|
1497
|
+
const { fullData, insertRowMaps, removeRowMaps } = internalData;
|
|
1498
|
+
const keyField = $xeList.computeKeyField;
|
|
1499
|
+
if (!keyField) {
|
|
1500
|
+
errLog('vxe.error.reqSupportProp', ['insert() | insertAt() | insertNextAt()', 'row-config.keyField']);
|
|
1501
|
+
return Promise.resolve({ row: null, rows: [] });
|
|
1502
|
+
}
|
|
1503
|
+
let delList = [];
|
|
1504
|
+
if (!rows) {
|
|
1505
|
+
rows = fullData;
|
|
1506
|
+
}
|
|
1507
|
+
else if (!XEUtils.isArray(rows)) {
|
|
1508
|
+
rows = [rows];
|
|
1509
|
+
}
|
|
1510
|
+
if (!rows.length) {
|
|
1511
|
+
return Promise.resolve({ row: null, rows: [] });
|
|
1512
|
+
}
|
|
1513
|
+
// 如果是新增,则保存记录
|
|
1514
|
+
rows.forEach((item) => {
|
|
1515
|
+
if (!$xeList.isInsertByRow(item)) {
|
|
1516
|
+
const rowid = $xeList.getRowId(item);
|
|
1517
|
+
removeRowMaps[rowid] = item;
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
// 从数据源中移除
|
|
1521
|
+
if (fullData === rows) {
|
|
1522
|
+
rows = delList = fullData.slice(0);
|
|
1523
|
+
internalData.fullData = [];
|
|
1524
|
+
}
|
|
1525
|
+
else {
|
|
1526
|
+
rows.forEach((item) => {
|
|
1527
|
+
const rowid = $xeList.getRowId(item);
|
|
1528
|
+
const rowIndex = XEUtils.findIndexOf(fullData, item => rowid === $xeList.getRowId(item));
|
|
1529
|
+
if (rowIndex > -1) {
|
|
1530
|
+
const rItems = fullData.splice(rowIndex, 1);
|
|
1531
|
+
delList.push(rItems[0]);
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
// 从新增中移除已删除的数据
|
|
1536
|
+
rows.forEach((item) => {
|
|
1537
|
+
const rowid = $xeList.getRowId(item);
|
|
1538
|
+
if (insertRowMaps[rowid]) {
|
|
1539
|
+
delete insertRowMaps[rowid];
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
reactData.removeRowFlag++;
|
|
1543
|
+
reactData.insertRowFlag++;
|
|
1544
|
+
$xeList.cacheRowMap();
|
|
1545
|
+
$xeList.handleData(true);
|
|
1546
|
+
$xeList.updateAfterDataIndex();
|
|
1547
|
+
$xeList.updateCheckboxStatus();
|
|
1548
|
+
if (reactData.scrollYLoad) {
|
|
1549
|
+
$xeList.updateYSpace();
|
|
1550
|
+
}
|
|
1551
|
+
return $xeList.$nextTick().then(() => {
|
|
1552
|
+
return $xeList.recalculate();
|
|
1553
|
+
}).then(() => {
|
|
1554
|
+
return { row: delList.length ? delList[delList.length - 1] : null, rows: delList };
|
|
1555
|
+
});
|
|
1556
|
+
},
|
|
1557
|
+
getRemoveRecords() {
|
|
1558
|
+
const $xeList = this;
|
|
1559
|
+
const internalData = $xeList.internalData;
|
|
1560
|
+
const { removeRowMaps } = internalData;
|
|
1561
|
+
const removeRecords = [];
|
|
1562
|
+
XEUtils.each(removeRowMaps, (item) => {
|
|
1563
|
+
removeRecords.push(item);
|
|
1564
|
+
});
|
|
1565
|
+
return removeRecords;
|
|
1566
|
+
},
|
|
1567
|
+
isRemoveByRow(row) {
|
|
1568
|
+
const $xeList = this;
|
|
1569
|
+
const reactData = $xeList.reactData;
|
|
1570
|
+
const internalData = $xeList.internalData;
|
|
1571
|
+
const rowid = $xeList.getRowId(row);
|
|
1572
|
+
return !!reactData.removeRowFlag && !!internalData.removeRowMaps[rowid];
|
|
1573
|
+
},
|
|
1574
|
+
handleCrossListRowDragCancelEvent() {
|
|
1575
|
+
const $xeList = this;
|
|
1576
|
+
$xeList.clearRowDragData();
|
|
1577
|
+
$xeList.clearCrossListDragStatus();
|
|
1578
|
+
},
|
|
1579
|
+
/**
|
|
1580
|
+
* 处理跨树拖拽完成
|
|
1581
|
+
*/
|
|
1582
|
+
handleCrossListRowDragFinishEvent(evnt) {
|
|
1583
|
+
const $xeList = this;
|
|
1584
|
+
const reactData = $xeList.reactData;
|
|
1585
|
+
const internalData = $xeList.internalData;
|
|
1586
|
+
const crossListDragRowInfo = getCrossListDragRowInfo($xeList);
|
|
1587
|
+
const { rowList } = reactData;
|
|
1588
|
+
const { rowMaps } = internalData;
|
|
1589
|
+
const dragOpts = $xeList.computeDragOpts;
|
|
1590
|
+
const { animation, isCrossListDrag } = dragOpts;
|
|
1591
|
+
const el = $xeList.$refs.refElem;
|
|
1592
|
+
if (!el) {
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
if (isCrossListDrag && crossListDragRowObj && crossListDragRowInfo) {
|
|
1596
|
+
const { row: dragRow } = crossListDragRowInfo;
|
|
1597
|
+
if (dragRow) {
|
|
1598
|
+
const dragRowid = $xeList.getRowId(dragRow);
|
|
1599
|
+
const dragRowRest = rowMaps[dragRowid];
|
|
1600
|
+
let dragRowHeight = 0;
|
|
1601
|
+
let rsIndex = -1;
|
|
1602
|
+
if (dragRowRest) {
|
|
1603
|
+
if (animation) {
|
|
1604
|
+
const oldItemEl = el.querySelector(`.vxe-list--row[rowid="${dragRowid}"]`);
|
|
1605
|
+
const targetItemEl = oldItemEl;
|
|
1606
|
+
if (targetItemEl) {
|
|
1607
|
+
dragRowHeight = targetItemEl.offsetHeight;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
rsIndex = dragRowRest.$index;
|
|
1611
|
+
}
|
|
1612
|
+
const dragRangeList = rsIndex > -1 && rsIndex < rowList.length - 1 ? rowList.slice(rsIndex + 1) : [];
|
|
1613
|
+
const dragList = [dragRow];
|
|
1614
|
+
$xeList.remove(dragList).then(() => {
|
|
1615
|
+
if (animation && dragRowHeight && dragRangeList.length) {
|
|
1616
|
+
const wrapperEl = el;
|
|
1617
|
+
const dtClss = [];
|
|
1618
|
+
dragRangeList.forEach(item => {
|
|
1619
|
+
const rowid = $xeList.getRowId(item);
|
|
1620
|
+
dtClss.push(`.vxe-list--row[rowid="${rowid}"]`);
|
|
1621
|
+
});
|
|
1622
|
+
const dtTrList = wrapperEl.querySelectorAll(dtClss.join(','));
|
|
1623
|
+
moveRowAnimateToTb(dtTrList, dragRowHeight);
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
$xeList.dispatchEvent('row-remove-dragend', {
|
|
1627
|
+
row: dragRow
|
|
1628
|
+
}, evnt);
|
|
1629
|
+
$xeList.handleRowDragEndClearStatus();
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
},
|
|
1633
|
+
/**
|
|
1634
|
+
* 处理跨树拖至新的空树
|
|
1635
|
+
*/
|
|
1636
|
+
handleCrossListRowDragoverEmptyEvent(evnt) {
|
|
1637
|
+
const $xeList = this;
|
|
1638
|
+
const reactData = $xeList.reactData;
|
|
1639
|
+
const internalData = $xeList.internalData;
|
|
1640
|
+
const { rowList } = reactData;
|
|
1641
|
+
const dragOpts = $xeList.computeDragOpts;
|
|
1642
|
+
const { isCrossListDrag } = dragOpts;
|
|
1643
|
+
if (isCrossListDrag && crossListDragRowObj && !rowList.length) {
|
|
1644
|
+
const { $oldList, $newList } = crossListDragRowObj;
|
|
1645
|
+
if ($oldList) {
|
|
1646
|
+
const oldListReactData = $oldList;
|
|
1647
|
+
if ($oldList.xID !== $xeList.xID) {
|
|
1648
|
+
if ($newList && $newList.xID !== $xeList.xID) {
|
|
1649
|
+
$newList.hideCrossListRowDropClearStatus();
|
|
1650
|
+
}
|
|
1651
|
+
evnt.preventDefault();
|
|
1652
|
+
$oldList.hideCrossListRowDropClearStatus();
|
|
1653
|
+
crossListDragRowObj.$newList = $xeList;
|
|
1654
|
+
internalData.prevDragRow = null;
|
|
1655
|
+
reactData.dragTipText = oldListReactData.dragTipText;
|
|
1656
|
+
$xeList.showDropTip(evnt, evnt.currentTarget, true, '');
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
},
|
|
1661
|
+
/**
|
|
1662
|
+
* 处理跨树拖插入
|
|
1663
|
+
*/
|
|
1664
|
+
handleCrossListRowDragInsertEvent(evnt) {
|
|
1665
|
+
const $xeList = this;
|
|
1666
|
+
const reactData = $xeList.reactData;
|
|
1667
|
+
const internalData = $xeList.internalData;
|
|
1668
|
+
const crossListDragRowInfo = getCrossListDragRowInfo($xeList);
|
|
1669
|
+
const { prevDragRow, prevDragPos } = internalData;
|
|
1670
|
+
const dragOpts = $xeList.computeDragOpts;
|
|
1671
|
+
const { animation, isCrossListDrag, dragEndMethod } = dragOpts;
|
|
1672
|
+
// 跨表拖拽
|
|
1673
|
+
if (isCrossListDrag && crossListDragRowObj && crossListDragRowInfo) {
|
|
1674
|
+
const { row: oldRow } = crossListDragRowInfo;
|
|
1675
|
+
const { $oldList } = crossListDragRowObj;
|
|
1676
|
+
const el = $xeList.$refs.refElem;
|
|
1677
|
+
if (!el) {
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
if ($oldList && oldRow) {
|
|
1681
|
+
const dragRow = oldRow;
|
|
1682
|
+
let dragOffsetIndex = -1;
|
|
1683
|
+
if (prevDragRow) {
|
|
1684
|
+
dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
|
|
1685
|
+
}
|
|
1686
|
+
const dragParams = {
|
|
1687
|
+
oldRow: dragRow,
|
|
1688
|
+
newRow: prevDragRow,
|
|
1689
|
+
dragRow,
|
|
1690
|
+
dragPos: prevDragPos,
|
|
1691
|
+
offsetIndex: dragOffsetIndex
|
|
1692
|
+
};
|
|
1693
|
+
const errRest = {
|
|
1694
|
+
status: false
|
|
1695
|
+
};
|
|
1696
|
+
Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
|
|
1697
|
+
if (!status) {
|
|
1698
|
+
if ($oldList) {
|
|
1699
|
+
if ($oldList.xID !== $xeList.xID) {
|
|
1700
|
+
$oldList.handleCrossListRowDragCancelEvent(evnt);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
$xeList.handleRowDragEndClearStatus();
|
|
1704
|
+
return errRest;
|
|
1705
|
+
}
|
|
1706
|
+
let insertRest = Promise.resolve();
|
|
1707
|
+
const dragList = [dragRow];
|
|
1708
|
+
$oldList.handleCrossListRowDragFinishEvent(evnt);
|
|
1709
|
+
if (prevDragRow) {
|
|
1710
|
+
if (prevDragPos === 'bottom') {
|
|
1711
|
+
insertRest = $xeList.insertNextAt(dragList, prevDragRow);
|
|
1712
|
+
}
|
|
1713
|
+
else {
|
|
1714
|
+
insertRest = $xeList.insertAt(dragList, prevDragRow);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
else {
|
|
1718
|
+
insertRest = $xeList.insert(dragList);
|
|
1719
|
+
}
|
|
1720
|
+
$xeList.dispatchEvent('row-insert-dragend', {
|
|
1721
|
+
oldRow,
|
|
1722
|
+
newRow: prevDragRow,
|
|
1723
|
+
dragRow,
|
|
1724
|
+
dragPos: prevDragPos,
|
|
1725
|
+
offsetIndex: dragOffsetIndex
|
|
1726
|
+
}, evnt);
|
|
1727
|
+
$xeList.clearRowDragData();
|
|
1728
|
+
insertRest.then(() => {
|
|
1729
|
+
const { rowList } = reactData;
|
|
1730
|
+
const { rowMaps } = internalData;
|
|
1731
|
+
const oldRowid = $xeList.getRowId(dragRow);
|
|
1732
|
+
const oldRowRest = rowMaps[oldRowid];
|
|
1733
|
+
let dragRowHeight = 0;
|
|
1734
|
+
let rsIndex = -1;
|
|
1735
|
+
if (oldRowRest) {
|
|
1736
|
+
if (animation) {
|
|
1737
|
+
const oldItemEl = el.querySelector(`.vxe-list--row[rowid="${oldRowid}"]`);
|
|
1738
|
+
const targetItemEl = oldItemEl;
|
|
1739
|
+
if (targetItemEl) {
|
|
1740
|
+
dragRowHeight = targetItemEl.offsetHeight;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
rsIndex = oldRowRest.$index;
|
|
1744
|
+
}
|
|
1745
|
+
const dragRangeList = rsIndex > -1 ? rowList.slice(rsIndex) : [];
|
|
1746
|
+
if (animation && dragRowHeight && dragRangeList.length) {
|
|
1747
|
+
const wrapperEl = el;
|
|
1748
|
+
const dtClss = [];
|
|
1749
|
+
dragRangeList.forEach(item => {
|
|
1750
|
+
const rowid = $xeList.getRowId(item);
|
|
1751
|
+
dtClss.push(`.vxe-list--row[rowid="${rowid}"]`);
|
|
1752
|
+
});
|
|
1753
|
+
const dtTrList = wrapperEl.querySelectorAll(dtClss.join(','));
|
|
1754
|
+
moveRowAnimateToTb(dtTrList, -dragRowHeight);
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
},
|
|
1761
|
+
hideCrossListRowDropClearStatus() {
|
|
1762
|
+
const $xeList = this;
|
|
1763
|
+
$xeList.hideDropTip();
|
|
1764
|
+
},
|
|
1765
|
+
handleContextmenuEvent(evnt, row) {
|
|
1766
|
+
const $xeList = this;
|
|
1767
|
+
const props = $xeList;
|
|
1768
|
+
const reactData = $xeList.reactData;
|
|
1769
|
+
const internalData = $xeList.internalData;
|
|
1770
|
+
const { menuConfig } = props;
|
|
1771
|
+
const menuOpts = $xeList.computeMenuOpts;
|
|
1772
|
+
const rowOpts = $xeList.computeRowOpts;
|
|
1773
|
+
const { isCurrent } = rowOpts;
|
|
1774
|
+
if (menuConfig ? isEnableConf(menuOpts) : menuOpts.enabled) {
|
|
1775
|
+
const { options, visibleMethod } = menuOpts;
|
|
1776
|
+
if (!visibleMethod || visibleMethod({ $list: $xeList, options, row })) {
|
|
1777
|
+
if (isCurrent) {
|
|
1778
|
+
$xeList.changeCurrentEvent(evnt, row);
|
|
1779
|
+
}
|
|
1780
|
+
else if (internalData.currentRow) {
|
|
1781
|
+
internalData.currentRow = null;
|
|
1782
|
+
reactData.currRowFlag++;
|
|
1783
|
+
}
|
|
1784
|
+
if (VxeUI.contextMenu) {
|
|
1785
|
+
VxeUI.contextMenu.openByEvent(evnt, {
|
|
1786
|
+
options,
|
|
1787
|
+
events: {
|
|
1788
|
+
optionClick(eventParams) {
|
|
1789
|
+
const { option } = eventParams;
|
|
1790
|
+
const gMenuOpts = menus.get(option.code);
|
|
1791
|
+
const tmMethod = gMenuOpts ? gMenuOpts.listMenuMethod : null;
|
|
1792
|
+
const params = {
|
|
1793
|
+
menu: option,
|
|
1794
|
+
row,
|
|
1795
|
+
$event: evnt,
|
|
1796
|
+
$list: $xeList
|
|
1797
|
+
};
|
|
1798
|
+
if (tmMethod) {
|
|
1799
|
+
tmMethod(params, evnt);
|
|
1800
|
+
}
|
|
1801
|
+
$xeList.dispatchEvent('menu-click', params, eventParams.$event);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
$xeList.dispatchEvent('row-menu', { row }, evnt);
|
|
1809
|
+
},
|
|
1281
1810
|
//
|
|
1282
1811
|
// Render
|
|
1283
1812
|
//
|
|
@@ -1396,6 +1925,7 @@ export default {
|
|
|
1396
1925
|
const { selectRadioRow, currRowFlag, updateCheckboxFlag } = reactData;
|
|
1397
1926
|
const { selectCheckboxMaps, currentRow } = internalData;
|
|
1398
1927
|
const contentSlot = slots.content;
|
|
1928
|
+
const extraSlot = slots.extra;
|
|
1399
1929
|
const dragOpts = $xeList.computeDragOpts;
|
|
1400
1930
|
const { trigger, icon, disabledMethod, visibleMethod } = dragOpts;
|
|
1401
1931
|
const rowOpts = $xeList.computeRowOpts;
|
|
@@ -1452,6 +1982,12 @@ export default {
|
|
|
1452
1982
|
key: 'ct5',
|
|
1453
1983
|
class: 'vxe-list--row-content'
|
|
1454
1984
|
}, contentSlot ? contentSlot(rowParams) : (contentField ? getText(row[contentField]) : '')));
|
|
1985
|
+
if (extraSlot) {
|
|
1986
|
+
ctVNs.push(h('div', {
|
|
1987
|
+
key: 'ct7',
|
|
1988
|
+
class: 'vxe-list--row-extra'
|
|
1989
|
+
}, extraSlot(rowParams)));
|
|
1990
|
+
}
|
|
1455
1991
|
const rowOns = {
|
|
1456
1992
|
mousedown(evnt) {
|
|
1457
1993
|
$xeList.handleRowMousedownEvent(evnt, row);
|
|
@@ -1462,6 +1998,9 @@ export default {
|
|
|
1462
1998
|
},
|
|
1463
1999
|
dblclick(evnt) {
|
|
1464
2000
|
$xeList.handleRowDblclickEvent(evnt, row);
|
|
2001
|
+
},
|
|
2002
|
+
contextmenu(evnt) {
|
|
2003
|
+
$xeList.handleContextmenuEvent(evnt, row);
|
|
1465
2004
|
}
|
|
1466
2005
|
};
|
|
1467
2006
|
// 拖拽行事件
|
|
@@ -1502,16 +2041,21 @@ export default {
|
|
|
1502
2041
|
const radioOpts = $xeList.computeRadioOpts;
|
|
1503
2042
|
const checkboxOpts = $xeList.computeCheckboxOpts;
|
|
1504
2043
|
const dragOpts = $xeList.computeDragOpts;
|
|
1505
|
-
const { trigger } = dragOpts;
|
|
2044
|
+
const { trigger, isCrossListDrag } = dragOpts;
|
|
1506
2045
|
const rowOpts = $xeList.computeRowOpts;
|
|
1507
2046
|
const { isHover, padding } = rowOpts;
|
|
1508
2047
|
const showDefChekboxHead = showCheckbox && checkboxOpts.showHeader !== false;
|
|
2048
|
+
const leOns = {};
|
|
2049
|
+
if (isCrossListDrag && !rowList.length) {
|
|
2050
|
+
leOns.dragover = $xeList.handleCrossListRowDragoverEmptyEvent;
|
|
2051
|
+
}
|
|
1509
2052
|
return h('div', {
|
|
1510
2053
|
ref: 'refElem',
|
|
1511
2054
|
class: ['vxe-list', className ? (XEUtils.isFunction(className) ? className({ $list: $xeList }) : className) : '', {
|
|
1512
2055
|
[`size--${vSize}`]: vSize,
|
|
1513
2056
|
'is--loading': loading
|
|
1514
2057
|
}],
|
|
2058
|
+
on: leOns,
|
|
1515
2059
|
style: wrapperStyles
|
|
1516
2060
|
}, [
|
|
1517
2061
|
headerSlot || showDefChekboxHead
|
|
@@ -1643,11 +2187,14 @@ export default {
|
|
|
1643
2187
|
const $xeList = this;
|
|
1644
2188
|
const props = $xeList;
|
|
1645
2189
|
const internalData = $xeList.internalData;
|
|
1646
|
-
const { showRadio, showCheckbox } = props;
|
|
2190
|
+
const { showSeq, showRadio, showCheckbox } = props;
|
|
1647
2191
|
const rowOpts = $xeList.computeRowOpts;
|
|
1648
2192
|
const { useKey, keyField } = rowOpts;
|
|
1649
2193
|
const isDrag = $xeList.computeIsDrag;
|
|
1650
2194
|
if (!keyField) {
|
|
2195
|
+
if (showSeq) {
|
|
2196
|
+
errLog('vxe.error.reqSupportProp', ['show-seq', 'row-config.keyField']);
|
|
2197
|
+
}
|
|
1651
2198
|
if (showRadio) {
|
|
1652
2199
|
errLog('vxe.error.reqSupportProp', ['show-radio', 'row-config.keyField']);
|
|
1653
2200
|
}
|