vxe-table 4.20.2 → 4.20.4

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 (162) hide show
  1. package/dist/all.esm.js +231 -114
  2. package/dist/style.css +1 -1
  3. package/es/locale/lang/ar-EG.js +7 -0
  4. package/es/locale/lang/de-DE.js +7 -0
  5. package/es/locale/lang/en-US.js +7 -0
  6. package/es/locale/lang/es-ES.js +7 -0
  7. package/es/locale/lang/fr-FR.js +7 -0
  8. package/es/locale/lang/hu-HU.js +7 -0
  9. package/es/locale/lang/hy-AM.js +7 -0
  10. package/es/locale/lang/id-ID.js +7 -0
  11. package/es/locale/lang/it-IT.js +7 -0
  12. package/es/locale/lang/ja-JP.js +7 -0
  13. package/es/locale/lang/ko-KR.js +7 -0
  14. package/es/locale/lang/ms-MY.js +7 -0
  15. package/es/locale/lang/nb-NO.js +7 -0
  16. package/es/locale/lang/pt-BR.js +7 -0
  17. package/es/locale/lang/ru-RU.js +7 -0
  18. package/es/locale/lang/th-TH.js +7 -0
  19. package/es/locale/lang/ug-CN.js +7 -0
  20. package/es/locale/lang/uk-UA.js +7 -0
  21. package/es/locale/lang/uz-UZ.js +7 -0
  22. package/es/locale/lang/vi-VN.js +7 -0
  23. package/es/locale/lang/zh-CHT.js +7 -0
  24. package/es/locale/lang/zh-CN.js +7 -0
  25. package/es/style.css +1 -1
  26. package/es/table/module/export/export-panel.js +61 -47
  27. package/es/table/module/export/hook.js +105 -27
  28. package/es/table/module/export/util.js +1 -1
  29. package/es/table/src/body.js +1 -1
  30. package/es/table/src/footer.js +1 -1
  31. package/es/table/src/header.js +5 -3
  32. package/es/table/src/table.js +48 -34
  33. package/es/table/src/util.js +1 -0
  34. package/es/ui/index.js +2 -1
  35. package/es/ui/src/log.js +1 -1
  36. package/lib/index.umd.js +164 -55
  37. package/lib/index.umd.min.js +1 -1
  38. package/lib/locale/lang/ar-EG.js +7 -0
  39. package/lib/locale/lang/ar-EG.min.js +1 -1
  40. package/lib/locale/lang/ar-EG.umd.js +7 -0
  41. package/lib/locale/lang/de-DE.js +7 -0
  42. package/lib/locale/lang/de-DE.min.js +1 -1
  43. package/lib/locale/lang/de-DE.umd.js +7 -0
  44. package/lib/locale/lang/en-US.js +7 -0
  45. package/lib/locale/lang/en-US.min.js +1 -1
  46. package/lib/locale/lang/en-US.umd.js +7 -0
  47. package/lib/locale/lang/es-ES.js +7 -0
  48. package/lib/locale/lang/es-ES.min.js +1 -1
  49. package/lib/locale/lang/es-ES.umd.js +7 -0
  50. package/lib/locale/lang/fr-FR.js +7 -0
  51. package/lib/locale/lang/fr-FR.min.js +1 -1
  52. package/lib/locale/lang/fr-FR.umd.js +7 -0
  53. package/lib/locale/lang/hu-HU.js +7 -0
  54. package/lib/locale/lang/hu-HU.min.js +1 -1
  55. package/lib/locale/lang/hu-HU.umd.js +7 -0
  56. package/lib/locale/lang/hy-AM.js +7 -0
  57. package/lib/locale/lang/hy-AM.min.js +1 -1
  58. package/lib/locale/lang/hy-AM.umd.js +7 -0
  59. package/lib/locale/lang/id-ID.js +7 -0
  60. package/lib/locale/lang/id-ID.min.js +1 -1
  61. package/lib/locale/lang/id-ID.umd.js +7 -0
  62. package/lib/locale/lang/it-IT.js +7 -0
  63. package/lib/locale/lang/it-IT.min.js +1 -1
  64. package/lib/locale/lang/it-IT.umd.js +7 -0
  65. package/lib/locale/lang/ja-JP.js +7 -0
  66. package/lib/locale/lang/ja-JP.min.js +1 -1
  67. package/lib/locale/lang/ja-JP.umd.js +7 -0
  68. package/lib/locale/lang/ko-KR.js +7 -0
  69. package/lib/locale/lang/ko-KR.min.js +1 -1
  70. package/lib/locale/lang/ko-KR.umd.js +7 -0
  71. package/lib/locale/lang/ms-MY.js +7 -0
  72. package/lib/locale/lang/ms-MY.min.js +1 -1
  73. package/lib/locale/lang/ms-MY.umd.js +7 -0
  74. package/lib/locale/lang/nb-NO.js +7 -0
  75. package/lib/locale/lang/nb-NO.min.js +1 -1
  76. package/lib/locale/lang/nb-NO.umd.js +7 -0
  77. package/lib/locale/lang/pt-BR.js +7 -0
  78. package/lib/locale/lang/pt-BR.min.js +1 -1
  79. package/lib/locale/lang/pt-BR.umd.js +7 -0
  80. package/lib/locale/lang/ru-RU.js +7 -0
  81. package/lib/locale/lang/ru-RU.min.js +1 -1
  82. package/lib/locale/lang/ru-RU.umd.js +7 -0
  83. package/lib/locale/lang/th-TH.js +7 -0
  84. package/lib/locale/lang/th-TH.min.js +1 -1
  85. package/lib/locale/lang/th-TH.umd.js +7 -0
  86. package/lib/locale/lang/ug-CN.js +7 -0
  87. package/lib/locale/lang/ug-CN.min.js +1 -1
  88. package/lib/locale/lang/ug-CN.umd.js +7 -0
  89. package/lib/locale/lang/uk-UA.js +7 -0
  90. package/lib/locale/lang/uk-UA.min.js +1 -1
  91. package/lib/locale/lang/uk-UA.umd.js +7 -0
  92. package/lib/locale/lang/uz-UZ.js +7 -0
  93. package/lib/locale/lang/uz-UZ.min.js +1 -1
  94. package/lib/locale/lang/uz-UZ.umd.js +7 -0
  95. package/lib/locale/lang/vi-VN.js +7 -0
  96. package/lib/locale/lang/vi-VN.min.js +1 -1
  97. package/lib/locale/lang/vi-VN.umd.js +7 -0
  98. package/lib/locale/lang/zh-CHT.js +7 -0
  99. package/lib/locale/lang/zh-CHT.min.js +1 -1
  100. package/lib/locale/lang/zh-CHT.umd.js +7 -0
  101. package/lib/locale/lang/zh-CN.js +7 -0
  102. package/lib/locale/lang/zh-CN.min.js +1 -1
  103. package/lib/locale/lang/zh-CN.umd.js +7 -0
  104. package/lib/style.css +1 -1
  105. package/lib/table/module/export/export-panel.js +32 -13
  106. package/lib/table/module/export/export-panel.min.js +1 -1
  107. package/lib/table/module/export/hook.js +105 -27
  108. package/lib/table/module/export/hook.min.js +1 -1
  109. package/lib/table/module/export/util.js +1 -1
  110. package/lib/table/module/export/util.min.js +1 -1
  111. package/lib/table/src/body.js +1 -1
  112. package/lib/table/src/body.min.js +1 -1
  113. package/lib/table/src/footer.js +1 -1
  114. package/lib/table/src/footer.min.js +1 -1
  115. package/lib/table/src/header.js +6 -3
  116. package/lib/table/src/header.min.js +1 -1
  117. package/lib/table/src/table.js +7 -7
  118. package/lib/table/src/table.min.js +1 -1
  119. package/lib/table/src/util.js +1 -0
  120. package/lib/table/src/util.min.js +1 -1
  121. package/lib/ui/index.js +2 -1
  122. package/lib/ui/index.min.js +1 -1
  123. package/lib/ui/src/log.js +1 -1
  124. package/lib/ui/src/log.min.js +1 -1
  125. package/package.json +2 -2
  126. package/packages/locale/lang/ar-EG.ts +7 -0
  127. package/packages/locale/lang/de-DE.ts +7 -0
  128. package/packages/locale/lang/en-US.ts +7 -0
  129. package/packages/locale/lang/es-ES.ts +7 -0
  130. package/packages/locale/lang/fr-FR.ts +7 -0
  131. package/packages/locale/lang/hu-HU.ts +7 -0
  132. package/packages/locale/lang/hy-AM.ts +7 -0
  133. package/packages/locale/lang/id-ID.ts +7 -0
  134. package/packages/locale/lang/it-IT.ts +7 -0
  135. package/packages/locale/lang/ja-JP.ts +7 -0
  136. package/packages/locale/lang/ko-KR.ts +7 -0
  137. package/packages/locale/lang/ms-MY.ts +7 -0
  138. package/packages/locale/lang/nb-NO.ts +7 -0
  139. package/packages/locale/lang/pt-BR.ts +7 -0
  140. package/packages/locale/lang/ru-RU.ts +7 -0
  141. package/packages/locale/lang/th-TH.ts +7 -0
  142. package/packages/locale/lang/ug-CN.ts +7 -0
  143. package/packages/locale/lang/uk-UA.ts +7 -0
  144. package/packages/locale/lang/uz-UZ.ts +7 -0
  145. package/packages/locale/lang/vi-VN.ts +7 -0
  146. package/packages/locale/lang/zh-CHT.ts +7 -0
  147. package/packages/locale/lang/zh-CN.ts +7 -0
  148. package/packages/table/module/export/export-panel.ts +120 -105
  149. package/packages/table/module/export/hook.ts +112 -28
  150. package/packages/table/module/export/util.ts +1 -1
  151. package/packages/table/src/body.ts +1 -1
  152. package/packages/table/src/footer.ts +1 -1
  153. package/packages/table/src/header.ts +5 -3
  154. package/packages/table/src/table.ts +48 -34
  155. package/packages/table/src/util.ts +3 -2
  156. package/packages/ui/index.ts +1 -0
  157. /package/es/{iconfont.1784122393131.ttf → iconfont.1784366386890.ttf} +0 -0
  158. /package/es/{iconfont.1784122393131.woff → iconfont.1784366386890.woff} +0 -0
  159. /package/es/{iconfont.1784122393131.woff2 → iconfont.1784366386890.woff2} +0 -0
  160. /package/lib/{iconfont.1784122393131.ttf → iconfont.1784366386890.ttf} +0 -0
  161. /package/lib/{iconfont.1784122393131.woff → iconfont.1784366386890.woff} +0 -0
  162. /package/lib/{iconfont.1784122393131.woff2 → iconfont.1784366386890.woff2} +0 -0
@@ -34,6 +34,13 @@ export default defineVxeComponent({
34
34
  const xButtonConfirm = ref();
35
35
  const xInputFilename = ref();
36
36
  const xInputSheetname = ref();
37
+ const computeColWidthModeOptions = computed(() => {
38
+ return [
39
+ { value: '', label: getI18n('vxe.export.wdModes.default') },
40
+ { value: 'auto', label: getI18n('vxe.export.wdModes.auto') },
41
+ { value: 'scale', label: getI18n('vxe.export.wdModes.scale') }
42
+ ];
43
+ });
37
44
  const computeCheckedAll = computed(() => {
38
45
  const { storeData } = props;
39
46
  return storeData.columns.every((column) => column.checked);
@@ -158,6 +165,7 @@ export default defineVxeComponent({
158
165
  const showSheet = computeShowSheet.value;
159
166
  const supportMerge = computeSupportMerge.value;
160
167
  const supportStyle = computeSupportStyle.value;
168
+ const colWidthModeOptions = computeColWidthModeOptions.value;
161
169
  // const supportGroup = computeSupportGroup.value
162
170
  const slots = defaultOptions.slots || {};
163
171
  const topSlot = slots.top;
@@ -358,6 +366,22 @@ export default defineVxeComponent({
358
366
  ])
359
367
  ])
360
368
  ]),
369
+ isPrint
370
+ ? h('tr', [
371
+ h('td', getI18n('vxe.export.widthMode')),
372
+ h('td', [
373
+ VxeUISelectComponent
374
+ ? h(VxeUISelectComponent, {
375
+ modelValue: defaultOptions.widthMode,
376
+ options: colWidthModeOptions,
377
+ 'onUpdate:modelValue'(value) {
378
+ defaultOptions.widthMode = value;
379
+ }
380
+ })
381
+ : renderEmptyElement($xeTable)
382
+ ])
383
+ ])
384
+ : renderEmptyElement($xeTable),
361
385
  h('tr', [
362
386
  h('td', getI18n('vxe.export.expOpts')),
363
387
  parameterSlot
@@ -369,9 +393,9 @@ export default defineVxeComponent({
369
393
  : h('td', [
370
394
  h('div', {
371
395
  class: 'vxe-table-export--panel-option-row'
372
- }, [
373
- VxeUICheckboxComponent
374
- ? h(VxeUICheckboxComponent, {
396
+ }, VxeUICheckboxComponent
397
+ ? [
398
+ h(VxeUICheckboxComponent, {
375
399
  modelValue: hasEmptyData || isHeader,
376
400
  disabled: hasEmptyData,
377
401
  title: getI18n('vxe.export.expHeaderTitle'),
@@ -379,10 +403,8 @@ export default defineVxeComponent({
379
403
  'onUpdate:modelValue'(value) {
380
404
  defaultOptions.isHeader = value;
381
405
  }
382
- })
383
- : renderEmptyElement($xeTable),
384
- VxeUICheckboxComponent
385
- ? h(VxeUICheckboxComponent, {
406
+ }),
407
+ h(VxeUICheckboxComponent, {
386
408
  modelValue: defaultOptions.isFooter,
387
409
  disabled: !storeData.hasFooter,
388
410
  title: getI18n('vxe.export.expFooterTitle'),
@@ -390,10 +412,8 @@ export default defineVxeComponent({
390
412
  'onUpdate:modelValue'(value) {
391
413
  defaultOptions.isFooter = value;
392
414
  }
393
- })
394
- : renderEmptyElement($xeTable),
395
- VxeUICheckboxComponent
396
- ? h(VxeUICheckboxComponent, {
415
+ }),
416
+ h(VxeUICheckboxComponent, {
397
417
  modelValue: isHeader ? defaultOptions.isTitle : false,
398
418
  disabled: !isHeader,
399
419
  title: getI18n('vxe.export.expTitleTitle'),
@@ -401,10 +421,8 @@ export default defineVxeComponent({
401
421
  'onUpdate:modelValue'(value) {
402
422
  defaultOptions.isTitle = value;
403
423
  }
404
- })
405
- : renderEmptyElement($xeTable),
406
- VxeUICheckboxComponent
407
- ? h(VxeUICheckboxComponent, {
424
+ }),
425
+ h(VxeUICheckboxComponent, {
408
426
  modelValue: isHeader && hasColgroup && supportMerge ? defaultOptions.isColgroup : false,
409
427
  title: getI18n('vxe.export.expColgroupTitle'),
410
428
  disabled: !isHeader || !hasColgroup || !supportMerge,
@@ -413,13 +431,13 @@ export default defineVxeComponent({
413
431
  defaultOptions.isColgroup = value;
414
432
  }
415
433
  })
416
- : renderEmptyElement($xeTable)
417
- ]),
434
+ ]
435
+ : []),
418
436
  h('div', {
419
437
  class: 'vxe-table-export--panel-option-row'
420
- }, [
421
- VxeUICheckboxComponent
422
- ? h(VxeUICheckboxComponent, {
438
+ }, VxeUICheckboxComponent
439
+ ? [
440
+ h(VxeUICheckboxComponent, {
423
441
  modelValue: hasEmptyData ? false : defaultOptions.original,
424
442
  disabled: hasEmptyData,
425
443
  title: getI18n('vxe.export.expOriginalTitle'),
@@ -427,10 +445,8 @@ export default defineVxeComponent({
427
445
  'onUpdate:modelValue'(value) {
428
446
  defaultOptions.original = value;
429
447
  }
430
- })
431
- : renderEmptyElement($xeTable),
432
- VxeUICheckboxComponent
433
- ? h(VxeUICheckboxComponent, {
448
+ }),
449
+ h(VxeUICheckboxComponent, {
434
450
  modelValue: hasMerge && supportMerge && checkedAll ? defaultOptions.isMerge : false,
435
451
  title: getI18n('vxe.export.expMergeTitle'),
436
452
  disabled: hasEmptyData || !hasMerge || !supportMerge || !checkedAll,
@@ -438,25 +454,25 @@ export default defineVxeComponent({
438
454
  'onUpdate:modelValue'(value) {
439
455
  defaultOptions.isMerge = value;
440
456
  }
441
- })
442
- : renderEmptyElement($xeTable),
443
- isPrint || !VxeUICheckboxComponent
444
- ? renderEmptyElement($xeTable)
445
- : h(VxeUICheckboxComponent, {
446
- modelValue: supportStyle ? defaultOptions.useStyle : false,
447
- disabled: !supportStyle,
448
- title: getI18n('vxe.export.expUseStyleTitle'),
449
- content: getI18n('vxe.export.expOptUseStyle'),
450
- 'onUpdate:modelValue'(value) {
451
- defaultOptions.useStyle = value;
452
- }
453
- })
454
- ]),
457
+ }),
458
+ isPrint
459
+ ? renderEmptyElement($xeTable)
460
+ : h(VxeUICheckboxComponent, {
461
+ modelValue: supportStyle ? defaultOptions.useStyle : false,
462
+ disabled: !supportStyle,
463
+ title: getI18n('vxe.export.expUseStyleTitle'),
464
+ content: getI18n('vxe.export.expOptUseStyle'),
465
+ 'onUpdate:modelValue'(value) {
466
+ defaultOptions.useStyle = value;
467
+ }
468
+ })
469
+ ]
470
+ : []),
455
471
  h('div', {
456
472
  class: 'vxe-table-export--panel-option-row'
457
- }, [
458
- VxeUICheckboxComponent
459
- ? h(VxeUICheckboxComponent, {
473
+ }, VxeUICheckboxComponent
474
+ ? [
475
+ h(VxeUICheckboxComponent, {
460
476
  modelValue: hasTree ? defaultOptions.isTreeAllExpanded : false,
461
477
  disabled: hasEmptyData || !hasTree,
462
478
  title: getI18n('vxe.export.expTreeAllExpandTitle'),
@@ -464,10 +480,8 @@ export default defineVxeComponent({
464
480
  'onUpdate:modelValue'(value) {
465
481
  defaultOptions.isTreeAllExpanded = value;
466
482
  }
467
- })
468
- : renderEmptyElement($xeTable),
469
- VxeUICheckboxComponent
470
- ? h(VxeUICheckboxComponent, {
483
+ }),
484
+ h(VxeUICheckboxComponent, {
471
485
  modelValue: hasRowGroup ? defaultOptions.isRowGroupAllExpanded : false,
472
486
  disabled: hasEmptyData || !hasRowGroup,
473
487
  title: getI18n('vxe.export.expRowGroupAllExpandTitle'),
@@ -476,8 +490,8 @@ export default defineVxeComponent({
476
490
  defaultOptions.isRowGroupAllExpanded = value;
477
491
  }
478
492
  })
479
- : renderEmptyElement($xeTable)
480
- ])
493
+ ]
494
+ : [])
481
495
  ])
482
496
  ])
483
497
  ]
@@ -3,7 +3,7 @@ import XEUtils from 'xe-utils';
3
3
  import { VxeUI } from '../../../ui';
4
4
  import { isColumnInfo, getCellValue, createHandleGetRowId } from '../../src/util';
5
5
  import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils';
6
- import { hasClass } from '../../../ui/src/dom';
6
+ import { hasClass, toCssUnit } from '../../../ui/src/dom';
7
7
  import { createHtmlPage, getExportBlobByContent } from './util';
8
8
  import { createComponentLog } from '../../../ui/src/log';
9
9
  const { warnLog, errLog } = createComponentLog('table');
@@ -666,22 +666,106 @@ hooks.add('tableExportModule', {
666
666
  }
667
667
  return isEllipsis;
668
668
  };
669
+ const getCustomColKey = (conf) => {
670
+ return `${conf.field || ''}:${conf.type || ''}`;
671
+ };
669
672
  const toHtml = (opts, columns, datas) => {
670
673
  const { id, border, treeConfig, headerAlign: allHeaderAlign, align: allAlign, footerAlign: allFooterAlign, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow } = props;
671
674
  const { isAllSelected, isIndeterminate } = reactData;
672
675
  const { mergeBodyCellMaps, mergeFooterCellMaps } = internalData;
673
676
  const treeOpts = computeTreeOpts.value;
674
- const { print: isPrint, isHeader, isFooter, isColgroup, isMerge, colgroups, original } = opts;
677
+ const { print: isPrint, widthMode, isHeader, isFooter, isColgroup, isMerge, colgroups, _columnConfs, original } = opts;
678
+ const isAutoWidth = widthMode === 'auto';
679
+ const isScaleWidth = widthMode === 'scale';
680
+ const isDefaultWidth = !isAutoWidth && !isScaleWidth;
681
+ const customWidthMaps = {};
682
+ if (_columnConfs) {
683
+ _columnConfs.forEach(conf => {
684
+ if (!isColumnInfo(conf)) {
685
+ if ((conf.field || conf.type) && conf.width) {
686
+ customWidthMaps[getCustomColKey(conf)] = conf.width;
687
+ }
688
+ }
689
+ });
690
+ }
691
+ // 计算宽度
692
+ const colWidthMaps = {};
693
+ const printWidthMaps = {};
694
+ if (isPrint) {
695
+ let tableWidth = 0;
696
+ columns.forEach(column => {
697
+ tableWidth += column.renderWidth;
698
+ });
699
+ if (colgroups) {
700
+ colgroups.forEach((cols) => {
701
+ cols.forEach((column) => {
702
+ if (!column.childNodes || !column.childNodes.length) {
703
+ return;
704
+ }
705
+ let childWidth = 0;
706
+ let countChild = 0;
707
+ XEUtils.eachTree([column], item => {
708
+ if (!item.childNodes || !column.childNodes.length) {
709
+ countChild++;
710
+ }
711
+ const ptWidth = printWidthMaps[item.id];
712
+ childWidth += ptWidth || 0;
713
+ }, { children: 'childNodes' });
714
+ const colWidth = childWidth - countChild;
715
+ colWidthMaps[column.id] = colWidth;
716
+ printWidthMaps[column.id] = XEUtils.floor(colWidth / tableWidth * 180, 2);
717
+ });
718
+ });
719
+ }
720
+ columns.forEach(column => {
721
+ const colWidth = column.renderWidth;
722
+ if (column.width) {
723
+ colWidthMaps[column.id] = colWidth;
724
+ }
725
+ printWidthMaps[column.id] = XEUtils.floor(colWidth / tableWidth * 180, 2);
726
+ });
727
+ }
728
+ const getHeaderWidthStyle = (column) => {
729
+ const cmColKey = getCustomColKey(column);
730
+ const cmWidthMaps = customWidthMaps[cmColKey];
731
+ if (cmWidthMaps) {
732
+ return 'width:' + toCssUnit(cmWidthMaps);
733
+ }
734
+ if (isAutoWidth) {
735
+ return '';
736
+ }
737
+ if (isScaleWidth) {
738
+ return printWidthMaps[column.id] ? ('width:' + printWidthMaps[column.id] + 'mm') : '';
739
+ }
740
+ return colWidthMaps[column.id] ? ('width:' + toCssUnit(colWidthMaps[column.id])) : '';
741
+ };
742
+ const getCellWidthStyle = (column) => {
743
+ const cmColKey = getCustomColKey(column);
744
+ const cmWidthMaps = customWidthMaps[cmColKey];
745
+ if (cmWidthMaps) {
746
+ return 'width:' + toCssUnit(cmWidthMaps);
747
+ }
748
+ if (isAutoWidth || isDefaultWidth) {
749
+ return '';
750
+ }
751
+ if (isScaleWidth) {
752
+ return printWidthMaps[column.id] ? ('width:' + printWidthMaps[column.id] + 'mm') : '';
753
+ }
754
+ return colWidthMaps[column.id] ? ('width:' + toCssUnit(colWidthMaps[column.id])) : '';
755
+ };
675
756
  const allCls = 'check-all';
676
757
  const clss = [
677
758
  'vxe-table',
678
759
  `border--${toTableBorder(border)}`,
679
760
  isPrint ? 'is--print' : '',
761
+ isAutoWidth ? 'is--auto-width' : '',
762
+ isScaleWidth ? 'is--scale-width' : '',
763
+ isDefaultWidth ? 'is--default-width' : '',
680
764
  isHeader ? 'is--header' : ''
681
765
  ].filter(cls => cls);
682
766
  const tables = [
683
767
  `<table class="${clss.join(' ')}" border="0" cellspacing="0" cellpadding="0">`,
684
- `<colgroup>${columns.map((column) => `<col style="width:${column.renderWidth}px">`).join('')}</colgroup>`
768
+ `<colgroup>${columns.map((column) => `<col style="${getHeaderWidthStyle(column)}">`).join('')}</colgroup>`
685
769
  ];
686
770
  if (isHeader) {
687
771
  tables.push('<thead>');
@@ -691,22 +775,13 @@ hooks.add('tableExportModule', {
691
775
  const headAlign = column.headerAlign || column.align || allHeaderAlign || allAlign;
692
776
  const classNames = hasEllipsis(column, 'showHeaderOverflow', allColumnHeaderOverflow) ? ['col--ellipsis'] : [];
693
777
  const cellTitle = getHeaderTitle(opts, column);
694
- let childWidth = 0;
695
- let countChild = 0;
696
- XEUtils.eachTree([column], item => {
697
- if (!item.childNodes || !column.childNodes.length) {
698
- countChild++;
699
- }
700
- childWidth += item.renderWidth;
701
- }, { children: 'childNodes' });
702
- const cellWidth = childWidth - countChild;
703
778
  if (headAlign) {
704
779
  classNames.push(`col--${headAlign}`);
705
780
  }
706
781
  if (column.type === 'checkbox') {
707
- 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>`;
782
+ return `<th class="${classNames.join(' ')}" colspan="${column._colSpan}" rowspan="${column._rowSpan}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" class="${allCls}" ${isAllSelected ? 'checked' : ''}><span>${cellTitle}</span></div></th>`;
708
783
  }
709
- return `<th class="${classNames.join(' ')}" colspan="${column._colSpan}" rowspan="${column._rowSpan}" title="${cellTitle}"><div ${isPrint ? '' : `style="width: ${cellWidth}px"`}><span>${formatText(cellTitle, true)}</span></div></th>`;
784
+ return `<th class="${classNames.join(' ')}" colspan="${column._colSpan}" rowspan="${column._rowSpan}" title="${cellTitle}"><div style="${getCellWidthStyle(column)}"><span>${formatText(cellTitle, true)}</span></div></th>`;
710
785
  }).join('')}</tr>`);
711
786
  });
712
787
  }
@@ -719,9 +794,9 @@ hooks.add('tableExportModule', {
719
794
  classNames.push(`col--${headAlign}`);
720
795
  }
721
796
  if (column.type === 'checkbox') {
722
- return `<th class="${classNames.join(' ')}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><input type="checkbox" class="${allCls}" ${isAllSelected ? 'checked' : ''}><span>${cellTitle}</span></div></th>`;
797
+ return `<th class="${classNames.join(' ')}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" class="${allCls}" ${isAllSelected ? 'checked' : ''}><span>${cellTitle}</span></div></th>`;
723
798
  }
724
- return `<th class="${classNames.join(' ')}" title="${cellTitle}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}><span>${formatText(cellTitle, true)}</span></div></th>`;
799
+ return `<th class="${classNames.join(' ')}" title="${cellTitle}"><div style="${getCellWidthStyle(column)}"><span>${formatText(cellTitle, true)}</span></div></th>`;
725
800
  }).join('')}</tr>`);
726
801
  }
727
802
  tables.push('</thead>');
@@ -745,20 +820,20 @@ hooks.add('tableExportModule', {
745
820
  }
746
821
  classNames.push('vxe-table--tree-node');
747
822
  if (column.type === 'radio') {
748
- 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>`;
823
+ return `<td class="${classNames.join(' ')}" title="${cellValue}"><div style="${getCellWidthStyle(column)}"><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>`;
749
824
  }
750
825
  else if (column.type === 'checkbox') {
751
- 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>`;
826
+ return `<td class="${classNames.join(' ')}" title="${cellValue}"><div style="${getCellWidthStyle(column)}"><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>`;
752
827
  }
753
- 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>`;
828
+ return `<td class="${classNames.join(' ')}" title="${cellValue}"><div style="${getCellWidthStyle(column)}"><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>`;
754
829
  }
755
830
  if (column.type === 'radio') {
756
- 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>`;
831
+ return `<td class="${classNames.join(' ')}"><div style="${getCellWidthStyle(column)}"><input type="radio" name="radio_${id}" ${item._radioDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._radioLabel}</span></div></td>`;
757
832
  }
758
833
  else if (column.type === 'checkbox') {
759
- 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>`;
834
+ return `<td class="${classNames.join(' ')}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" ${item._checkboxDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._checkboxLabel}</span></div></td>`;
760
835
  }
761
- return `<td class="${classNames.join(' ')}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}>${formatText(cellValue, true)}</div></td>`;
836
+ return `<td class="${classNames.join(' ')}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
762
837
  }).join('') + '</tr>');
763
838
  });
764
839
  }
@@ -791,12 +866,12 @@ hooks.add('tableExportModule', {
791
866
  classNames.push(`col--${cellAlign}`);
792
867
  }
793
868
  if (column.type === 'radio') {
794
- 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>`;
869
+ return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}"><div style="${getCellWidthStyle(column)}"><input type="radio" name="radio_${id}" ${item._radioDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._radioLabel}</span></div></td>`;
795
870
  }
796
871
  else if (column.type === 'checkbox') {
797
- 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>`;
872
+ return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" ${item._checkboxDisabled ? 'disabled ' : ''}${getBooleanValue(cellValue) ? 'checked' : ''}><span>${item._checkboxLabel}</span></div></td>`;
798
873
  }
799
- return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}>${formatText(cellValue, true)}</div></td>`;
874
+ return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
800
875
  }).join('') + '</tr>');
801
876
  });
802
877
  }
@@ -834,7 +909,7 @@ hooks.add('tableExportModule', {
834
909
  if (footAlign) {
835
910
  classNames.push(`col--${footAlign}`);
836
911
  }
837
- return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div ${isPrint ? '' : `style="width: ${column.renderWidth}px"`}>${formatText(cellValue, true)}</div></td>`;
912
+ return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
838
913
  }).join('')}</tr>`);
839
914
  });
840
915
  tables.push('</tfoot>');
@@ -1249,6 +1324,9 @@ hooks.add('tableExportModule', {
1249
1324
  if (!typeList.some(item => item.value === type)) {
1250
1325
  exportParams.type = typeList[0].value;
1251
1326
  }
1327
+ if (!exportParams.widthMode) {
1328
+ exportParams.widthMode = '';
1329
+ }
1252
1330
  initStore.export = true;
1253
1331
  return nextTick();
1254
1332
  };
@@ -1335,7 +1413,7 @@ hooks.add('tableExportModule', {
1335
1413
  return isChecked;
1336
1414
  }, { children: 'children', mapChildren: 'childNodes', original: true });
1337
1415
  }
1338
- const handleOptions = Object.assign({}, opts, { filename: '', sheetName: '' });
1416
+ const handleOptions = Object.assign({}, opts, { filename: '', sheetName: '', _columnConfs: columns });
1339
1417
  // 如果设置源数据,则默认导出设置了字段的列
1340
1418
  if (!isCustomCol && !columnFilterMethod) {
1341
1419
  columnFilterMethod = ({ column }) => {
@@ -1,5 +1,5 @@
1
1
  // 默认导出或打印的 HTML 样式
2
- const defaultHtmlStyle = 'body{margin:0;padding: 0 1px;color:#333333;font-size:14px;font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu}body *{-webkit-box-sizing:border-box;box-sizing:border-box}.vxe-table{border-collapse:collapse;text-align:left;border-spacing:0}.vxe-table:not(.is--print){table-layout:fixed}.vxe-table,.vxe-table th,.vxe-table td,.vxe-table td{border-color:#D0D0D0;border-style:solid;border-width:0}.vxe-table.is--print{width:100%}.border--default,.border--full,.border--outer{border-top-width:1px}.border--default,.border--full,.border--outer{border-left-width:1px}.border--outer,.border--default th,.border--default td,.border--full th,.border--full td,.border--outer th,.border--inner th,.border--inner td{border-bottom-width:1px}.border--default,.border--outer,.border--full th,.border--full td{border-right-width:1px}.border--default th,.border--full th,.border--outer th{background-color:#f8f8f9}.vxe-table td>div,.vxe-table th>div{padding:.5em .4em}.col--center{text-align:center}.col--right{text-align:right}.vxe-table:not(.is--print) .col--ellipsis>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-break:break-all}.vxe-table--tree-node{text-align:left}.vxe-table--tree-node-wrapper{position:relative}.vxe-table--tree-icon-wrapper{position:absolute;top:50%;width:1em;height:1em;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}.vxe-table--tree-unfold-icon,.vxe-table--tree-fold-icon{position:absolute;width:0;height:0;border-style:solid;border-width:.5em;border-right-color:transparent;border-bottom-color:transparent}.vxe-table--tree-unfold-icon{left:.3em;top:0;border-left-color:#939599;border-top-color:transparent}.vxe-table--tree-fold-icon{left:0;top:.3em;border-left-color:transparent;border-top-color:#939599}.vxe-table--tree-cell{display:block;padding-left:1.5em}.vxe-table input[type="checkbox"]{margin:0}.vxe-table input[type="checkbox"],.vxe-table input[type="radio"],.vxe-table input[type="checkbox"]+span,.vxe-table input[type="radio"]+span{vertical-align:middle;padding-left:0.4em}';
2
+ const defaultHtmlStyle = 'body{padding:0;color:rgba(0,0,0,0.7);font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,MingLiu;}body *{-webkit-box-sizing:border-box;box-sizing:border-box;}.vxe-table{border-collapse:collapse;text-align:left;border-spacing:0;}.vxe-table.is--default-width,.vxe-table.is--auto-width{width:100%;}.vxe-table.is--scale-width{table-layout:fixed;}.vxe-table,.vxe-table th,.vxe-table td,.vxe-table td{word-break:break-all;border-color:#D0D0D0;border-style:solid;border-width:0;}.border--default,.border--full,.border--outer{border-top-width:1px;}.border--default,.border--full,.border--outer{border-left-width:1px}.border--outer,.border--default th,.border--default td,.border--full th,.border--full td,.border--outer th,.border--inner th,.border--inner td{border-bottom-width:1px;}.border--default,.border--outer,.border--full th,.border--full td{border-right-width:1px;}.border--default th,.border--full th,.border--outer th{background-color:#f8f8f9;}.vxe-table td>div,.vxe-table th>div{padding:0.5em 0.4em;}.col--center{text-align:center;}.col--right{text-align:right;}.vxe-table .col--ellipsis>div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-break:break-all;}.vxe-table--tree-node{text-align:left;}.vxe-table--tree-node-wrapper{position:relative;}.vxe-table--tree-icon-wrapper{position:absolute;top:50%;width:1em;height:1em;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;}.vxe-table--tree-unfold-icon,.vxe-table--tree-fold-icon{position:absolute;width:0;height:0;border-style:solid;border-width:0.5em;border-right-color:transparent;border-bottom-color:transparent;}.vxe-table--tree-unfold-icon{left:.3em;top:0;border-left-color:#939599;border-top-color:transparent;}.vxe-table--tree-fold-icon{left:0;top:.3em;border-left-color:transparent;border-top-color:#939599;}.vxe-table--tree-cell{display:block;padding-left:1.5em;}.vxe-table input[type="checkbox"]{margin:0;}.vxe-table input[type="checkbox"],.vxe-table input[type="radio"],.vxe-table input[type="checkbox"]+span,.vxe-table input[type="radio"]+span{vertical-align:middle;padding-left:0.4em}';
3
3
  export function getExportBlobByContent(content, options) {
4
4
  return new Blob([content], { type: `text/${options.type};charset=utf-8;` });
5
5
  }
@@ -139,7 +139,7 @@ export default defineVxeComponent({
139
139
  const cellOverflow = XEUtils.eqNull(showOverflow) ? allShowOverflow : showOverflow;
140
140
  const showEllipsis = cellOverflow === 'ellipsis';
141
141
  const showTitle = cellOverflow === 'title';
142
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
142
+ const showTooltip = cellOverflow === true ? tooltipOpts.mode === 'tooltip' : cellOverflow === 'tooltip';
143
143
  const hasEllipsis = isAllOverflow || showTitle || showTooltip || showEllipsis;
144
144
  const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable));
145
145
  const isCsHeight = !!customCellHeight;
@@ -66,7 +66,7 @@ export default defineVxeComponent({
66
66
  const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
67
67
  const showEllipsis = footOverflow === 'ellipsis';
68
68
  const showTitle = footOverflow === 'title';
69
- const showTooltip = footOverflow === true || footOverflow === 'tooltip';
69
+ const showTooltip = footOverflow === true ? footerTooltipOpts.mode === 'tooltip' : footOverflow === 'tooltip';
70
70
  const hasEllipsis = showTitle || showTooltip || showEllipsis;
71
71
  const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable));
72
72
  const attrs = { colid };
@@ -23,7 +23,7 @@ export default defineVxeComponent({
23
23
  setup(props) {
24
24
  const $xeTable = inject('$xeTable', {});
25
25
  const { xID, props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable;
26
- const { computeColumnOpts, computeColumnDragOpts, computeCellOpts, computeMouseOpts, computeHeaderCellOpts, computeDefaultRowHeight, computeVirtualXOpts, computeFloatingFilterOpts, computeIsHeaderRenderOptimize } = $xeTable.getComputeMaps();
26
+ const { computeColumnOpts, computeColumnDragOpts, computeCellOpts, computeMouseOpts, computeHeaderCellOpts, computeDefaultRowHeight, computeVirtualXOpts, computeFloatingFilterOpts, computeIsHeaderRenderOptimize, computeHeaderTooltipOpts } = $xeTable.getComputeMaps();
27
27
  const headerColumn = ref([]);
28
28
  const refElem = ref();
29
29
  const refHeaderScroll = ref();
@@ -58,6 +58,7 @@ export default defineVxeComponent({
58
58
  const virtualXOpts = computeVirtualXOpts.value;
59
59
  const columnOpts = computeColumnOpts.value;
60
60
  const columnDragOpts = computeColumnDragOpts.value;
61
+ const headerTooltipOpts = computeHeaderTooltipOpts.value;
61
62
  const cellOpts = computeCellOpts.value;
62
63
  const defaultRowHeight = computeDefaultRowHeight.value;
63
64
  const headerCellOpts = computeHeaderCellOpts.value;
@@ -77,7 +78,7 @@ export default defineVxeComponent({
77
78
  const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
78
79
  const showEllipsis = headOverflow === 'ellipsis';
79
80
  const showTitle = headOverflow === 'title';
80
- const showTooltip = headOverflow === true || headOverflow === 'tooltip';
81
+ const showTooltip = headOverflow === true ? headerTooltipOpts.mode === 'tooltip' : headOverflow === 'tooltip';
81
82
  const hasEllipsis = showTitle || showTooltip || showEllipsis;
82
83
  let hasFilter = false;
83
84
  let firstFilterOption = null;
@@ -237,6 +238,7 @@ export default defineVxeComponent({
237
238
  const { showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign } = tableProps;
238
239
  const { currentColumn, overflowX } = tableReactData;
239
240
  const { fullColumnIdData } = tableInternalData;
241
+ const headerTooltipOpts = computeHeaderTooltipOpts.value;
240
242
  const cellOpts = computeCellOpts.value;
241
243
  const defaultRowHeight = computeDefaultRowHeight.value;
242
244
  const headerCellOpts = computeHeaderCellOpts.value;
@@ -258,7 +260,7 @@ export default defineVxeComponent({
258
260
  const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
259
261
  const showEllipsis = headOverflow === 'ellipsis';
260
262
  const showTitle = headOverflow === 'title';
261
- const showTooltip = headOverflow === true || headOverflow === 'tooltip';
263
+ const showTooltip = headOverflow === true ? headerTooltipOpts.mode === 'tooltip' : headOverflow === 'tooltip';
262
264
  const hasEllipsis = showTitle || showTooltip || showEllipsis;
263
265
  let hasFilter = false;
264
266
  let firstFilterOption = null;