vxe-table 3.12.0-beta.9 → 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.
Files changed (75) hide show
  1. package/es/locale/lang/de-DE.js +490 -490
  2. package/es/locale/lang/en-US.js +438 -438
  3. package/es/locale/lang/it-IT.js +692 -0
  4. package/es/locale/lang/ru-RU.js +36 -36
  5. package/es/locale/lang/th-TH.js +692 -0
  6. package/es/locale/lang/zh-CHT.js +19 -19
  7. package/es/style.css +1 -1
  8. package/es/table/module/custom/panel.js +5 -5
  9. package/es/table/module/export/mixin.js +208 -140
  10. package/es/table/src/cell.js +88 -61
  11. package/es/table/src/column.js +2 -2
  12. package/es/table/src/group.js +2 -2
  13. package/es/table/src/methods.js +112 -87
  14. package/es/table/src/table.js +7 -11
  15. package/es/toolbar/src/toolbar.js +22 -4
  16. package/es/ui/index.js +2 -2
  17. package/es/ui/src/log.js +1 -1
  18. package/es/ui/src/vn.js +3 -0
  19. package/lib/index.umd.js +512 -356
  20. package/lib/index.umd.min.js +1 -1
  21. package/lib/locale/lang/de-DE.js +490 -490
  22. package/lib/locale/lang/de-DE.min.js +1 -1
  23. package/lib/locale/lang/en-US.js +438 -438
  24. package/lib/locale/lang/en-US.min.js +1 -1
  25. package/lib/locale/lang/en-US.umd.js +438 -438
  26. package/lib/locale/lang/it-IT.js +698 -0
  27. package/lib/locale/lang/it-IT.min.js +1 -0
  28. package/lib/locale/lang/ru-RU.js +36 -36
  29. package/lib/locale/lang/ru-RU.min.js +1 -1
  30. package/lib/locale/lang/ru-RU.umd.js +36 -36
  31. package/lib/locale/lang/th-TH.js +698 -0
  32. package/lib/locale/lang/th-TH.min.js +1 -0
  33. package/lib/locale/lang/zh-CHT.js +19 -19
  34. package/lib/locale/lang/zh-CHT.min.js +1 -1
  35. package/lib/locale/lang/zh-CHT.umd.js +19 -19
  36. package/lib/style.css +1 -1
  37. package/lib/table/module/custom/panel.js +5 -5
  38. package/lib/table/module/custom/panel.min.js +1 -1
  39. package/lib/table/module/export/mixin.js +239 -167
  40. package/lib/table/module/export/mixin.min.js +1 -1
  41. package/lib/table/src/cell.js +109 -83
  42. package/lib/table/src/cell.min.js +1 -1
  43. package/lib/table/src/methods.js +112 -87
  44. package/lib/table/src/methods.min.js +1 -1
  45. package/lib/table/src/table.js +4 -9
  46. package/lib/table/src/table.min.js +1 -1
  47. package/lib/toolbar/src/toolbar.js +36 -2
  48. package/lib/toolbar/src/toolbar.min.js +1 -1
  49. package/lib/ui/index.js +2 -2
  50. package/lib/ui/index.min.js +1 -1
  51. package/lib/ui/src/log.js +1 -1
  52. package/lib/ui/src/log.min.js +1 -1
  53. package/lib/ui/src/vn.js +3 -0
  54. package/lib/ui/src/vn.min.js +1 -1
  55. package/package.json +3 -3
  56. package/packages/locale/lang/de-DE.ts +492 -491
  57. package/packages/locale/lang/en-US.ts +438 -438
  58. package/packages/locale/lang/it-IT.ts +692 -0
  59. package/packages/locale/lang/ru-RU.ts +36 -36
  60. package/packages/locale/lang/th-TH.ts +692 -0
  61. package/packages/locale/lang/zh-CHT.ts +19 -19
  62. package/packages/table/module/custom/panel.ts +5 -5
  63. package/packages/table/module/export/mixin.ts +227 -156
  64. package/packages/table/src/cell.ts +141 -108
  65. package/packages/table/src/methods.ts +136 -105
  66. package/packages/table/src/table.ts +8 -12
  67. package/packages/toolbar/src/toolbar.ts +26 -8
  68. package/packages/ui/index.ts +1 -1
  69. package/packages/ui/src/vn.ts +4 -1
  70. /package/es/{iconfont.1735301172726.ttf → iconfont.1735661059384.ttf} +0 -0
  71. /package/es/{iconfont.1735301172726.woff → iconfont.1735661059384.woff} +0 -0
  72. /package/es/{iconfont.1735301172726.woff2 → iconfont.1735661059384.woff2} +0 -0
  73. /package/lib/{iconfont.1735301172726.ttf → iconfont.1735661059384.ttf} +0 -0
  74. /package/lib/{iconfont.1735301172726.woff → iconfont.1735661059384.woff} +0 -0
  75. /package/lib/{iconfont.1735301172726.woff2 → iconfont.1735661059384.woff2} +0 -0
@@ -1096,7 +1096,7 @@ export default {
1096
1096
  }
1097
1097
  if (oldAllMaps[newColumn.id]) {
1098
1098
  isSelfToChildStatus = true;
1099
- if (!isSelfToChildDrag) {
1099
+ if (!(isCrossDrag && isSelfToChildDrag)) {
1100
1100
  if (VxeUI.modal) {
1101
1101
  VxeUI.modal.message({
1102
1102
  status: 'error',
@@ -1120,7 +1120,7 @@ export default {
1120
1120
  }
1121
1121
  if (oldAllMaps[newColumn.id]) {
1122
1122
  isSelfToChildStatus = true;
1123
- if (!isSelfToChildDrag) {
1123
+ if (!(isCrossDrag && isSelfToChildDrag)) {
1124
1124
  if (VxeUI.modal) {
1125
1125
  VxeUI.modal.message({
1126
1126
  status: 'error',
@@ -1136,7 +1136,7 @@ export default {
1136
1136
  }
1137
1137
  const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === oldColumn.id);
1138
1138
  // 改变层级
1139
- if (isSelfToChildStatus && isSelfToChildDrag) {
1139
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
1140
1140
  if (oldewMatchRest) {
1141
1141
  const { items: oCols, index: oIndex } = oldewMatchRest;
1142
1142
  const childList = oldColumn.children || [];
@@ -1160,7 +1160,7 @@ export default {
1160
1160
  if (newMatchRest) {
1161
1161
  const { items: nCols, index: nIndex, parent: nParent } = newMatchRest;
1162
1162
  // 转子级
1163
- if (isToChildDrag && prevDragToChild) {
1163
+ if ((isCrossDrag && isToChildDrag) && prevDragToChild) {
1164
1164
  oldColumn.parentId = newColumn.id;
1165
1165
  newColumn.children = (newColumn.children || []).concat([oldColumn]);
1166
1166
  }
@@ -1243,7 +1243,7 @@ export default {
1243
1243
  showDropTip(this, evnt, optEl, false, dragPos);
1244
1244
  return;
1245
1245
  }
1246
- this.prevDragToChild = !!(isToChildDrag && hasCtrlKey && immediate);
1246
+ this.prevDragToChild = !!((isCrossDrag && isToChildDrag) && hasCtrlKey && immediate);
1247
1247
  this.prevDragCol = column;
1248
1248
  this.prevDragPos = dragPos;
1249
1249
  showDropTip(this, evnt, optEl, true, dragPos);
@@ -2,7 +2,6 @@ import XEUtils from 'xe-utils';
2
2
  import { VxeUI } from '../../../ui';
3
3
  import { isColumnInfo, mergeBodyMethod, getCellValue } from '../../src/util';
4
4
  import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils';
5
- import { browse } from '../../../ui/src/dom';
6
5
  import { createHtmlPage, getExportBlobByContent } from './util';
7
6
  import { warnLog, errLog } from '../../../ui/src/log';
8
7
  const { getI18n, renderer } = VxeUI;
@@ -10,30 +9,23 @@ let htmlCellElem;
10
9
  // 导入
11
10
  let fileForm;
12
11
  let fileInput;
13
- // 打印
14
- let printFrame;
15
12
  const csvBOM = '\ufeff';
16
13
  const enterSymbol = '\r\n';
17
- function createFrame() {
18
- const frame = document.createElement('iframe');
19
- frame.className = 'vxe-table--print-frame';
20
- return frame;
21
- }
22
- function hasTreeChildren($xetable, row) {
23
- const treeOpts = $xetable.treeOpts;
14
+ function hasTreeChildren($xeTable, row) {
15
+ const treeOpts = $xeTable.computeTreeOpts;
24
16
  const childrenField = treeOpts.children || treeOpts.childrenField;
25
- return row[childrenField] && row[childrenField].length > 0;
17
+ return row[childrenField] && row[childrenField].length;
26
18
  }
27
- function getSeq($xetable, cellValue, row, $rowIndex, column, $columnIndex) {
28
- const seqOpts = $xetable.seqOpts;
19
+ function getSeq($xeTable, cellValue, row, $rowIndex, column, $columnIndex) {
20
+ const seqOpts = $xeTable.computeSeqOpts;
29
21
  const seqMethod = seqOpts.seqMethod || column.seqMethod;
30
22
  if (seqMethod) {
31
23
  return seqMethod({
32
24
  row,
33
- rowIndex: $xetable.getRowIndex(row),
25
+ rowIndex: $xeTable.getRowIndex(row),
34
26
  $rowIndex,
35
27
  column,
36
- columnIndex: $xetable.getColumnIndex(column),
28
+ columnIndex: $xeTable.getColumnIndex(column),
37
29
  $columnIndex
38
30
  });
39
31
  }
@@ -58,13 +50,18 @@ const toStringValue = (cellValue) => {
58
50
  return eqEmptyValue(cellValue) ? '' : `${cellValue}`;
59
51
  };
60
52
  function getBodyLabelData($xeTable, opts, columns, datas) {
53
+ const props = $xeTable;
61
54
  const { isAllExpand, mode } = opts;
62
- const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xeTable;
63
- const childrenField = treeOpts.children || treeOpts.childrenField;
55
+ const { treeConfig } = props;
56
+ const radioOpts = $xeTable.computeRadioOpts;
57
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
58
+ const treeOpts = $xeTable.computeTreeOpts;
59
+ const columnOpts = $xeTable.computeColumnOpts;
64
60
  if (!htmlCellElem) {
65
61
  htmlCellElem = document.createElement('div');
66
62
  }
67
63
  if (treeConfig) {
64
+ const childrenField = treeOpts.children || treeOpts.childrenField;
68
65
  // 如果是树表格只允许导出数据源
69
66
  const rest = [];
70
67
  const expandMaps = new Map();
@@ -82,11 +79,11 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
82
79
  columns.forEach((column, $columnIndex) => {
83
80
  let cellValue = '';
84
81
  const renderOpts = column.editRender || column.cellRender;
85
- let bodyExportMethod = column.exportMethod;
82
+ let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
86
83
  if (!bodyExportMethod && renderOpts && renderOpts.name) {
87
84
  const compConf = renderer.get(renderOpts.name);
88
85
  if (compConf) {
89
- bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod || compConf.cellExportMethod;
86
+ bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
90
87
  }
91
88
  }
92
89
  if (!bodyExportMethod) {
@@ -98,8 +95,8 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
98
95
  else {
99
96
  switch (column.type) {
100
97
  case 'seq': {
101
- const seqValue = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('');
102
- cellValue = mode === 'all' ? seqValue : getSeq($xeTable, seqValue, row, $rowIndex, column, $columnIndex);
98
+ const seqVal = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('');
99
+ cellValue = mode === 'all' ? seqVal : getSeq($xeTable, seqVal, row, $rowIndex, column, $columnIndex);
103
100
  break;
104
101
  }
105
102
  case 'checkbox':
@@ -146,16 +143,13 @@ function getBodyLabelData($xeTable, opts, columns, datas) {
146
143
  columns.forEach((column, $columnIndex) => {
147
144
  let cellValue = '';
148
145
  const renderOpts = column.editRender || column.cellRender;
149
- let bodyExportMethod = column.exportMethod;
146
+ let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
150
147
  if (!bodyExportMethod && renderOpts && renderOpts.name) {
151
148
  const compConf = renderer.get(renderOpts.name);
152
149
  if (compConf) {
153
- bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod || compConf.cellExportMethod;
150
+ bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
154
151
  }
155
152
  }
156
- if (!bodyExportMethod) {
157
- bodyExportMethod = columnOpts.exportMethod;
158
- }
159
153
  if (bodyExportMethod) {
160
154
  cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts });
161
155
  }
@@ -583,24 +577,25 @@ function clearColumnConvert(columns) {
583
577
  delete column.childNodes;
584
578
  }, { children: 'children' });
585
579
  }
586
- function handleExport($xetable, opts) {
580
+ function handleExport($xeTable, opts) {
581
+ const $xeGrid = $xeTable.$xeGrid;
587
582
  const { remote, columns, colgroups, exportMethod, afterExportMethod } = opts;
588
583
  return new Promise(resolve => {
589
584
  if (remote) {
590
- const params = { options: opts, $table: $xetable, $grid: $xetable.$xegrid };
585
+ const params = { options: opts, $table: $xeTable, $grid: $xeGrid };
591
586
  resolve(exportMethod ? exportMethod(params) : params);
592
587
  }
593
588
  else {
594
- const datas = getExportData($xetable, opts);
595
- resolve($xetable.preventEvent(null, 'event.export', { options: opts, columns, colgroups, datas }, () => {
596
- return downloadFile($xetable, opts, getContent($xetable, opts, columns, datas));
589
+ const datas = getExportData($xeTable, opts);
590
+ resolve($xeTable.preventEvent(null, 'event.export', { options: opts, columns, colgroups, datas }, () => {
591
+ return downloadFile($xeTable, opts, getContent($xeTable, opts, columns, datas));
597
592
  }));
598
593
  }
599
594
  }).then((params) => {
600
595
  clearColumnConvert(columns);
601
596
  if (!opts.print) {
602
597
  if (afterExportMethod) {
603
- afterExportMethod({ status: true, options: opts, $table: $xetable, $grid: $xetable.$xegrid });
598
+ afterExportMethod({ status: true, options: opts, $table: $xeTable, $grid: $xeGrid });
604
599
  }
605
600
  }
606
601
  return Object.assign({ status: true }, params);
@@ -608,7 +603,7 @@ function handleExport($xetable, opts) {
608
603
  clearColumnConvert(columns);
609
604
  if (!opts.print) {
610
605
  if (afterExportMethod) {
611
- afterExportMethod({ status: false, options: opts, $table: $xetable, $grid: $xetable.$xegrid });
606
+ afterExportMethod({ status: false, options: opts, $table: $xeTable, $grid: $xeGrid });
612
607
  }
613
608
  }
614
609
  const params = { status: false };
@@ -948,64 +943,28 @@ export function readLocalFile(options = {}) {
948
943
  fileInput.click();
949
944
  });
950
945
  }
951
- function removePrintFrame() {
952
- if (printFrame) {
953
- if (printFrame.parentNode) {
954
- try {
955
- printFrame.contentDocument.write('');
956
- }
957
- catch (e) { }
958
- printFrame.parentNode.removeChild(printFrame);
959
- }
960
- printFrame = null;
961
- }
962
- }
963
- function appendPrintFrame() {
964
- if (!printFrame.parentNode) {
965
- document.body.appendChild(printFrame);
966
- }
967
- }
968
- function afterPrintEvent() {
969
- requestAnimationFrame(removePrintFrame);
970
- }
971
- export function handlePrint($xetable, opts, content) {
972
- const { beforePrintMethod } = opts;
973
- if (beforePrintMethod) {
974
- content = beforePrintMethod({ content, options: opts, $table: $xetable }) || '';
975
- }
976
- content = createHtmlPage(opts, content);
977
- const blob = getExportBlobByContent(content, opts);
978
- if (browse.msie) {
979
- removePrintFrame();
980
- printFrame = createFrame();
981
- appendPrintFrame();
982
- printFrame.contentDocument.write(content);
983
- printFrame.contentDocument.execCommand('print');
984
- }
985
- else {
986
- if (!printFrame) {
987
- printFrame = createFrame();
988
- printFrame.onload = (evnt) => {
989
- if (evnt.target.src) {
990
- evnt.target.contentWindow.onafterprint = afterPrintEvent;
991
- evnt.target.contentWindow.print();
992
- }
993
- };
994
- }
995
- appendPrintFrame();
996
- printFrame.src = URL.createObjectURL(blob);
997
- }
998
- }
999
- function handleExportAndPrint($xetable, options, isPrint) {
1000
- const { $xegrid, initStore, customOpts, collectColumn, footerTableData, treeConfig, mergeList, isGroup, exportParams, exportOpts } = $xetable;
1001
- const proxyOpts = $xegrid ? $xegrid.proxyOpts : {};
1002
- const selectRecords = $xetable.getCheckboxRecords();
1003
- const hasFooter = !!footerTableData.length;
946
+ function handleExportAndPrint($xeTable, options, isPrint) {
947
+ const props = $xeTable;
948
+ const reactData = $xeTable;
949
+ const internalData = $xeTable;
950
+ const $xeGrid = $xeTable.$xeGrid;
951
+ const { treeConfig, showHeader, showFooter } = props;
952
+ const { initStore, mergeList, mergeFooterList, isGroup, footerTableData, exportStore, exportParams } = reactData;
953
+ const { collectColumn } = internalData;
954
+ const exportOpts = $xeTable.computeExportOpts;
1004
955
  const hasTree = treeConfig;
1005
- const hasMerge = !hasTree && mergeList.length;
956
+ const customOpts = $xeTable.computeCustomOpts;
957
+ const selectRecords = $xeTable.getCheckboxRecords();
958
+ const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {};
959
+ const hasFooter = !!footerTableData.length;
960
+ const hasMerge = !!(mergeList.length || mergeFooterList.length);
1006
961
  const defOpts = Object.assign({
1007
962
  message: true,
1008
- isHeader: true,
963
+ isHeader: showHeader,
964
+ isFooter: showFooter,
965
+ isColgroup: isGroup,
966
+ isMerge: hasMerge,
967
+ useStyle: true,
1009
968
  current: 'current',
1010
969
  modes: ['current', 'selected'].concat(proxyOpts.ajax && proxyOpts.ajax.queryAll ? ['all'] : [])
1011
970
  }, options);
@@ -1040,7 +999,7 @@ function handleExportAndPrint($xetable, options, isPrint) {
1040
999
  column.checked = columns
1041
1000
  ? columns.some((item) => {
1042
1001
  if (isColumnInfo(item)) {
1043
- return column === item;
1002
+ return column.id === item.id;
1044
1003
  }
1045
1004
  else if (XEUtils.isString(item)) {
1046
1005
  return column.field === item;
@@ -1070,7 +1029,7 @@ function handleExportAndPrint($xetable, options, isPrint) {
1070
1029
  }
1071
1030
  });
1072
1031
  // 更新条件
1073
- Object.assign($xetable.exportStore, {
1032
+ Object.assign(exportStore, {
1074
1033
  columns: exportColumns,
1075
1034
  typeList,
1076
1035
  modeList,
@@ -1085,14 +1044,39 @@ function handleExportAndPrint($xetable, options, isPrint) {
1085
1044
  Object.assign(exportParams, {
1086
1045
  mode: selectRecords.length ? 'selected' : 'current'
1087
1046
  }, defOpts);
1088
- if (!modeList.some((item) => item.value === exportParams.mode)) {
1047
+ const { filename, sheetName, mode, type } = exportParams;
1048
+ if (filename) {
1049
+ if (XEUtils.isFunction(filename)) {
1050
+ exportParams.filename = filename({
1051
+ options: defOpts,
1052
+ $table: $xeTable,
1053
+ $grid: $xeGrid
1054
+ });
1055
+ }
1056
+ else {
1057
+ exportParams.filename = `${filename}`;
1058
+ }
1059
+ }
1060
+ if (sheetName) {
1061
+ if (XEUtils.isFunction(sheetName)) {
1062
+ exportParams.sheetName = sheetName({
1063
+ options: defOpts,
1064
+ $table: $xeTable,
1065
+ $grid: $xeGrid
1066
+ });
1067
+ }
1068
+ else {
1069
+ exportParams.sheetName = `${sheetName}`;
1070
+ }
1071
+ }
1072
+ if (!modeList.some(item => item.value === mode)) {
1089
1073
  exportParams.mode = modeList[0].value;
1090
1074
  }
1091
- if (!typeList.some((item) => item.value === exportParams.type)) {
1075
+ if (!typeList.some(item => item.value === type)) {
1092
1076
  exportParams.type = typeList[0].value;
1093
1077
  }
1094
1078
  initStore.export = true;
1095
- return $xetable.$nextTick();
1079
+ return $xeTable.$nextTick();
1096
1080
  }
1097
1081
  const getConvertColumns = (columns) => {
1098
1082
  const result = [];
@@ -1153,11 +1137,13 @@ export default {
1153
1137
  /**
1154
1138
  * 导出文件,支持 csv/html/xml/txt
1155
1139
  * 如果是树表格,则默认是导出所有节点
1156
- * 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数自行转换数据
1140
+ * 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数转换数据
1157
1141
  * @param {Object} options 参数
1158
1142
  */
1159
1143
  _exportData(options) {
1160
- const { $xegrid, isGroup, tableGroupColumn, tableFullColumn, afterFullData, treeConfig, treeOpts, exportOpts } = this;
1144
+ const $xeTable = this;
1145
+ const $xeGrid = $xeTable.$xeGrid;
1146
+ const { isGroup, tableGroupColumn, tableFullColumn, afterFullData, treeConfig, treeOpts, exportOpts } = this;
1161
1147
  const opts = Object.assign({
1162
1148
  // filename: '',
1163
1149
  // sheetName: '',
@@ -1182,13 +1168,13 @@ export default {
1182
1168
  }, exportOpts, {
1183
1169
  print: false
1184
1170
  }, options);
1185
- const { type, mode, columns, original, beforeExportMethod, excludeFields, includeFields } = opts;
1171
+ const { filename, sheetName, type, mode, columns, original, columnFilterMethod, beforeExportMethod, includeFields, excludeFields } = opts;
1186
1172
  let groups = [];
1187
1173
  const customCols = columns && columns.length ? columns : null;
1174
+ const handleOptions = Object.assign({}, opts, { filename: '', sheetName: '' });
1188
1175
  // 如果设置源数据,则默认导出设置了字段的列
1189
- let columnFilterMethod = opts.columnFilterMethod;
1190
1176
  if (!customCols && !columnFilterMethod) {
1191
- columnFilterMethod = ({ column }) => {
1177
+ handleOptions.columnFilterMethod = ({ column }) => {
1192
1178
  if (excludeFields) {
1193
1179
  if (XEUtils.includes(excludeFields, column.field)) {
1194
1180
  return false;
@@ -1204,28 +1190,28 @@ export default {
1204
1190
  };
1205
1191
  }
1206
1192
  if (customCols) {
1207
- opts._isCustomColumn = true;
1208
- groups = XEUtils.searchTree(XEUtils.mapTree(customCols, item => {
1193
+ handleOptions._isCustomColumn = true;
1194
+ groups = XEUtils.searchTree(XEUtils.mapTree(customCols, (item) => {
1209
1195
  let targetColumn;
1210
1196
  if (item) {
1211
1197
  if (isColumnInfo(item)) {
1212
1198
  targetColumn = item;
1213
1199
  }
1214
1200
  else if (XEUtils.isString(item)) {
1215
- targetColumn = this.getColumnByField(item);
1201
+ targetColumn = $xeTable.getColumnByField(item);
1216
1202
  }
1217
1203
  else {
1218
1204
  const colid = item.id || item.colId;
1219
1205
  const type = item.type;
1220
1206
  const field = item.field;
1221
1207
  if (colid) {
1222
- targetColumn = this.getColumnById(colid);
1208
+ targetColumn = $xeTable.getColumnById(colid);
1223
1209
  }
1224
1210
  else if (field && type) {
1225
1211
  targetColumn = tableFullColumn.find((column) => column.field === field && column.type === type);
1226
1212
  }
1227
1213
  else if (field) {
1228
- targetColumn = this.getColumnByField(field);
1214
+ targetColumn = $xeTable.getColumnByField(field);
1229
1215
  }
1230
1216
  else if (type) {
1231
1217
  targetColumn = tableFullColumn.find((column) => column.type === type);
@@ -1236,7 +1222,7 @@ export default {
1236
1222
  }, {
1237
1223
  children: 'childNodes',
1238
1224
  mapChildren: '_children'
1239
- }), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column, $columnIndex: index })), {
1225
+ }), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column: column, $columnIndex: index })), {
1240
1226
  children: '_children',
1241
1227
  mapChildren: 'childNodes',
1242
1228
  original: true
@@ -1254,16 +1240,40 @@ export default {
1254
1240
  }
1255
1241
  }, { children: 'childNodes' });
1256
1242
  // 构建分组层级
1257
- opts.columns = cols;
1258
- opts.colgroups = convertToRows(groups);
1259
- if (!opts.filename) {
1260
- opts.filename = getI18n(opts.original ? 'vxe.table.expOriginFilename' : 'vxe.table.expFilename', [XEUtils.toDateString(Date.now(), 'yyyyMMddHHmmss')]);
1243
+ handleOptions.columns = cols;
1244
+ handleOptions.colgroups = convertToRows(groups);
1245
+ if (filename) {
1246
+ if (XEUtils.isFunction(filename)) {
1247
+ handleOptions.filename = filename({
1248
+ options: opts,
1249
+ $table: $xeTable,
1250
+ $grid: $xeGrid
1251
+ });
1252
+ }
1253
+ else {
1254
+ handleOptions.filename = `${filename}`;
1255
+ }
1256
+ }
1257
+ if (!handleOptions.filename) {
1258
+ handleOptions.filename = getI18n(handleOptions.original ? 'vxe.table.expOriginFilename' : 'vxe.table.expFilename', [XEUtils.toDateString(Date.now(), 'yyyyMMddHHmmss')]);
1259
+ }
1260
+ if (sheetName) {
1261
+ if (XEUtils.isFunction(sheetName)) {
1262
+ handleOptions.sheetName = sheetName({
1263
+ options: opts,
1264
+ $table: $xeTable,
1265
+ $grid: $xeGrid
1266
+ });
1267
+ }
1268
+ else {
1269
+ handleOptions.sheetName = `${sheetName}`;
1270
+ }
1261
1271
  }
1262
- if (!opts.sheetName) {
1263
- opts.sheetName = document.title;
1272
+ if (!handleOptions.sheetName) {
1273
+ handleOptions.sheetName = document.title || '';
1264
1274
  }
1265
1275
  // 检查类型,如果为自定义导出,则不需要校验类型
1266
- if (!opts.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
1276
+ if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
1267
1277
  errLog('vxe.error.notType', [type]);
1268
1278
  if (process.env.NODE_ENV === 'development') {
1269
1279
  if (['xlsx', 'pdf'].includes(type)) {
@@ -1273,17 +1283,17 @@ export default {
1273
1283
  const params = { status: false };
1274
1284
  return Promise.reject(params);
1275
1285
  }
1276
- if (!opts.print) {
1286
+ if (!handleOptions.print) {
1277
1287
  if (beforeExportMethod) {
1278
- beforeExportMethod({ options: opts, $table: this, $grid: $xegrid });
1288
+ beforeExportMethod({ options: handleOptions, $table: $xeTable, $grid: $xeGrid });
1279
1289
  }
1280
1290
  }
1281
1291
  if (!opts.data) {
1282
- opts.data = [];
1292
+ handleOptions.data = [];
1283
1293
  if (mode === 'selected') {
1284
- const selectRecords = this.getCheckboxRecords();
1294
+ const selectRecords = $xeTable.getCheckboxRecords();
1285
1295
  if (['html', 'pdf'].indexOf(type) > -1 && treeConfig) {
1286
- opts.data = XEUtils.searchTree(this.getTableData().fullData, (item) => selectRecords.indexOf(item) > -1, Object.assign({}, treeOpts, { data: '_row' }));
1296
+ opts.data = XEUtils.searchTree($xeTable.getTableData().fullData, item => $xeTable.findRowIndexOf(selectRecords, item) > -1, Object.assign({}, treeOpts, { data: '_row' }));
1287
1297
  }
1288
1298
  else {
1289
1299
  opts.data = selectRecords;
@@ -1291,12 +1301,16 @@ export default {
1291
1301
  }
1292
1302
  else if (mode === 'all') {
1293
1303
  if (process.env.NODE_ENV === 'development') {
1294
- if (!$xegrid) {
1304
+ if (!$xeGrid) {
1295
1305
  warnLog('vxe.error.errProp', ['all', 'mode=current,selected']);
1296
1306
  }
1297
1307
  }
1298
- if ($xegrid && !opts.remote) {
1299
- const { beforeQueryAll, afterQueryAll, ajax = {}, props = {} } = $xegrid.proxyOpts;
1308
+ if ($xeGrid && !handleOptions.remote) {
1309
+ const gridReactData = $xeGrid;
1310
+ const proxyOpts = $xeGrid.computeProxyOpts;
1311
+ const { sortData } = gridReactData;
1312
+ const { beforeQueryAll, afterQueryAll, ajax = {} } = proxyOpts;
1313
+ const resConfigs = proxyOpts.response || proxyOpts.props || {};
1300
1314
  const ajaxMethods = ajax.queryAll;
1301
1315
  const queryAllSuccessMethods = ajax.queryAllSuccess;
1302
1316
  const queryAllErrorMethods = ajax.queryAllError;
@@ -1307,24 +1321,25 @@ export default {
1307
1321
  }
1308
1322
  if (ajaxMethods) {
1309
1323
  const params = {
1310
- $table: this,
1311
- $grid: $xegrid,
1312
- sort: $xegrid.sortData,
1313
- filters: $xegrid.filterData,
1314
- form: $xegrid.formData,
1315
- target: ajaxMethods,
1316
- options: opts
1324
+ $table: $xeTable,
1325
+ $grid: $xeGrid,
1326
+ sort: sortData.length ? sortData[0] : {},
1327
+ sorts: sortData,
1328
+ filters: gridReactData.filterData,
1329
+ form: gridReactData.formData,
1330
+ options: handleOptions
1317
1331
  };
1318
1332
  return Promise.resolve((beforeQueryAll || ajaxMethods)(params))
1319
1333
  .then(rest => {
1320
- opts.data = (props.list ? XEUtils.get(rest, props.list) : rest) || [];
1334
+ const listProp = resConfigs.list;
1335
+ handleOptions.data = (listProp ? (XEUtils.isFunction(listProp) ? listProp({ data: rest, $grid: $xeGrid }) : XEUtils.get(rest, listProp)) : rest) || [];
1321
1336
  if (afterQueryAll) {
1322
1337
  afterQueryAll(params);
1323
1338
  }
1324
1339
  if (queryAllSuccessMethods) {
1325
1340
  queryAllSuccessMethods(Object.assign(Object.assign({}, params), { response: rest }));
1326
1341
  }
1327
- return handleExport(this, opts);
1342
+ return handleExport($xeTable, handleOptions);
1328
1343
  })
1329
1344
  .catch((rest) => {
1330
1345
  if (queryAllErrorMethods) {
@@ -1335,10 +1350,10 @@ export default {
1335
1350
  }
1336
1351
  }
1337
1352
  else if (mode === 'current') {
1338
- opts.data = afterFullData;
1353
+ handleOptions.data = afterFullData;
1339
1354
  }
1340
1355
  }
1341
- return handleExport(this, opts);
1356
+ return handleExport($xeTable, opts);
1342
1357
  },
1343
1358
  _importByFile(file, options) {
1344
1359
  const opts = Object.assign({}, options);
@@ -1376,6 +1391,8 @@ export default {
1376
1391
  return readLocalFile(options);
1377
1392
  },
1378
1393
  _print(options) {
1394
+ const $xeTable = this;
1395
+ const $xeGrid = $xeTable.$xeGrid;
1379
1396
  const opts = Object.assign({
1380
1397
  original: false
1381
1398
  // beforePrintMethod
@@ -1385,22 +1402,73 @@ export default {
1385
1402
  remote: false,
1386
1403
  print: true
1387
1404
  });
1388
- if (!opts.sheetName) {
1389
- opts.sheetName = document.title;
1405
+ const { sheetName } = opts;
1406
+ let printTitle = '';
1407
+ if (sheetName) {
1408
+ if (XEUtils.isFunction(sheetName)) {
1409
+ printTitle = sheetName({
1410
+ options: opts,
1411
+ $table: $xeTable,
1412
+ $grid: $xeGrid
1413
+ });
1414
+ }
1415
+ else {
1416
+ printTitle = `${sheetName}`;
1417
+ }
1418
+ }
1419
+ if (!printTitle) {
1420
+ printTitle = document.title || '';
1390
1421
  }
1391
- return new Promise(resolve => {
1392
- if (opts.content) {
1393
- resolve(handlePrint(this, opts, opts.content));
1422
+ const beforePrintMethod = opts.beforePrintMethod;
1423
+ const tableHtml = opts.html || opts.content;
1424
+ return new Promise((resolve, reject) => {
1425
+ if (VxeUI.print) {
1426
+ if (tableHtml) {
1427
+ resolve(VxeUI.print({
1428
+ title: printTitle,
1429
+ html: tableHtml,
1430
+ customStyle: opts.style,
1431
+ beforeMethod: beforePrintMethod
1432
+ ? ({ html }) => {
1433
+ return beforePrintMethod({
1434
+ html,
1435
+ content: html,
1436
+ options: opts,
1437
+ $table: $xeTable
1438
+ });
1439
+ }
1440
+ : undefined
1441
+ }));
1442
+ }
1443
+ else {
1444
+ resolve($xeTable.exportData(opts).then(({ content }) => {
1445
+ return VxeUI.print({
1446
+ title: printTitle,
1447
+ html: content,
1448
+ customStyle: opts.style,
1449
+ beforeMethod: beforePrintMethod
1450
+ ? ({ html }) => {
1451
+ return beforePrintMethod({
1452
+ html,
1453
+ content: html,
1454
+ options: opts,
1455
+ $table: $xeTable
1456
+ });
1457
+ }
1458
+ : undefined
1459
+ });
1460
+ }));
1461
+ }
1394
1462
  }
1395
1463
  else {
1396
- resolve(this.exportData(opts).then(({ content }) => {
1397
- return handlePrint(this, opts, content);
1398
- }));
1464
+ const e = { status: false };
1465
+ reject(e);
1399
1466
  }
1400
1467
  });
1401
1468
  },
1402
1469
  _getPrintHtml(options) {
1403
- const { printOpts } = this;
1470
+ const $xeTable = this;
1471
+ const printOpts = $xeTable.computePrintOpts;
1404
1472
  const opts = Object.assign({
1405
1473
  original: false
1406
1474
  // beforePrintMethod
@@ -1410,7 +1478,7 @@ export default {
1410
1478
  remote: false,
1411
1479
  print: true
1412
1480
  });
1413
- return this.exportData(opts).then(({ content }) => {
1481
+ return $xeTable.exportData(opts).then(({ content }) => {
1414
1482
  return {
1415
1483
  html: content
1416
1484
  };