tomtaw-vxe-table 3.25.13 → 3.25.14

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