vxe-table 3.15.29 → 3.15.30
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/grid/src/grid.js +39 -42
- package/es/style.css +1 -1
- package/es/table/module/edit/mixin.js +11 -27
- package/es/table/module/export/mixin.js +65 -139
- package/es/table/module/menu/mixin.js +2 -6
- package/es/table/module/validator/mixin.js +99 -41
- package/es/table/src/methods.js +12 -36
- package/es/table/src/table.js +6 -8
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/grid/src/grid.js +24 -26
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +248 -556
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/edit/mixin.js +11 -27
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/mixin.js +78 -168
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +2 -6
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +97 -40
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/methods.js +12 -36
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +8 -10
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +1 -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/package.json +1 -1
- package/packages/grid/src/grid.ts +39 -41
- package/packages/table/module/edit/mixin.ts +11 -27
- package/packages/table/module/export/mixin.ts +96 -158
- package/packages/table/module/menu/mixin.ts +2 -6
- package/packages/table/module/validator/mixin.ts +101 -40
- package/packages/table/src/methods.ts +12 -36
- package/packages/table/src/table.ts +6 -8
- /package/es/{iconfont.1747286367921.ttf → iconfont.1747357311626.ttf} +0 -0
- /package/es/{iconfont.1747286367921.woff → iconfont.1747357311626.woff} +0 -0
- /package/es/{iconfont.1747286367921.woff2 → iconfont.1747357311626.woff2} +0 -0
- /package/lib/{iconfont.1747286367921.ttf → iconfont.1747357311626.ttf} +0 -0
- /package/lib/{iconfont.1747286367921.woff → iconfont.1747357311626.woff} +0 -0
- /package/lib/{iconfont.1747286367921.woff2 → iconfont.1747357311626.woff2} +0 -0
|
@@ -75,10 +75,8 @@ function insertTreeRow($xeTable, newRecords, isAppend) {
|
|
|
75
75
|
fullAllDataRowIdData[rowid] = rest;
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
warnLog('vxe.error.unableInsert');
|
|
81
|
-
}
|
|
78
|
+
if (parentRowId) {
|
|
79
|
+
warnLog('vxe.error.unableInsert');
|
|
82
80
|
}
|
|
83
81
|
afterFullData[funcName](item);
|
|
84
82
|
tableFullTreeData[funcName](item);
|
|
@@ -159,11 +157,9 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
|
|
|
159
157
|
const parentLevel = parentRest ? parentRest.level : 0;
|
|
160
158
|
newRecords.forEach((item, i) => {
|
|
161
159
|
const rowid = getRowid($xeTable, item);
|
|
162
|
-
if (
|
|
163
|
-
if (item[treeOpts.parentField]) {
|
|
164
|
-
|
|
165
|
-
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`]);
|
|
166
|
-
}
|
|
160
|
+
if (item[treeOpts.parentField]) {
|
|
161
|
+
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
162
|
+
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`]);
|
|
167
163
|
}
|
|
168
164
|
}
|
|
169
165
|
if (parentRow) {
|
|
@@ -192,9 +188,7 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
|
|
|
192
188
|
}
|
|
193
189
|
}
|
|
194
190
|
else {
|
|
195
|
-
|
|
196
|
-
warnLog('vxe.error.unableInsert');
|
|
197
|
-
}
|
|
191
|
+
warnLog('vxe.error.unableInsert');
|
|
198
192
|
insertTreeRow($xeTable, newRecords, true);
|
|
199
193
|
}
|
|
200
194
|
}
|
|
@@ -733,9 +727,7 @@ export default {
|
|
|
733
727
|
syncActivedCell($xeTable);
|
|
734
728
|
},
|
|
735
729
|
_clearActived(row) {
|
|
736
|
-
|
|
737
|
-
warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit']);
|
|
738
|
-
}
|
|
730
|
+
warnLog('vxe.error.delFunc', ['clearActived', 'clearEdit']);
|
|
739
731
|
// 即将废弃
|
|
740
732
|
return this.clearEdit(row);
|
|
741
733
|
},
|
|
@@ -755,9 +747,7 @@ export default {
|
|
|
755
747
|
},
|
|
756
748
|
_getActiveRecord() {
|
|
757
749
|
const $xeTable = this;
|
|
758
|
-
|
|
759
|
-
warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord']);
|
|
760
|
-
}
|
|
750
|
+
warnLog('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord']);
|
|
761
751
|
// 即将废弃
|
|
762
752
|
return $xeTable.getEditRecord();
|
|
763
753
|
},
|
|
@@ -776,9 +766,7 @@ export default {
|
|
|
776
766
|
},
|
|
777
767
|
_isActiveByRow(row) {
|
|
778
768
|
const $xeTable = this;
|
|
779
|
-
|
|
780
|
-
warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow']);
|
|
781
|
-
}
|
|
769
|
+
warnLog('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow']);
|
|
782
770
|
// 即将废弃
|
|
783
771
|
return $xeTable.isEditByRow(row);
|
|
784
772
|
},
|
|
@@ -856,9 +844,7 @@ export default {
|
|
|
856
844
|
},
|
|
857
845
|
_setActiveRow(row) {
|
|
858
846
|
const $xeTable = this;
|
|
859
|
-
|
|
860
|
-
warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow']);
|
|
861
|
-
}
|
|
847
|
+
warnLog('vxe.error.delFunc', ['setActiveRow', 'setEditRow']);
|
|
862
848
|
// 即将废弃
|
|
863
849
|
return $xeTable.setEditRow(row);
|
|
864
850
|
},
|
|
@@ -878,9 +864,7 @@ export default {
|
|
|
878
864
|
return handleEditCell($xeTable, row, column, isPos);
|
|
879
865
|
},
|
|
880
866
|
_setActiveCell(row, fieldOrColumn) {
|
|
881
|
-
|
|
882
|
-
warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell']);
|
|
883
|
-
}
|
|
867
|
+
warnLog('vxe.error.delFunc', ['setActiveCell', 'setEditCell']);
|
|
884
868
|
// 即将废弃
|
|
885
869
|
return this.setEditCell(row, fieldOrColumn);
|
|
886
870
|
},
|
|
@@ -7,9 +7,6 @@ import { createHtmlPage, getExportBlobByContent } from './util';
|
|
|
7
7
|
import { warnLog, errLog } from '../../../ui/src/log';
|
|
8
8
|
const { getI18n, renderer } = VxeUI;
|
|
9
9
|
let htmlCellElem;
|
|
10
|
-
// 导入
|
|
11
|
-
let fileForm;
|
|
12
|
-
let fileInput;
|
|
13
10
|
const csvBOM = '\ufeff';
|
|
14
11
|
const enterSymbol = '\r\n';
|
|
15
12
|
function hasTreeChildren($xeTable, row) {
|
|
@@ -34,7 +31,7 @@ function getSeq($xeTable, cellValue, row, $rowIndex, column, $columnIndex) {
|
|
|
34
31
|
return cellValue;
|
|
35
32
|
}
|
|
36
33
|
function defaultFilterExportColumn(column) {
|
|
37
|
-
return column.field || ['seq', 'checkbox', 'radio'].indexOf(column.type) > -1;
|
|
34
|
+
return !!column.field || ['seq', 'checkbox', 'radio'].indexOf(column.type || '') > -1;
|
|
38
35
|
}
|
|
39
36
|
function toTableBorder(border) {
|
|
40
37
|
if (border === true) {
|
|
@@ -532,53 +529,21 @@ function getContent($xeTable, opts, columns, datas) {
|
|
|
532
529
|
}
|
|
533
530
|
return '';
|
|
534
531
|
}
|
|
535
|
-
/**
|
|
536
|
-
* 保存文件到本地
|
|
537
|
-
* @param {*} options 参数
|
|
538
|
-
*/
|
|
539
|
-
export function saveLocalFile(options) {
|
|
540
|
-
const { filename, type, content } = options;
|
|
541
|
-
const name = `${filename}.${type}`;
|
|
542
|
-
if (window.Blob) {
|
|
543
|
-
const blob = content instanceof Blob ? content : getExportBlobByContent(XEUtils.toValueString(content), options);
|
|
544
|
-
if (navigator.msSaveBlob) {
|
|
545
|
-
navigator.msSaveBlob(blob, name);
|
|
546
|
-
}
|
|
547
|
-
else {
|
|
548
|
-
const url = URL.createObjectURL(blob);
|
|
549
|
-
const linkElem = document.createElement('a');
|
|
550
|
-
linkElem.target = '_blank';
|
|
551
|
-
linkElem.download = name;
|
|
552
|
-
linkElem.href = url;
|
|
553
|
-
document.body.appendChild(linkElem);
|
|
554
|
-
linkElem.click();
|
|
555
|
-
document.body.removeChild(linkElem);
|
|
556
|
-
requestAnimationFrame(() => {
|
|
557
|
-
if (linkElem.parentNode) {
|
|
558
|
-
linkElem.parentNode.removeChild(linkElem);
|
|
559
|
-
}
|
|
560
|
-
URL.revokeObjectURL(url);
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
return Promise.resolve();
|
|
564
|
-
}
|
|
565
|
-
return Promise.reject(new Error(getI18n('vxe.error.notExp')));
|
|
566
|
-
}
|
|
567
532
|
function downloadFile($xeTable, opts, content) {
|
|
568
533
|
const { filename, type, download } = opts;
|
|
569
534
|
if (!download) {
|
|
570
535
|
const blob = getExportBlobByContent(content, opts);
|
|
571
536
|
return Promise.resolve({ type, content, blob });
|
|
572
537
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
538
|
+
if (VxeUI.saveFile) {
|
|
539
|
+
VxeUI.saveFile({ filename, type, content }).then(() => {
|
|
540
|
+
if (opts.message !== false) {
|
|
541
|
+
if (VxeUI.modal) {
|
|
542
|
+
VxeUI.modal.message({ content: getI18n('vxe.table.expSuccess'), status: 'success' });
|
|
543
|
+
}
|
|
578
544
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
});
|
|
545
|
+
});
|
|
546
|
+
}
|
|
582
547
|
}
|
|
583
548
|
function clearColumnConvert(columns) {
|
|
584
549
|
XEUtils.eachTree(columns, column => {
|
|
@@ -908,58 +873,6 @@ function handleCloseExport() {
|
|
|
908
873
|
}
|
|
909
874
|
return Promise.resolve();
|
|
910
875
|
}
|
|
911
|
-
/**
|
|
912
|
-
* 读取本地文件
|
|
913
|
-
* @param {*} options 参数
|
|
914
|
-
*/
|
|
915
|
-
export function readLocalFile(options = {}) {
|
|
916
|
-
if (!fileForm) {
|
|
917
|
-
fileForm = document.createElement('form');
|
|
918
|
-
fileInput = document.createElement('input');
|
|
919
|
-
fileForm.className = 'vxe-table--file-form';
|
|
920
|
-
fileInput.name = 'file';
|
|
921
|
-
fileInput.type = 'file';
|
|
922
|
-
fileForm.appendChild(fileInput);
|
|
923
|
-
document.body.appendChild(fileForm);
|
|
924
|
-
}
|
|
925
|
-
return new Promise((resolve, reject) => {
|
|
926
|
-
const types = options.types || [];
|
|
927
|
-
const isAllType = !types.length || types.some((type) => type === '*');
|
|
928
|
-
fileInput.multiple = !!options.multiple;
|
|
929
|
-
fileInput.accept = isAllType ? '' : `.${types.join(', .')}`;
|
|
930
|
-
fileInput.onchange = (evnt) => {
|
|
931
|
-
const { files } = evnt.target;
|
|
932
|
-
const file = files[0];
|
|
933
|
-
let errType;
|
|
934
|
-
// 校验类型
|
|
935
|
-
if (!isAllType) {
|
|
936
|
-
for (let fIndex = 0; fIndex < files.length; fIndex++) {
|
|
937
|
-
const { type } = parseFile(files[fIndex]);
|
|
938
|
-
if (!XEUtils.includes(types, type)) {
|
|
939
|
-
errType = type;
|
|
940
|
-
break;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
if (!errType) {
|
|
945
|
-
resolve({ status: true, files, file });
|
|
946
|
-
}
|
|
947
|
-
else {
|
|
948
|
-
if (options.message !== false) {
|
|
949
|
-
// 检测弹窗模块
|
|
950
|
-
if (!VxeUI.modal) {
|
|
951
|
-
errLog('vxe.error.reqModule', ['Modal']);
|
|
952
|
-
}
|
|
953
|
-
VxeUI.modal.message({ content: getI18n('vxe.error.notType', [errType]), status: 'error' });
|
|
954
|
-
}
|
|
955
|
-
const params = { status: false, files, file };
|
|
956
|
-
reject(params);
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
fileForm.reset();
|
|
960
|
-
fileInput.click();
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
876
|
function handleFilterColumns(exportOpts, column, columns) {
|
|
964
877
|
return columns.some((item) => {
|
|
965
878
|
if (isColumnInfo(item)) {
|
|
@@ -1000,7 +913,7 @@ function handleFilterFields(exportOpts, column, includeFields, excludeFields) {
|
|
|
1000
913
|
}
|
|
1001
914
|
return false;
|
|
1002
915
|
}
|
|
1003
|
-
return exportOpts.original ? column.field : defaultFilterExportColumn(column);
|
|
916
|
+
return exportOpts.original ? !!column.field : defaultFilterExportColumn(column);
|
|
1004
917
|
}
|
|
1005
918
|
function handleExportAndPrint($xeTable, options, isPrint) {
|
|
1006
919
|
const props = $xeTable;
|
|
@@ -1054,7 +967,7 @@ function handleExportAndPrint($xeTable, options, isPrint) {
|
|
|
1054
967
|
});
|
|
1055
968
|
// 默认选中
|
|
1056
969
|
XEUtils.eachTree(exportColumns, (column, index, items, path, parent) => {
|
|
1057
|
-
const isColGroup = column.children && column.children.length;
|
|
970
|
+
const isColGroup = column.children && column.children.length > 0;
|
|
1058
971
|
let isChecked = false;
|
|
1059
972
|
if (columns && columns.length) {
|
|
1060
973
|
isChecked = handleFilterColumns(defOpts, column, columns);
|
|
@@ -1188,8 +1101,8 @@ export default {
|
|
|
1188
1101
|
const internalData = $xeTable;
|
|
1189
1102
|
const $xeGrid = $xeTable.$xeGrid;
|
|
1190
1103
|
const { treeConfig, showHeader, showFooter } = props;
|
|
1191
|
-
const {
|
|
1192
|
-
const { tableFullColumn, afterFullData, mergeBodyList,
|
|
1104
|
+
const { isGroup } = reactData;
|
|
1105
|
+
const { tableFullColumn, afterFullData, collectColumn, mergeBodyList, mergeFooterList } = internalData;
|
|
1193
1106
|
const exportOpts = $xeTable.computeExportOpts;
|
|
1194
1107
|
const treeOpts = $xeTable.computeTreeOpts;
|
|
1195
1108
|
const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {};
|
|
@@ -1228,7 +1141,7 @@ export default {
|
|
|
1228
1141
|
const customCols = columns && columns.length
|
|
1229
1142
|
? columns
|
|
1230
1143
|
: XEUtils.searchTree(collectColumn, column => {
|
|
1231
|
-
const isColGroup = column.children && column.children.length;
|
|
1144
|
+
const isColGroup = column.children && column.children.length > 0;
|
|
1232
1145
|
let isChecked = false;
|
|
1233
1146
|
if (columns && columns.length) {
|
|
1234
1147
|
isChecked = handleFilterColumns(opts, column, columns);
|
|
@@ -1244,7 +1157,7 @@ export default {
|
|
|
1244
1157
|
const handleOptions = Object.assign({}, opts, { filename: '', sheetName: '' });
|
|
1245
1158
|
// 如果设置源数据,则默认导出设置了字段的列
|
|
1246
1159
|
if (!customCols && !columnFilterMethod) {
|
|
1247
|
-
|
|
1160
|
+
columnFilterMethod = ({ column }) => {
|
|
1248
1161
|
if (excludeFields) {
|
|
1249
1162
|
if (XEUtils.includes(excludeFields, column.field)) {
|
|
1250
1163
|
return false;
|
|
@@ -1256,8 +1169,9 @@ export default {
|
|
|
1256
1169
|
}
|
|
1257
1170
|
return false;
|
|
1258
1171
|
}
|
|
1259
|
-
return original ? column.field : defaultFilterExportColumn(column);
|
|
1172
|
+
return original ? !!column.field : defaultFilterExportColumn(column);
|
|
1260
1173
|
};
|
|
1174
|
+
handleOptions.columnFilterMethod = columnFilterMethod;
|
|
1261
1175
|
}
|
|
1262
1176
|
if (customCols) {
|
|
1263
1177
|
handleOptions._isCustomColumn = true;
|
|
@@ -1292,14 +1206,14 @@ export default {
|
|
|
1292
1206
|
}, {
|
|
1293
1207
|
children: 'childNodes',
|
|
1294
1208
|
mapChildren: '_children'
|
|
1295
|
-
}), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column: column, $columnIndex: index })), {
|
|
1209
|
+
}), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, column: column, $columnIndex: index })), {
|
|
1296
1210
|
children: '_children',
|
|
1297
1211
|
mapChildren: 'childNodes',
|
|
1298
1212
|
original: true
|
|
1299
1213
|
});
|
|
1300
1214
|
}
|
|
1301
1215
|
else {
|
|
1302
|
-
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1216
|
+
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1303
1217
|
}
|
|
1304
1218
|
// 获取所有列
|
|
1305
1219
|
const cols = [];
|
|
@@ -1345,10 +1259,8 @@ export default {
|
|
|
1345
1259
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1346
1260
|
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
|
|
1347
1261
|
errLog('vxe.error.notType', [type]);
|
|
1348
|
-
if (
|
|
1349
|
-
|
|
1350
|
-
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx']);
|
|
1351
|
-
}
|
|
1262
|
+
if (['xlsx', 'pdf'].includes(type)) {
|
|
1263
|
+
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx']);
|
|
1352
1264
|
}
|
|
1353
1265
|
const params = { status: false };
|
|
1354
1266
|
return Promise.reject(params);
|
|
@@ -1369,10 +1281,8 @@ export default {
|
|
|
1369
1281
|
}
|
|
1370
1282
|
}
|
|
1371
1283
|
else if (mode === 'all') {
|
|
1372
|
-
if (
|
|
1373
|
-
|
|
1374
|
-
warnLog('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1375
|
-
}
|
|
1284
|
+
if (!$xeGrid) {
|
|
1285
|
+
errLog('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1376
1286
|
}
|
|
1377
1287
|
if ($xeGrid && !handleOptions.remote) {
|
|
1378
1288
|
const gridReactData = $xeGrid;
|
|
@@ -1383,10 +1293,8 @@ export default {
|
|
|
1383
1293
|
const ajaxMethods = ajax.queryAll;
|
|
1384
1294
|
const queryAllSuccessMethods = ajax.queryAllSuccess;
|
|
1385
1295
|
const queryAllErrorMethods = ajax.queryAllError;
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1388
|
-
warnLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll']);
|
|
1389
|
-
}
|
|
1296
|
+
if (!ajaxMethods) {
|
|
1297
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll']);
|
|
1390
1298
|
}
|
|
1391
1299
|
if (ajaxMethods) {
|
|
1392
1300
|
const params = {
|
|
@@ -1425,14 +1333,16 @@ export default {
|
|
|
1425
1333
|
return handleExport($xeTable, handleOptions);
|
|
1426
1334
|
},
|
|
1427
1335
|
_importByFile(file, options) {
|
|
1336
|
+
const $xeTable = this;
|
|
1428
1337
|
const opts = Object.assign({}, options);
|
|
1429
1338
|
const { beforeImportMethod } = opts;
|
|
1430
1339
|
if (beforeImportMethod) {
|
|
1431
|
-
beforeImportMethod({ options: opts, $table:
|
|
1340
|
+
beforeImportMethod({ options: opts, $table: $xeTable });
|
|
1432
1341
|
}
|
|
1433
|
-
return handleFileImport(
|
|
1342
|
+
return handleFileImport($xeTable, file, opts);
|
|
1434
1343
|
},
|
|
1435
1344
|
_importData(options) {
|
|
1345
|
+
const $xeTable = this;
|
|
1436
1346
|
const { importOpts } = this;
|
|
1437
1347
|
const opts = Object.assign({
|
|
1438
1348
|
types: XEUtils.keys(importOpts._typeMaps)
|
|
@@ -1443,21 +1353,21 @@ export default {
|
|
|
1443
1353
|
if (beforeImportMethod) {
|
|
1444
1354
|
beforeImportMethod({ options: opts, $table: this });
|
|
1445
1355
|
}
|
|
1446
|
-
return
|
|
1356
|
+
return VxeUI.readFile(opts).catch(e => {
|
|
1447
1357
|
if (afterImportMethod) {
|
|
1448
|
-
afterImportMethod({ status: false, options: opts, $table:
|
|
1358
|
+
afterImportMethod({ status: false, options: opts, $table: $xeTable });
|
|
1449
1359
|
}
|
|
1450
1360
|
return Promise.reject(e);
|
|
1451
1361
|
}).then((params) => {
|
|
1452
1362
|
const { file } = params;
|
|
1453
|
-
return handleFileImport(
|
|
1363
|
+
return handleFileImport($xeTable, file, opts);
|
|
1454
1364
|
});
|
|
1455
1365
|
},
|
|
1456
1366
|
_saveFile(options) {
|
|
1457
|
-
return
|
|
1367
|
+
return VxeUI.saveFile(options);
|
|
1458
1368
|
},
|
|
1459
1369
|
_readFile(options) {
|
|
1460
|
-
return
|
|
1370
|
+
return VxeUI.readFile(options);
|
|
1461
1371
|
},
|
|
1462
1372
|
_print(options) {
|
|
1463
1373
|
const $xeTable = this;
|
|
@@ -1560,23 +1470,28 @@ export default {
|
|
|
1560
1470
|
return Promise.resolve();
|
|
1561
1471
|
},
|
|
1562
1472
|
_openImport(options) {
|
|
1563
|
-
const
|
|
1473
|
+
const $xeTable = this;
|
|
1474
|
+
const props = $xeTable;
|
|
1475
|
+
const reactData = $xeTable;
|
|
1476
|
+
const { treeConfig, importConfig } = props;
|
|
1477
|
+
const { initStore, importStore, importParams } = reactData;
|
|
1478
|
+
const importOpts = $xeTable.computeImportOpts;
|
|
1564
1479
|
const defOpts = Object.assign({
|
|
1565
1480
|
mode: 'insertTop',
|
|
1566
1481
|
message: true,
|
|
1567
1482
|
types: XEUtils.keys(importOpts._typeMaps),
|
|
1568
1483
|
modes: ['insertTop', 'covering']
|
|
1569
|
-
},
|
|
1484
|
+
}, importOpts, options);
|
|
1570
1485
|
const types = defOpts.types || [];
|
|
1571
1486
|
const modes = defOpts.modes || [];
|
|
1572
|
-
const isTree = !!
|
|
1487
|
+
const isTree = !!treeConfig;
|
|
1573
1488
|
if (isTree) {
|
|
1574
1489
|
if (defOpts.message) {
|
|
1575
1490
|
VxeUI.modal.message({ content: getI18n('vxe.error.treeNotImp'), status: 'error' });
|
|
1576
1491
|
}
|
|
1577
1492
|
return;
|
|
1578
1493
|
}
|
|
1579
|
-
if (!
|
|
1494
|
+
if (!importConfig) {
|
|
1580
1495
|
errLog('vxe.error.reqProp', ['import-config']);
|
|
1581
1496
|
}
|
|
1582
1497
|
// 处理类型
|
|
@@ -1598,7 +1513,7 @@ export default {
|
|
|
1598
1513
|
label: getI18n(`vxe.import.modes.${item}`)
|
|
1599
1514
|
};
|
|
1600
1515
|
});
|
|
1601
|
-
Object.assign(
|
|
1516
|
+
Object.assign(importStore, {
|
|
1602
1517
|
file: null,
|
|
1603
1518
|
type: '',
|
|
1604
1519
|
filename: '',
|
|
@@ -1606,27 +1521,38 @@ export default {
|
|
|
1606
1521
|
typeList,
|
|
1607
1522
|
visible: true
|
|
1608
1523
|
});
|
|
1609
|
-
Object.assign(
|
|
1610
|
-
if (!modeList.some(
|
|
1611
|
-
|
|
1524
|
+
Object.assign(importParams, defOpts);
|
|
1525
|
+
if (!modeList.some(item => item.value === importParams.mode)) {
|
|
1526
|
+
importParams.mode = modeList[0].value;
|
|
1612
1527
|
}
|
|
1613
|
-
|
|
1528
|
+
initStore.import = true;
|
|
1614
1529
|
},
|
|
1615
1530
|
_closeExport: handleCloseExport,
|
|
1616
1531
|
_openExport(options) {
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1532
|
+
const $xeTable = this;
|
|
1533
|
+
const props = $xeTable;
|
|
1534
|
+
const exportOpts = $xeTable.computeExportOpts;
|
|
1535
|
+
const defOpts = Object.assign({
|
|
1536
|
+
message: true,
|
|
1537
|
+
types: XEUtils.keys(exportOpts._typeMaps)
|
|
1538
|
+
}, exportOpts, options);
|
|
1539
|
+
if (!props.exportConfig) {
|
|
1619
1540
|
errLog('vxe.error.reqProp', ['export-config']);
|
|
1620
1541
|
}
|
|
1621
|
-
return handleExportAndPrint(
|
|
1542
|
+
return handleExportAndPrint($xeTable, defOpts);
|
|
1622
1543
|
},
|
|
1623
1544
|
_closePrint: handleCloseExport,
|
|
1624
1545
|
_openPrint(options) {
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1546
|
+
const $xeTable = this;
|
|
1547
|
+
const props = $xeTable;
|
|
1548
|
+
const printOpts = $xeTable.computePrintOpts;
|
|
1549
|
+
const defOpts = Object.assign({
|
|
1550
|
+
message: true
|
|
1551
|
+
}, printOpts, options);
|
|
1552
|
+
if (!props.printConfig) {
|
|
1627
1553
|
errLog('vxe.error.reqProp', ['print-config']);
|
|
1628
1554
|
}
|
|
1629
|
-
return handleExportAndPrint(
|
|
1555
|
+
return handleExportAndPrint($xeTable, defOpts, true);
|
|
1630
1556
|
}
|
|
1631
1557
|
}
|
|
1632
1558
|
};
|
|
@@ -115,9 +115,7 @@ export default {
|
|
|
115
115
|
this.handleOpenMenuEvent(evnt, layout, params);
|
|
116
116
|
// 在 v4 中废弃事件 cell-context-menu、header-cell-context-menu、footer-cell-context-menu
|
|
117
117
|
if (this.$listeners[`${typePrefix}cell-context-menu`]) {
|
|
118
|
-
|
|
119
|
-
warnLog('vxe.error.delEvent', [`${typePrefix}cell-context-menu`, `${typePrefix}cell-menu`]);
|
|
120
|
-
}
|
|
118
|
+
warnLog('vxe.error.delEvent', [`${typePrefix}cell-context-menu`, `${typePrefix}cell-menu`]);
|
|
121
119
|
this.emitEvent(`${typePrefix}cell-context-menu`, params, evnt);
|
|
122
120
|
}
|
|
123
121
|
else {
|
|
@@ -274,9 +272,7 @@ export default {
|
|
|
274
272
|
}
|
|
275
273
|
// 在 v4 中废弃事件 context-menu-click
|
|
276
274
|
if (this.$listeners['context-menu-click']) {
|
|
277
|
-
|
|
278
|
-
warnLog('vxe.error.delEvent', ['context-menu-click', 'menu-click']);
|
|
279
|
-
}
|
|
275
|
+
warnLog('vxe.error.delEvent', ['context-menu-click', 'menu-click']);
|
|
280
276
|
this.emitEvent('context-menu-click', params, evnt);
|
|
281
277
|
}
|
|
282
278
|
else {
|