vxe-table 4.23.5 → 4.23.7
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/dist/all.esm.js +32456 -33938
- package/dist/style.css +4501 -1
- package/dist/style.mini.css +1 -0
- package/es/colgroup/index.d.ts +760 -0
- package/es/colgroup/index.js +16 -13
- package/es/column/index.d.ts +760 -0
- package/es/column/index.js +16 -13
- package/es/components.d.ts +9 -0
- package/es/components.js +29 -29
- package/es/grid/index.d.ts +2824 -0
- package/es/grid/index.js +14 -9
- package/es/grid/src/emits.d.ts +2 -0
- package/es/grid/src/emits.js +18 -15
- package/es/grid/src/grid.d.ts +556 -0
- package/es/grid/src/grid.js +1695 -1758
- package/es/grid/src/props.d.ts +200 -0
- package/es/grid/src/props.js +19 -6
- package/es/{vxe-grid/style.min.css → grid/style.mini.css} +1 -1
- package/es/index.d.ts +3 -0
- package/es/index.esm.js +6 -3
- package/es/index.js +6 -0
- package/es/locale/lang/ar-EG.d.ts +908 -2
- package/es/locale/lang/ar-EG.js +906 -903
- package/es/locale/lang/de-DE.d.ts +908 -2
- package/es/locale/lang/de-DE.js +906 -903
- package/es/locale/lang/en-US.d.ts +908 -2
- package/es/locale/lang/en-US.js +906 -903
- package/es/locale/lang/es-ES.d.ts +908 -2
- package/es/locale/lang/es-ES.js +906 -903
- package/es/locale/lang/fr-FR.d.ts +908 -2
- package/es/locale/lang/fr-FR.js +906 -903
- package/es/locale/lang/hu-HU.d.ts +908 -2
- package/es/locale/lang/hu-HU.js +906 -903
- package/es/locale/lang/hy-AM.d.ts +908 -2
- package/es/locale/lang/hy-AM.js +906 -903
- package/es/locale/lang/id-ID.d.ts +908 -2
- package/es/locale/lang/id-ID.js +906 -903
- package/es/locale/lang/it-IT.d.ts +908 -2
- package/es/locale/lang/it-IT.js +906 -903
- package/es/locale/lang/ja-JP.d.ts +908 -2
- package/es/locale/lang/ja-JP.js +906 -903
- package/es/locale/lang/ko-KR.d.ts +908 -2
- package/es/locale/lang/ko-KR.js +906 -903
- package/es/locale/lang/ms-MY.d.ts +908 -2
- package/es/locale/lang/ms-MY.js +906 -903
- package/es/locale/lang/nb-NO.d.ts +908 -2
- package/es/locale/lang/nb-NO.js +906 -903
- package/es/locale/lang/pt-BR.d.ts +908 -2
- package/es/locale/lang/pt-BR.js +906 -903
- package/es/locale/lang/ru-RU.d.ts +908 -2
- package/es/locale/lang/ru-RU.js +906 -903
- package/es/locale/lang/th-TH.d.ts +908 -2
- package/es/locale/lang/th-TH.js +906 -903
- package/es/locale/lang/ug-CN.d.ts +908 -2
- package/es/locale/lang/ug-CN.js +906 -903
- package/es/locale/lang/uk-UA.d.ts +908 -2
- package/es/locale/lang/uk-UA.js +906 -903
- package/es/locale/lang/uz-UZ.d.ts +908 -2
- package/es/locale/lang/uz-UZ.js +906 -903
- package/es/locale/lang/vi-VN.d.ts +908 -2
- package/es/locale/lang/vi-VN.js +906 -903
- package/es/locale/lang/zh-CHT.d.ts +908 -2
- package/es/locale/lang/zh-CHT.js +906 -903
- package/es/locale/lang/zh-CN.d.ts +908 -2
- package/es/locale/lang/zh-CN.js +906 -903
- package/es/locale/lang/zh-HK.d.ts +908 -2
- package/es/locale/lang/zh-HK.js +910 -2
- package/es/locale/lang/zh-MO.d.ts +908 -2
- package/es/locale/lang/zh-MO.js +910 -2
- package/es/locale/lang/zh-TC.d.ts +908 -0
- package/es/locale/lang/zh-TC.js +910 -2
- package/es/locale/lang/zh-TW.d.ts +908 -2
- package/es/locale/lang/zh-TW.js +910 -2
- package/es/style.css +4501 -1
- package/es/style.mini.css +1 -0
- package/es/table/index.d.ts +2672 -0
- package/es/table/index.js +16 -11
- package/es/table/module/custom/hook.d.ts +1 -0
- package/es/table/module/custom/hook.js +462 -483
- package/es/table/module/custom/panel.d.ts +17 -0
- package/es/table/module/custom/panel.js +1482 -1559
- package/es/table/module/edit/hook.d.ts +1 -0
- package/es/table/module/edit/hook.js +1008 -1078
- package/es/table/module/export/export-panel.d.ts +27 -0
- package/es/table/module/export/export-panel.js +523 -575
- package/es/table/module/export/hook.d.ts +1 -0
- package/es/table/module/export/hook.js +1805 -1884
- package/es/table/module/export/import-panel.d.ts +27 -0
- package/es/table/module/export/import-panel.js +244 -252
- package/es/table/module/export/util.d.ts +5 -0
- package/es/table/module/export/util.js +20 -17
- package/es/table/module/filter/hook.d.ts +1 -0
- package/es/table/module/filter/hook.js +472 -487
- package/es/table/module/filter/panel.d.ts +16 -0
- package/es/table/module/filter/panel.js +251 -275
- package/es/table/module/keyboard/hook.d.ts +1 -0
- package/es/table/module/keyboard/hook.js +445 -497
- package/es/table/module/menu/hook.d.ts +1 -0
- package/es/table/module/menu/hook.js +295 -315
- package/es/table/module/menu/panel.d.ts +2 -0
- package/es/table/module/menu/panel.js +164 -183
- package/es/table/module/validator/hook.d.ts +1 -0
- package/es/table/module/validator/hook.js +522 -571
- package/es/table/render/index.d.ts +1 -0
- package/es/table/render/index.js +1402 -1362
- package/es/table/src/body.d.ts +24 -0
- package/es/table/src/body.js +850 -865
- package/es/table/src/cell.d.ts +192 -0
- package/es/table/src/cell.js +1209 -1207
- package/es/table/src/column.d.ts +263 -0
- package/es/table/src/column.js +178 -174
- package/es/table/src/columnInfo.d.ts +13 -0
- package/es/table/src/columnInfo.js +202 -196
- package/es/table/src/emits.d.ts +2 -0
- package/es/table/src/emits.js +126 -119
- package/es/table/src/footer.d.ts +45 -0
- package/es/table/src/footer.js +336 -340
- package/es/table/src/group.d.ts +178 -0
- package/es/table/src/group.js +49 -46
- package/es/table/src/header.d.ts +26 -0
- package/es/table/src/header.js +517 -519
- package/es/table/src/props.d.ts +238 -0
- package/es/table/src/props.js +331 -328
- package/es/table/src/store.d.ts +6 -0
- package/es/table/src/store.js +9 -6
- package/es/table/src/table.d.ts +539 -0
- package/es/table/src/table.js +14061 -15071
- package/es/table/src/use/cell-view.d.ts +10 -0
- package/es/table/src/use/cell-view.js +36 -33
- package/es/table/src/use/index.d.ts +1 -0
- package/es/table/src/use/index.js +1 -1
- package/es/table/src/util.d.ts +74 -0
- package/es/table/src/util.js +1038 -1026
- package/es/table/style.css +1 -1
- package/es/table/style.mini.css +1 -0
- package/es/toolbar/index.d.ts +340 -0
- package/es/toolbar/index.js +14 -9
- package/es/toolbar/src/toolbar.d.ts +75 -0
- package/es/toolbar/src/toolbar.js +605 -613
- package/es/toolbar/{style.min.css → style.mini.css} +1 -1
- package/es/ui/index.d.ts +86 -0
- package/es/ui/index.js +457 -501
- package/es/ui/src/anime.d.ts +10 -0
- package/es/ui/src/anime.js +40 -40
- package/es/ui/src/comp.d.ts +2 -0
- package/es/ui/src/comp.js +5 -2
- package/es/ui/src/dom.d.ts +80 -0
- package/es/ui/src/dom.js +377 -380
- package/es/ui/src/log.d.ts +6 -0
- package/es/ui/src/log.js +18 -13
- package/es/ui/src/utils.d.ts +23 -0
- package/es/ui/src/utils.js +57 -53
- package/es/ui/src/vn.d.ts +7 -0
- package/es/ui/src/vn.js +49 -42
- package/es/v-x-e-table/index.d.ts +3 -0
- package/es/v-x-e-table/index.js +6 -3
- package/es/vxe-colgroup/index.d.ts +3 -0
- package/es/vxe-colgroup/index.js +6 -3
- package/es/vxe-column/index.d.ts +3 -0
- package/es/vxe-column/index.js +6 -3
- package/es/vxe-grid/index.d.ts +3 -0
- package/es/vxe-grid/index.js +6 -3
- package/{lib/grid/style/style.min.css → es/vxe-grid/style.mini.css} +1 -1
- package/es/vxe-table/index.d.ts +3 -0
- package/es/vxe-table/index.js +6 -3
- package/es/vxe-table/style.css +1 -1
- package/es/vxe-table/style.mini.css +1 -0
- package/es/vxe-toolbar/index.d.ts +3 -0
- package/es/vxe-toolbar/index.js +6 -3
- package/es/vxe-toolbar/{style.min.css → style.mini.css} +1 -1
- package/es/vxe-ui/index.d.ts +3 -0
- package/es/vxe-ui/index.js +6 -3
- package/lib/colgroup/index.js +44 -18
- package/lib/colgroup/style/index.js +1 -1
- package/lib/column/index.js +44 -18
- package/lib/column/style/index.js +1 -1
- package/lib/components.js +58 -92
- package/lib/grid/index.js +42 -14
- package/lib/grid/src/emits.js +37 -6
- package/lib/grid/src/grid.js +850 -1195
- package/lib/grid/src/props.js +27 -11
- package/lib/grid/style/index.js +1 -1
- package/lib/{vxe-grid/style/style.min.css → grid/style/style.mini.css} +1 -1
- package/lib/iconfont.1792979665397.ttf +0 -0
- package/lib/iconfont.1792979665397.woff +0 -0
- package/lib/iconfont.1792979665397.woff2 +0 -0
- package/lib/index.common.js +35 -19
- package/lib/index.js +37 -0
- package/lib/index.umd.js +30584 -24324
- package/lib/index.umd.min.js +3 -1
- package/lib/locale/ar-EG.umd.js +948 -0
- package/lib/locale/de-DE.umd.js +948 -0
- package/lib/locale/en-US.umd.js +948 -0
- package/lib/locale/es-ES.umd.js +948 -0
- package/lib/locale/fr-FR.umd.js +948 -0
- package/lib/locale/hu-HU.umd.js +948 -0
- package/lib/locale/hy-AM.umd.js +948 -0
- package/lib/locale/id-ID.umd.js +948 -0
- package/lib/locale/it-IT.umd.js +948 -0
- package/lib/locale/ja-JP.umd.js +948 -0
- package/lib/locale/ko-KR.umd.js +948 -0
- package/lib/locale/lang/ar-EG.js +681 -664
- package/lib/locale/lang/ar-EG.umd.js +913 -892
- package/lib/locale/lang/de-DE.js +681 -664
- package/lib/locale/lang/de-DE.umd.js +913 -892
- package/lib/locale/lang/en-US.js +678 -661
- package/lib/locale/lang/en-US.umd.js +913 -892
- package/lib/locale/lang/es-ES.js +681 -664
- package/lib/locale/lang/es-ES.umd.js +913 -892
- package/lib/locale/lang/fr-FR.js +654 -637
- package/lib/locale/lang/fr-FR.umd.js +913 -892
- package/lib/locale/lang/hu-HU.js +681 -664
- package/lib/locale/lang/hu-HU.umd.js +913 -892
- package/lib/locale/lang/hy-AM.js +681 -664
- package/lib/locale/lang/hy-AM.umd.js +913 -892
- package/lib/locale/lang/id-ID.js +681 -664
- package/lib/locale/lang/id-ID.umd.js +913 -892
- package/lib/locale/lang/it-IT.js +661 -644
- package/lib/locale/lang/it-IT.umd.js +912 -891
- package/lib/locale/lang/ja-JP.js +710 -693
- package/lib/locale/lang/ja-JP.umd.js +913 -892
- package/lib/locale/lang/ko-KR.js +681 -664
- package/lib/locale/lang/ko-KR.umd.js +913 -892
- package/lib/locale/lang/ms-MY.js +681 -664
- package/lib/locale/lang/ms-MY.umd.js +913 -892
- package/lib/locale/lang/nb-NO.js +681 -664
- package/lib/locale/lang/nb-NO.umd.js +913 -892
- package/lib/locale/lang/pt-BR.js +681 -664
- package/lib/locale/lang/pt-BR.umd.js +913 -892
- package/lib/locale/lang/ru-RU.js +690 -673
- package/lib/locale/lang/ru-RU.umd.js +913 -892
- package/lib/locale/lang/th-TH.js +681 -664
- package/lib/locale/lang/th-TH.umd.js +913 -892
- package/lib/locale/lang/ug-CN.js +681 -664
- package/lib/locale/lang/ug-CN.umd.js +913 -892
- package/lib/locale/lang/uk-UA.js +674 -657
- package/lib/locale/lang/uk-UA.umd.js +913 -892
- package/lib/locale/lang/uz-UZ.js +583 -566
- package/lib/locale/lang/uz-UZ.umd.js +908 -887
- package/lib/locale/lang/vi-VN.js +681 -664
- package/lib/locale/lang/vi-VN.umd.js +913 -892
- package/lib/locale/lang/zh-CHT.js +681 -664
- package/lib/locale/lang/zh-CHT.umd.js +913 -892
- package/lib/locale/lang/zh-CN.js +681 -664
- package/lib/locale/lang/zh-CN.umd.js +913 -892
- package/lib/locale/lang/zh-HK.js +928 -7
- package/lib/locale/lang/zh-HK.umd.js +945 -20
- package/lib/locale/lang/zh-MO.js +928 -7
- package/lib/locale/lang/zh-MO.umd.js +945 -20
- package/lib/locale/lang/zh-TC.js +928 -7
- package/lib/locale/lang/zh-TC.umd.js +948 -0
- package/lib/locale/lang/zh-TW.js +928 -7
- package/lib/locale/lang/zh-TW.umd.js +945 -20
- package/lib/locale/ms-MY.umd.js +948 -0
- package/lib/locale/nb-NO.umd.js +948 -0
- package/lib/locale/pt-BR.umd.js +948 -0
- package/lib/locale/ru-RU.umd.js +948 -0
- package/lib/locale/th-TH.umd.js +948 -0
- package/lib/locale/ug-CN.umd.js +948 -0
- package/lib/locale/uk-UA.umd.js +948 -0
- package/lib/locale/uz-UZ.umd.js +948 -0
- package/lib/locale/vi-VN.umd.js +948 -0
- package/lib/locale/zh-CHT.umd.js +948 -0
- package/lib/locale/zh-CN.umd.js +948 -0
- package/lib/locale/zh-HK.umd.js +948 -0
- package/lib/locale/zh-MO.umd.js +948 -0
- package/lib/locale/zh-TC.umd.js +948 -0
- package/lib/locale/zh-TW.umd.js +948 -0
- package/lib/style.css +4501 -1
- package/lib/style.mini.css +1 -0
- package/lib/table/index.js +45 -17
- package/lib/table/module/custom/hook.js +132 -252
- package/lib/table/module/custom/panel.js +919 -970
- package/lib/table/module/edit/hook.js +248 -618
- package/lib/table/module/export/export-panel.js +390 -347
- package/lib/table/module/export/hook.js +745 -1179
- package/lib/table/module/export/import-panel.js +170 -136
- package/lib/table/module/export/util.js +37 -14
- package/lib/table/module/filter/hook.js +127 -227
- package/lib/table/module/filter/panel.js +177 -208
- package/lib/table/module/keyboard/hook.js +93 -172
- package/lib/table/module/menu/hook.js +86 -165
- package/lib/table/module/menu/panel.js +176 -141
- package/lib/table/module/validator/hook.js +164 -271
- package/lib/table/render/index.js +700 -1147
- package/lib/table/src/body.js +426 -559
- package/lib/table/src/cell.js +619 -987
- package/lib/table/src/column.js +55 -30
- package/lib/table/src/columnInfo.js +88 -110
- package/lib/table/src/emits.js +145 -13
- package/lib/table/src/footer.js +181 -240
- package/lib/table/src/group.js +56 -34
- package/lib/table/src/header.js +292 -367
- package/lib/table/src/props.js +27 -12
- package/lib/table/src/store.js +25 -9
- package/lib/table/src/table.js +14179 -1023
- package/lib/table/src/use/cell-view.js +47 -37
- package/lib/table/src/use/index.js +17 -15
- package/lib/table/src/util.js +236 -337
- package/lib/table/style/index.js +1 -1
- package/lib/table/style/style.css +1 -1
- package/lib/table/style/style.mini.css +1 -0
- package/lib/toolbar/index.js +42 -14
- package/lib/toolbar/src/toolbar.js +271 -379
- package/lib/toolbar/style/index.js +1 -1
- package/lib/toolbar/style/{style.min.css → style.mini.css} +1 -1
- package/lib/ui/index.js +153 -195
- package/lib/ui/src/anime.js +49 -29
- package/lib/ui/src/comp.js +23 -6
- package/lib/ui/src/dom.js +114 -147
- package/lib/ui/src/log.js +34 -18
- package/lib/ui/src/utils.js +57 -45
- package/lib/ui/src/vn.js +60 -34
- package/lib/ui/style/index.js +1 -1
- package/lib/v-x-e-table/index.js +35 -19
- package/lib/vxe-colgroup/index.js +35 -19
- package/lib/vxe-colgroup/style/index.js +1 -1
- package/lib/vxe-column/index.js +35 -19
- package/lib/vxe-column/style/index.js +1 -1
- package/lib/vxe-grid/index.js +35 -19
- package/lib/vxe-grid/style/index.js +1 -1
- package/{es/grid/style.min.css → lib/vxe-grid/style/style.mini.css} +1 -1
- package/lib/vxe-table/index.js +35 -19
- package/lib/vxe-table/style/index.js +1 -1
- package/lib/vxe-table/style/style.css +1 -1
- package/lib/vxe-table/style/style.mini.css +1 -0
- package/lib/vxe-toolbar/index.js +35 -19
- package/lib/vxe-toolbar/style/index.js +1 -1
- package/lib/vxe-toolbar/style/{style.min.css → style.mini.css} +1 -1
- package/lib/vxe-ui/index.js +35 -19
- package/lib/vxe-ui/style/index.js +1 -1
- package/package.json +8 -4
- package/packages/locale/lang/zh-HK.ts +907 -3
- package/packages/locale/lang/zh-MO.ts +907 -3
- package/packages/locale/lang/zh-TC.ts +907 -3
- package/packages/locale/lang/zh-TW.ts +907 -3
- package/packages/ui/index.ts +1 -28
- package/dist/style.min.css +0 -1
- package/es/index.css +0 -1
- package/es/index.min.css +0 -1
- package/es/style.min.css +0 -1
- package/es/table/style.min.css +0 -1
- package/es/vxe-table/style.min.css +0 -1
- package/es/vxe-v-x-e-table/index.js +0 -3
- package/lib/colgroup/index.min.js +0 -1
- package/lib/column/index.min.js +0 -1
- package/lib/components.min.js +0 -1
- package/lib/grid/index.min.js +0 -1
- package/lib/grid/src/emits.min.js +0 -1
- package/lib/grid/src/grid.min.js +0 -1
- package/lib/grid/src/props.min.js +0 -1
- package/lib/index.css +0 -1
- package/lib/index.min.css +0 -1
- package/lib/locale/lang/ar-EG.d.ts +0 -2
- package/lib/locale/lang/ar-EG.min.js +0 -1
- package/lib/locale/lang/de-DE.d.ts +0 -2
- package/lib/locale/lang/de-DE.min.js +0 -1
- package/lib/locale/lang/en-US.d.ts +0 -2
- package/lib/locale/lang/en-US.min.js +0 -1
- package/lib/locale/lang/es-ES.d.ts +0 -2
- package/lib/locale/lang/es-ES.min.js +0 -1
- package/lib/locale/lang/fr-FR.d.ts +0 -2
- package/lib/locale/lang/fr-FR.min.js +0 -1
- package/lib/locale/lang/hu-HU.d.ts +0 -2
- package/lib/locale/lang/hu-HU.min.js +0 -1
- package/lib/locale/lang/hy-AM.d.ts +0 -2
- package/lib/locale/lang/hy-AM.min.js +0 -1
- package/lib/locale/lang/id-ID.d.ts +0 -2
- package/lib/locale/lang/id-ID.min.js +0 -1
- package/lib/locale/lang/it-IT.d.ts +0 -2
- package/lib/locale/lang/it-IT.min.js +0 -1
- package/lib/locale/lang/ja-JP.d.ts +0 -2
- package/lib/locale/lang/ja-JP.min.js +0 -1
- package/lib/locale/lang/ko-KR.d.ts +0 -2
- package/lib/locale/lang/ko-KR.min.js +0 -1
- package/lib/locale/lang/ms-MY.d.ts +0 -2
- package/lib/locale/lang/ms-MY.min.js +0 -1
- package/lib/locale/lang/nb-NO.d.ts +0 -2
- package/lib/locale/lang/nb-NO.min.js +0 -1
- package/lib/locale/lang/pt-BR.d.ts +0 -2
- package/lib/locale/lang/pt-BR.min.js +0 -1
- package/lib/locale/lang/ru-RU.d.ts +0 -2
- package/lib/locale/lang/ru-RU.min.js +0 -1
- package/lib/locale/lang/th-TH.d.ts +0 -2
- package/lib/locale/lang/th-TH.min.js +0 -1
- package/lib/locale/lang/ug-CN.d.ts +0 -2
- package/lib/locale/lang/ug-CN.min.js +0 -1
- package/lib/locale/lang/uk-UA.d.ts +0 -2
- package/lib/locale/lang/uk-UA.min.js +0 -1
- package/lib/locale/lang/uz-UZ.d.ts +0 -2
- package/lib/locale/lang/uz-UZ.min.js +0 -1
- package/lib/locale/lang/vi-VN.d.ts +0 -2
- package/lib/locale/lang/vi-VN.min.js +0 -1
- package/lib/locale/lang/zh-CHT.d.ts +0 -2
- package/lib/locale/lang/zh-CHT.min.js +0 -1
- package/lib/locale/lang/zh-CN.d.ts +0 -2
- package/lib/locale/lang/zh-CN.min.js +0 -1
- package/lib/locale/lang/zh-HK.d.ts +0 -2
- package/lib/locale/lang/zh-HK.min.js +0 -1
- package/lib/locale/lang/zh-MO.d.ts +0 -2
- package/lib/locale/lang/zh-MO.min.js +0 -1
- package/lib/locale/lang/zh-TC.min.js +0 -1
- package/lib/locale/lang/zh-TW.d.ts +0 -2
- package/lib/locale/lang/zh-TW.min.js +0 -1
- package/lib/style.min.css +0 -1
- package/lib/table/index.min.js +0 -1
- package/lib/table/module/custom/hook.min.js +0 -1
- package/lib/table/module/custom/panel.min.js +0 -1
- package/lib/table/module/edit/hook.min.js +0 -1
- package/lib/table/module/export/export-panel.min.js +0 -1
- package/lib/table/module/export/hook.min.js +0 -1
- package/lib/table/module/export/import-panel.min.js +0 -1
- package/lib/table/module/export/util.min.js +0 -1
- package/lib/table/module/filter/hook.min.js +0 -1
- package/lib/table/module/filter/panel.min.js +0 -1
- package/lib/table/module/keyboard/hook.min.js +0 -1
- package/lib/table/module/menu/hook.min.js +0 -1
- package/lib/table/module/menu/panel.min.js +0 -1
- package/lib/table/module/validator/hook.min.js +0 -1
- package/lib/table/render/index.min.js +0 -1
- package/lib/table/src/body.min.js +0 -1
- package/lib/table/src/cell.min.js +0 -1
- package/lib/table/src/column.min.js +0 -1
- package/lib/table/src/columnInfo.min.js +0 -1
- package/lib/table/src/emits.min.js +0 -1
- package/lib/table/src/footer.min.js +0 -1
- package/lib/table/src/group.min.js +0 -1
- package/lib/table/src/header.min.js +0 -1
- package/lib/table/src/props.min.js +0 -1
- package/lib/table/src/store.min.js +0 -1
- package/lib/table/src/table.min.js +0 -1
- package/lib/table/src/use/cell-view.min.js +0 -1
- package/lib/table/src/use/index.min.js +0 -1
- package/lib/table/src/util.min.js +0 -1
- package/lib/table/style/style.min.css +0 -1
- package/lib/toolbar/index.min.js +0 -1
- package/lib/toolbar/src/toolbar.min.js +0 -1
- package/lib/ui/index.min.js +0 -1
- package/lib/ui/src/anime.min.js +0 -1
- package/lib/ui/src/comp.min.js +0 -1
- package/lib/ui/src/dom.min.js +0 -1
- package/lib/ui/src/log.min.js +0 -1
- package/lib/ui/src/utils.min.js +0 -1
- package/lib/ui/src/vn.min.js +0 -1
- package/lib/ui/style/style.min.css +0 -0
- package/lib/v-x-e-table/index.min.js +0 -1
- package/lib/v-x-e-table/style/index.js +0 -1
- package/lib/v-x-e-table/style/style.css +0 -0
- package/lib/v-x-e-table/style/style.min.css +0 -0
- package/lib/vxe-colgroup/index.min.js +0 -1
- package/lib/vxe-colgroup/style/style.min.css +0 -0
- package/lib/vxe-column/index.min.js +0 -1
- package/lib/vxe-column/style/style.min.css +0 -0
- package/lib/vxe-grid/index.min.js +0 -1
- package/lib/vxe-table/index.min.js +0 -1
- package/lib/vxe-table/style/style.min.css +0 -1
- package/lib/vxe-toolbar/index.min.js +0 -1
- package/lib/vxe-ui/index.min.js +0 -1
- package/lib/vxe-ui/style/style.min.css +0 -0
- package/lib/vxe-v-x-e-table/index.js +0 -21
- package/lib/vxe-v-x-e-table/index.min.js +0 -1
- package/lib/vxe-v-x-e-table/style/index.js +0 -1
- package/lib/vxe-v-x-e-table/style/style.css +0 -0
- package/lib/vxe-v-x-e-table/style/style.min.css +0 -0
- /package/{es/iconfont.1792838769925.ttf → dist/iconfont.1792979665397.ttf} +0 -0
- /package/{es/iconfont.1792838769925.woff → dist/iconfont.1792979665397.woff} +0 -0
- /package/{es/iconfont.1792838769925.woff2 → dist/iconfont.1792979665397.woff2} +0 -0
- /package/es/colgroup/{style.min.css → style.mini.css} +0 -0
- /package/es/column/{style.min.css → style.mini.css} +0 -0
- /package/{lib/iconfont.1792838769925.ttf → es/iconfont.1792979665397.ttf} +0 -0
- /package/{lib/iconfont.1792838769925.woff → es/iconfont.1792979665397.woff} +0 -0
- /package/{lib/iconfont.1792838769925.woff2 → es/iconfont.1792979665397.woff2} +0 -0
- /package/es/ui/{style.min.css → style.mini.css} +0 -0
- /package/es/{v-x-e-table/style.css → vxe-colgroup/style.mini.css} +0 -0
- /package/es/{v-x-e-table/style.min.css → vxe-column/style.mini.css} +0 -0
- /package/es/{vxe-colgroup/style.min.css → vxe-ui/style.mini.css} +0 -0
- /package/{es/vxe-column/style.min.css → lib/colgroup/style/style.mini.css} +0 -0
- /package/{es/vxe-ui/style.min.css → lib/column/style/style.mini.css} +0 -0
- /package/{es/vxe-v-x-e-table/style.css → lib/ui/style/style.mini.css} +0 -0
- /package/{es/vxe-v-x-e-table/style.min.css → lib/vxe-colgroup/style/style.mini.css} +0 -0
- /package/lib/{colgroup/style/style.min.css → vxe-column/style/style.mini.css} +0 -0
- /package/lib/{column/style/style.min.css → vxe-ui/style/style.mini.css} +0 -0
|
@@ -1,1994 +1,1915 @@
|
|
|
1
|
-
import { nextTick } from
|
|
2
|
-
import XEUtils from
|
|
3
|
-
import { VxeUI } from
|
|
4
|
-
import { isColumnInfo, getCellValue, createHandleGetRowId } from
|
|
5
|
-
import { parseFile, formatText, eqEmptyValue, hasEnableConf } from
|
|
6
|
-
import { hasClass, toCssUnit } from
|
|
7
|
-
import { createHtmlPage, getExportBlobByContent } from
|
|
8
|
-
import { createComponentLog } from
|
|
9
|
-
const { warnLog, errLog } = createComponentLog(
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
import XEUtils from "xe-utils";
|
|
3
|
+
import { VxeUI } from "../../../ui";
|
|
4
|
+
import { isColumnInfo, getCellValue, createHandleGetRowId } from "../../src/util";
|
|
5
|
+
import { parseFile, formatText, eqEmptyValue, hasEnableConf } from "../../../ui/src/utils";
|
|
6
|
+
import { hasClass, toCssUnit } from "../../../ui/src/dom";
|
|
7
|
+
import { createHtmlPage, getExportBlobByContent } from "./util";
|
|
8
|
+
import { createComponentLog } from "../../../ui/src/log";
|
|
9
|
+
const { warnLog, errLog } = createComponentLog("table");
|
|
10
10
|
const { getI18n, hooks, renderer } = VxeUI;
|
|
11
11
|
let htmlCellElem;
|
|
12
|
-
const csvBOM =
|
|
13
|
-
const enterSymbol =
|
|
12
|
+
const csvBOM = "\uFEFF";
|
|
13
|
+
const enterSymbol = "\r\n";
|
|
14
14
|
function defaultFilterExportColumn(column) {
|
|
15
|
-
|
|
15
|
+
return !!column.field || ["seq", "checkbox", "radio"].indexOf(column.type || "") === -1;
|
|
16
16
|
}
|
|
17
17
|
const getConvertColumns = (columns) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return result;
|
|
18
|
+
const result = [];
|
|
19
|
+
columns.forEach((column) => {
|
|
20
|
+
if (column.childNodes && column.childNodes.length) {
|
|
21
|
+
result.push(column);
|
|
22
|
+
result.push(...getConvertColumns(column.childNodes));
|
|
23
|
+
} else {
|
|
24
|
+
result.push(column);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
29
28
|
};
|
|
30
29
|
const convertToRows = (originColumns) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (column.childNodes && column.childNodes.length) {
|
|
40
|
-
let colSpan = 0;
|
|
41
|
-
column.childNodes.forEach((subColumn) => {
|
|
42
|
-
traverse(subColumn, column);
|
|
43
|
-
colSpan += subColumn._colSpan;
|
|
44
|
-
});
|
|
45
|
-
column._colSpan = colSpan;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
column._colSpan = 1;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
originColumns.forEach((column) => {
|
|
52
|
-
column._level = 1;
|
|
53
|
-
traverse(column);
|
|
54
|
-
});
|
|
55
|
-
const rows = [];
|
|
56
|
-
for (let i = 0; i < maxLevel; i++) {
|
|
57
|
-
rows.push([]);
|
|
30
|
+
let maxLevel = 1;
|
|
31
|
+
const traverse = (column, parent) => {
|
|
32
|
+
if (parent) {
|
|
33
|
+
column._level = parent._level + 1;
|
|
34
|
+
if (maxLevel < column._level) {
|
|
35
|
+
maxLevel = column._level;
|
|
36
|
+
}
|
|
58
37
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
return rows;
|
|
70
|
-
};
|
|
71
|
-
function toTableBorder(border) {
|
|
72
|
-
if (border === true) {
|
|
73
|
-
return 'full';
|
|
38
|
+
if (column.childNodes && column.childNodes.length) {
|
|
39
|
+
let colSpan = 0;
|
|
40
|
+
column.childNodes.forEach((subColumn) => {
|
|
41
|
+
traverse(subColumn, column);
|
|
42
|
+
colSpan += subColumn._colSpan;
|
|
43
|
+
});
|
|
44
|
+
column._colSpan = colSpan;
|
|
45
|
+
} else {
|
|
46
|
+
column._colSpan = 1;
|
|
74
47
|
}
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
};
|
|
49
|
+
originColumns.forEach((column) => {
|
|
50
|
+
column._level = 1;
|
|
51
|
+
traverse(column);
|
|
52
|
+
});
|
|
53
|
+
const rows = [];
|
|
54
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
55
|
+
rows.push([]);
|
|
56
|
+
}
|
|
57
|
+
const allColumns = getConvertColumns(originColumns);
|
|
58
|
+
allColumns.forEach((column) => {
|
|
59
|
+
if (column.childNodes && column.childNodes.length) {
|
|
60
|
+
column._rowSpan = 1;
|
|
61
|
+
} else {
|
|
62
|
+
column._rowSpan = maxLevel - column._level + 1;
|
|
77
63
|
}
|
|
78
|
-
|
|
64
|
+
rows[column._level - 1].push(column);
|
|
65
|
+
});
|
|
66
|
+
return rows;
|
|
67
|
+
};
|
|
68
|
+
function toTableBorder(border) {
|
|
69
|
+
if (border === true) {
|
|
70
|
+
return "full";
|
|
71
|
+
}
|
|
72
|
+
if (border) {
|
|
73
|
+
return border;
|
|
74
|
+
}
|
|
75
|
+
return "default";
|
|
79
76
|
}
|
|
80
77
|
function getBooleanValue(cellValue) {
|
|
81
|
-
|
|
78
|
+
return cellValue === "TRUE" || cellValue === "true" || cellValue === true;
|
|
82
79
|
}
|
|
83
80
|
function getFooterData($xeTable, opts, footerTableData) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
82
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
83
|
+
const { footerFilterMethod } = opts;
|
|
84
|
+
return footerFilterMethod ? footerTableData.filter((items, index) => footerFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, items, $rowIndex: index })) : footerTableData;
|
|
88
85
|
}
|
|
89
86
|
function getCsvCellTypeLabel(column, cellValue) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
if (cellValue) {
|
|
88
|
+
if (column.type === "seq") {
|
|
89
|
+
return ` ${cellValue}`;
|
|
90
|
+
}
|
|
91
|
+
switch (column.cellType) {
|
|
92
|
+
case "string":
|
|
93
|
+
if (!isNaN(cellValue)) {
|
|
94
|
+
return ` ${cellValue}`;
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
case 'number':
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
if (cellValue.length >= 12 && !isNaN(cellValue)) {
|
|
104
|
-
return `\t${cellValue}`;
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
96
|
+
break;
|
|
97
|
+
case "number":
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
if (cellValue.length >= 12 && !isNaN(cellValue)) {
|
|
101
|
+
return ` ${cellValue}`;
|
|
107
102
|
}
|
|
103
|
+
break;
|
|
108
104
|
}
|
|
109
|
-
|
|
105
|
+
}
|
|
106
|
+
return cellValue;
|
|
110
107
|
}
|
|
111
108
|
function toTxtCellLabel(val) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
if (/[",\s\n]/.test(val)) {
|
|
110
|
+
return `"${val.replace(/"/g, '""')}"`;
|
|
111
|
+
}
|
|
112
|
+
return XEUtils.eqNull(val) ? "" : val;
|
|
116
113
|
}
|
|
117
114
|
function getElementsByTagName(elem, qualifiedName) {
|
|
118
|
-
|
|
115
|
+
return elem.getElementsByTagName(qualifiedName);
|
|
119
116
|
}
|
|
120
117
|
function getTxtCellKey(now) {
|
|
121
|
-
|
|
118
|
+
return `#${now}@${XEUtils.uniqueId()}`;
|
|
122
119
|
}
|
|
123
120
|
function replaceTxtCell(cell, vMaps) {
|
|
124
|
-
|
|
121
|
+
return cell.replace(/#\d+@\d+/g, (key) => XEUtils.hasOwnProp(vMaps, key) ? vMaps[key] : key);
|
|
125
122
|
}
|
|
126
123
|
function getTxtCellValue(val, vMaps) {
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
const rest = replaceTxtCell(val, vMaps);
|
|
125
|
+
return rest.replace(/^"+$/g, (qVal) => '"'.repeat(Math.ceil(qVal.length / 2)));
|
|
129
126
|
}
|
|
130
127
|
function toExportField(tableConf, field) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
field = teCol.field;
|
|
137
|
-
}
|
|
128
|
+
const { fieldMaps, titleMaps } = tableConf;
|
|
129
|
+
if (!fieldMaps[field]) {
|
|
130
|
+
const teCol = titleMaps[field];
|
|
131
|
+
if (teCol && teCol.field) {
|
|
132
|
+
field = teCol.field;
|
|
138
133
|
}
|
|
139
|
-
|
|
134
|
+
}
|
|
135
|
+
return field;
|
|
140
136
|
}
|
|
141
137
|
function parseCsvAndTxt(tableConf, content, cellSeparator) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
const cells = rVal.split(cellSeparator);
|
|
161
|
-
if (!fields.length) {
|
|
162
|
-
fields = cells.map((val) => toExportField(tableConf, getTxtCellValue(val.trim(), vMaps)));
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
cells.forEach((val, colIndex) => {
|
|
166
|
-
if (colIndex < fields.length) {
|
|
167
|
-
item[fields[colIndex]] = getTxtCellValue(val.trim(), vMaps);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
rows.push(item);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
138
|
+
const list = content.split(enterSymbol);
|
|
139
|
+
const rows = [];
|
|
140
|
+
let fields = [];
|
|
141
|
+
if (list.length) {
|
|
142
|
+
const vMaps = {};
|
|
143
|
+
const now = Date.now();
|
|
144
|
+
list.forEach((rVal) => {
|
|
145
|
+
if (rVal) {
|
|
146
|
+
const item = {};
|
|
147
|
+
rVal = rVal.replace(/("")|(\n)/g, (text, dVal) => {
|
|
148
|
+
const key = getTxtCellKey(now);
|
|
149
|
+
vMaps[key] = dVal ? '"' : "\n";
|
|
150
|
+
return key;
|
|
151
|
+
}).replace(/"(.*?)"/g, (text, cVal) => {
|
|
152
|
+
const key = getTxtCellKey(now);
|
|
153
|
+
vMaps[key] = replaceTxtCell(cVal, vMaps);
|
|
154
|
+
return key;
|
|
173
155
|
});
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
const cells = rVal.split(cellSeparator);
|
|
157
|
+
if (!fields.length) {
|
|
158
|
+
fields = cells.map((val) => toExportField(tableConf, getTxtCellValue(val.trim(), vMaps)));
|
|
159
|
+
} else {
|
|
160
|
+
cells.forEach((val, colIndex) => {
|
|
161
|
+
if (colIndex < fields.length) {
|
|
162
|
+
item[fields[colIndex]] = getTxtCellValue(val.trim(), vMaps);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
rows.push(item);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return { fields, rows };
|
|
176
171
|
}
|
|
177
172
|
function parseCsv(tableConf, content) {
|
|
178
|
-
|
|
173
|
+
return parseCsvAndTxt(tableConf, content, ",");
|
|
179
174
|
}
|
|
180
175
|
function parseTxt(tableConf, content) {
|
|
181
|
-
|
|
176
|
+
return parseCsvAndTxt(tableConf, content, " ");
|
|
182
177
|
}
|
|
183
178
|
function parseHTML(tableConf, content) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
}
|
|
179
|
+
const domParser = new DOMParser();
|
|
180
|
+
const xmlDoc = domParser.parseFromString(content, "text/html");
|
|
181
|
+
const bodyNodes = getElementsByTagName(xmlDoc, "body");
|
|
182
|
+
const rows = [];
|
|
183
|
+
const fields = [];
|
|
184
|
+
if (bodyNodes.length) {
|
|
185
|
+
const tableNodes = getElementsByTagName(bodyNodes[0], "table");
|
|
186
|
+
if (tableNodes.length) {
|
|
187
|
+
const theadNodes = getElementsByTagName(tableNodes[0], "thead");
|
|
188
|
+
if (theadNodes.length) {
|
|
189
|
+
XEUtils.arrayEach(getElementsByTagName(theadNodes[0], "tr"), (rowNode) => {
|
|
190
|
+
XEUtils.arrayEach(getElementsByTagName(rowNode, "th"), (cellNode) => {
|
|
191
|
+
fields.push(toExportField(tableConf, cellNode.textContent || ""));
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
const tbodyNodes = getElementsByTagName(tableNodes[0], "tbody");
|
|
195
|
+
if (tbodyNodes.length) {
|
|
196
|
+
XEUtils.arrayEach(getElementsByTagName(tbodyNodes[0], "tr"), (rowNode) => {
|
|
197
|
+
const item = {};
|
|
198
|
+
XEUtils.arrayEach(getElementsByTagName(rowNode, "td"), (cellNode, colIndex) => {
|
|
199
|
+
if (fields[colIndex]) {
|
|
200
|
+
item[fields[colIndex]] = cellNode.textContent || "";
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
rows.push(item);
|
|
204
|
+
});
|
|
212
205
|
}
|
|
206
|
+
}
|
|
213
207
|
}
|
|
214
|
-
|
|
208
|
+
}
|
|
209
|
+
return { fields, rows };
|
|
215
210
|
}
|
|
216
211
|
function parseXML(tableConf, content) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
212
|
+
const domParser = new DOMParser();
|
|
213
|
+
const xmlDoc = domParser.parseFromString(content, "application/xml");
|
|
214
|
+
const sheetNodes = getElementsByTagName(xmlDoc, "Worksheet");
|
|
215
|
+
const rows = [];
|
|
216
|
+
const fields = [];
|
|
217
|
+
if (sheetNodes.length) {
|
|
218
|
+
const tableNodes = getElementsByTagName(sheetNodes[0], "Table");
|
|
219
|
+
if (tableNodes.length) {
|
|
220
|
+
const rowNodes = getElementsByTagName(tableNodes[0], "Row");
|
|
221
|
+
if (rowNodes.length) {
|
|
222
|
+
XEUtils.arrayEach(getElementsByTagName(rowNodes[0], "Cell"), (cellNode) => {
|
|
223
|
+
fields.push(toExportField(tableConf, cellNode.textContent || ""));
|
|
224
|
+
});
|
|
225
|
+
XEUtils.arrayEach(rowNodes, (rowNode, index) => {
|
|
226
|
+
if (index) {
|
|
227
|
+
const item = {};
|
|
228
|
+
const cellNodes = getElementsByTagName(rowNode, "Cell");
|
|
229
|
+
XEUtils.arrayEach(cellNodes, (cellNode, colIndex) => {
|
|
230
|
+
if (fields[colIndex]) {
|
|
231
|
+
item[fields[colIndex]] = cellNode.textContent;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
rows.push(item);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
244
238
|
}
|
|
245
|
-
|
|
239
|
+
}
|
|
240
|
+
return { fields, rows };
|
|
246
241
|
}
|
|
247
242
|
function clearColumnConvert(columns) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
243
|
+
XEUtils.eachTree(columns, (column) => {
|
|
244
|
+
delete column._level;
|
|
245
|
+
delete column._colSpan;
|
|
246
|
+
delete column._rowSpan;
|
|
247
|
+
delete column._children;
|
|
248
|
+
delete column.childNodes;
|
|
249
|
+
}, { children: "children" });
|
|
255
250
|
}
|
|
256
|
-
const tableExportMethodKeys = [
|
|
257
|
-
hooks.add(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (contentMethod) {
|
|
396
|
-
cellValue = `${contentMethod(ctParams)}`;
|
|
397
|
-
}
|
|
398
|
-
if (showTotal) {
|
|
399
|
-
cellValue = getI18n('vxe.table.rowGroupContentTotal', [cellValue, totalMethod ? totalMethod(ctParams) : childCount, childCount]);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
else if ($xeTable.getPivotTableAggregateCellAggValue) {
|
|
403
|
-
const aggParams = {
|
|
404
|
-
$table: $xeTable,
|
|
405
|
-
row,
|
|
406
|
-
column
|
|
407
|
-
};
|
|
408
|
-
cellValue = $xeTable.getPivotTableAggregateCellAggValue(aggParams);
|
|
409
|
-
}
|
|
410
|
-
else if (aggFunc === true || (countFields && countFields.includes(field))) {
|
|
411
|
-
cellValue = currAggData ? currAggData.value : childCount;
|
|
412
|
-
ctParams.aggValue = cellValue;
|
|
413
|
-
if (formatValuesMethod) {
|
|
414
|
-
cellValue = formatValuesMethod(ctParams);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
else if (opts.original) {
|
|
419
|
-
cellValue = getCellValue(row, column);
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
cellValue = $xeTable.getCellLabel(row, column);
|
|
423
|
-
if (column.type === 'html') {
|
|
424
|
-
htmlCellElem.innerHTML = cellValue;
|
|
425
|
-
cellValue = htmlCellElem.innerText.trim();
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
const cell = $xeTable.getCellElement(row, column);
|
|
429
|
-
if (cell && !hasClass(cell, 'is--progress')) {
|
|
430
|
-
cellValue = cell.innerText.trim();
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
item[column.id] = toStringValue(cellValue);
|
|
439
|
-
});
|
|
440
|
-
useMaps[rowid] = true;
|
|
441
|
-
if (pRowid) {
|
|
442
|
-
expandMaps[pRowid] = true;
|
|
251
|
+
const tableExportMethodKeys = ["exportData", "importByFile", "importData", "saveFile", "readFile", "print", "getPrintHtml", "openImport", "closeImport", "openExport", "closeExport", "openPrint", "closePrint"];
|
|
252
|
+
hooks.add("tableExportModule", {
|
|
253
|
+
setupTable($xeTable) {
|
|
254
|
+
const { props, reactData, internalData } = $xeTable;
|
|
255
|
+
const { computeTreeOpts, computePrintOpts, computeExportOpts, computeImportOpts, computeSeqOpts, computeRadioOpts, computeCheckboxOpts, computeColumnOpts, computeAggregateOpts, computeRendererOpts } = $xeTable.getComputeMaps();
|
|
256
|
+
const getSeq = (cellValue, row, $rowIndex, column, $columnIndex) => {
|
|
257
|
+
const seqOpts = computeSeqOpts.value;
|
|
258
|
+
const seqMd = seqOpts.seqMethod || column.seqMethod;
|
|
259
|
+
if (seqMd) {
|
|
260
|
+
return seqMd({
|
|
261
|
+
$table: $xeTable,
|
|
262
|
+
row,
|
|
263
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
264
|
+
_rowIndex: $xeTable.getVTRowIndex(row),
|
|
265
|
+
$rowIndex,
|
|
266
|
+
column,
|
|
267
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
268
|
+
_columnIndex: $xeTable.getVTColumnIndex(column),
|
|
269
|
+
$columnIndex
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return cellValue;
|
|
273
|
+
};
|
|
274
|
+
function getHeaderTitle(opts, column) {
|
|
275
|
+
const columnOpts = computeColumnOpts.value;
|
|
276
|
+
const headExportMethod = column.headerExportMethod || columnOpts.headerExportMethod;
|
|
277
|
+
return headExportMethod ? headExportMethod({ column, options: opts, $table: $xeTable }) : (opts.isTitle ? $xeTable.getHeaderCellLabel(column) : column.field) || "";
|
|
278
|
+
}
|
|
279
|
+
const toBooleanValue = (cellValue) => {
|
|
280
|
+
return XEUtils.isBoolean(cellValue) ? cellValue ? "TRUE" : "FALSE" : cellValue;
|
|
281
|
+
};
|
|
282
|
+
const toStringValue = (cellValue) => {
|
|
283
|
+
return eqEmptyValue(cellValue) ? "" : `${cellValue}`;
|
|
284
|
+
};
|
|
285
|
+
const getBodyLabelData = (opts, columns, datas) => {
|
|
286
|
+
const { isTreeAllExpanded, isRowGroupAllExpanded, mode: expMode } = opts;
|
|
287
|
+
const { treeConfig } = props;
|
|
288
|
+
const { isRowGroupStatus } = reactData;
|
|
289
|
+
const { fullColumnFieldData, fullAllDataRowIdData } = internalData;
|
|
290
|
+
const radioOpts = computeRadioOpts.value;
|
|
291
|
+
const checkboxOpts = computeCheckboxOpts.value;
|
|
292
|
+
const treeOpts = computeTreeOpts.value;
|
|
293
|
+
const columnOpts = computeColumnOpts.value;
|
|
294
|
+
const aggregateOpts = computeAggregateOpts.value;
|
|
295
|
+
const rendererOpts = computeRendererOpts.value;
|
|
296
|
+
if (!htmlCellElem) {
|
|
297
|
+
htmlCellElem = document.createElement("div");
|
|
298
|
+
}
|
|
299
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable);
|
|
300
|
+
if (isRowGroupStatus) {
|
|
301
|
+
const { mode: aggMode, showTotal, totalMethod, countFields, contentMethod, formatValuesMethod, mapChildrenField } = aggregateOpts;
|
|
302
|
+
const rest = [];
|
|
303
|
+
const expandMaps = {};
|
|
304
|
+
const useMaps = {};
|
|
305
|
+
XEUtils.eachTree(datas, (item, $rowIndex, items, path, parentItem, nodes) => {
|
|
306
|
+
const row = item._row || item;
|
|
307
|
+
const rowid = handleGetRowId(row);
|
|
308
|
+
if (useMaps[rowid]) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const parentRow = parentItem && parentItem._row ? parentItem._row : parentItem;
|
|
312
|
+
const pRowid = parentRow ? handleGetRowId(parentRow) : "";
|
|
313
|
+
if (isRowGroupAllExpanded || !parentRow || expandMaps[pRowid] && $xeTable.isRowExpandByRow(parentRow)) {
|
|
314
|
+
const hasRowChild = mapChildrenField && row[mapChildrenField] && row[mapChildrenField].length;
|
|
315
|
+
const item2 = {
|
|
316
|
+
_row: row,
|
|
317
|
+
_level: nodes.length - 1,
|
|
318
|
+
_hasChild: hasRowChild,
|
|
319
|
+
_expand: hasRowChild && $xeTable.isRowExpandByRow(row)
|
|
320
|
+
};
|
|
321
|
+
columns.forEach((column, $columnIndex) => {
|
|
322
|
+
const { field, editRender, cellRender, aggFunc, rowGroupNode } = column;
|
|
323
|
+
let cellValue = "";
|
|
324
|
+
const renderOpts = editRender || cellRender;
|
|
325
|
+
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
326
|
+
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
327
|
+
const compConf = rendererOpts[renderOpts.name] || renderer.get(renderOpts.name);
|
|
328
|
+
if (compConf) {
|
|
329
|
+
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (!bodyExportMethod) {
|
|
333
|
+
bodyExportMethod = columnOpts.exportMethod;
|
|
334
|
+
}
|
|
335
|
+
if (bodyExportMethod) {
|
|
336
|
+
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts });
|
|
337
|
+
} else {
|
|
338
|
+
switch (column.type) {
|
|
339
|
+
case "seq": {
|
|
340
|
+
const seqVal = path.map((num, i) => i % 2 === 0 ? Number(num) + 1 : ".").join("");
|
|
341
|
+
cellValue = expMode === "all" ? seqVal : getSeq(seqVal, row, $rowIndex, column, $columnIndex);
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case "checkbox": {
|
|
345
|
+
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row));
|
|
346
|
+
item2._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : "";
|
|
347
|
+
item2._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ $table: $xeTable, row });
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
case "radio": {
|
|
351
|
+
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row));
|
|
352
|
+
item2._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : "";
|
|
353
|
+
item2._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ $table: $xeTable, row });
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
default: {
|
|
357
|
+
if (field && row.isAggregate) {
|
|
358
|
+
const aggRow = row;
|
|
359
|
+
const aggData = aggRow.aggData;
|
|
360
|
+
const currAggData = aggData ? aggData[field] : null;
|
|
361
|
+
const groupField = aggRow.groupField;
|
|
362
|
+
const groupContent = aggRow.groupContent;
|
|
363
|
+
const childList = mapChildrenField ? aggRow[mapChildrenField] || [] : [];
|
|
364
|
+
const childCount = aggRow.childCount;
|
|
365
|
+
const colRest = fullColumnFieldData[groupField] || {};
|
|
366
|
+
const ctParams = {
|
|
367
|
+
$table: $xeTable,
|
|
368
|
+
groupField,
|
|
369
|
+
groupColumn: colRest ? colRest.column : null,
|
|
370
|
+
column,
|
|
371
|
+
groupValue: groupContent,
|
|
372
|
+
childList,
|
|
373
|
+
childCount,
|
|
374
|
+
aggValue: null,
|
|
375
|
+
/**
|
|
376
|
+
* 已废弃
|
|
377
|
+
* @deprecated
|
|
378
|
+
*/
|
|
379
|
+
children: childList,
|
|
380
|
+
/**
|
|
381
|
+
* 已废弃
|
|
382
|
+
* @deprecated
|
|
383
|
+
*/
|
|
384
|
+
totalValue: childCount
|
|
385
|
+
};
|
|
386
|
+
if (aggMode === "column" ? field === aggRow.groupField : rowGroupNode) {
|
|
387
|
+
cellValue = groupContent;
|
|
388
|
+
if (contentMethod) {
|
|
389
|
+
cellValue = `${contentMethod(ctParams)}`;
|
|
443
390
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}, { children: mapChildrenField });
|
|
447
|
-
return rest;
|
|
448
|
-
}
|
|
449
|
-
if (treeConfig) {
|
|
450
|
-
// 如果是树结构
|
|
451
|
-
const { seqMode } = treeOpts;
|
|
452
|
-
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
453
|
-
const rest = [];
|
|
454
|
-
const expandMaps = {};
|
|
455
|
-
const useMaps = {};
|
|
456
|
-
XEUtils.eachTree(datas, (item, $rowIndex, items, path, parentItem, nodes) => {
|
|
457
|
-
const row = item._row || item;
|
|
458
|
-
const rowid = handleGetRowId(row);
|
|
459
|
-
if (useMaps[rowid]) {
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
const parentRow = parentItem && parentItem._row ? parentItem._row : parentItem;
|
|
463
|
-
const pRowid = parentRow ? handleGetRowId(parentRow) : '';
|
|
464
|
-
if ((isTreeAllExpanded || !parentRow || (expandMaps[pRowid] && $xeTable.isTreeExpandByRow(parentRow)))) {
|
|
465
|
-
const hasRowChild = row[childrenField] && row[childrenField].length;
|
|
466
|
-
const item = {
|
|
467
|
-
_row: row,
|
|
468
|
-
_level: nodes.length - 1,
|
|
469
|
-
_hasChild: hasRowChild,
|
|
470
|
-
_expand: hasRowChild && $xeTable.isTreeExpandByRow(row)
|
|
471
|
-
};
|
|
472
|
-
const rowRest = fullAllDataRowIdData[rowid] || {};
|
|
473
|
-
columns.forEach((column, $columnIndex) => {
|
|
474
|
-
let cellValue = '';
|
|
475
|
-
const renderOpts = column.editRender || column.cellRender;
|
|
476
|
-
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
477
|
-
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
478
|
-
const compConf = rendererOpts[renderOpts.name] || renderer.get(renderOpts.name);
|
|
479
|
-
if (compConf) {
|
|
480
|
-
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
if (!bodyExportMethod) {
|
|
484
|
-
bodyExportMethod = columnOpts.exportMethod;
|
|
485
|
-
}
|
|
486
|
-
if (bodyExportMethod) {
|
|
487
|
-
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts });
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
switch (column.type) {
|
|
491
|
-
case 'seq': {
|
|
492
|
-
let seqVal = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('');
|
|
493
|
-
if (seqMode === 'increasing') {
|
|
494
|
-
seqVal = rowRest ? (rowRest._index + 1) : -1;
|
|
495
|
-
}
|
|
496
|
-
cellValue = expMode === 'all' ? seqVal : getSeq(seqVal, row, $rowIndex, column, $columnIndex);
|
|
497
|
-
break;
|
|
498
|
-
}
|
|
499
|
-
case 'checkbox':
|
|
500
|
-
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row));
|
|
501
|
-
item._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : '';
|
|
502
|
-
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ $table: $xeTable, row });
|
|
503
|
-
break;
|
|
504
|
-
case 'radio':
|
|
505
|
-
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row));
|
|
506
|
-
item._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : '';
|
|
507
|
-
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ $table: $xeTable, row });
|
|
508
|
-
break;
|
|
509
|
-
default:
|
|
510
|
-
if (opts.original) {
|
|
511
|
-
cellValue = getCellValue(row, column);
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
cellValue = $xeTable.getCellLabel(row, column);
|
|
515
|
-
if (column.type === 'html') {
|
|
516
|
-
htmlCellElem.innerHTML = cellValue;
|
|
517
|
-
cellValue = htmlCellElem.innerText.trim();
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
const cell = $xeTable.getCellElement(row, column);
|
|
521
|
-
if (cell && !hasClass(cell, 'is--progress')) {
|
|
522
|
-
cellValue = cell.innerText.trim();
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
item[column.id] = toStringValue(cellValue);
|
|
529
|
-
});
|
|
530
|
-
useMaps[rowid] = true;
|
|
531
|
-
if (pRowid) {
|
|
532
|
-
expandMaps[pRowid] = true;
|
|
391
|
+
if (showTotal) {
|
|
392
|
+
cellValue = getI18n("vxe.table.rowGroupContentTotal", [cellValue, totalMethod ? totalMethod(ctParams) : childCount, childCount]);
|
|
533
393
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
547
|
-
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
548
|
-
const compConf = rendererOpts[renderOpts.name] || renderer.get(renderOpts.name);
|
|
549
|
-
if (compConf) {
|
|
550
|
-
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
394
|
+
} else if ($xeTable.getPivotTableAggregateCellAggValue) {
|
|
395
|
+
const aggParams = {
|
|
396
|
+
$table: $xeTable,
|
|
397
|
+
row,
|
|
398
|
+
column
|
|
399
|
+
};
|
|
400
|
+
cellValue = $xeTable.getPivotTableAggregateCellAggValue(aggParams);
|
|
401
|
+
} else if (aggFunc === true || countFields && countFields.includes(field)) {
|
|
402
|
+
cellValue = currAggData ? currAggData.value : childCount;
|
|
403
|
+
ctParams.aggValue = cellValue;
|
|
404
|
+
if (formatValuesMethod) {
|
|
405
|
+
cellValue = formatValuesMethod(ctParams);
|
|
551
406
|
}
|
|
552
|
-
|
|
553
|
-
if (
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row));
|
|
565
|
-
item._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : '';
|
|
566
|
-
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ $table: $xeTable, row });
|
|
567
|
-
break;
|
|
568
|
-
case 'radio':
|
|
569
|
-
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row));
|
|
570
|
-
item._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : '';
|
|
571
|
-
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ $table: $xeTable, row });
|
|
572
|
-
break;
|
|
573
|
-
default:
|
|
574
|
-
if (opts.original) {
|
|
575
|
-
cellValue = getCellValue(row, column);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
cellValue = $xeTable.getCellLabel(row, column);
|
|
579
|
-
if (column.type === 'html') {
|
|
580
|
-
htmlCellElem.innerHTML = cellValue;
|
|
581
|
-
cellValue = htmlCellElem.innerText.trim();
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
const cell = $xeTable.getCellElement(row, column);
|
|
585
|
-
if (cell && !hasClass(cell, 'is--progress')) {
|
|
586
|
-
cellValue = cell.innerText.trim();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
407
|
+
}
|
|
408
|
+
} else if (opts.original) {
|
|
409
|
+
cellValue = getCellValue(row, column);
|
|
410
|
+
} else {
|
|
411
|
+
cellValue = $xeTable.getCellLabel(row, column);
|
|
412
|
+
if (column.type === "html") {
|
|
413
|
+
htmlCellElem.innerHTML = cellValue;
|
|
414
|
+
cellValue = htmlCellElem.innerText.trim();
|
|
415
|
+
} else {
|
|
416
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
417
|
+
if (cell && !hasClass(cell, "is--progress")) {
|
|
418
|
+
cellValue = cell.innerText.trim();
|
|
590
419
|
}
|
|
420
|
+
}
|
|
591
421
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
item2[column.id] = toStringValue(cellValue);
|
|
595
427
|
});
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
const $xeGantt = $xeTable.xeGantt;
|
|
600
|
-
const { columns, dataFilterMethod } = opts;
|
|
601
|
-
let datas = opts.data;
|
|
602
|
-
if (dataFilterMethod) {
|
|
603
|
-
datas = datas.filter((row, index) => dataFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, row, $rowIndex: index }));
|
|
428
|
+
useMaps[rowid] = true;
|
|
429
|
+
if (pRowid) {
|
|
430
|
+
expandMaps[pRowid] = true;
|
|
604
431
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
432
|
+
rest.push(Object.assign(item2, row));
|
|
433
|
+
}
|
|
434
|
+
}, { children: mapChildrenField });
|
|
435
|
+
return rest;
|
|
436
|
+
}
|
|
437
|
+
if (treeConfig) {
|
|
438
|
+
const { seqMode } = treeOpts;
|
|
439
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
440
|
+
const rest = [];
|
|
441
|
+
const expandMaps = {};
|
|
442
|
+
const useMaps = {};
|
|
443
|
+
XEUtils.eachTree(datas, (item, $rowIndex, items, path, parentItem, nodes) => {
|
|
444
|
+
const row = item._row || item;
|
|
445
|
+
const rowid = handleGetRowId(row);
|
|
446
|
+
if (useMaps[rowid]) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const parentRow = parentItem && parentItem._row ? parentItem._row : parentItem;
|
|
450
|
+
const pRowid = parentRow ? handleGetRowId(parentRow) : "";
|
|
451
|
+
if (isTreeAllExpanded || !parentRow || expandMaps[pRowid] && $xeTable.isTreeExpandByRow(parentRow)) {
|
|
452
|
+
const hasRowChild = row[childrenField] && row[childrenField].length;
|
|
453
|
+
const item2 = {
|
|
454
|
+
_row: row,
|
|
455
|
+
_level: nodes.length - 1,
|
|
456
|
+
_hasChild: hasRowChild,
|
|
457
|
+
_expand: hasRowChild && $xeTable.isTreeExpandByRow(row)
|
|
458
|
+
};
|
|
459
|
+
const rowRest = fullAllDataRowIdData[rowid] || {};
|
|
460
|
+
columns.forEach((column, $columnIndex) => {
|
|
461
|
+
let cellValue = "";
|
|
462
|
+
const renderOpts = column.editRender || column.cellRender;
|
|
463
|
+
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
464
|
+
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
613
465
|
const compConf = rendererOpts[renderOpts.name] || renderer.get(renderOpts.name);
|
|
614
466
|
if (compConf) {
|
|
615
|
-
|
|
467
|
+
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (!bodyExportMethod) {
|
|
471
|
+
bodyExportMethod = columnOpts.exportMethod;
|
|
472
|
+
}
|
|
473
|
+
if (bodyExportMethod) {
|
|
474
|
+
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts });
|
|
475
|
+
} else {
|
|
476
|
+
switch (column.type) {
|
|
477
|
+
case "seq": {
|
|
478
|
+
let seqVal = path.map((num, i) => i % 2 === 0 ? Number(num) + 1 : ".").join("");
|
|
479
|
+
if (seqMode === "increasing") {
|
|
480
|
+
seqVal = rowRest ? rowRest._index + 1 : -1;
|
|
481
|
+
}
|
|
482
|
+
cellValue = expMode === "all" ? seqVal : getSeq(seqVal, row, $rowIndex, column, $columnIndex);
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
case "checkbox":
|
|
486
|
+
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row));
|
|
487
|
+
item2._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : "";
|
|
488
|
+
item2._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ $table: $xeTable, row });
|
|
489
|
+
break;
|
|
490
|
+
case "radio":
|
|
491
|
+
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row));
|
|
492
|
+
item2._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : "";
|
|
493
|
+
item2._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ $table: $xeTable, row });
|
|
494
|
+
break;
|
|
495
|
+
default:
|
|
496
|
+
if (opts.original) {
|
|
497
|
+
cellValue = getCellValue(row, column);
|
|
498
|
+
} else {
|
|
499
|
+
cellValue = $xeTable.getCellLabel(row, column);
|
|
500
|
+
if (column.type === "html") {
|
|
501
|
+
htmlCellElem.innerHTML = cellValue;
|
|
502
|
+
cellValue = htmlCellElem.innerText.trim();
|
|
503
|
+
} else {
|
|
504
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
505
|
+
if (cell && !hasClass(cell, "is--progress")) {
|
|
506
|
+
cellValue = cell.innerText.trim();
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
616
510
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
footLabelMethod = columnOpts.footerExportMethod;
|
|
620
|
-
}
|
|
621
|
-
if (footLabelMethod) {
|
|
622
|
-
const _columnIndex = $xeTable.getVTColumnIndex(column);
|
|
623
|
-
return footLabelMethod({ $table: $xeTable, items: row, itemIndex: _columnIndex, row, _columnIndex, column, options: opts });
|
|
624
|
-
}
|
|
625
|
-
const cellValue = $xeTable.getFooterCellLabel(row, column);
|
|
626
|
-
return cellValue;
|
|
627
|
-
};
|
|
628
|
-
const toCsv = ($xeTable, opts, columns, datas) => {
|
|
629
|
-
let content = csvBOM;
|
|
630
|
-
if (opts.isHeader) {
|
|
631
|
-
content += columns.map((column) => toTxtCellLabel(getHeaderTitle(opts, column))).join(',') + enterSymbol;
|
|
632
|
-
}
|
|
633
|
-
datas.forEach((row) => {
|
|
634
|
-
content += columns.map((column) => toTxtCellLabel(getCsvCellTypeLabel(column, row[column.id]))).join(',') + enterSymbol;
|
|
511
|
+
}
|
|
512
|
+
item2[column.id] = toStringValue(cellValue);
|
|
635
513
|
});
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
footers.forEach((row) => {
|
|
640
|
-
content += columns.map((column) => toTxtCellLabel(getFooterCellValue(opts, row, column))).join(',') + enterSymbol;
|
|
641
|
-
});
|
|
514
|
+
useMaps[rowid] = true;
|
|
515
|
+
if (pRowid) {
|
|
516
|
+
expandMaps[pRowid] = true;
|
|
642
517
|
}
|
|
643
|
-
|
|
518
|
+
rest.push(Object.assign(item2, row));
|
|
519
|
+
}
|
|
520
|
+
}, { children: childrenField });
|
|
521
|
+
return rest;
|
|
522
|
+
}
|
|
523
|
+
return datas.map((row, $rowIndex) => {
|
|
524
|
+
const item = {
|
|
525
|
+
_row: row
|
|
644
526
|
};
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
527
|
+
columns.forEach((column, $columnIndex) => {
|
|
528
|
+
let cellValue = "";
|
|
529
|
+
const renderOpts = column.editRender || column.cellRender;
|
|
530
|
+
let bodyExportMethod = column.exportMethod || columnOpts.exportMethod;
|
|
531
|
+
if (!bodyExportMethod && renderOpts && renderOpts.name) {
|
|
532
|
+
const compConf = rendererOpts[renderOpts.name] || renderer.get(renderOpts.name);
|
|
533
|
+
if (compConf) {
|
|
534
|
+
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod;
|
|
649
535
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
536
|
+
}
|
|
537
|
+
if (bodyExportMethod) {
|
|
538
|
+
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts });
|
|
539
|
+
} else {
|
|
540
|
+
switch (column.type) {
|
|
541
|
+
case "seq": {
|
|
542
|
+
const seqValue = $rowIndex + 1;
|
|
543
|
+
cellValue = expMode === "all" ? seqValue : getSeq(seqValue, row, $rowIndex, column, $columnIndex);
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
case "checkbox":
|
|
547
|
+
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row));
|
|
548
|
+
item._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : "";
|
|
549
|
+
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ $table: $xeTable, row });
|
|
550
|
+
break;
|
|
551
|
+
case "radio":
|
|
552
|
+
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row));
|
|
553
|
+
item._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : "";
|
|
554
|
+
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ $table: $xeTable, row });
|
|
555
|
+
break;
|
|
556
|
+
default:
|
|
557
|
+
if (opts.original) {
|
|
558
|
+
cellValue = getCellValue(row, column);
|
|
559
|
+
} else {
|
|
560
|
+
cellValue = $xeTable.getCellLabel(row, column);
|
|
561
|
+
if (column.type === "html") {
|
|
562
|
+
htmlCellElem.innerHTML = cellValue;
|
|
563
|
+
cellValue = htmlCellElem.innerText.trim();
|
|
564
|
+
} else {
|
|
565
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
566
|
+
if (cell && !hasClass(cell, "is--progress")) {
|
|
567
|
+
cellValue = cell.innerText.trim();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
659
571
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
572
|
+
}
|
|
573
|
+
item[column.id] = toStringValue(cellValue);
|
|
574
|
+
});
|
|
575
|
+
return item;
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
const getExportData = (opts) => {
|
|
579
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
580
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
581
|
+
const { columns, dataFilterMethod } = opts;
|
|
582
|
+
let datas = opts.data;
|
|
583
|
+
if (dataFilterMethod) {
|
|
584
|
+
datas = datas.filter((row, index) => dataFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, row, $rowIndex: index }));
|
|
585
|
+
}
|
|
586
|
+
return getBodyLabelData(opts, columns, datas);
|
|
587
|
+
};
|
|
588
|
+
const getFooterCellValue = (opts, row, column) => {
|
|
589
|
+
const columnOpts = computeColumnOpts.value;
|
|
590
|
+
const rendererOpts = computeRendererOpts.value;
|
|
591
|
+
const renderOpts = column.editRender || column.cellRender;
|
|
592
|
+
let footLabelMethod = column.footerExportMethod;
|
|
593
|
+
if (!footLabelMethod && renderOpts && renderOpts.name) {
|
|
594
|
+
const compConf = rendererOpts[renderOpts.name] || renderer.get(renderOpts.name);
|
|
595
|
+
if (compConf) {
|
|
596
|
+
footLabelMethod = compConf.tableFooterExportMethod || compConf.footerExportMethod;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (!footLabelMethod) {
|
|
600
|
+
footLabelMethod = columnOpts.footerExportMethod;
|
|
601
|
+
}
|
|
602
|
+
if (footLabelMethod) {
|
|
603
|
+
const _columnIndex = $xeTable.getVTColumnIndex(column);
|
|
604
|
+
return footLabelMethod({ $table: $xeTable, items: row, itemIndex: _columnIndex, row, _columnIndex, column, options: opts });
|
|
605
|
+
}
|
|
606
|
+
const cellValue = $xeTable.getFooterCellLabel(row, column);
|
|
607
|
+
return cellValue;
|
|
608
|
+
};
|
|
609
|
+
const toCsv = ($xeTable2, opts, columns, datas) => {
|
|
610
|
+
let content = csvBOM;
|
|
611
|
+
if (opts.isHeader) {
|
|
612
|
+
content += columns.map((column) => toTxtCellLabel(getHeaderTitle(opts, column))).join(",") + enterSymbol;
|
|
613
|
+
}
|
|
614
|
+
datas.forEach((row) => {
|
|
615
|
+
content += columns.map((column) => toTxtCellLabel(getCsvCellTypeLabel(column, row[column.id]))).join(",") + enterSymbol;
|
|
616
|
+
});
|
|
617
|
+
if (opts.isFooter) {
|
|
618
|
+
const { footerTableData } = reactData;
|
|
619
|
+
const footers = getFooterData($xeTable2, opts, footerTableData);
|
|
620
|
+
footers.forEach((row) => {
|
|
621
|
+
content += columns.map((column) => toTxtCellLabel(getFooterCellValue(opts, row, column))).join(",") + enterSymbol;
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
return content;
|
|
625
|
+
};
|
|
626
|
+
const toTxt = ($xeTable2, opts, columns, datas) => {
|
|
627
|
+
let content = "";
|
|
628
|
+
if (opts.isHeader) {
|
|
629
|
+
content += columns.map((column) => toTxtCellLabel(getHeaderTitle(opts, column))).join(" ") + enterSymbol;
|
|
630
|
+
}
|
|
631
|
+
datas.forEach((row) => {
|
|
632
|
+
content += columns.map((column) => toTxtCellLabel(row[column.id])).join(" ") + enterSymbol;
|
|
633
|
+
});
|
|
634
|
+
if (opts.isFooter) {
|
|
635
|
+
const { footerTableData } = reactData;
|
|
636
|
+
const footers = getFooterData($xeTable2, opts, footerTableData);
|
|
637
|
+
footers.forEach((row) => {
|
|
638
|
+
content += columns.map((column) => toTxtCellLabel(getFooterCellValue(opts, row, column))).join(" ") + enterSymbol;
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
return content;
|
|
642
|
+
};
|
|
643
|
+
const hasEllipsis = (column, property, allColumnOverflow) => {
|
|
644
|
+
const columnOverflow = column[property];
|
|
645
|
+
const headOverflow = XEUtils.isUndefined(columnOverflow) || XEUtils.isNull(columnOverflow) ? allColumnOverflow : columnOverflow;
|
|
646
|
+
const showEllipsis = headOverflow === "ellipsis";
|
|
647
|
+
const showTitle = headOverflow === "title";
|
|
648
|
+
const showTooltip = headOverflow === true || headOverflow === "tooltip";
|
|
649
|
+
let isEllipsis = showTitle || showTooltip || showEllipsis;
|
|
650
|
+
const { scrollXLoad, scrollYLoad } = reactData;
|
|
651
|
+
if ((scrollXLoad || scrollYLoad) && !isEllipsis) {
|
|
652
|
+
isEllipsis = true;
|
|
653
|
+
}
|
|
654
|
+
return isEllipsis;
|
|
655
|
+
};
|
|
656
|
+
const getCustomColKey = (conf) => {
|
|
657
|
+
return `${conf.field || ""}:${conf.type || ""}`;
|
|
658
|
+
};
|
|
659
|
+
const toHtml = (opts, columns, datas) => {
|
|
660
|
+
const { id, border, treeConfig, headerAlign: allHeaderAlign, align: allAlign, footerAlign: allFooterAlign, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow } = props;
|
|
661
|
+
const { isAllSelected, isIndeterminate } = reactData;
|
|
662
|
+
const { mergeBodyCellMaps, mergeFooterCellMaps } = internalData;
|
|
663
|
+
const treeOpts = computeTreeOpts.value;
|
|
664
|
+
const { print: isPrint, widthMode, isHeader, isFooter, isColgroup, isMerge, colgroups, _columnConfs, original } = opts;
|
|
665
|
+
const isAutoWidth = widthMode === "auto";
|
|
666
|
+
const isScaleWidth = widthMode === "scale";
|
|
667
|
+
const isDefaultWidth = !isAutoWidth && !isScaleWidth;
|
|
668
|
+
const customWidthMaps = {};
|
|
669
|
+
if (_columnConfs) {
|
|
670
|
+
_columnConfs.forEach((conf) => {
|
|
671
|
+
if (!isColumnInfo(conf)) {
|
|
672
|
+
if ((conf.field || conf.type) && conf.width) {
|
|
673
|
+
customWidthMaps[getCustomColKey(conf)] = conf.width;
|
|
673
674
|
}
|
|
674
|
-
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
const colWidthMaps = {};
|
|
679
|
+
const printWidthMaps = {};
|
|
680
|
+
if (isPrint) {
|
|
681
|
+
let tableWidth = 0;
|
|
682
|
+
columns.forEach((column) => {
|
|
683
|
+
tableWidth += column.renderWidth;
|
|
684
|
+
});
|
|
685
|
+
if (colgroups) {
|
|
686
|
+
colgroups.forEach((cols) => {
|
|
687
|
+
cols.forEach((column) => {
|
|
688
|
+
if (!column.childNodes || !column.childNodes.length) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
let childWidth = 0;
|
|
692
|
+
let countChild = 0;
|
|
693
|
+
XEUtils.eachTree([column], (item) => {
|
|
694
|
+
if (!item.childNodes || !column.childNodes.length) {
|
|
695
|
+
countChild++;
|
|
696
|
+
}
|
|
697
|
+
const ptWidth = printWidthMaps[item.id];
|
|
698
|
+
childWidth += ptWidth || 0;
|
|
699
|
+
}, { children: "childNodes" });
|
|
700
|
+
const colWidth = childWidth - countChild;
|
|
701
|
+
colWidthMaps[column.id] = colWidth;
|
|
702
|
+
printWidthMaps[column.id] = XEUtils.floor(colWidth / tableWidth * 180, 2);
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
columns.forEach((column) => {
|
|
707
|
+
const colWidth = column.renderWidth;
|
|
708
|
+
if (column.width) {
|
|
709
|
+
colWidthMaps[column.id] = colWidth;
|
|
710
|
+
}
|
|
711
|
+
printWidthMaps[column.id] = XEUtils.floor(colWidth / tableWidth * 180, 2);
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
const getHeaderWidthStyle = (column) => {
|
|
715
|
+
const cmColKey = getCustomColKey(column);
|
|
716
|
+
const cmWidthMaps = customWidthMaps[cmColKey];
|
|
717
|
+
if (cmWidthMaps) {
|
|
718
|
+
return "width:" + toCssUnit(cmWidthMaps);
|
|
719
|
+
}
|
|
720
|
+
if (isAutoWidth) {
|
|
721
|
+
return "";
|
|
722
|
+
}
|
|
723
|
+
if (isScaleWidth) {
|
|
724
|
+
return printWidthMaps[column.id] ? "width:" + printWidthMaps[column.id] + "mm" : "";
|
|
725
|
+
}
|
|
726
|
+
return colWidthMaps[column.id] ? "width:" + toCssUnit(colWidthMaps[column.id]) : "";
|
|
727
|
+
};
|
|
728
|
+
const getCellWidthStyle = (column) => {
|
|
729
|
+
const cmColKey = getCustomColKey(column);
|
|
730
|
+
const cmWidthMaps = customWidthMaps[cmColKey];
|
|
731
|
+
if (cmWidthMaps) {
|
|
732
|
+
return "width:" + toCssUnit(cmWidthMaps);
|
|
733
|
+
}
|
|
734
|
+
if (isAutoWidth || isDefaultWidth) {
|
|
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 allCls = "check-all";
|
|
743
|
+
const clss = [
|
|
744
|
+
"vxe-table",
|
|
745
|
+
`border--${toTableBorder(border)}`,
|
|
746
|
+
isPrint ? "is--print" : "",
|
|
747
|
+
isAutoWidth ? "is--auto-width" : "",
|
|
748
|
+
isScaleWidth ? "is--scale-width" : "",
|
|
749
|
+
isDefaultWidth ? "is--default-width" : "",
|
|
750
|
+
isHeader ? "is--header" : ""
|
|
751
|
+
].filter((cls) => cls);
|
|
752
|
+
const tables = [
|
|
753
|
+
`<table class="${clss.join(" ")}" border="0" cellspacing="0" cellpadding="0">`,
|
|
754
|
+
`<colgroup>${columns.map((column) => `<col style="${getHeaderWidthStyle(column)}">`).join("")}</colgroup>`
|
|
755
|
+
];
|
|
756
|
+
if (isHeader) {
|
|
757
|
+
tables.push("<thead>");
|
|
758
|
+
if (isColgroup && !original) {
|
|
759
|
+
colgroups.forEach((cols) => {
|
|
760
|
+
tables.push(
|
|
761
|
+
`<tr>${cols.map((column) => {
|
|
762
|
+
const headAlign = column.headerAlign || column.align || allHeaderAlign || allAlign;
|
|
763
|
+
const classNames = hasEllipsis(column, "showHeaderOverflow", allColumnHeaderOverflow) ? ["col--ellipsis"] : [];
|
|
764
|
+
const cellTitle = getHeaderTitle(opts, column);
|
|
765
|
+
if (headAlign) {
|
|
766
|
+
classNames.push(`col--${headAlign}`);
|
|
767
|
+
}
|
|
768
|
+
if (column.type === "checkbox") {
|
|
769
|
+
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>`;
|
|
770
|
+
}
|
|
771
|
+
return `<th class="${classNames.join(" ")}" colspan="${column._colSpan}" rowspan="${column._rowSpan}" title="${cellTitle}"><div style="${getCellWidthStyle(column)}"><span>${formatText(cellTitle, true)}</span></div></th>`;
|
|
772
|
+
}).join("")}</tr>`
|
|
773
|
+
);
|
|
774
|
+
});
|
|
775
|
+
} else {
|
|
776
|
+
tables.push(
|
|
777
|
+
`<tr>${columns.map((column) => {
|
|
778
|
+
const headAlign = column.headerAlign || column.align || allHeaderAlign || allAlign;
|
|
779
|
+
const classNames = hasEllipsis(column, "showHeaderOverflow", allColumnHeaderOverflow) ? ["col--ellipsis"] : [];
|
|
780
|
+
const cellTitle = getHeaderTitle(opts, column);
|
|
781
|
+
if (headAlign) {
|
|
782
|
+
classNames.push(`col--${headAlign}`);
|
|
783
|
+
}
|
|
784
|
+
if (column.type === "checkbox") {
|
|
785
|
+
return `<th class="${classNames.join(" ")}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" class="${allCls}" ${isAllSelected ? "checked" : ""}><span>${cellTitle}</span></div></th>`;
|
|
786
|
+
}
|
|
787
|
+
return `<th class="${classNames.join(" ")}" title="${cellTitle}"><div style="${getCellWidthStyle(column)}"><span>${formatText(cellTitle, true)}</span></div></th>`;
|
|
788
|
+
}).join("")}</tr>`
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
tables.push("</thead>");
|
|
792
|
+
}
|
|
793
|
+
if (datas.length) {
|
|
794
|
+
tables.push("<tbody>");
|
|
795
|
+
if (treeConfig) {
|
|
796
|
+
datas.forEach((item) => {
|
|
797
|
+
tables.push(
|
|
798
|
+
"<tr>" + columns.map((column) => {
|
|
799
|
+
const colid = column.id;
|
|
800
|
+
const cellAlign = column.align || allAlign;
|
|
801
|
+
const classNames = hasEllipsis(column, "showOverflow", allColumnOverflow) ? ["col--ellipsis"] : [];
|
|
802
|
+
const cellValue = item[colid];
|
|
803
|
+
if (cellAlign) {
|
|
804
|
+
classNames.push(`col--${cellAlign}`);
|
|
805
|
+
}
|
|
806
|
+
if (column.treeNode) {
|
|
807
|
+
let treeIcon = "";
|
|
808
|
+
if (item._hasChild) {
|
|
809
|
+
treeIcon = `<i class="${item._expand ? "vxe-table--tree-fold-icon" : "vxe-table--tree-unfold-icon"}"></i>`;
|
|
810
|
+
}
|
|
811
|
+
classNames.push("vxe-table--tree-node");
|
|
812
|
+
if (column.type === "radio") {
|
|
813
|
+
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>`;
|
|
814
|
+
} else if (column.type === "checkbox") {
|
|
815
|
+
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>`;
|
|
816
|
+
}
|
|
817
|
+
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>`;
|
|
818
|
+
}
|
|
819
|
+
if (column.type === "radio") {
|
|
820
|
+
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>`;
|
|
821
|
+
} else if (column.type === "checkbox") {
|
|
822
|
+
return `<td class="${classNames.join(" ")}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" ${item._checkboxDisabled ? "disabled " : ""}${getBooleanValue(cellValue) ? "checked" : ""}><span>${item._checkboxLabel}</span></div></td>`;
|
|
823
|
+
}
|
|
824
|
+
return `<td class="${classNames.join(" ")}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
|
|
825
|
+
}).join("") + "</tr>"
|
|
826
|
+
);
|
|
827
|
+
});
|
|
828
|
+
} else {
|
|
829
|
+
datas.forEach((item) => {
|
|
830
|
+
tables.push(
|
|
831
|
+
"<tr>" + columns.map((column) => {
|
|
832
|
+
const cellAlign = column.align || allAlign;
|
|
833
|
+
const classNames = hasEllipsis(column, "showOverflow", allColumnOverflow) ? ["col--ellipsis"] : [];
|
|
834
|
+
const cellValue = item[column.id];
|
|
835
|
+
let rowSpan = 1;
|
|
836
|
+
let colSpan = 1;
|
|
837
|
+
if (isMerge) {
|
|
838
|
+
const _rowIndex = $xeTable.getVTRowIndex(item._row);
|
|
839
|
+
const _columnIndex = $xeTable.getVTColumnIndex(column);
|
|
840
|
+
const spanRest = mergeBodyCellMaps[`${_rowIndex}:${_columnIndex}`];
|
|
841
|
+
if (spanRest) {
|
|
842
|
+
const { rowspan, colspan } = spanRest;
|
|
843
|
+
if (!rowspan || !colspan) {
|
|
844
|
+
return "";
|
|
695
845
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
// 计算宽度
|
|
699
|
-
const colWidthMaps = {};
|
|
700
|
-
const printWidthMaps = {};
|
|
701
|
-
if (isPrint) {
|
|
702
|
-
let tableWidth = 0;
|
|
703
|
-
columns.forEach(column => {
|
|
704
|
-
tableWidth += column.renderWidth;
|
|
705
|
-
});
|
|
706
|
-
if (colgroups) {
|
|
707
|
-
colgroups.forEach((cols) => {
|
|
708
|
-
cols.forEach((column) => {
|
|
709
|
-
if (!column.childNodes || !column.childNodes.length) {
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
let childWidth = 0;
|
|
713
|
-
let countChild = 0;
|
|
714
|
-
XEUtils.eachTree([column], item => {
|
|
715
|
-
if (!item.childNodes || !column.childNodes.length) {
|
|
716
|
-
countChild++;
|
|
717
|
-
}
|
|
718
|
-
const ptWidth = printWidthMaps[item.id];
|
|
719
|
-
childWidth += ptWidth || 0;
|
|
720
|
-
}, { children: 'childNodes' });
|
|
721
|
-
const colWidth = childWidth - countChild;
|
|
722
|
-
colWidthMaps[column.id] = colWidth;
|
|
723
|
-
printWidthMaps[column.id] = XEUtils.floor(colWidth / tableWidth * 180, 2);
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
columns.forEach(column => {
|
|
728
|
-
const colWidth = column.renderWidth;
|
|
729
|
-
if (column.width) {
|
|
730
|
-
colWidthMaps[column.id] = colWidth;
|
|
846
|
+
if (rowspan > 1) {
|
|
847
|
+
rowSpan = rowspan;
|
|
731
848
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
const cmColKey = getCustomColKey(column);
|
|
737
|
-
const cmWidthMaps = customWidthMaps[cmColKey];
|
|
738
|
-
if (cmWidthMaps) {
|
|
739
|
-
return 'width:' + toCssUnit(cmWidthMaps);
|
|
740
|
-
}
|
|
741
|
-
if (isAutoWidth) {
|
|
742
|
-
return '';
|
|
743
|
-
}
|
|
744
|
-
if (isScaleWidth) {
|
|
745
|
-
return printWidthMaps[column.id] ? ('width:' + printWidthMaps[column.id] + 'mm') : '';
|
|
746
|
-
}
|
|
747
|
-
return colWidthMaps[column.id] ? ('width:' + toCssUnit(colWidthMaps[column.id])) : '';
|
|
748
|
-
};
|
|
749
|
-
const getCellWidthStyle = (column) => {
|
|
750
|
-
const cmColKey = getCustomColKey(column);
|
|
751
|
-
const cmWidthMaps = customWidthMaps[cmColKey];
|
|
752
|
-
if (cmWidthMaps) {
|
|
753
|
-
return 'width:' + toCssUnit(cmWidthMaps);
|
|
849
|
+
if (colspan > 1) {
|
|
850
|
+
colSpan = colspan;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
754
853
|
}
|
|
755
|
-
if (
|
|
756
|
-
|
|
854
|
+
if (cellAlign) {
|
|
855
|
+
classNames.push(`col--${cellAlign}`);
|
|
757
856
|
}
|
|
758
|
-
if (
|
|
759
|
-
|
|
857
|
+
if (column.type === "radio") {
|
|
858
|
+
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>`;
|
|
859
|
+
} else if (column.type === "checkbox") {
|
|
860
|
+
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>`;
|
|
760
861
|
}
|
|
761
|
-
return
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
862
|
+
return `<td class="${classNames.join(" ")}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
|
|
863
|
+
}).join("") + "</tr>"
|
|
864
|
+
);
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
tables.push("</tbody>");
|
|
868
|
+
}
|
|
869
|
+
if (isFooter) {
|
|
870
|
+
const { footerTableData } = reactData;
|
|
871
|
+
const footers = getFooterData($xeTable, opts, footerTableData);
|
|
872
|
+
if (footers.length) {
|
|
873
|
+
tables.push("<tfoot>");
|
|
874
|
+
footers.forEach((row, rIndex) => {
|
|
875
|
+
tables.push(
|
|
876
|
+
`<tr>${columns.map((column) => {
|
|
877
|
+
const footAlign = column.footerAlign || column.align || allFooterAlign || allAlign;
|
|
878
|
+
const classNames = hasEllipsis(column, "showOverflow", allColumnOverflow) ? ["col--ellipsis"] : [];
|
|
879
|
+
const cellValue = getFooterCellValue(opts, row, column);
|
|
880
|
+
let rowSpan = 1;
|
|
881
|
+
let colSpan = 1;
|
|
882
|
+
if (isMerge) {
|
|
883
|
+
const _rowIndex = rIndex;
|
|
884
|
+
const _columnIndex = $xeTable.getVTColumnIndex(column);
|
|
885
|
+
const spanRest = mergeFooterCellMaps[`${_rowIndex}:${_columnIndex}`];
|
|
886
|
+
if (spanRest) {
|
|
887
|
+
const { rowspan, colspan } = spanRest;
|
|
888
|
+
if (!rowspan || !colspan) {
|
|
889
|
+
return "";
|
|
890
|
+
}
|
|
891
|
+
if (rowspan > 1) {
|
|
892
|
+
rowSpan = rowspan;
|
|
893
|
+
}
|
|
894
|
+
if (colspan > 1) {
|
|
895
|
+
colSpan = colspan;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
794
898
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
const headAlign = column.headerAlign || column.align || allHeaderAlign || allAlign;
|
|
798
|
-
const classNames = hasEllipsis(column, 'showHeaderOverflow', allColumnHeaderOverflow) ? ['col--ellipsis'] : [];
|
|
799
|
-
const cellTitle = getHeaderTitle(opts, column);
|
|
800
|
-
if (headAlign) {
|
|
801
|
-
classNames.push(`col--${headAlign}`);
|
|
802
|
-
}
|
|
803
|
-
if (column.type === 'checkbox') {
|
|
804
|
-
return `<th class="${classNames.join(' ')}"><div style="${getCellWidthStyle(column)}"><input type="checkbox" class="${allCls}" ${isAllSelected ? 'checked' : ''}><span>${cellTitle}</span></div></th>`;
|
|
805
|
-
}
|
|
806
|
-
return `<th class="${classNames.join(' ')}" title="${cellTitle}"><div style="${getCellWidthStyle(column)}"><span>${formatText(cellTitle, true)}</span></div></th>`;
|
|
807
|
-
}).join('')}</tr>`);
|
|
899
|
+
if (footAlign) {
|
|
900
|
+
classNames.push(`col--${footAlign}`);
|
|
808
901
|
}
|
|
809
|
-
|
|
902
|
+
return `<td class="${classNames.join(" ")}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
|
|
903
|
+
}).join("")}</tr>`
|
|
904
|
+
);
|
|
905
|
+
});
|
|
906
|
+
tables.push("</tfoot>");
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
const script = !isAllSelected && isIndeterminate ? `<script>(function(){var a=document.querySelector(".${allCls}");if(a){a.indeterminate=true}})()</script>` : "";
|
|
910
|
+
tables.push("</table>", script);
|
|
911
|
+
return isPrint ? tables.join("") : createHtmlPage(opts, tables.join(""));
|
|
912
|
+
};
|
|
913
|
+
const toXML = (opts, columns, datas) => {
|
|
914
|
+
let xml = [
|
|
915
|
+
'<?xml version="1.0"?>',
|
|
916
|
+
'<?mso-application progid="Excel.Sheet"?>',
|
|
917
|
+
'<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">',
|
|
918
|
+
'<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">',
|
|
919
|
+
"<Version>16.00</Version>",
|
|
920
|
+
"</DocumentProperties>",
|
|
921
|
+
'<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">',
|
|
922
|
+
"<WindowHeight>7920</WindowHeight>",
|
|
923
|
+
"<WindowWidth>21570</WindowWidth>",
|
|
924
|
+
"<WindowTopX>32767</WindowTopX>",
|
|
925
|
+
"<WindowTopY>32767</WindowTopY>",
|
|
926
|
+
"<ProtectStructure>False</ProtectStructure>",
|
|
927
|
+
"<ProtectWindows>False</ProtectWindows>",
|
|
928
|
+
"</ExcelWorkbook>",
|
|
929
|
+
`<Worksheet ss:Name="${opts.sheetName}">`,
|
|
930
|
+
"<Table>",
|
|
931
|
+
columns.map((column) => `<Column ss:Width="${column.renderWidth}"/>`).join("")
|
|
932
|
+
].join("");
|
|
933
|
+
if (opts.isHeader) {
|
|
934
|
+
xml += `<Row>${columns.map((column) => `<Cell><Data ss:Type="String">${getHeaderTitle(opts, column)}</Data></Cell>`).join("")}</Row>`;
|
|
935
|
+
}
|
|
936
|
+
datas.forEach((row) => {
|
|
937
|
+
xml += "<Row>" + columns.map((column) => `<Cell><Data ss:Type="String">${row[column.id]}</Data></Cell>`).join("") + "</Row>";
|
|
938
|
+
});
|
|
939
|
+
if (opts.isFooter) {
|
|
940
|
+
const { footerTableData } = reactData;
|
|
941
|
+
const footers = getFooterData($xeTable, opts, footerTableData);
|
|
942
|
+
footers.forEach((row) => {
|
|
943
|
+
xml += `<Row>${columns.map((column) => `<Cell><Data ss:Type="String">${getFooterCellValue(opts, row, column)}</Data></Cell>`).join("")}</Row>`;
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
return `${xml}</Table></Worksheet></Workbook>`;
|
|
947
|
+
};
|
|
948
|
+
const getContent = ($xeTable2, opts, columns, datas) => {
|
|
949
|
+
if (columns.length) {
|
|
950
|
+
switch (opts.type) {
|
|
951
|
+
case "csv":
|
|
952
|
+
return toCsv($xeTable2, opts, columns, datas);
|
|
953
|
+
case "txt":
|
|
954
|
+
return toTxt($xeTable2, opts, columns, datas);
|
|
955
|
+
case "html":
|
|
956
|
+
return toHtml(opts, columns, datas);
|
|
957
|
+
case "xml":
|
|
958
|
+
return toXML(opts, columns, datas);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return "";
|
|
962
|
+
};
|
|
963
|
+
const downloadFile = (opts, content) => {
|
|
964
|
+
const { filename, type, download } = opts;
|
|
965
|
+
if (!download) {
|
|
966
|
+
const blob = getExportBlobByContent(content, opts);
|
|
967
|
+
return Promise.resolve({ type, content, blob });
|
|
968
|
+
}
|
|
969
|
+
if (VxeUI.saveFile) {
|
|
970
|
+
VxeUI.saveFile({ filename, type, content }).then(() => {
|
|
971
|
+
if (opts.message !== false) {
|
|
972
|
+
if (VxeUI.modal) {
|
|
973
|
+
VxeUI.modal.message({ content: getI18n("vxe.table.expSuccess"), status: "success" });
|
|
810
974
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
const handleExport = (opts) => {
|
|
980
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
981
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
982
|
+
const { remote, columns, colgroups, exportMethod, afterExportMethod } = opts;
|
|
983
|
+
return new Promise((resolve) => {
|
|
984
|
+
if (remote) {
|
|
985
|
+
const params = { options: opts, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt };
|
|
986
|
+
resolve(exportMethod ? exportMethod(params) : params);
|
|
987
|
+
} else {
|
|
988
|
+
const datas = getExportData(opts);
|
|
989
|
+
resolve(
|
|
990
|
+
$xeTable.preventEvent(null, "event.export", { options: opts, columns, colgroups, datas }, () => {
|
|
991
|
+
return downloadFile(opts, getContent($xeTable, opts, columns, datas));
|
|
992
|
+
})
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
}).then((params) => {
|
|
996
|
+
clearColumnConvert(columns);
|
|
997
|
+
if (!opts.print) {
|
|
998
|
+
if (afterExportMethod) {
|
|
999
|
+
afterExportMethod({ status: true, options: opts, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return Object.assign({ status: true }, params);
|
|
1003
|
+
}).catch(() => {
|
|
1004
|
+
clearColumnConvert(columns);
|
|
1005
|
+
if (!opts.print) {
|
|
1006
|
+
if (afterExportMethod) {
|
|
1007
|
+
afterExportMethod({ status: false, options: opts, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
const params = { status: false };
|
|
1011
|
+
return Promise.reject(params);
|
|
1012
|
+
});
|
|
1013
|
+
};
|
|
1014
|
+
const handleImport = (content, opts) => {
|
|
1015
|
+
const { tableFullColumn, _importResolve, _importReject } = internalData;
|
|
1016
|
+
let rest = { fields: [], rows: [] };
|
|
1017
|
+
const tableFieldMaps = {};
|
|
1018
|
+
const tableTitleMaps = {};
|
|
1019
|
+
tableFullColumn.forEach((column) => {
|
|
1020
|
+
const field = column.field;
|
|
1021
|
+
const title = $xeTable.getHeaderCellLabel(column);
|
|
1022
|
+
if (field) {
|
|
1023
|
+
tableFieldMaps[field] = column;
|
|
1024
|
+
}
|
|
1025
|
+
if (title) {
|
|
1026
|
+
tableTitleMaps[title] = column;
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
const tableConf = {
|
|
1030
|
+
fieldMaps: tableFieldMaps,
|
|
1031
|
+
titleMaps: tableTitleMaps
|
|
1032
|
+
};
|
|
1033
|
+
switch (opts.type) {
|
|
1034
|
+
case "csv":
|
|
1035
|
+
rest = parseCsv(tableConf, content);
|
|
1036
|
+
break;
|
|
1037
|
+
case "txt":
|
|
1038
|
+
rest = parseTxt(tableConf, content);
|
|
1039
|
+
break;
|
|
1040
|
+
case "html":
|
|
1041
|
+
rest = parseHTML(tableConf, content);
|
|
1042
|
+
break;
|
|
1043
|
+
case "xml":
|
|
1044
|
+
rest = parseXML(tableConf, content);
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
const { fields, rows } = rest;
|
|
1048
|
+
const status = fields.some((field) => tableFieldMaps[field] || tableTitleMaps[field]);
|
|
1049
|
+
if (status) {
|
|
1050
|
+
$xeTable.createData(rows).then((data) => {
|
|
1051
|
+
let loadRest;
|
|
1052
|
+
if (opts.mode === "insert" || opts.mode === "insertBottom") {
|
|
1053
|
+
loadRest = $xeTable.insertAt(data, -1);
|
|
1054
|
+
} else if (opts.mode === "insertTop") {
|
|
1055
|
+
loadRest = $xeTable.insert(data);
|
|
1056
|
+
} else {
|
|
1057
|
+
loadRest = $xeTable.reloadData(data);
|
|
1058
|
+
}
|
|
1059
|
+
if (opts.message !== false) {
|
|
1060
|
+
if (VxeUI.modal) {
|
|
1061
|
+
VxeUI.modal.message({ content: getI18n("vxe.table.impSuccess", [rows.length]), status: "success" });
|
|
886
1062
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
tables.push('<tfoot>');
|
|
892
|
-
footers.forEach((row, rIndex) => {
|
|
893
|
-
tables.push(`<tr>${columns.map((column) => {
|
|
894
|
-
const footAlign = column.footerAlign || column.align || allFooterAlign || allAlign;
|
|
895
|
-
const classNames = hasEllipsis(column, 'showOverflow', allColumnOverflow) ? ['col--ellipsis'] : [];
|
|
896
|
-
const cellValue = getFooterCellValue(opts, row, column);
|
|
897
|
-
let rowSpan = 1;
|
|
898
|
-
let colSpan = 1;
|
|
899
|
-
if (isMerge) {
|
|
900
|
-
const _rowIndex = rIndex;
|
|
901
|
-
const _columnIndex = $xeTable.getVTColumnIndex(column);
|
|
902
|
-
const spanRest = mergeFooterCellMaps[`${_rowIndex}:${_columnIndex}`];
|
|
903
|
-
if (spanRest) {
|
|
904
|
-
const { rowspan, colspan } = spanRest;
|
|
905
|
-
if (!rowspan || !colspan) {
|
|
906
|
-
return '';
|
|
907
|
-
}
|
|
908
|
-
if (rowspan > 1) {
|
|
909
|
-
rowSpan = rowspan;
|
|
910
|
-
}
|
|
911
|
-
if (colspan > 1) {
|
|
912
|
-
colSpan = colspan;
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
if (footAlign) {
|
|
917
|
-
classNames.push(`col--${footAlign}`);
|
|
918
|
-
}
|
|
919
|
-
return `<td class="${classNames.join(' ')}" rowspan="${rowSpan}" colspan="${colSpan}" title="${cellValue}"><div style="${getCellWidthStyle(column)}">${formatText(cellValue, true)}</div></td>`;
|
|
920
|
-
}).join('')}</tr>`);
|
|
921
|
-
});
|
|
922
|
-
tables.push('</tfoot>');
|
|
923
|
-
}
|
|
1063
|
+
}
|
|
1064
|
+
return loadRest.then(() => {
|
|
1065
|
+
if (_importResolve) {
|
|
1066
|
+
_importResolve({ status: true });
|
|
924
1067
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
} else if (opts.message !== false) {
|
|
1071
|
+
if (VxeUI.modal) {
|
|
1072
|
+
VxeUI.modal.message({ content: getI18n("vxe.error.impFields"), status: "error" });
|
|
1073
|
+
}
|
|
1074
|
+
if (_importReject) {
|
|
1075
|
+
_importReject({ status: false, msg: "field mismatching" });
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
const handleFileImport = (file, opts) => {
|
|
1080
|
+
const { importMethod, afterImportMethod } = opts;
|
|
1081
|
+
const { type, filename } = parseFile(file);
|
|
1082
|
+
const importOpts = computeImportOpts.value;
|
|
1083
|
+
if (!importMethod && !XEUtils.includes(XEUtils.keys(importOpts._typeMaps), type)) {
|
|
1084
|
+
if (opts.message !== false) {
|
|
1085
|
+
if (VxeUI.modal) {
|
|
1086
|
+
VxeUI.modal.message({ content: getI18n("vxe.error.notType", [type]), status: "error" });
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
const params = { status: false, msg: "type error" };
|
|
1090
|
+
return Promise.reject(params);
|
|
1091
|
+
}
|
|
1092
|
+
const rest = new Promise((resolve, reject) => {
|
|
1093
|
+
const _importResolve = (params) => {
|
|
1094
|
+
resolve(params);
|
|
1095
|
+
internalData._importResolve = null;
|
|
1096
|
+
internalData._importReject = null;
|
|
1097
|
+
};
|
|
1098
|
+
const _importReject = (params) => {
|
|
1099
|
+
reject(params);
|
|
1100
|
+
internalData._importResolve = null;
|
|
1101
|
+
internalData._importReject = null;
|
|
929
1102
|
};
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
'<ProtectStructure>False</ProtectStructure>',
|
|
944
|
-
'<ProtectWindows>False</ProtectWindows>',
|
|
945
|
-
'</ExcelWorkbook>',
|
|
946
|
-
`<Worksheet ss:Name="${opts.sheetName}">`,
|
|
947
|
-
'<Table>',
|
|
948
|
-
columns.map((column) => `<Column ss:Width="${column.renderWidth}"/>`).join('')
|
|
949
|
-
].join('');
|
|
950
|
-
if (opts.isHeader) {
|
|
951
|
-
xml += `<Row>${columns.map((column) => `<Cell><Data ss:Type="String">${getHeaderTitle(opts, column)}</Data></Cell>`).join('')}</Row>`;
|
|
1103
|
+
internalData._importResolve = _importResolve;
|
|
1104
|
+
internalData._importReject = _importReject;
|
|
1105
|
+
if (window.FileReader) {
|
|
1106
|
+
const options = Object.assign({ mode: "insertTop" }, opts, { type, filename });
|
|
1107
|
+
if (options.remote) {
|
|
1108
|
+
if (importMethod) {
|
|
1109
|
+
Promise.resolve(importMethod({ file, options, $table: $xeTable })).then(() => {
|
|
1110
|
+
_importResolve({ status: true });
|
|
1111
|
+
}).catch(() => {
|
|
1112
|
+
_importResolve({ status: true });
|
|
1113
|
+
});
|
|
1114
|
+
} else {
|
|
1115
|
+
_importResolve({ status: true });
|
|
952
1116
|
}
|
|
953
|
-
|
|
954
|
-
|
|
1117
|
+
} else {
|
|
1118
|
+
const { tableFullColumn } = internalData;
|
|
1119
|
+
$xeTable.preventEvent(null, "event.import", { file, options, columns: tableFullColumn }, () => {
|
|
1120
|
+
const reader = new FileReader();
|
|
1121
|
+
reader.onerror = () => {
|
|
1122
|
+
errLog("vxe.error.notType", [type]);
|
|
1123
|
+
_importReject({ status: false, msg: "reading file error" });
|
|
1124
|
+
};
|
|
1125
|
+
reader.onload = (e) => {
|
|
1126
|
+
handleImport(e.target.result, options);
|
|
1127
|
+
};
|
|
1128
|
+
reader.readAsText(file, options.encoding || "UTF-8");
|
|
955
1129
|
});
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1130
|
+
}
|
|
1131
|
+
} else {
|
|
1132
|
+
errLog("vxe.error.notExp");
|
|
1133
|
+
_importResolve({ status: false, msg: "unsupported browser" });
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
return rest.then(() => {
|
|
1137
|
+
if (afterImportMethod) {
|
|
1138
|
+
afterImportMethod({ status: true, options: opts, $table: $xeTable });
|
|
1139
|
+
}
|
|
1140
|
+
}).catch((e) => {
|
|
1141
|
+
if (afterImportMethod) {
|
|
1142
|
+
afterImportMethod({ status: false, options: opts, $table: $xeTable });
|
|
1143
|
+
}
|
|
1144
|
+
return Promise.reject(e);
|
|
1145
|
+
});
|
|
1146
|
+
};
|
|
1147
|
+
const handleFilterColumns = (exportOpts, column, columns) => {
|
|
1148
|
+
return columns.some((item) => {
|
|
1149
|
+
if (isColumnInfo(item)) {
|
|
1150
|
+
return column.id === item.id;
|
|
1151
|
+
} else if (XEUtils.isString(item)) {
|
|
1152
|
+
return column.field === item;
|
|
1153
|
+
} else {
|
|
1154
|
+
const colid = item.id || item.colId;
|
|
1155
|
+
const type = item.type;
|
|
1156
|
+
const field = item.field;
|
|
1157
|
+
if (colid) {
|
|
1158
|
+
return column.id === colid;
|
|
1159
|
+
} else if (field && type) {
|
|
1160
|
+
return column.field === field && column.type === type;
|
|
1161
|
+
} else if (field) {
|
|
1162
|
+
return column.field === field;
|
|
1163
|
+
} else if (type) {
|
|
1164
|
+
return column.type === type;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return false;
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
const handleFilterFields = (exportOpts, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps) => {
|
|
1171
|
+
const { field } = column;
|
|
1172
|
+
if (excludeFdMaps[field]) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
if (includeFields) {
|
|
1176
|
+
if (includeFdMaps[field]) {
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
return false;
|
|
1180
|
+
}
|
|
1181
|
+
if (extraFdMaps[field]) {
|
|
1182
|
+
return true;
|
|
1183
|
+
}
|
|
1184
|
+
return exportOpts.original ? !!field : defaultFilterExportColumn(column);
|
|
1185
|
+
};
|
|
1186
|
+
const handleExportAndPrint = (options, isPrint) => {
|
|
1187
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
1188
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
1189
|
+
const $xeGGWrapper = $xeGrid || $xeGantt;
|
|
1190
|
+
const { treeConfig, showHeader, showFooter } = props;
|
|
1191
|
+
const { initStore, isGroup, rowGroupList, footerTableData, exportStore, exportParams } = reactData;
|
|
1192
|
+
const { collectColumn, mergeBodyList, mergeFooterList } = internalData;
|
|
1193
|
+
const exportOpts = computeExportOpts.value;
|
|
1194
|
+
const printOpts = computePrintOpts.value;
|
|
1195
|
+
const hasTree = !!treeConfig;
|
|
1196
|
+
const hasRowGroup = rowGroupList.length > 0;
|
|
1197
|
+
const selectRecords = $xeTable.getCheckboxRecords();
|
|
1198
|
+
const proxyOpts = $xeGGWrapper ? $xeGGWrapper.getComputeMaps().computeProxyOpts.value : {};
|
|
1199
|
+
const hasFooter = !!footerTableData.length;
|
|
1200
|
+
const hasMerge = !!(mergeBodyList.length || mergeFooterList.length);
|
|
1201
|
+
const defOpts = Object.assign({
|
|
1202
|
+
message: true,
|
|
1203
|
+
isHeader: showHeader,
|
|
1204
|
+
isTitle: showHeader,
|
|
1205
|
+
isFooter: showFooter,
|
|
1206
|
+
isColgroup: isGroup,
|
|
1207
|
+
isMerge: hasMerge,
|
|
1208
|
+
useStyle: true,
|
|
1209
|
+
current: "current",
|
|
1210
|
+
modes: (proxyOpts.ajax && proxyOpts.ajax.queryAll ? ["all"] : []).concat(["current", "selected", "empty"])
|
|
1211
|
+
}, options);
|
|
1212
|
+
if (XEUtils.isBoolean(defOpts.isAllExpand)) {
|
|
1213
|
+
warnLog("vxe.error.delProp", ["isAllExpand", "isTreeAllExpanded"]);
|
|
1214
|
+
defOpts.isTreeAllExpanded = defOpts.isAllExpand;
|
|
1215
|
+
}
|
|
1216
|
+
const types = isPrint ? [] : defOpts.types || XEUtils.keys(exportOpts._typeMaps);
|
|
1217
|
+
const modes = defOpts.modes || [];
|
|
1218
|
+
const checkMethod = (isPrint ? printOpts : exportOpts).checkMethod;
|
|
1219
|
+
const exportColumns = collectColumn.slice(0);
|
|
1220
|
+
const { columns, excludeFields, includeFields, extraFields } = defOpts;
|
|
1221
|
+
const typeList = types.map((value) => {
|
|
1222
|
+
return {
|
|
1223
|
+
value,
|
|
1224
|
+
label: getI18n(`vxe.export.types.${value}`)
|
|
964
1225
|
};
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
return '';
|
|
1226
|
+
});
|
|
1227
|
+
const modeList = modes.map((item) => {
|
|
1228
|
+
if (item && item.value) {
|
|
1229
|
+
return {
|
|
1230
|
+
value: item.value,
|
|
1231
|
+
label: item.label || item.value
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
return {
|
|
1235
|
+
value: item,
|
|
1236
|
+
label: getI18n(`vxe.export.modes.${item}`)
|
|
979
1237
|
};
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1238
|
+
});
|
|
1239
|
+
const excludeFdMaps = {};
|
|
1240
|
+
if (excludeFields && excludeFields.length) {
|
|
1241
|
+
excludeFields.forEach((field) => {
|
|
1242
|
+
excludeFdMaps[field] = 1;
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
const includeFdMaps = {};
|
|
1246
|
+
if (includeFields && includeFields.length) {
|
|
1247
|
+
includeFields.forEach((field) => {
|
|
1248
|
+
includeFdMaps[field] = 1;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
const extraFdMaps = {};
|
|
1252
|
+
if (extraFields) {
|
|
1253
|
+
extraFields.forEach((field) => {
|
|
1254
|
+
extraFdMaps[field] = 1;
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
XEUtils.eachTree(exportColumns, (column, index, items, path, parentColumn) => {
|
|
1258
|
+
const isColGroup = column.children && column.children.length > 0;
|
|
1259
|
+
let isChecked = false;
|
|
1260
|
+
const isExtraChecked = extraFdMaps[column.field];
|
|
1261
|
+
if (columns) {
|
|
1262
|
+
isChecked = handleFilterColumns(defOpts, column, columns);
|
|
1263
|
+
} else if (excludeFields || includeFields) {
|
|
1264
|
+
isChecked = handleFilterFields(defOpts, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps);
|
|
1265
|
+
} else {
|
|
1266
|
+
if (isExtraChecked) {
|
|
1267
|
+
isChecked = true;
|
|
1268
|
+
} else {
|
|
1269
|
+
isChecked = column.visible && (isColGroup || defaultFilterExportColumn(column));
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
column.checked = isChecked;
|
|
1273
|
+
column.halfChecked = false;
|
|
1274
|
+
column.disabled = parentColumn && parentColumn.disabled || (checkMethod ? !checkMethod({ $table: $xeTable, column }) : false);
|
|
1275
|
+
});
|
|
1276
|
+
exportStore.columns = exportColumns;
|
|
1277
|
+
exportStore.typeList = typeList;
|
|
1278
|
+
exportStore.modeList = modeList;
|
|
1279
|
+
exportStore.hasFooter = hasFooter;
|
|
1280
|
+
exportStore.hasMerge = hasMerge;
|
|
1281
|
+
exportStore.hasTree = hasTree;
|
|
1282
|
+
exportStore.hasRowGroup = hasRowGroup;
|
|
1283
|
+
exportStore.isPrint = !!isPrint;
|
|
1284
|
+
exportStore.hasColgroup = isGroup;
|
|
1285
|
+
exportStore.visible = true;
|
|
1286
|
+
Object.assign(exportParams, {
|
|
1287
|
+
mode: selectRecords.length ? "selected" : "current"
|
|
1288
|
+
}, defOpts);
|
|
1289
|
+
const { filename, sheetName, mode, type } = exportParams;
|
|
1290
|
+
if (filename) {
|
|
1291
|
+
if (XEUtils.isFunction(filename)) {
|
|
1292
|
+
exportParams.filename = filename({
|
|
1293
|
+
options: defOpts,
|
|
1294
|
+
$table: $xeTable,
|
|
1295
|
+
$grid: $xeGrid,
|
|
1296
|
+
$gantt: $xeGantt
|
|
1297
|
+
});
|
|
1298
|
+
} else {
|
|
1299
|
+
exportParams.filename = `${filename}`;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
if (sheetName) {
|
|
1303
|
+
if (XEUtils.isFunction(sheetName)) {
|
|
1304
|
+
exportParams.sheetName = sheetName({
|
|
1305
|
+
options: defOpts,
|
|
1306
|
+
$table: $xeTable,
|
|
1307
|
+
$grid: $xeGrid,
|
|
1308
|
+
$gantt: $xeGantt
|
|
1309
|
+
});
|
|
1310
|
+
} else {
|
|
1311
|
+
exportParams.sheetName = `${sheetName}`;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
if (!modeList.some((item) => item.value === mode)) {
|
|
1315
|
+
exportParams.mode = modeList.length ? modeList[0].value : "";
|
|
1316
|
+
}
|
|
1317
|
+
if (!typeList.some((item) => item.value === type)) {
|
|
1318
|
+
exportParams.type = typeList.length ? typeList[0].value : "";
|
|
1319
|
+
}
|
|
1320
|
+
if (!exportParams.widthMode) {
|
|
1321
|
+
exportParams.widthMode = "";
|
|
1322
|
+
}
|
|
1323
|
+
initStore.export = true;
|
|
1324
|
+
return nextTick();
|
|
1325
|
+
};
|
|
1326
|
+
const handleCloseExport = () => {
|
|
1327
|
+
if (VxeUI.modal) {
|
|
1328
|
+
return VxeUI.modal.close("VXE_EXPORT_MODAL");
|
|
1329
|
+
}
|
|
1330
|
+
return Promise.resolve();
|
|
1331
|
+
};
|
|
1332
|
+
const exportMethods = {
|
|
1333
|
+
/**
|
|
1334
|
+
* 导出文件,支持 csv/html/xml/txt
|
|
1335
|
+
* 如果是树表格,则默认是导出所有节点
|
|
1336
|
+
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数转换数据
|
|
1337
|
+
* @param {Object} options 参数
|
|
1338
|
+
*/
|
|
1339
|
+
exportData(options) {
|
|
1340
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
1341
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
1342
|
+
const $xeGGWrapper = $xeGrid || $xeGantt;
|
|
1343
|
+
const { treeConfig, showHeader, showFooter } = props;
|
|
1344
|
+
const { isGroup } = reactData;
|
|
1345
|
+
const { tableFullColumn, afterFullData, afterTreeFullData, collectColumn, mergeBodyList, mergeFooterList } = internalData;
|
|
1346
|
+
const exportOpts = computeExportOpts.value;
|
|
1347
|
+
const treeOpts = computeTreeOpts.value;
|
|
1348
|
+
const proxyOpts = $xeGGWrapper ? $xeGGWrapper.getComputeMaps().computeProxyOpts.value : {};
|
|
1349
|
+
const hasMerge = !!(mergeBodyList.length || mergeFooterList.length);
|
|
1350
|
+
const opts = Object.assign({
|
|
1351
|
+
message: true,
|
|
1352
|
+
isHeader: showHeader,
|
|
1353
|
+
isTitle: showHeader,
|
|
1354
|
+
isFooter: showFooter,
|
|
1355
|
+
isColgroup: isGroup,
|
|
1356
|
+
isMerge: hasMerge,
|
|
1357
|
+
useStyle: true,
|
|
1358
|
+
current: "current",
|
|
1359
|
+
modes: (proxyOpts.ajax && proxyOpts.ajax.queryAll ? ["all"] : []).concat(["current", "selected", "empty"]),
|
|
1360
|
+
download: true,
|
|
1361
|
+
type: "csv"
|
|
1362
|
+
// filename: '',
|
|
1363
|
+
// sheetName: '',
|
|
1364
|
+
// original: false,
|
|
1365
|
+
// isTreeAllExpanded: false,
|
|
1366
|
+
// isRowGroupAllExpanded: false,
|
|
1367
|
+
// data: null,
|
|
1368
|
+
// remote: false,
|
|
1369
|
+
// dataFilterMethod: null,
|
|
1370
|
+
// footerFilterMethod: null,
|
|
1371
|
+
// exportMethod: null,
|
|
1372
|
+
// columnFilterMethod: null,
|
|
1373
|
+
// beforeExportMethod: null,
|
|
1374
|
+
// afterExportMethod: null
|
|
1375
|
+
}, exportOpts, options);
|
|
1376
|
+
if (XEUtils.isBoolean(opts.isAllExpand)) {
|
|
1377
|
+
warnLog("vxe.error.delProp", ["isAllExpand", "isTreeAllExpanded"]);
|
|
1378
|
+
opts.isTreeAllExpanded = opts.isAllExpand;
|
|
1379
|
+
}
|
|
1380
|
+
let { filename, sheetName, type, mode, columns, columnFilterMethod, beforeExportMethod, includeFields, excludeFields, extraFields } = opts;
|
|
1381
|
+
let groups = [];
|
|
1382
|
+
const selectRecords = $xeTable.getCheckboxRecords();
|
|
1383
|
+
if (!mode) {
|
|
1384
|
+
mode = selectRecords.length ? "selected" : "current";
|
|
1385
|
+
}
|
|
1386
|
+
const excludeFdMaps = {};
|
|
1387
|
+
if (excludeFields && excludeFields.length) {
|
|
1388
|
+
excludeFields.forEach((field) => {
|
|
1389
|
+
excludeFdMaps[field] = 1;
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
const includeFdMaps = {};
|
|
1393
|
+
if (includeFields && includeFields.length) {
|
|
1394
|
+
includeFields.forEach((field) => {
|
|
1395
|
+
includeFdMaps[field] = 1;
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
const extraFdMaps = {};
|
|
1399
|
+
if (extraFields) {
|
|
1400
|
+
extraFields.forEach((field) => {
|
|
1401
|
+
extraFdMaps[field] = 1;
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
let isCustomCol = false;
|
|
1405
|
+
let customCols = [];
|
|
1406
|
+
const _columns = opts._columns;
|
|
1407
|
+
if (_columns) {
|
|
1408
|
+
isCustomCol = true;
|
|
1409
|
+
customCols = XEUtils.searchTree(_columns, () => true, { children: "_children", mapChildren: "childNodes", original: true });
|
|
1410
|
+
} else if (columns) {
|
|
1411
|
+
isCustomCol = true;
|
|
1412
|
+
customCols = XEUtils.searchTree(columns, () => true, { children: "children", mapChildren: "childNodes", original: true });
|
|
1413
|
+
} else {
|
|
1414
|
+
customCols = XEUtils.searchTree(collectColumn, (column) => {
|
|
1415
|
+
const isColGroup = column.children && column.children.length > 0;
|
|
1416
|
+
let isChecked = false;
|
|
1417
|
+
const isExtraChecked = extraFdMaps[column.field];
|
|
1418
|
+
if (columns) {
|
|
1419
|
+
isChecked = handleFilterColumns(opts, column, columns);
|
|
1420
|
+
} else if (excludeFields || includeFields) {
|
|
1421
|
+
isChecked = handleFilterFields(opts, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps);
|
|
1422
|
+
} else {
|
|
1423
|
+
if (isExtraChecked) {
|
|
1424
|
+
isChecked = true;
|
|
1425
|
+
} else {
|
|
1426
|
+
isChecked = column.visible && (isColGroup || defaultFilterExportColumn(column));
|
|
1427
|
+
}
|
|
985
1428
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1429
|
+
return isChecked;
|
|
1430
|
+
}, { children: "children", mapChildren: "childNodes", original: true });
|
|
1431
|
+
}
|
|
1432
|
+
const handleOptions = Object.assign({}, opts, { filename: "", sheetName: "", _columnConfs: columns });
|
|
1433
|
+
if (!isCustomCol && !columnFilterMethod) {
|
|
1434
|
+
columnFilterMethod = ({ column }) => handleFilterFields(handleOptions, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps);
|
|
1435
|
+
handleOptions.columnFilterMethod = columnFilterMethod;
|
|
1436
|
+
}
|
|
1437
|
+
if (customCols) {
|
|
1438
|
+
handleOptions._isCustomColumn = true;
|
|
1439
|
+
groups = XEUtils.searchTree(
|
|
1440
|
+
XEUtils.mapTree(customCols, (item) => {
|
|
1441
|
+
let targetColumn;
|
|
1442
|
+
if (item) {
|
|
1443
|
+
if (isColumnInfo(item)) {
|
|
1444
|
+
targetColumn = item;
|
|
1445
|
+
} else if (XEUtils.isString(item)) {
|
|
1446
|
+
targetColumn = $xeTable.getColumnByField(item);
|
|
1447
|
+
} else {
|
|
1448
|
+
const colid = item.id || item.colId;
|
|
1449
|
+
const type2 = item.type;
|
|
1450
|
+
const field = item.field;
|
|
1451
|
+
if (colid) {
|
|
1452
|
+
targetColumn = $xeTable.getColumnById(colid);
|
|
1453
|
+
} else if (field && type2) {
|
|
1454
|
+
targetColumn = tableFullColumn.find((column) => column.field === field && column.type === type2);
|
|
1455
|
+
} else if (field) {
|
|
1456
|
+
targetColumn = $xeTable.getColumnByField(field);
|
|
1457
|
+
} else if (type2) {
|
|
1458
|
+
targetColumn = tableFullColumn.find((column) => column.type === type2);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
return targetColumn || {};
|
|
1462
|
+
}
|
|
1463
|
+
}, {
|
|
1464
|
+
children: "childNodes",
|
|
1465
|
+
mapChildren: "_children"
|
|
1466
|
+
}),
|
|
1467
|
+
(column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, column, $columnIndex: index })),
|
|
1468
|
+
{
|
|
1469
|
+
children: "_children",
|
|
1470
|
+
mapChildren: "childNodes",
|
|
1471
|
+
original: true
|
|
994
1472
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
afterExportMethod({ status: true, options: opts, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
return Object.assign({ status: true }, params);
|
|
1019
|
-
}).catch(() => {
|
|
1020
|
-
clearColumnConvert(columns);
|
|
1021
|
-
if (!opts.print) {
|
|
1022
|
-
if (afterExportMethod) {
|
|
1023
|
-
afterExportMethod({ status: false, options: opts, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
const params = { status: false };
|
|
1027
|
-
return Promise.reject(params);
|
|
1473
|
+
);
|
|
1474
|
+
} else {
|
|
1475
|
+
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, column, $columnIndex: index })), { children: "children", mapChildren: "childNodes", original: true });
|
|
1476
|
+
}
|
|
1477
|
+
const cols = [];
|
|
1478
|
+
XEUtils.eachTree(groups, (column) => {
|
|
1479
|
+
const isColGroup = column.children && column.children.length;
|
|
1480
|
+
if (!isColGroup) {
|
|
1481
|
+
cols.push(column);
|
|
1482
|
+
}
|
|
1483
|
+
}, { children: "childNodes" });
|
|
1484
|
+
handleOptions.columns = cols;
|
|
1485
|
+
handleOptions.colgroups = convertToRows(groups);
|
|
1486
|
+
if (filename) {
|
|
1487
|
+
if (XEUtils.isFunction(filename)) {
|
|
1488
|
+
handleOptions.filename = filename({
|
|
1489
|
+
options: opts,
|
|
1490
|
+
$table: $xeTable,
|
|
1491
|
+
$grid: $xeGrid,
|
|
1492
|
+
$gantt: $xeGantt
|
|
1028
1493
|
});
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1494
|
+
} else {
|
|
1495
|
+
handleOptions.filename = `${filename}`;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
if (!handleOptions.filename) {
|
|
1499
|
+
handleOptions.filename = getI18n(handleOptions.original ? "vxe.table.expOriginFilename" : "vxe.table.expFilename", [XEUtils.toDateString(Date.now(), "yyyyMMddHHmmss")]);
|
|
1500
|
+
}
|
|
1501
|
+
if (sheetName) {
|
|
1502
|
+
if (XEUtils.isFunction(sheetName)) {
|
|
1503
|
+
handleOptions.sheetName = sheetName({
|
|
1504
|
+
options: opts,
|
|
1505
|
+
$table: $xeTable,
|
|
1506
|
+
$grid: $xeGrid,
|
|
1507
|
+
$gantt: $xeGantt
|
|
1044
1508
|
});
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
loadRest = $xeTable.insertAt(data, -1);
|
|
1071
|
-
}
|
|
1072
|
-
else if (opts.mode === 'insertTop') {
|
|
1073
|
-
loadRest = $xeTable.insert(data);
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
loadRest = $xeTable.reloadData(data);
|
|
1077
|
-
}
|
|
1078
|
-
if (opts.message !== false) {
|
|
1079
|
-
if (VxeUI.modal) {
|
|
1080
|
-
VxeUI.modal.message({ content: getI18n('vxe.table.impSuccess', [rows.length]), status: 'success' });
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
return loadRest.then(() => {
|
|
1084
|
-
if (_importResolve) {
|
|
1085
|
-
_importResolve({ status: true });
|
|
1086
|
-
}
|
|
1087
|
-
});
|
|
1088
|
-
});
|
|
1509
|
+
} else {
|
|
1510
|
+
handleOptions.sheetName = `${sheetName}`;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
if (!handleOptions.sheetName) {
|
|
1514
|
+
handleOptions.sheetName = document.title || "";
|
|
1515
|
+
}
|
|
1516
|
+
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
|
|
1517
|
+
errLog("vxe.error.notType", [type]);
|
|
1518
|
+
if (["xlsx", "pdf"].includes(type)) {
|
|
1519
|
+
warnLog("vxe.error.reqPlugin", [4, "plugin-export-xlsx"]);
|
|
1520
|
+
}
|
|
1521
|
+
const params = { status: false, msg: "type error" };
|
|
1522
|
+
return Promise.reject(params);
|
|
1523
|
+
}
|
|
1524
|
+
if (!handleOptions.print) {
|
|
1525
|
+
if (beforeExportMethod) {
|
|
1526
|
+
const beRest = beforeExportMethod({ options: handleOptions, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1527
|
+
if (XEUtils.isBoolean(beRest)) {
|
|
1528
|
+
if (!beRest) {
|
|
1529
|
+
const params = { status: false, msg: "before prevent" };
|
|
1530
|
+
return Promise.reject(params);
|
|
1531
|
+
}
|
|
1532
|
+
} else {
|
|
1533
|
+
warnLog("vxe.error.returnErr", ["beforeExportMethod", "boolean", beRest]);
|
|
1089
1534
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
if (!handleOptions.data) {
|
|
1538
|
+
handleOptions.data = [];
|
|
1539
|
+
if (mode === "selected") {
|
|
1540
|
+
if (["html", "pdf"].indexOf(type) > -1 && treeConfig) {
|
|
1541
|
+
handleOptions.data = XEUtils.searchTree($xeTable.getTableData().fullData, (item) => $xeTable.findRowIndexOf(selectRecords, item) > -1, Object.assign({}, treeOpts, { data: "_row" }));
|
|
1542
|
+
} else {
|
|
1543
|
+
handleOptions.data = selectRecords;
|
|
1097
1544
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
const { type, filename } = parseFile(file);
|
|
1102
|
-
const importOpts = computeImportOpts.value;
|
|
1103
|
-
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1104
|
-
if (!importMethod && !XEUtils.includes(XEUtils.keys(importOpts._typeMaps), type)) {
|
|
1105
|
-
if (opts.message !== false) {
|
|
1106
|
-
if (VxeUI.modal) {
|
|
1107
|
-
VxeUI.modal.message({ content: getI18n('vxe.error.notType', [type]), status: 'error' });
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
const params = { status: false, msg: 'type error' };
|
|
1111
|
-
return Promise.reject(params);
|
|
1545
|
+
} else if (mode === "all") {
|
|
1546
|
+
if (!$xeGGWrapper) {
|
|
1547
|
+
errLog("vxe.error.errProp", ["all", "mode=current,selected"]);
|
|
1112
1548
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1549
|
+
if ($xeGGWrapper && !handleOptions.remote) {
|
|
1550
|
+
const gridReactData = $xeGGWrapper.reactData;
|
|
1551
|
+
const { computeProxyOpts } = $xeGGWrapper.getComputeMaps();
|
|
1552
|
+
const proxyOpts2 = computeProxyOpts.value;
|
|
1553
|
+
const { sortData } = gridReactData;
|
|
1554
|
+
const { beforeQueryAll: oldBeforeQueryAll, afterQueryAll: oldAfterQueryAll, ajax = {} } = proxyOpts2;
|
|
1555
|
+
const resConfigs = proxyOpts2.response || proxyOpts2.props || {};
|
|
1556
|
+
const beforeQueryAllMethod = ajax.beforeQueryAll;
|
|
1557
|
+
const queryAllMethod = ajax.queryAll;
|
|
1558
|
+
const afterQueryAllMethod = ajax.afterQueryAll;
|
|
1559
|
+
const queryAllSuccessMethod = ajax.queryAllSuccess;
|
|
1560
|
+
const queryAllErrorMethod = ajax.queryAllError;
|
|
1561
|
+
if (!queryAllMethod) {
|
|
1562
|
+
errLog("vxe.error.notFunc", ["proxy-config.ajax.queryAll"]);
|
|
1563
|
+
}
|
|
1564
|
+
if (queryAllMethod) {
|
|
1565
|
+
const params = {
|
|
1566
|
+
$table: $xeTable,
|
|
1567
|
+
$grid: $xeGrid,
|
|
1568
|
+
$gantt: $xeGantt,
|
|
1569
|
+
sort: sortData.length ? sortData[0] : {},
|
|
1570
|
+
sorts: sortData,
|
|
1571
|
+
filters: gridReactData.filterData,
|
|
1572
|
+
form: gridReactData.formData,
|
|
1573
|
+
options: handleOptions
|
|
1118
1574
|
};
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
_importResolve({ status: true });
|
|
1132
|
-
}).catch(() => {
|
|
1133
|
-
_importResolve({ status: true });
|
|
1134
|
-
});
|
|
1575
|
+
const handleQueryAll = () => {
|
|
1576
|
+
return Promise.resolve((oldBeforeQueryAll || queryAllMethod)(params)).then((rest) => {
|
|
1577
|
+
if (afterQueryAllMethod) {
|
|
1578
|
+
afterQueryAllMethod({ ...params, response: rest, status: "success" });
|
|
1579
|
+
} else {
|
|
1580
|
+
const listProp = resConfigs.list;
|
|
1581
|
+
let tdData = [];
|
|
1582
|
+
if (listProp) {
|
|
1583
|
+
if (XEUtils.isFunction(listProp)) {
|
|
1584
|
+
tdData = listProp({ data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1585
|
+
} else {
|
|
1586
|
+
tdData = XEUtils.isArray(rest) ? rest : XEUtils.get(rest, listProp);
|
|
1135
1587
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1588
|
+
} else {
|
|
1589
|
+
if (XEUtils.isArray(rest)) {
|
|
1590
|
+
tdData = rest;
|
|
1138
1591
|
}
|
|
1592
|
+
}
|
|
1593
|
+
handleOptions.data = tdData;
|
|
1594
|
+
if (oldAfterQueryAll) {
|
|
1595
|
+
oldAfterQueryAll({ ...params, response: rest });
|
|
1596
|
+
}
|
|
1139
1597
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
$xeTable.preventEvent(null, 'event.import', { file, options, columns: tableFullColumn }, () => {
|
|
1143
|
-
const reader = new FileReader();
|
|
1144
|
-
reader.onerror = () => {
|
|
1145
|
-
errLog('vxe.error.notType', [type]);
|
|
1146
|
-
_importReject({ status: false, msg: 'reading file error' });
|
|
1147
|
-
};
|
|
1148
|
-
reader.onload = (e) => {
|
|
1149
|
-
handleImport(e.target.result, options);
|
|
1150
|
-
};
|
|
1151
|
-
reader.readAsText(file, options.encoding || 'UTF-8');
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
else {
|
|
1156
|
-
// 不支持的浏览器
|
|
1157
|
-
errLog('vxe.error.notExp');
|
|
1158
|
-
_importResolve({ status: false, msg: 'unsupported browser' });
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
return rest.then(() => {
|
|
1162
|
-
if (afterImportMethod) {
|
|
1163
|
-
afterImportMethod({ status: true, options: opts, $table: $xeTable });
|
|
1164
|
-
}
|
|
1165
|
-
}).catch((e) => {
|
|
1166
|
-
if (afterImportMethod) {
|
|
1167
|
-
afterImportMethod({ status: false, options: opts, $table: $xeTable });
|
|
1168
|
-
}
|
|
1169
|
-
return Promise.reject(e);
|
|
1170
|
-
});
|
|
1171
|
-
};
|
|
1172
|
-
const handleFilterColumns = (exportOpts, column, columns) => {
|
|
1173
|
-
return columns.some((item) => {
|
|
1174
|
-
if (isColumnInfo(item)) {
|
|
1175
|
-
return column.id === item.id;
|
|
1176
|
-
}
|
|
1177
|
-
else if (XEUtils.isString(item)) {
|
|
1178
|
-
return column.field === item;
|
|
1179
|
-
}
|
|
1180
|
-
else {
|
|
1181
|
-
const colid = item.id || item.colId;
|
|
1182
|
-
const type = item.type;
|
|
1183
|
-
const field = item.field;
|
|
1184
|
-
if (colid) {
|
|
1185
|
-
return column.id === colid;
|
|
1186
|
-
}
|
|
1187
|
-
else if (field && type) {
|
|
1188
|
-
return column.field === field && column.type === type;
|
|
1598
|
+
if (queryAllSuccessMethod) {
|
|
1599
|
+
queryAllSuccessMethod({ ...params, response: rest });
|
|
1189
1600
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1601
|
+
return handleExport(handleOptions);
|
|
1602
|
+
}).catch((rest) => {
|
|
1603
|
+
if (afterQueryAllMethod) {
|
|
1604
|
+
afterQueryAllMethod({ ...params, response: rest, status: "error" });
|
|
1192
1605
|
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1606
|
+
if (queryAllErrorMethod) {
|
|
1607
|
+
queryAllErrorMethod({ ...params, response: rest });
|
|
1195
1608
|
}
|
|
1196
|
-
|
|
1197
|
-
return false;
|
|
1198
|
-
});
|
|
1199
|
-
};
|
|
1200
|
-
const handleFilterFields = (exportOpts, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps) => {
|
|
1201
|
-
const { field } = column;
|
|
1202
|
-
if (excludeFdMaps[field]) {
|
|
1203
|
-
return false;
|
|
1204
|
-
}
|
|
1205
|
-
if (includeFields) {
|
|
1206
|
-
if (includeFdMaps[field]) {
|
|
1207
|
-
return true;
|
|
1208
|
-
}
|
|
1209
|
-
return false;
|
|
1210
|
-
}
|
|
1211
|
-
if (extraFdMaps[field]) {
|
|
1212
|
-
return true;
|
|
1213
|
-
}
|
|
1214
|
-
return exportOpts.original ? !!field : defaultFilterExportColumn(column);
|
|
1215
|
-
};
|
|
1216
|
-
const handleExportAndPrint = (options, isPrint) => {
|
|
1217
|
-
const $xeGrid = $xeTable.xeGrid;
|
|
1218
|
-
const $xeGantt = $xeTable.xeGantt;
|
|
1219
|
-
const $xeGGWrapper = $xeGrid || $xeGantt;
|
|
1220
|
-
const { treeConfig, showHeader, showFooter } = props;
|
|
1221
|
-
const { initStore, isGroup, rowGroupList, footerTableData, exportStore, exportParams } = reactData;
|
|
1222
|
-
const { collectColumn, mergeBodyList, mergeFooterList } = internalData;
|
|
1223
|
-
const exportOpts = computeExportOpts.value;
|
|
1224
|
-
const printOpts = computePrintOpts.value;
|
|
1225
|
-
const hasTree = !!treeConfig;
|
|
1226
|
-
const hasRowGroup = rowGroupList.length > 0;
|
|
1227
|
-
const selectRecords = $xeTable.getCheckboxRecords();
|
|
1228
|
-
const proxyOpts = $xeGGWrapper ? $xeGGWrapper.getComputeMaps().computeProxyOpts.value : {};
|
|
1229
|
-
const hasFooter = !!footerTableData.length;
|
|
1230
|
-
const hasMerge = !!(mergeBodyList.length || mergeFooterList.length);
|
|
1231
|
-
const defOpts = Object.assign({
|
|
1232
|
-
message: true,
|
|
1233
|
-
isHeader: showHeader,
|
|
1234
|
-
isTitle: showHeader,
|
|
1235
|
-
isFooter: showFooter,
|
|
1236
|
-
isColgroup: isGroup,
|
|
1237
|
-
isMerge: hasMerge,
|
|
1238
|
-
useStyle: true,
|
|
1239
|
-
current: 'current',
|
|
1240
|
-
modes: (proxyOpts.ajax && proxyOpts.ajax.queryAll ? ['all'] : []).concat(['current', 'selected', 'empty'])
|
|
1241
|
-
}, options);
|
|
1242
|
-
// 已废弃,参数 isAllExpand
|
|
1243
|
-
if (XEUtils.isBoolean(defOpts.isAllExpand)) {
|
|
1244
|
-
warnLog('vxe.error.delProp', ['isAllExpand', 'isTreeAllExpanded']);
|
|
1245
|
-
defOpts.isTreeAllExpanded = defOpts.isAllExpand;
|
|
1246
|
-
}
|
|
1247
|
-
const types = isPrint ? [] : (defOpts.types || XEUtils.keys(exportOpts._typeMaps));
|
|
1248
|
-
const modes = defOpts.modes || [];
|
|
1249
|
-
const checkMethod = (isPrint ? printOpts : exportOpts).checkMethod;
|
|
1250
|
-
const exportColumns = collectColumn.slice(0);
|
|
1251
|
-
const { columns, excludeFields, includeFields, extraFields } = defOpts;
|
|
1252
|
-
// 处理类型
|
|
1253
|
-
const typeList = types.map((value) => {
|
|
1254
|
-
return {
|
|
1255
|
-
value,
|
|
1256
|
-
label: getI18n(`vxe.export.types.${value}`)
|
|
1609
|
+
});
|
|
1257
1610
|
};
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
};
|
|
1611
|
+
if (beforeQueryAllMethod) {
|
|
1612
|
+
return Promise.resolve(beforeQueryAllMethod(params)).then((status) => {
|
|
1613
|
+
if (status !== false) {
|
|
1614
|
+
return handleQueryAll();
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1265
1617
|
}
|
|
1266
|
-
return
|
|
1267
|
-
|
|
1268
|
-
label: getI18n(`vxe.export.modes.${item}`)
|
|
1269
|
-
};
|
|
1270
|
-
});
|
|
1271
|
-
const excludeFdMaps = {};
|
|
1272
|
-
if (excludeFields && excludeFields.length) {
|
|
1273
|
-
excludeFields.forEach(field => {
|
|
1274
|
-
excludeFdMaps[field] = 1;
|
|
1275
|
-
});
|
|
1618
|
+
return handleQueryAll();
|
|
1619
|
+
}
|
|
1276
1620
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1621
|
+
}
|
|
1622
|
+
if (mode === "current") {
|
|
1623
|
+
handleOptions.data = treeConfig ? afterTreeFullData : afterFullData;
|
|
1624
|
+
}
|
|
1625
|
+
} else {
|
|
1626
|
+
handleOptions._isCustomData = true;
|
|
1627
|
+
}
|
|
1628
|
+
return handleExport(handleOptions);
|
|
1629
|
+
},
|
|
1630
|
+
importByFile(file, options) {
|
|
1631
|
+
const opts = Object.assign({}, options);
|
|
1632
|
+
const { beforeImportMethod } = opts;
|
|
1633
|
+
if (beforeImportMethod) {
|
|
1634
|
+
const biRest = beforeImportMethod({ options: opts, $table: $xeTable });
|
|
1635
|
+
if (XEUtils.isBoolean(biRest)) {
|
|
1636
|
+
if (!biRest) {
|
|
1637
|
+
const params = { status: false, mas: "before prevent" };
|
|
1638
|
+
return Promise.reject(params);
|
|
1282
1639
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1640
|
+
} else {
|
|
1641
|
+
warnLog("vxe.error.returnErr", ["beforeImportMethod", "boolean", biRest]);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return handleFileImport(file, opts);
|
|
1645
|
+
},
|
|
1646
|
+
importData(options) {
|
|
1647
|
+
const importOpts = computeImportOpts.value;
|
|
1648
|
+
const opts = Object.assign({
|
|
1649
|
+
types: XEUtils.keys(importOpts._typeMaps)
|
|
1650
|
+
// beforeImportMethod: null,
|
|
1651
|
+
// afterImportMethod: null
|
|
1652
|
+
}, importOpts, options);
|
|
1653
|
+
const { beforeImportMethod, afterImportMethod } = opts;
|
|
1654
|
+
if (beforeImportMethod) {
|
|
1655
|
+
const biRest = beforeImportMethod({ options: opts, $table: $xeTable });
|
|
1656
|
+
if (XEUtils.isBoolean(biRest)) {
|
|
1657
|
+
if (!biRest) {
|
|
1658
|
+
const params = { status: false, mas: "before prevent" };
|
|
1659
|
+
return Promise.reject(params);
|
|
1288
1660
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1661
|
+
} else {
|
|
1662
|
+
warnLog("vxe.error.returnErr", ["beforeImportMethod", "boolean", biRest]);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
return VxeUI.readFile(opts).catch((e) => {
|
|
1666
|
+
if (afterImportMethod) {
|
|
1667
|
+
afterImportMethod({ status: false, options: opts, $table: $xeTable });
|
|
1668
|
+
}
|
|
1669
|
+
return Promise.reject(e);
|
|
1670
|
+
}).then((params) => {
|
|
1671
|
+
const { file } = params;
|
|
1672
|
+
return handleFileImport(file, opts);
|
|
1673
|
+
});
|
|
1674
|
+
},
|
|
1675
|
+
saveFile(options) {
|
|
1676
|
+
return VxeUI.saveFile(options);
|
|
1677
|
+
},
|
|
1678
|
+
readFile(options) {
|
|
1679
|
+
return VxeUI.readFile(options);
|
|
1680
|
+
},
|
|
1681
|
+
print(options) {
|
|
1682
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
1683
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
1684
|
+
const printOpts = computePrintOpts.value;
|
|
1685
|
+
const opts = Object.assign({
|
|
1686
|
+
original: false
|
|
1687
|
+
// beforePrintMethod
|
|
1688
|
+
}, printOpts, options, {
|
|
1689
|
+
type: "html",
|
|
1690
|
+
download: false,
|
|
1691
|
+
remote: false,
|
|
1692
|
+
print: true
|
|
1693
|
+
});
|
|
1694
|
+
const { sheetName } = opts;
|
|
1695
|
+
let printTitle = "";
|
|
1696
|
+
if (sheetName) {
|
|
1697
|
+
if (XEUtils.isFunction(sheetName)) {
|
|
1698
|
+
printTitle = sheetName({
|
|
1699
|
+
options: opts,
|
|
1700
|
+
$table: $xeTable,
|
|
1701
|
+
$grid: $xeGrid,
|
|
1702
|
+
$gantt: $xeGantt
|
|
1312
1703
|
});
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1704
|
+
} else {
|
|
1705
|
+
printTitle = `${sheetName}`;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
if (!printTitle) {
|
|
1709
|
+
printTitle = document.title || "";
|
|
1710
|
+
}
|
|
1711
|
+
const beforePrintMethod = opts.beforePrintMethod;
|
|
1712
|
+
const printMethod = opts.printMethod;
|
|
1713
|
+
const tableHtml = opts.html || opts.content;
|
|
1714
|
+
return new Promise((resolve, reject) => {
|
|
1715
|
+
if (VxeUI.print) {
|
|
1716
|
+
if (tableHtml) {
|
|
1717
|
+
resolve(
|
|
1718
|
+
VxeUI.print({
|
|
1719
|
+
title: printTitle,
|
|
1720
|
+
html: tableHtml,
|
|
1721
|
+
customStyle: opts.style,
|
|
1722
|
+
beforeMethod: beforePrintMethod ? ({ html }) => {
|
|
1723
|
+
return beforePrintMethod({
|
|
1724
|
+
html,
|
|
1725
|
+
content: html,
|
|
1726
|
+
options: opts,
|
|
1727
|
+
$table: $xeTable,
|
|
1728
|
+
$grid: $xeGrid,
|
|
1729
|
+
$gantt: $xeGantt
|
|
1730
|
+
});
|
|
1731
|
+
} : void 0,
|
|
1732
|
+
beforePrintMethod: beforePrintMethod ? ({ html }) => {
|
|
1733
|
+
return beforePrintMethod({
|
|
1734
|
+
html,
|
|
1735
|
+
content: html,
|
|
1736
|
+
options: opts,
|
|
1737
|
+
$table: $xeTable,
|
|
1738
|
+
$grid: $xeGrid,
|
|
1739
|
+
$gantt: $xeGantt
|
|
1740
|
+
});
|
|
1741
|
+
} : void 0,
|
|
1742
|
+
printMethod: printMethod ? ({ html }) => {
|
|
1743
|
+
return printMethod({
|
|
1744
|
+
html,
|
|
1745
|
+
content: html,
|
|
1746
|
+
options: opts,
|
|
1747
|
+
$table: $xeTable,
|
|
1748
|
+
$grid: $xeGrid,
|
|
1749
|
+
$gantt: $xeGantt
|
|
1750
|
+
});
|
|
1751
|
+
} : void 0
|
|
1752
|
+
})
|
|
1753
|
+
);
|
|
1754
|
+
} else {
|
|
1755
|
+
resolve(
|
|
1756
|
+
exportMethods.exportData(opts).then(({ content }) => {
|
|
1757
|
+
return VxeUI.print({
|
|
1758
|
+
title: printTitle,
|
|
1759
|
+
html: content,
|
|
1760
|
+
customStyle: opts.style,
|
|
1761
|
+
beforeMethod: beforePrintMethod ? ({ html }) => {
|
|
1762
|
+
return beforePrintMethod({
|
|
1763
|
+
html,
|
|
1764
|
+
content: html,
|
|
1765
|
+
options: opts,
|
|
1333
1766
|
$table: $xeTable,
|
|
1334
1767
|
$grid: $xeGrid,
|
|
1335
1768
|
$gantt: $xeGantt
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
if (XEUtils.isFunction(sheetName)) {
|
|
1344
|
-
exportParams.sheetName = sheetName({
|
|
1345
|
-
options: defOpts,
|
|
1769
|
+
});
|
|
1770
|
+
} : void 0,
|
|
1771
|
+
beforePrintMethod: beforePrintMethod ? ({ html }) => {
|
|
1772
|
+
return beforePrintMethod({
|
|
1773
|
+
html,
|
|
1774
|
+
content: html,
|
|
1775
|
+
options: opts,
|
|
1346
1776
|
$table: $xeTable,
|
|
1347
1777
|
$grid: $xeGrid,
|
|
1348
1778
|
$gantt: $xeGantt
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1779
|
+
});
|
|
1780
|
+
} : void 0,
|
|
1781
|
+
printMethod: printMethod ? ({ html }) => {
|
|
1782
|
+
return printMethod({
|
|
1783
|
+
html,
|
|
1784
|
+
content: html,
|
|
1785
|
+
options: opts,
|
|
1786
|
+
$table: $xeTable,
|
|
1787
|
+
$grid: $xeGrid,
|
|
1788
|
+
$gantt: $xeGantt
|
|
1789
|
+
});
|
|
1790
|
+
} : void 0
|
|
1791
|
+
});
|
|
1792
|
+
})
|
|
1793
|
+
);
|
|
1363
1794
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1795
|
+
} else {
|
|
1796
|
+
errLog("vxe.error.reqComp", ["vxe-print"]);
|
|
1797
|
+
const e = { status: false, msg: "print not exist" };
|
|
1798
|
+
reject(e);
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
},
|
|
1802
|
+
getPrintHtml(options) {
|
|
1803
|
+
const printOpts = computePrintOpts.value;
|
|
1804
|
+
const opts = Object.assign({
|
|
1805
|
+
original: false
|
|
1806
|
+
// beforePrintMethod
|
|
1807
|
+
}, printOpts, options, {
|
|
1808
|
+
type: "html",
|
|
1809
|
+
download: false,
|
|
1810
|
+
remote: false,
|
|
1811
|
+
print: true
|
|
1812
|
+
});
|
|
1813
|
+
return $xeTable.exportData(opts).then(({ content }) => {
|
|
1814
|
+
return {
|
|
1815
|
+
html: content
|
|
1816
|
+
};
|
|
1817
|
+
});
|
|
1818
|
+
},
|
|
1819
|
+
closeImport() {
|
|
1820
|
+
if (VxeUI.modal) {
|
|
1821
|
+
return VxeUI.modal.close("VXE_IMPORT_MODAL");
|
|
1822
|
+
}
|
|
1823
|
+
return Promise.resolve();
|
|
1824
|
+
},
|
|
1825
|
+
openImport(options) {
|
|
1826
|
+
const { treeConfig, importConfig } = props;
|
|
1827
|
+
const { initStore, importStore, importParams } = reactData;
|
|
1828
|
+
const importOpts = computeImportOpts.value;
|
|
1829
|
+
const defOpts = Object.assign({
|
|
1830
|
+
mode: "insertTop",
|
|
1831
|
+
message: true,
|
|
1832
|
+
types: XEUtils.keys(importOpts._typeMaps),
|
|
1833
|
+
modes: ["insertTop", "covering"]
|
|
1834
|
+
}, importOpts, options);
|
|
1835
|
+
const types = defOpts.types || [];
|
|
1836
|
+
const modes = defOpts.modes || [];
|
|
1837
|
+
const isTree = !!treeConfig;
|
|
1838
|
+
if (isTree) {
|
|
1839
|
+
if (defOpts.message) {
|
|
1368
1840
|
if (VxeUI.modal) {
|
|
1369
|
-
|
|
1841
|
+
VxeUI.modal.message({ content: getI18n("vxe.error.treeNotImp"), status: "error" });
|
|
1370
1842
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
extraFdMaps[field] = 1;
|
|
1444
|
-
});
|
|
1445
|
-
}
|
|
1446
|
-
let isCustomCol = false;
|
|
1447
|
-
let customCols = [];
|
|
1448
|
-
const _columns = opts._columns;
|
|
1449
|
-
if (_columns) {
|
|
1450
|
-
// 内部导出使用 _columns -> _children 为自定义子集
|
|
1451
|
-
isCustomCol = true;
|
|
1452
|
-
customCols = XEUtils.searchTree(_columns, () => true, { children: '_children', mapChildren: 'childNodes', original: true });
|
|
1453
|
-
}
|
|
1454
|
-
else if (columns) {
|
|
1455
|
-
isCustomCol = true;
|
|
1456
|
-
customCols = XEUtils.searchTree(columns, () => true, { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1457
|
-
}
|
|
1458
|
-
else {
|
|
1459
|
-
customCols = XEUtils.searchTree(collectColumn, column => {
|
|
1460
|
-
const isColGroup = column.children && column.children.length > 0;
|
|
1461
|
-
let isChecked = false;
|
|
1462
|
-
const isExtraChecked = extraFdMaps[column.field];
|
|
1463
|
-
if (columns) {
|
|
1464
|
-
isChecked = handleFilterColumns(opts, column, columns);
|
|
1465
|
-
}
|
|
1466
|
-
else if (excludeFields || includeFields) {
|
|
1467
|
-
isChecked = handleFilterFields(opts, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps);
|
|
1468
|
-
}
|
|
1469
|
-
else {
|
|
1470
|
-
if (isExtraChecked) {
|
|
1471
|
-
isChecked = true;
|
|
1472
|
-
}
|
|
1473
|
-
else {
|
|
1474
|
-
isChecked = column.visible && (isColGroup || defaultFilterExportColumn(column));
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
return isChecked;
|
|
1478
|
-
}, { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1479
|
-
}
|
|
1480
|
-
const handleOptions = Object.assign({}, opts, { filename: '', sheetName: '', _columnConfs: columns });
|
|
1481
|
-
// 如果设置源数据,则默认导出设置了字段的列
|
|
1482
|
-
if (!isCustomCol && !columnFilterMethod) {
|
|
1483
|
-
columnFilterMethod = ({ column }) => handleFilterFields(handleOptions, column, includeFields, includeFdMaps, excludeFdMaps, extraFdMaps);
|
|
1484
|
-
handleOptions.columnFilterMethod = columnFilterMethod;
|
|
1485
|
-
}
|
|
1486
|
-
if (customCols) {
|
|
1487
|
-
handleOptions._isCustomColumn = true;
|
|
1488
|
-
groups = XEUtils.searchTree(XEUtils.mapTree(customCols, (item) => {
|
|
1489
|
-
let targetColumn;
|
|
1490
|
-
if (item) {
|
|
1491
|
-
if (isColumnInfo(item)) {
|
|
1492
|
-
targetColumn = item;
|
|
1493
|
-
}
|
|
1494
|
-
else if (XEUtils.isString(item)) {
|
|
1495
|
-
targetColumn = $xeTable.getColumnByField(item);
|
|
1496
|
-
}
|
|
1497
|
-
else {
|
|
1498
|
-
const colid = item.id || item.colId;
|
|
1499
|
-
const type = item.type;
|
|
1500
|
-
const field = item.field;
|
|
1501
|
-
if (colid) {
|
|
1502
|
-
targetColumn = $xeTable.getColumnById(colid);
|
|
1503
|
-
}
|
|
1504
|
-
else if (field && type) {
|
|
1505
|
-
targetColumn = tableFullColumn.find((column) => column.field === field && column.type === type);
|
|
1506
|
-
}
|
|
1507
|
-
else if (field) {
|
|
1508
|
-
targetColumn = $xeTable.getColumnByField(field);
|
|
1509
|
-
}
|
|
1510
|
-
else if (type) {
|
|
1511
|
-
targetColumn = tableFullColumn.find((column) => column.type === type);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
return targetColumn || {};
|
|
1515
|
-
}
|
|
1516
|
-
}, {
|
|
1517
|
-
children: 'childNodes',
|
|
1518
|
-
mapChildren: '_children'
|
|
1519
|
-
}), (column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, column: column, $columnIndex: index })), {
|
|
1520
|
-
children: '_children',
|
|
1521
|
-
mapChildren: 'childNodes',
|
|
1522
|
-
original: true
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
else {
|
|
1526
|
-
groups = XEUtils.searchTree(isGroup ? collectColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true });
|
|
1527
|
-
}
|
|
1528
|
-
// 获取所有列
|
|
1529
|
-
const cols = [];
|
|
1530
|
-
XEUtils.eachTree(groups, column => {
|
|
1531
|
-
const isColGroup = column.children && column.children.length;
|
|
1532
|
-
if (!isColGroup) {
|
|
1533
|
-
cols.push(column);
|
|
1534
|
-
}
|
|
1535
|
-
}, { children: 'childNodes' });
|
|
1536
|
-
// 构建分组层级
|
|
1537
|
-
handleOptions.columns = cols;
|
|
1538
|
-
handleOptions.colgroups = convertToRows(groups);
|
|
1539
|
-
if (filename) {
|
|
1540
|
-
if (XEUtils.isFunction(filename)) {
|
|
1541
|
-
handleOptions.filename = filename({
|
|
1542
|
-
options: opts,
|
|
1543
|
-
$table: $xeTable,
|
|
1544
|
-
$grid: $xeGrid,
|
|
1545
|
-
$gantt: $xeGantt
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
else {
|
|
1549
|
-
handleOptions.filename = `${filename}`;
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
if (!handleOptions.filename) {
|
|
1553
|
-
handleOptions.filename = getI18n(handleOptions.original ? 'vxe.table.expOriginFilename' : 'vxe.table.expFilename', [XEUtils.toDateString(Date.now(), 'yyyyMMddHHmmss')]);
|
|
1554
|
-
}
|
|
1555
|
-
if (sheetName) {
|
|
1556
|
-
if (XEUtils.isFunction(sheetName)) {
|
|
1557
|
-
handleOptions.sheetName = sheetName({
|
|
1558
|
-
options: opts,
|
|
1559
|
-
$table: $xeTable,
|
|
1560
|
-
$grid: $xeGrid,
|
|
1561
|
-
$gantt: $xeGantt
|
|
1562
|
-
});
|
|
1563
|
-
}
|
|
1564
|
-
else {
|
|
1565
|
-
handleOptions.sheetName = `${sheetName}`;
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
if (!handleOptions.sheetName) {
|
|
1569
|
-
handleOptions.sheetName = document.title || '';
|
|
1570
|
-
}
|
|
1571
|
-
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1572
|
-
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
|
|
1573
|
-
errLog('vxe.error.notType', [type]);
|
|
1574
|
-
if (['xlsx', 'pdf'].includes(type)) {
|
|
1575
|
-
warnLog('vxe.error.reqPlugin', [4, 'plugin-export-xlsx']);
|
|
1576
|
-
}
|
|
1577
|
-
const params = { status: false, msg: 'type error' };
|
|
1578
|
-
return Promise.reject(params);
|
|
1579
|
-
}
|
|
1580
|
-
if (!handleOptions.print) {
|
|
1581
|
-
if (beforeExportMethod) {
|
|
1582
|
-
const beRest = beforeExportMethod({ options: handleOptions, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1583
|
-
if (XEUtils.isBoolean(beRest)) {
|
|
1584
|
-
if (!beRest) {
|
|
1585
|
-
const params = { status: false, msg: 'before prevent' };
|
|
1586
|
-
return Promise.reject(params);
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
else {
|
|
1590
|
-
warnLog('vxe.error.returnErr', ['beforeExportMethod', 'boolean', beRest]);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
if (!handleOptions.data) {
|
|
1595
|
-
handleOptions.data = [];
|
|
1596
|
-
if (mode === 'selected') {
|
|
1597
|
-
if (['html', 'pdf'].indexOf(type) > -1 && treeConfig) {
|
|
1598
|
-
handleOptions.data = XEUtils.searchTree($xeTable.getTableData().fullData, item => $xeTable.findRowIndexOf(selectRecords, item) > -1, Object.assign({}, treeOpts, { data: '_row' }));
|
|
1599
|
-
}
|
|
1600
|
-
else {
|
|
1601
|
-
handleOptions.data = selectRecords;
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
else if (mode === 'all') {
|
|
1605
|
-
if (!$xeGGWrapper) {
|
|
1606
|
-
errLog('vxe.error.errProp', ['all', 'mode=current,selected']);
|
|
1607
|
-
}
|
|
1608
|
-
if ($xeGGWrapper && !handleOptions.remote) {
|
|
1609
|
-
const gridReactData = $xeGGWrapper.reactData;
|
|
1610
|
-
const { computeProxyOpts } = $xeGGWrapper.getComputeMaps();
|
|
1611
|
-
const proxyOpts = computeProxyOpts.value;
|
|
1612
|
-
const { sortData } = gridReactData;
|
|
1613
|
-
const { beforeQueryAll: oldBeforeQueryAll, afterQueryAll: oldAfterQueryAll, ajax = {} } = proxyOpts;
|
|
1614
|
-
const resConfigs = proxyOpts.response || proxyOpts.props || {};
|
|
1615
|
-
const beforeQueryAllMethod = ajax.beforeQueryAll;
|
|
1616
|
-
const queryAllMethod = ajax.queryAll;
|
|
1617
|
-
const afterQueryAllMethod = ajax.afterQueryAll;
|
|
1618
|
-
const queryAllSuccessMethod = ajax.queryAllSuccess;
|
|
1619
|
-
const queryAllErrorMethod = ajax.queryAllError;
|
|
1620
|
-
if (!queryAllMethod) {
|
|
1621
|
-
errLog('vxe.error.notFunc', ['proxy-config.ajax.queryAll']);
|
|
1622
|
-
}
|
|
1623
|
-
if (queryAllMethod) {
|
|
1624
|
-
const params = {
|
|
1625
|
-
$table: $xeTable,
|
|
1626
|
-
$grid: $xeGrid,
|
|
1627
|
-
$gantt: $xeGantt,
|
|
1628
|
-
sort: sortData.length ? sortData[0] : {},
|
|
1629
|
-
sorts: sortData,
|
|
1630
|
-
filters: gridReactData.filterData,
|
|
1631
|
-
form: gridReactData.formData,
|
|
1632
|
-
options: handleOptions
|
|
1633
|
-
};
|
|
1634
|
-
const handleQueryAll = () => {
|
|
1635
|
-
return Promise.resolve((oldBeforeQueryAll || queryAllMethod)(params))
|
|
1636
|
-
.then((rest) => {
|
|
1637
|
-
if (afterQueryAllMethod) {
|
|
1638
|
-
afterQueryAllMethod(Object.assign(Object.assign({}, params), { response: rest, status: 'success' }));
|
|
1639
|
-
}
|
|
1640
|
-
else {
|
|
1641
|
-
const listProp = resConfigs.list;
|
|
1642
|
-
let tdData = [];
|
|
1643
|
-
if (listProp) {
|
|
1644
|
-
if (XEUtils.isFunction(listProp)) {
|
|
1645
|
-
tdData = listProp({ data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
|
|
1646
|
-
}
|
|
1647
|
-
else {
|
|
1648
|
-
tdData = XEUtils.isArray(rest) ? rest : XEUtils.get(rest, listProp);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
else {
|
|
1652
|
-
if (XEUtils.isArray(rest)) {
|
|
1653
|
-
tdData = rest;
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
handleOptions.data = tdData;
|
|
1657
|
-
if (oldAfterQueryAll) {
|
|
1658
|
-
oldAfterQueryAll(Object.assign(Object.assign({}, params), { response: rest }));
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
if (queryAllSuccessMethod) {
|
|
1662
|
-
queryAllSuccessMethod(Object.assign(Object.assign({}, params), { response: rest }));
|
|
1663
|
-
}
|
|
1664
|
-
return handleExport(handleOptions);
|
|
1665
|
-
})
|
|
1666
|
-
.catch((rest) => {
|
|
1667
|
-
if (afterQueryAllMethod) {
|
|
1668
|
-
afterQueryAllMethod(Object.assign(Object.assign({}, params), { response: rest, status: 'error' }));
|
|
1669
|
-
}
|
|
1670
|
-
if (queryAllErrorMethod) {
|
|
1671
|
-
queryAllErrorMethod(Object.assign(Object.assign({}, params), { response: rest }));
|
|
1672
|
-
}
|
|
1673
|
-
});
|
|
1674
|
-
};
|
|
1675
|
-
if (beforeQueryAllMethod) {
|
|
1676
|
-
return Promise.resolve(beforeQueryAllMethod(params)).then(status => {
|
|
1677
|
-
if (status !== false) {
|
|
1678
|
-
return handleQueryAll();
|
|
1679
|
-
}
|
|
1680
|
-
});
|
|
1681
|
-
}
|
|
1682
|
-
return handleQueryAll();
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
if (mode === 'current') {
|
|
1687
|
-
handleOptions.data = treeConfig ? afterTreeFullData : afterFullData;
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
else {
|
|
1691
|
-
handleOptions._isCustomData = true;
|
|
1692
|
-
}
|
|
1693
|
-
return handleExport(handleOptions);
|
|
1694
|
-
},
|
|
1695
|
-
importByFile(file, options) {
|
|
1696
|
-
const opts = Object.assign({}, options);
|
|
1697
|
-
const { beforeImportMethod } = opts;
|
|
1698
|
-
if (beforeImportMethod) {
|
|
1699
|
-
const biRest = beforeImportMethod({ options: opts, $table: $xeTable });
|
|
1700
|
-
if (XEUtils.isBoolean(biRest)) {
|
|
1701
|
-
if (!biRest) {
|
|
1702
|
-
const params = { status: false, mas: 'before prevent' };
|
|
1703
|
-
return Promise.reject(params);
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
else {
|
|
1707
|
-
warnLog('vxe.error.returnErr', ['beforeImportMethod', 'boolean', biRest]);
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
return handleFileImport(file, opts);
|
|
1711
|
-
},
|
|
1712
|
-
importData(options) {
|
|
1713
|
-
const importOpts = computeImportOpts.value;
|
|
1714
|
-
const opts = Object.assign({
|
|
1715
|
-
types: XEUtils.keys(importOpts._typeMaps)
|
|
1716
|
-
// beforeImportMethod: null,
|
|
1717
|
-
// afterImportMethod: null
|
|
1718
|
-
}, importOpts, options);
|
|
1719
|
-
const { beforeImportMethod, afterImportMethod } = opts;
|
|
1720
|
-
if (beforeImportMethod) {
|
|
1721
|
-
const biRest = beforeImportMethod({ options: opts, $table: $xeTable });
|
|
1722
|
-
if (XEUtils.isBoolean(biRest)) {
|
|
1723
|
-
if (!biRest) {
|
|
1724
|
-
const params = { status: false, mas: 'before prevent' };
|
|
1725
|
-
return Promise.reject(params);
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
else {
|
|
1729
|
-
warnLog('vxe.error.returnErr', ['beforeImportMethod', 'boolean', biRest]);
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
return VxeUI.readFile(opts).catch(e => {
|
|
1733
|
-
if (afterImportMethod) {
|
|
1734
|
-
afterImportMethod({ status: false, options: opts, $table: $xeTable });
|
|
1735
|
-
}
|
|
1736
|
-
return Promise.reject(e);
|
|
1737
|
-
}).then((params) => {
|
|
1738
|
-
const { file } = params;
|
|
1739
|
-
return handleFileImport(file, opts);
|
|
1740
|
-
});
|
|
1741
|
-
},
|
|
1742
|
-
saveFile(options) {
|
|
1743
|
-
return VxeUI.saveFile(options);
|
|
1744
|
-
},
|
|
1745
|
-
readFile(options) {
|
|
1746
|
-
return VxeUI.readFile(options);
|
|
1747
|
-
},
|
|
1748
|
-
print(options) {
|
|
1749
|
-
const $xeGrid = $xeTable.xeGrid;
|
|
1750
|
-
const $xeGantt = $xeTable.xeGantt;
|
|
1751
|
-
const printOpts = computePrintOpts.value;
|
|
1752
|
-
const opts = Object.assign({
|
|
1753
|
-
original: false
|
|
1754
|
-
// beforePrintMethod
|
|
1755
|
-
}, printOpts, options, {
|
|
1756
|
-
type: 'html',
|
|
1757
|
-
download: false,
|
|
1758
|
-
remote: false,
|
|
1759
|
-
print: true
|
|
1760
|
-
});
|
|
1761
|
-
const { sheetName } = opts;
|
|
1762
|
-
let printTitle = '';
|
|
1763
|
-
if (sheetName) {
|
|
1764
|
-
if (XEUtils.isFunction(sheetName)) {
|
|
1765
|
-
printTitle = sheetName({
|
|
1766
|
-
options: opts,
|
|
1767
|
-
$table: $xeTable,
|
|
1768
|
-
$grid: $xeGrid,
|
|
1769
|
-
$gantt: $xeGantt
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
else {
|
|
1773
|
-
printTitle = `${sheetName}`;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
if (!printTitle) {
|
|
1777
|
-
printTitle = document.title || '';
|
|
1778
|
-
}
|
|
1779
|
-
const beforePrintMethod = opts.beforePrintMethod;
|
|
1780
|
-
const printMethod = opts.printMethod;
|
|
1781
|
-
const tableHtml = opts.html || opts.content;
|
|
1782
|
-
return new Promise((resolve, reject) => {
|
|
1783
|
-
if (VxeUI.print) {
|
|
1784
|
-
if (tableHtml) {
|
|
1785
|
-
resolve(VxeUI.print({
|
|
1786
|
-
title: printTitle,
|
|
1787
|
-
html: tableHtml,
|
|
1788
|
-
customStyle: opts.style,
|
|
1789
|
-
beforeMethod: beforePrintMethod
|
|
1790
|
-
? ({ html }) => {
|
|
1791
|
-
return beforePrintMethod({
|
|
1792
|
-
html,
|
|
1793
|
-
content: html,
|
|
1794
|
-
options: opts,
|
|
1795
|
-
$table: $xeTable,
|
|
1796
|
-
$grid: $xeGrid,
|
|
1797
|
-
$gantt: $xeGantt
|
|
1798
|
-
});
|
|
1799
|
-
}
|
|
1800
|
-
: undefined,
|
|
1801
|
-
beforePrintMethod: beforePrintMethod
|
|
1802
|
-
? ({ html }) => {
|
|
1803
|
-
return beforePrintMethod({
|
|
1804
|
-
html,
|
|
1805
|
-
content: html,
|
|
1806
|
-
options: opts,
|
|
1807
|
-
$table: $xeTable,
|
|
1808
|
-
$grid: $xeGrid,
|
|
1809
|
-
$gantt: $xeGantt
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
: undefined,
|
|
1813
|
-
printMethod: printMethod
|
|
1814
|
-
? ({ html }) => {
|
|
1815
|
-
return printMethod({
|
|
1816
|
-
html,
|
|
1817
|
-
content: html,
|
|
1818
|
-
options: opts,
|
|
1819
|
-
$table: $xeTable,
|
|
1820
|
-
$grid: $xeGrid,
|
|
1821
|
-
$gantt: $xeGantt
|
|
1822
|
-
});
|
|
1823
|
-
}
|
|
1824
|
-
: undefined
|
|
1825
|
-
}));
|
|
1826
|
-
}
|
|
1827
|
-
else {
|
|
1828
|
-
resolve(exportMethods.exportData(opts).then(({ content }) => {
|
|
1829
|
-
return VxeUI.print({
|
|
1830
|
-
title: printTitle,
|
|
1831
|
-
html: content,
|
|
1832
|
-
customStyle: opts.style,
|
|
1833
|
-
beforeMethod: beforePrintMethod
|
|
1834
|
-
? ({ html }) => {
|
|
1835
|
-
return beforePrintMethod({
|
|
1836
|
-
html,
|
|
1837
|
-
content: html,
|
|
1838
|
-
options: opts,
|
|
1839
|
-
$table: $xeTable,
|
|
1840
|
-
$grid: $xeGrid,
|
|
1841
|
-
$gantt: $xeGantt
|
|
1842
|
-
});
|
|
1843
|
-
}
|
|
1844
|
-
: undefined,
|
|
1845
|
-
beforePrintMethod: beforePrintMethod
|
|
1846
|
-
? ({ html }) => {
|
|
1847
|
-
return beforePrintMethod({
|
|
1848
|
-
html,
|
|
1849
|
-
content: html,
|
|
1850
|
-
options: opts,
|
|
1851
|
-
$table: $xeTable,
|
|
1852
|
-
$grid: $xeGrid,
|
|
1853
|
-
$gantt: $xeGantt
|
|
1854
|
-
});
|
|
1855
|
-
}
|
|
1856
|
-
: undefined,
|
|
1857
|
-
printMethod: printMethod
|
|
1858
|
-
? ({ html }) => {
|
|
1859
|
-
return printMethod({
|
|
1860
|
-
html,
|
|
1861
|
-
content: html,
|
|
1862
|
-
options: opts,
|
|
1863
|
-
$table: $xeTable,
|
|
1864
|
-
$grid: $xeGrid,
|
|
1865
|
-
$gantt: $xeGantt
|
|
1866
|
-
});
|
|
1867
|
-
}
|
|
1868
|
-
: undefined
|
|
1869
|
-
});
|
|
1870
|
-
}));
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
else {
|
|
1874
|
-
errLog('vxe.error.reqComp', ['vxe-print']);
|
|
1875
|
-
const e = { status: false, msg: 'print not exist' };
|
|
1876
|
-
reject(e);
|
|
1877
|
-
}
|
|
1878
|
-
});
|
|
1879
|
-
},
|
|
1880
|
-
getPrintHtml(options) {
|
|
1881
|
-
const printOpts = computePrintOpts.value;
|
|
1882
|
-
const opts = Object.assign({
|
|
1883
|
-
original: false
|
|
1884
|
-
// beforePrintMethod
|
|
1885
|
-
}, printOpts, options, {
|
|
1886
|
-
type: 'html',
|
|
1887
|
-
download: false,
|
|
1888
|
-
remote: false,
|
|
1889
|
-
print: true
|
|
1890
|
-
});
|
|
1891
|
-
return $xeTable.exportData(opts).then(({ content }) => {
|
|
1892
|
-
return {
|
|
1893
|
-
html: content
|
|
1894
|
-
};
|
|
1895
|
-
});
|
|
1896
|
-
},
|
|
1897
|
-
closeImport() {
|
|
1898
|
-
if (VxeUI.modal) {
|
|
1899
|
-
return VxeUI.modal.close('VXE_IMPORT_MODAL');
|
|
1900
|
-
}
|
|
1901
|
-
return Promise.resolve();
|
|
1902
|
-
},
|
|
1903
|
-
openImport(options) {
|
|
1904
|
-
const { treeConfig, importConfig } = props;
|
|
1905
|
-
const { initStore, importStore, importParams } = reactData;
|
|
1906
|
-
const importOpts = computeImportOpts.value;
|
|
1907
|
-
const defOpts = Object.assign({
|
|
1908
|
-
mode: 'insertTop',
|
|
1909
|
-
message: true,
|
|
1910
|
-
types: XEUtils.keys(importOpts._typeMaps),
|
|
1911
|
-
modes: ['insertTop', 'covering']
|
|
1912
|
-
}, importOpts, options);
|
|
1913
|
-
const types = defOpts.types || [];
|
|
1914
|
-
const modes = defOpts.modes || [];
|
|
1915
|
-
const isTree = !!treeConfig;
|
|
1916
|
-
if (isTree) {
|
|
1917
|
-
if (defOpts.message) {
|
|
1918
|
-
if (VxeUI.modal) {
|
|
1919
|
-
VxeUI.modal.message({ content: getI18n('vxe.error.treeNotImp'), status: 'error' });
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
return;
|
|
1923
|
-
}
|
|
1924
|
-
if (!hasEnableConf(importConfig, importOpts)) {
|
|
1925
|
-
errLog('vxe.error.reqProp', ['import-config']);
|
|
1926
|
-
}
|
|
1927
|
-
// 处理类型
|
|
1928
|
-
const typeList = types.map((value) => {
|
|
1929
|
-
return {
|
|
1930
|
-
value,
|
|
1931
|
-
label: getI18n(`vxe.export.types.${value}`)
|
|
1932
|
-
};
|
|
1933
|
-
});
|
|
1934
|
-
const modeList = modes.map((item) => {
|
|
1935
|
-
if (item && item.value) {
|
|
1936
|
-
return {
|
|
1937
|
-
value: item.value,
|
|
1938
|
-
label: item.label || item.value
|
|
1939
|
-
};
|
|
1940
|
-
}
|
|
1941
|
-
return {
|
|
1942
|
-
value: item,
|
|
1943
|
-
label: getI18n(`vxe.import.modes.${item}`)
|
|
1944
|
-
};
|
|
1945
|
-
});
|
|
1946
|
-
Object.assign(importStore, {
|
|
1947
|
-
file: null,
|
|
1948
|
-
type: '',
|
|
1949
|
-
filename: '',
|
|
1950
|
-
modeList,
|
|
1951
|
-
typeList,
|
|
1952
|
-
visible: true
|
|
1953
|
-
});
|
|
1954
|
-
Object.assign(importParams, defOpts);
|
|
1955
|
-
if (!modeList.some(item => item.value === importParams.mode)) {
|
|
1956
|
-
importParams.mode = modeList[0].value;
|
|
1957
|
-
}
|
|
1958
|
-
initStore.import = true;
|
|
1959
|
-
},
|
|
1960
|
-
closeExport: handleCloseExport,
|
|
1961
|
-
openExport(options) {
|
|
1962
|
-
const { exportConfig } = props;
|
|
1963
|
-
const exportOpts = computeExportOpts.value;
|
|
1964
|
-
const defOpts = Object.assign({
|
|
1965
|
-
message: true,
|
|
1966
|
-
types: XEUtils.keys(exportOpts._typeMaps)
|
|
1967
|
-
}, exportOpts, options);
|
|
1968
|
-
if (!hasEnableConf(exportConfig, exportOpts)) {
|
|
1969
|
-
errLog('vxe.error.reqProp', ['export-config']);
|
|
1970
|
-
}
|
|
1971
|
-
return handleExportAndPrint(defOpts);
|
|
1972
|
-
},
|
|
1973
|
-
closePrint: handleCloseExport,
|
|
1974
|
-
openPrint(options) {
|
|
1975
|
-
const { printConfig } = props;
|
|
1976
|
-
const printOpts = computePrintOpts.value;
|
|
1977
|
-
const defOpts = Object.assign({
|
|
1978
|
-
message: true
|
|
1979
|
-
}, printOpts, options);
|
|
1980
|
-
if (!hasEnableConf(printConfig, printOpts)) {
|
|
1981
|
-
errLog('vxe.error.reqProp', ['print-config']);
|
|
1982
|
-
}
|
|
1983
|
-
return handleExportAndPrint(defOpts, true);
|
|
1984
|
-
}
|
|
1985
|
-
};
|
|
1986
|
-
return exportMethods;
|
|
1987
|
-
},
|
|
1988
|
-
setupGrid($xeGrid) {
|
|
1989
|
-
return $xeGrid.extendTableMethods(tableExportMethodKeys);
|
|
1990
|
-
},
|
|
1991
|
-
setupGantt($xeGantt) {
|
|
1992
|
-
return $xeGantt.extendTableMethods(tableExportMethodKeys);
|
|
1993
|
-
}
|
|
1843
|
+
}
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
if (!hasEnableConf(importConfig, importOpts)) {
|
|
1847
|
+
errLog("vxe.error.reqProp", ["import-config"]);
|
|
1848
|
+
}
|
|
1849
|
+
const typeList = types.map((value) => {
|
|
1850
|
+
return {
|
|
1851
|
+
value,
|
|
1852
|
+
label: getI18n(`vxe.export.types.${value}`)
|
|
1853
|
+
};
|
|
1854
|
+
});
|
|
1855
|
+
const modeList = modes.map((item) => {
|
|
1856
|
+
if (item && item.value) {
|
|
1857
|
+
return {
|
|
1858
|
+
value: item.value,
|
|
1859
|
+
label: item.label || item.value
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
return {
|
|
1863
|
+
value: item,
|
|
1864
|
+
label: getI18n(`vxe.import.modes.${item}`)
|
|
1865
|
+
};
|
|
1866
|
+
});
|
|
1867
|
+
Object.assign(importStore, {
|
|
1868
|
+
file: null,
|
|
1869
|
+
type: "",
|
|
1870
|
+
filename: "",
|
|
1871
|
+
modeList,
|
|
1872
|
+
typeList,
|
|
1873
|
+
visible: true
|
|
1874
|
+
});
|
|
1875
|
+
Object.assign(importParams, defOpts);
|
|
1876
|
+
if (!modeList.some((item) => item.value === importParams.mode)) {
|
|
1877
|
+
importParams.mode = modeList[0].value;
|
|
1878
|
+
}
|
|
1879
|
+
initStore.import = true;
|
|
1880
|
+
},
|
|
1881
|
+
closeExport: handleCloseExport,
|
|
1882
|
+
openExport(options) {
|
|
1883
|
+
const { exportConfig } = props;
|
|
1884
|
+
const exportOpts = computeExportOpts.value;
|
|
1885
|
+
const defOpts = Object.assign({
|
|
1886
|
+
message: true,
|
|
1887
|
+
types: XEUtils.keys(exportOpts._typeMaps)
|
|
1888
|
+
}, exportOpts, options);
|
|
1889
|
+
if (!hasEnableConf(exportConfig, exportOpts)) {
|
|
1890
|
+
errLog("vxe.error.reqProp", ["export-config"]);
|
|
1891
|
+
}
|
|
1892
|
+
return handleExportAndPrint(defOpts);
|
|
1893
|
+
},
|
|
1894
|
+
closePrint: handleCloseExport,
|
|
1895
|
+
openPrint(options) {
|
|
1896
|
+
const { printConfig } = props;
|
|
1897
|
+
const printOpts = computePrintOpts.value;
|
|
1898
|
+
const defOpts = Object.assign({
|
|
1899
|
+
message: true
|
|
1900
|
+
}, printOpts, options);
|
|
1901
|
+
if (!hasEnableConf(printConfig, printOpts)) {
|
|
1902
|
+
errLog("vxe.error.reqProp", ["print-config"]);
|
|
1903
|
+
}
|
|
1904
|
+
return handleExportAndPrint(defOpts, true);
|
|
1905
|
+
}
|
|
1906
|
+
};
|
|
1907
|
+
return exportMethods;
|
|
1908
|
+
},
|
|
1909
|
+
setupGrid($xeGrid) {
|
|
1910
|
+
return $xeGrid.extendTableMethods(tableExportMethodKeys);
|
|
1911
|
+
},
|
|
1912
|
+
setupGantt($xeGantt) {
|
|
1913
|
+
return $xeGantt.extendTableMethods(tableExportMethodKeys);
|
|
1914
|
+
}
|
|
1994
1915
|
});
|