vxe-table 3.15.29 → 3.15.31
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 +75 -143
- 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 +271 -572
- 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 +101 -184
- 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 +105 -162
- 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.1747621179042.ttf} +0 -0
- /package/es/{iconfont.1747286367921.woff → iconfont.1747621179042.woff} +0 -0
- /package/es/{iconfont.1747286367921.woff2 → iconfont.1747621179042.woff2} +0 -0
- /package/lib/{iconfont.1747286367921.ttf → iconfont.1747621179042.ttf} +0 -0
- /package/lib/{iconfont.1747286367921.woff → iconfont.1747621179042.woff} +0 -0
- /package/lib/{iconfont.1747286367921.woff2 → iconfont.1747621179042.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)
|
|
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 : {};
|
|
@@ -1225,10 +1138,15 @@ export default {
|
|
|
1225
1138
|
if (!mode) {
|
|
1226
1139
|
mode = selectRecords.length ? 'selected' : 'current';
|
|
1227
1140
|
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1141
|
+
let isCustomCol = false;
|
|
1142
|
+
let customCols = [];
|
|
1143
|
+
if (columns && columns.length) {
|
|
1144
|
+
isCustomCol = true;
|
|
1145
|
+
customCols = columns;
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
customCols = XEUtils.searchTree(collectColumn, column => {
|
|
1149
|
+
const isColGroup = column.children && column.children.length > 0;
|
|
1232
1150
|
let isChecked = false;
|
|
1233
1151
|
if (columns && columns.length) {
|
|
1234
1152
|
isChecked = handleFilterColumns(opts, column, columns);
|
|
@@ -1241,10 +1159,11 @@ export default {
|
|
|
1241
1159
|
}
|
|
1242
1160
|
return isChecked;
|
|
1243
1161
|
}, { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1162
|
+
}
|
|
1244
1163
|
const handleOptions = Object.assign({}, opts, { filename: '', sheetName: '' });
|
|
1245
1164
|
// 如果设置源数据,则默认导出设置了字段的列
|
|
1246
|
-
if (!
|
|
1247
|
-
|
|
1165
|
+
if (!isCustomCol && !columnFilterMethod) {
|
|
1166
|
+
columnFilterMethod = ({ column }) => {
|
|
1248
1167
|
if (excludeFields) {
|
|
1249
1168
|
if (XEUtils.includes(excludeFields, column.field)) {
|
|
1250
1169
|
return false;
|
|
@@ -1256,8 +1175,9 @@ export default {
|
|
|
1256
1175
|
}
|
|
1257
1176
|
return false;
|
|
1258
1177
|
}
|
|
1259
|
-
return original ? column.field : defaultFilterExportColumn(column);
|
|
1178
|
+
return original ? !!column.field : defaultFilterExportColumn(column);
|
|
1260
1179
|
};
|
|
1180
|
+
handleOptions.columnFilterMethod = columnFilterMethod;
|
|
1261
1181
|
}
|
|
1262
1182
|
if (customCols) {
|
|
1263
1183
|
handleOptions._isCustomColumn = true;
|
|
@@ -1292,14 +1212,14 @@ export default {
|
|
|
1292
1212
|
}, {
|
|
1293
1213
|
children: 'childNodes',
|
|
1294
1214
|
mapChildren: '_children'
|
|
1295
|
-
}), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column: column, $columnIndex: index })), {
|
|
1215
|
+
}), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, column: column, $columnIndex: index })), {
|
|
1296
1216
|
children: '_children',
|
|
1297
1217
|
mapChildren: 'childNodes',
|
|
1298
1218
|
original: true
|
|
1299
1219
|
});
|
|
1300
1220
|
}
|
|
1301
1221
|
else {
|
|
1302
|
-
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1222
|
+
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1303
1223
|
}
|
|
1304
1224
|
// 获取所有列
|
|
1305
1225
|
const cols = [];
|
|
@@ -1345,10 +1265,8 @@ export default {
|
|
|
1345
1265
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1346
1266
|
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
|
|
1347
1267
|
errLog('vxe.error.notType', [type]);
|
|
1348
|
-
if (
|
|
1349
|
-
|
|
1350
|
-
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx']);
|
|
1351
|
-
}
|
|
1268
|
+
if (['xlsx', 'pdf'].includes(type)) {
|
|
1269
|
+
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx']);
|
|
1352
1270
|
}
|
|
1353
1271
|
const params = { status: false };
|
|
1354
1272
|
return Promise.reject(params);
|
|
@@ -1369,10 +1287,8 @@ export default {
|
|
|
1369
1287
|
}
|
|
1370
1288
|
}
|
|
1371
1289
|
else if (mode === 'all') {
|
|
1372
|
-
if (
|
|
1373
|
-
|
|
1374
|
-
warnLog('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1375
|
-
}
|
|
1290
|
+
if (!$xeGrid) {
|
|
1291
|
+
errLog('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1376
1292
|
}
|
|
1377
1293
|
if ($xeGrid && !handleOptions.remote) {
|
|
1378
1294
|
const gridReactData = $xeGrid;
|
|
@@ -1383,10 +1299,8 @@ export default {
|
|
|
1383
1299
|
const ajaxMethods = ajax.queryAll;
|
|
1384
1300
|
const queryAllSuccessMethods = ajax.queryAllSuccess;
|
|
1385
1301
|
const queryAllErrorMethods = ajax.queryAllError;
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1388
|
-
warnLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll']);
|
|
1389
|
-
}
|
|
1302
|
+
if (!ajaxMethods) {
|
|
1303
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll']);
|
|
1390
1304
|
}
|
|
1391
1305
|
if (ajaxMethods) {
|
|
1392
1306
|
const params = {
|
|
@@ -1425,14 +1339,16 @@ export default {
|
|
|
1425
1339
|
return handleExport($xeTable, handleOptions);
|
|
1426
1340
|
},
|
|
1427
1341
|
_importByFile(file, options) {
|
|
1342
|
+
const $xeTable = this;
|
|
1428
1343
|
const opts = Object.assign({}, options);
|
|
1429
1344
|
const { beforeImportMethod } = opts;
|
|
1430
1345
|
if (beforeImportMethod) {
|
|
1431
|
-
beforeImportMethod({ options: opts, $table:
|
|
1346
|
+
beforeImportMethod({ options: opts, $table: $xeTable });
|
|
1432
1347
|
}
|
|
1433
|
-
return handleFileImport(
|
|
1348
|
+
return handleFileImport($xeTable, file, opts);
|
|
1434
1349
|
},
|
|
1435
1350
|
_importData(options) {
|
|
1351
|
+
const $xeTable = this;
|
|
1436
1352
|
const { importOpts } = this;
|
|
1437
1353
|
const opts = Object.assign({
|
|
1438
1354
|
types: XEUtils.keys(importOpts._typeMaps)
|
|
@@ -1443,21 +1359,21 @@ export default {
|
|
|
1443
1359
|
if (beforeImportMethod) {
|
|
1444
1360
|
beforeImportMethod({ options: opts, $table: this });
|
|
1445
1361
|
}
|
|
1446
|
-
return
|
|
1362
|
+
return VxeUI.readFile(opts).catch(e => {
|
|
1447
1363
|
if (afterImportMethod) {
|
|
1448
|
-
afterImportMethod({ status: false, options: opts, $table:
|
|
1364
|
+
afterImportMethod({ status: false, options: opts, $table: $xeTable });
|
|
1449
1365
|
}
|
|
1450
1366
|
return Promise.reject(e);
|
|
1451
1367
|
}).then((params) => {
|
|
1452
1368
|
const { file } = params;
|
|
1453
|
-
return handleFileImport(
|
|
1369
|
+
return handleFileImport($xeTable, file, opts);
|
|
1454
1370
|
});
|
|
1455
1371
|
},
|
|
1456
1372
|
_saveFile(options) {
|
|
1457
|
-
return
|
|
1373
|
+
return VxeUI.saveFile(options);
|
|
1458
1374
|
},
|
|
1459
1375
|
_readFile(options) {
|
|
1460
|
-
return
|
|
1376
|
+
return VxeUI.readFile(options);
|
|
1461
1377
|
},
|
|
1462
1378
|
_print(options) {
|
|
1463
1379
|
const $xeTable = this;
|
|
@@ -1560,23 +1476,28 @@ export default {
|
|
|
1560
1476
|
return Promise.resolve();
|
|
1561
1477
|
},
|
|
1562
1478
|
_openImport(options) {
|
|
1563
|
-
const
|
|
1479
|
+
const $xeTable = this;
|
|
1480
|
+
const props = $xeTable;
|
|
1481
|
+
const reactData = $xeTable;
|
|
1482
|
+
const { treeConfig, importConfig } = props;
|
|
1483
|
+
const { initStore, importStore, importParams } = reactData;
|
|
1484
|
+
const importOpts = $xeTable.computeImportOpts;
|
|
1564
1485
|
const defOpts = Object.assign({
|
|
1565
1486
|
mode: 'insertTop',
|
|
1566
1487
|
message: true,
|
|
1567
1488
|
types: XEUtils.keys(importOpts._typeMaps),
|
|
1568
1489
|
modes: ['insertTop', 'covering']
|
|
1569
|
-
},
|
|
1490
|
+
}, importOpts, options);
|
|
1570
1491
|
const types = defOpts.types || [];
|
|
1571
1492
|
const modes = defOpts.modes || [];
|
|
1572
|
-
const isTree = !!
|
|
1493
|
+
const isTree = !!treeConfig;
|
|
1573
1494
|
if (isTree) {
|
|
1574
1495
|
if (defOpts.message) {
|
|
1575
1496
|
VxeUI.modal.message({ content: getI18n('vxe.error.treeNotImp'), status: 'error' });
|
|
1576
1497
|
}
|
|
1577
1498
|
return;
|
|
1578
1499
|
}
|
|
1579
|
-
if (!
|
|
1500
|
+
if (!importConfig) {
|
|
1580
1501
|
errLog('vxe.error.reqProp', ['import-config']);
|
|
1581
1502
|
}
|
|
1582
1503
|
// 处理类型
|
|
@@ -1598,7 +1519,7 @@ export default {
|
|
|
1598
1519
|
label: getI18n(`vxe.import.modes.${item}`)
|
|
1599
1520
|
};
|
|
1600
1521
|
});
|
|
1601
|
-
Object.assign(
|
|
1522
|
+
Object.assign(importStore, {
|
|
1602
1523
|
file: null,
|
|
1603
1524
|
type: '',
|
|
1604
1525
|
filename: '',
|
|
@@ -1606,27 +1527,38 @@ export default {
|
|
|
1606
1527
|
typeList,
|
|
1607
1528
|
visible: true
|
|
1608
1529
|
});
|
|
1609
|
-
Object.assign(
|
|
1610
|
-
if (!modeList.some(
|
|
1611
|
-
|
|
1530
|
+
Object.assign(importParams, defOpts);
|
|
1531
|
+
if (!modeList.some(item => item.value === importParams.mode)) {
|
|
1532
|
+
importParams.mode = modeList[0].value;
|
|
1612
1533
|
}
|
|
1613
|
-
|
|
1534
|
+
initStore.import = true;
|
|
1614
1535
|
},
|
|
1615
1536
|
_closeExport: handleCloseExport,
|
|
1616
1537
|
_openExport(options) {
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1538
|
+
const $xeTable = this;
|
|
1539
|
+
const props = $xeTable;
|
|
1540
|
+
const exportOpts = $xeTable.computeExportOpts;
|
|
1541
|
+
const defOpts = Object.assign({
|
|
1542
|
+
message: true,
|
|
1543
|
+
types: XEUtils.keys(exportOpts._typeMaps)
|
|
1544
|
+
}, exportOpts, options);
|
|
1545
|
+
if (!props.exportConfig) {
|
|
1619
1546
|
errLog('vxe.error.reqProp', ['export-config']);
|
|
1620
1547
|
}
|
|
1621
|
-
return handleExportAndPrint(
|
|
1548
|
+
return handleExportAndPrint($xeTable, defOpts);
|
|
1622
1549
|
},
|
|
1623
1550
|
_closePrint: handleCloseExport,
|
|
1624
1551
|
_openPrint(options) {
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1552
|
+
const $xeTable = this;
|
|
1553
|
+
const props = $xeTable;
|
|
1554
|
+
const printOpts = $xeTable.computePrintOpts;
|
|
1555
|
+
const defOpts = Object.assign({
|
|
1556
|
+
message: true
|
|
1557
|
+
}, printOpts, options);
|
|
1558
|
+
if (!props.printConfig) {
|
|
1627
1559
|
errLog('vxe.error.reqProp', ['print-config']);
|
|
1628
1560
|
}
|
|
1629
|
-
return handleExportAndPrint(
|
|
1561
|
+
return handleExportAndPrint($xeTable, defOpts, true);
|
|
1630
1562
|
}
|
|
1631
1563
|
}
|
|
1632
1564
|
};
|
|
@@ -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 {
|