vxe-table 3.9.0-rc.9 → 3.9.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/README.md +1 -1
- package/es/grid/src/grid.js +120 -66
- package/es/grid/style.css +0 -1
- package/es/grid/style.min.css +1 -1
- package/es/index.esm.js +22 -3
- package/es/locale/lang/en-US.js +2 -1
- package/es/locale/lang/es-ES.js +2 -1
- package/es/locale/lang/hu-HU.js +2 -1
- package/es/locale/lang/ja-JP.js +2 -1
- package/es/locale/lang/ko-KR.js +2 -1
- package/es/locale/lang/pt-BR.js +2 -1
- package/es/locale/lang/ru-RU.js +2 -1
- package/es/locale/lang/uk-UA.js +2 -1
- package/es/locale/lang/vi-VN.js +2 -1
- package/es/locale/lang/zh-CHT.js +2 -1
- package/es/locale/lang/zh-CN.js +2 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/custom/panel.js +183 -173
- package/es/table/module/edit/mixin.js +33 -24
- package/es/table/module/export/export-panel.js +32 -4
- package/es/table/module/export/import-panel.js +25 -6
- package/es/table/module/export/mixin.js +11 -11
- package/es/table/module/menu/mixin.js +2 -2
- package/es/table/module/validator/mixin.js +4 -4
- package/es/table/render/index.js +17 -11
- package/es/table/src/body.js +1 -0
- package/es/table/src/columnInfo.js +3 -3
- package/es/table/src/methods.js +54 -42
- package/es/table/src/props.js +65 -15
- package/es/table/src/table.js +91 -57
- package/es/table/src/util.js +3 -2
- package/es/table/style.css +37 -48
- package/es/table/style.min.css +1 -1
- package/es/toolbar/src/toolbar.js +21 -7
- package/es/toolbar/style.css +0 -1
- package/es/toolbar/style.min.css +1 -1
- package/es/ui/index.js +5 -3
- package/es/ui/src/log.js +1 -1
- package/es/vxe-grid/style.css +0 -1
- package/es/vxe-grid/style.min.css +1 -1
- package/es/vxe-table/style.css +37 -48
- package/es/vxe-table/style.min.css +1 -1
- package/es/vxe-toolbar/style.css +0 -1
- package/es/vxe-toolbar/style.min.css +1 -1
- package/lib/colgroup/index.js +3 -3
- package/lib/colgroup/index.min.js +1 -1
- package/lib/column/index.js +3 -3
- package/lib/column/index.min.js +1 -1
- package/lib/components.js +9 -11
- package/lib/components.min.js +1 -1
- package/lib/grid/index.js +3 -3
- package/lib/grid/index.min.js +1 -1
- package/lib/grid/src/grid.js +581 -491
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/grid/style/style.css +0 -1
- package/lib/grid/style/style.min.css +1 -1
- package/lib/index.common.js +3 -4
- package/lib/index.umd.js +9174 -17260
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/en-US.js +2 -1
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +2 -1
- package/lib/locale/lang/es-ES.js +2 -1
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +2 -1
- package/lib/locale/lang/hu-HU.js +2 -1
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +2 -1
- package/lib/locale/lang/ja-JP.js +2 -1
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +2 -1
- package/lib/locale/lang/ko-KR.js +2 -1
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +2 -1
- package/lib/locale/lang/pt-BR.js +2 -1
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +2 -1
- package/lib/locale/lang/ru-RU.js +2 -1
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +2 -1
- package/lib/locale/lang/uk-UA.js +2 -1
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +2 -1
- package/lib/locale/lang/vi-VN.js +2 -1
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +2 -1
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +2 -1
- package/lib/locale/lang/zh-CN.js +2 -1
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +2 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/index.js +4 -4
- package/lib/table/index.min.js +1 -1
- package/lib/table/module/custom/mixin.js +53 -44
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/module/custom/panel.js +310 -239
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/module/edit/mixin.js +436 -371
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/export-panel.js +136 -106
- package/lib/table/module/export/export-panel.min.js +1 -1
- package/lib/table/module/export/import-panel.js +75 -54
- package/lib/table/module/export/import-panel.min.js +1 -1
- package/lib/table/module/export/mixin.js +592 -597
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/export/util.js +6 -4
- package/lib/table/module/export/util.min.js +1 -1
- package/lib/table/module/filter/mixin.js +147 -118
- package/lib/table/module/filter/mixin.min.js +1 -1
- package/lib/table/module/filter/panel.js +86 -65
- package/lib/table/module/filter/panel.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +163 -151
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +125 -114
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/menu/panel.js +36 -34
- package/lib/table/module/menu/panel.min.js +1 -1
- package/lib/table/module/validator/mixin.js +225 -214
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/render/index.js +401 -297
- package/lib/table/render/index.min.js +1 -1
- package/lib/table/src/body.js +411 -349
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +470 -344
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +10 -10
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +46 -55
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +157 -132
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/group.js +1 -1
- package/lib/table/src/group.min.js +1 -1
- package/lib/table/src/header.js +170 -153
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +2758 -2478
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +33 -74
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +465 -424
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +143 -131
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +37 -48
- package/lib/table/style/style.min.css +1 -1
- package/lib/toolbar/index.js +3 -3
- package/lib/toolbar/index.min.js +1 -1
- package/lib/toolbar/src/toolbar.js +332 -284
- package/lib/toolbar/src/toolbar.min.js +1 -1
- package/lib/toolbar/style/style.css +0 -1
- package/lib/toolbar/style/style.min.css +1 -1
- package/lib/ui/index.js +50 -41
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/comp.js +2 -3
- package/lib/ui/src/comp.min.js +1 -1
- package/lib/ui/src/dom.js +29 -28
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +6 -4
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/utils.js +7 -7
- package/lib/v-x-e-table/index.js +3 -4
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/vxe-colgroup/index.js +3 -4
- package/lib/vxe-colgroup/index.min.js +1 -1
- package/lib/vxe-column/index.js +3 -4
- package/lib/vxe-column/index.min.js +1 -1
- package/lib/vxe-grid/index.js +3 -4
- package/lib/vxe-grid/index.min.js +1 -1
- package/lib/vxe-grid/style/style.css +0 -1
- package/lib/vxe-grid/style/style.min.css +1 -1
- package/lib/vxe-table/index.js +3 -4
- package/lib/vxe-table/index.min.js +1 -1
- package/lib/vxe-table/style/style.css +37 -48
- package/lib/vxe-table/style/style.min.css +1 -1
- package/lib/vxe-toolbar/index.js +3 -4
- package/lib/vxe-toolbar/index.min.js +1 -1
- package/lib/vxe-toolbar/style/style.css +0 -1
- package/lib/vxe-toolbar/style/style.min.css +1 -1
- package/lib/vxe-ui/index.js +3 -4
- package/lib/vxe-ui/index.min.js +1 -1
- package/lib/vxe-v-x-e-table/index.js +3 -4
- package/lib/vxe-v-x-e-table/index.min.js +1 -1
- package/package.json +5 -4
- package/packages/grid/src/grid.ts +127 -65
- package/packages/locale/lang/en-US.ts +2 -1
- package/packages/locale/lang/es-ES.ts +2 -1
- package/packages/locale/lang/hu-HU.ts +2 -1
- package/packages/locale/lang/ja-JP.ts +2 -1
- package/packages/locale/lang/ko-KR.ts +2 -1
- package/packages/locale/lang/pt-BR.ts +2 -1
- package/packages/locale/lang/ru-RU.ts +2 -1
- package/packages/locale/lang/uk-UA.ts +2 -1
- package/packages/locale/lang/vi-VN.ts +2 -1
- package/packages/locale/lang/zh-CHT.ts +2 -1
- package/packages/locale/lang/zh-CN.ts +2 -1
- package/packages/table/module/custom/panel.ts +186 -175
- package/packages/table/module/edit/mixin.ts +32 -23
- package/packages/table/module/export/export-panel.ts +36 -4
- package/packages/table/module/export/import-panel.ts +29 -6
- package/packages/table/module/export/mixin.ts +11 -11
- package/packages/table/module/menu/mixin.ts +2 -2
- package/packages/table/module/validator/mixin.ts +4 -4
- package/packages/table/render/index.ts +20 -11
- package/packages/table/src/body.ts +1 -0
- package/packages/table/src/columnInfo.ts +3 -3
- package/packages/table/src/methods.ts +53 -42
- package/packages/table/src/props.ts +68 -15
- package/packages/table/src/table.ts +99 -54
- package/packages/table/src/util.ts +3 -2
- package/packages/toolbar/src/toolbar.ts +21 -7
- package/packages/ui/index.ts +3 -1
- package/styles/components/table.scss +82 -17
- package/types/all.d.ts +1 -0
- /package/es/{iconfont.1726453742001.ttf → iconfont.1728348263835.ttf} +0 -0
- /package/es/{iconfont.1726453742001.woff → iconfont.1728348263835.woff} +0 -0
- /package/es/{iconfont.1726453742001.woff2 → iconfont.1728348263835.woff2} +0 -0
- /package/lib/{iconfont.1726453742001.ttf → iconfont.1728348263835.ttf} +0 -0
- /package/lib/{iconfont.1726453742001.woff → iconfont.1728348263835.woff} +0 -0
- /package/lib/{iconfont.1726453742001.woff2 → iconfont.1728348263835.woff2} +0 -0
|
@@ -15,43 +15,39 @@ var _dom = require("../../../ui/src/dom");
|
|
|
15
15
|
var _util2 = require("./util");
|
|
16
16
|
var _log = require("../../../ui/src/log");
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
24
|
-
var getI18n = _ui.VxeUI.getI18n,
|
|
25
|
-
renderer = _ui.VxeUI.renderer;
|
|
26
|
-
var htmlCellElem;
|
|
18
|
+
const {
|
|
19
|
+
getI18n,
|
|
20
|
+
renderer
|
|
21
|
+
} = _ui.VxeUI;
|
|
22
|
+
let htmlCellElem;
|
|
27
23
|
// 导入
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
let fileForm;
|
|
25
|
+
let fileInput;
|
|
30
26
|
// 打印
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
let printFrame;
|
|
28
|
+
const csvBOM = '\ufeff';
|
|
29
|
+
const enterSymbol = '\r\n';
|
|
34
30
|
function createFrame() {
|
|
35
|
-
|
|
31
|
+
const frame = document.createElement('iframe');
|
|
36
32
|
frame.className = 'vxe-table--print-frame';
|
|
37
33
|
return frame;
|
|
38
34
|
}
|
|
39
35
|
function hasTreeChildren($xetable, row) {
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const treeOpts = $xetable.treeOpts;
|
|
37
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
42
38
|
return row[childrenField] && row[childrenField].length > 0;
|
|
43
39
|
}
|
|
44
40
|
function getSeq($xetable, cellValue, row, $rowIndex, column, $columnIndex) {
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const seqOpts = $xetable.seqOpts;
|
|
42
|
+
const seqMethod = seqOpts.seqMethod || column.seqMethod;
|
|
47
43
|
if (seqMethod) {
|
|
48
44
|
return seqMethod({
|
|
49
|
-
row
|
|
45
|
+
row,
|
|
50
46
|
rowIndex: $xetable.getRowIndex(row),
|
|
51
|
-
$rowIndex
|
|
52
|
-
column
|
|
47
|
+
$rowIndex,
|
|
48
|
+
column,
|
|
53
49
|
columnIndex: $xetable.getColumnIndex(column),
|
|
54
|
-
$columnIndex
|
|
50
|
+
$columnIndex
|
|
55
51
|
});
|
|
56
52
|
}
|
|
57
53
|
return cellValue;
|
|
@@ -72,38 +68,42 @@ function toBooleanValue(cellValue) {
|
|
|
72
68
|
return _xeUtils.default.isBoolean(cellValue) ? cellValue ? 'TRUE' : 'FALSE' : cellValue;
|
|
73
69
|
}
|
|
74
70
|
function getLabelData($xetable, opts, columns, datas) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
const {
|
|
72
|
+
isAllExpand,
|
|
73
|
+
mode
|
|
74
|
+
} = opts;
|
|
75
|
+
const {
|
|
76
|
+
treeConfig,
|
|
77
|
+
treeOpts,
|
|
78
|
+
radioOpts,
|
|
79
|
+
checkboxOpts,
|
|
80
|
+
columnOpts
|
|
81
|
+
} = $xetable;
|
|
82
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
83
83
|
if (!htmlCellElem) {
|
|
84
84
|
htmlCellElem = document.createElement('div');
|
|
85
85
|
}
|
|
86
86
|
if (treeConfig) {
|
|
87
87
|
// 如果是树表格只允许导出数据源
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_xeUtils.default.eachTree(datas,
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const rest = [];
|
|
89
|
+
const expandMaps = new Map();
|
|
90
|
+
_xeUtils.default.eachTree(datas, (item, $rowIndex, items, path, parent, nodes) => {
|
|
91
|
+
const row = item._row || item;
|
|
92
|
+
const parentRow = parent && parent._row ? parent._row : parent;
|
|
93
93
|
if (isAllExpand || !parentRow || expandMaps.has(parentRow) && $xetable.isTreeExpandByRow(parentRow)) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const hasRowChild = hasTreeChildren($xetable, row);
|
|
95
|
+
const item = {
|
|
96
96
|
_row: row,
|
|
97
97
|
_level: nodes.length - 1,
|
|
98
98
|
_hasChild: hasRowChild,
|
|
99
99
|
_expand: hasRowChild && $xetable.isTreeExpandByRow(row)
|
|
100
100
|
};
|
|
101
|
-
columns.forEach(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
columns.forEach((column, $columnIndex) => {
|
|
102
|
+
let cellValue = '';
|
|
103
|
+
const renderOpts = column.editRender || column.cellRender;
|
|
104
|
+
let bodyExportMethod = column.exportMethod;
|
|
105
105
|
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
106
|
-
|
|
106
|
+
const compConf = renderer.get(renderOpts.name);
|
|
107
107
|
if (compConf) {
|
|
108
108
|
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod || compConf.cellExportMethod;
|
|
109
109
|
}
|
|
@@ -114,32 +114,30 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
114
114
|
if (bodyExportMethod) {
|
|
115
115
|
cellValue = bodyExportMethod({
|
|
116
116
|
$table: $xetable,
|
|
117
|
-
row
|
|
118
|
-
column
|
|
117
|
+
row,
|
|
118
|
+
column,
|
|
119
119
|
options: opts
|
|
120
120
|
});
|
|
121
121
|
} else {
|
|
122
122
|
switch (column.type) {
|
|
123
123
|
case 'seq':
|
|
124
124
|
{
|
|
125
|
-
|
|
126
|
-
return i % 2 === 0 ? Number(num) + 1 : '.';
|
|
127
|
-
}).join('');
|
|
125
|
+
const seqValue = path.map((num, i) => i % 2 === 0 ? Number(num) + 1 : '.').join('');
|
|
128
126
|
cellValue = mode === 'all' ? seqValue : getSeq($xetable, seqValue, row, $rowIndex, column, $columnIndex);
|
|
129
127
|
break;
|
|
130
128
|
}
|
|
131
129
|
case 'checkbox':
|
|
132
130
|
cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row));
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
row
|
|
131
|
+
item._checkboxLabel = checkboxOpts.labelField ? _xeUtils.default.get(row, checkboxOpts.labelField) : '';
|
|
132
|
+
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({
|
|
133
|
+
row
|
|
136
134
|
});
|
|
137
135
|
break;
|
|
138
136
|
case 'radio':
|
|
139
137
|
cellValue = toBooleanValue($xetable.isCheckedByRadioRow(row));
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
row
|
|
138
|
+
item._radioLabel = radioOpts.labelField ? _xeUtils.default.get(row, radioOpts.labelField) : '';
|
|
139
|
+
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({
|
|
140
|
+
row
|
|
143
141
|
});
|
|
144
142
|
break;
|
|
145
143
|
default:
|
|
@@ -151,7 +149,7 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
151
149
|
htmlCellElem.innerHTML = cellValue;
|
|
152
150
|
cellValue = htmlCellElem.innerText.trim();
|
|
153
151
|
} else {
|
|
154
|
-
|
|
152
|
+
const cell = $xetable.getCellElement(row, column);
|
|
155
153
|
if (cell) {
|
|
156
154
|
cellValue = cell.innerText.trim();
|
|
157
155
|
}
|
|
@@ -159,26 +157,26 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
|
-
|
|
160
|
+
item[column.id] = _xeUtils.default.toValueString(cellValue);
|
|
163
161
|
});
|
|
164
162
|
expandMaps.set(row, 1);
|
|
165
|
-
rest.push(Object.assign(
|
|
163
|
+
rest.push(Object.assign(item, row));
|
|
166
164
|
}
|
|
167
165
|
}, {
|
|
168
166
|
children: childrenField
|
|
169
167
|
});
|
|
170
168
|
return rest;
|
|
171
169
|
}
|
|
172
|
-
return datas.map(
|
|
173
|
-
|
|
170
|
+
return datas.map((row, $rowIndex) => {
|
|
171
|
+
const item = {
|
|
174
172
|
_row: row
|
|
175
173
|
};
|
|
176
|
-
columns.forEach(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
columns.forEach((column, $columnIndex) => {
|
|
175
|
+
let cellValue = '';
|
|
176
|
+
const renderOpts = column.editRender || column.cellRender;
|
|
177
|
+
let exportLabelMethod = column.exportMethod;
|
|
180
178
|
if (!exportLabelMethod && renderOpts && renderOpts.name) {
|
|
181
|
-
|
|
179
|
+
const compConf = renderer.get(renderOpts.name);
|
|
182
180
|
if (compConf) {
|
|
183
181
|
exportLabelMethod = compConf.tableExportMethod || compConf.exportMethod || compConf.cellExportMethod;
|
|
184
182
|
}
|
|
@@ -186,15 +184,15 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
186
184
|
if (exportLabelMethod) {
|
|
187
185
|
cellValue = exportLabelMethod({
|
|
188
186
|
$table: $xetable,
|
|
189
|
-
row
|
|
190
|
-
column
|
|
187
|
+
row,
|
|
188
|
+
column,
|
|
191
189
|
options: opts
|
|
192
190
|
});
|
|
193
191
|
} else {
|
|
194
192
|
switch (column.type) {
|
|
195
193
|
case 'seq':
|
|
196
194
|
{
|
|
197
|
-
|
|
195
|
+
const seqValue = $rowIndex + 1;
|
|
198
196
|
cellValue = mode === 'all' ? seqValue : getSeq($xetable, seqValue, row, $rowIndex, column, $columnIndex);
|
|
199
197
|
break;
|
|
200
198
|
}
|
|
@@ -202,14 +200,14 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
202
200
|
cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row));
|
|
203
201
|
item._checkboxLabel = checkboxOpts.labelField ? _xeUtils.default.get(row, checkboxOpts.labelField) : '';
|
|
204
202
|
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({
|
|
205
|
-
row
|
|
203
|
+
row
|
|
206
204
|
});
|
|
207
205
|
break;
|
|
208
206
|
case 'radio':
|
|
209
207
|
cellValue = toBooleanValue($xetable.isCheckedByRadioRow(row));
|
|
210
208
|
item._radioLabel = radioOpts.labelField ? _xeUtils.default.get(row, radioOpts.labelField) : '';
|
|
211
209
|
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({
|
|
212
|
-
row
|
|
210
|
+
row
|
|
213
211
|
});
|
|
214
212
|
break;
|
|
215
213
|
default:
|
|
@@ -221,7 +219,7 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
221
219
|
htmlCellElem.innerHTML = cellValue;
|
|
222
220
|
cellValue = htmlCellElem.innerText.trim();
|
|
223
221
|
} else {
|
|
224
|
-
|
|
222
|
+
const cell = $xetable.getCellElement(row, column);
|
|
225
223
|
if (cell) {
|
|
226
224
|
cellValue = cell.innerText.trim();
|
|
227
225
|
}
|
|
@@ -235,16 +233,16 @@ function getLabelData($xetable, opts, columns, datas) {
|
|
|
235
233
|
});
|
|
236
234
|
}
|
|
237
235
|
function getExportData($xetable, opts) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
const {
|
|
237
|
+
columns,
|
|
238
|
+
dataFilterMethod
|
|
239
|
+
} = opts;
|
|
240
|
+
let datas = opts.data;
|
|
241
241
|
if (dataFilterMethod) {
|
|
242
|
-
datas = datas.filter(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
});
|
|
242
|
+
datas = datas.filter((row, index) => dataFilterMethod({
|
|
243
|
+
row,
|
|
244
|
+
$rowIndex: index
|
|
245
|
+
}));
|
|
248
246
|
}
|
|
249
247
|
return getLabelData($xetable, opts, columns, datas);
|
|
250
248
|
}
|
|
@@ -252,20 +250,24 @@ function getBooleanValue(cellValue) {
|
|
|
252
250
|
return cellValue === 'TRUE' || cellValue === 'true' || cellValue === true;
|
|
253
251
|
}
|
|
254
252
|
function getHeaderTitle($xetable, opts, column) {
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
const {
|
|
254
|
+
columnOpts
|
|
255
|
+
} = $xetable;
|
|
256
|
+
const headExportMethod = column.headerExportMethod || columnOpts.headerExportMethod;
|
|
257
257
|
return headExportMethod ? headExportMethod({
|
|
258
|
-
column
|
|
258
|
+
column,
|
|
259
259
|
options: opts,
|
|
260
260
|
$table: $xetable
|
|
261
261
|
}) : (opts.original ? column.property : column.getTitle()) || '';
|
|
262
262
|
}
|
|
263
263
|
function getFooterCellValue($xetable, opts, row, column) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
const {
|
|
265
|
+
columnOpts
|
|
266
|
+
} = $xetable;
|
|
267
|
+
const renderOpts = column.editRender || column.cellRender;
|
|
268
|
+
let footLabelMethod = column.footerExportMethod;
|
|
267
269
|
if (!footLabelMethod && renderOpts && renderOpts.name) {
|
|
268
|
-
|
|
270
|
+
const compConf = renderer.get(renderOpts.name);
|
|
269
271
|
if (compConf) {
|
|
270
272
|
footLabelMethod = compConf.tableFooterExportMethod || compConf.footerExportMethod || compConf.footerCellExportMethod;
|
|
271
273
|
}
|
|
@@ -273,15 +275,15 @@ function getFooterCellValue($xetable, opts, row, column) {
|
|
|
273
275
|
if (!footLabelMethod) {
|
|
274
276
|
footLabelMethod = columnOpts.footerExportMethod;
|
|
275
277
|
}
|
|
276
|
-
|
|
278
|
+
const _columnIndex = $xetable.getVTColumnIndex(column);
|
|
277
279
|
if (footLabelMethod) {
|
|
278
280
|
return footLabelMethod({
|
|
279
281
|
$table: $xetable,
|
|
280
282
|
items: row,
|
|
281
283
|
itemIndex: _columnIndex,
|
|
282
|
-
row
|
|
283
|
-
_columnIndex
|
|
284
|
-
column
|
|
284
|
+
row,
|
|
285
|
+
_columnIndex,
|
|
286
|
+
column,
|
|
285
287
|
options: opts
|
|
286
288
|
});
|
|
287
289
|
}
|
|
@@ -292,30 +294,30 @@ function getFooterCellValue($xetable, opts, row, column) {
|
|
|
292
294
|
return _xeUtils.default.get(row, column.field);
|
|
293
295
|
}
|
|
294
296
|
function getFooterData(opts, footerTableData) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}) : footerTableData;
|
|
297
|
+
const {
|
|
298
|
+
footerFilterMethod
|
|
299
|
+
} = opts;
|
|
300
|
+
return footerFilterMethod ? footerTableData.filter((items, index) => footerFilterMethod({
|
|
301
|
+
items,
|
|
302
|
+
$rowIndex: index
|
|
303
|
+
})) : footerTableData;
|
|
302
304
|
}
|
|
303
305
|
function getCsvCellTypeLabel(column, cellValue) {
|
|
304
306
|
if (cellValue) {
|
|
305
307
|
if (column.type === 'seq') {
|
|
306
|
-
return
|
|
308
|
+
return `\t${cellValue}`;
|
|
307
309
|
}
|
|
308
310
|
switch (column.cellType) {
|
|
309
311
|
case 'string':
|
|
310
312
|
if (!isNaN(cellValue)) {
|
|
311
|
-
return
|
|
313
|
+
return `\t${cellValue}`;
|
|
312
314
|
}
|
|
313
315
|
break;
|
|
314
316
|
case 'number':
|
|
315
317
|
break;
|
|
316
318
|
default:
|
|
317
319
|
if (cellValue.length >= 12 && !isNaN(cellValue)) {
|
|
318
|
-
return
|
|
320
|
+
return `\t${cellValue}`;
|
|
319
321
|
}
|
|
320
322
|
break;
|
|
321
323
|
}
|
|
@@ -324,63 +326,51 @@ function getCsvCellTypeLabel(column, cellValue) {
|
|
|
324
326
|
}
|
|
325
327
|
function toTxtCellLabel(val) {
|
|
326
328
|
if (/[",\s\n]/.test(val)) {
|
|
327
|
-
return "
|
|
329
|
+
return `"${val.replace(/"/g, '""')}"`;
|
|
328
330
|
}
|
|
329
331
|
return val;
|
|
330
332
|
}
|
|
331
333
|
function toCsv($xetable, opts, columns, datas) {
|
|
332
|
-
|
|
334
|
+
let content = csvBOM;
|
|
333
335
|
if (opts.isHeader) {
|
|
334
|
-
content += columns.map(
|
|
335
|
-
return toTxtCellLabel(getHeaderTitle($xetable, opts, column));
|
|
336
|
-
}).join(',') + enterSymbol;
|
|
336
|
+
content += columns.map(column => toTxtCellLabel(getHeaderTitle($xetable, opts, column))).join(',') + enterSymbol;
|
|
337
337
|
}
|
|
338
|
-
datas.forEach(
|
|
339
|
-
content += columns.map(
|
|
340
|
-
return toTxtCellLabel(getCsvCellTypeLabel(column, row[column.id]));
|
|
341
|
-
}).join(',') + enterSymbol;
|
|
338
|
+
datas.forEach(row => {
|
|
339
|
+
content += columns.map(column => toTxtCellLabel(getCsvCellTypeLabel(column, row[column.id]))).join(',') + enterSymbol;
|
|
342
340
|
});
|
|
343
341
|
if (opts.isFooter) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
footers.forEach(
|
|
347
|
-
content += columns.map(
|
|
348
|
-
return toTxtCellLabel(getFooterCellValue($xetable, opts, row, column));
|
|
349
|
-
}).join(',') + enterSymbol;
|
|
342
|
+
const footerTableData = $xetable.footerTableData;
|
|
343
|
+
const footers = getFooterData(opts, footerTableData);
|
|
344
|
+
footers.forEach(row => {
|
|
345
|
+
content += columns.map(column => toTxtCellLabel(getFooterCellValue($xetable, opts, row, column))).join(',') + enterSymbol;
|
|
350
346
|
});
|
|
351
347
|
}
|
|
352
348
|
return content;
|
|
353
349
|
}
|
|
354
350
|
function toTxt($xetable, opts, columns, datas) {
|
|
355
|
-
|
|
351
|
+
let content = '';
|
|
356
352
|
if (opts.isHeader) {
|
|
357
|
-
content += columns.map(
|
|
358
|
-
return toTxtCellLabel(getHeaderTitle($xetable, opts, column));
|
|
359
|
-
}).join('\t') + enterSymbol;
|
|
353
|
+
content += columns.map(column => toTxtCellLabel(getHeaderTitle($xetable, opts, column))).join('\t') + enterSymbol;
|
|
360
354
|
}
|
|
361
|
-
datas.forEach(
|
|
362
|
-
content += columns.map(
|
|
363
|
-
return toTxtCellLabel(row[column.id]);
|
|
364
|
-
}).join('\t') + enterSymbol;
|
|
355
|
+
datas.forEach(row => {
|
|
356
|
+
content += columns.map(column => toTxtCellLabel(row[column.id])).join('\t') + enterSymbol;
|
|
365
357
|
});
|
|
366
358
|
if (opts.isFooter) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
footers.forEach(
|
|
370
|
-
content += columns.map(
|
|
371
|
-
return toTxtCellLabel(getFooterCellValue($xetable, opts, row, column));
|
|
372
|
-
}).join(',') + enterSymbol;
|
|
359
|
+
const footerTableData = $xetable.footerTableData;
|
|
360
|
+
const footers = getFooterData(opts, footerTableData);
|
|
361
|
+
footers.forEach(row => {
|
|
362
|
+
content += columns.map(column => toTxtCellLabel(getFooterCellValue($xetable, opts, row, column))).join(',') + enterSymbol;
|
|
373
363
|
});
|
|
374
364
|
}
|
|
375
365
|
return content;
|
|
376
366
|
}
|
|
377
367
|
function hasEllipsis($xetable, column, property, allColumnOverflow) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
368
|
+
const columnOverflow = column[property];
|
|
369
|
+
const headOverflow = _xeUtils.default.isUndefined(columnOverflow) || _xeUtils.default.isNull(columnOverflow) ? allColumnOverflow : columnOverflow;
|
|
370
|
+
const showEllipsis = headOverflow === 'ellipsis';
|
|
371
|
+
const showTitle = headOverflow === 'title';
|
|
372
|
+
const showTooltip = headOverflow === true || headOverflow === 'tooltip';
|
|
373
|
+
let isEllipsis = showTitle || showTooltip || showEllipsis;
|
|
384
374
|
// 虚拟滚动不支持动态高度
|
|
385
375
|
if (($xetable.scrollXLoad || $xetable.scrollYLoad) && !isEllipsis) {
|
|
386
376
|
isEllipsis = true;
|
|
@@ -388,43 +378,43 @@ function hasEllipsis($xetable, column, property, allColumnOverflow) {
|
|
|
388
378
|
return isEllipsis;
|
|
389
379
|
}
|
|
390
380
|
function toHtml($xetable, opts, columns, datas) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
381
|
+
const {
|
|
382
|
+
id,
|
|
383
|
+
border,
|
|
384
|
+
treeConfig,
|
|
385
|
+
treeOpts,
|
|
386
|
+
isAllSelected,
|
|
387
|
+
isIndeterminate,
|
|
388
|
+
headerAlign: allHeaderAlign,
|
|
389
|
+
align: allAlign,
|
|
390
|
+
footerAlign: allFooterAlign,
|
|
391
|
+
showOverflow: allColumnOverflow,
|
|
392
|
+
showHeaderOverflow: allColumnHeaderOverflow,
|
|
393
|
+
mergeList
|
|
394
|
+
} = $xetable;
|
|
395
|
+
const {
|
|
396
|
+
print: isPrint,
|
|
397
|
+
isHeader,
|
|
398
|
+
isFooter,
|
|
399
|
+
isColgroup,
|
|
400
|
+
isMerge,
|
|
401
|
+
colgroups,
|
|
402
|
+
original
|
|
403
|
+
} = opts;
|
|
404
|
+
const allCls = 'check-all';
|
|
405
|
+
const clss = ['vxe-table', `border--${toTableBorder(border)}`, isPrint ? 'is--print' : '', isHeader ? 'is--header' : ''].filter(cls => cls);
|
|
406
|
+
const tables = [`<table class="${clss.join(' ')}" border="0" cellspacing="0" cellpadding="0">`, `<colgroup>${columns.map(column => `<col style="width:${column.renderWidth}px">`).join('')}</colgroup>`];
|
|
417
407
|
if (isHeader) {
|
|
418
408
|
tables.push('<thead>');
|
|
419
409
|
if (isColgroup && !original) {
|
|
420
|
-
colgroups.forEach(
|
|
421
|
-
tables.push(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
_xeUtils.default.eachTree([column],
|
|
410
|
+
colgroups.forEach(cols => {
|
|
411
|
+
tables.push(`<tr>${cols.map(column => {
|
|
412
|
+
const headAlign = column.headerAlign || column.align || allHeaderAlign || allAlign;
|
|
413
|
+
const classNames = hasEllipsis($xetable, column, 'showHeaderOverflow', allColumnHeaderOverflow) ? ['col--ellipsis'] : [];
|
|
414
|
+
const cellTitle = getHeaderTitle($xetable, opts, column);
|
|
415
|
+
let childWidth = 0;
|
|
416
|
+
let countChild = 0;
|
|
417
|
+
_xeUtils.default.eachTree([column], item => {
|
|
428
418
|
if (!item.childNodes || !column.childNodes.length) {
|
|
429
419
|
countChild++;
|
|
430
420
|
}
|
|
@@ -432,79 +422,81 @@ function toHtml($xetable, opts, columns, datas) {
|
|
|
432
422
|
}, {
|
|
433
423
|
children: 'childNodes'
|
|
434
424
|
});
|
|
435
|
-
|
|
425
|
+
const cellWidth = childWidth - countChild;
|
|
436
426
|
if (headAlign) {
|
|
437
|
-
classNames.push(
|
|
427
|
+
classNames.push(`col--${headAlign}`);
|
|
438
428
|
}
|
|
439
429
|
if (column.type === 'checkbox') {
|
|
440
|
-
return
|
|
430
|
+
return `<th class="${classNames.join(' ')}" colspan="${column._colSpan}" rowspan="${column._rowSpan}"><div ${isPrint ? '' : `style="width: ${cellWidth}px"`}><input type="checkbox" class="${allCls}" ${isAllSelected ? 'checked' : ''}><span>${cellTitle}</span></div></th>`;
|
|
441
431
|
}
|
|
442
|
-
return
|
|
443
|
-
}).join('')
|
|
432
|
+
return `<th class="${classNames.join(' ')}" colspan="${column._colSpan}" rowspan="${column._rowSpan}" title="${cellTitle}"><div ${isPrint ? '' : `style="width: ${cellWidth}px"`}><span>${(0, _utils.formatText)(cellTitle, true)}</span></div></th>`;
|
|
433
|
+
}).join('')}</tr>`);
|
|
444
434
|
});
|
|
445
435
|
} else {
|
|
446
|
-
tables.push(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
436
|
+
tables.push(`<tr>${columns.map(column => {
|
|
437
|
+
const headAlign = column.headerAlign || column.align || allHeaderAlign || allAlign;
|
|
438
|
+
const classNames = hasEllipsis($xetable, column, 'showHeaderOverflow', allColumnHeaderOverflow) ? ['col--ellipsis'] : [];
|
|
439
|
+
const cellTitle = getHeaderTitle($xetable, opts, column);
|
|
450
440
|
if (headAlign) {
|
|
451
|
-
classNames.push(
|
|
441
|
+
classNames.push(`col--${headAlign}`);
|
|
452
442
|
}
|
|
453
443
|
if (column.type === 'checkbox') {
|
|
454
|
-
return
|
|
444
|
+
return `<th class="${classNames.join(' ')}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><input type="checkbox" class="${allCls}" ${isAllSelected ? 'checked' : ''}><span>${cellTitle}</span></div></th>`;
|
|
455
445
|
}
|
|
456
|
-
return
|
|
457
|
-
}).join('')
|
|
446
|
+
return `<th class="${classNames.join(' ')}" title="${cellTitle}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><span>${(0, _utils.formatText)(cellTitle, true)}</span></div></th>`;
|
|
447
|
+
}).join('')}</tr>`);
|
|
458
448
|
}
|
|
459
449
|
tables.push('</thead>');
|
|
460
450
|
}
|
|
461
451
|
if (datas.length) {
|
|
462
452
|
tables.push('<tbody>');
|
|
463
453
|
if (treeConfig) {
|
|
464
|
-
datas.forEach(
|
|
465
|
-
tables.push('<tr>' + columns.map(
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
454
|
+
datas.forEach(item => {
|
|
455
|
+
tables.push('<tr>' + columns.map(column => {
|
|
456
|
+
const cellAlign = column.align || allAlign;
|
|
457
|
+
const classNames = hasEllipsis($xetable, column, 'showOverflow', allColumnOverflow) ? ['col--ellipsis'] : [];
|
|
458
|
+
const cellValue = item[column.id];
|
|
469
459
|
if (cellAlign) {
|
|
470
|
-
classNames.push(
|
|
460
|
+
classNames.push(`col--${cellAlign}`);
|
|
471
461
|
}
|
|
472
462
|
if (column.treeNode) {
|
|
473
|
-
|
|
463
|
+
let treeIcon = '';
|
|
474
464
|
if (item._hasChild) {
|
|
475
|
-
treeIcon =
|
|
465
|
+
treeIcon = `<i class="${item._expand ? 'vxe-table--tree-fold-icon' : 'vxe-table--tree-unfold-icon'}"></i>`;
|
|
476
466
|
}
|
|
477
467
|
classNames.push('vxe-table--tree-node');
|
|
478
468
|
if (column.type === 'radio') {
|
|
479
|
-
return
|
|
469
|
+
return `<td class="${classNames.join(' ')}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><div class="vxe-table--tree-node-wrapper" style="padding-left: ${item._level * treeOpts.indent}px"><div class="vxe-table--tree-icon-wrapper">${treeIcon}</div><div class="vxe-table--tree-cell"><input type="radio" name="radio_${id}" ${item._radioDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._radioLabel}</span></div></div></div></td>`;
|
|
480
470
|
} else if (column.type === 'checkbox') {
|
|
481
|
-
return
|
|
471
|
+
return `<td class="${classNames.join(' ')}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><div class="vxe-table--tree-node-wrapper" style="padding-left: ${item._level * treeOpts.indent}px"><div class="vxe-table--tree-icon-wrapper">${treeIcon}</div><div class="vxe-table--tree-cell"><input type="checkbox" ${item._checkboxDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._checkboxLabel}</span></div></div></div></td>`;
|
|
482
472
|
}
|
|
483
|
-
return
|
|
473
|
+
return `<td class="${classNames.join(' ')}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><div class="vxe-table--tree-node-wrapper" style="padding-left: ${item._level * treeOpts.indent}px"><div class="vxe-table--tree-icon-wrapper">${treeIcon}</div><div class="vxe-table--tree-cell">${cellValue}</div></div></div></td>`;
|
|
484
474
|
}
|
|
485
475
|
if (column.type === 'radio') {
|
|
486
|
-
return
|
|
476
|
+
return `<td class="${classNames.join(' ')}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><input type="radio" name="radio_${id}" ${item._radioDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._radioLabel}</span></div></td>`;
|
|
487
477
|
} else if (column.type === 'checkbox') {
|
|
488
|
-
return
|
|
478
|
+
return `<td class="${classNames.join(' ')}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><input type="checkbox" ${item._checkboxDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._checkboxLabel}</span></div></td>`;
|
|
489
479
|
}
|
|
490
|
-
return
|
|
480
|
+
return `<td class="${classNames.join(' ')}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}>${(0, _utils.formatText)(cellValue, true)}</div></td>`;
|
|
491
481
|
}).join('') + '</tr>');
|
|
492
482
|
});
|
|
493
483
|
} else {
|
|
494
|
-
datas.forEach(
|
|
495
|
-
tables.push('<tr>' + columns.map(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
484
|
+
datas.forEach(item => {
|
|
485
|
+
tables.push('<tr>' + columns.map(column => {
|
|
486
|
+
const cellAlign = column.align || allAlign;
|
|
487
|
+
const classNames = hasEllipsis($xetable, column, 'showOverflow', allColumnOverflow) ? ['col--ellipsis'] : [];
|
|
488
|
+
const cellValue = item[column.id];
|
|
489
|
+
let rowSpan = 1;
|
|
490
|
+
let colSpan = 1;
|
|
501
491
|
if (isMerge && mergeList.length) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
492
|
+
const _rowIndex = $xetable.getVTRowIndex(item._row);
|
|
493
|
+
const _columnIndex = $xetable.getVTColumnIndex(column);
|
|
494
|
+
const spanRest = (0, _util.mergeBodyMethod)(mergeList, _rowIndex, _columnIndex);
|
|
505
495
|
if (spanRest) {
|
|
506
|
-
|
|
507
|
-
|
|
496
|
+
const {
|
|
497
|
+
rowspan,
|
|
498
|
+
colspan
|
|
499
|
+
} = spanRest;
|
|
508
500
|
if (!rowspan || !colspan) {
|
|
509
501
|
return '';
|
|
510
502
|
}
|
|
@@ -517,67 +509,59 @@ function toHtml($xetable, opts, columns, datas) {
|
|
|
517
509
|
}
|
|
518
510
|
}
|
|
519
511
|
if (cellAlign) {
|
|
520
|
-
classNames.push(
|
|
512
|
+
classNames.push(`col--${cellAlign}`);
|
|
521
513
|
}
|
|
522
514
|
if (column.type === 'radio') {
|
|
523
|
-
return
|
|
515
|
+
return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><input type="radio" name="radio_${id}" ${item._radioDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._radioLabel}</span></div></td>`;
|
|
524
516
|
} else if (column.type === 'checkbox') {
|
|
525
|
-
return
|
|
517
|
+
return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><input type="checkbox" ${item._checkboxDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._checkboxLabel}</span></div></td>`;
|
|
526
518
|
}
|
|
527
|
-
return
|
|
519
|
+
return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}>${(0, _utils.formatText)(cellValue, true)}</div></td>`;
|
|
528
520
|
}).join('') + '</tr>');
|
|
529
521
|
});
|
|
530
522
|
}
|
|
531
523
|
tables.push('</tbody>');
|
|
532
524
|
}
|
|
533
525
|
if (isFooter) {
|
|
534
|
-
|
|
535
|
-
|
|
526
|
+
const footerTableData = $xetable.footerTableData;
|
|
527
|
+
const footers = getFooterData(opts, footerTableData);
|
|
536
528
|
if (footers.length) {
|
|
537
529
|
tables.push('<tfoot>');
|
|
538
|
-
footers.forEach(
|
|
539
|
-
tables.push(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
530
|
+
footers.forEach(row => {
|
|
531
|
+
tables.push(`<tr>${columns.map(column => {
|
|
532
|
+
const footAlign = column.footerAlign || column.align || allFooterAlign || allAlign;
|
|
533
|
+
const classNames = hasEllipsis($xetable, column, 'showOverflow', allColumnOverflow) ? ['col--ellipsis'] : [];
|
|
534
|
+
const cellValue = getFooterCellValue($xetable, opts, row, column);
|
|
543
535
|
if (footAlign) {
|
|
544
|
-
classNames.push(
|
|
536
|
+
classNames.push(`col--${footAlign}`);
|
|
545
537
|
}
|
|
546
|
-
return
|
|
547
|
-
}).join('')
|
|
538
|
+
return `<td class="${classNames.join(' ')}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}>${(0, _utils.formatText)(cellValue, true)}</div></td>`;
|
|
539
|
+
}).join('')}</tr>`);
|
|
548
540
|
});
|
|
549
541
|
tables.push('</tfoot>');
|
|
550
542
|
}
|
|
551
543
|
}
|
|
552
544
|
// 是否半选状态
|
|
553
|
-
|
|
545
|
+
const script = !isAllSelected && isIndeterminate ? `<script>(function(){var a=document.querySelector(".${allCls}");if(a){a.indeterminate=true}})()</script>` : '';
|
|
554
546
|
tables.push('</table>', script);
|
|
555
547
|
return isPrint ? tables.join('') : (0, _util2.createHtmlPage)(opts, tables.join(''));
|
|
556
548
|
}
|
|
557
549
|
function toXML($xetable, opts, columns, datas) {
|
|
558
|
-
|
|
559
|
-
return "<Column ss:Width=\"".concat(column.renderWidth, "\"/>");
|
|
560
|
-
}).join('')].join('');
|
|
550
|
+
let xml = ['<?xml version="1.0"?>', '<?mso-application progid="Excel.Sheet"?>', '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">', '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">', '<Version>16.00</Version>', '</DocumentProperties>', '<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">', '<WindowHeight>7920</WindowHeight>', '<WindowWidth>21570</WindowWidth>', '<WindowTopX>32767</WindowTopX>', '<WindowTopY>32767</WindowTopY>', '<ProtectStructure>False</ProtectStructure>', '<ProtectWindows>False</ProtectWindows>', '</ExcelWorkbook>', `<Worksheet ss:Name="${opts.sheetName}">`, '<Table>', columns.map(column => `<Column ss:Width="${column.renderWidth}"/>`).join('')].join('');
|
|
561
551
|
if (opts.isHeader) {
|
|
562
|
-
xml +=
|
|
563
|
-
return "<Cell><Data ss:Type=\"String\">".concat(getHeaderTitle($xetable, opts, column), "</Data></Cell>");
|
|
564
|
-
}).join(''), "</Row>");
|
|
552
|
+
xml += `<Row>${columns.map(column => `<Cell><Data ss:Type="String">${getHeaderTitle($xetable, opts, column)}</Data></Cell>`).join('')}</Row>`;
|
|
565
553
|
}
|
|
566
|
-
datas.forEach(
|
|
567
|
-
xml += '<Row>' + columns.map(
|
|
568
|
-
return "<Cell><Data ss:Type=\"String\">".concat(row[column.id], "</Data></Cell>");
|
|
569
|
-
}).join('') + '</Row>';
|
|
554
|
+
datas.forEach(row => {
|
|
555
|
+
xml += '<Row>' + columns.map(column => `<Cell><Data ss:Type="String">${row[column.id]}</Data></Cell>`).join('') + '</Row>';
|
|
570
556
|
});
|
|
571
557
|
if (opts.isFooter) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
footers.forEach(
|
|
575
|
-
xml +=
|
|
576
|
-
return "<Cell><Data ss:Type=\"String\">".concat(getFooterCellValue($xetable, opts, row, column), "</Data></Cell>");
|
|
577
|
-
}).join(''), "</Row>");
|
|
558
|
+
const footerTableData = $xetable.footerTableData;
|
|
559
|
+
const footers = getFooterData(opts, footerTableData);
|
|
560
|
+
footers.forEach(row => {
|
|
561
|
+
xml += `<Row>${columns.map(column => `<Cell><Data ss:Type="String">${getFooterCellValue($xetable, opts, row, column)}</Data></Cell>`).join('')}</Row>`;
|
|
578
562
|
});
|
|
579
563
|
}
|
|
580
|
-
return
|
|
564
|
+
return `${xml}</Table></Worksheet></Workbook>`;
|
|
581
565
|
}
|
|
582
566
|
function getContent($xetable, opts, columns, datas) {
|
|
583
567
|
if (columns.length) {
|
|
@@ -599,24 +583,26 @@ function getContent($xetable, opts, columns, datas) {
|
|
|
599
583
|
* @param {*} options 参数
|
|
600
584
|
*/
|
|
601
585
|
function saveLocalFile(options) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
586
|
+
const {
|
|
587
|
+
filename,
|
|
588
|
+
type,
|
|
589
|
+
content
|
|
590
|
+
} = options;
|
|
591
|
+
const name = `${filename}.${type}`;
|
|
606
592
|
if (window.Blob) {
|
|
607
|
-
|
|
593
|
+
const blob = content instanceof Blob ? content : (0, _util2.getExportBlobByContent)(_xeUtils.default.toValueString(content), options);
|
|
608
594
|
if (navigator.msSaveBlob) {
|
|
609
595
|
navigator.msSaveBlob(blob, name);
|
|
610
596
|
} else {
|
|
611
|
-
|
|
612
|
-
|
|
597
|
+
const url = URL.createObjectURL(blob);
|
|
598
|
+
const linkElem = document.createElement('a');
|
|
613
599
|
linkElem.target = '_blank';
|
|
614
600
|
linkElem.download = name;
|
|
615
601
|
linkElem.href = url;
|
|
616
602
|
document.body.appendChild(linkElem);
|
|
617
603
|
linkElem.click();
|
|
618
604
|
document.body.removeChild(linkElem);
|
|
619
|
-
requestAnimationFrame(
|
|
605
|
+
requestAnimationFrame(() => {
|
|
620
606
|
if (linkElem.parentNode) {
|
|
621
607
|
linkElem.parentNode.removeChild(linkElem);
|
|
622
608
|
}
|
|
@@ -628,25 +614,27 @@ function saveLocalFile(options) {
|
|
|
628
614
|
return Promise.reject(new Error(getI18n('vxe.error.notExp')));
|
|
629
615
|
}
|
|
630
616
|
function downloadFile($xetable, opts, content) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
617
|
+
const {
|
|
618
|
+
filename,
|
|
619
|
+
type,
|
|
620
|
+
download
|
|
621
|
+
} = opts;
|
|
634
622
|
if (!download) {
|
|
635
|
-
|
|
623
|
+
const blob = (0, _util2.getExportBlobByContent)(content, opts);
|
|
636
624
|
return Promise.resolve({
|
|
637
|
-
type
|
|
638
|
-
content
|
|
639
|
-
blob
|
|
625
|
+
type,
|
|
626
|
+
content,
|
|
627
|
+
blob
|
|
640
628
|
});
|
|
641
629
|
}
|
|
642
630
|
saveLocalFile({
|
|
643
|
-
filename
|
|
644
|
-
type
|
|
645
|
-
content
|
|
646
|
-
}).then(
|
|
631
|
+
filename,
|
|
632
|
+
type,
|
|
633
|
+
content
|
|
634
|
+
}).then(() => {
|
|
647
635
|
if (opts.message !== false) {
|
|
648
636
|
// 检测弹窗模块
|
|
649
|
-
if (process.env.
|
|
637
|
+
if (process.env.NODE_ENV === 'development') {
|
|
650
638
|
if (!_ui.VxeUI.modal) {
|
|
651
639
|
(0, _log.errLog)('vxe.error.reqModule', ['Modal']);
|
|
652
640
|
}
|
|
@@ -659,7 +647,7 @@ function downloadFile($xetable, opts, content) {
|
|
|
659
647
|
});
|
|
660
648
|
}
|
|
661
649
|
function clearColumnConvert(columns) {
|
|
662
|
-
_xeUtils.default.eachTree(columns,
|
|
650
|
+
_xeUtils.default.eachTree(columns, column => {
|
|
663
651
|
delete column._level;
|
|
664
652
|
delete column._colSpan;
|
|
665
653
|
delete column._rowSpan;
|
|
@@ -670,31 +658,33 @@ function clearColumnConvert(columns) {
|
|
|
670
658
|
});
|
|
671
659
|
}
|
|
672
660
|
function handleExport($xetable, opts) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
661
|
+
const {
|
|
662
|
+
remote,
|
|
663
|
+
columns,
|
|
664
|
+
colgroups,
|
|
665
|
+
exportMethod,
|
|
666
|
+
afterExportMethod
|
|
667
|
+
} = opts;
|
|
668
|
+
return new Promise(resolve => {
|
|
679
669
|
if (remote) {
|
|
680
|
-
|
|
670
|
+
const params = {
|
|
681
671
|
options: opts,
|
|
682
672
|
$table: $xetable,
|
|
683
673
|
$grid: $xetable.$xegrid
|
|
684
674
|
};
|
|
685
675
|
resolve(exportMethod ? exportMethod(params) : params);
|
|
686
676
|
} else {
|
|
687
|
-
|
|
677
|
+
const datas = getExportData($xetable, opts);
|
|
688
678
|
resolve($xetable.preventEvent(null, 'event.export', {
|
|
689
679
|
options: opts,
|
|
690
|
-
columns
|
|
691
|
-
colgroups
|
|
692
|
-
datas
|
|
693
|
-
},
|
|
680
|
+
columns,
|
|
681
|
+
colgroups,
|
|
682
|
+
datas
|
|
683
|
+
}, () => {
|
|
694
684
|
return downloadFile($xetable, opts, getContent($xetable, opts, columns, datas));
|
|
695
685
|
}));
|
|
696
686
|
}
|
|
697
|
-
}).then(
|
|
687
|
+
}).then(params => {
|
|
698
688
|
clearColumnConvert(columns);
|
|
699
689
|
if (!opts.print) {
|
|
700
690
|
if (afterExportMethod) {
|
|
@@ -709,7 +699,7 @@ function handleExport($xetable, opts) {
|
|
|
709
699
|
return Object.assign({
|
|
710
700
|
status: true
|
|
711
701
|
}, params);
|
|
712
|
-
}).catch(
|
|
702
|
+
}).catch(() => {
|
|
713
703
|
clearColumnConvert(columns);
|
|
714
704
|
if (!opts.print) {
|
|
715
705
|
if (afterExportMethod) {
|
|
@@ -721,7 +711,7 @@ function handleExport($xetable, opts) {
|
|
|
721
711
|
});
|
|
722
712
|
}
|
|
723
713
|
}
|
|
724
|
-
|
|
714
|
+
const params = {
|
|
725
715
|
status: false
|
|
726
716
|
};
|
|
727
717
|
return Promise.reject(params);
|
|
@@ -731,45 +721,39 @@ function getElementsByTagName(elem, qualifiedName) {
|
|
|
731
721
|
return elem.getElementsByTagName(qualifiedName);
|
|
732
722
|
}
|
|
733
723
|
function getTxtCellKey(now) {
|
|
734
|
-
return
|
|
724
|
+
return `#${now}@${_xeUtils.default.uniqueId()}`;
|
|
735
725
|
}
|
|
736
726
|
function replaceTxtCell(cell, vMaps) {
|
|
737
|
-
return cell.replace(/#\d+@\d+/g,
|
|
738
|
-
return _xeUtils.default.hasOwnProp(vMaps, key) ? vMaps[key] : key;
|
|
739
|
-
});
|
|
727
|
+
return cell.replace(/#\d+@\d+/g, key => _xeUtils.default.hasOwnProp(vMaps, key) ? vMaps[key] : key);
|
|
740
728
|
}
|
|
741
729
|
function getTxtCellValue(val, vMaps) {
|
|
742
|
-
|
|
743
|
-
return rest.replace(/^"+$/g,
|
|
744
|
-
return '"'.repeat(Math.ceil(qVal.length / 2));
|
|
745
|
-
});
|
|
730
|
+
const rest = replaceTxtCell(val, vMaps);
|
|
731
|
+
return rest.replace(/^"+$/g, qVal => '"'.repeat(Math.ceil(qVal.length / 2)));
|
|
746
732
|
}
|
|
747
733
|
function parseCsvAndTxt(columns, content, cellSeparator) {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
734
|
+
const list = content.split(enterSymbol);
|
|
735
|
+
const rows = [];
|
|
736
|
+
let fields = [];
|
|
751
737
|
if (list.length) {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
list.forEach(
|
|
738
|
+
const vMaps = {};
|
|
739
|
+
const now = Date.now();
|
|
740
|
+
list.forEach(rVal => {
|
|
755
741
|
if (rVal) {
|
|
756
|
-
|
|
757
|
-
rVal = rVal.replace(/("")|(\n)/g,
|
|
758
|
-
|
|
742
|
+
const item = {};
|
|
743
|
+
rVal = rVal.replace(/("")|(\n)/g, (text, dVal) => {
|
|
744
|
+
const key = getTxtCellKey(now);
|
|
759
745
|
vMaps[key] = dVal ? '"' : '\n';
|
|
760
746
|
return key;
|
|
761
|
-
}).replace(/"(.*?)"/g,
|
|
762
|
-
|
|
747
|
+
}).replace(/"(.*?)"/g, (text, cVal) => {
|
|
748
|
+
const key = getTxtCellKey(now);
|
|
763
749
|
vMaps[key] = replaceTxtCell(cVal, vMaps);
|
|
764
750
|
return key;
|
|
765
751
|
});
|
|
766
|
-
|
|
752
|
+
const cells = rVal.split(cellSeparator);
|
|
767
753
|
if (!fields.length) {
|
|
768
|
-
fields = cells.map(
|
|
769
|
-
return getTxtCellValue(val.trim(), vMaps);
|
|
770
|
-
});
|
|
754
|
+
fields = cells.map(val => getTxtCellValue(val.trim(), vMaps));
|
|
771
755
|
} else {
|
|
772
|
-
cells.forEach(
|
|
756
|
+
cells.forEach((val, colIndex) => {
|
|
773
757
|
if (colIndex < fields.length) {
|
|
774
758
|
item[fields[colIndex]] = getTxtCellValue(val, vMaps);
|
|
775
759
|
}
|
|
@@ -780,8 +764,8 @@ function parseCsvAndTxt(columns, content, cellSeparator) {
|
|
|
780
764
|
});
|
|
781
765
|
}
|
|
782
766
|
return {
|
|
783
|
-
fields
|
|
784
|
-
rows
|
|
767
|
+
fields,
|
|
768
|
+
rows
|
|
785
769
|
};
|
|
786
770
|
}
|
|
787
771
|
function parseCsv(columns, content) {
|
|
@@ -791,26 +775,26 @@ function parseTxt(columns, content) {
|
|
|
791
775
|
return parseCsvAndTxt(columns, content, '\t');
|
|
792
776
|
}
|
|
793
777
|
function parseHTML(columns, content) {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
778
|
+
const domParser = new DOMParser();
|
|
779
|
+
const xmlDoc = domParser.parseFromString(content, 'text/html');
|
|
780
|
+
const bodyNodes = getElementsByTagName(xmlDoc, 'body');
|
|
781
|
+
const rows = [];
|
|
782
|
+
const fields = [];
|
|
799
783
|
if (bodyNodes.length) {
|
|
800
|
-
|
|
784
|
+
const tableNodes = getElementsByTagName(bodyNodes[0], 'table');
|
|
801
785
|
if (tableNodes.length) {
|
|
802
|
-
|
|
786
|
+
const theadNodes = getElementsByTagName(tableNodes[0], 'thead');
|
|
803
787
|
if (theadNodes.length) {
|
|
804
|
-
_xeUtils.default.arrayEach(getElementsByTagName(theadNodes[0], 'tr'),
|
|
805
|
-
_xeUtils.default.arrayEach(getElementsByTagName(rowNode, 'th'),
|
|
788
|
+
_xeUtils.default.arrayEach(getElementsByTagName(theadNodes[0], 'tr'), rowNode => {
|
|
789
|
+
_xeUtils.default.arrayEach(getElementsByTagName(rowNode, 'th'), cellNode => {
|
|
806
790
|
fields.push(cellNode.textContent);
|
|
807
791
|
});
|
|
808
792
|
});
|
|
809
|
-
|
|
793
|
+
const tbodyNodes = getElementsByTagName(tableNodes[0], 'tbody');
|
|
810
794
|
if (tbodyNodes.length) {
|
|
811
|
-
_xeUtils.default.arrayEach(getElementsByTagName(tbodyNodes[0], 'tr'),
|
|
812
|
-
|
|
813
|
-
_xeUtils.default.arrayEach(getElementsByTagName(rowNode, 'td'),
|
|
795
|
+
_xeUtils.default.arrayEach(getElementsByTagName(tbodyNodes[0], 'tr'), rowNode => {
|
|
796
|
+
const item = {};
|
|
797
|
+
_xeUtils.default.arrayEach(getElementsByTagName(rowNode, 'td'), (cellNode, colIndex) => {
|
|
814
798
|
if (fields[colIndex]) {
|
|
815
799
|
item[fields[colIndex]] = cellNode.textContent || '';
|
|
816
800
|
}
|
|
@@ -822,29 +806,29 @@ function parseHTML(columns, content) {
|
|
|
822
806
|
}
|
|
823
807
|
}
|
|
824
808
|
return {
|
|
825
|
-
fields
|
|
826
|
-
rows
|
|
809
|
+
fields,
|
|
810
|
+
rows
|
|
827
811
|
};
|
|
828
812
|
}
|
|
829
813
|
function parseXML(columns, content) {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
814
|
+
const domParser = new DOMParser();
|
|
815
|
+
const xmlDoc = domParser.parseFromString(content, 'application/xml');
|
|
816
|
+
const sheetNodes = getElementsByTagName(xmlDoc, 'Worksheet');
|
|
817
|
+
const rows = [];
|
|
818
|
+
const fields = [];
|
|
835
819
|
if (sheetNodes.length) {
|
|
836
|
-
|
|
820
|
+
const tableNodes = getElementsByTagName(sheetNodes[0], 'Table');
|
|
837
821
|
if (tableNodes.length) {
|
|
838
|
-
|
|
822
|
+
const rowNodes = getElementsByTagName(tableNodes[0], 'Row');
|
|
839
823
|
if (rowNodes.length) {
|
|
840
|
-
_xeUtils.default.arrayEach(getElementsByTagName(rowNodes[0], 'Cell'),
|
|
824
|
+
_xeUtils.default.arrayEach(getElementsByTagName(rowNodes[0], 'Cell'), cellNode => {
|
|
841
825
|
fields.push(cellNode.textContent);
|
|
842
826
|
});
|
|
843
|
-
_xeUtils.default.arrayEach(rowNodes,
|
|
827
|
+
_xeUtils.default.arrayEach(rowNodes, (rowNode, index) => {
|
|
844
828
|
if (index) {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
_xeUtils.default.arrayEach(cellNodes,
|
|
829
|
+
const item = {};
|
|
830
|
+
const cellNodes = getElementsByTagName(rowNode, 'Cell');
|
|
831
|
+
_xeUtils.default.arrayEach(cellNodes, (cellNode, colIndex) => {
|
|
848
832
|
if (fields[colIndex]) {
|
|
849
833
|
item[fields[colIndex]] = cellNode.textContent;
|
|
850
834
|
}
|
|
@@ -856,8 +840,8 @@ function parseXML(columns, content) {
|
|
|
856
840
|
}
|
|
857
841
|
}
|
|
858
842
|
return {
|
|
859
|
-
fields
|
|
860
|
-
rows
|
|
843
|
+
fields,
|
|
844
|
+
rows
|
|
861
845
|
};
|
|
862
846
|
}
|
|
863
847
|
/**
|
|
@@ -866,22 +850,22 @@ function parseXML(columns, content) {
|
|
|
866
850
|
* @param {Array} rows 数据列表
|
|
867
851
|
*/
|
|
868
852
|
function checkImportData(columns, fields) {
|
|
869
|
-
|
|
870
|
-
columns.forEach(
|
|
871
|
-
|
|
853
|
+
const tableFields = [];
|
|
854
|
+
columns.forEach(column => {
|
|
855
|
+
const field = column.property;
|
|
872
856
|
if (field) {
|
|
873
857
|
tableFields.push(field);
|
|
874
858
|
}
|
|
875
859
|
});
|
|
876
|
-
return fields.some(
|
|
877
|
-
return tableFields.indexOf(field) > -1;
|
|
878
|
-
});
|
|
860
|
+
return fields.some(field => tableFields.indexOf(field) > -1);
|
|
879
861
|
}
|
|
880
862
|
function handleImport($xetable, content, opts) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
863
|
+
const {
|
|
864
|
+
tableFullColumn,
|
|
865
|
+
_importResolve,
|
|
866
|
+
_importReject
|
|
867
|
+
} = $xetable;
|
|
868
|
+
let rest = {
|
|
885
869
|
fields: [],
|
|
886
870
|
rows: []
|
|
887
871
|
};
|
|
@@ -899,13 +883,14 @@ function handleImport($xetable, content, opts) {
|
|
|
899
883
|
rest = parseXML(tableFullColumn, content);
|
|
900
884
|
break;
|
|
901
885
|
}
|
|
902
|
-
|
|
903
|
-
fields
|
|
904
|
-
rows
|
|
905
|
-
|
|
886
|
+
const {
|
|
887
|
+
fields,
|
|
888
|
+
rows
|
|
889
|
+
} = rest;
|
|
890
|
+
const status = checkImportData(tableFullColumn, fields);
|
|
906
891
|
if (status) {
|
|
907
|
-
$xetable.createData(rows).then(
|
|
908
|
-
|
|
892
|
+
$xetable.createData(rows).then(data => {
|
|
893
|
+
let loadRest;
|
|
909
894
|
if (opts.mode === 'insert' || opts.mode === 'insertBottom') {
|
|
910
895
|
loadRest = $xetable.insertAt(data, -1);
|
|
911
896
|
}
|
|
@@ -916,7 +901,7 @@ function handleImport($xetable, content, opts) {
|
|
|
916
901
|
}
|
|
917
902
|
if (opts.message !== false) {
|
|
918
903
|
// 检测弹窗模块
|
|
919
|
-
if (process.env.
|
|
904
|
+
if (process.env.NODE_ENV === 'development') {
|
|
920
905
|
if (!_ui.VxeUI.modal) {
|
|
921
906
|
(0, _log.errLog)('vxe.error.reqModule', ['Modal']);
|
|
922
907
|
}
|
|
@@ -926,7 +911,7 @@ function handleImport($xetable, content, opts) {
|
|
|
926
911
|
status: 'success'
|
|
927
912
|
});
|
|
928
913
|
}
|
|
929
|
-
return loadRest.then(
|
|
914
|
+
return loadRest.then(() => {
|
|
930
915
|
if (_importResolve) {
|
|
931
916
|
_importResolve({
|
|
932
917
|
status: true
|
|
@@ -936,7 +921,7 @@ function handleImport($xetable, content, opts) {
|
|
|
936
921
|
});
|
|
937
922
|
} else if (opts.message !== false) {
|
|
938
923
|
// 检测弹窗模块
|
|
939
|
-
if (process.env.
|
|
924
|
+
if (process.env.NODE_ENV === 'development') {
|
|
940
925
|
if (!_ui.VxeUI.modal) {
|
|
941
926
|
(0, _log.errLog)('vxe.error.reqModule', ['Modal']);
|
|
942
927
|
}
|
|
@@ -953,17 +938,22 @@ function handleImport($xetable, content, opts) {
|
|
|
953
938
|
}
|
|
954
939
|
}
|
|
955
940
|
function handleFileImport($xetable, file, opts) {
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
941
|
+
const {
|
|
942
|
+
importOpts
|
|
943
|
+
} = $xetable;
|
|
944
|
+
const {
|
|
945
|
+
importMethod,
|
|
946
|
+
afterImportMethod
|
|
947
|
+
} = opts;
|
|
948
|
+
const {
|
|
949
|
+
type,
|
|
950
|
+
filename
|
|
951
|
+
} = (0, _utils.parseFile)(file);
|
|
962
952
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
963
953
|
if (!importMethod && !_xeUtils.default.includes(_xeUtils.default.keys(importOpts._typeMaps), type)) {
|
|
964
954
|
if (opts.message !== false) {
|
|
965
955
|
// 检测弹窗模块
|
|
966
|
-
if (process.env.
|
|
956
|
+
if (process.env.NODE_ENV === 'development') {
|
|
967
957
|
if (!_ui.VxeUI.modal) {
|
|
968
958
|
(0, _log.errLog)('vxe.error.reqModule', ['Modal']);
|
|
969
959
|
}
|
|
@@ -973,18 +963,18 @@ function handleFileImport($xetable, file, opts) {
|
|
|
973
963
|
status: 'error'
|
|
974
964
|
});
|
|
975
965
|
}
|
|
976
|
-
|
|
966
|
+
const params = {
|
|
977
967
|
status: false
|
|
978
968
|
};
|
|
979
969
|
return Promise.reject(params);
|
|
980
970
|
}
|
|
981
|
-
|
|
982
|
-
|
|
971
|
+
const rest = new Promise((resolve, reject) => {
|
|
972
|
+
const _importResolve = params => {
|
|
983
973
|
resolve(params);
|
|
984
974
|
$xetable._importResolve = null;
|
|
985
975
|
$xetable._importReject = null;
|
|
986
976
|
};
|
|
987
|
-
|
|
977
|
+
const _importReject = params => {
|
|
988
978
|
reject(params);
|
|
989
979
|
$xetable._importResolve = null;
|
|
990
980
|
$xetable._importReject = null;
|
|
@@ -992,23 +982,23 @@ function handleFileImport($xetable, file, opts) {
|
|
|
992
982
|
$xetable._importResolve = _importResolve;
|
|
993
983
|
$xetable._importReject = _importReject;
|
|
994
984
|
if (window.FileReader) {
|
|
995
|
-
|
|
985
|
+
const options = Object.assign({
|
|
996
986
|
mode: 'insertTop'
|
|
997
987
|
}, opts, {
|
|
998
|
-
type
|
|
999
|
-
filename
|
|
988
|
+
type,
|
|
989
|
+
filename
|
|
1000
990
|
});
|
|
1001
991
|
if (options.remote) {
|
|
1002
992
|
if (importMethod) {
|
|
1003
993
|
Promise.resolve(importMethod({
|
|
1004
|
-
file
|
|
1005
|
-
options
|
|
994
|
+
file,
|
|
995
|
+
options,
|
|
1006
996
|
$table: $xetable
|
|
1007
|
-
})).then(
|
|
997
|
+
})).then(() => {
|
|
1008
998
|
_importResolve({
|
|
1009
999
|
status: true
|
|
1010
1000
|
});
|
|
1011
|
-
}).catch(
|
|
1001
|
+
}).catch(() => {
|
|
1012
1002
|
_importResolve({
|
|
1013
1003
|
status: true
|
|
1014
1004
|
});
|
|
@@ -1020,18 +1010,18 @@ function handleFileImport($xetable, file, opts) {
|
|
|
1020
1010
|
}
|
|
1021
1011
|
} else {
|
|
1022
1012
|
$xetable.preventEvent(null, 'event.import', {
|
|
1023
|
-
file
|
|
1024
|
-
options
|
|
1013
|
+
file,
|
|
1014
|
+
options,
|
|
1025
1015
|
columns: $xetable.tableFullColumn
|
|
1026
|
-
},
|
|
1027
|
-
|
|
1028
|
-
reader.onerror =
|
|
1016
|
+
}, () => {
|
|
1017
|
+
const reader = new FileReader();
|
|
1018
|
+
reader.onerror = () => {
|
|
1029
1019
|
(0, _log.errLog)('vxe.error.notType', [type]);
|
|
1030
1020
|
_importReject({
|
|
1031
1021
|
status: false
|
|
1032
1022
|
});
|
|
1033
1023
|
};
|
|
1034
|
-
reader.onload =
|
|
1024
|
+
reader.onload = e => {
|
|
1035
1025
|
handleImport($xetable, e.target.result, options);
|
|
1036
1026
|
};
|
|
1037
1027
|
reader.readAsText(file, options.encoding || 'UTF-8');
|
|
@@ -1039,7 +1029,7 @@ function handleFileImport($xetable, file, opts) {
|
|
|
1039
1029
|
}
|
|
1040
1030
|
} else {
|
|
1041
1031
|
// 不支持的浏览器
|
|
1042
|
-
if (process.env.
|
|
1032
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1043
1033
|
(0, _log.errLog)('vxe.error.notExp');
|
|
1044
1034
|
}
|
|
1045
1035
|
_importResolve({
|
|
@@ -1047,7 +1037,7 @@ function handleFileImport($xetable, file, opts) {
|
|
|
1047
1037
|
});
|
|
1048
1038
|
}
|
|
1049
1039
|
});
|
|
1050
|
-
return rest.then(
|
|
1040
|
+
return rest.then(() => {
|
|
1051
1041
|
if (afterImportMethod) {
|
|
1052
1042
|
afterImportMethod({
|
|
1053
1043
|
status: true,
|
|
@@ -1055,7 +1045,7 @@ function handleFileImport($xetable, file, opts) {
|
|
|
1055
1045
|
$table: $xetable
|
|
1056
1046
|
});
|
|
1057
1047
|
}
|
|
1058
|
-
}).catch(
|
|
1048
|
+
}).catch(e => {
|
|
1059
1049
|
if (afterImportMethod) {
|
|
1060
1050
|
afterImportMethod({
|
|
1061
1051
|
status: false,
|
|
@@ -1070,8 +1060,7 @@ function handleFileImport($xetable, file, opts) {
|
|
|
1070
1060
|
* 读取本地文件
|
|
1071
1061
|
* @param {*} options 参数
|
|
1072
1062
|
*/
|
|
1073
|
-
function readLocalFile() {
|
|
1074
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1063
|
+
function readLocalFile(options = {}) {
|
|
1075
1064
|
if (!fileForm) {
|
|
1076
1065
|
fileForm = document.createElement('form');
|
|
1077
1066
|
fileInput = document.createElement('input');
|
|
@@ -1081,22 +1070,23 @@ function readLocalFile() {
|
|
|
1081
1070
|
fileForm.appendChild(fileInput);
|
|
1082
1071
|
document.body.appendChild(fileForm);
|
|
1083
1072
|
}
|
|
1084
|
-
return new Promise(
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
return type === '*';
|
|
1088
|
-
});
|
|
1073
|
+
return new Promise((resolve, reject) => {
|
|
1074
|
+
const types = options.types || [];
|
|
1075
|
+
const isAllType = !types.length || types.some(type => type === '*');
|
|
1089
1076
|
fileInput.multiple = !!options.multiple;
|
|
1090
|
-
fileInput.accept = isAllType ? '' :
|
|
1091
|
-
fileInput.onchange =
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1077
|
+
fileInput.accept = isAllType ? '' : `.${types.join(', .')}`;
|
|
1078
|
+
fileInput.onchange = evnt => {
|
|
1079
|
+
const {
|
|
1080
|
+
files
|
|
1081
|
+
} = evnt.target;
|
|
1082
|
+
const file = files[0];
|
|
1083
|
+
let errType;
|
|
1095
1084
|
// 校验类型
|
|
1096
1085
|
if (!isAllType) {
|
|
1097
|
-
for (
|
|
1098
|
-
|
|
1099
|
-
type
|
|
1086
|
+
for (let fIndex = 0; fIndex < files.length; fIndex++) {
|
|
1087
|
+
const {
|
|
1088
|
+
type
|
|
1089
|
+
} = (0, _utils.parseFile)(files[fIndex]);
|
|
1100
1090
|
if (!_xeUtils.default.includes(types, type)) {
|
|
1101
1091
|
errType = type;
|
|
1102
1092
|
break;
|
|
@@ -1106,13 +1096,13 @@ function readLocalFile() {
|
|
|
1106
1096
|
if (!errType) {
|
|
1107
1097
|
resolve({
|
|
1108
1098
|
status: true,
|
|
1109
|
-
files
|
|
1110
|
-
file
|
|
1099
|
+
files,
|
|
1100
|
+
file
|
|
1111
1101
|
});
|
|
1112
1102
|
} else {
|
|
1113
1103
|
if (options.message !== false) {
|
|
1114
1104
|
// 检测弹窗模块
|
|
1115
|
-
if (process.env.
|
|
1105
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1116
1106
|
if (!_ui.VxeUI.modal) {
|
|
1117
1107
|
(0, _log.errLog)('vxe.error.reqModule', ['Modal']);
|
|
1118
1108
|
}
|
|
@@ -1122,10 +1112,10 @@ function readLocalFile() {
|
|
|
1122
1112
|
status: 'error'
|
|
1123
1113
|
});
|
|
1124
1114
|
}
|
|
1125
|
-
|
|
1115
|
+
const params = {
|
|
1126
1116
|
status: false,
|
|
1127
|
-
files
|
|
1128
|
-
file
|
|
1117
|
+
files,
|
|
1118
|
+
file
|
|
1129
1119
|
};
|
|
1130
1120
|
reject(params);
|
|
1131
1121
|
}
|
|
@@ -1154,16 +1144,18 @@ function afterPrintEvent() {
|
|
|
1154
1144
|
requestAnimationFrame(removePrintFrame);
|
|
1155
1145
|
}
|
|
1156
1146
|
function handlePrint($xetable, opts, content) {
|
|
1157
|
-
|
|
1147
|
+
const {
|
|
1148
|
+
beforePrintMethod
|
|
1149
|
+
} = opts;
|
|
1158
1150
|
if (beforePrintMethod) {
|
|
1159
1151
|
content = beforePrintMethod({
|
|
1160
|
-
content
|
|
1152
|
+
content,
|
|
1161
1153
|
options: opts,
|
|
1162
1154
|
$table: $xetable
|
|
1163
1155
|
}) || '';
|
|
1164
1156
|
}
|
|
1165
1157
|
content = (0, _util2.createHtmlPage)(opts, content);
|
|
1166
|
-
|
|
1158
|
+
const blob = (0, _util2.getExportBlobByContent)(content, opts);
|
|
1167
1159
|
if (_dom.browse.msie) {
|
|
1168
1160
|
removePrintFrame();
|
|
1169
1161
|
printFrame = createFrame();
|
|
@@ -1173,7 +1165,7 @@ function handlePrint($xetable, opts, content) {
|
|
|
1173
1165
|
} else {
|
|
1174
1166
|
if (!printFrame) {
|
|
1175
1167
|
printFrame = createFrame();
|
|
1176
|
-
printFrame.onload =
|
|
1168
|
+
printFrame.onload = evnt => {
|
|
1177
1169
|
if (evnt.target.src) {
|
|
1178
1170
|
evnt.target.contentWindow.onafterprint = afterPrintEvent;
|
|
1179
1171
|
evnt.target.contentWindow.print();
|
|
@@ -1185,40 +1177,44 @@ function handlePrint($xetable, opts, content) {
|
|
|
1185
1177
|
}
|
|
1186
1178
|
}
|
|
1187
1179
|
function handleExportAndPrint($xetable, options, isPrint) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1180
|
+
const {
|
|
1181
|
+
$xegrid,
|
|
1182
|
+
initStore,
|
|
1183
|
+
customOpts,
|
|
1184
|
+
collectColumn,
|
|
1185
|
+
footerTableData,
|
|
1186
|
+
treeConfig,
|
|
1187
|
+
mergeList,
|
|
1188
|
+
isGroup,
|
|
1189
|
+
exportParams,
|
|
1190
|
+
exportOpts
|
|
1191
|
+
} = $xetable;
|
|
1192
|
+
const proxyOpts = $xegrid ? $xegrid.proxyOpts : {};
|
|
1193
|
+
const selectRecords = $xetable.getCheckboxRecords();
|
|
1194
|
+
const hasFooter = !!footerTableData.length;
|
|
1195
|
+
const hasTree = treeConfig;
|
|
1196
|
+
const hasMerge = !hasTree && mergeList.length;
|
|
1197
|
+
const defOpts = Object.assign({
|
|
1204
1198
|
message: true,
|
|
1205
1199
|
isHeader: true,
|
|
1206
1200
|
current: 'current',
|
|
1207
1201
|
modes: ['current', 'selected'].concat(proxyOpts.ajax && proxyOpts.ajax.queryAll ? ['all'] : [])
|
|
1208
1202
|
}, options);
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1203
|
+
const types = defOpts.types || _xeUtils.default.keys(exportOpts._typeMaps);
|
|
1204
|
+
const modes = defOpts.modes || [];
|
|
1205
|
+
const checkMethod = customOpts.checkMethod;
|
|
1206
|
+
const exportColumns = collectColumn.slice(0);
|
|
1207
|
+
const {
|
|
1208
|
+
columns
|
|
1209
|
+
} = defOpts;
|
|
1214
1210
|
// 处理类型
|
|
1215
|
-
|
|
1211
|
+
const typeList = types.map(value => {
|
|
1216
1212
|
return {
|
|
1217
|
-
value
|
|
1218
|
-
label: getI18n(
|
|
1213
|
+
value,
|
|
1214
|
+
label: getI18n(`vxe.export.types.${value}`)
|
|
1219
1215
|
};
|
|
1220
1216
|
});
|
|
1221
|
-
|
|
1217
|
+
const modeList = modes.map(item => {
|
|
1222
1218
|
if (item && item.value) {
|
|
1223
1219
|
return {
|
|
1224
1220
|
value: item.value,
|
|
@@ -1227,22 +1223,22 @@ function handleExportAndPrint($xetable, options, isPrint) {
|
|
|
1227
1223
|
}
|
|
1228
1224
|
return {
|
|
1229
1225
|
value: item,
|
|
1230
|
-
label: getI18n(
|
|
1226
|
+
label: getI18n(`vxe.export.modes.${item}`)
|
|
1231
1227
|
};
|
|
1232
1228
|
});
|
|
1233
1229
|
// 默认选中
|
|
1234
|
-
_xeUtils.default.eachTree(exportColumns,
|
|
1235
|
-
|
|
1230
|
+
_xeUtils.default.eachTree(exportColumns, (column, index, items, path, parent) => {
|
|
1231
|
+
const isColGroup = column.children && column.children.length;
|
|
1236
1232
|
if (isColGroup || defaultFilterExportColumn(column)) {
|
|
1237
|
-
column.checked = columns ? columns.some(
|
|
1233
|
+
column.checked = columns ? columns.some(item => {
|
|
1238
1234
|
if ((0, _util.isColumnInfo)(item)) {
|
|
1239
1235
|
return column === item;
|
|
1240
1236
|
} else if (_xeUtils.default.isString(item)) {
|
|
1241
1237
|
return column.field === item;
|
|
1242
1238
|
} else {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1239
|
+
const colid = item.id || item.colId;
|
|
1240
|
+
const type = item.type;
|
|
1241
|
+
const field = item.property || item.field;
|
|
1246
1242
|
if (colid) {
|
|
1247
1243
|
return column.id === colid;
|
|
1248
1244
|
} else if (field && type) {
|
|
@@ -1257,19 +1253,19 @@ function handleExportAndPrint($xetable, options, isPrint) {
|
|
|
1257
1253
|
}) : column.visible;
|
|
1258
1254
|
column.halfChecked = false;
|
|
1259
1255
|
column.disabled = parent && parent.disabled || (checkMethod ? !checkMethod({
|
|
1260
|
-
column
|
|
1256
|
+
column
|
|
1261
1257
|
}) : false);
|
|
1262
1258
|
}
|
|
1263
1259
|
});
|
|
1264
1260
|
// 更新条件
|
|
1265
1261
|
Object.assign($xetable.exportStore, {
|
|
1266
1262
|
columns: exportColumns,
|
|
1267
|
-
typeList
|
|
1268
|
-
modeList
|
|
1269
|
-
hasFooter
|
|
1270
|
-
hasMerge
|
|
1271
|
-
hasTree
|
|
1272
|
-
isPrint
|
|
1263
|
+
typeList,
|
|
1264
|
+
modeList,
|
|
1265
|
+
hasFooter,
|
|
1266
|
+
hasMerge,
|
|
1267
|
+
hasTree,
|
|
1268
|
+
isPrint,
|
|
1273
1269
|
hasColgroup: isGroup,
|
|
1274
1270
|
visible: true
|
|
1275
1271
|
});
|
|
@@ -1277,34 +1273,30 @@ function handleExportAndPrint($xetable, options, isPrint) {
|
|
|
1277
1273
|
Object.assign(exportParams, {
|
|
1278
1274
|
mode: selectRecords.length ? 'selected' : 'current'
|
|
1279
1275
|
}, defOpts);
|
|
1280
|
-
if (!modeList.some(
|
|
1281
|
-
return item.value === exportParams.mode;
|
|
1282
|
-
})) {
|
|
1276
|
+
if (!modeList.some(item => item.value === exportParams.mode)) {
|
|
1283
1277
|
exportParams.mode = modeList[0].value;
|
|
1284
1278
|
}
|
|
1285
|
-
if (!typeList.some(
|
|
1286
|
-
return item.value === exportParams.type;
|
|
1287
|
-
})) {
|
|
1279
|
+
if (!typeList.some(item => item.value === exportParams.type)) {
|
|
1288
1280
|
exportParams.type = typeList[0].value;
|
|
1289
1281
|
}
|
|
1290
1282
|
initStore.export = true;
|
|
1291
1283
|
return $xetable.$nextTick();
|
|
1292
1284
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
columns.forEach(
|
|
1285
|
+
const getConvertColumns = columns => {
|
|
1286
|
+
const result = [];
|
|
1287
|
+
columns.forEach(column => {
|
|
1296
1288
|
if (column.childNodes && column.childNodes.length) {
|
|
1297
1289
|
result.push(column);
|
|
1298
|
-
result.push
|
|
1290
|
+
result.push(...getConvertColumns(column.childNodes));
|
|
1299
1291
|
} else {
|
|
1300
1292
|
result.push(column);
|
|
1301
1293
|
}
|
|
1302
1294
|
});
|
|
1303
1295
|
return result;
|
|
1304
1296
|
};
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1297
|
+
const convertToRows = originColumns => {
|
|
1298
|
+
let maxLevel = 1;
|
|
1299
|
+
const traverse = (column, parent) => {
|
|
1308
1300
|
if (parent) {
|
|
1309
1301
|
column._level = parent._level + 1;
|
|
1310
1302
|
if (maxLevel < column._level) {
|
|
@@ -1312,9 +1304,9 @@ var convertToRows = function convertToRows(originColumns) {
|
|
|
1312
1304
|
}
|
|
1313
1305
|
}
|
|
1314
1306
|
if (column.childNodes && column.childNodes.length) {
|
|
1315
|
-
|
|
1316
|
-
column.childNodes.forEach(
|
|
1317
|
-
|
|
1307
|
+
let colSpan = 0;
|
|
1308
|
+
column.childNodes.forEach(subColumn => {
|
|
1309
|
+
traverse(subColumn, column);
|
|
1318
1310
|
colSpan += subColumn._colSpan;
|
|
1319
1311
|
});
|
|
1320
1312
|
column._colSpan = colSpan;
|
|
@@ -1322,16 +1314,16 @@ var convertToRows = function convertToRows(originColumns) {
|
|
|
1322
1314
|
column._colSpan = 1;
|
|
1323
1315
|
}
|
|
1324
1316
|
};
|
|
1325
|
-
originColumns.forEach(
|
|
1317
|
+
originColumns.forEach(column => {
|
|
1326
1318
|
column._level = 1;
|
|
1327
|
-
|
|
1319
|
+
traverse(column);
|
|
1328
1320
|
});
|
|
1329
|
-
|
|
1330
|
-
for (
|
|
1321
|
+
const rows = [];
|
|
1322
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
1331
1323
|
rows.push([]);
|
|
1332
1324
|
}
|
|
1333
|
-
|
|
1334
|
-
allColumns.forEach(
|
|
1325
|
+
const allColumns = getConvertColumns(originColumns);
|
|
1326
|
+
allColumns.forEach(column => {
|
|
1335
1327
|
if (column.childNodes && column.childNodes.length) {
|
|
1336
1328
|
column._rowSpan = 1;
|
|
1337
1329
|
} else {
|
|
@@ -1349,17 +1341,18 @@ var _default = exports.default = {
|
|
|
1349
1341
|
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数自行转换数据
|
|
1350
1342
|
* @param {Object} options 参数
|
|
1351
1343
|
*/
|
|
1352
|
-
_exportData
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
isGroup
|
|
1356
|
-
tableGroupColumn
|
|
1357
|
-
tableFullColumn
|
|
1358
|
-
afterFullData
|
|
1359
|
-
treeConfig
|
|
1360
|
-
treeOpts
|
|
1361
|
-
exportOpts
|
|
1362
|
-
|
|
1344
|
+
_exportData(options) {
|
|
1345
|
+
const {
|
|
1346
|
+
$xegrid,
|
|
1347
|
+
isGroup,
|
|
1348
|
+
tableGroupColumn,
|
|
1349
|
+
tableFullColumn,
|
|
1350
|
+
afterFullData,
|
|
1351
|
+
treeConfig,
|
|
1352
|
+
treeOpts,
|
|
1353
|
+
exportOpts
|
|
1354
|
+
} = this;
|
|
1355
|
+
const opts = Object.assign({
|
|
1363
1356
|
// filename: '',
|
|
1364
1357
|
// sheetName: '',
|
|
1365
1358
|
// original: false,
|
|
@@ -1383,49 +1376,45 @@ var _default = exports.default = {
|
|
|
1383
1376
|
}, exportOpts, {
|
|
1384
1377
|
print: false
|
|
1385
1378
|
}, options);
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1379
|
+
const {
|
|
1380
|
+
type,
|
|
1381
|
+
mode,
|
|
1382
|
+
columns,
|
|
1383
|
+
original,
|
|
1384
|
+
beforeExportMethod
|
|
1385
|
+
} = opts;
|
|
1386
|
+
let groups = [];
|
|
1387
|
+
const customCols = columns && columns.length ? columns : null;
|
|
1393
1388
|
// 如果设置源数据,则默认导出设置了字段的列
|
|
1394
|
-
|
|
1389
|
+
let columnFilterMethod = opts.columnFilterMethod;
|
|
1395
1390
|
if (!customCols && !columnFilterMethod) {
|
|
1396
|
-
columnFilterMethod = original ?
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
return defaultFilterExportColumn(column);
|
|
1402
|
-
};
|
|
1391
|
+
columnFilterMethod = original ? ({
|
|
1392
|
+
column
|
|
1393
|
+
}) => column.property : ({
|
|
1394
|
+
column
|
|
1395
|
+
}) => defaultFilterExportColumn(column);
|
|
1403
1396
|
}
|
|
1404
1397
|
if (customCols) {
|
|
1405
1398
|
opts._isCustomColumn = true;
|
|
1406
|
-
groups = _xeUtils.default.searchTree(_xeUtils.default.mapTree(customCols,
|
|
1407
|
-
|
|
1399
|
+
groups = _xeUtils.default.searchTree(_xeUtils.default.mapTree(customCols, item => {
|
|
1400
|
+
let targetColumn;
|
|
1408
1401
|
if (item) {
|
|
1409
1402
|
if ((0, _util.isColumnInfo)(item)) {
|
|
1410
1403
|
targetColumn = item;
|
|
1411
1404
|
} else if (_xeUtils.default.isString(item)) {
|
|
1412
|
-
targetColumn =
|
|
1405
|
+
targetColumn = this.getColumnByField(item);
|
|
1413
1406
|
} else {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1407
|
+
const colid = item.id || item.colId;
|
|
1408
|
+
const type = item.type;
|
|
1409
|
+
const field = item.property || item.field;
|
|
1417
1410
|
if (colid) {
|
|
1418
|
-
targetColumn =
|
|
1419
|
-
} else if (field &&
|
|
1420
|
-
targetColumn = tableFullColumn.find(
|
|
1421
|
-
return column.property === field && column.type === _type;
|
|
1422
|
-
});
|
|
1411
|
+
targetColumn = this.getColumnById(colid);
|
|
1412
|
+
} else if (field && type) {
|
|
1413
|
+
targetColumn = tableFullColumn.find(column => column.property === field && column.type === type);
|
|
1423
1414
|
} else if (field) {
|
|
1424
|
-
targetColumn =
|
|
1425
|
-
} else if (
|
|
1426
|
-
targetColumn = tableFullColumn.find(
|
|
1427
|
-
return column.type === _type;
|
|
1428
|
-
});
|
|
1415
|
+
targetColumn = this.getColumnByField(field);
|
|
1416
|
+
} else if (type) {
|
|
1417
|
+
targetColumn = tableFullColumn.find(column => column.type === type);
|
|
1429
1418
|
}
|
|
1430
1419
|
}
|
|
1431
1420
|
return targetColumn || {};
|
|
@@ -1433,32 +1422,28 @@ var _default = exports.default = {
|
|
|
1433
1422
|
}, {
|
|
1434
1423
|
children: 'childNodes',
|
|
1435
1424
|
mapChildren: '_children'
|
|
1436
|
-
}),
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
}));
|
|
1441
|
-
}, {
|
|
1425
|
+
}), (column, index) => (0, _util.isColumnInfo)(column) && (!columnFilterMethod || columnFilterMethod({
|
|
1426
|
+
column,
|
|
1427
|
+
$columnIndex: index
|
|
1428
|
+
})), {
|
|
1442
1429
|
children: '_children',
|
|
1443
1430
|
mapChildren: 'childNodes',
|
|
1444
1431
|
original: true
|
|
1445
1432
|
});
|
|
1446
1433
|
} else {
|
|
1447
|
-
groups = _xeUtils.default.searchTree(isGroup ? tableGroupColumn : tableFullColumn,
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
}));
|
|
1452
|
-
}, {
|
|
1434
|
+
groups = _xeUtils.default.searchTree(isGroup ? tableGroupColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({
|
|
1435
|
+
column,
|
|
1436
|
+
$columnIndex: index
|
|
1437
|
+
})), {
|
|
1453
1438
|
children: 'children',
|
|
1454
1439
|
mapChildren: 'childNodes',
|
|
1455
1440
|
original: true
|
|
1456
1441
|
});
|
|
1457
1442
|
}
|
|
1458
1443
|
// 获取所有列
|
|
1459
|
-
|
|
1460
|
-
_xeUtils.default.eachTree(groups,
|
|
1461
|
-
|
|
1444
|
+
const cols = [];
|
|
1445
|
+
_xeUtils.default.eachTree(groups, column => {
|
|
1446
|
+
const isColGroup = column.children && column.children.length;
|
|
1462
1447
|
if (!isColGroup) {
|
|
1463
1448
|
cols.push(column);
|
|
1464
1449
|
}
|
|
@@ -1476,10 +1461,10 @@ var _default = exports.default = {
|
|
|
1476
1461
|
}
|
|
1477
1462
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1478
1463
|
if (!opts.exportMethod && !_xeUtils.default.includes(_xeUtils.default.keys(exportOpts._typeMaps), type)) {
|
|
1479
|
-
if (process.env.
|
|
1464
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1480
1465
|
(0, _log.errLog)('vxe.error.notType', [type]);
|
|
1481
1466
|
}
|
|
1482
|
-
|
|
1467
|
+
const params = {
|
|
1483
1468
|
status: false
|
|
1484
1469
|
};
|
|
1485
1470
|
return Promise.reject(params);
|
|
@@ -1496,40 +1481,37 @@ var _default = exports.default = {
|
|
|
1496
1481
|
if (!opts.data) {
|
|
1497
1482
|
opts.data = [];
|
|
1498
1483
|
if (mode === 'selected') {
|
|
1499
|
-
|
|
1484
|
+
const selectRecords = this.getCheckboxRecords();
|
|
1500
1485
|
if (['html', 'pdf'].indexOf(type) > -1 && treeConfig) {
|
|
1501
|
-
opts.data = _xeUtils.default.searchTree(this.getTableData().fullData,
|
|
1502
|
-
return selectRecords.indexOf(item) > -1;
|
|
1503
|
-
}, Object.assign({}, treeOpts, {
|
|
1486
|
+
opts.data = _xeUtils.default.searchTree(this.getTableData().fullData, item => selectRecords.indexOf(item) > -1, Object.assign({}, treeOpts, {
|
|
1504
1487
|
data: '_row'
|
|
1505
1488
|
}));
|
|
1506
1489
|
} else {
|
|
1507
1490
|
opts.data = selectRecords;
|
|
1508
1491
|
}
|
|
1509
1492
|
} else if (mode === 'all') {
|
|
1510
|
-
if (process.env.
|
|
1493
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1511
1494
|
if (!$xegrid) {
|
|
1512
1495
|
(0, _log.warnLog)('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1513
1496
|
}
|
|
1514
1497
|
}
|
|
1515
1498
|
if ($xegrid && !opts.remote) {
|
|
1516
|
-
|
|
1517
|
-
beforeQueryAll
|
|
1518
|
-
afterQueryAll
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
1499
|
+
const {
|
|
1500
|
+
beforeQueryAll,
|
|
1501
|
+
afterQueryAll,
|
|
1502
|
+
ajax = {},
|
|
1503
|
+
props = {}
|
|
1504
|
+
} = $xegrid.proxyOpts;
|
|
1505
|
+
const ajaxMethods = ajax.queryAll;
|
|
1506
|
+
const queryAllSuccessMethods = ajax.queryAllSuccess;
|
|
1507
|
+
const queryAllErrorMethods = ajax.queryAllError;
|
|
1508
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1527
1509
|
if (!ajaxMethods) {
|
|
1528
1510
|
(0, _log.warnLog)('vxe.error.notFunc', ['proxy-config.ajax.queryAll']);
|
|
1529
1511
|
}
|
|
1530
1512
|
}
|
|
1531
1513
|
if (ajaxMethods) {
|
|
1532
|
-
|
|
1514
|
+
const params = {
|
|
1533
1515
|
$table: this,
|
|
1534
1516
|
$grid: $xegrid,
|
|
1535
1517
|
sort: $xegrid.sortData,
|
|
@@ -1538,20 +1520,20 @@ var _default = exports.default = {
|
|
|
1538
1520
|
target: ajaxMethods,
|
|
1539
1521
|
options: opts
|
|
1540
1522
|
};
|
|
1541
|
-
return Promise.resolve((beforeQueryAll || ajaxMethods)(
|
|
1523
|
+
return Promise.resolve((beforeQueryAll || ajaxMethods)(params)).then(rest => {
|
|
1542
1524
|
opts.data = (props.list ? _xeUtils.default.get(rest, props.list) : rest) || [];
|
|
1543
1525
|
if (afterQueryAll) {
|
|
1544
|
-
afterQueryAll(
|
|
1526
|
+
afterQueryAll(params);
|
|
1545
1527
|
}
|
|
1546
1528
|
if (queryAllSuccessMethods) {
|
|
1547
|
-
queryAllSuccessMethods(Object.assign(Object.assign({},
|
|
1529
|
+
queryAllSuccessMethods(Object.assign(Object.assign({}, params), {
|
|
1548
1530
|
response: rest
|
|
1549
1531
|
}));
|
|
1550
1532
|
}
|
|
1551
|
-
return handleExport(
|
|
1552
|
-
}).catch(
|
|
1533
|
+
return handleExport(this, opts);
|
|
1534
|
+
}).catch(rest => {
|
|
1553
1535
|
if (queryAllErrorMethods) {
|
|
1554
|
-
queryAllErrorMethods(Object.assign(Object.assign({},
|
|
1536
|
+
queryAllErrorMethods(Object.assign(Object.assign({}, params), {
|
|
1555
1537
|
response: rest
|
|
1556
1538
|
}));
|
|
1557
1539
|
}
|
|
@@ -1564,9 +1546,11 @@ var _default = exports.default = {
|
|
|
1564
1546
|
}
|
|
1565
1547
|
return handleExport(this, opts);
|
|
1566
1548
|
},
|
|
1567
|
-
_importByFile
|
|
1568
|
-
|
|
1569
|
-
|
|
1549
|
+
_importByFile(file, options) {
|
|
1550
|
+
const opts = Object.assign({}, options);
|
|
1551
|
+
const {
|
|
1552
|
+
beforeImportMethod
|
|
1553
|
+
} = opts;
|
|
1570
1554
|
if (beforeImportMethod) {
|
|
1571
1555
|
beforeImportMethod({
|
|
1572
1556
|
options: opts,
|
|
@@ -1575,45 +1559,49 @@ var _default = exports.default = {
|
|
|
1575
1559
|
}
|
|
1576
1560
|
return handleFileImport(this, file, opts);
|
|
1577
1561
|
},
|
|
1578
|
-
_importData
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1562
|
+
_importData(options) {
|
|
1563
|
+
const {
|
|
1564
|
+
importOpts
|
|
1565
|
+
} = this;
|
|
1566
|
+
const opts = Object.assign({
|
|
1582
1567
|
types: _xeUtils.default.keys(importOpts._typeMaps)
|
|
1583
1568
|
// beforeImportMethod: null,
|
|
1584
1569
|
// afterImportMethod: null
|
|
1585
1570
|
}, importOpts, options);
|
|
1586
|
-
|
|
1587
|
-
|
|
1571
|
+
const {
|
|
1572
|
+
beforeImportMethod,
|
|
1573
|
+
afterImportMethod
|
|
1574
|
+
} = opts;
|
|
1588
1575
|
if (beforeImportMethod) {
|
|
1589
1576
|
beforeImportMethod({
|
|
1590
1577
|
options: opts,
|
|
1591
1578
|
$table: this
|
|
1592
1579
|
});
|
|
1593
1580
|
}
|
|
1594
|
-
return readLocalFile(opts).catch(
|
|
1581
|
+
return readLocalFile(opts).catch(e => {
|
|
1595
1582
|
if (afterImportMethod) {
|
|
1596
1583
|
afterImportMethod({
|
|
1597
1584
|
status: false,
|
|
1598
1585
|
options: opts,
|
|
1599
|
-
$table:
|
|
1586
|
+
$table: this
|
|
1600
1587
|
});
|
|
1601
1588
|
}
|
|
1602
1589
|
return Promise.reject(e);
|
|
1603
|
-
}).then(
|
|
1604
|
-
|
|
1605
|
-
|
|
1590
|
+
}).then(params => {
|
|
1591
|
+
const {
|
|
1592
|
+
file
|
|
1593
|
+
} = params;
|
|
1594
|
+
return handleFileImport(this, file, opts);
|
|
1606
1595
|
});
|
|
1607
1596
|
},
|
|
1608
|
-
_saveFile
|
|
1597
|
+
_saveFile(options) {
|
|
1609
1598
|
return saveLocalFile(options);
|
|
1610
1599
|
},
|
|
1611
|
-
_readFile
|
|
1600
|
+
_readFile(options) {
|
|
1612
1601
|
return readLocalFile(options);
|
|
1613
1602
|
},
|
|
1614
|
-
_print
|
|
1615
|
-
|
|
1616
|
-
var opts = Object.assign({
|
|
1603
|
+
_print(options) {
|
|
1604
|
+
const opts = Object.assign({
|
|
1617
1605
|
original: false
|
|
1618
1606
|
// beforePrintMethod
|
|
1619
1607
|
}, this.printOpts, options, {
|
|
@@ -1625,20 +1613,23 @@ var _default = exports.default = {
|
|
|
1625
1613
|
if (!opts.sheetName) {
|
|
1626
1614
|
opts.sheetName = document.title;
|
|
1627
1615
|
}
|
|
1628
|
-
return new Promise(
|
|
1616
|
+
return new Promise(resolve => {
|
|
1629
1617
|
if (opts.content) {
|
|
1630
|
-
resolve(handlePrint(
|
|
1618
|
+
resolve(handlePrint(this, opts, opts.content));
|
|
1631
1619
|
} else {
|
|
1632
|
-
resolve(
|
|
1633
|
-
|
|
1634
|
-
|
|
1620
|
+
resolve(this.exportData(opts).then(({
|
|
1621
|
+
content
|
|
1622
|
+
}) => {
|
|
1623
|
+
return handlePrint(this, opts, content);
|
|
1635
1624
|
}));
|
|
1636
1625
|
}
|
|
1637
1626
|
});
|
|
1638
1627
|
},
|
|
1639
|
-
_getPrintHtml
|
|
1640
|
-
|
|
1641
|
-
|
|
1628
|
+
_getPrintHtml(options) {
|
|
1629
|
+
const {
|
|
1630
|
+
printOpts
|
|
1631
|
+
} = this;
|
|
1632
|
+
const opts = Object.assign({
|
|
1642
1633
|
original: false
|
|
1643
1634
|
// beforePrintMethod
|
|
1644
1635
|
}, printOpts, options, {
|
|
@@ -1647,25 +1638,27 @@ var _default = exports.default = {
|
|
|
1647
1638
|
remote: false,
|
|
1648
1639
|
print: true
|
|
1649
1640
|
});
|
|
1650
|
-
return this.exportData(opts).then(
|
|
1651
|
-
|
|
1641
|
+
return this.exportData(opts).then(({
|
|
1642
|
+
content
|
|
1643
|
+
}) => {
|
|
1652
1644
|
return {
|
|
1653
1645
|
html: content
|
|
1654
1646
|
};
|
|
1655
1647
|
});
|
|
1656
1648
|
},
|
|
1657
|
-
_openImport
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1649
|
+
_openImport(options) {
|
|
1650
|
+
const {
|
|
1651
|
+
importOpts
|
|
1652
|
+
} = this;
|
|
1653
|
+
const defOpts = Object.assign({
|
|
1661
1654
|
mode: 'insertTop',
|
|
1662
1655
|
message: true,
|
|
1663
1656
|
types: _xeUtils.default.keys(importOpts._typeMaps),
|
|
1664
1657
|
modes: ['insertTop', 'covering']
|
|
1665
1658
|
}, options, importOpts);
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1659
|
+
const types = defOpts.types || [];
|
|
1660
|
+
const modes = defOpts.modes || [];
|
|
1661
|
+
const isTree = !!this.getTreeStatus();
|
|
1669
1662
|
if (isTree) {
|
|
1670
1663
|
if (defOpts.message) {
|
|
1671
1664
|
_ui.VxeUI.modal.message({
|
|
@@ -1679,13 +1672,13 @@ var _default = exports.default = {
|
|
|
1679
1672
|
(0, _log.errLog)('vxe.error.reqProp', ['import-config']);
|
|
1680
1673
|
}
|
|
1681
1674
|
// 处理类型
|
|
1682
|
-
|
|
1675
|
+
const typeList = types.map(value => {
|
|
1683
1676
|
return {
|
|
1684
|
-
value
|
|
1685
|
-
label: getI18n(
|
|
1677
|
+
value,
|
|
1678
|
+
label: getI18n(`vxe.export.types.${value}`)
|
|
1686
1679
|
};
|
|
1687
1680
|
});
|
|
1688
|
-
|
|
1681
|
+
const modeList = modes.map(item => {
|
|
1689
1682
|
if (item && item.value) {
|
|
1690
1683
|
return {
|
|
1691
1684
|
value: item.value,
|
|
@@ -1694,37 +1687,39 @@ var _default = exports.default = {
|
|
|
1694
1687
|
}
|
|
1695
1688
|
return {
|
|
1696
1689
|
value: item,
|
|
1697
|
-
label: getI18n(
|
|
1690
|
+
label: getI18n(`vxe.import.modes.${item}`)
|
|
1698
1691
|
};
|
|
1699
1692
|
});
|
|
1700
1693
|
Object.assign(this.importStore, {
|
|
1701
1694
|
file: null,
|
|
1702
1695
|
type: '',
|
|
1703
1696
|
filename: '',
|
|
1704
|
-
modeList
|
|
1705
|
-
typeList
|
|
1697
|
+
modeList,
|
|
1698
|
+
typeList,
|
|
1706
1699
|
visible: true
|
|
1707
1700
|
});
|
|
1708
1701
|
Object.assign(this.importParams, defOpts);
|
|
1709
|
-
if (!modeList.some(
|
|
1710
|
-
return item.value === _this4.importParams.mode;
|
|
1711
|
-
})) {
|
|
1702
|
+
if (!modeList.some(item => item.value === this.importParams.mode)) {
|
|
1712
1703
|
this.importParams.mode = modeList[0].value;
|
|
1713
1704
|
}
|
|
1714
1705
|
this.initStore.import = true;
|
|
1715
1706
|
},
|
|
1716
|
-
_openExport
|
|
1717
|
-
|
|
1718
|
-
|
|
1707
|
+
_openExport(options) {
|
|
1708
|
+
const {
|
|
1709
|
+
exportOpts
|
|
1710
|
+
} = this;
|
|
1711
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1719
1712
|
if (!this.exportConfig) {
|
|
1720
1713
|
(0, _log.errLog)('vxe.error.reqProp', ['export-config']);
|
|
1721
1714
|
}
|
|
1722
1715
|
}
|
|
1723
1716
|
return handleExportAndPrint(this, Object.assign({}, exportOpts, options));
|
|
1724
1717
|
},
|
|
1725
|
-
_openPrint
|
|
1726
|
-
|
|
1727
|
-
|
|
1718
|
+
_openPrint(options) {
|
|
1719
|
+
const {
|
|
1720
|
+
printOpts
|
|
1721
|
+
} = this;
|
|
1722
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1728
1723
|
if (!this.printConfig) {
|
|
1729
1724
|
(0, _log.errLog)('vxe.error.reqProp', ['print-config']);
|
|
1730
1725
|
}
|