vxe-table 3.12.0-beta.8 → 3.12.0
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/locale/lang/de-DE.js +490 -490
- package/es/locale/lang/en-US.js +438 -438
- package/es/locale/lang/it-IT.js +692 -0
- package/es/locale/lang/ru-RU.js +36 -36
- package/es/locale/lang/th-TH.js +692 -0
- package/es/locale/lang/zh-CHT.js +19 -19
- package/es/style.css +1 -1
- package/es/table/module/custom/panel.js +5 -5
- package/es/table/module/export/mixin.js +208 -140
- package/es/table/module/validator/mixin.js +2 -6
- package/es/table/src/cell.js +88 -61
- package/es/table/src/column.js +2 -2
- package/es/table/src/group.js +2 -2
- package/es/table/src/methods.js +112 -87
- package/es/table/src/table.js +7 -11
- package/es/toolbar/src/toolbar.js +22 -4
- package/es/ui/index.js +2 -2
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/vn.js +3 -0
- package/lib/index.umd.js +513 -362
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/de-DE.js +490 -490
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/en-US.js +438 -438
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +438 -438
- package/lib/locale/lang/it-IT.js +698 -0
- package/lib/locale/lang/it-IT.min.js +1 -0
- package/lib/locale/lang/ru-RU.js +36 -36
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +36 -36
- package/lib/locale/lang/th-TH.js +698 -0
- package/lib/locale/lang/th-TH.min.js +1 -0
- package/lib/locale/lang/zh-CHT.js +19 -19
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +19 -19
- package/lib/style.css +1 -1
- package/lib/table/module/custom/panel.js +5 -5
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/module/export/mixin.js +239 -167
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +1 -6
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/cell.js +109 -83
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +112 -87
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +4 -9
- package/lib/table/src/table.min.js +1 -1
- package/lib/toolbar/src/toolbar.js +36 -2
- package/lib/toolbar/src/toolbar.min.js +1 -1
- package/lib/ui/index.js +2 -2
- 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/ui/src/vn.js +3 -0
- package/lib/ui/src/vn.min.js +1 -1
- package/package.json +3 -3
- package/packages/locale/lang/de-DE.ts +492 -491
- package/packages/locale/lang/en-US.ts +438 -438
- package/packages/locale/lang/it-IT.ts +692 -0
- package/packages/locale/lang/ru-RU.ts +36 -36
- package/packages/locale/lang/th-TH.ts +692 -0
- package/packages/locale/lang/zh-CHT.ts +19 -19
- package/packages/table/module/custom/panel.ts +5 -5
- package/packages/table/module/export/mixin.ts +227 -156
- package/packages/table/module/validator/mixin.ts +2 -6
- package/packages/table/src/cell.ts +141 -108
- package/packages/table/src/methods.ts +136 -105
- package/packages/table/src/table.ts +8 -12
- package/packages/toolbar/src/toolbar.ts +26 -8
- package/packages/ui/index.ts +1 -1
- package/packages/ui/src/vn.ts +4 -1
- /package/es/{iconfont.1735299026800.ttf → iconfont.1735661059384.ttf} +0 -0
- /package/es/{iconfont.1735299026800.woff → iconfont.1735661059384.woff} +0 -0
- /package/es/{iconfont.1735299026800.woff2 → iconfont.1735661059384.woff2} +0 -0
- /package/lib/{iconfont.1735299026800.ttf → iconfont.1735661059384.ttf} +0 -0
- /package/lib/{iconfont.1735299026800.woff → iconfont.1735661059384.woff} +0 -0
- /package/lib/{iconfont.1735299026800.woff2 → iconfont.1735661059384.woff2} +0 -0
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
exports.handlePrint = handlePrint;
|
|
8
7
|
exports.readLocalFile = readLocalFile;
|
|
9
8
|
exports.saveLocalFile = saveLocalFile;
|
|
10
9
|
var _xeUtils = _interopRequireDefault(require("xe-utils"));
|
|
11
10
|
var _ui = require("../../../ui");
|
|
12
11
|
var _util = require("../../src/util");
|
|
13
12
|
var _utils = require("../../../ui/src/utils");
|
|
14
|
-
var _dom = require("../../../ui/src/dom");
|
|
15
13
|
var _util2 = require("./util");
|
|
16
14
|
var _log = require("../../../ui/src/log");
|
|
17
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -23,30 +21,23 @@ let htmlCellElem;
|
|
|
23
21
|
// 导入
|
|
24
22
|
let fileForm;
|
|
25
23
|
let fileInput;
|
|
26
|
-
// 打印
|
|
27
|
-
let printFrame;
|
|
28
24
|
const csvBOM = '\ufeff';
|
|
29
25
|
const enterSymbol = '\r\n';
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
frame.className = 'vxe-table--print-frame';
|
|
33
|
-
return frame;
|
|
34
|
-
}
|
|
35
|
-
function hasTreeChildren($xetable, row) {
|
|
36
|
-
const treeOpts = $xetable.treeOpts;
|
|
26
|
+
function hasTreeChildren($xeTable, row) {
|
|
27
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
37
28
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
38
|
-
return row[childrenField] && row[childrenField].length
|
|
29
|
+
return row[childrenField] && row[childrenField].length;
|
|
39
30
|
}
|
|
40
|
-
function getSeq($
|
|
41
|
-
const seqOpts = $
|
|
31
|
+
function getSeq($xeTable, cellValue, row, $rowIndex, column, $columnIndex) {
|
|
32
|
+
const seqOpts = $xeTable.computeSeqOpts;
|
|
42
33
|
const seqMethod = seqOpts.seqMethod || column.seqMethod;
|
|
43
34
|
if (seqMethod) {
|
|
44
35
|
return seqMethod({
|
|
45
36
|
row,
|
|
46
|
-
rowIndex: $
|
|
37
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
47
38
|
$rowIndex,
|
|
48
39
|
column,
|
|
49
|
-
columnIndex: $
|
|
40
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
50
41
|
$columnIndex
|
|
51
42
|
});
|
|
52
43
|
}
|
|
@@ -71,22 +62,23 @@ const toStringValue = cellValue => {
|
|
|
71
62
|
return (0, _utils.eqEmptyValue)(cellValue) ? '' : `${cellValue}`;
|
|
72
63
|
};
|
|
73
64
|
function getBodyLabelData($xeTable, opts, columns, datas) {
|
|
65
|
+
const props = $xeTable;
|
|
74
66
|
const {
|
|
75
67
|
isAllExpand,
|
|
76
68
|
mode
|
|
77
69
|
} = opts;
|
|
78
70
|
const {
|
|
79
|
-
treeConfig
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
71
|
+
treeConfig
|
|
72
|
+
} = props;
|
|
73
|
+
const radioOpts = $xeTable.computeRadioOpts;
|
|
74
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
75
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
76
|
+
const columnOpts = $xeTable.computeColumnOpts;
|
|
86
77
|
if (!htmlCellElem) {
|
|
87
78
|
htmlCellElem = document.createElement('div');
|
|
88
79
|
}
|
|
89
80
|
if (treeConfig) {
|
|
81
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
90
82
|
// 如果是树表格只允许导出数据源
|
|
91
83
|
const rest = [];
|
|
92
84
|
const expandMaps = new Map();
|
|
@@ -104,11 +96,11 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
|
|
|
104
96
|
columns.forEach((column, $columnIndex) => {
|
|
105
97
|
let cellValue = '';
|
|
106
98
|
const renderOpts = column.editRender || column.cellRender;
|
|
107
|
-
let bodyExportMethod = column.exportMethod;
|
|
99
|
+
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
108
100
|
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
109
101
|
const compConf = renderer.get(renderOpts.name);
|
|
110
102
|
if (compConf) {
|
|
111
|
-
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod
|
|
103
|
+
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
if (!bodyExportMethod) {
|
|
@@ -125,8 +117,8 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
|
|
|
125
117
|
switch (column.type) {
|
|
126
118
|
case 'seq':
|
|
127
119
|
{
|
|
128
|
-
const
|
|
129
|
-
cellValue = mode === 'all' ?
|
|
120
|
+
const seqVal = path.map((num, i) => i % 2 === 0 ? Number(num) + 1 : '.').join('');
|
|
121
|
+
cellValue = mode === 'all' ? seqVal : getSeq($xeTable, seqVal, row, $rowIndex, column, $columnIndex);
|
|
130
122
|
break;
|
|
131
123
|
}
|
|
132
124
|
case 'checkbox':
|
|
@@ -177,16 +169,13 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
|
|
|
177
169
|
columns.forEach((column, $columnIndex) => {
|
|
178
170
|
let cellValue = '';
|
|
179
171
|
const renderOpts = column.editRender || column.cellRender;
|
|
180
|
-
let bodyExportMethod = column.exportMethod;
|
|
172
|
+
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
181
173
|
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
182
174
|
const compConf = renderer.get(renderOpts.name);
|
|
183
175
|
if (compConf) {
|
|
184
|
-
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod
|
|
176
|
+
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
185
177
|
}
|
|
186
178
|
}
|
|
187
|
-
if (!bodyExportMethod) {
|
|
188
|
-
bodyExportMethod = columnOpts.exportMethod;
|
|
189
|
-
}
|
|
190
179
|
if (bodyExportMethod) {
|
|
191
180
|
cellValue = bodyExportMethod({
|
|
192
181
|
$table: $xeTable,
|
|
@@ -663,7 +652,8 @@ function clearColumnConvert(columns) {
|
|
|
663
652
|
children: 'children'
|
|
664
653
|
});
|
|
665
654
|
}
|
|
666
|
-
function handleExport($
|
|
655
|
+
function handleExport($xeTable, opts) {
|
|
656
|
+
const $xeGrid = $xeTable.$xeGrid;
|
|
667
657
|
const {
|
|
668
658
|
remote,
|
|
669
659
|
columns,
|
|
@@ -675,19 +665,19 @@ function handleExport($xetable, opts) {
|
|
|
675
665
|
if (remote) {
|
|
676
666
|
const params = {
|
|
677
667
|
options: opts,
|
|
678
|
-
$table: $
|
|
679
|
-
$grid: $
|
|
668
|
+
$table: $xeTable,
|
|
669
|
+
$grid: $xeGrid
|
|
680
670
|
};
|
|
681
671
|
resolve(exportMethod ? exportMethod(params) : params);
|
|
682
672
|
} else {
|
|
683
|
-
const datas = getExportData($
|
|
684
|
-
resolve($
|
|
673
|
+
const datas = getExportData($xeTable, opts);
|
|
674
|
+
resolve($xeTable.preventEvent(null, 'event.export', {
|
|
685
675
|
options: opts,
|
|
686
676
|
columns,
|
|
687
677
|
colgroups,
|
|
688
678
|
datas
|
|
689
679
|
}, () => {
|
|
690
|
-
return downloadFile($
|
|
680
|
+
return downloadFile($xeTable, opts, getContent($xeTable, opts, columns, datas));
|
|
691
681
|
}));
|
|
692
682
|
}
|
|
693
683
|
}).then(params => {
|
|
@@ -697,8 +687,8 @@ function handleExport($xetable, opts) {
|
|
|
697
687
|
afterExportMethod({
|
|
698
688
|
status: true,
|
|
699
689
|
options: opts,
|
|
700
|
-
$table: $
|
|
701
|
-
$grid: $
|
|
690
|
+
$table: $xeTable,
|
|
691
|
+
$grid: $xeGrid
|
|
702
692
|
});
|
|
703
693
|
}
|
|
704
694
|
}
|
|
@@ -712,8 +702,8 @@ function handleExport($xetable, opts) {
|
|
|
712
702
|
afterExportMethod({
|
|
713
703
|
status: false,
|
|
714
704
|
options: opts,
|
|
715
|
-
$table: $
|
|
716
|
-
$grid: $
|
|
705
|
+
$table: $xeTable,
|
|
706
|
+
$grid: $xeGrid
|
|
717
707
|
});
|
|
718
708
|
}
|
|
719
709
|
}
|
|
@@ -1136,79 +1126,42 @@ function readLocalFile(options = {}) {
|
|
|
1136
1126
|
fileInput.click();
|
|
1137
1127
|
});
|
|
1138
1128
|
}
|
|
1139
|
-
function
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
} catch (e) {}
|
|
1145
|
-
printFrame.parentNode.removeChild(printFrame);
|
|
1146
|
-
}
|
|
1147
|
-
printFrame = null;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
function appendPrintFrame() {
|
|
1151
|
-
if (!printFrame.parentNode) {
|
|
1152
|
-
document.body.appendChild(printFrame);
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
function afterPrintEvent() {
|
|
1156
|
-
requestAnimationFrame(removePrintFrame);
|
|
1157
|
-
}
|
|
1158
|
-
function handlePrint($xetable, opts, content) {
|
|
1129
|
+
function handleExportAndPrint($xeTable, options, isPrint) {
|
|
1130
|
+
const props = $xeTable;
|
|
1131
|
+
const reactData = $xeTable;
|
|
1132
|
+
const internalData = $xeTable;
|
|
1133
|
+
const $xeGrid = $xeTable.$xeGrid;
|
|
1159
1134
|
const {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
content,
|
|
1165
|
-
options: opts,
|
|
1166
|
-
$table: $xetable
|
|
1167
|
-
}) || '';
|
|
1168
|
-
}
|
|
1169
|
-
content = (0, _util2.createHtmlPage)(opts, content);
|
|
1170
|
-
const blob = (0, _util2.getExportBlobByContent)(content, opts);
|
|
1171
|
-
if (_dom.browse.msie) {
|
|
1172
|
-
removePrintFrame();
|
|
1173
|
-
printFrame = createFrame();
|
|
1174
|
-
appendPrintFrame();
|
|
1175
|
-
printFrame.contentDocument.write(content);
|
|
1176
|
-
printFrame.contentDocument.execCommand('print');
|
|
1177
|
-
} else {
|
|
1178
|
-
if (!printFrame) {
|
|
1179
|
-
printFrame = createFrame();
|
|
1180
|
-
printFrame.onload = evnt => {
|
|
1181
|
-
if (evnt.target.src) {
|
|
1182
|
-
evnt.target.contentWindow.onafterprint = afterPrintEvent;
|
|
1183
|
-
evnt.target.contentWindow.print();
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
appendPrintFrame();
|
|
1188
|
-
printFrame.src = URL.createObjectURL(blob);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
function handleExportAndPrint($xetable, options, isPrint) {
|
|
1135
|
+
treeConfig,
|
|
1136
|
+
showHeader,
|
|
1137
|
+
showFooter
|
|
1138
|
+
} = props;
|
|
1192
1139
|
const {
|
|
1193
|
-
$xegrid,
|
|
1194
1140
|
initStore,
|
|
1195
|
-
customOpts,
|
|
1196
|
-
collectColumn,
|
|
1197
|
-
footerTableData,
|
|
1198
|
-
treeConfig,
|
|
1199
1141
|
mergeList,
|
|
1142
|
+
mergeFooterList,
|
|
1200
1143
|
isGroup,
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1144
|
+
footerTableData,
|
|
1145
|
+
exportStore,
|
|
1146
|
+
exportParams
|
|
1147
|
+
} = reactData;
|
|
1148
|
+
const {
|
|
1149
|
+
collectColumn
|
|
1150
|
+
} = internalData;
|
|
1151
|
+
const exportOpts = $xeTable.computeExportOpts;
|
|
1207
1152
|
const hasTree = treeConfig;
|
|
1208
|
-
const
|
|
1153
|
+
const customOpts = $xeTable.computeCustomOpts;
|
|
1154
|
+
const selectRecords = $xeTable.getCheckboxRecords();
|
|
1155
|
+
const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {};
|
|
1156
|
+
const hasFooter = !!footerTableData.length;
|
|
1157
|
+
const hasMerge = !!(mergeList.length || mergeFooterList.length);
|
|
1209
1158
|
const defOpts = Object.assign({
|
|
1210
1159
|
message: true,
|
|
1211
|
-
isHeader:
|
|
1160
|
+
isHeader: showHeader,
|
|
1161
|
+
isFooter: showFooter,
|
|
1162
|
+
isColgroup: isGroup,
|
|
1163
|
+
isMerge: hasMerge,
|
|
1164
|
+
useStyle: true,
|
|
1212
1165
|
current: 'current',
|
|
1213
1166
|
modes: ['current', 'selected'].concat(proxyOpts.ajax && proxyOpts.ajax.queryAll ? ['all'] : [])
|
|
1214
1167
|
}, options);
|
|
@@ -1244,7 +1197,7 @@ function handleExportAndPrint($xetable, options, isPrint) {
|
|
|
1244
1197
|
if (isColGroup || defaultFilterExportColumn(column)) {
|
|
1245
1198
|
column.checked = columns ? columns.some(item => {
|
|
1246
1199
|
if ((0, _util.isColumnInfo)(item)) {
|
|
1247
|
-
return column === item;
|
|
1200
|
+
return column.id === item.id;
|
|
1248
1201
|
} else if (_xeUtils.default.isString(item)) {
|
|
1249
1202
|
return column.field === item;
|
|
1250
1203
|
} else {
|
|
@@ -1270,7 +1223,7 @@ function handleExportAndPrint($xetable, options, isPrint) {
|
|
|
1270
1223
|
}
|
|
1271
1224
|
});
|
|
1272
1225
|
// 更新条件
|
|
1273
|
-
Object.assign(
|
|
1226
|
+
Object.assign(exportStore, {
|
|
1274
1227
|
columns: exportColumns,
|
|
1275
1228
|
typeList,
|
|
1276
1229
|
modeList,
|
|
@@ -1285,14 +1238,42 @@ function handleExportAndPrint($xetable, options, isPrint) {
|
|
|
1285
1238
|
Object.assign(exportParams, {
|
|
1286
1239
|
mode: selectRecords.length ? 'selected' : 'current'
|
|
1287
1240
|
}, defOpts);
|
|
1288
|
-
|
|
1241
|
+
const {
|
|
1242
|
+
filename,
|
|
1243
|
+
sheetName,
|
|
1244
|
+
mode,
|
|
1245
|
+
type
|
|
1246
|
+
} = exportParams;
|
|
1247
|
+
if (filename) {
|
|
1248
|
+
if (_xeUtils.default.isFunction(filename)) {
|
|
1249
|
+
exportParams.filename = filename({
|
|
1250
|
+
options: defOpts,
|
|
1251
|
+
$table: $xeTable,
|
|
1252
|
+
$grid: $xeGrid
|
|
1253
|
+
});
|
|
1254
|
+
} else {
|
|
1255
|
+
exportParams.filename = `${filename}`;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
if (sheetName) {
|
|
1259
|
+
if (_xeUtils.default.isFunction(sheetName)) {
|
|
1260
|
+
exportParams.sheetName = sheetName({
|
|
1261
|
+
options: defOpts,
|
|
1262
|
+
$table: $xeTable,
|
|
1263
|
+
$grid: $xeGrid
|
|
1264
|
+
});
|
|
1265
|
+
} else {
|
|
1266
|
+
exportParams.sheetName = `${sheetName}`;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
if (!modeList.some(item => item.value === mode)) {
|
|
1289
1270
|
exportParams.mode = modeList[0].value;
|
|
1290
1271
|
}
|
|
1291
|
-
if (!typeList.some(item => item.value ===
|
|
1272
|
+
if (!typeList.some(item => item.value === type)) {
|
|
1292
1273
|
exportParams.type = typeList[0].value;
|
|
1293
1274
|
}
|
|
1294
1275
|
initStore.export = true;
|
|
1295
|
-
return $
|
|
1276
|
+
return $xeTable.$nextTick();
|
|
1296
1277
|
}
|
|
1297
1278
|
const getConvertColumns = columns => {
|
|
1298
1279
|
const result = [];
|
|
@@ -1350,12 +1331,13 @@ var _default = exports.default = {
|
|
|
1350
1331
|
/**
|
|
1351
1332
|
* 导出文件,支持 csv/html/xml/txt
|
|
1352
1333
|
* 如果是树表格,则默认是导出所有节点
|
|
1353
|
-
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod
|
|
1334
|
+
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数转换数据
|
|
1354
1335
|
* @param {Object} options 参数
|
|
1355
1336
|
*/
|
|
1356
1337
|
_exportData(options) {
|
|
1338
|
+
const $xeTable = this;
|
|
1339
|
+
const $xeGrid = $xeTable.$xeGrid;
|
|
1357
1340
|
const {
|
|
1358
|
-
$xegrid,
|
|
1359
1341
|
isGroup,
|
|
1360
1342
|
tableGroupColumn,
|
|
1361
1343
|
tableFullColumn,
|
|
@@ -1389,20 +1371,26 @@ var _default = exports.default = {
|
|
|
1389
1371
|
print: false
|
|
1390
1372
|
}, options);
|
|
1391
1373
|
const {
|
|
1374
|
+
filename,
|
|
1375
|
+
sheetName,
|
|
1392
1376
|
type,
|
|
1393
1377
|
mode,
|
|
1394
1378
|
columns,
|
|
1395
1379
|
original,
|
|
1380
|
+
columnFilterMethod,
|
|
1396
1381
|
beforeExportMethod,
|
|
1397
|
-
|
|
1398
|
-
|
|
1382
|
+
includeFields,
|
|
1383
|
+
excludeFields
|
|
1399
1384
|
} = opts;
|
|
1400
1385
|
let groups = [];
|
|
1401
1386
|
const customCols = columns && columns.length ? columns : null;
|
|
1387
|
+
const handleOptions = Object.assign({}, opts, {
|
|
1388
|
+
filename: '',
|
|
1389
|
+
sheetName: ''
|
|
1390
|
+
});
|
|
1402
1391
|
// 如果设置源数据,则默认导出设置了字段的列
|
|
1403
|
-
let columnFilterMethod = opts.columnFilterMethod;
|
|
1404
1392
|
if (!customCols && !columnFilterMethod) {
|
|
1405
|
-
columnFilterMethod = ({
|
|
1393
|
+
handleOptions.columnFilterMethod = ({
|
|
1406
1394
|
column
|
|
1407
1395
|
}) => {
|
|
1408
1396
|
if (excludeFields) {
|
|
@@ -1420,24 +1408,24 @@ var _default = exports.default = {
|
|
|
1420
1408
|
};
|
|
1421
1409
|
}
|
|
1422
1410
|
if (customCols) {
|
|
1423
|
-
|
|
1411
|
+
handleOptions._isCustomColumn = true;
|
|
1424
1412
|
groups = _xeUtils.default.searchTree(_xeUtils.default.mapTree(customCols, item => {
|
|
1425
1413
|
let targetColumn;
|
|
1426
1414
|
if (item) {
|
|
1427
1415
|
if ((0, _util.isColumnInfo)(item)) {
|
|
1428
1416
|
targetColumn = item;
|
|
1429
1417
|
} else if (_xeUtils.default.isString(item)) {
|
|
1430
|
-
targetColumn =
|
|
1418
|
+
targetColumn = $xeTable.getColumnByField(item);
|
|
1431
1419
|
} else {
|
|
1432
1420
|
const colid = item.id || item.colId;
|
|
1433
1421
|
const type = item.type;
|
|
1434
1422
|
const field = item.field;
|
|
1435
1423
|
if (colid) {
|
|
1436
|
-
targetColumn =
|
|
1424
|
+
targetColumn = $xeTable.getColumnById(colid);
|
|
1437
1425
|
} else if (field && type) {
|
|
1438
1426
|
targetColumn = tableFullColumn.find(column => column.field === field && column.type === type);
|
|
1439
1427
|
} else if (field) {
|
|
1440
|
-
targetColumn =
|
|
1428
|
+
targetColumn = $xeTable.getColumnByField(field);
|
|
1441
1429
|
} else if (type) {
|
|
1442
1430
|
targetColumn = tableFullColumn.find(column => column.type === type);
|
|
1443
1431
|
}
|
|
@@ -1448,7 +1436,7 @@ var _default = exports.default = {
|
|
|
1448
1436
|
children: 'childNodes',
|
|
1449
1437
|
mapChildren: '_children'
|
|
1450
1438
|
}), (column, index) => (0, _util.isColumnInfo)(column) && (!columnFilterMethod || columnFilterMethod({
|
|
1451
|
-
column,
|
|
1439
|
+
column: column,
|
|
1452
1440
|
$columnIndex: index
|
|
1453
1441
|
})), {
|
|
1454
1442
|
children: '_children',
|
|
@@ -1476,16 +1464,38 @@ var _default = exports.default = {
|
|
|
1476
1464
|
children: 'childNodes'
|
|
1477
1465
|
});
|
|
1478
1466
|
// 构建分组层级
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
if (
|
|
1482
|
-
|
|
1467
|
+
handleOptions.columns = cols;
|
|
1468
|
+
handleOptions.colgroups = convertToRows(groups);
|
|
1469
|
+
if (filename) {
|
|
1470
|
+
if (_xeUtils.default.isFunction(filename)) {
|
|
1471
|
+
handleOptions.filename = filename({
|
|
1472
|
+
options: opts,
|
|
1473
|
+
$table: $xeTable,
|
|
1474
|
+
$grid: $xeGrid
|
|
1475
|
+
});
|
|
1476
|
+
} else {
|
|
1477
|
+
handleOptions.filename = `${filename}`;
|
|
1478
|
+
}
|
|
1483
1479
|
}
|
|
1484
|
-
if (!
|
|
1485
|
-
|
|
1480
|
+
if (!handleOptions.filename) {
|
|
1481
|
+
handleOptions.filename = getI18n(handleOptions.original ? 'vxe.table.expOriginFilename' : 'vxe.table.expFilename', [_xeUtils.default.toDateString(Date.now(), 'yyyyMMddHHmmss')]);
|
|
1482
|
+
}
|
|
1483
|
+
if (sheetName) {
|
|
1484
|
+
if (_xeUtils.default.isFunction(sheetName)) {
|
|
1485
|
+
handleOptions.sheetName = sheetName({
|
|
1486
|
+
options: opts,
|
|
1487
|
+
$table: $xeTable,
|
|
1488
|
+
$grid: $xeGrid
|
|
1489
|
+
});
|
|
1490
|
+
} else {
|
|
1491
|
+
handleOptions.sheetName = `${sheetName}`;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
if (!handleOptions.sheetName) {
|
|
1495
|
+
handleOptions.sheetName = document.title || '';
|
|
1486
1496
|
}
|
|
1487
1497
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1488
|
-
if (!
|
|
1498
|
+
if (!handleOptions.exportMethod && !_xeUtils.default.includes(_xeUtils.default.keys(exportOpts._typeMaps), type)) {
|
|
1489
1499
|
(0, _log.errLog)('vxe.error.notType', [type]);
|
|
1490
1500
|
if (process.env.NODE_ENV === 'development') {
|
|
1491
1501
|
if (['xlsx', 'pdf'].includes(type)) {
|
|
@@ -1497,21 +1507,21 @@ var _default = exports.default = {
|
|
|
1497
1507
|
};
|
|
1498
1508
|
return Promise.reject(params);
|
|
1499
1509
|
}
|
|
1500
|
-
if (!
|
|
1510
|
+
if (!handleOptions.print) {
|
|
1501
1511
|
if (beforeExportMethod) {
|
|
1502
1512
|
beforeExportMethod({
|
|
1503
|
-
options:
|
|
1504
|
-
$table:
|
|
1505
|
-
$grid: $
|
|
1513
|
+
options: handleOptions,
|
|
1514
|
+
$table: $xeTable,
|
|
1515
|
+
$grid: $xeGrid
|
|
1506
1516
|
});
|
|
1507
1517
|
}
|
|
1508
1518
|
}
|
|
1509
1519
|
if (!opts.data) {
|
|
1510
|
-
|
|
1520
|
+
handleOptions.data = [];
|
|
1511
1521
|
if (mode === 'selected') {
|
|
1512
|
-
const selectRecords =
|
|
1522
|
+
const selectRecords = $xeTable.getCheckboxRecords();
|
|
1513
1523
|
if (['html', 'pdf'].indexOf(type) > -1 && treeConfig) {
|
|
1514
|
-
opts.data = _xeUtils.default.searchTree(
|
|
1524
|
+
opts.data = _xeUtils.default.searchTree($xeTable.getTableData().fullData, item => $xeTable.findRowIndexOf(selectRecords, item) > -1, Object.assign({}, treeOpts, {
|
|
1515
1525
|
data: '_row'
|
|
1516
1526
|
}));
|
|
1517
1527
|
} else {
|
|
@@ -1519,17 +1529,22 @@ var _default = exports.default = {
|
|
|
1519
1529
|
}
|
|
1520
1530
|
} else if (mode === 'all') {
|
|
1521
1531
|
if (process.env.NODE_ENV === 'development') {
|
|
1522
|
-
if (!$
|
|
1532
|
+
if (!$xeGrid) {
|
|
1523
1533
|
(0, _log.warnLog)('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1524
1534
|
}
|
|
1525
1535
|
}
|
|
1526
|
-
if ($
|
|
1536
|
+
if ($xeGrid && !handleOptions.remote) {
|
|
1537
|
+
const gridReactData = $xeGrid;
|
|
1538
|
+
const proxyOpts = $xeGrid.computeProxyOpts;
|
|
1539
|
+
const {
|
|
1540
|
+
sortData
|
|
1541
|
+
} = gridReactData;
|
|
1527
1542
|
const {
|
|
1528
1543
|
beforeQueryAll,
|
|
1529
1544
|
afterQueryAll,
|
|
1530
|
-
ajax = {}
|
|
1531
|
-
|
|
1532
|
-
|
|
1545
|
+
ajax = {}
|
|
1546
|
+
} = proxyOpts;
|
|
1547
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {};
|
|
1533
1548
|
const ajaxMethods = ajax.queryAll;
|
|
1534
1549
|
const queryAllSuccessMethods = ajax.queryAllSuccess;
|
|
1535
1550
|
const queryAllErrorMethods = ajax.queryAllError;
|
|
@@ -1540,16 +1555,20 @@ var _default = exports.default = {
|
|
|
1540
1555
|
}
|
|
1541
1556
|
if (ajaxMethods) {
|
|
1542
1557
|
const params = {
|
|
1543
|
-
$table:
|
|
1544
|
-
$grid: $
|
|
1545
|
-
sort:
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
options:
|
|
1558
|
+
$table: $xeTable,
|
|
1559
|
+
$grid: $xeGrid,
|
|
1560
|
+
sort: sortData.length ? sortData[0] : {},
|
|
1561
|
+
sorts: sortData,
|
|
1562
|
+
filters: gridReactData.filterData,
|
|
1563
|
+
form: gridReactData.formData,
|
|
1564
|
+
options: handleOptions
|
|
1550
1565
|
};
|
|
1551
1566
|
return Promise.resolve((beforeQueryAll || ajaxMethods)(params)).then(rest => {
|
|
1552
|
-
|
|
1567
|
+
const listProp = resConfigs.list;
|
|
1568
|
+
handleOptions.data = (listProp ? _xeUtils.default.isFunction(listProp) ? listProp({
|
|
1569
|
+
data: rest,
|
|
1570
|
+
$grid: $xeGrid
|
|
1571
|
+
}) : _xeUtils.default.get(rest, listProp) : rest) || [];
|
|
1553
1572
|
if (afterQueryAll) {
|
|
1554
1573
|
afterQueryAll(params);
|
|
1555
1574
|
}
|
|
@@ -1558,7 +1577,7 @@ var _default = exports.default = {
|
|
|
1558
1577
|
response: rest
|
|
1559
1578
|
}));
|
|
1560
1579
|
}
|
|
1561
|
-
return handleExport(
|
|
1580
|
+
return handleExport($xeTable, handleOptions);
|
|
1562
1581
|
}).catch(rest => {
|
|
1563
1582
|
if (queryAllErrorMethods) {
|
|
1564
1583
|
queryAllErrorMethods(Object.assign(Object.assign({}, params), {
|
|
@@ -1569,10 +1588,10 @@ var _default = exports.default = {
|
|
|
1569
1588
|
}
|
|
1570
1589
|
}
|
|
1571
1590
|
} else if (mode === 'current') {
|
|
1572
|
-
|
|
1591
|
+
handleOptions.data = afterFullData;
|
|
1573
1592
|
}
|
|
1574
1593
|
}
|
|
1575
|
-
return handleExport(
|
|
1594
|
+
return handleExport($xeTable, opts);
|
|
1576
1595
|
},
|
|
1577
1596
|
_importByFile(file, options) {
|
|
1578
1597
|
const opts = Object.assign({}, options);
|
|
@@ -1629,6 +1648,8 @@ var _default = exports.default = {
|
|
|
1629
1648
|
return readLocalFile(options);
|
|
1630
1649
|
},
|
|
1631
1650
|
_print(options) {
|
|
1651
|
+
const $xeTable = this;
|
|
1652
|
+
const $xeGrid = $xeTable.$xeGrid;
|
|
1632
1653
|
const opts = Object.assign({
|
|
1633
1654
|
original: false
|
|
1634
1655
|
// beforePrintMethod
|
|
@@ -1638,25 +1659,76 @@ var _default = exports.default = {
|
|
|
1638
1659
|
remote: false,
|
|
1639
1660
|
print: true
|
|
1640
1661
|
});
|
|
1641
|
-
|
|
1642
|
-
|
|
1662
|
+
const {
|
|
1663
|
+
sheetName
|
|
1664
|
+
} = opts;
|
|
1665
|
+
let printTitle = '';
|
|
1666
|
+
if (sheetName) {
|
|
1667
|
+
if (_xeUtils.default.isFunction(sheetName)) {
|
|
1668
|
+
printTitle = sheetName({
|
|
1669
|
+
options: opts,
|
|
1670
|
+
$table: $xeTable,
|
|
1671
|
+
$grid: $xeGrid
|
|
1672
|
+
});
|
|
1673
|
+
} else {
|
|
1674
|
+
printTitle = `${sheetName}`;
|
|
1675
|
+
}
|
|
1643
1676
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1677
|
+
if (!printTitle) {
|
|
1678
|
+
printTitle = document.title || '';
|
|
1679
|
+
}
|
|
1680
|
+
const beforePrintMethod = opts.beforePrintMethod;
|
|
1681
|
+
const tableHtml = opts.html || opts.content;
|
|
1682
|
+
return new Promise((resolve, reject) => {
|
|
1683
|
+
if (_ui.VxeUI.print) {
|
|
1684
|
+
if (tableHtml) {
|
|
1685
|
+
resolve(_ui.VxeUI.print({
|
|
1686
|
+
title: printTitle,
|
|
1687
|
+
html: tableHtml,
|
|
1688
|
+
customStyle: opts.style,
|
|
1689
|
+
beforeMethod: beforePrintMethod ? ({
|
|
1690
|
+
html
|
|
1691
|
+
}) => {
|
|
1692
|
+
return beforePrintMethod({
|
|
1693
|
+
html,
|
|
1694
|
+
content: html,
|
|
1695
|
+
options: opts,
|
|
1696
|
+
$table: $xeTable
|
|
1697
|
+
});
|
|
1698
|
+
} : undefined
|
|
1699
|
+
}));
|
|
1700
|
+
} else {
|
|
1701
|
+
resolve($xeTable.exportData(opts).then(({
|
|
1702
|
+
content
|
|
1703
|
+
}) => {
|
|
1704
|
+
return _ui.VxeUI.print({
|
|
1705
|
+
title: printTitle,
|
|
1706
|
+
html: content,
|
|
1707
|
+
customStyle: opts.style,
|
|
1708
|
+
beforeMethod: beforePrintMethod ? ({
|
|
1709
|
+
html
|
|
1710
|
+
}) => {
|
|
1711
|
+
return beforePrintMethod({
|
|
1712
|
+
html,
|
|
1713
|
+
content: html,
|
|
1714
|
+
options: opts,
|
|
1715
|
+
$table: $xeTable
|
|
1716
|
+
});
|
|
1717
|
+
} : undefined
|
|
1718
|
+
});
|
|
1719
|
+
}));
|
|
1720
|
+
}
|
|
1647
1721
|
} else {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
}));
|
|
1722
|
+
const e = {
|
|
1723
|
+
status: false
|
|
1724
|
+
};
|
|
1725
|
+
reject(e);
|
|
1653
1726
|
}
|
|
1654
1727
|
});
|
|
1655
1728
|
},
|
|
1656
1729
|
_getPrintHtml(options) {
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1659
|
-
} = this;
|
|
1730
|
+
const $xeTable = this;
|
|
1731
|
+
const printOpts = $xeTable.computePrintOpts;
|
|
1660
1732
|
const opts = Object.assign({
|
|
1661
1733
|
original: false
|
|
1662
1734
|
// beforePrintMethod
|
|
@@ -1666,7 +1738,7 @@ var _default = exports.default = {
|
|
|
1666
1738
|
remote: false,
|
|
1667
1739
|
print: true
|
|
1668
1740
|
});
|
|
1669
|
-
return
|
|
1741
|
+
return $xeTable.exportData(opts).then(({
|
|
1670
1742
|
content
|
|
1671
1743
|
}) => {
|
|
1672
1744
|
return {
|