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
package/es/grid/src/grid.js
CHANGED
|
@@ -1,1819 +1,1756 @@
|
|
|
1
|
-
import { h, ref, computed, provide, reactive, onBeforeUnmount, watch, nextTick, onMounted } from
|
|
2
|
-
import { defineVxeComponent } from
|
|
3
|
-
import XEUtils from
|
|
4
|
-
import { getLastZIndex, nextZIndex, isEnableConf } from
|
|
5
|
-
import { getOffsetHeight, getPaddingTopBottomSize, getDomNode, toCssUnit, hasClass } from
|
|
6
|
-
import { VxeUI } from
|
|
7
|
-
import { gridProps } from
|
|
8
|
-
import { gridEmits } from
|
|
9
|
-
import { getSlotVNs } from
|
|
10
|
-
import { createComponentLog } from
|
|
11
|
-
import { tableEmits } from
|
|
12
|
-
import { tableProps } from
|
|
13
|
-
import VxeTableComponent from
|
|
14
|
-
import VxeToolbarComponent from
|
|
15
|
-
const { warnLog, errLog } = createComponentLog(
|
|
1
|
+
import { h, ref, computed, provide, reactive, onBeforeUnmount, watch, nextTick, onMounted } from "vue";
|
|
2
|
+
import { defineVxeComponent } from "../../ui/src/comp";
|
|
3
|
+
import XEUtils from "xe-utils";
|
|
4
|
+
import { getLastZIndex, nextZIndex, isEnableConf } from "../../ui/src/utils";
|
|
5
|
+
import { getOffsetHeight, getPaddingTopBottomSize, getDomNode, toCssUnit, hasClass } from "../../ui/src/dom";
|
|
6
|
+
import { VxeUI } from "../../ui";
|
|
7
|
+
import { gridProps } from "./props";
|
|
8
|
+
import { gridEmits } from "./emits";
|
|
9
|
+
import { getSlotVNs } from "../../ui/src/vn";
|
|
10
|
+
import { createComponentLog } from "../../ui/src/log";
|
|
11
|
+
import { tableEmits } from "../../table/src/emits";
|
|
12
|
+
import { tableProps } from "../../table/src/props";
|
|
13
|
+
import VxeTableComponent from "../../table";
|
|
14
|
+
import VxeToolbarComponent from "../../toolbar";
|
|
15
|
+
const { warnLog, errLog } = createComponentLog("grid");
|
|
16
16
|
const { getConfig, getI18n, commands, hooks, useFns, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement } = VxeUI;
|
|
17
17
|
const tableComponentPropKeys = Object.keys(tableProps);
|
|
18
|
-
const tableComponentMethodKeys = [
|
|
18
|
+
const tableComponentMethodKeys = ["clearAll", "syncData", "updateData", "loadData", "reloadData", "reloadRow", "loadColumn", "reloadColumn", "getRowNode", "getColumnNode", "getRowIndex", "getVTRowIndex", "getVMRowIndex", "getColumnIndex", "getVTColumnIndex", "getVMColumnIndex", "setRow", "createData", "createRow", "revertData", "clearData", "isRemoveByRow", "isInsertByRow", "isUpdateByRow", "getColumns", "getColumnById", "getColumnByField", "getTableColumn", "getFullColumns", "getData", "getCheckboxRecords", "getParentRow", "getTreeRowChildren", "getTreeRowLevel", "getTreeParentRow", "getRowSeq", "getRowById", "getRowid", "getTableData", "getFullData", "setColumnFixed", "clearColumnFixed", "setColumnWidth", "getColumnWidth", "recalcRowHeight", "setRowHeightConf", "getRowHeightConf", "setRowHeight", "getRowHeight", "hideColumn", "showColumn", "resetColumn", "refreshColumn", "refreshScroll", "recalculate", "closeTooltip", "isAllCheckboxChecked", "isAllCheckboxIndeterminate", "getCheckboxIndeterminateRecords", "setCheckboxRow", "setCheckboxRowKey", "isCheckedByCheckboxRow", "isCheckedByCheckboxRowKey", "isIndeterminateByCheckboxRow", "isIndeterminateByCheckboxRowKey", "toggleCheckboxRow", "setAllCheckboxRow", "getRadioReserveRecord", "clearRadioReserve", "getCheckboxReserveRecords", "clearCheckboxReserve", "toggleAllCheckboxRow", "clearCheckboxRow", "setCurrentRow", "isCheckedByRadioRow", "isCheckedByRadioRowKey", "setRadioRow", "setRadioRowKey", "clearCurrentRow", "clearRadioRow", "getCurrentRecord", "getRadioRecord", "getCurrentColumn", "setCurrentColumn", "clearCurrentColumn", "setPendingRow", "togglePendingRow", "hasPendingByRow", "isPendingByRow", "getPendingRecords", "clearPendingRow", "setFilterByEvent", "sort", "setSort", "setSortByEvent", "clearSort", "clearSortByEvent", "isSort", "getSortColumns", "closeFilter", "isFilter", "clearFilterByEvent", "isActiveFilterByColumn", "isRowExpandLoaded", "clearRowExpandLoaded", "reloadRowExpand", "reloadRowExpand", "toggleRowExpand", "setAllRowExpand", "setRowExpand", "isExpandByRow", "isRowExpandByRow", "clearRowExpand", "clearRowExpandReserve", "getRowExpandRecords", "getTreeExpandRecords", "isTreeExpandLoaded", "clearTreeExpandLoaded", "reloadTreeExpand", "reloadTreeChilds", "toggleTreeExpand", "setAllTreeExpand", "setTreeExpand", "isTreeExpandByRow", "clearTreeExpand", "clearTreeExpandReserve", "getScroll", "getScrollData", "scrollTo", "scrollToStartRow", "scrollToEndRow", "scrollToRow", "scrollToStartColumn", "scrollToEndColumn", "scrollToColumn", "clearScroll", "updateFooter", "updateStatus", "setMergeCells", "removeInsertRow", "removeMergeCells", "getMergeCells", "setMergeHeaderCells", "removeMergeHeaderCells", "getMergeHeaderCells", "clearMergeHeaderCells", "clearMergeCells", "setMergeFooterItems", "removeMergeFooterItems", "getMergeFooterItems", "clearMergeFooterItems", "setCustomStoreData", "getCustomStoreData", "setRowGroupExpand", "setRowGroupExpandByField", "setAllRowGroupExpand", "clearRowGroupExpand", "isRowGroupExpandByRow", "isRowGroupRecord", "isAggregateRecord", "isAggregateExpandByRow", "getAggregateContentByRow", "getAggregateRowChildren", "setRowGroups", "clearRowGroups", "openTooltip", "moveColumnTo", "moveRowTo", "getCellLabel", "updateCellLabel", "clearFormatterCache", "getFooterCellLabel", "updateFooterCellLabel", "clearFooterFormatterCache", "getUpdateCells", "undo", "redo", "effectCellData", "getCellElement", "focus", "blur", "connect", "connectToolbar"];
|
|
19
19
|
function createReactData() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
var _a;
|
|
21
|
+
return {
|
|
22
|
+
tableLoading: false,
|
|
23
|
+
proxyInited: false,
|
|
24
|
+
isZMax: false,
|
|
25
|
+
tableData: [],
|
|
26
|
+
filterData: [],
|
|
27
|
+
formData: {},
|
|
28
|
+
sortData: [],
|
|
29
|
+
footerData: [],
|
|
30
|
+
tZindex: 0,
|
|
31
|
+
tablePage: {
|
|
32
|
+
total: 0,
|
|
33
|
+
pageSize: ((_a = getConfig().pager) == null ? void 0 : _a.pageSize) || 10,
|
|
34
|
+
currentPage: 1
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
37
|
}
|
|
38
38
|
function createInternalData() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return {
|
|
40
|
+
uFoot: false
|
|
41
|
+
};
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
return funcs;
|
|
43
|
+
var grid_default = defineVxeComponent({
|
|
44
|
+
name: "VxeGrid",
|
|
45
|
+
props: gridProps,
|
|
46
|
+
emits: gridEmits,
|
|
47
|
+
setup(props, context) {
|
|
48
|
+
const { slots, emit } = context;
|
|
49
|
+
const xID = XEUtils.uniqueId();
|
|
50
|
+
const VxeUIFormComponent = VxeUI.getComponent("VxeForm");
|
|
51
|
+
const VxeUIPagerComponent = VxeUI.getComponent("VxePager");
|
|
52
|
+
const defaultLayouts = [["Form"], ["Toolbar", "Top", "Table", "Bottom", "Pager"]];
|
|
53
|
+
const { computeSize } = useFns.useSize(props);
|
|
54
|
+
const { computeIsVScrollbar } = useFns.useVScrollbar(props);
|
|
55
|
+
const reactData = reactive(createReactData());
|
|
56
|
+
const internalData = createInternalData();
|
|
57
|
+
const refElem = ref();
|
|
58
|
+
const refTable = ref();
|
|
59
|
+
const refForm = ref();
|
|
60
|
+
const refToolbar = ref();
|
|
61
|
+
const refPager = ref();
|
|
62
|
+
const refPopupContainerElem = ref();
|
|
63
|
+
const refFormWrapper = ref();
|
|
64
|
+
const refToolbarWrapper = ref();
|
|
65
|
+
const refTopWrapper = ref();
|
|
66
|
+
const refBottomWrapper = ref();
|
|
67
|
+
const refPagerWrapper = ref();
|
|
68
|
+
const extendTableMethods = (methodKeys) => {
|
|
69
|
+
const funcs = {};
|
|
70
|
+
methodKeys.forEach((name) => {
|
|
71
|
+
funcs[name] = (...args) => {
|
|
72
|
+
const $xeTable = refTable.value;
|
|
73
|
+
if ($xeTable && $xeTable[name]) {
|
|
74
|
+
return $xeTable[name](...args);
|
|
75
|
+
}
|
|
80
76
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
77
|
+
});
|
|
78
|
+
return funcs;
|
|
79
|
+
};
|
|
80
|
+
const gridExtendTableMethods = extendTableMethods(tableComponentMethodKeys);
|
|
81
|
+
tableComponentMethodKeys.forEach((name) => {
|
|
82
|
+
gridExtendTableMethods[name] = (...args) => {
|
|
83
|
+
const $xeTable = refTable.value;
|
|
84
|
+
if ($xeTable && $xeTable[name]) {
|
|
85
|
+
return $xeTable && $xeTable[name](...args);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
const computeProxyOpts = computed(() => {
|
|
90
|
+
return XEUtils.merge({}, XEUtils.clone(getConfig().grid.proxyConfig, true), props.proxyConfig);
|
|
91
|
+
});
|
|
92
|
+
const computeIsRespMsg = computed(() => {
|
|
93
|
+
const proxyOpts = computeProxyOpts.value;
|
|
94
|
+
return !!(XEUtils.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg);
|
|
95
|
+
});
|
|
96
|
+
const computeIsActiveMsg = computed(() => {
|
|
97
|
+
const proxyOpts = computeProxyOpts.value;
|
|
98
|
+
return XEUtils.isBoolean(proxyOpts.showActionMsg) ? proxyOpts.showActionMsg : !!proxyOpts.showActiveMsg;
|
|
99
|
+
});
|
|
100
|
+
const computePagerOpts = computed(() => {
|
|
101
|
+
return Object.assign({}, getConfig().grid.pagerConfig, props.pagerConfig);
|
|
102
|
+
});
|
|
103
|
+
const computePagerProps = computed(() => {
|
|
104
|
+
const pagerOpts = computePagerOpts.value;
|
|
105
|
+
return Object.assign({}, pagerOpts, { enabled: void 0, slots: void 0 });
|
|
106
|
+
});
|
|
107
|
+
const computeFormOpts = computed(() => {
|
|
108
|
+
return Object.assign({}, getConfig().grid.formConfig, props.formConfig);
|
|
109
|
+
});
|
|
110
|
+
const computeToolbarOpts = computed(() => {
|
|
111
|
+
return Object.assign({}, getConfig().grid.toolbarConfig, props.toolbarConfig);
|
|
112
|
+
});
|
|
113
|
+
const computeZoomOpts = computed(() => {
|
|
114
|
+
return Object.assign({}, getConfig().grid.zoomConfig, props.zoomConfig);
|
|
115
|
+
});
|
|
116
|
+
const computeStyles = computed(() => {
|
|
117
|
+
const { height, maxHeight } = props;
|
|
118
|
+
const { isZMax, tZindex } = reactData;
|
|
119
|
+
const stys = {};
|
|
120
|
+
if (isZMax) {
|
|
121
|
+
stys.zIndex = tZindex;
|
|
122
|
+
} else {
|
|
123
|
+
if (height) {
|
|
124
|
+
stys.height = height === "auto" || height === "100%" ? "100%" : toCssUnit(height);
|
|
125
|
+
}
|
|
126
|
+
if (maxHeight) {
|
|
127
|
+
stys.maxHeight = maxHeight === "auto" || maxHeight === "100%" ? "100%" : toCssUnit(maxHeight);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return stys;
|
|
131
|
+
});
|
|
132
|
+
const computeTableExtendProps = computed(() => {
|
|
133
|
+
const rest = {};
|
|
134
|
+
tableComponentPropKeys.forEach((key) => {
|
|
135
|
+
if (props[key] !== void 0) {
|
|
136
|
+
rest[key] = props[key];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return rest;
|
|
140
|
+
});
|
|
141
|
+
const computeTableProps = computed(() => {
|
|
142
|
+
const { showFooter, seqConfig, pagerConfig, editConfig, proxyConfig } = props;
|
|
143
|
+
const { isZMax, tablePage, footerData } = reactData;
|
|
144
|
+
const tableExtendProps = computeTableExtendProps.value;
|
|
145
|
+
const proxyOpts = computeProxyOpts.value;
|
|
146
|
+
const pagerOpts = computePagerOpts.value;
|
|
147
|
+
const isLoading = computeIsLoading.value;
|
|
148
|
+
const tProps = Object.assign({}, tableExtendProps);
|
|
149
|
+
if (showFooter && !tProps.footerData) {
|
|
150
|
+
tProps.footerData = footerData;
|
|
151
|
+
} else if (proxyOpts.footer && footerData.length) {
|
|
152
|
+
tProps.footerData = footerData;
|
|
153
|
+
}
|
|
154
|
+
if (isZMax) {
|
|
155
|
+
if (tProps.maxHeight) {
|
|
156
|
+
tProps.maxHeight = "100%";
|
|
157
|
+
} else {
|
|
158
|
+
tProps.height = "100%";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
162
|
+
tProps.loading = isLoading;
|
|
163
|
+
if (pagerConfig && proxyOpts.seq && isEnableConf(pagerOpts)) {
|
|
164
|
+
tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (editConfig) {
|
|
168
|
+
tProps.editConfig = Object.assign({}, editConfig);
|
|
169
|
+
}
|
|
170
|
+
return tProps;
|
|
171
|
+
});
|
|
172
|
+
const computeCurrLayoutConf = computed(() => {
|
|
173
|
+
const { layouts } = props;
|
|
174
|
+
let confs = [];
|
|
175
|
+
if (layouts && layouts.length) {
|
|
176
|
+
confs = layouts;
|
|
177
|
+
} else {
|
|
178
|
+
confs = getConfig().grid.layouts || defaultLayouts;
|
|
179
|
+
}
|
|
180
|
+
let headKeys = [];
|
|
181
|
+
let bodyKeys = [];
|
|
182
|
+
let footKeys = [];
|
|
183
|
+
if (confs.length) {
|
|
184
|
+
if (XEUtils.isArray(confs[0])) {
|
|
185
|
+
headKeys = confs[0];
|
|
186
|
+
bodyKeys = confs[1] || [];
|
|
187
|
+
footKeys = confs[2] || [];
|
|
188
|
+
} else {
|
|
189
|
+
bodyKeys = confs;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
headKeys,
|
|
194
|
+
bodyKeys,
|
|
195
|
+
footKeys
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
const computeCustomCurrentPageFlag = computed(() => {
|
|
199
|
+
const pagerOpts = computePagerOpts.value;
|
|
200
|
+
return pagerOpts.currentPage;
|
|
201
|
+
});
|
|
202
|
+
const computeCustomPageSizeFlag = computed(() => {
|
|
203
|
+
const pagerOpts = computePagerOpts.value;
|
|
204
|
+
return pagerOpts.pageSize;
|
|
205
|
+
});
|
|
206
|
+
const computeCustomTotalFlag = computed(() => {
|
|
207
|
+
const pagerOpts = computePagerOpts.value;
|
|
208
|
+
return pagerOpts.total;
|
|
209
|
+
});
|
|
210
|
+
const computePageCount = computed(() => {
|
|
211
|
+
const { tablePage } = reactData;
|
|
212
|
+
return Math.max(Math.ceil(tablePage.total / tablePage.pageSize), 1);
|
|
213
|
+
});
|
|
214
|
+
const computeIsLoading = computed(() => {
|
|
215
|
+
const { loading, proxyConfig } = props;
|
|
216
|
+
const { tableLoading } = reactData;
|
|
217
|
+
const proxyOpts = computeProxyOpts.value;
|
|
218
|
+
const { showLoading } = proxyOpts;
|
|
219
|
+
return loading || tableLoading && showLoading && proxyConfig && isEnableConf(proxyOpts);
|
|
220
|
+
});
|
|
221
|
+
const refMaps = {
|
|
222
|
+
refElem,
|
|
223
|
+
refTable,
|
|
224
|
+
refForm,
|
|
225
|
+
refToolbar,
|
|
226
|
+
refPager,
|
|
227
|
+
refPopupContainerElem
|
|
228
|
+
};
|
|
229
|
+
const computeMaps = {
|
|
230
|
+
computeSize,
|
|
231
|
+
computeIsVScrollbar,
|
|
232
|
+
computeProxyOpts,
|
|
233
|
+
computePagerOpts,
|
|
234
|
+
computeFormOpts,
|
|
235
|
+
computeToolbarOpts,
|
|
236
|
+
computeZoomOpts
|
|
237
|
+
};
|
|
238
|
+
const $xeGrid = {
|
|
239
|
+
xID,
|
|
240
|
+
props,
|
|
241
|
+
context,
|
|
242
|
+
reactData,
|
|
243
|
+
internalData,
|
|
244
|
+
getRefMaps: () => refMaps,
|
|
245
|
+
getComputeMaps: () => computeMaps
|
|
246
|
+
};
|
|
247
|
+
const initToolbar = () => {
|
|
248
|
+
const toolbarOpts = computeToolbarOpts.value;
|
|
249
|
+
if (props.toolbarConfig && isEnableConf(toolbarOpts)) {
|
|
250
|
+
nextTick(() => {
|
|
251
|
+
const $xeTable = refTable.value;
|
|
252
|
+
const $xeToolbar = refToolbar.value;
|
|
253
|
+
if ($xeTable && $xeToolbar) {
|
|
254
|
+
$xeTable.connectToolbar($xeToolbar);
|
|
255
|
+
}
|
|
107
256
|
});
|
|
108
|
-
|
|
109
|
-
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const getFormData = () => {
|
|
260
|
+
const { proxyConfig } = props;
|
|
261
|
+
const { formData } = reactData;
|
|
262
|
+
const proxyOpts = computeProxyOpts.value;
|
|
263
|
+
const formOpts = computeFormOpts.value;
|
|
264
|
+
return proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data;
|
|
265
|
+
};
|
|
266
|
+
const initPages = (propKey) => {
|
|
267
|
+
const { tablePage } = reactData;
|
|
268
|
+
const { pagerConfig } = props;
|
|
269
|
+
const pagerOpts = computePagerOpts.value;
|
|
270
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
271
|
+
if (propKey) {
|
|
272
|
+
if (pagerOpts[propKey]) {
|
|
273
|
+
tablePage[propKey] = XEUtils.toNumber(pagerOpts[propKey]);
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
const { currentPage, pageSize, total } = pagerOpts;
|
|
277
|
+
if (currentPage) {
|
|
278
|
+
tablePage.currentPage = currentPage;
|
|
279
|
+
}
|
|
280
|
+
if (pageSize) {
|
|
281
|
+
tablePage.pageSize = pageSize;
|
|
282
|
+
}
|
|
283
|
+
if (total) {
|
|
284
|
+
tablePage.total = total;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
const triggerPendingEvent = (code) => {
|
|
290
|
+
const isActiveMsg = computeIsActiveMsg.value;
|
|
291
|
+
const $xeTable = refTable.value;
|
|
292
|
+
const selectRecords = $xeTable ? $xeTable.getCheckboxRecords() : [];
|
|
293
|
+
if (selectRecords.length) {
|
|
294
|
+
if ($xeTable) {
|
|
295
|
+
$xeTable.togglePendingRow(selectRecords);
|
|
296
|
+
}
|
|
297
|
+
$xeGrid.clearCheckboxRow();
|
|
298
|
+
} else {
|
|
299
|
+
if (isActiveMsg) {
|
|
300
|
+
if (VxeUI.modal) {
|
|
301
|
+
VxeUI.modal.message({ id: code, content: getI18n("vxe.grid.selectOneRecord"), status: "warning" });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const getRespMsg = (rest, defaultMsg) => {
|
|
307
|
+
const proxyOpts = computeProxyOpts.value;
|
|
308
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {};
|
|
309
|
+
const messageProp = resConfigs.message;
|
|
310
|
+
const $xeTable = refTable.value;
|
|
311
|
+
let msg;
|
|
312
|
+
if (rest && messageProp) {
|
|
313
|
+
msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: null }) : XEUtils.get(rest, messageProp);
|
|
314
|
+
}
|
|
315
|
+
return msg || getI18n(defaultMsg);
|
|
316
|
+
};
|
|
317
|
+
const handleDeleteRow = (code, alertKey, callback) => {
|
|
318
|
+
const isActiveMsg = computeIsActiveMsg.value;
|
|
319
|
+
const selectRecords = $xeGrid.getCheckboxRecords();
|
|
320
|
+
if (isActiveMsg) {
|
|
321
|
+
if (selectRecords.length) {
|
|
322
|
+
if (VxeUI.modal) {
|
|
323
|
+
return VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
|
|
324
|
+
if (type === "confirm") {
|
|
325
|
+
return callback();
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
if (VxeUI.modal) {
|
|
331
|
+
VxeUI.modal.message({ id: `msg_${code}`, content: getI18n("vxe.grid.selectOneRecord"), status: "warning" });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
if (selectRecords.length) {
|
|
336
|
+
callback();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return Promise.resolve();
|
|
340
|
+
};
|
|
341
|
+
const pageChangeEvent = (params) => {
|
|
342
|
+
const { proxyConfig } = props;
|
|
343
|
+
const { tablePage } = reactData;
|
|
344
|
+
const { $event, currentPage, pageSize } = params;
|
|
345
|
+
const proxyOpts = computeProxyOpts.value;
|
|
346
|
+
tablePage.currentPage = currentPage;
|
|
347
|
+
tablePage.pageSize = pageSize;
|
|
348
|
+
$xeGrid.dispatchEvent("page-change", params, $event);
|
|
349
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
350
|
+
$xeGrid.commitProxy("query").then((rest) => {
|
|
351
|
+
$xeGrid.dispatchEvent("proxy-query", rest, $event);
|
|
110
352
|
});
|
|
111
|
-
|
|
112
|
-
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const handleSortEvent = (params) => {
|
|
356
|
+
const $xeTable = refTable.value;
|
|
357
|
+
const { proxyConfig } = props;
|
|
358
|
+
if (!$xeTable) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const { computeSortOpts } = $xeTable.getComputeMaps();
|
|
362
|
+
const proxyOpts = computeProxyOpts.value;
|
|
363
|
+
const sortOpts = computeSortOpts.value;
|
|
364
|
+
if (sortOpts.remote) {
|
|
365
|
+
reactData.sortData = params.sortList;
|
|
366
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
367
|
+
reactData.tablePage.currentPage = 1;
|
|
368
|
+
$xeGrid.commitProxy("query").then((rest) => {
|
|
369
|
+
$xeGrid.dispatchEvent("proxy-query", rest, params.$event);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const sortChangeEvent = (params) => {
|
|
375
|
+
handleSortEvent(params);
|
|
376
|
+
$xeGrid.dispatchEvent("sort-change", params, params.$event);
|
|
377
|
+
};
|
|
378
|
+
const clearAllSortEvent = (params) => {
|
|
379
|
+
handleSortEvent(params);
|
|
380
|
+
$xeGrid.dispatchEvent("clear-all-sort", params, params.$event);
|
|
381
|
+
};
|
|
382
|
+
const handleFilterEvent = (params) => {
|
|
383
|
+
const $xeTable = refTable.value;
|
|
384
|
+
const { proxyConfig } = props;
|
|
385
|
+
if (!$xeTable) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const { computeFilterOpts } = $xeTable.getComputeMaps();
|
|
389
|
+
const proxyOpts = computeProxyOpts.value;
|
|
390
|
+
const filterOpts = computeFilterOpts.value;
|
|
391
|
+
if (filterOpts.remote) {
|
|
392
|
+
reactData.filterData = params.filterList;
|
|
393
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
394
|
+
reactData.tablePage.currentPage = 1;
|
|
395
|
+
internalData.uFoot = true;
|
|
396
|
+
$xeGrid.commitProxy("query").then((rest) => {
|
|
397
|
+
$xeGrid.dispatchEvent("proxy-query", rest, params.$event);
|
|
398
|
+
});
|
|
399
|
+
internalData.uFoot = false;
|
|
400
|
+
updateQueryFooter();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const filterChangeEvent = (params) => {
|
|
405
|
+
handleFilterEvent(params);
|
|
406
|
+
$xeGrid.dispatchEvent("filter-change", params, params.$event);
|
|
407
|
+
};
|
|
408
|
+
const clearAllFilterEvent = (params) => {
|
|
409
|
+
handleFilterEvent(params);
|
|
410
|
+
$xeGrid.dispatchEvent("clear-all-filter", params, params.$event);
|
|
411
|
+
};
|
|
412
|
+
const submitFormEvent = (params) => {
|
|
413
|
+
const { proxyConfig } = props;
|
|
414
|
+
const proxyOpts = computeProxyOpts.value;
|
|
415
|
+
const formOptions = proxyOpts.formOptions || {};
|
|
416
|
+
if (reactData.tableLoading) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
420
|
+
$xeGrid.dispatchEvent("form-submit", params, params.$event);
|
|
421
|
+
internalData.uFoot = true;
|
|
422
|
+
$xeGrid.commitProxy(formOptions.submitMode || "reload").then((rest) => {
|
|
423
|
+
$xeGrid.dispatchEvent("proxy-query", { ...rest, isReload: true }, params.$event);
|
|
113
424
|
});
|
|
114
|
-
|
|
115
|
-
|
|
425
|
+
internalData.uFoot = false;
|
|
426
|
+
updateQueryFooter();
|
|
427
|
+
} else {
|
|
428
|
+
$xeGrid.dispatchEvent("form-submit", params, params.$event);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
const resetFormEvent = (params) => {
|
|
432
|
+
const $xeTable = refTable.value;
|
|
433
|
+
const { proxyConfig } = props;
|
|
434
|
+
const { $event } = params;
|
|
435
|
+
const proxyOpts = computeProxyOpts.value;
|
|
436
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
437
|
+
const formOptions = proxyOpts.formOptions || {};
|
|
438
|
+
$xeGrid.dispatchEvent("form-reset", params, $event);
|
|
439
|
+
if ($xeTable) {
|
|
440
|
+
$xeTable.clearScroll();
|
|
441
|
+
}
|
|
442
|
+
internalData.uFoot = true;
|
|
443
|
+
$xeGrid.commitProxy(formOptions.resetMode === "reset_form" ? "query" : "reload").then((rest) => {
|
|
444
|
+
$xeGrid.dispatchEvent("proxy-query", { ...rest, isReload: true }, $event);
|
|
116
445
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
446
|
+
internalData.uFoot = false;
|
|
447
|
+
updateQueryFooter();
|
|
448
|
+
} else {
|
|
449
|
+
$xeGrid.dispatchEvent("form-reset", params, $event);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const submitInvalidEvent = (params) => {
|
|
453
|
+
$xeGrid.dispatchEvent("form-submit-invalid", params, params.$event);
|
|
454
|
+
};
|
|
455
|
+
const collapseEvent = (params) => {
|
|
456
|
+
const { $event } = params;
|
|
457
|
+
$xeGrid.dispatchEvent("form-toggle-collapse", params, $event);
|
|
458
|
+
$xeGrid.dispatchEvent("form-collapse", params, $event);
|
|
459
|
+
};
|
|
460
|
+
const handleZoom = (isMax) => {
|
|
461
|
+
const { isZMax } = reactData;
|
|
462
|
+
if (isMax ? !isZMax : isZMax) {
|
|
463
|
+
reactData.isZMax = !isZMax;
|
|
464
|
+
if (reactData.tZindex < getLastZIndex()) {
|
|
465
|
+
reactData.tZindex = nextZIndex();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return nextTick().then(() => $xeGrid.recalculate(true)).then(() => {
|
|
469
|
+
setTimeout(() => $xeGrid.recalculate(true), 15);
|
|
470
|
+
return reactData.isZMax;
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
const getFuncSlot = (optSlots, slotKey) => {
|
|
474
|
+
const funcSlot = optSlots[slotKey];
|
|
475
|
+
if (funcSlot) {
|
|
476
|
+
if (XEUtils.isString(funcSlot)) {
|
|
477
|
+
if (slots[funcSlot]) {
|
|
478
|
+
return slots[funcSlot];
|
|
479
|
+
} else {
|
|
480
|
+
errLog("vxe.error.notSlot", [funcSlot]);
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
return funcSlot;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return null;
|
|
487
|
+
};
|
|
488
|
+
const getConfigSlot = (slotConfigs) => {
|
|
489
|
+
const slotConf = {};
|
|
490
|
+
XEUtils.objectMap(slotConfigs, (slotFunc, slotKey) => {
|
|
491
|
+
if (slotFunc) {
|
|
492
|
+
if (XEUtils.isString(slotFunc)) {
|
|
493
|
+
if (slots[slotFunc]) {
|
|
494
|
+
slotConf[slotKey] = slots[slotFunc];
|
|
495
|
+
} else {
|
|
496
|
+
errLog("vxe.error.notSlot", [slotFunc]);
|
|
123
497
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
498
|
+
} else {
|
|
499
|
+
slotConf[slotKey] = slotFunc;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
return slotConf;
|
|
504
|
+
};
|
|
505
|
+
const renderForm = () => {
|
|
506
|
+
const { formConfig, proxyConfig } = props;
|
|
507
|
+
const { formData } = reactData;
|
|
508
|
+
const proxyOpts = computeProxyOpts.value;
|
|
509
|
+
const formOpts = computeFormOpts.value;
|
|
510
|
+
if (formConfig && isEnableConf(formOpts) || slots.form) {
|
|
511
|
+
let slotVNs = [];
|
|
512
|
+
if (slots.form) {
|
|
513
|
+
slotVNs = slots.form({ $grid: $xeGrid, $gantt: null });
|
|
514
|
+
} else {
|
|
515
|
+
if (formOpts.items) {
|
|
516
|
+
const formSlots = {};
|
|
517
|
+
if (!formOpts.inited) {
|
|
518
|
+
formOpts.inited = true;
|
|
519
|
+
const beforeItem = proxyOpts.beforeItem;
|
|
520
|
+
if (proxyOpts && beforeItem) {
|
|
521
|
+
formOpts.items.forEach((item) => {
|
|
522
|
+
beforeItem({ $grid: $xeGrid, $gantt: null, item });
|
|
523
|
+
});
|
|
524
|
+
}
|
|
131
525
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
rest[key] = props[key];
|
|
526
|
+
formOpts.items.forEach((item) => {
|
|
527
|
+
XEUtils.each(item.slots, (func) => {
|
|
528
|
+
if (func && !XEUtils.isFunction(func)) {
|
|
529
|
+
if (slots[func]) {
|
|
530
|
+
formSlots[func] = slots[func];
|
|
531
|
+
}
|
|
139
532
|
}
|
|
533
|
+
});
|
|
140
534
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
535
|
+
if (VxeUIFormComponent) {
|
|
536
|
+
slotVNs.push(
|
|
537
|
+
h(VxeUIFormComponent, {
|
|
538
|
+
ref: refForm,
|
|
539
|
+
...Object.assign({}, formOpts, {
|
|
540
|
+
data: proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data
|
|
541
|
+
}),
|
|
542
|
+
onSubmit: submitFormEvent,
|
|
543
|
+
onReset: resetFormEvent,
|
|
544
|
+
onSubmitInvalid: submitInvalidEvent,
|
|
545
|
+
onCollapse: collapseEvent
|
|
546
|
+
}, formSlots)
|
|
547
|
+
);
|
|
154
548
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return h("div", {
|
|
552
|
+
ref: refFormWrapper,
|
|
553
|
+
key: "form",
|
|
554
|
+
class: "vxe-grid--form-wrapper"
|
|
555
|
+
}, slotVNs);
|
|
556
|
+
}
|
|
557
|
+
return renderEmptyElement($xeGrid);
|
|
558
|
+
};
|
|
559
|
+
const renderToolbar = () => {
|
|
560
|
+
const { toolbarConfig } = props;
|
|
561
|
+
const toolbarOpts = computeToolbarOpts.value;
|
|
562
|
+
const toolbarSlot = slots.toolbar;
|
|
563
|
+
if (toolbarConfig && isEnableConf(toolbarOpts) || toolbarSlot) {
|
|
564
|
+
let slotVNs = [];
|
|
565
|
+
if (toolbarSlot) {
|
|
566
|
+
slotVNs = toolbarSlot({ $grid: $xeGrid, $gantt: null });
|
|
567
|
+
} else {
|
|
568
|
+
const toolbarOptSlots = toolbarOpts.slots;
|
|
569
|
+
const toolbarSlots = {};
|
|
570
|
+
if (toolbarOptSlots) {
|
|
571
|
+
const buttonsSlot = getFuncSlot(toolbarOptSlots, "buttons");
|
|
572
|
+
const buttonPrefixSlot = getFuncSlot(toolbarOptSlots, "buttonPrefix");
|
|
573
|
+
const buttonSuffixSlot = getFuncSlot(toolbarOptSlots, "buttonSuffix");
|
|
574
|
+
const toolsSlot = getFuncSlot(toolbarOptSlots, "tools");
|
|
575
|
+
const toolPrefixSlot = getFuncSlot(toolbarOptSlots, "toolPrefix");
|
|
576
|
+
const toolSuffixSlot = getFuncSlot(toolbarOptSlots, "toolSuffix");
|
|
577
|
+
if (buttonsSlot) {
|
|
578
|
+
toolbarSlots.buttons = buttonsSlot;
|
|
158
579
|
}
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
tProps.maxHeight = '100%';
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
tProps.height = '100%';
|
|
165
|
-
}
|
|
580
|
+
if (buttonPrefixSlot) {
|
|
581
|
+
toolbarSlots.buttonPrefix = buttonPrefixSlot;
|
|
166
582
|
}
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
if (pagerConfig && proxyOpts.seq && isEnableConf(pagerOpts)) {
|
|
170
|
-
tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize });
|
|
171
|
-
}
|
|
583
|
+
if (buttonSuffixSlot) {
|
|
584
|
+
toolbarSlots.buttonSuffix = buttonSuffixSlot;
|
|
172
585
|
}
|
|
173
|
-
if (
|
|
174
|
-
|
|
586
|
+
if (toolsSlot) {
|
|
587
|
+
toolbarSlots.tools = toolsSlot;
|
|
175
588
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const computeCurrLayoutConf = computed(() => {
|
|
179
|
-
const { layouts } = props;
|
|
180
|
-
let confs = [];
|
|
181
|
-
if (layouts && layouts.length) {
|
|
182
|
-
confs = layouts;
|
|
589
|
+
if (toolPrefixSlot) {
|
|
590
|
+
toolbarSlots.toolPrefix = toolPrefixSlot;
|
|
183
591
|
}
|
|
184
|
-
|
|
185
|
-
|
|
592
|
+
if (toolSuffixSlot) {
|
|
593
|
+
toolbarSlots.toolSuffix = toolSuffixSlot;
|
|
186
594
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
595
|
+
}
|
|
596
|
+
slotVNs.push(
|
|
597
|
+
h(VxeToolbarComponent, {
|
|
598
|
+
ref: refToolbar,
|
|
599
|
+
...toolbarOpts,
|
|
600
|
+
slots: void 0
|
|
601
|
+
}, toolbarSlots)
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
return h("div", {
|
|
605
|
+
ref: refToolbarWrapper,
|
|
606
|
+
key: "toolbar",
|
|
607
|
+
class: "vxe-grid--toolbar-wrapper"
|
|
608
|
+
}, slotVNs);
|
|
609
|
+
}
|
|
610
|
+
return renderEmptyElement($xeGrid);
|
|
611
|
+
};
|
|
612
|
+
const renderTop = () => {
|
|
613
|
+
const topSlot = slots.top;
|
|
614
|
+
if (topSlot) {
|
|
615
|
+
return h("div", {
|
|
616
|
+
ref: refTopWrapper,
|
|
617
|
+
key: "top",
|
|
618
|
+
class: "vxe-grid--top-wrapper"
|
|
619
|
+
}, topSlot({ $grid: $xeGrid, $gantt: null }));
|
|
620
|
+
}
|
|
621
|
+
return renderEmptyElement($xeGrid);
|
|
622
|
+
};
|
|
623
|
+
const renderTableLeft = () => {
|
|
624
|
+
const leftSlot = slots.left;
|
|
625
|
+
if (leftSlot) {
|
|
626
|
+
return h("div", {
|
|
627
|
+
class: "vxe-grid--left-wrapper"
|
|
628
|
+
}, leftSlot({ $grid: $xeGrid, $gantt: null }));
|
|
629
|
+
}
|
|
630
|
+
return renderEmptyElement($xeGrid);
|
|
631
|
+
};
|
|
632
|
+
const renderTableRight = () => {
|
|
633
|
+
const rightSlot = slots.right;
|
|
634
|
+
if (rightSlot) {
|
|
635
|
+
return h("div", {
|
|
636
|
+
class: "vxe-grid--right-wrapper"
|
|
637
|
+
}, rightSlot({ $grid: $xeGrid, $gantt: null }));
|
|
638
|
+
}
|
|
639
|
+
return renderEmptyElement($xeGrid);
|
|
640
|
+
};
|
|
641
|
+
const renderTable = () => {
|
|
642
|
+
const { proxyConfig } = props;
|
|
643
|
+
const tableProps2 = computeTableProps.value;
|
|
644
|
+
const proxyOpts = computeProxyOpts.value;
|
|
645
|
+
const tableOns = Object.assign({}, tableCompEvents);
|
|
646
|
+
const emptySlot = slots.empty;
|
|
647
|
+
const loadingSlot = slots.loading;
|
|
648
|
+
const rowDragIconSlot = slots.rowDragIcon || slots["row-drag-icon"];
|
|
649
|
+
const columnDragIconSlot = slots.columnDragIcon || slots["column-drag-icon"];
|
|
650
|
+
const headerTooltipSlot = slots.headerTooltip || slots["header-tooltip"];
|
|
651
|
+
const tooltipSlot = slots.tooltip;
|
|
652
|
+
const footerTooltipSlot = slots.footerTooltip || slots["footer-tooltip"];
|
|
653
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
654
|
+
if (proxyOpts.sort) {
|
|
655
|
+
tableOns.onSortChange = sortChangeEvent;
|
|
656
|
+
tableOns.onClearAllSort = clearAllSortEvent;
|
|
657
|
+
}
|
|
658
|
+
if (proxyOpts.filter) {
|
|
659
|
+
tableOns.onFilterChange = filterChangeEvent;
|
|
660
|
+
tableOns.onClearAllFilter = clearAllFilterEvent;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const slotObj = {};
|
|
664
|
+
if (emptySlot) {
|
|
665
|
+
slotObj.empty = emptySlot;
|
|
666
|
+
}
|
|
667
|
+
if (loadingSlot) {
|
|
668
|
+
slotObj.loading = loadingSlot;
|
|
669
|
+
}
|
|
670
|
+
if (rowDragIconSlot) {
|
|
671
|
+
slotObj.rowDragIcon = rowDragIconSlot;
|
|
672
|
+
}
|
|
673
|
+
if (columnDragIconSlot) {
|
|
674
|
+
slotObj.columnDragIcon = columnDragIconSlot;
|
|
675
|
+
}
|
|
676
|
+
if (headerTooltipSlot) {
|
|
677
|
+
slotObj.headerTooltip = headerTooltipSlot;
|
|
678
|
+
}
|
|
679
|
+
if (tooltipSlot) {
|
|
680
|
+
slotObj.tooltip = tooltipSlot;
|
|
681
|
+
}
|
|
682
|
+
if (footerTooltipSlot) {
|
|
683
|
+
slotObj.footerTooltip = footerTooltipSlot;
|
|
684
|
+
}
|
|
685
|
+
return h("div", {
|
|
686
|
+
class: "vxe-grid--table-wrapper"
|
|
687
|
+
}, [
|
|
688
|
+
h(VxeTableComponent, {
|
|
689
|
+
ref: refTable,
|
|
690
|
+
...tableProps2,
|
|
691
|
+
...tableOns
|
|
692
|
+
}, slotObj)
|
|
693
|
+
]);
|
|
694
|
+
};
|
|
695
|
+
const renderBottom = () => {
|
|
696
|
+
if (slots.bottom) {
|
|
697
|
+
return h("div", {
|
|
698
|
+
ref: refBottomWrapper,
|
|
699
|
+
key: "bottom",
|
|
700
|
+
class: "vxe-grid--bottom-wrapper"
|
|
701
|
+
}, slots.bottom({ $grid: $xeGrid, $gantt: null }));
|
|
702
|
+
}
|
|
703
|
+
return renderEmptyElement($xeGrid);
|
|
704
|
+
};
|
|
705
|
+
const renderPager = () => {
|
|
706
|
+
const { proxyConfig, pagerConfig } = props;
|
|
707
|
+
const proxyOpts = computeProxyOpts.value;
|
|
708
|
+
const pagerOpts = computePagerOpts.value;
|
|
709
|
+
const pagerProps = computePagerProps.value;
|
|
710
|
+
const pagerSlot = slots.pager;
|
|
711
|
+
if (pagerConfig && isEnableConf(pagerOpts) || slots.pager) {
|
|
712
|
+
return h("div", {
|
|
713
|
+
ref: refPagerWrapper,
|
|
714
|
+
key: "pager",
|
|
715
|
+
class: "vxe-grid--pager-wrapper"
|
|
716
|
+
}, pagerSlot ? pagerSlot({ $grid: $xeGrid, $gantt: null }) : [
|
|
717
|
+
VxeUIPagerComponent ? h(VxeUIPagerComponent, {
|
|
718
|
+
ref: refPager,
|
|
719
|
+
...pagerProps,
|
|
720
|
+
...proxyConfig && isEnableConf(proxyOpts) ? reactData.tablePage : {},
|
|
721
|
+
onPageChange: pageChangeEvent
|
|
722
|
+
}, getConfigSlot(pagerOpts.slots)) : renderEmptyElement($xeGrid)
|
|
723
|
+
]);
|
|
724
|
+
}
|
|
725
|
+
return renderEmptyElement($xeGrid);
|
|
726
|
+
};
|
|
727
|
+
const renderChildLayout = (layoutKeys) => {
|
|
728
|
+
const childVNs = [];
|
|
729
|
+
layoutKeys.forEach((key) => {
|
|
730
|
+
switch (key) {
|
|
731
|
+
case "Form":
|
|
732
|
+
childVNs.push(renderForm());
|
|
733
|
+
break;
|
|
734
|
+
case "Toolbar":
|
|
735
|
+
childVNs.push(renderToolbar());
|
|
736
|
+
break;
|
|
737
|
+
case "Top":
|
|
738
|
+
childVNs.push(renderTop());
|
|
739
|
+
break;
|
|
740
|
+
case "Table":
|
|
741
|
+
childVNs.push(
|
|
742
|
+
h("div", {
|
|
743
|
+
key: "table",
|
|
744
|
+
class: "vxe-grid--table-container"
|
|
745
|
+
}, [
|
|
746
|
+
renderTableLeft(),
|
|
747
|
+
renderTable(),
|
|
748
|
+
renderTableRight()
|
|
749
|
+
])
|
|
750
|
+
);
|
|
751
|
+
break;
|
|
752
|
+
case "Bottom":
|
|
753
|
+
childVNs.push(renderBottom());
|
|
754
|
+
break;
|
|
755
|
+
case "Pager":
|
|
756
|
+
childVNs.push(renderPager());
|
|
757
|
+
break;
|
|
758
|
+
default:
|
|
759
|
+
errLog("vxe.error.notProp", [`layouts -> ${key}`]);
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
return childVNs;
|
|
764
|
+
};
|
|
765
|
+
const renderLayout = () => {
|
|
766
|
+
const currLayoutConf = computeCurrLayoutConf.value;
|
|
767
|
+
const { headKeys, bodyKeys, footKeys } = currLayoutConf;
|
|
768
|
+
const asideLeftSlot = slots.asideLeft || slots["aside-left"];
|
|
769
|
+
const asideRightSlot = slots.asideRight || slots["aside-right"];
|
|
770
|
+
return [
|
|
771
|
+
h("div", {
|
|
772
|
+
class: "vxe-grid--layout-header-wrapper"
|
|
773
|
+
}, renderChildLayout(headKeys)),
|
|
774
|
+
h("div", {
|
|
775
|
+
class: "vxe-grid--layout-body-wrapper"
|
|
776
|
+
}, [
|
|
777
|
+
asideLeftSlot ? h("div", {
|
|
778
|
+
class: "vxe-grid--layout-aside-left-wrapper"
|
|
779
|
+
}, asideLeftSlot({})) : renderEmptyElement($xeGrid),
|
|
780
|
+
h("div", {
|
|
781
|
+
class: "vxe-grid--layout-body-content-wrapper"
|
|
782
|
+
}, renderChildLayout(bodyKeys)),
|
|
783
|
+
asideRightSlot ? h("div", {
|
|
784
|
+
class: "vxe-grid--layout-aside-right-wrapper"
|
|
785
|
+
}, asideRightSlot({})) : renderEmptyElement($xeGrid)
|
|
786
|
+
]),
|
|
787
|
+
h("div", {
|
|
788
|
+
class: "vxe-grid--layout-footer-wrapper"
|
|
789
|
+
}, renderChildLayout(footKeys)),
|
|
790
|
+
h("div", {
|
|
791
|
+
ref: refPopupContainerElem
|
|
792
|
+
})
|
|
793
|
+
];
|
|
794
|
+
};
|
|
795
|
+
const tableCompEvents = {};
|
|
796
|
+
tableEmits.forEach((name) => {
|
|
797
|
+
const type = XEUtils.camelCase(`on-${name}`);
|
|
798
|
+
tableCompEvents[type] = (...args) => emit(name, ...args);
|
|
799
|
+
});
|
|
800
|
+
const getDefaultFormData = () => {
|
|
801
|
+
const formOpts = computeFormOpts.value;
|
|
802
|
+
if (formOpts.items) {
|
|
803
|
+
const fData = {};
|
|
804
|
+
formOpts.items.forEach((item) => {
|
|
805
|
+
const { field, itemRender } = item;
|
|
806
|
+
if (field) {
|
|
807
|
+
let itemValue = null;
|
|
808
|
+
if (itemRender) {
|
|
809
|
+
const { startField, endField, defaultValue } = itemRender;
|
|
810
|
+
if (XEUtils.isFunction(defaultValue)) {
|
|
811
|
+
itemValue = defaultValue({ item });
|
|
812
|
+
} else if (!XEUtils.isUndefined(defaultValue)) {
|
|
813
|
+
itemValue = defaultValue;
|
|
814
|
+
}
|
|
815
|
+
if (startField && endField) {
|
|
816
|
+
XEUtils.set(fData, startField, null);
|
|
817
|
+
XEUtils.set(fData, endField, null);
|
|
818
|
+
}
|
|
199
819
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
bodyKeys,
|
|
203
|
-
footKeys
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
const computeCustomCurrentPageFlag = computed(() => {
|
|
207
|
-
const pagerOpts = computePagerOpts.value;
|
|
208
|
-
return pagerOpts.currentPage;
|
|
209
|
-
});
|
|
210
|
-
const computeCustomPageSizeFlag = computed(() => {
|
|
211
|
-
const pagerOpts = computePagerOpts.value;
|
|
212
|
-
return pagerOpts.pageSize;
|
|
820
|
+
fData[field] = itemValue;
|
|
821
|
+
}
|
|
213
822
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const
|
|
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
|
-
|
|
823
|
+
return fData;
|
|
824
|
+
}
|
|
825
|
+
return {};
|
|
826
|
+
};
|
|
827
|
+
const initProxy = () => {
|
|
828
|
+
const { proxyConfig, formConfig } = props;
|
|
829
|
+
const { proxyInited } = reactData;
|
|
830
|
+
const proxyOpts = computeProxyOpts.value;
|
|
831
|
+
const formOpts = computeFormOpts.value;
|
|
832
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
833
|
+
if (formConfig && isEnableConf(formOpts) && proxyOpts.form && formOpts.items) {
|
|
834
|
+
reactData.formData = getDefaultFormData();
|
|
835
|
+
}
|
|
836
|
+
if (!proxyInited) {
|
|
837
|
+
reactData.proxyInited = true;
|
|
838
|
+
if (proxyOpts.autoLoad !== false) {
|
|
839
|
+
nextTick().then(() => {
|
|
840
|
+
internalData.uFoot = true;
|
|
841
|
+
const rest = $xeGrid.commitProxy("initial");
|
|
842
|
+
internalData.uFoot = false;
|
|
843
|
+
updateQueryFooter();
|
|
844
|
+
return rest;
|
|
845
|
+
}).then((rest) => {
|
|
846
|
+
dispatchEvent("proxy-query", { ...rest, isInited: true }, new Event("initial"));
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
const updateQueryFooter = () => {
|
|
853
|
+
const proxyOpts = computeProxyOpts.value;
|
|
854
|
+
const { ajax } = proxyOpts;
|
|
855
|
+
if (ajax && ajax.queryFooter) {
|
|
856
|
+
return $xeGrid.commitProxy("queryFooter");
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
const handleGlobalKeydownEvent = (evnt) => {
|
|
860
|
+
const zoomOpts = computeZoomOpts.value;
|
|
861
|
+
const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
|
|
862
|
+
if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
|
|
863
|
+
$xeGrid.triggerZoomEvent(evnt);
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
const dispatchEvent = (type, params, evnt) => {
|
|
867
|
+
emit(type, createEvent(evnt, { $grid: $xeGrid, $gantt: null }, params));
|
|
868
|
+
};
|
|
869
|
+
const gridMethods = {
|
|
870
|
+
dispatchEvent,
|
|
871
|
+
getEl() {
|
|
872
|
+
return refElem.value;
|
|
873
|
+
},
|
|
874
|
+
/**
|
|
875
|
+
* 提交指令,支持 code 或 button
|
|
876
|
+
* @param {String/Object} code 字符串或对象
|
|
877
|
+
*/
|
|
878
|
+
commitProxy(proxyTarget, ...args) {
|
|
879
|
+
const { showFooter, proxyConfig, toolbarConfig, pagerConfig, editRules, validConfig } = props;
|
|
880
|
+
const { tablePage } = reactData;
|
|
881
|
+
const isActiveMsg = computeIsActiveMsg.value;
|
|
882
|
+
const isRespMsg = computeIsRespMsg.value;
|
|
883
|
+
const proxyOpts = computeProxyOpts.value;
|
|
884
|
+
const pagerOpts = computePagerOpts.value;
|
|
885
|
+
const toolbarOpts = computeToolbarOpts.value;
|
|
886
|
+
const { beforeQuery: oldBeforeQuery, afterQuery: oldAfterQuery, beforeQueryFooter: oldBeforeQueryFooter, afterQueryFooter: oldAfterQueryFooter, beforeDelete: oldBeforeDelete, afterDelete: oldAfterDelete, beforeSave: oldBeforeSave, afterSave: oldAfterSave, ajax = {} } = proxyOpts;
|
|
887
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {};
|
|
888
|
+
const $xeTable = refTable.value;
|
|
889
|
+
if (!$xeTable) {
|
|
890
|
+
return nextTick();
|
|
891
|
+
}
|
|
892
|
+
let formData = getFormData();
|
|
893
|
+
let button = null;
|
|
894
|
+
let code = null;
|
|
895
|
+
if (XEUtils.isString(proxyTarget)) {
|
|
896
|
+
const { buttons } = toolbarOpts;
|
|
897
|
+
const matchObj = toolbarConfig && isEnableConf(toolbarOpts) && buttons ? XEUtils.findTree(buttons, (item) => item.code === proxyTarget, { children: "dropdowns" }) : null;
|
|
898
|
+
button = matchObj ? matchObj.item : null;
|
|
899
|
+
code = proxyTarget;
|
|
900
|
+
} else {
|
|
901
|
+
button = proxyTarget;
|
|
902
|
+
code = button.code;
|
|
903
|
+
}
|
|
904
|
+
const btnParams = button ? button.params : null;
|
|
905
|
+
switch (code) {
|
|
906
|
+
case "insert":
|
|
907
|
+
return $xeTable.insert({});
|
|
908
|
+
case "insert_edit":
|
|
909
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true));
|
|
910
|
+
// 已废弃
|
|
911
|
+
case "insert_actived":
|
|
912
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true));
|
|
913
|
+
// 已废弃
|
|
914
|
+
case "mark_cancel":
|
|
915
|
+
triggerPendingEvent(code);
|
|
916
|
+
break;
|
|
917
|
+
case "remove":
|
|
918
|
+
return handleDeleteRow(code, "vxe.grid.removeSelectRecord", () => $xeTable.removeCheckboxRow());
|
|
919
|
+
case "import":
|
|
920
|
+
$xeTable.importData(btnParams);
|
|
921
|
+
break;
|
|
922
|
+
case "open_import":
|
|
923
|
+
$xeTable.openImport(btnParams);
|
|
924
|
+
break;
|
|
925
|
+
case "export":
|
|
926
|
+
$xeTable.exportData(btnParams);
|
|
927
|
+
break;
|
|
928
|
+
case "open_export":
|
|
929
|
+
$xeTable.openExport(btnParams);
|
|
930
|
+
break;
|
|
931
|
+
case "reset_custom":
|
|
932
|
+
return $xeTable.resetCustom(true);
|
|
933
|
+
case "initial":
|
|
934
|
+
case "reload":
|
|
935
|
+
case "query": {
|
|
936
|
+
const bqMethod = ajax.beforeQuery;
|
|
937
|
+
const qMethod = ajax.query;
|
|
938
|
+
const aqMethod = ajax.afterQuery;
|
|
939
|
+
const qsMethod = ajax.querySuccess;
|
|
940
|
+
const qeMethod = ajax.queryError;
|
|
941
|
+
if (qMethod) {
|
|
942
|
+
const isInited = code === "initial";
|
|
943
|
+
const isReload = code === "reload";
|
|
944
|
+
if (!isInited && reactData.tableLoading) {
|
|
945
|
+
return nextTick();
|
|
946
|
+
}
|
|
947
|
+
let operPromise = null;
|
|
948
|
+
let sortList = [];
|
|
949
|
+
let filterList = [];
|
|
950
|
+
let pageParams = {};
|
|
951
|
+
if (pagerConfig) {
|
|
952
|
+
if (isInited || isReload) {
|
|
953
|
+
tablePage.currentPage = 1;
|
|
305
954
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
else {
|
|
309
|
-
if (isActiveMsg) {
|
|
310
|
-
if (VxeUI.modal) {
|
|
311
|
-
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
|
|
312
|
-
}
|
|
955
|
+
if (isEnableConf(pagerOpts)) {
|
|
956
|
+
pageParams = { ...tablePage };
|
|
313
957
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const messageProp = resConfigs.message;
|
|
320
|
-
const $xeTable = refTable.value;
|
|
321
|
-
let msg;
|
|
322
|
-
if (rest && messageProp) {
|
|
323
|
-
msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: null }) : XEUtils.get(rest, messageProp);
|
|
324
|
-
}
|
|
325
|
-
return msg || getI18n(defaultMsg);
|
|
326
|
-
};
|
|
327
|
-
const handleDeleteRow = (code, alertKey, callback) => {
|
|
328
|
-
const isActiveMsg = computeIsActiveMsg.value;
|
|
329
|
-
const selectRecords = $xeGrid.getCheckboxRecords();
|
|
330
|
-
if (isActiveMsg) {
|
|
331
|
-
if (selectRecords.length) {
|
|
332
|
-
if (VxeUI.modal) {
|
|
333
|
-
return VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
|
|
334
|
-
if (type === 'confirm') {
|
|
335
|
-
return callback();
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}
|
|
958
|
+
}
|
|
959
|
+
if (isInited) {
|
|
960
|
+
if (proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form) {
|
|
961
|
+
formData = getDefaultFormData();
|
|
962
|
+
reactData.formData = formData;
|
|
339
963
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
964
|
+
if ($xeTable) {
|
|
965
|
+
const tableInternalData = $xeTable.internalData;
|
|
966
|
+
const { tableFullColumn, fullColumnFieldData } = tableInternalData;
|
|
967
|
+
const { computeSortOpts } = $xeTable.getComputeMaps();
|
|
968
|
+
const sortOpts = computeSortOpts.value;
|
|
969
|
+
let defaultSort = sortOpts.defaultSort;
|
|
970
|
+
tableFullColumn.forEach((column) => {
|
|
971
|
+
column.order = null;
|
|
972
|
+
});
|
|
973
|
+
if (defaultSort) {
|
|
974
|
+
if (!XEUtils.isArray(defaultSort)) {
|
|
975
|
+
defaultSort = [defaultSort];
|
|
343
976
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
tablePage.currentPage = currentPage;
|
|
359
|
-
tablePage.pageSize = pageSize;
|
|
360
|
-
$xeGrid.dispatchEvent('page-change', params, $event);
|
|
361
|
-
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
362
|
-
$xeGrid.commitProxy('query').then((rest) => {
|
|
363
|
-
$xeGrid.dispatchEvent('proxy-query', rest, $event);
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
const handleSortEvent = (params) => {
|
|
368
|
-
const $xeTable = refTable.value;
|
|
369
|
-
const { proxyConfig } = props;
|
|
370
|
-
if (!$xeTable) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const { computeSortOpts } = $xeTable.getComputeMaps();
|
|
374
|
-
const proxyOpts = computeProxyOpts.value;
|
|
375
|
-
const sortOpts = computeSortOpts.value;
|
|
376
|
-
// 如果是服务端排序
|
|
377
|
-
if (sortOpts.remote) {
|
|
378
|
-
reactData.sortData = params.sortList;
|
|
379
|
-
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
380
|
-
reactData.tablePage.currentPage = 1;
|
|
381
|
-
$xeGrid.commitProxy('query').then((rest) => {
|
|
382
|
-
$xeGrid.dispatchEvent('proxy-query', rest, params.$event);
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
const sortChangeEvent = (params) => {
|
|
388
|
-
handleSortEvent(params);
|
|
389
|
-
$xeGrid.dispatchEvent('sort-change', params, params.$event);
|
|
390
|
-
};
|
|
391
|
-
const clearAllSortEvent = (params) => {
|
|
392
|
-
handleSortEvent(params);
|
|
393
|
-
$xeGrid.dispatchEvent('clear-all-sort', params, params.$event);
|
|
394
|
-
};
|
|
395
|
-
const handleFilterEvent = (params) => {
|
|
396
|
-
const $xeTable = refTable.value;
|
|
397
|
-
const { proxyConfig } = props;
|
|
398
|
-
if (!$xeTable) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
const { computeFilterOpts } = $xeTable.getComputeMaps();
|
|
402
|
-
const proxyOpts = computeProxyOpts.value;
|
|
403
|
-
const filterOpts = computeFilterOpts.value;
|
|
404
|
-
// 如果是服务端过滤
|
|
405
|
-
if (filterOpts.remote) {
|
|
406
|
-
reactData.filterData = params.filterList;
|
|
407
|
-
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
408
|
-
reactData.tablePage.currentPage = 1;
|
|
409
|
-
internalData.uFoot = true;
|
|
410
|
-
$xeGrid.commitProxy('query').then((rest) => {
|
|
411
|
-
$xeGrid.dispatchEvent('proxy-query', rest, params.$event);
|
|
977
|
+
sortList = defaultSort.map((item) => {
|
|
978
|
+
const { field, order } = item;
|
|
979
|
+
const colRest = fullColumnFieldData[field];
|
|
980
|
+
if (colRest) {
|
|
981
|
+
const column = colRest.column;
|
|
982
|
+
if (column) {
|
|
983
|
+
column.order = order;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return {
|
|
987
|
+
field,
|
|
988
|
+
property: field,
|
|
989
|
+
order
|
|
990
|
+
};
|
|
412
991
|
});
|
|
413
|
-
|
|
414
|
-
|
|
992
|
+
}
|
|
993
|
+
filterList = $xeTable.getCheckedFilters();
|
|
415
994
|
}
|
|
416
|
-
|
|
417
|
-
};
|
|
418
|
-
const filterChangeEvent = (params) => {
|
|
419
|
-
handleFilterEvent(params);
|
|
420
|
-
$xeGrid.dispatchEvent('filter-change', params, params.$event);
|
|
421
|
-
};
|
|
422
|
-
const clearAllFilterEvent = (params) => {
|
|
423
|
-
handleFilterEvent(params);
|
|
424
|
-
$xeGrid.dispatchEvent('clear-all-filter', params, params.$event);
|
|
425
|
-
};
|
|
426
|
-
const submitFormEvent = (params) => {
|
|
427
|
-
const { proxyConfig } = props;
|
|
428
|
-
const proxyOpts = computeProxyOpts.value;
|
|
429
|
-
const formOptions = proxyOpts.formOptions || {};
|
|
430
|
-
if (reactData.tableLoading) {
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
434
|
-
$xeGrid.dispatchEvent('form-submit', params, params.$event);
|
|
435
|
-
internalData.uFoot = true;
|
|
436
|
-
$xeGrid.commitProxy(formOptions.submitMode || 'reload').then((rest) => {
|
|
437
|
-
$xeGrid.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), params.$event);
|
|
438
|
-
});
|
|
439
|
-
internalData.uFoot = false;
|
|
440
|
-
updateQueryFooter();
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
$xeGrid.dispatchEvent('form-submit', params, params.$event);
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
const resetFormEvent = (params) => {
|
|
447
|
-
const $xeTable = refTable.value;
|
|
448
|
-
const { proxyConfig } = props;
|
|
449
|
-
const { $event } = params;
|
|
450
|
-
const proxyOpts = computeProxyOpts.value;
|
|
451
|
-
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
452
|
-
const formOptions = proxyOpts.formOptions || {};
|
|
453
|
-
$xeGrid.dispatchEvent('form-reset', params, $event);
|
|
995
|
+
} else {
|
|
454
996
|
if ($xeTable) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
$
|
|
460
|
-
|
|
461
|
-
internalData.uFoot = false;
|
|
462
|
-
updateQueryFooter();
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
$xeGrid.dispatchEvent('form-reset', params, $event);
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
const submitInvalidEvent = (params) => {
|
|
469
|
-
$xeGrid.dispatchEvent('form-submit-invalid', params, params.$event);
|
|
470
|
-
};
|
|
471
|
-
const collapseEvent = (params) => {
|
|
472
|
-
const { $event } = params;
|
|
473
|
-
$xeGrid.dispatchEvent('form-toggle-collapse', params, $event);
|
|
474
|
-
$xeGrid.dispatchEvent('form-collapse', params, $event);
|
|
475
|
-
};
|
|
476
|
-
const handleZoom = (isMax) => {
|
|
477
|
-
const { isZMax } = reactData;
|
|
478
|
-
if (isMax ? !isZMax : isZMax) {
|
|
479
|
-
reactData.isZMax = !isZMax;
|
|
480
|
-
if (reactData.tZindex < getLastZIndex()) {
|
|
481
|
-
reactData.tZindex = nextZIndex();
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return nextTick()
|
|
485
|
-
.then(() => $xeGrid.recalculate(true))
|
|
486
|
-
.then(() => {
|
|
487
|
-
setTimeout(() => $xeGrid.recalculate(true), 15);
|
|
488
|
-
return reactData.isZMax;
|
|
489
|
-
});
|
|
490
|
-
};
|
|
491
|
-
const getFuncSlot = (optSlots, slotKey) => {
|
|
492
|
-
const funcSlot = optSlots[slotKey];
|
|
493
|
-
if (funcSlot) {
|
|
494
|
-
if (XEUtils.isString(funcSlot)) {
|
|
495
|
-
if (slots[funcSlot]) {
|
|
496
|
-
return slots[funcSlot];
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
errLog('vxe.error.notSlot', [funcSlot]);
|
|
500
|
-
}
|
|
997
|
+
if (isReload) {
|
|
998
|
+
operPromise = $xeTable.clearAll();
|
|
999
|
+
} else {
|
|
1000
|
+
sortList = $xeTable.getSortColumns();
|
|
1001
|
+
filterList = $xeTable.getCheckedFilters();
|
|
1002
|
+
}
|
|
501
1003
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
1004
|
+
}
|
|
1005
|
+
const commitParams = {
|
|
1006
|
+
$table: $xeTable,
|
|
1007
|
+
$grid: $xeGrid,
|
|
1008
|
+
$gantt: null,
|
|
1009
|
+
code,
|
|
1010
|
+
button,
|
|
1011
|
+
isInited,
|
|
1012
|
+
isReload,
|
|
1013
|
+
page: pageParams,
|
|
1014
|
+
sort: sortList.length ? sortList[0] : {},
|
|
1015
|
+
sorts: sortList,
|
|
1016
|
+
filters: filterList,
|
|
1017
|
+
form: formData,
|
|
1018
|
+
options: qMethod
|
|
1019
|
+
};
|
|
1020
|
+
const handleQuery = () => {
|
|
1021
|
+
reactData.sortData = sortList;
|
|
1022
|
+
reactData.filterData = filterList;
|
|
1023
|
+
reactData.tableLoading = true;
|
|
1024
|
+
return Promise.all([
|
|
1025
|
+
Promise.resolve((oldBeforeQuery || qMethod)(commitParams, ...args)),
|
|
1026
|
+
operPromise
|
|
1027
|
+
]).then(([rest]) => {
|
|
1028
|
+
reactData.tableLoading = false;
|
|
1029
|
+
if (aqMethod) {
|
|
1030
|
+
aqMethod({ ...commitParams, response: rest, status: "success" }, ...args);
|
|
1031
|
+
} else {
|
|
1032
|
+
let tableData = [];
|
|
1033
|
+
if (rest) {
|
|
1034
|
+
const listProp = resConfigs.list;
|
|
1035
|
+
const resultProp = resConfigs.result;
|
|
1036
|
+
const reParams = { data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: null };
|
|
1037
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
1038
|
+
const totalProp = resConfigs.total;
|
|
1039
|
+
const total = (XEUtils.isFunction(totalProp) ? totalProp(reParams) : XEUtils.get(rest, totalProp || "page.total")) || 0;
|
|
1040
|
+
tablePage.total = XEUtils.toNumber(total);
|
|
1041
|
+
tableData = (XEUtils.isFunction(resultProp) ? resultProp(reParams) : XEUtils.get(rest, resultProp || "result")) || [];
|
|
1042
|
+
const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1);
|
|
1043
|
+
if (tablePage.currentPage > pageCount) {
|
|
1044
|
+
tablePage.currentPage = pageCount;
|
|
515
1045
|
}
|
|
516
|
-
|
|
517
|
-
|
|
1046
|
+
} else {
|
|
1047
|
+
if (XEUtils.isArray(rest)) {
|
|
1048
|
+
tableData = rest;
|
|
1049
|
+
} else if (listProp) {
|
|
1050
|
+
tableData = (XEUtils.isFunction(listProp) ? listProp(reParams) : XEUtils.get(rest, listProp)) || [];
|
|
518
1051
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return slotConf;
|
|
526
|
-
};
|
|
527
|
-
/**
|
|
528
|
-
* 渲染表单
|
|
529
|
-
*/
|
|
530
|
-
const renderForm = () => {
|
|
531
|
-
const { formConfig, proxyConfig } = props;
|
|
532
|
-
const { formData } = reactData;
|
|
533
|
-
const proxyOpts = computeProxyOpts.value;
|
|
534
|
-
const formOpts = computeFormOpts.value;
|
|
535
|
-
if ((formConfig && isEnableConf(formOpts)) || slots.form) {
|
|
536
|
-
let slotVNs = [];
|
|
537
|
-
if (slots.form) {
|
|
538
|
-
slotVNs = slots.form({ $grid: $xeGrid, $gantt: null });
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
if (formOpts.items) {
|
|
542
|
-
const formSlots = {};
|
|
543
|
-
if (!formOpts.inited) {
|
|
544
|
-
formOpts.inited = true;
|
|
545
|
-
const beforeItem = proxyOpts.beforeItem;
|
|
546
|
-
if (proxyOpts && beforeItem) {
|
|
547
|
-
formOpts.items.forEach((item) => {
|
|
548
|
-
beforeItem({ $grid: $xeGrid, $gantt: null, item });
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
// 处理插槽
|
|
553
|
-
formOpts.items.forEach((item) => {
|
|
554
|
-
XEUtils.each(item.slots, (func) => {
|
|
555
|
-
if (func && !XEUtils.isFunction(func)) {
|
|
556
|
-
if (slots[func]) {
|
|
557
|
-
formSlots[func] = slots[func];
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
if (VxeUIFormComponent) {
|
|
563
|
-
slotVNs.push(h(VxeUIFormComponent, Object.assign(Object.assign({ ref: refForm }, Object.assign({}, formOpts, {
|
|
564
|
-
data: proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data
|
|
565
|
-
})), { onSubmit: submitFormEvent, onReset: resetFormEvent, onSubmitInvalid: submitInvalidEvent, onCollapse: collapseEvent }), formSlots));
|
|
1052
|
+
}
|
|
1053
|
+
if (showFooter) {
|
|
1054
|
+
const fdProp = resConfigs.footerData;
|
|
1055
|
+
const footerList = fdProp ? XEUtils.isFunction(fdProp) ? fdProp(reParams) : XEUtils.get(rest, fdProp) : [];
|
|
1056
|
+
if (XEUtils.isArray(footerList)) {
|
|
1057
|
+
reactData.footerData = footerList;
|
|
566
1058
|
}
|
|
1059
|
+
}
|
|
567
1060
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return renderEmptyElement($xeGrid);
|
|
576
|
-
};
|
|
577
|
-
/**
|
|
578
|
-
* 渲染工具栏
|
|
579
|
-
*/
|
|
580
|
-
const renderToolbar = () => {
|
|
581
|
-
const { toolbarConfig } = props;
|
|
582
|
-
const toolbarOpts = computeToolbarOpts.value;
|
|
583
|
-
const toolbarSlot = slots.toolbar;
|
|
584
|
-
if ((toolbarConfig && isEnableConf(toolbarOpts)) || toolbarSlot) {
|
|
585
|
-
let slotVNs = [];
|
|
586
|
-
if (toolbarSlot) {
|
|
587
|
-
slotVNs = toolbarSlot({ $grid: $xeGrid, $gantt: null });
|
|
588
|
-
}
|
|
589
|
-
else {
|
|
590
|
-
const toolbarOptSlots = toolbarOpts.slots;
|
|
591
|
-
const toolbarSlots = {};
|
|
592
|
-
if (toolbarOptSlots) {
|
|
593
|
-
const buttonsSlot = getFuncSlot(toolbarOptSlots, 'buttons');
|
|
594
|
-
const buttonPrefixSlot = getFuncSlot(toolbarOptSlots, 'buttonPrefix');
|
|
595
|
-
const buttonSuffixSlot = getFuncSlot(toolbarOptSlots, 'buttonSuffix');
|
|
596
|
-
const toolsSlot = getFuncSlot(toolbarOptSlots, 'tools');
|
|
597
|
-
const toolPrefixSlot = getFuncSlot(toolbarOptSlots, 'toolPrefix');
|
|
598
|
-
const toolSuffixSlot = getFuncSlot(toolbarOptSlots, 'toolSuffix');
|
|
599
|
-
if (buttonsSlot) {
|
|
600
|
-
toolbarSlots.buttons = buttonsSlot;
|
|
601
|
-
}
|
|
602
|
-
if (buttonPrefixSlot) {
|
|
603
|
-
toolbarSlots.buttonPrefix = buttonPrefixSlot;
|
|
604
|
-
}
|
|
605
|
-
if (buttonSuffixSlot) {
|
|
606
|
-
toolbarSlots.buttonSuffix = buttonSuffixSlot;
|
|
607
|
-
}
|
|
608
|
-
if (toolsSlot) {
|
|
609
|
-
toolbarSlots.tools = toolsSlot;
|
|
610
|
-
}
|
|
611
|
-
if (toolPrefixSlot) {
|
|
612
|
-
toolbarSlots.toolPrefix = toolPrefixSlot;
|
|
613
|
-
}
|
|
614
|
-
if (toolSuffixSlot) {
|
|
615
|
-
toolbarSlots.toolSuffix = toolSuffixSlot;
|
|
1061
|
+
if ($xeTable) {
|
|
1062
|
+
$xeTable.loadData(tableData);
|
|
1063
|
+
} else {
|
|
1064
|
+
nextTick(() => {
|
|
1065
|
+
const $xeTable2 = refTable.value;
|
|
1066
|
+
if ($xeTable2) {
|
|
1067
|
+
$xeTable2.loadData(tableData);
|
|
616
1068
|
}
|
|
1069
|
+
});
|
|
617
1070
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
return h('div', {
|
|
621
|
-
ref: refToolbarWrapper,
|
|
622
|
-
key: 'toolbar',
|
|
623
|
-
class: 'vxe-grid--toolbar-wrapper'
|
|
624
|
-
}, slotVNs);
|
|
625
|
-
}
|
|
626
|
-
return renderEmptyElement($xeGrid);
|
|
627
|
-
};
|
|
628
|
-
/**
|
|
629
|
-
* 渲染表格顶部区域
|
|
630
|
-
*/
|
|
631
|
-
const renderTop = () => {
|
|
632
|
-
const topSlot = slots.top;
|
|
633
|
-
if (topSlot) {
|
|
634
|
-
return h('div', {
|
|
635
|
-
ref: refTopWrapper,
|
|
636
|
-
key: 'top',
|
|
637
|
-
class: 'vxe-grid--top-wrapper'
|
|
638
|
-
}, topSlot({ $grid: $xeGrid, $gantt: null }));
|
|
639
|
-
}
|
|
640
|
-
return renderEmptyElement($xeGrid);
|
|
641
|
-
};
|
|
642
|
-
const renderTableLeft = () => {
|
|
643
|
-
const leftSlot = slots.left;
|
|
644
|
-
if (leftSlot) {
|
|
645
|
-
return h('div', {
|
|
646
|
-
class: 'vxe-grid--left-wrapper'
|
|
647
|
-
}, leftSlot({ $grid: $xeGrid, $gantt: null }));
|
|
648
|
-
}
|
|
649
|
-
return renderEmptyElement($xeGrid);
|
|
650
|
-
};
|
|
651
|
-
const renderTableRight = () => {
|
|
652
|
-
const rightSlot = slots.right;
|
|
653
|
-
if (rightSlot) {
|
|
654
|
-
return h('div', {
|
|
655
|
-
class: 'vxe-grid--right-wrapper'
|
|
656
|
-
}, rightSlot({ $grid: $xeGrid, $gantt: null }));
|
|
657
|
-
}
|
|
658
|
-
return renderEmptyElement($xeGrid);
|
|
659
|
-
};
|
|
660
|
-
/**
|
|
661
|
-
* 渲染表格
|
|
662
|
-
*/
|
|
663
|
-
const renderTable = () => {
|
|
664
|
-
const { proxyConfig } = props;
|
|
665
|
-
const tableProps = computeTableProps.value;
|
|
666
|
-
const proxyOpts = computeProxyOpts.value;
|
|
667
|
-
const tableOns = Object.assign({}, tableCompEvents);
|
|
668
|
-
const emptySlot = slots.empty;
|
|
669
|
-
const loadingSlot = slots.loading;
|
|
670
|
-
const rowDragIconSlot = slots.rowDragIcon || slots['row-drag-icon'];
|
|
671
|
-
const columnDragIconSlot = slots.columnDragIcon || slots['column-drag-icon'];
|
|
672
|
-
const headerTooltipSlot = slots.headerTooltip || slots['header-tooltip'];
|
|
673
|
-
const tooltipSlot = slots.tooltip;
|
|
674
|
-
const footerTooltipSlot = slots.footerTooltip || slots['footer-tooltip'];
|
|
675
|
-
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
676
|
-
if (proxyOpts.sort) {
|
|
677
|
-
tableOns.onSortChange = sortChangeEvent;
|
|
678
|
-
tableOns.onClearAllSort = clearAllSortEvent;
|
|
679
|
-
}
|
|
680
|
-
if (proxyOpts.filter) {
|
|
681
|
-
tableOns.onFilterChange = filterChangeEvent;
|
|
682
|
-
tableOns.onClearAllFilter = clearAllFilterEvent;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
const slotObj = {};
|
|
686
|
-
if (emptySlot) {
|
|
687
|
-
slotObj.empty = emptySlot;
|
|
688
|
-
}
|
|
689
|
-
if (loadingSlot) {
|
|
690
|
-
slotObj.loading = loadingSlot;
|
|
691
|
-
}
|
|
692
|
-
if (rowDragIconSlot) {
|
|
693
|
-
slotObj.rowDragIcon = rowDragIconSlot;
|
|
694
|
-
}
|
|
695
|
-
if (columnDragIconSlot) {
|
|
696
|
-
slotObj.columnDragIcon = columnDragIconSlot;
|
|
697
|
-
}
|
|
698
|
-
if (headerTooltipSlot) {
|
|
699
|
-
slotObj.headerTooltip = headerTooltipSlot;
|
|
700
|
-
}
|
|
701
|
-
if (tooltipSlot) {
|
|
702
|
-
slotObj.tooltip = tooltipSlot;
|
|
703
|
-
}
|
|
704
|
-
if (footerTooltipSlot) {
|
|
705
|
-
slotObj.footerTooltip = footerTooltipSlot;
|
|
706
|
-
}
|
|
707
|
-
return h('div', {
|
|
708
|
-
class: 'vxe-grid--table-wrapper'
|
|
709
|
-
}, [
|
|
710
|
-
h(VxeTableComponent, Object.assign(Object.assign({ ref: refTable }, tableProps), tableOns), slotObj)
|
|
711
|
-
]);
|
|
712
|
-
};
|
|
713
|
-
/**
|
|
714
|
-
* 渲染表格底部区域
|
|
715
|
-
*/
|
|
716
|
-
const renderBottom = () => {
|
|
717
|
-
if (slots.bottom) {
|
|
718
|
-
return h('div', {
|
|
719
|
-
ref: refBottomWrapper,
|
|
720
|
-
key: 'bottom',
|
|
721
|
-
class: 'vxe-grid--bottom-wrapper'
|
|
722
|
-
}, slots.bottom({ $grid: $xeGrid, $gantt: null }));
|
|
723
|
-
}
|
|
724
|
-
return renderEmptyElement($xeGrid);
|
|
725
|
-
};
|
|
726
|
-
/**
|
|
727
|
-
* 渲染分页
|
|
728
|
-
*/
|
|
729
|
-
const renderPager = () => {
|
|
730
|
-
const { proxyConfig, pagerConfig } = props;
|
|
731
|
-
const proxyOpts = computeProxyOpts.value;
|
|
732
|
-
const pagerOpts = computePagerOpts.value;
|
|
733
|
-
const pagerProps = computePagerProps.value;
|
|
734
|
-
const pagerSlot = slots.pager;
|
|
735
|
-
if ((pagerConfig && isEnableConf(pagerOpts)) || slots.pager) {
|
|
736
|
-
return h('div', {
|
|
737
|
-
ref: refPagerWrapper,
|
|
738
|
-
key: 'pager',
|
|
739
|
-
class: 'vxe-grid--pager-wrapper'
|
|
740
|
-
}, pagerSlot
|
|
741
|
-
? pagerSlot({ $grid: $xeGrid, $gantt: null })
|
|
742
|
-
: [
|
|
743
|
-
VxeUIPagerComponent
|
|
744
|
-
? h(VxeUIPagerComponent, Object.assign(Object.assign(Object.assign({ ref: refPager }, pagerProps), (proxyConfig && isEnableConf(proxyOpts) ? reactData.tablePage : {})), { onPageChange: pageChangeEvent }), getConfigSlot(pagerOpts.slots))
|
|
745
|
-
: renderEmptyElement($xeGrid)
|
|
746
|
-
]);
|
|
747
|
-
}
|
|
748
|
-
return renderEmptyElement($xeGrid);
|
|
749
|
-
};
|
|
750
|
-
const renderChildLayout = (layoutKeys) => {
|
|
751
|
-
const childVNs = [];
|
|
752
|
-
layoutKeys.forEach(key => {
|
|
753
|
-
switch (key) {
|
|
754
|
-
case 'Form':
|
|
755
|
-
childVNs.push(renderForm());
|
|
756
|
-
break;
|
|
757
|
-
case 'Toolbar':
|
|
758
|
-
childVNs.push(renderToolbar());
|
|
759
|
-
break;
|
|
760
|
-
case 'Top':
|
|
761
|
-
childVNs.push(renderTop());
|
|
762
|
-
break;
|
|
763
|
-
case 'Table':
|
|
764
|
-
childVNs.push(h('div', {
|
|
765
|
-
key: 'table',
|
|
766
|
-
class: 'vxe-grid--table-container'
|
|
767
|
-
}, [
|
|
768
|
-
renderTableLeft(),
|
|
769
|
-
renderTable(),
|
|
770
|
-
renderTableRight()
|
|
771
|
-
]));
|
|
772
|
-
break;
|
|
773
|
-
case 'Bottom':
|
|
774
|
-
childVNs.push(renderBottom());
|
|
775
|
-
break;
|
|
776
|
-
case 'Pager':
|
|
777
|
-
childVNs.push(renderPager());
|
|
778
|
-
break;
|
|
779
|
-
default:
|
|
780
|
-
errLog('vxe.error.notProp', [`layouts -> ${key}`]);
|
|
781
|
-
break;
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
return childVNs;
|
|
785
|
-
};
|
|
786
|
-
const renderLayout = () => {
|
|
787
|
-
const currLayoutConf = computeCurrLayoutConf.value;
|
|
788
|
-
const { headKeys, bodyKeys, footKeys } = currLayoutConf;
|
|
789
|
-
const asideLeftSlot = slots.asideLeft || slots['aside-left'];
|
|
790
|
-
const asideRightSlot = slots.asideRight || slots['aside-right'];
|
|
791
|
-
return [
|
|
792
|
-
h('div', {
|
|
793
|
-
class: 'vxe-grid--layout-header-wrapper'
|
|
794
|
-
}, renderChildLayout(headKeys)),
|
|
795
|
-
h('div', {
|
|
796
|
-
class: 'vxe-grid--layout-body-wrapper'
|
|
797
|
-
}, [
|
|
798
|
-
asideLeftSlot
|
|
799
|
-
? h('div', {
|
|
800
|
-
class: 'vxe-grid--layout-aside-left-wrapper'
|
|
801
|
-
}, asideLeftSlot({}))
|
|
802
|
-
: renderEmptyElement($xeGrid),
|
|
803
|
-
h('div', {
|
|
804
|
-
class: 'vxe-grid--layout-body-content-wrapper'
|
|
805
|
-
}, renderChildLayout(bodyKeys)),
|
|
806
|
-
asideRightSlot
|
|
807
|
-
? h('div', {
|
|
808
|
-
class: 'vxe-grid--layout-aside-right-wrapper'
|
|
809
|
-
}, asideRightSlot({}))
|
|
810
|
-
: renderEmptyElement($xeGrid)
|
|
811
|
-
]),
|
|
812
|
-
h('div', {
|
|
813
|
-
class: 'vxe-grid--layout-footer-wrapper'
|
|
814
|
-
}, renderChildLayout(footKeys)),
|
|
815
|
-
h('div', {
|
|
816
|
-
ref: refPopupContainerElem
|
|
817
|
-
})
|
|
818
|
-
];
|
|
819
|
-
};
|
|
820
|
-
const tableCompEvents = {};
|
|
821
|
-
tableEmits.forEach(name => {
|
|
822
|
-
const type = XEUtils.camelCase(`on-${name}`);
|
|
823
|
-
tableCompEvents[type] = (...args) => emit(name, ...args);
|
|
824
|
-
});
|
|
825
|
-
const getDefaultFormData = () => {
|
|
826
|
-
const formOpts = computeFormOpts.value;
|
|
827
|
-
if (formOpts.items) {
|
|
828
|
-
const fData = {};
|
|
829
|
-
formOpts.items.forEach(item => {
|
|
830
|
-
const { field, itemRender } = item;
|
|
831
|
-
if (field) {
|
|
832
|
-
let itemValue = null;
|
|
833
|
-
if (itemRender) {
|
|
834
|
-
const { startField, endField, defaultValue } = itemRender;
|
|
835
|
-
if (XEUtils.isFunction(defaultValue)) {
|
|
836
|
-
itemValue = defaultValue({ item });
|
|
837
|
-
}
|
|
838
|
-
else if (!XEUtils.isUndefined(defaultValue)) {
|
|
839
|
-
itemValue = defaultValue;
|
|
840
|
-
}
|
|
841
|
-
if (startField && endField) {
|
|
842
|
-
XEUtils.set(fData, startField, null);
|
|
843
|
-
XEUtils.set(fData, endField, null);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
fData[field] = itemValue;
|
|
1071
|
+
if (oldAfterQuery) {
|
|
1072
|
+
oldAfterQuery({ ...commitParams, response: rest }, ...args);
|
|
847
1073
|
}
|
|
1074
|
+
}
|
|
1075
|
+
if (qsMethod) {
|
|
1076
|
+
qsMethod({ ...commitParams, response: rest });
|
|
1077
|
+
}
|
|
1078
|
+
return { status: true };
|
|
1079
|
+
}).catch((rest) => {
|
|
1080
|
+
reactData.tableLoading = false;
|
|
1081
|
+
if (aqMethod) {
|
|
1082
|
+
aqMethod({ ...commitParams, response: rest, status: "error" }, ...args);
|
|
1083
|
+
}
|
|
1084
|
+
if (qeMethod) {
|
|
1085
|
+
qeMethod({ ...commitParams, response: rest });
|
|
1086
|
+
}
|
|
1087
|
+
return { status: false };
|
|
1088
|
+
});
|
|
1089
|
+
};
|
|
1090
|
+
if (bqMethod) {
|
|
1091
|
+
return Promise.resolve(bqMethod(commitParams, ...args)).then((status) => {
|
|
1092
|
+
if (status !== false) {
|
|
1093
|
+
return handleQuery();
|
|
1094
|
+
}
|
|
848
1095
|
});
|
|
849
|
-
|
|
1096
|
+
}
|
|
1097
|
+
return handleQuery();
|
|
1098
|
+
} else {
|
|
1099
|
+
errLog("vxe.error.notFunc", ["proxy-config.ajax.query"]);
|
|
850
1100
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
const
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
case "queryFooter":
|
|
1104
|
+
case "query_footer": {
|
|
1105
|
+
const bqfMethod = ajax.beforeQueryFooter;
|
|
1106
|
+
const qfMethod = ajax.queryFooter;
|
|
1107
|
+
const aqfMethod = ajax.afterQueryFooter;
|
|
1108
|
+
const qfSuccessMethod = ajax.queryFooterSuccess;
|
|
1109
|
+
const qfErrorMethod = ajax.queryFooterError;
|
|
1110
|
+
if (qfMethod) {
|
|
1111
|
+
let filterList = [];
|
|
1112
|
+
if ($xeTable) {
|
|
1113
|
+
filterList = $xeTable.getCheckedFilters();
|
|
1114
|
+
}
|
|
1115
|
+
let pageParams = {};
|
|
1116
|
+
if (pagerConfig) {
|
|
1117
|
+
if (isEnableConf(pagerOpts)) {
|
|
1118
|
+
pageParams = { ...tablePage };
|
|
861
1119
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
1120
|
+
}
|
|
1121
|
+
const commitParams = {
|
|
1122
|
+
$table: $xeTable,
|
|
1123
|
+
$grid: $xeGrid,
|
|
1124
|
+
$gantt: null,
|
|
1125
|
+
code,
|
|
1126
|
+
button,
|
|
1127
|
+
page: pageParams,
|
|
1128
|
+
filters: filterList,
|
|
1129
|
+
form: formData,
|
|
1130
|
+
options: qfMethod
|
|
1131
|
+
};
|
|
1132
|
+
const handleQueryFooter = () => {
|
|
1133
|
+
return Promise.resolve((oldBeforeQueryFooter || qfMethod)(commitParams, ...args)).then((rest) => {
|
|
1134
|
+
if (aqfMethod) {
|
|
1135
|
+
aqfMethod({ ...commitParams, response: rest, status: "success" }, ...args);
|
|
1136
|
+
} else {
|
|
1137
|
+
reactData.footerData = XEUtils.isArray(rest) ? rest : [];
|
|
1138
|
+
if (oldAfterQueryFooter) {
|
|
1139
|
+
oldAfterQueryFooter({ ...commitParams, response: rest }, ...args);
|
|
874
1140
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1141
|
+
}
|
|
1142
|
+
if (qfSuccessMethod) {
|
|
1143
|
+
qfSuccessMethod({ ...commitParams, response: rest });
|
|
1144
|
+
}
|
|
1145
|
+
return { status: true };
|
|
1146
|
+
}).catch((rest) => {
|
|
1147
|
+
if (aqfMethod) {
|
|
1148
|
+
aqfMethod({ ...commitParams, response: rest, status: "error" }, ...args);
|
|
1149
|
+
}
|
|
1150
|
+
if (qfErrorMethod) {
|
|
1151
|
+
qfErrorMethod({ ...commitParams, response: rest });
|
|
1152
|
+
}
|
|
1153
|
+
return { status: false };
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
if (bqfMethod) {
|
|
1157
|
+
return Promise.resolve(bqfMethod(commitParams, ...args)).then((status) => {
|
|
1158
|
+
if (status !== false) {
|
|
1159
|
+
return handleQueryFooter();
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
return handleQueryFooter();
|
|
1164
|
+
} else {
|
|
1165
|
+
errLog("vxe.error.notFunc", ["proxy-config.ajax.queryFooter"]);
|
|
890
1166
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
return
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
931
|
-
const btnParams = button ? button.params : null;
|
|
932
|
-
switch (code) {
|
|
933
|
-
case 'insert':
|
|
934
|
-
return $xeTable.insert({});
|
|
935
|
-
case 'insert_edit':
|
|
936
|
-
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true));
|
|
937
|
-
// 已废弃
|
|
938
|
-
case 'insert_actived':
|
|
939
|
-
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true));
|
|
940
|
-
// 已废弃
|
|
941
|
-
case 'mark_cancel':
|
|
942
|
-
triggerPendingEvent(code);
|
|
943
|
-
break;
|
|
944
|
-
case 'remove':
|
|
945
|
-
return handleDeleteRow(code, 'vxe.grid.removeSelectRecord', () => $xeTable.removeCheckboxRow());
|
|
946
|
-
case 'import':
|
|
947
|
-
$xeTable.importData(btnParams);
|
|
948
|
-
break;
|
|
949
|
-
case 'open_import':
|
|
950
|
-
$xeTable.openImport(btnParams);
|
|
951
|
-
break;
|
|
952
|
-
case 'export':
|
|
953
|
-
$xeTable.exportData(btnParams);
|
|
954
|
-
break;
|
|
955
|
-
case 'open_export':
|
|
956
|
-
$xeTable.openExport(btnParams);
|
|
957
|
-
break;
|
|
958
|
-
case 'reset_custom':
|
|
959
|
-
return $xeTable.resetCustom(true);
|
|
960
|
-
case 'initial':
|
|
961
|
-
case 'reload':
|
|
962
|
-
case 'query': {
|
|
963
|
-
const bqMethod = ajax.beforeQuery;
|
|
964
|
-
const qMethod = ajax.query;
|
|
965
|
-
const aqMethod = ajax.afterQuery;
|
|
966
|
-
const qsMethod = ajax.querySuccess;
|
|
967
|
-
const qeMethod = ajax.queryError;
|
|
968
|
-
if (qMethod) {
|
|
969
|
-
const isInited = code === 'initial';
|
|
970
|
-
const isReload = code === 'reload';
|
|
971
|
-
if (!isInited && reactData.tableLoading) {
|
|
972
|
-
return nextTick();
|
|
973
|
-
}
|
|
974
|
-
let operPromise = null;
|
|
975
|
-
let sortList = [];
|
|
976
|
-
let filterList = [];
|
|
977
|
-
let pageParams = {};
|
|
978
|
-
if (pagerConfig) {
|
|
979
|
-
if (isInited || isReload) {
|
|
980
|
-
// 重置分页
|
|
981
|
-
tablePage.currentPage = 1;
|
|
982
|
-
}
|
|
983
|
-
if (isEnableConf(pagerOpts)) {
|
|
984
|
-
pageParams = Object.assign({}, tablePage);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
if (isInited) {
|
|
988
|
-
// 重置代理表单数据
|
|
989
|
-
if (proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form) {
|
|
990
|
-
formData = getDefaultFormData();
|
|
991
|
-
reactData.formData = formData;
|
|
992
|
-
}
|
|
993
|
-
if ($xeTable) {
|
|
994
|
-
const tableInternalData = $xeTable.internalData;
|
|
995
|
-
const { tableFullColumn, fullColumnFieldData } = tableInternalData;
|
|
996
|
-
const { computeSortOpts } = $xeTable.getComputeMaps();
|
|
997
|
-
const sortOpts = computeSortOpts.value;
|
|
998
|
-
let defaultSort = sortOpts.defaultSort;
|
|
999
|
-
tableFullColumn.forEach((column) => {
|
|
1000
|
-
column.order = null;
|
|
1001
|
-
});
|
|
1002
|
-
// 如果使用默认排序
|
|
1003
|
-
if (defaultSort) {
|
|
1004
|
-
if (!XEUtils.isArray(defaultSort)) {
|
|
1005
|
-
defaultSort = [defaultSort];
|
|
1006
|
-
}
|
|
1007
|
-
sortList = defaultSort.map((item) => {
|
|
1008
|
-
const { field, order } = item;
|
|
1009
|
-
const colRest = fullColumnFieldData[field];
|
|
1010
|
-
if (colRest) {
|
|
1011
|
-
const column = colRest.column;
|
|
1012
|
-
if (column) {
|
|
1013
|
-
column.order = order;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
return {
|
|
1017
|
-
field,
|
|
1018
|
-
property: field,
|
|
1019
|
-
order
|
|
1020
|
-
};
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
filterList = $xeTable.getCheckedFilters();
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
else {
|
|
1027
|
-
if ($xeTable) {
|
|
1028
|
-
if (isReload) {
|
|
1029
|
-
operPromise = $xeTable.clearAll();
|
|
1030
|
-
}
|
|
1031
|
-
else {
|
|
1032
|
-
sortList = $xeTable.getSortColumns();
|
|
1033
|
-
filterList = $xeTable.getCheckedFilters();
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
const commitParams = {
|
|
1038
|
-
$table: $xeTable,
|
|
1039
|
-
$grid: $xeGrid,
|
|
1040
|
-
$gantt: null,
|
|
1041
|
-
code,
|
|
1042
|
-
button,
|
|
1043
|
-
isInited,
|
|
1044
|
-
isReload,
|
|
1045
|
-
page: pageParams,
|
|
1046
|
-
sort: sortList.length ? sortList[0] : {},
|
|
1047
|
-
sorts: sortList,
|
|
1048
|
-
filters: filterList,
|
|
1049
|
-
form: formData,
|
|
1050
|
-
options: qMethod
|
|
1051
|
-
};
|
|
1052
|
-
const handleQuery = () => {
|
|
1053
|
-
reactData.sortData = sortList;
|
|
1054
|
-
reactData.filterData = filterList;
|
|
1055
|
-
reactData.tableLoading = true;
|
|
1056
|
-
return Promise.all([
|
|
1057
|
-
Promise.resolve((oldBeforeQuery || qMethod)(commitParams, ...args)),
|
|
1058
|
-
operPromise
|
|
1059
|
-
]).then(([rest]) => {
|
|
1060
|
-
reactData.tableLoading = false;
|
|
1061
|
-
if (aqMethod) {
|
|
1062
|
-
aqMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'success' }), ...args);
|
|
1063
|
-
}
|
|
1064
|
-
else {
|
|
1065
|
-
let tableData = [];
|
|
1066
|
-
if (rest) {
|
|
1067
|
-
const listProp = resConfigs.list;
|
|
1068
|
-
const resultProp = resConfigs.result;
|
|
1069
|
-
const reParams = { data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: null };
|
|
1070
|
-
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
1071
|
-
const totalProp = resConfigs.total;
|
|
1072
|
-
const total = (XEUtils.isFunction(totalProp) ? totalProp(reParams) : XEUtils.get(rest, totalProp || 'page.total')) || 0;
|
|
1073
|
-
tablePage.total = XEUtils.toNumber(total);
|
|
1074
|
-
tableData = (XEUtils.isFunction(resultProp) ? resultProp(reParams) : XEUtils.get(rest, resultProp || 'result')) || [];
|
|
1075
|
-
// 检验当前页码,不能超出当前最大页数
|
|
1076
|
-
const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1);
|
|
1077
|
-
if (tablePage.currentPage > pageCount) {
|
|
1078
|
-
tablePage.currentPage = pageCount;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
else {
|
|
1082
|
-
if (XEUtils.isArray(rest)) {
|
|
1083
|
-
tableData = rest;
|
|
1084
|
-
}
|
|
1085
|
-
else if (listProp) {
|
|
1086
|
-
tableData = (XEUtils.isFunction(listProp) ? listProp(reParams) : XEUtils.get(rest, listProp)) || [];
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
if (showFooter) {
|
|
1090
|
-
const fdProp = resConfigs.footerData;
|
|
1091
|
-
const footerList = fdProp ? (XEUtils.isFunction(fdProp) ? fdProp(reParams) : XEUtils.get(rest, fdProp)) : [];
|
|
1092
|
-
if (XEUtils.isArray(footerList)) {
|
|
1093
|
-
reactData.footerData = footerList;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
if ($xeTable) {
|
|
1098
|
-
$xeTable.loadData(tableData);
|
|
1099
|
-
}
|
|
1100
|
-
else {
|
|
1101
|
-
nextTick(() => {
|
|
1102
|
-
const $xeTable = refTable.value;
|
|
1103
|
-
if ($xeTable) {
|
|
1104
|
-
$xeTable.loadData(tableData);
|
|
1105
|
-
}
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
if (oldAfterQuery) {
|
|
1109
|
-
oldAfterQuery(Object.assign(Object.assign({}, commitParams), { response: rest }), ...args);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
if (qsMethod) {
|
|
1113
|
-
qsMethod(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1114
|
-
}
|
|
1115
|
-
return { status: true };
|
|
1116
|
-
}).catch((rest) => {
|
|
1117
|
-
reactData.tableLoading = false;
|
|
1118
|
-
if (aqMethod) {
|
|
1119
|
-
aqMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'error' }), ...args);
|
|
1120
|
-
}
|
|
1121
|
-
if (qeMethod) {
|
|
1122
|
-
qeMethod(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1123
|
-
}
|
|
1124
|
-
return { status: false };
|
|
1125
|
-
});
|
|
1126
|
-
};
|
|
1127
|
-
if (bqMethod) {
|
|
1128
|
-
return Promise.resolve(bqMethod(commitParams, ...args)).then(status => {
|
|
1129
|
-
if (status !== false) {
|
|
1130
|
-
return handleQuery();
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
return handleQuery();
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
case "delete": {
|
|
1170
|
+
const bdMethod = ajax.beforeDelete;
|
|
1171
|
+
const dMethod = ajax.delete;
|
|
1172
|
+
const adMethod = ajax.afterDelete;
|
|
1173
|
+
const deleteSuccessMethods = ajax.deleteSuccess;
|
|
1174
|
+
const deleteErrorMethods = ajax.deleteError;
|
|
1175
|
+
if (dMethod) {
|
|
1176
|
+
const selectRecords = $xeGrid.getCheckboxRecords();
|
|
1177
|
+
const removeRecords = selectRecords.filter((row) => !$xeTable.isInsertByRow(row));
|
|
1178
|
+
const body = { removeRecords };
|
|
1179
|
+
const commitParams = {
|
|
1180
|
+
$table: $xeTable,
|
|
1181
|
+
$grid: $xeGrid,
|
|
1182
|
+
$gantt: null,
|
|
1183
|
+
code,
|
|
1184
|
+
button,
|
|
1185
|
+
body,
|
|
1186
|
+
form: formData,
|
|
1187
|
+
options: dMethod
|
|
1188
|
+
};
|
|
1189
|
+
if (selectRecords.length) {
|
|
1190
|
+
return handleDeleteRow(code, "vxe.grid.deleteSelectRecord", () => {
|
|
1191
|
+
if (!removeRecords.length) {
|
|
1192
|
+
return $xeTable.remove(selectRecords);
|
|
1193
|
+
}
|
|
1194
|
+
const handleDelete = () => {
|
|
1195
|
+
reactData.tableLoading = true;
|
|
1196
|
+
return Promise.resolve((oldBeforeDelete || dMethod)(commitParams, ...args)).then((rest) => {
|
|
1197
|
+
reactData.tableLoading = false;
|
|
1198
|
+
if (adMethod) {
|
|
1199
|
+
adMethod({ ...commitParams, response: rest, status: "success" }, ...args);
|
|
1200
|
+
} else {
|
|
1201
|
+
$xeTable.setPendingRow(removeRecords, false);
|
|
1202
|
+
if (isRespMsg) {
|
|
1203
|
+
if (VxeUI.modal) {
|
|
1204
|
+
VxeUI.modal.message({ content: getRespMsg(rest, "vxe.grid.delSuccess"), status: "success" });
|
|
1205
|
+
}
|
|
1135
1206
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1207
|
+
if (oldAfterDelete) {
|
|
1208
|
+
oldAfterDelete({ ...commitParams, response: rest }, ...args);
|
|
1209
|
+
} else {
|
|
1210
|
+
internalData.uFoot = true;
|
|
1211
|
+
$xeGrid.commitProxy("query");
|
|
1212
|
+
internalData.uFoot = false;
|
|
1213
|
+
updateQueryFooter();
|
|
1138
1214
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
let pageParams = {};
|
|
1154
|
-
if (pagerConfig) {
|
|
1155
|
-
if (isEnableConf(pagerOpts)) {
|
|
1156
|
-
pageParams = Object.assign({}, tablePage);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
const commitParams = {
|
|
1160
|
-
$table: $xeTable,
|
|
1161
|
-
$grid: $xeGrid,
|
|
1162
|
-
$gantt: null,
|
|
1163
|
-
code,
|
|
1164
|
-
button,
|
|
1165
|
-
page: pageParams,
|
|
1166
|
-
filters: filterList,
|
|
1167
|
-
form: formData,
|
|
1168
|
-
options: qfMethod
|
|
1169
|
-
};
|
|
1170
|
-
const handleQueryFooter = () => {
|
|
1171
|
-
return Promise.resolve((oldBeforeQueryFooter || qfMethod)(commitParams, ...args)).then(rest => {
|
|
1172
|
-
if (aqfMethod) {
|
|
1173
|
-
aqfMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'success' }), ...args);
|
|
1174
|
-
}
|
|
1175
|
-
else {
|
|
1176
|
-
reactData.footerData = XEUtils.isArray(rest) ? rest : [];
|
|
1177
|
-
if (oldAfterQueryFooter) {
|
|
1178
|
-
oldAfterQueryFooter(Object.assign(Object.assign({}, commitParams), { response: rest }), ...args);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
if (qfSuccessMethod) {
|
|
1182
|
-
qfSuccessMethod(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1183
|
-
}
|
|
1184
|
-
return { status: true };
|
|
1185
|
-
}).catch((rest) => {
|
|
1186
|
-
if (aqfMethod) {
|
|
1187
|
-
aqfMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'error' }), ...args);
|
|
1188
|
-
}
|
|
1189
|
-
if (qfErrorMethod) {
|
|
1190
|
-
qfErrorMethod(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1191
|
-
}
|
|
1192
|
-
return { status: false };
|
|
1193
|
-
});
|
|
1194
|
-
};
|
|
1195
|
-
if (bqfMethod) {
|
|
1196
|
-
return Promise.resolve(bqfMethod(commitParams, ...args)).then(status => {
|
|
1197
|
-
if (status !== false) {
|
|
1198
|
-
return handleQueryFooter();
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
return handleQueryFooter();
|
|
1203
|
-
}
|
|
1204
|
-
else {
|
|
1205
|
-
errLog('vxe.error.notFunc', ['proxy-config.ajax.queryFooter']);
|
|
1206
|
-
}
|
|
1207
|
-
break;
|
|
1208
|
-
}
|
|
1209
|
-
case 'delete': {
|
|
1210
|
-
const bdMethod = ajax.beforeDelete;
|
|
1211
|
-
const dMethod = ajax.delete;
|
|
1212
|
-
const adMethod = ajax.afterDelete;
|
|
1213
|
-
const deleteSuccessMethods = ajax.deleteSuccess;
|
|
1214
|
-
const deleteErrorMethods = ajax.deleteError;
|
|
1215
|
-
if (dMethod) {
|
|
1216
|
-
const selectRecords = $xeGrid.getCheckboxRecords();
|
|
1217
|
-
const removeRecords = selectRecords.filter(row => !$xeTable.isInsertByRow(row));
|
|
1218
|
-
const body = { removeRecords };
|
|
1219
|
-
const commitParams = {
|
|
1220
|
-
$table: $xeTable,
|
|
1221
|
-
$grid: $xeGrid,
|
|
1222
|
-
$gantt: null,
|
|
1223
|
-
code,
|
|
1224
|
-
button,
|
|
1225
|
-
body,
|
|
1226
|
-
form: formData,
|
|
1227
|
-
options: dMethod
|
|
1228
|
-
};
|
|
1229
|
-
if (selectRecords.length) {
|
|
1230
|
-
return handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => {
|
|
1231
|
-
if (!removeRecords.length) {
|
|
1232
|
-
return $xeTable.remove(selectRecords);
|
|
1233
|
-
}
|
|
1234
|
-
const handleDelete = () => {
|
|
1235
|
-
reactData.tableLoading = true;
|
|
1236
|
-
return Promise.resolve((oldBeforeDelete || dMethod)(commitParams, ...args))
|
|
1237
|
-
.then(rest => {
|
|
1238
|
-
reactData.tableLoading = false;
|
|
1239
|
-
if (adMethod) {
|
|
1240
|
-
adMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'success' }), ...args);
|
|
1241
|
-
}
|
|
1242
|
-
else {
|
|
1243
|
-
$xeTable.setPendingRow(removeRecords, false);
|
|
1244
|
-
if (isRespMsg) {
|
|
1245
|
-
if (VxeUI.modal) {
|
|
1246
|
-
VxeUI.modal.message({ content: getRespMsg(rest, 'vxe.grid.delSuccess'), status: 'success' });
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
if (oldAfterDelete) {
|
|
1250
|
-
oldAfterDelete(Object.assign(Object.assign({}, commitParams), { response: rest }), ...args);
|
|
1251
|
-
}
|
|
1252
|
-
else {
|
|
1253
|
-
internalData.uFoot = true;
|
|
1254
|
-
$xeGrid.commitProxy('query');
|
|
1255
|
-
internalData.uFoot = false;
|
|
1256
|
-
updateQueryFooter();
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
if (deleteSuccessMethods) {
|
|
1260
|
-
deleteSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1261
|
-
}
|
|
1262
|
-
return { status: true };
|
|
1263
|
-
})
|
|
1264
|
-
.catch(rest => {
|
|
1265
|
-
reactData.tableLoading = false;
|
|
1266
|
-
if (adMethod) {
|
|
1267
|
-
adMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'error' }), ...args);
|
|
1268
|
-
}
|
|
1269
|
-
else {
|
|
1270
|
-
if (isRespMsg) {
|
|
1271
|
-
if (VxeUI.modal) {
|
|
1272
|
-
VxeUI.modal.message({ id: code, content: getRespMsg(rest, 'vxe.grid.operError'), status: 'error' });
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
if (deleteErrorMethods) {
|
|
1277
|
-
deleteErrorMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1278
|
-
}
|
|
1279
|
-
return { status: false };
|
|
1280
|
-
});
|
|
1281
|
-
};
|
|
1282
|
-
if (bdMethod) {
|
|
1283
|
-
return Promise.resolve(bdMethod(commitParams, ...args)).then(status => {
|
|
1284
|
-
if (status !== false) {
|
|
1285
|
-
return handleDelete();
|
|
1286
|
-
}
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
return handleDelete();
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
else {
|
|
1293
|
-
if (isActiveMsg) {
|
|
1294
|
-
if (VxeUI.modal) {
|
|
1295
|
-
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' });
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
else {
|
|
1301
|
-
errLog('vxe.error.notFunc', ['proxy-config.ajax.delete']);
|
|
1215
|
+
}
|
|
1216
|
+
if (deleteSuccessMethods) {
|
|
1217
|
+
deleteSuccessMethods({ ...commitParams, response: rest });
|
|
1218
|
+
}
|
|
1219
|
+
return { status: true };
|
|
1220
|
+
}).catch((rest) => {
|
|
1221
|
+
reactData.tableLoading = false;
|
|
1222
|
+
if (adMethod) {
|
|
1223
|
+
adMethod({ ...commitParams, response: rest, status: "error" }, ...args);
|
|
1224
|
+
} else {
|
|
1225
|
+
if (isRespMsg) {
|
|
1226
|
+
if (VxeUI.modal) {
|
|
1227
|
+
VxeUI.modal.message({ id: code, content: getRespMsg(rest, "vxe.grid.operError"), status: "error" });
|
|
1228
|
+
}
|
|
1302
1229
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
// 排除掉新增且标记为删除的数据
|
|
1325
|
-
if (insertRecords.length) {
|
|
1326
|
-
body.pendingRecords = pendingRecords.filter((row) => $xeTable.findRowIndexOf(insertRecords, row) === -1);
|
|
1327
|
-
}
|
|
1328
|
-
// 排除已标记为删除的数据
|
|
1329
|
-
if (pendingRecords.length) {
|
|
1330
|
-
body.insertRecords = insertRecords.filter((row) => $xeTable.findRowIndexOf(pendingRecords, row) === -1);
|
|
1331
|
-
}
|
|
1332
|
-
let restPromise = Promise.resolve();
|
|
1333
|
-
if (editRules) {
|
|
1334
|
-
// 只校验新增和修改的数据
|
|
1335
|
-
restPromise = $xeTable[validConfig && validConfig.msgMode === 'full' ? 'fullValidate' : 'validate'](body.insertRecords.concat(updateRecords));
|
|
1336
|
-
}
|
|
1337
|
-
return restPromise.then((errMap) => {
|
|
1338
|
-
if (errMap) {
|
|
1339
|
-
// 如果校验不通过
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) {
|
|
1343
|
-
const handleSave = () => {
|
|
1344
|
-
reactData.tableLoading = true;
|
|
1345
|
-
return Promise.resolve((oldBeforeSave || sMethod)(commitParams, ...args))
|
|
1346
|
-
.then(rest => {
|
|
1347
|
-
reactData.tableLoading = false;
|
|
1348
|
-
if (aSaveMethod) {
|
|
1349
|
-
aSaveMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'success' }), ...args);
|
|
1350
|
-
}
|
|
1351
|
-
else {
|
|
1352
|
-
$xeTable.clearPendingRow();
|
|
1353
|
-
if (isRespMsg) {
|
|
1354
|
-
if (VxeUI.modal) {
|
|
1355
|
-
VxeUI.modal.message({ content: getRespMsg(rest, 'vxe.grid.saveSuccess'), status: 'success' });
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
if (oldAfterSave) {
|
|
1359
|
-
oldAfterSave(Object.assign(Object.assign({}, commitParams), { response: rest }), ...args);
|
|
1360
|
-
}
|
|
1361
|
-
else {
|
|
1362
|
-
internalData.uFoot = true;
|
|
1363
|
-
$xeGrid.commitProxy('query');
|
|
1364
|
-
internalData.uFoot = false;
|
|
1365
|
-
updateQueryFooter();
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
if (sSuccessMethod) {
|
|
1369
|
-
sSuccessMethod(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1370
|
-
}
|
|
1371
|
-
return { status: true };
|
|
1372
|
-
})
|
|
1373
|
-
.catch(rest => {
|
|
1374
|
-
reactData.tableLoading = false;
|
|
1375
|
-
if (aSaveMethod) {
|
|
1376
|
-
aSaveMethod(Object.assign(Object.assign({}, commitParams), { response: rest, status: 'error' }), ...args);
|
|
1377
|
-
}
|
|
1378
|
-
else {
|
|
1379
|
-
if (isRespMsg) {
|
|
1380
|
-
if (VxeUI.modal) {
|
|
1381
|
-
VxeUI.modal.message({ id: code, content: getRespMsg(rest, 'vxe.grid.operError'), status: 'error' });
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
if (sErrorMethod) {
|
|
1386
|
-
sErrorMethod(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1387
|
-
}
|
|
1388
|
-
return { status: false };
|
|
1389
|
-
});
|
|
1390
|
-
};
|
|
1391
|
-
if (bSaveMethod) {
|
|
1392
|
-
return Promise.resolve(bSaveMethod(commitParams, ...args)).then(status => {
|
|
1393
|
-
if (status !== false) {
|
|
1394
|
-
return handleSave();
|
|
1395
|
-
}
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
return handleSave();
|
|
1399
|
-
}
|
|
1400
|
-
else {
|
|
1401
|
-
if (isActiveMsg) {
|
|
1402
|
-
if (VxeUI.modal) {
|
|
1403
|
-
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.dataUnchanged'), status: 'info' });
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
else {
|
|
1410
|
-
errLog('vxe.error.notFunc', ['proxy-config.ajax.save']);
|
|
1411
|
-
}
|
|
1412
|
-
break;
|
|
1413
|
-
}
|
|
1414
|
-
default: {
|
|
1415
|
-
const gCommandOpts = commands.get(code);
|
|
1416
|
-
if (gCommandOpts) {
|
|
1417
|
-
const tCommandMethod = gCommandOpts.tableCommandMethod || gCommandOpts.commandMethod;
|
|
1418
|
-
if (tCommandMethod) {
|
|
1419
|
-
tCommandMethod({ code, button, $grid: $xeGrid, $table: $xeTable, $gantt: null }, ...args);
|
|
1420
|
-
}
|
|
1421
|
-
else {
|
|
1422
|
-
errLog('vxe.error.notCommands', [code]);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
return nextTick();
|
|
1428
|
-
},
|
|
1429
|
-
getParams() {
|
|
1430
|
-
return props.params;
|
|
1431
|
-
},
|
|
1432
|
-
zoom() {
|
|
1433
|
-
if (reactData.isZMax) {
|
|
1434
|
-
return $xeGrid.revert();
|
|
1435
|
-
}
|
|
1436
|
-
return $xeGrid.maximize();
|
|
1437
|
-
},
|
|
1438
|
-
isMaximized() {
|
|
1439
|
-
return reactData.isZMax;
|
|
1440
|
-
},
|
|
1441
|
-
maximize() {
|
|
1442
|
-
return handleZoom(true);
|
|
1443
|
-
},
|
|
1444
|
-
revert() {
|
|
1445
|
-
return handleZoom();
|
|
1446
|
-
},
|
|
1447
|
-
getFormData,
|
|
1448
|
-
/**
|
|
1449
|
-
* 已废弃,被 getFormFlatItems 替换
|
|
1450
|
-
* @deprecated
|
|
1451
|
-
*/
|
|
1452
|
-
getFormItems(itemIndex) {
|
|
1453
|
-
const formOpts = computeFormOpts.value;
|
|
1454
|
-
const { formConfig } = props;
|
|
1455
|
-
const { items } = formOpts;
|
|
1456
|
-
const itemList = [];
|
|
1457
|
-
XEUtils.eachTree(formConfig && isEnableConf(formOpts) && items ? items : [], item => {
|
|
1458
|
-
itemList.push(item);
|
|
1459
|
-
}, { children: 'children' });
|
|
1460
|
-
// errLog('vxe.error.delFunc', ['getFormItems', 'getFormFlatItems'])
|
|
1461
|
-
return XEUtils.isUndefined(itemIndex) ? itemList : itemList[itemIndex];
|
|
1462
|
-
},
|
|
1463
|
-
getFormFlatItems() {
|
|
1464
|
-
const $form = refForm.value;
|
|
1465
|
-
if ($form) {
|
|
1466
|
-
return $form.getFlatItems();
|
|
1467
|
-
}
|
|
1468
|
-
return [];
|
|
1469
|
-
},
|
|
1470
|
-
getFormNestedItems() {
|
|
1471
|
-
const $form = refForm.value;
|
|
1472
|
-
if ($form) {
|
|
1473
|
-
return $form.getNestedItems();
|
|
1474
|
-
}
|
|
1475
|
-
return [];
|
|
1476
|
-
},
|
|
1477
|
-
getFormItemByField(field) {
|
|
1478
|
-
const $form = refForm.value;
|
|
1479
|
-
if ($form) {
|
|
1480
|
-
return $form.getItemByField(field);
|
|
1481
|
-
}
|
|
1482
|
-
return null;
|
|
1483
|
-
},
|
|
1484
|
-
resetForm() {
|
|
1485
|
-
const $form = refForm.value;
|
|
1486
|
-
if ($form) {
|
|
1487
|
-
return $form.reset();
|
|
1488
|
-
}
|
|
1489
|
-
return nextTick();
|
|
1490
|
-
},
|
|
1491
|
-
validateForm() {
|
|
1492
|
-
const $form = refForm.value;
|
|
1493
|
-
if ($form) {
|
|
1494
|
-
return $form.validate();
|
|
1495
|
-
}
|
|
1496
|
-
return Promise.resolve();
|
|
1497
|
-
},
|
|
1498
|
-
validateFormField(field) {
|
|
1499
|
-
const $form = refForm.value;
|
|
1500
|
-
if ($form) {
|
|
1501
|
-
return $form.validateField(field);
|
|
1502
|
-
}
|
|
1503
|
-
return Promise.resolve();
|
|
1504
|
-
},
|
|
1505
|
-
clearFormValidate(field) {
|
|
1506
|
-
const $form = refForm.value;
|
|
1507
|
-
if ($form) {
|
|
1508
|
-
return $form.clearValidate(field);
|
|
1509
|
-
}
|
|
1510
|
-
return nextTick();
|
|
1511
|
-
},
|
|
1512
|
-
homePage() {
|
|
1513
|
-
const { tablePage } = reactData;
|
|
1514
|
-
tablePage.currentPage = 1;
|
|
1515
|
-
return nextTick();
|
|
1516
|
-
},
|
|
1517
|
-
homePageByEvent(evnt) {
|
|
1518
|
-
const $pager = refPager.value;
|
|
1519
|
-
if ($pager) {
|
|
1520
|
-
$pager.homePageByEvent(evnt);
|
|
1521
|
-
}
|
|
1522
|
-
},
|
|
1523
|
-
endPage() {
|
|
1524
|
-
const { tablePage } = reactData;
|
|
1525
|
-
const pageCount = computePageCount.value;
|
|
1526
|
-
tablePage.currentPage = pageCount;
|
|
1527
|
-
return nextTick();
|
|
1528
|
-
},
|
|
1529
|
-
endPageByEvent(evnt) {
|
|
1530
|
-
const $pager = refPager.value;
|
|
1531
|
-
if ($pager) {
|
|
1532
|
-
$pager.endPageByEvent(evnt);
|
|
1533
|
-
}
|
|
1534
|
-
},
|
|
1535
|
-
getCurrentPage() {
|
|
1536
|
-
const { tablePage } = reactData;
|
|
1537
|
-
return tablePage.currentPage;
|
|
1538
|
-
},
|
|
1539
|
-
setCurrentPage(currentPage) {
|
|
1540
|
-
const { tablePage } = reactData;
|
|
1541
|
-
const pageCount = computePageCount.value;
|
|
1542
|
-
tablePage.currentPage = Math.min(pageCount, Math.max(1, XEUtils.toNumber(currentPage)));
|
|
1543
|
-
return nextTick();
|
|
1544
|
-
},
|
|
1545
|
-
setCurrentPageByEvent(evnt, currentPage) {
|
|
1546
|
-
const $pager = refPager.value;
|
|
1547
|
-
if ($pager) {
|
|
1548
|
-
$pager.setCurrentPageByEvent(evnt, currentPage);
|
|
1549
|
-
}
|
|
1550
|
-
},
|
|
1551
|
-
getPageSize() {
|
|
1552
|
-
const { tablePage } = reactData;
|
|
1553
|
-
return tablePage.pageSize;
|
|
1554
|
-
},
|
|
1555
|
-
setPageSize(pageSize) {
|
|
1556
|
-
const { tablePage } = reactData;
|
|
1557
|
-
tablePage.pageSize = Math.max(1, XEUtils.toNumber(pageSize));
|
|
1558
|
-
return nextTick();
|
|
1559
|
-
},
|
|
1560
|
-
setPageSizeByEvent(evnt, pageSize) {
|
|
1561
|
-
const $pager = refPager.value;
|
|
1562
|
-
if ($pager) {
|
|
1563
|
-
$pager.setPageSizeByEvent(evnt, pageSize);
|
|
1564
|
-
}
|
|
1565
|
-
},
|
|
1566
|
-
getProxyInfo() {
|
|
1567
|
-
const $xeTable = refTable.value;
|
|
1568
|
-
if (props.proxyConfig) {
|
|
1569
|
-
const { sortData } = reactData;
|
|
1570
|
-
return {
|
|
1571
|
-
data: $xeTable ? $xeTable.getFullData() : [],
|
|
1572
|
-
filter: reactData.filterData,
|
|
1573
|
-
form: getFormData(),
|
|
1574
|
-
sort: sortData.length ? sortData[0] : {},
|
|
1575
|
-
sorts: sortData,
|
|
1576
|
-
pager: reactData.tablePage,
|
|
1577
|
-
pendingRecords: $xeTable ? $xeTable.getPendingRecords() : []
|
|
1578
|
-
};
|
|
1579
|
-
}
|
|
1580
|
-
return null;
|
|
1581
|
-
},
|
|
1582
|
-
getCustomPagerData() {
|
|
1583
|
-
const { pagerConfig } = props;
|
|
1584
|
-
const { tablePage } = reactData;
|
|
1585
|
-
const pagerOpts = computePagerOpts.value;
|
|
1586
|
-
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
1587
|
-
return {
|
|
1588
|
-
pSize: tablePage.pageSize
|
|
1589
|
-
};
|
|
1230
|
+
}
|
|
1231
|
+
if (deleteErrorMethods) {
|
|
1232
|
+
deleteErrorMethods({ ...commitParams, response: rest });
|
|
1233
|
+
}
|
|
1234
|
+
return { status: false };
|
|
1235
|
+
});
|
|
1236
|
+
};
|
|
1237
|
+
if (bdMethod) {
|
|
1238
|
+
return Promise.resolve(bdMethod(commitParams, ...args)).then((status) => {
|
|
1239
|
+
if (status !== false) {
|
|
1240
|
+
return handleDelete();
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
return handleDelete();
|
|
1245
|
+
});
|
|
1246
|
+
} else {
|
|
1247
|
+
if (isActiveMsg) {
|
|
1248
|
+
if (VxeUI.modal) {
|
|
1249
|
+
VxeUI.modal.message({ id: code, content: getI18n("vxe.grid.selectOneRecord"), status: "warning" });
|
|
1250
|
+
}
|
|
1590
1251
|
}
|
|
1591
|
-
|
|
1252
|
+
}
|
|
1253
|
+
} else {
|
|
1254
|
+
errLog("vxe.error.notFunc", ["proxy-config.ajax.delete"]);
|
|
1592
1255
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
*/
|
|
1628
|
-
getExcludeHeight() {
|
|
1629
|
-
const { height } = props;
|
|
1630
|
-
const { isZMax } = reactData;
|
|
1631
|
-
const el = refElem.value;
|
|
1632
|
-
if (el) {
|
|
1633
|
-
const formWrapper = refFormWrapper.value;
|
|
1634
|
-
const toolbarWrapper = refToolbarWrapper.value;
|
|
1635
|
-
const topWrapper = refTopWrapper.value;
|
|
1636
|
-
const bottomWrapper = refBottomWrapper.value;
|
|
1637
|
-
const pagerWrapper = refPagerWrapper.value;
|
|
1638
|
-
const parentEl = el.parentElement;
|
|
1639
|
-
let parentPaddingSize = 0;
|
|
1640
|
-
if (parentEl && (height === '100%' || height === 'auto')) {
|
|
1641
|
-
parentPaddingSize = isZMax ? 0 : getPaddingTopBottomSize(parentEl);
|
|
1642
|
-
}
|
|
1643
|
-
return parentPaddingSize + getPaddingTopBottomSize(el) + getOffsetHeight(formWrapper) + getOffsetHeight(toolbarWrapper) + getOffsetHeight(topWrapper) + getOffsetHeight(bottomWrapper) + getOffsetHeight(pagerWrapper);
|
|
1644
|
-
}
|
|
1645
|
-
return 0;
|
|
1646
|
-
},
|
|
1647
|
-
getParentElem() {
|
|
1648
|
-
const el = refElem.value;
|
|
1649
|
-
if (!el) {
|
|
1650
|
-
return null;
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
case "save": {
|
|
1259
|
+
const bSaveMethod = ajax.beforeSave;
|
|
1260
|
+
const sMethod = ajax.save;
|
|
1261
|
+
const aSaveMethod = ajax.afterSave;
|
|
1262
|
+
const sSuccessMethod = ajax.saveSuccess;
|
|
1263
|
+
const sErrorMethod = ajax.saveError;
|
|
1264
|
+
if (sMethod) {
|
|
1265
|
+
const body = $xeTable.getRecordset();
|
|
1266
|
+
const { insertRecords, removeRecords, updateRecords, pendingRecords } = body;
|
|
1267
|
+
const commitParams = {
|
|
1268
|
+
$table: $xeTable,
|
|
1269
|
+
$grid: $xeGrid,
|
|
1270
|
+
$gantt: null,
|
|
1271
|
+
code,
|
|
1272
|
+
button,
|
|
1273
|
+
body,
|
|
1274
|
+
form: formData,
|
|
1275
|
+
options: sMethod
|
|
1276
|
+
};
|
|
1277
|
+
if (insertRecords.length) {
|
|
1278
|
+
body.pendingRecords = pendingRecords.filter((row) => $xeTable.findRowIndexOf(insertRecords, row) === -1);
|
|
1279
|
+
}
|
|
1280
|
+
if (pendingRecords.length) {
|
|
1281
|
+
body.insertRecords = insertRecords.filter((row) => $xeTable.findRowIndexOf(pendingRecords, row) === -1);
|
|
1282
|
+
}
|
|
1283
|
+
let restPromise = Promise.resolve();
|
|
1284
|
+
if (editRules) {
|
|
1285
|
+
restPromise = $xeTable[validConfig && validConfig.msgMode === "full" ? "fullValidate" : "validate"](body.insertRecords.concat(updateRecords));
|
|
1286
|
+
}
|
|
1287
|
+
return restPromise.then((errMap) => {
|
|
1288
|
+
if (errMap) {
|
|
1289
|
+
return;
|
|
1651
1290
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
return 0;
|
|
1666
|
-
},
|
|
1667
|
-
triggerToolbarCommitEvent(params, evnt) {
|
|
1668
|
-
const { code } = params;
|
|
1669
|
-
if (code) {
|
|
1670
|
-
const isUf = ['reload', 'delete', 'save'].includes(code);
|
|
1671
|
-
if (isUf) {
|
|
1672
|
-
internalData.uFoot = true;
|
|
1673
|
-
}
|
|
1674
|
-
const rest = $xeGrid.commitProxy(params, evnt).then((rest) => {
|
|
1675
|
-
if (rest && rest.status && ['query', 'reload', 'delete', 'save'].includes(code)) {
|
|
1676
|
-
$xeGrid.dispatchEvent(code === 'delete' || code === 'save' ? `proxy-${code}` : 'proxy-query', Object.assign(Object.assign({}, rest), { isReload: code === 'reload' }), evnt);
|
|
1291
|
+
if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) {
|
|
1292
|
+
const handleSave = () => {
|
|
1293
|
+
reactData.tableLoading = true;
|
|
1294
|
+
return Promise.resolve((oldBeforeSave || sMethod)(commitParams, ...args)).then((rest) => {
|
|
1295
|
+
reactData.tableLoading = false;
|
|
1296
|
+
if (aSaveMethod) {
|
|
1297
|
+
aSaveMethod({ ...commitParams, response: rest, status: "success" }, ...args);
|
|
1298
|
+
} else {
|
|
1299
|
+
$xeTable.clearPendingRow();
|
|
1300
|
+
if (isRespMsg) {
|
|
1301
|
+
if (VxeUI.modal) {
|
|
1302
|
+
VxeUI.modal.message({ content: getRespMsg(rest, "vxe.grid.saveSuccess"), status: "success" });
|
|
1303
|
+
}
|
|
1677
1304
|
}
|
|
1305
|
+
if (oldAfterSave) {
|
|
1306
|
+
oldAfterSave({ ...commitParams, response: rest }, ...args);
|
|
1307
|
+
} else {
|
|
1308
|
+
internalData.uFoot = true;
|
|
1309
|
+
$xeGrid.commitProxy("query");
|
|
1310
|
+
internalData.uFoot = false;
|
|
1311
|
+
updateQueryFooter();
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
if (sSuccessMethod) {
|
|
1315
|
+
sSuccessMethod({ ...commitParams, response: rest });
|
|
1316
|
+
}
|
|
1317
|
+
return { status: true };
|
|
1318
|
+
}).catch((rest) => {
|
|
1319
|
+
reactData.tableLoading = false;
|
|
1320
|
+
if (aSaveMethod) {
|
|
1321
|
+
aSaveMethod({ ...commitParams, response: rest, status: "error" }, ...args);
|
|
1322
|
+
} else {
|
|
1323
|
+
if (isRespMsg) {
|
|
1324
|
+
if (VxeUI.modal) {
|
|
1325
|
+
VxeUI.modal.message({ id: code, content: getRespMsg(rest, "vxe.grid.operError"), status: "error" });
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
if (sErrorMethod) {
|
|
1330
|
+
sErrorMethod({ ...commitParams, response: rest });
|
|
1331
|
+
}
|
|
1332
|
+
return { status: false };
|
|
1333
|
+
});
|
|
1334
|
+
};
|
|
1335
|
+
if (bSaveMethod) {
|
|
1336
|
+
return Promise.resolve(bSaveMethod(commitParams, ...args)).then((status) => {
|
|
1337
|
+
if (status !== false) {
|
|
1338
|
+
return handleSave();
|
|
1339
|
+
}
|
|
1678
1340
|
});
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1341
|
+
}
|
|
1342
|
+
return handleSave();
|
|
1343
|
+
} else {
|
|
1344
|
+
if (isActiveMsg) {
|
|
1345
|
+
if (VxeUI.modal) {
|
|
1346
|
+
VxeUI.modal.message({ id: code, content: getI18n("vxe.grid.dataUnchanged"), status: "info" });
|
|
1682
1347
|
}
|
|
1683
|
-
|
|
1348
|
+
}
|
|
1684
1349
|
}
|
|
1685
|
-
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
$xeGrid.triggerToolbarCommitEvent(button, evnt);
|
|
1689
|
-
$xeGrid.dispatchEvent('toolbar-button-click', { code: button.code, button }, evnt);
|
|
1690
|
-
},
|
|
1691
|
-
triggerToolbarTolEvent(tool, evnt) {
|
|
1692
|
-
$xeGrid.triggerToolbarCommitEvent(tool, evnt);
|
|
1693
|
-
$xeGrid.dispatchEvent('toolbar-tool-click', { code: tool.code, tool }, evnt);
|
|
1694
|
-
},
|
|
1695
|
-
triggerZoomEvent(evnt) {
|
|
1696
|
-
$xeGrid.zoom();
|
|
1697
|
-
$xeGrid.dispatchEvent('zoom', { type: reactData.isZMax ? 'max' : 'revert' }, evnt);
|
|
1350
|
+
});
|
|
1351
|
+
} else {
|
|
1352
|
+
errLog("vxe.error.notFunc", ["proxy-config.ajax.save"]);
|
|
1698
1353
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
});
|
|
1715
|
-
if ($xeTable) {
|
|
1716
|
-
return $xeTable.loadColumn(columns);
|
|
1717
|
-
}
|
|
1718
|
-
return nextTick();
|
|
1719
|
-
},
|
|
1720
|
-
reloadColumn(columns) {
|
|
1721
|
-
$xeGrid.clearAll();
|
|
1722
|
-
return $xeGrid.loadColumn(columns);
|
|
1354
|
+
break;
|
|
1355
|
+
}
|
|
1356
|
+
default: {
|
|
1357
|
+
const gCommandOpts = commands.get(code);
|
|
1358
|
+
if (gCommandOpts) {
|
|
1359
|
+
const tCommandMethod = gCommandOpts.tableCommandMethod || gCommandOpts.commandMethod;
|
|
1360
|
+
if (tCommandMethod) {
|
|
1361
|
+
tCommandMethod({ code, button, $grid: $xeGrid, $table: $xeTable, $gantt: null }, ...args);
|
|
1362
|
+
} else {
|
|
1363
|
+
errLog("vxe.error.notCommands", [code]);
|
|
1364
|
+
}
|
|
1723
1365
|
}
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
return nextTick();
|
|
1369
|
+
},
|
|
1370
|
+
getParams() {
|
|
1371
|
+
return props.params;
|
|
1372
|
+
},
|
|
1373
|
+
zoom() {
|
|
1374
|
+
if (reactData.isZMax) {
|
|
1375
|
+
return $xeGrid.revert();
|
|
1376
|
+
}
|
|
1377
|
+
return $xeGrid.maximize();
|
|
1378
|
+
},
|
|
1379
|
+
isMaximized() {
|
|
1380
|
+
return reactData.isZMax;
|
|
1381
|
+
},
|
|
1382
|
+
maximize() {
|
|
1383
|
+
return handleZoom(true);
|
|
1384
|
+
},
|
|
1385
|
+
revert() {
|
|
1386
|
+
return handleZoom();
|
|
1387
|
+
},
|
|
1388
|
+
getFormData,
|
|
1389
|
+
/**
|
|
1390
|
+
* 已废弃,被 getFormFlatItems 替换
|
|
1391
|
+
* @deprecated
|
|
1392
|
+
*/
|
|
1393
|
+
getFormItems(itemIndex) {
|
|
1394
|
+
const formOpts = computeFormOpts.value;
|
|
1395
|
+
const { formConfig } = props;
|
|
1396
|
+
const { items } = formOpts;
|
|
1397
|
+
const itemList = [];
|
|
1398
|
+
XEUtils.eachTree(formConfig && isEnableConf(formOpts) && items ? items : [], (item) => {
|
|
1399
|
+
itemList.push(item);
|
|
1400
|
+
}, { children: "children" });
|
|
1401
|
+
return XEUtils.isUndefined(itemIndex) ? itemList : itemList[itemIndex];
|
|
1402
|
+
},
|
|
1403
|
+
getFormFlatItems() {
|
|
1404
|
+
const $form = refForm.value;
|
|
1405
|
+
if ($form) {
|
|
1406
|
+
return $form.getFlatItems();
|
|
1407
|
+
}
|
|
1408
|
+
return [];
|
|
1409
|
+
},
|
|
1410
|
+
getFormNestedItems() {
|
|
1411
|
+
const $form = refForm.value;
|
|
1412
|
+
if ($form) {
|
|
1413
|
+
return $form.getNestedItems();
|
|
1414
|
+
}
|
|
1415
|
+
return [];
|
|
1416
|
+
},
|
|
1417
|
+
getFormItemByField(field) {
|
|
1418
|
+
const $form = refForm.value;
|
|
1419
|
+
if ($form) {
|
|
1420
|
+
return $form.getItemByField(field);
|
|
1421
|
+
}
|
|
1422
|
+
return null;
|
|
1423
|
+
},
|
|
1424
|
+
resetForm() {
|
|
1425
|
+
const $form = refForm.value;
|
|
1426
|
+
if ($form) {
|
|
1427
|
+
return $form.reset();
|
|
1428
|
+
}
|
|
1429
|
+
return nextTick();
|
|
1430
|
+
},
|
|
1431
|
+
validateForm() {
|
|
1432
|
+
const $form = refForm.value;
|
|
1433
|
+
if ($form) {
|
|
1434
|
+
return $form.validate();
|
|
1435
|
+
}
|
|
1436
|
+
return Promise.resolve();
|
|
1437
|
+
},
|
|
1438
|
+
validateFormField(field) {
|
|
1439
|
+
const $form = refForm.value;
|
|
1440
|
+
if ($form) {
|
|
1441
|
+
return $form.validateField(field);
|
|
1442
|
+
}
|
|
1443
|
+
return Promise.resolve();
|
|
1444
|
+
},
|
|
1445
|
+
clearFormValidate(field) {
|
|
1446
|
+
const $form = refForm.value;
|
|
1447
|
+
if ($form) {
|
|
1448
|
+
return $form.clearValidate(field);
|
|
1449
|
+
}
|
|
1450
|
+
return nextTick();
|
|
1451
|
+
},
|
|
1452
|
+
homePage() {
|
|
1453
|
+
const { tablePage } = reactData;
|
|
1454
|
+
tablePage.currentPage = 1;
|
|
1455
|
+
return nextTick();
|
|
1456
|
+
},
|
|
1457
|
+
homePageByEvent(evnt) {
|
|
1458
|
+
const $pager = refPager.value;
|
|
1459
|
+
if ($pager) {
|
|
1460
|
+
$pager.homePageByEvent(evnt);
|
|
1461
|
+
}
|
|
1462
|
+
},
|
|
1463
|
+
endPage() {
|
|
1464
|
+
const { tablePage } = reactData;
|
|
1465
|
+
const pageCount = computePageCount.value;
|
|
1466
|
+
tablePage.currentPage = pageCount;
|
|
1467
|
+
return nextTick();
|
|
1468
|
+
},
|
|
1469
|
+
endPageByEvent(evnt) {
|
|
1470
|
+
const $pager = refPager.value;
|
|
1471
|
+
if ($pager) {
|
|
1472
|
+
$pager.endPageByEvent(evnt);
|
|
1473
|
+
}
|
|
1474
|
+
},
|
|
1475
|
+
getCurrentPage() {
|
|
1476
|
+
const { tablePage } = reactData;
|
|
1477
|
+
return tablePage.currentPage;
|
|
1478
|
+
},
|
|
1479
|
+
setCurrentPage(currentPage) {
|
|
1480
|
+
const { tablePage } = reactData;
|
|
1481
|
+
const pageCount = computePageCount.value;
|
|
1482
|
+
tablePage.currentPage = Math.min(pageCount, Math.max(1, XEUtils.toNumber(currentPage)));
|
|
1483
|
+
return nextTick();
|
|
1484
|
+
},
|
|
1485
|
+
setCurrentPageByEvent(evnt, currentPage) {
|
|
1486
|
+
const $pager = refPager.value;
|
|
1487
|
+
if ($pager) {
|
|
1488
|
+
$pager.setCurrentPageByEvent(evnt, currentPage);
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
getPageSize() {
|
|
1492
|
+
const { tablePage } = reactData;
|
|
1493
|
+
return tablePage.pageSize;
|
|
1494
|
+
},
|
|
1495
|
+
setPageSize(pageSize) {
|
|
1496
|
+
const { tablePage } = reactData;
|
|
1497
|
+
tablePage.pageSize = Math.max(1, XEUtils.toNumber(pageSize));
|
|
1498
|
+
return nextTick();
|
|
1499
|
+
},
|
|
1500
|
+
setPageSizeByEvent(evnt, pageSize) {
|
|
1501
|
+
const $pager = refPager.value;
|
|
1502
|
+
if ($pager) {
|
|
1503
|
+
$pager.setPageSizeByEvent(evnt, pageSize);
|
|
1504
|
+
}
|
|
1505
|
+
},
|
|
1506
|
+
getProxyInfo() {
|
|
1507
|
+
const $xeTable = refTable.value;
|
|
1508
|
+
if (props.proxyConfig) {
|
|
1509
|
+
const { sortData } = reactData;
|
|
1510
|
+
return {
|
|
1511
|
+
data: $xeTable ? $xeTable.getFullData() : [],
|
|
1512
|
+
filter: reactData.filterData,
|
|
1513
|
+
form: getFormData(),
|
|
1514
|
+
sort: sortData.length ? sortData[0] : {},
|
|
1515
|
+
sorts: sortData,
|
|
1516
|
+
pager: reactData.tablePage,
|
|
1517
|
+
pendingRecords: $xeTable ? $xeTable.getPendingRecords() : []
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
return null;
|
|
1521
|
+
},
|
|
1522
|
+
getCustomPagerData() {
|
|
1523
|
+
const { pagerConfig } = props;
|
|
1524
|
+
const { tablePage } = reactData;
|
|
1525
|
+
const pagerOpts = computePagerOpts.value;
|
|
1526
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
1527
|
+
return {
|
|
1528
|
+
pSize: tablePage.pageSize
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
return {};
|
|
1532
|
+
}
|
|
1533
|
+
// setProxyInfo (options) {
|
|
1534
|
+
// if (props.proxyConfig && options) {
|
|
1535
|
+
// const { pager, form } = options
|
|
1536
|
+
// const proxyOpts = computeProxyOpts.value
|
|
1537
|
+
// if (pager) {
|
|
1538
|
+
// if (pager.currentPage) {
|
|
1539
|
+
// reactData.tablePage.currentPage = Number(pager.currentPage)
|
|
1540
|
+
// }
|
|
1541
|
+
// if (pager.pageSize) {
|
|
1542
|
+
// reactData.tablePage.pageSize = Number(pager.pageSize)
|
|
1543
|
+
// }
|
|
1544
|
+
// }
|
|
1545
|
+
// if (proxyOpts.form && form) {
|
|
1546
|
+
// Object.assign(reactData.formData, form)
|
|
1547
|
+
// }
|
|
1548
|
+
// }
|
|
1549
|
+
// return nextTick()
|
|
1550
|
+
// }
|
|
1551
|
+
};
|
|
1552
|
+
const gridPrivateMethods = {
|
|
1553
|
+
extendTableMethods,
|
|
1554
|
+
callSlot(slotFunc, params) {
|
|
1555
|
+
if (slotFunc) {
|
|
1556
|
+
if (XEUtils.isString(slotFunc)) {
|
|
1557
|
+
slotFunc = slots[slotFunc] || null;
|
|
1558
|
+
}
|
|
1559
|
+
if (XEUtils.isFunction(slotFunc)) {
|
|
1560
|
+
return getSlotVNs(slotFunc(params));
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return [];
|
|
1564
|
+
},
|
|
1565
|
+
/**
|
|
1566
|
+
* 获取需要排除的高度
|
|
1567
|
+
*/
|
|
1568
|
+
getExcludeHeight() {
|
|
1569
|
+
const { height } = props;
|
|
1570
|
+
const { isZMax } = reactData;
|
|
1571
|
+
const el = refElem.value;
|
|
1572
|
+
if (el) {
|
|
1573
|
+
const formWrapper = refFormWrapper.value;
|
|
1574
|
+
const toolbarWrapper = refToolbarWrapper.value;
|
|
1575
|
+
const topWrapper = refTopWrapper.value;
|
|
1576
|
+
const bottomWrapper = refBottomWrapper.value;
|
|
1577
|
+
const pagerWrapper = refPagerWrapper.value;
|
|
1578
|
+
const parentEl = el.parentElement;
|
|
1579
|
+
let parentPaddingSize = 0;
|
|
1580
|
+
if (parentEl && (height === "100%" || height === "auto")) {
|
|
1581
|
+
parentPaddingSize = isZMax ? 0 : getPaddingTopBottomSize(parentEl);
|
|
1582
|
+
}
|
|
1583
|
+
return parentPaddingSize + getPaddingTopBottomSize(el) + getOffsetHeight(formWrapper) + getOffsetHeight(toolbarWrapper) + getOffsetHeight(topWrapper) + getOffsetHeight(bottomWrapper) + getOffsetHeight(pagerWrapper);
|
|
1584
|
+
}
|
|
1585
|
+
return 0;
|
|
1586
|
+
},
|
|
1587
|
+
getParentElem() {
|
|
1588
|
+
const el = refElem.value;
|
|
1589
|
+
if (!el) {
|
|
1590
|
+
return null;
|
|
1591
|
+
}
|
|
1592
|
+
let parentEl = el.parentElement;
|
|
1593
|
+
if (parentEl && hasClass(parentEl, "vxe-scrollbar--view-inner")) {
|
|
1594
|
+
parentEl = parentEl.parentElement;
|
|
1595
|
+
}
|
|
1596
|
+
return parentEl;
|
|
1597
|
+
},
|
|
1598
|
+
getParentHeight() {
|
|
1599
|
+
const el = refElem.value;
|
|
1600
|
+
if (el) {
|
|
1601
|
+
const parentEl = $xeGrid.getParentElem();
|
|
1602
|
+
return (reactData.isZMax ? getDomNode().visibleHeight : parentEl ? XEUtils.toNumber(getComputedStyle(parentEl).height) : 0) - gridPrivateMethods.getExcludeHeight();
|
|
1603
|
+
}
|
|
1604
|
+
return 0;
|
|
1605
|
+
},
|
|
1606
|
+
triggerToolbarCommitEvent(params, evnt) {
|
|
1607
|
+
const { code } = params;
|
|
1608
|
+
if (code) {
|
|
1609
|
+
const isUf = ["reload", "delete", "save"].includes(code);
|
|
1610
|
+
if (isUf) {
|
|
1611
|
+
internalData.uFoot = true;
|
|
1612
|
+
}
|
|
1613
|
+
const rest = $xeGrid.commitProxy(params, evnt).then((rest2) => {
|
|
1614
|
+
if (rest2 && rest2.status && ["query", "reload", "delete", "save"].includes(code)) {
|
|
1615
|
+
$xeGrid.dispatchEvent(code === "delete" || code === "save" ? `proxy-${code}` : "proxy-query", { ...rest2, isReload: code === "reload" }, evnt);
|
|
1773
1616
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1617
|
+
});
|
|
1618
|
+
internalData.uFoot = false;
|
|
1619
|
+
if (isUf) {
|
|
1620
|
+
updateQueryFooter();
|
|
1621
|
+
}
|
|
1622
|
+
return rest;
|
|
1623
|
+
}
|
|
1624
|
+
return nextTick();
|
|
1625
|
+
},
|
|
1626
|
+
triggerToolbarBtnEvent(button, evnt) {
|
|
1627
|
+
$xeGrid.triggerToolbarCommitEvent(button, evnt);
|
|
1628
|
+
$xeGrid.dispatchEvent("toolbar-button-click", { code: button.code, button }, evnt);
|
|
1629
|
+
},
|
|
1630
|
+
triggerToolbarTolEvent(tool, evnt) {
|
|
1631
|
+
$xeGrid.triggerToolbarCommitEvent(tool, evnt);
|
|
1632
|
+
$xeGrid.dispatchEvent("toolbar-tool-click", { code: tool.code, tool }, evnt);
|
|
1633
|
+
},
|
|
1634
|
+
triggerZoomEvent(evnt) {
|
|
1635
|
+
$xeGrid.zoom();
|
|
1636
|
+
$xeGrid.dispatchEvent("zoom", { type: reactData.isZMax ? "max" : "revert" }, evnt);
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
Object.assign($xeGrid, gridExtendTableMethods, gridMethods, gridPrivateMethods, {
|
|
1640
|
+
// 检查插槽
|
|
1641
|
+
loadColumn(columns) {
|
|
1642
|
+
const $xeTable = refTable.value;
|
|
1643
|
+
XEUtils.eachTree(columns, (column) => {
|
|
1644
|
+
if (column.slots) {
|
|
1645
|
+
XEUtils.each(column.slots, (func) => {
|
|
1646
|
+
if (func && !XEUtils.isFunction(func)) {
|
|
1647
|
+
if (!slots[func]) {
|
|
1648
|
+
errLog("vxe.error.notSlot", [func]);
|
|
1800
1649
|
}
|
|
1801
|
-
|
|
1802
|
-
initProxy();
|
|
1650
|
+
}
|
|
1803
1651
|
});
|
|
1804
|
-
|
|
1805
|
-
});
|
|
1806
|
-
onBeforeUnmount(() => {
|
|
1807
|
-
globalEvents.off($xeGrid, 'keydown');
|
|
1808
|
-
XEUtils.assign(reactData, createReactData());
|
|
1809
|
-
XEUtils.assign(internalData, createInternalData());
|
|
1652
|
+
}
|
|
1810
1653
|
});
|
|
1811
|
-
$
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
return
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1654
|
+
if ($xeTable) {
|
|
1655
|
+
return $xeTable.loadColumn(columns);
|
|
1656
|
+
}
|
|
1657
|
+
return nextTick();
|
|
1658
|
+
},
|
|
1659
|
+
reloadColumn(columns) {
|
|
1660
|
+
$xeGrid.clearAll();
|
|
1661
|
+
return $xeGrid.loadColumn(columns);
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
const renderVN = () => {
|
|
1665
|
+
const vSize = computeSize.value;
|
|
1666
|
+
const styles = computeStyles.value;
|
|
1667
|
+
const isLoading = computeIsLoading.value;
|
|
1668
|
+
return h("div", {
|
|
1669
|
+
ref: refElem,
|
|
1670
|
+
class: ["vxe-grid", {
|
|
1671
|
+
[`size--${vSize}`]: vSize,
|
|
1672
|
+
"is--animat": !!props.animat,
|
|
1673
|
+
"is--round": props.round,
|
|
1674
|
+
"is--maximize": reactData.isZMax,
|
|
1675
|
+
"is--loading": isLoading
|
|
1676
|
+
}],
|
|
1677
|
+
style: styles
|
|
1678
|
+
}, renderLayout());
|
|
1679
|
+
};
|
|
1680
|
+
const columnFlag = ref(0);
|
|
1681
|
+
watch(() => props.columns ? props.columns.length : -1, () => {
|
|
1682
|
+
columnFlag.value++;
|
|
1683
|
+
});
|
|
1684
|
+
watch(() => props.columns, () => {
|
|
1685
|
+
columnFlag.value++;
|
|
1686
|
+
});
|
|
1687
|
+
watch(columnFlag, () => {
|
|
1688
|
+
nextTick(() => $xeGrid.loadColumn(props.columns || []));
|
|
1689
|
+
});
|
|
1690
|
+
watch(() => props.toolbarConfig, () => {
|
|
1691
|
+
initToolbar();
|
|
1692
|
+
});
|
|
1693
|
+
watch(computeCustomCurrentPageFlag, () => {
|
|
1694
|
+
initPages("currentPage");
|
|
1695
|
+
});
|
|
1696
|
+
watch(computeCustomPageSizeFlag, () => {
|
|
1697
|
+
initPages("pageSize");
|
|
1698
|
+
});
|
|
1699
|
+
watch(computeCustomTotalFlag, () => {
|
|
1700
|
+
initPages("total");
|
|
1701
|
+
});
|
|
1702
|
+
watch(() => props.proxyConfig, () => {
|
|
1703
|
+
initProxy();
|
|
1704
|
+
});
|
|
1705
|
+
hooks.forEach((options) => {
|
|
1706
|
+
const { setupGrid } = options;
|
|
1707
|
+
if (setupGrid) {
|
|
1708
|
+
const hookRest = setupGrid($xeGrid);
|
|
1709
|
+
if (hookRest && XEUtils.isObject(hookRest)) {
|
|
1710
|
+
Object.assign($xeGrid, hookRest);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
initPages();
|
|
1715
|
+
onMounted(() => {
|
|
1716
|
+
nextTick(() => {
|
|
1717
|
+
const { columns } = props;
|
|
1718
|
+
const proxyOpts = computeProxyOpts.value;
|
|
1719
|
+
if (props.formConfig) {
|
|
1720
|
+
if (!VxeUIFormComponent) {
|
|
1721
|
+
errLog("vxe.error.reqComp", ["vxe-form"]);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (props.pagerConfig) {
|
|
1725
|
+
if (!VxeUIPagerComponent) {
|
|
1726
|
+
errLog("vxe.error.reqComp", ["vxe-pager"]);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
if (proxyOpts.props) {
|
|
1730
|
+
warnLog("vxe.error.delProp", ["proxy-config.props", "proxy-config.response"]);
|
|
1731
|
+
}
|
|
1732
|
+
if (columns && columns.length) {
|
|
1733
|
+
$xeGrid.loadColumn(columns);
|
|
1734
|
+
}
|
|
1735
|
+
initToolbar();
|
|
1736
|
+
initProxy();
|
|
1737
|
+
});
|
|
1738
|
+
globalEvents.on($xeGrid, "keydown", handleGlobalKeydownEvent);
|
|
1739
|
+
});
|
|
1740
|
+
onBeforeUnmount(() => {
|
|
1741
|
+
globalEvents.off($xeGrid, "keydown");
|
|
1742
|
+
XEUtils.assign(reactData, createReactData());
|
|
1743
|
+
XEUtils.assign(internalData, createInternalData());
|
|
1744
|
+
});
|
|
1745
|
+
$xeGrid.renderVN = renderVN;
|
|
1746
|
+
provide("$xeGrid", $xeGrid);
|
|
1747
|
+
provide("$xeGantt", null);
|
|
1748
|
+
return $xeGrid;
|
|
1749
|
+
},
|
|
1750
|
+
render() {
|
|
1751
|
+
return this.renderVN();
|
|
1752
|
+
}
|
|
1819
1753
|
});
|
|
1754
|
+
export {
|
|
1755
|
+
grid_default as default
|
|
1756
|
+
};
|