vxe-pc-ui 4.20.24 → 4.20.26

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 (627) hide show
  1. package/dist/all.esm.js +15151 -10366
  2. package/dist/style.css +1 -1
  3. package/dist/style.mini.css +1 -1
  4. package/es/alert/src/alert.js +61 -36
  5. package/es/anchor/src/anchor-link.js +39 -20
  6. package/es/anchor/src/anchor.js +74 -45
  7. package/es/avatar/src/avatar.js +47 -27
  8. package/es/backtop/src/backtop.js +65 -40
  9. package/es/badge/src/badge.js +32 -16
  10. package/es/breadcrumb/src/breadcrumb-item.js +52 -27
  11. package/es/breadcrumb/src/breadcrumb.js +11 -8
  12. package/es/button/src/button-group.js +24 -18
  13. package/es/button/src/button.js +284 -185
  14. package/es/calendar/src/calendar.js +571 -358
  15. package/es/card/src/card.js +123 -68
  16. package/es/carousel/src/carousel-item.js +14 -7
  17. package/es/carousel/src/carousel.js +174 -112
  18. package/es/cascader/src/cascader.js +526 -380
  19. package/es/checkbox/src/button.js +90 -55
  20. package/es/checkbox/src/checkbox.js +60 -40
  21. package/es/checkbox/src/group.js +34 -26
  22. package/es/collapse/src/collapse-pane.js +33 -16
  23. package/es/collapse/src/collapse.js +133 -79
  24. package/es/color-picker/src/color-picker.js +489 -350
  25. package/es/components.d.ts +3 -1
  26. package/es/components.js +3 -2
  27. package/es/context-menu/src/context-menu.js +190 -110
  28. package/es/countdown/src/countdown.js +91 -59
  29. package/es/date-panel/src/date-panel.js +760 -450
  30. package/es/date-picker/src/date-picker.js +331 -228
  31. package/es/date-range-picker/src/date-range-picker.js +366 -265
  32. package/es/divider/src/divider.js +26 -12
  33. package/es/drawer/src/drawer.js +254 -154
  34. package/es/dynamics/index.js +38 -25
  35. package/es/empty/src/empty.js +53 -29
  36. package/es/form/render/index.js +66 -41
  37. package/es/form/src/form-config-item.js +22 -16
  38. package/es/form/src/form-group.js +23 -14
  39. package/es/form/src/form-item.js +23 -17
  40. package/es/form/src/form.js +139 -95
  41. package/es/form/src/itemInfo.js +2 -1
  42. package/es/form/src/render.js +207 -127
  43. package/es/form/src/util.js +8 -4
  44. package/es/icon/src/icon.js +14 -10
  45. package/es/icon/style.css +1 -1
  46. package/es/icon/style.mini.css +1 -1
  47. package/es/icon-picker/src/icon-picker.js +250 -157
  48. package/es/image/src/group.js +26 -20
  49. package/es/image/src/image.js +33 -32
  50. package/es/image/src/preview.js +182 -122
  51. package/es/image/src/util.js +6 -3
  52. package/es/index.d.ts +3 -0
  53. package/es/index.esm.js +12 -0
  54. package/es/index.js +12 -0
  55. package/es/input/src/input.js +820 -507
  56. package/es/layout-aside/src/layout-aside.js +54 -38
  57. package/es/layout-body/src/layout-body.js +39 -27
  58. package/es/layout-container/src/layout-container.js +16 -9
  59. package/es/layout-footer/src/layout-footer.js +16 -7
  60. package/es/layout-header/src/layout-header.js +15 -7
  61. package/es/link/src/link.js +65 -44
  62. package/es/list/src/list.js +453 -333
  63. package/es/loading/index.js +8 -5
  64. package/es/loading/src/loading.js +60 -33
  65. package/es/mention/src/mention.js +2 -1
  66. package/es/menu/src/menu.js +341 -210
  67. package/es/modal/index.js +60 -37
  68. package/es/modal/src/modal.js +303 -205
  69. package/es/notice-bar/src/notice-bar.js +64 -37
  70. package/es/number-input/src/number-input.js +249 -172
  71. package/es/pager/src/pager.js +346 -202
  72. package/es/password-input/src/password-input.js +145 -105
  73. package/es/print/src/page-break.js +2 -1
  74. package/es/print/src/print.js +184 -99
  75. package/es/pulldown/src/pulldown.js +113 -71
  76. package/es/radio/src/button.js +92 -57
  77. package/es/radio/src/group.js +33 -25
  78. package/es/radio/src/radio.js +61 -41
  79. package/es/rate/src/rate.js +48 -36
  80. package/es/result/src/result.js +67 -35
  81. package/es/row/src/col.js +30 -16
  82. package/es/row/src/row.js +21 -14
  83. package/es/scrollbar/src/scrollbar.js +177 -145
  84. package/es/segmented/src/segmented.js +93 -60
  85. package/es/select/src/optgroup.js +7 -3
  86. package/es/select/src/select.js +483 -340
  87. package/es/select/src/util.js +6 -3
  88. package/es/slider/src/slider.js +108 -80
  89. package/es/space/src/space.js +43 -26
  90. package/es/splitter/src/splitter-panel.js +50 -25
  91. package/es/splitter/src/splitter.js +219 -144
  92. package/es/steps/src/steps.js +10 -5
  93. package/es/style.css +1 -1
  94. package/es/style.mini.css +1 -1
  95. package/es/switch/src/switch.js +115 -64
  96. package/es/table-select/src/table-select.js +232 -153
  97. package/es/table-transfer/src/table-transfer.js +10 -5
  98. package/es/tabs/src/tab-pane.js +33 -16
  99. package/es/tabs/src/tabs.js +363 -230
  100. package/es/tag/src/tag.js +61 -43
  101. package/es/text/src/text.js +89 -65
  102. package/es/text-ellipsis/src/text-ellipsis.js +82 -51
  103. package/es/textarea/src/textarea.js +116 -86
  104. package/es/timeline/src/timeline-item.js +2 -1
  105. package/es/timeline/src/timeline.js +2 -1
  106. package/es/tip/src/tip.js +53 -29
  107. package/es/tooltip/src/tooltip.js +114 -74
  108. package/es/tour/src/tour.js +2 -1
  109. package/es/transfer/src/transfer.js +42 -25
  110. package/es/tree/src/tree.js +709 -492
  111. package/es/tree-select/src/tree-select.js +320 -225
  112. package/es/ui/index.d.ts +0 -1
  113. package/es/ui/index.js +46 -3
  114. package/es/ui/src/dom.js +9 -6
  115. package/es/ui/src/log.js +1 -1
  116. package/es/ui/src/utils.d.ts +1 -1
  117. package/es/upload/src/upload.js +614 -398
  118. package/es/vxe-icon/style.css +1 -1
  119. package/es/vxe-icon/style.mini.css +1 -1
  120. package/es/watermark/src/util.js +15 -12
  121. package/es/watermark/src/watermark.js +55 -25
  122. package/lib/alert/src/alert.js +62 -37
  123. package/lib/anchor/src/anchor-link.js +39 -20
  124. package/lib/anchor/src/anchor.js +75 -46
  125. package/lib/avatar/src/avatar.js +52 -32
  126. package/lib/backtop/src/backtop.js +81 -56
  127. package/lib/badge/src/badge.js +35 -19
  128. package/lib/breadcrumb/src/breadcrumb-item.js +52 -27
  129. package/lib/breadcrumb/src/breadcrumb.js +13 -10
  130. package/lib/button/src/button-group.js +27 -21
  131. package/lib/button/src/button.js +306 -207
  132. package/lib/calendar/src/calendar.js +575 -362
  133. package/lib/card/src/card.js +133 -78
  134. package/lib/carousel/src/carousel-item.js +15 -8
  135. package/lib/carousel/src/carousel.js +182 -120
  136. package/lib/cascader/src/cascader.js +555 -409
  137. package/lib/checkbox/src/button.js +93 -58
  138. package/lib/checkbox/src/checkbox.js +63 -43
  139. package/lib/checkbox/src/group.js +37 -29
  140. package/lib/collapse/src/collapse-pane.js +34 -17
  141. package/lib/collapse/src/collapse.js +139 -85
  142. package/lib/color-picker/src/color-picker.js +516 -377
  143. package/lib/components.js +3 -2
  144. package/lib/context-menu/src/context-menu.js +212 -132
  145. package/lib/countdown/src/countdown.js +95 -63
  146. package/lib/date-panel/src/date-panel.js +776 -466
  147. package/lib/date-picker/src/date-picker.js +377 -274
  148. package/lib/date-range-picker/src/date-range-picker.js +401 -300
  149. package/lib/divider/src/divider.js +31 -17
  150. package/lib/drawer/src/drawer.js +255 -155
  151. package/lib/dynamics/index.js +38 -25
  152. package/lib/empty/src/empty.js +55 -31
  153. package/lib/form/render/index.js +68 -43
  154. package/lib/form/src/form-config-item.js +24 -18
  155. package/lib/form/src/form-group.js +25 -16
  156. package/lib/form/src/form-item.js +25 -19
  157. package/lib/form/src/form.js +140 -96
  158. package/lib/form/src/itemInfo.js +4 -3
  159. package/lib/form/src/render.js +214 -134
  160. package/lib/form/src/util.js +9 -5
  161. package/lib/icon/src/icon.js +17 -13
  162. package/lib/icon/style/style.css +1 -1
  163. package/lib/icon/style/style.mini.css +1 -1
  164. package/lib/icon-picker/src/icon-picker.js +251 -158
  165. package/lib/image/src/group.js +26 -20
  166. package/lib/image/src/image.js +41 -40
  167. package/lib/image/src/preview.js +206 -146
  168. package/lib/image/src/util.js +6 -3
  169. package/lib/index.common.js +12 -0
  170. package/lib/index.js +12 -0
  171. package/lib/index.umd.js +15359 -10558
  172. package/lib/index.umd.min.js +3 -3
  173. package/lib/input/src/input.js +878 -565
  174. package/lib/layout-aside/src/layout-aside.js +61 -45
  175. package/lib/layout-body/src/layout-body.js +47 -35
  176. package/lib/layout-container/src/layout-container.js +18 -11
  177. package/lib/layout-footer/src/layout-footer.js +17 -8
  178. package/lib/layout-header/src/layout-header.js +16 -8
  179. package/lib/link/src/link.js +69 -48
  180. package/lib/list/src/list.js +456 -336
  181. package/lib/loading/index.js +8 -5
  182. package/lib/loading/src/loading.js +69 -42
  183. package/lib/mention/src/mention.js +4 -3
  184. package/lib/menu/src/menu.js +351 -220
  185. package/lib/modal/index.js +60 -37
  186. package/lib/modal/src/modal.js +306 -208
  187. package/lib/notice-bar/src/notice-bar.js +70 -43
  188. package/lib/number-input/src/number-input.js +290 -213
  189. package/lib/pager/src/pager.js +347 -203
  190. package/lib/password-input/src/password-input.js +155 -115
  191. package/lib/print/src/page-break.js +3 -2
  192. package/lib/print/src/print.js +193 -108
  193. package/lib/pulldown/src/pulldown.js +128 -86
  194. package/lib/radio/src/button.js +96 -61
  195. package/lib/radio/src/group.js +37 -29
  196. package/lib/radio/src/radio.js +65 -45
  197. package/lib/rate/src/rate.js +50 -38
  198. package/lib/result/src/result.js +68 -36
  199. package/lib/row/src/col.js +32 -18
  200. package/lib/row/src/row.js +25 -18
  201. package/lib/scrollbar/src/scrollbar.js +178 -146
  202. package/lib/segmented/src/segmented.js +97 -64
  203. package/lib/select/src/optgroup.js +7 -3
  204. package/lib/select/src/select.js +486 -343
  205. package/lib/select/src/util.js +6 -3
  206. package/lib/slider/src/slider.js +122 -94
  207. package/lib/space/src/space.js +57 -40
  208. package/lib/splitter/src/splitter-panel.js +51 -26
  209. package/lib/splitter/src/splitter.js +233 -158
  210. package/lib/steps/src/steps.js +11 -6
  211. package/lib/style.css +1 -1
  212. package/lib/style.mini.css +1 -1
  213. package/lib/switch/src/switch.js +116 -65
  214. package/lib/table-select/src/table-select.js +234 -155
  215. package/lib/table-transfer/src/table-transfer.js +12 -7
  216. package/lib/tabs/src/tab-pane.js +34 -17
  217. package/lib/tabs/src/tabs.js +365 -232
  218. package/lib/tag/src/tag.js +67 -49
  219. package/lib/text/src/text.js +100 -76
  220. package/lib/text-ellipsis/src/text-ellipsis.js +86 -55
  221. package/lib/textarea/src/textarea.js +127 -97
  222. package/lib/timeline/src/timeline-item.js +3 -2
  223. package/lib/timeline/src/timeline.js +4 -3
  224. package/lib/tip/src/tip.js +58 -34
  225. package/lib/tooltip/src/tooltip.js +116 -76
  226. package/lib/tour/src/tour.js +4 -3
  227. package/lib/transfer/src/transfer.js +44 -27
  228. package/lib/tree/src/tree.js +717 -500
  229. package/lib/tree-select/src/tree-select.js +351 -256
  230. package/lib/ui/index.js +46 -4
  231. package/lib/ui/src/dom.js +9 -6
  232. package/lib/ui/src/log.js +1 -1
  233. package/lib/upload/src/upload.js +708 -492
  234. package/lib/vxe-icon/style/style.css +1 -1
  235. package/lib/vxe-icon/style/style.mini.css +1 -1
  236. package/lib/watermark/src/util.js +15 -12
  237. package/lib/watermark/src/watermark.js +60 -30
  238. package/package.json +10 -4
  239. package/packages/alert/index.ts +16 -16
  240. package/packages/alert/src/alert.ts +148 -126
  241. package/packages/anchor/index.ts +16 -16
  242. package/packages/anchor/src/anchor-link.ts +139 -121
  243. package/packages/anchor/src/anchor.ts +266 -237
  244. package/packages/anchor/src/util.ts +23 -23
  245. package/packages/anchor-link/index.ts +16 -16
  246. package/packages/avatar/index.ts +16 -16
  247. package/packages/avatar/src/avatar.ts +166 -149
  248. package/packages/backtop/index.ts +16 -16
  249. package/packages/backtop/src/backtop.ts +337 -313
  250. package/packages/badge/index.ts +16 -16
  251. package/packages/badge/src/badge.ts +131 -118
  252. package/packages/breadcrumb/index.ts +16 -16
  253. package/packages/breadcrumb/src/breadcrumb-item.ts +129 -106
  254. package/packages/breadcrumb/src/breadcrumb.ts +94 -92
  255. package/packages/breadcrumb-item/index.ts +16 -16
  256. package/packages/button/index.ts +16 -16
  257. package/packages/button/src/button-group.ts +116 -110
  258. package/packages/button/src/button.ts +975 -855
  259. package/packages/button-group/index.ts +16 -16
  260. package/packages/calendar/index.ts +16 -16
  261. package/packages/calendar/src/calendar.ts +1566 -1352
  262. package/packages/card/index.ts +16 -16
  263. package/packages/card/src/card.ts +285 -236
  264. package/packages/carousel/index.ts +16 -16
  265. package/packages/carousel/src/carousel-item.ts +120 -102
  266. package/packages/carousel/src/carousel.ts +475 -414
  267. package/packages/carousel/src/util.ts +21 -21
  268. package/packages/carousel-item/index.ts +16 -16
  269. package/packages/cascader/index.ts +16 -16
  270. package/packages/cascader/src/cascader.ts +2074 -1896
  271. package/packages/cascader/src/util.ts +9 -9
  272. package/packages/checkbox/index.ts +16 -16
  273. package/packages/checkbox/src/button.ts +267 -221
  274. package/packages/checkbox/src/checkbox.ts +219 -199
  275. package/packages/checkbox/src/group.ts +292 -269
  276. package/packages/checkbox-button/index.ts +16 -16
  277. package/packages/checkbox-group/index.ts +16 -16
  278. package/packages/col/index.ts +16 -16
  279. package/packages/collapse/index.ts +16 -16
  280. package/packages/collapse/src/collapse-pane.ts +142 -114
  281. package/packages/collapse/src/collapse.ts +453 -384
  282. package/packages/collapse/src/util.ts +21 -21
  283. package/packages/collapse-pane/index.ts +16 -16
  284. package/packages/color-picker/index.ts +31 -31
  285. package/packages/color-picker/src/color-picker.ts +1310 -1147
  286. package/packages/color-picker/src/util.ts +436 -423
  287. package/packages/components.ts +350 -349
  288. package/packages/context-menu/index.ts +54 -54
  289. package/packages/context-menu/src/context-menu.ts +773 -681
  290. package/packages/countdown/index.ts +16 -16
  291. package/packages/countdown/src/countdown.ts +295 -262
  292. package/packages/date-panel/index.ts +16 -16
  293. package/packages/date-panel/src/date-panel.ts +2214 -1900
  294. package/packages/date-panel/src/util.ts +354 -326
  295. package/packages/date-picker/index.ts +16 -16
  296. package/packages/date-picker/src/date-picker.ts +1884 -1752
  297. package/packages/date-range-picker/index.ts +16 -16
  298. package/packages/date-range-picker/src/date-range-picker.ts +1728 -1604
  299. package/packages/divider/index.ts +16 -16
  300. package/packages/divider/src/divider.ts +105 -93
  301. package/packages/drawer/index.ts +78 -78
  302. package/packages/drawer/src/drawer.ts +920 -802
  303. package/packages/drawer/src/store.ts +3 -3
  304. package/packages/dynamics/index.ts +124 -117
  305. package/packages/empty/index.ts +16 -16
  306. package/packages/empty/src/empty.ts +124 -103
  307. package/packages/form/index.ts +16 -16
  308. package/packages/form/render/index.ts +646 -614
  309. package/packages/form/src/form-config-item.ts +85 -80
  310. package/packages/form/src/form-group.ts +96 -86
  311. package/packages/form/src/form-item.ts +181 -174
  312. package/packages/form/src/form.ts +1122 -1069
  313. package/packages/form/src/itemInfo.ts +84 -82
  314. package/packages/form/src/render.ts +470 -387
  315. package/packages/form/src/util.ts +98 -93
  316. package/packages/form-gather/index.ts +26 -26
  317. package/packages/form-group/index.ts +16 -16
  318. package/packages/form-item/index.ts +16 -16
  319. package/packages/icon/index.ts +16 -16
  320. package/packages/icon/src/icon.ts +78 -75
  321. package/packages/icon-picker/index.ts +16 -16
  322. package/packages/icon-picker/src/icon-picker.ts +922 -809
  323. package/packages/image/index.ts +16 -16
  324. package/packages/image/src/group.ts +159 -153
  325. package/packages/image/src/image.ts +298 -298
  326. package/packages/image/src/preview.ts +749 -672
  327. package/packages/image/src/util.ts +62 -59
  328. package/packages/image-group/index.ts +16 -16
  329. package/packages/image-preview/index.ts +19 -19
  330. package/packages/index.ts +20 -4
  331. package/packages/input/index.ts +16 -16
  332. package/packages/input/src/input.ts +3201 -2863
  333. package/packages/language/fr-FR.ts +15 -15
  334. package/packages/language/it-IT.ts +4 -4
  335. package/packages/language/uk-UA.ts +1 -1
  336. package/packages/language/uz-UZ.ts +13 -13
  337. package/packages/language/zh-CN.ts +907 -907
  338. package/packages/layout-aside/index.ts +16 -16
  339. package/packages/layout-aside/src/layout-aside.ts +172 -156
  340. package/packages/layout-body/index.ts +16 -16
  341. package/packages/layout-body/src/layout-body.ts +191 -181
  342. package/packages/layout-container/index.ts +16 -16
  343. package/packages/layout-container/src/layout-container.ts +108 -92
  344. package/packages/layout-footer/index.ts +16 -16
  345. package/packages/layout-footer/src/layout-footer.ts +81 -74
  346. package/packages/layout-header/index.ts +16 -16
  347. package/packages/layout-header/src/layout-header.ts +79 -73
  348. package/packages/link/index.ts +16 -16
  349. package/packages/link/src/link.ts +180 -161
  350. package/packages/list/index.ts +16 -16
  351. package/packages/list/src/list.ts +2690 -2564
  352. package/packages/list/src/store.ts +10 -10
  353. package/packages/list/src/util.ts +10 -11
  354. package/packages/loading/index.ts +39 -36
  355. package/packages/loading/src/loading.ts +179 -152
  356. package/packages/mention/index.ts +16 -16
  357. package/packages/mention/src/mention.ts +69 -71
  358. package/packages/menu/index.ts +16 -16
  359. package/packages/menu/src/menu.ts +1000 -857
  360. package/packages/modal/index.ts +164 -141
  361. package/packages/modal/src/modal.ts +1803 -1681
  362. package/packages/modal/src/store.ts +3 -3
  363. package/packages/notice-bar/index.ts +16 -16
  364. package/packages/notice-bar/src/notice-bar.ts +207 -181
  365. package/packages/number-input/index.ts +16 -16
  366. package/packages/number-input/src/number-input.ts +1322 -1242
  367. package/packages/number-input/src/util.ts +25 -25
  368. package/packages/optgroup/index.ts +16 -16
  369. package/packages/option/index.ts +16 -16
  370. package/packages/pager/index.ts +16 -16
  371. package/packages/pager/src/pager.ts +919 -775
  372. package/packages/password-input/index.ts +16 -16
  373. package/packages/password-input/src/password-input.ts +523 -482
  374. package/packages/print/index.ts +18 -18
  375. package/packages/print/src/page-break.ts +104 -92
  376. package/packages/print/src/print.ts +366 -281
  377. package/packages/print/src/util.ts +299 -304
  378. package/packages/print-page-break/index.ts +16 -16
  379. package/packages/pulldown/index.ts +16 -16
  380. package/packages/pulldown/src/pulldown.ts +505 -445
  381. package/packages/radio/index.ts +16 -16
  382. package/packages/radio/src/button.ts +290 -243
  383. package/packages/radio/src/group.ts +275 -252
  384. package/packages/radio/src/radio.ts +237 -218
  385. package/packages/radio-button/index.ts +16 -16
  386. package/packages/radio-group/index.ts +16 -16
  387. package/packages/rate/index.ts +16 -16
  388. package/packages/rate/src/rate.ts +203 -192
  389. package/packages/result/index.ts +16 -16
  390. package/packages/result/src/result.ts +141 -112
  391. package/packages/row/index.ts +16 -16
  392. package/packages/row/src/col.ts +171 -159
  393. package/packages/row/src/row.ts +143 -138
  394. package/packages/scrollbar/index.ts +16 -16
  395. package/packages/scrollbar/src/scrollbar.ts +626 -595
  396. package/packages/segmented/index.ts +16 -16
  397. package/packages/segmented/src/segmented.ts +297 -264
  398. package/packages/select/index.ts +16 -16
  399. package/packages/select/src/optgroup.ts +53 -49
  400. package/packages/select/src/option-info.ts +20 -20
  401. package/packages/select/src/option.ts +47 -47
  402. package/packages/select/src/select.ts +2390 -2214
  403. package/packages/select/src/util.ts +50 -47
  404. package/packages/slider/index.ts +16 -16
  405. package/packages/slider/src/slider.ts +547 -506
  406. package/packages/space/index.ts +16 -16
  407. package/packages/space/src/space.ts +225 -209
  408. package/packages/split/index.ts +16 -16
  409. package/packages/split-pane/index.ts +17 -17
  410. package/packages/splitter/index.ts +16 -16
  411. package/packages/splitter/src/splitter-panel.ts +199 -163
  412. package/packages/splitter/src/splitter.ts +1110 -1020
  413. package/packages/splitter/src/util.ts +21 -21
  414. package/packages/splitter-panel/index.ts +16 -16
  415. package/packages/steps/index.ts +16 -16
  416. package/packages/steps/src/steps.ts +69 -68
  417. package/packages/switch/index.ts +16 -16
  418. package/packages/switch/src/switch.ts +300 -245
  419. package/packages/tab-pane/index.ts +16 -16
  420. package/packages/table-select/index.ts +16 -16
  421. package/packages/table-select/src/table-select.ts +1103 -999
  422. package/packages/table-transfer/index.ts +16 -16
  423. package/packages/table-transfer/src/table-transfer.ts +104 -91
  424. package/packages/tabs/index.ts +16 -16
  425. package/packages/tabs/src/tab-pane.ts +132 -117
  426. package/packages/tabs/src/tabs.ts +1137 -997
  427. package/packages/tabs/src/util.ts +21 -21
  428. package/packages/tag/index.ts +16 -16
  429. package/packages/tag/src/tag.ts +204 -187
  430. package/packages/text/index.ts +16 -16
  431. package/packages/text/src/text.ts +282 -260
  432. package/packages/text-ellipsis/index.ts +16 -16
  433. package/packages/text-ellipsis/src/text-ellipsis.ts +312 -282
  434. package/packages/textarea/index.ts +16 -16
  435. package/packages/textarea/src/textarea.ts +526 -495
  436. package/packages/timeline/index.ts +16 -16
  437. package/packages/timeline/src/timeline-item.ts +65 -67
  438. package/packages/timeline/src/timeline.ts +70 -71
  439. package/packages/timeline-item/index.ts +16 -16
  440. package/packages/tip/index.ts +19 -19
  441. package/packages/tip/src/tip.ts +150 -129
  442. package/packages/tooltip/index.ts +72 -72
  443. package/packages/tooltip/src/tooltip.ts +669 -627
  444. package/packages/tour/index.ts +16 -16
  445. package/packages/tour/src/tour.ts +70 -71
  446. package/packages/transfer/index.ts +16 -16
  447. package/packages/transfer/src/transfer.ts +130 -117
  448. package/packages/tree/index.ts +16 -16
  449. package/packages/tree/src/store.ts +10 -10
  450. package/packages/tree/src/tree.ts +4077 -3852
  451. package/packages/tree/src/util.ts +51 -51
  452. package/packages/tree-select/index.ts +16 -16
  453. package/packages/tree-select/src/tree-select.ts +1217 -1094
  454. package/packages/ui/index.ts +836 -793
  455. package/packages/ui/src/anime.ts +51 -52
  456. package/packages/ui/src/comp.ts +3 -3
  457. package/packages/ui/src/dom.ts +357 -354
  458. package/packages/ui/src/log.ts +19 -19
  459. package/packages/ui/src/utils.ts +79 -79
  460. package/packages/ui/src/vn.ts +39 -39
  461. package/packages/upload/index.ts +20 -20
  462. package/packages/upload/src/upload.ts +2271 -2021
  463. package/packages/upload/src/util.ts +109 -109
  464. package/packages/watermark/index.ts +33 -33
  465. package/packages/watermark/src/util.ts +186 -180
  466. package/packages/watermark/src/watermark.ts +196 -168
  467. package/types/all.d.ts +552 -552
  468. package/types/components/alert.d.ts +83 -87
  469. package/types/components/anchor-link.d.ts +88 -91
  470. package/types/components/anchor.d.ts +97 -104
  471. package/types/components/avatar.d.ts +85 -88
  472. package/types/components/backtop.d.ts +119 -122
  473. package/types/components/badge.d.ts +77 -80
  474. package/types/components/breadcrumb-item.d.ts +77 -80
  475. package/types/components/breadcrumb.d.ts +83 -87
  476. package/types/components/button-group.d.ts +118 -120
  477. package/types/components/button.d.ts +331 -339
  478. package/types/components/calendar.d.ts +247 -264
  479. package/types/components/card.d.ts +111 -113
  480. package/types/components/carousel-item.d.ts +73 -75
  481. package/types/components/carousel.d.ts +130 -134
  482. package/types/components/cascader.d.ts +336 -386
  483. package/types/components/checkbox-button.d.ts +109 -114
  484. package/types/components/checkbox-group.d.ts +152 -154
  485. package/types/components/checkbox.d.ts +123 -128
  486. package/types/components/col.d.ts +77 -80
  487. package/types/components/colgroup.d.ts +64 -69
  488. package/types/components/collapse-pane.d.ts +86 -89
  489. package/types/components/collapse.d.ts +123 -133
  490. package/types/components/color-picker.d.ts +275 -280
  491. package/types/components/column.d.ts +834 -851
  492. package/types/components/context-menu.d.ts +282 -289
  493. package/types/components/countdown.d.ts +108 -112
  494. package/types/components/date-panel.d.ts +319 -331
  495. package/types/components/date-picker.d.ts +361 -384
  496. package/types/components/date-range-picker.d.ts +351 -371
  497. package/types/components/divider.d.ts +72 -75
  498. package/types/components/drawer.d.ts +333 -344
  499. package/types/components/empty.d.ts +75 -78
  500. package/types/components/flow-design.d.ts +73 -85
  501. package/types/components/flow-view.d.ts +73 -85
  502. package/types/components/form-design.d.ts +370 -376
  503. package/types/components/form-gather.d.ts +120 -124
  504. package/types/components/form-group.d.ts +73 -77
  505. package/types/components/form-item.d.ts +395 -413
  506. package/types/components/form-view.d.ts +179 -183
  507. package/types/components/form.d.ts +499 -495
  508. package/types/components/gantt-module/gantt-view.d.ts +195 -200
  509. package/types/components/gantt-module/index.d.ts +1 -1
  510. package/types/components/gantt-plugins/extend-gantt-chart.d.ts +137 -131
  511. package/types/components/gantt-plugins/index.d.ts +1 -1
  512. package/types/components/gantt.d.ts +1248 -1399
  513. package/types/components/grid.d.ts +1289 -1317
  514. package/types/components/icon-picker.d.ts +242 -253
  515. package/types/components/icon.d.ts +332 -87
  516. package/types/components/image-group.d.ts +124 -127
  517. package/types/components/image-preview.d.ts +167 -167
  518. package/types/components/image.d.ts +166 -173
  519. package/types/components/input.d.ts +429 -453
  520. package/types/components/layout-aside.d.ts +123 -123
  521. package/types/components/layout-body.d.ts +110 -113
  522. package/types/components/layout-container.d.ts +73 -75
  523. package/types/components/layout-footer.d.ts +71 -73
  524. package/types/components/layout-header.d.ts +67 -69
  525. package/types/components/link.d.ts +107 -111
  526. package/types/components/list-design.d.ts +189 -190
  527. package/types/components/list-view.d.ts +193 -199
  528. package/types/components/list.d.ts +678 -715
  529. package/types/components/loading.d.ts +98 -103
  530. package/types/components/mention.d.ts +70 -77
  531. package/types/components/menu.d.ts +284 -295
  532. package/types/components/modal.d.ts +567 -584
  533. package/types/components/notice-bar.d.ts +102 -106
  534. package/types/components/number-input.d.ts +359 -365
  535. package/types/components/optgroup.d.ts +85 -88
  536. package/types/components/option.d.ts +94 -103
  537. package/types/components/pager.d.ts +330 -335
  538. package/types/components/password-input.d.ts +143 -156
  539. package/types/components/print-page-break.d.ts +65 -69
  540. package/types/components/print.d.ts +243 -245
  541. package/types/components/pulldown.d.ts +231 -239
  542. package/types/components/radio-button.d.ts +113 -118
  543. package/types/components/radio-group.d.ts +151 -153
  544. package/types/components/radio.d.ts +129 -134
  545. package/types/components/rate.d.ts +83 -88
  546. package/types/components/result.d.ts +81 -84
  547. package/types/components/row.d.ts +77 -81
  548. package/types/components/scrollbar.d.ts +299 -305
  549. package/types/components/segmented.d.ts +119 -123
  550. package/types/components/select.d.ts +598 -616
  551. package/types/components/slider.d.ts +137 -151
  552. package/types/components/space.d.ts +120 -127
  553. package/types/components/split-pane.d.ts +126 -133
  554. package/types/components/split.d.ts +301 -312
  555. package/types/components/splitter-panel.d.ts +123 -130
  556. package/types/components/splitter.d.ts +290 -301
  557. package/types/components/steps.d.ts +63 -68
  558. package/types/components/switch.d.ts +127 -133
  559. package/types/components/tab-pane.d.ts +111 -114
  560. package/types/components/table-module/custom.d.ts +123 -123
  561. package/types/components/table-module/edit.d.ts +297 -276
  562. package/types/components/table-module/export.d.ts +88 -96
  563. package/types/components/table-module/filter.d.ts +144 -144
  564. package/types/components/table-module/index.d.ts +7 -7
  565. package/types/components/table-module/keyboard.d.ts +26 -26
  566. package/types/components/table-module/menu.d.ts +46 -46
  567. package/types/components/table-module/validator.d.ts +53 -53
  568. package/types/components/table-plugins/extend-cell-area.d.ts +781 -781
  569. package/types/components/table-plugins/extend-pivot-table.d.ts +59 -58
  570. package/types/components/table-plugins/filters-combination.d.ts +15 -15
  571. package/types/components/table-plugins/filters-complex-input.d.ts +9 -9
  572. package/types/components/table-plugins/index.d.ts +4 -4
  573. package/types/components/table-select.d.ts +268 -276
  574. package/types/components/table-transfer.d.ts +80 -84
  575. package/types/components/table.d.ts +7530 -8000
  576. package/types/components/tabs.d.ts +314 -352
  577. package/types/components/tag.d.ts +108 -114
  578. package/types/components/text-ellipsis.d.ts +107 -112
  579. package/types/components/text.d.ts +112 -122
  580. package/types/components/textarea.d.ts +261 -275
  581. package/types/components/timeline-item.d.ts +66 -75
  582. package/types/components/timeline.d.ts +70 -77
  583. package/types/components/tip.d.ts +81 -83
  584. package/types/components/toolbar.d.ts +327 -336
  585. package/types/components/tooltip.d.ts +250 -255
  586. package/types/components/tour.d.ts +70 -77
  587. package/types/components/transfer.d.ts +80 -84
  588. package/types/components/tree-select.d.ts +361 -376
  589. package/types/components/tree.d.ts +994 -1036
  590. package/types/components/upload.d.ts +477 -518
  591. package/types/components/watermark.d.ts +116 -120
  592. package/types/handles/form-design.d.ts +50 -50
  593. package/types/handles/index.d.ts +3 -3
  594. package/types/handles/list-design.d.ts +1 -2
  595. package/types/handles/table.d.ts +15 -15
  596. package/types/index.d.ts +8 -8
  597. package/types/ui/commands.d.ts +57 -57
  598. package/types/ui/formats.d.ts +62 -62
  599. package/types/ui/global-config.d.ts +269 -269
  600. package/types/ui/global-icon.d.ts +315 -315
  601. package/types/ui/hooks.d.ts +13 -13
  602. package/types/ui/index.d.ts +100 -100
  603. package/types/ui/interceptor.d.ts +52 -52
  604. package/types/ui/menus.d.ts +89 -89
  605. package/types/ui/renderer.d.ts +1033 -1047
  606. package/types/ui/validators.d.ts +37 -38
  607. /package/dist/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  608. /package/dist/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  609. /package/dist/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
  610. /package/es/icon/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  611. /package/es/icon/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  612. /package/es/icon/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
  613. /package/es/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  614. /package/es/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  615. /package/es/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
  616. /package/es/vxe-icon/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  617. /package/es/vxe-icon/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  618. /package/es/vxe-icon/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
  619. /package/lib/icon/style/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  620. /package/lib/icon/style/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  621. /package/lib/icon/style/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
  622. /package/lib/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  623. /package/lib/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  624. /package/lib/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
  625. /package/lib/vxe-icon/style/{iconfont.1792979107495.ttf → iconfont.1793007755017.ttf} +0 -0
  626. /package/lib/vxe-icon/style/{iconfont.1792979107495.woff → iconfont.1793007755017.woff} +0 -0
  627. /package/lib/vxe-icon/style/{iconfont.1792979107495.woff2 → iconfont.1793007755017.woff2} +0 -0
@@ -1,1896 +1,2074 @@
1
- import { ref, computed, h, PropType, nextTick, inject, provide, reactive, Teleport, onMounted, onUnmounted, watch } from 'vue'
2
- import { defineVxeComponent } from '../../ui/src/comp'
3
- import { getConfig, getI18n, getIcon, globalEvents, createEvent, useSize, renderEmptyElement, getSlotVNs } from '../../ui'
4
- import { getEventTargetNode, updatePanelPlacement, toCssUnit } from '../../ui/src/dom'
5
- import { getLastZIndex, nextZIndex } from '../../ui/src/utils'
6
- import { enNodeValue, deNodeValue } from './util'
7
- import XEUtils from 'xe-utils'
8
- import VxeListComponent from '../../list'
9
- import VxeInputComponent from '../../input'
10
- import VxeButtonComponent from '../../button'
11
-
12
- import type { CascaderReactData, VxeCascaderEmits, CascaderInternalData, VxeButtonEvents, ValueOf, VxeComponentStyleType, VxeCascaderDefines, CascaderPrivateRef, CascaderPrivateMethods, CascaderMethods, VxeCascaderPrivateComputed, VxeCascaderPropTypes, VxeCascaderConstructor, VxeListSlotTypes, VxeFormDefines, VxeDrawerConstructor, VxeDrawerMethods, VxeCascaderPrivateMethods, VxeFormConstructor, VxeFormPrivateMethods, VxeInputConstructor, VxeModalConstructor, VxeModalMethods } from '../../../types'
13
- import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/components/table'
14
-
15
- /**
16
- * 生成节点的唯一主键
17
- */
18
- function getNodeUniqueId () {
19
- return XEUtils.uniqueId('node_')
20
- }
21
-
22
- function createReactData (): CascaderReactData {
23
- return {
24
- initialized: false,
25
- searchValue: '',
26
- searchLoading: false,
27
- currentCunkList: [],
28
- currentItems: [],
29
- currentNode: null,
30
- panelIndex: 0,
31
- panelStyle: {},
32
- panelPlacement: null,
33
- triggerFocusPanel: false,
34
- visiblePanel: false,
35
- isAniVisible: false,
36
- isActivated: false,
37
- selectRadioKey: null,
38
- treeList: [],
39
- updateExpandedFlag: 1,
40
- updateCheckboxFlag: 1,
41
- fullOptFlag: 1,
42
- lazyOptFlag: 1
43
- }
44
- }
45
-
46
- function createInternalData (): CascaderInternalData {
47
- return {
48
- // hpTimeout: undefined,
49
- listVirtualYOpts: {
50
- enabled: true,
51
- gt: 20
52
- },
53
- afterTreeList: [],
54
- treeFullData: [],
55
- afterVisibleList: [],
56
- nodeMaps: {},
57
- fullNodeMaps: {},
58
- lazyNodeMaps: {},
59
- indeterminateRowMaps: {},
60
- selectCheckboxMaps: {},
61
- treeExpandedMaps: {},
62
- treeExpandLazyLoadedMaps: {}
63
- // isUpdateMode: false
64
- }
65
- }
66
-
67
- export default defineVxeComponent({
68
- name: 'VxeCascader',
69
- props: {
70
- modelValue: [String, Number, Array] as PropType<VxeCascaderPropTypes.ModelValue>,
71
- clearable: Boolean as PropType<VxeCascaderPropTypes.Clearable>,
72
- placeholder: {
73
- type: String as PropType<VxeCascaderPropTypes.Placeholder>,
74
- default: () => XEUtils.eqNull(getConfig().cascader.placeholder) ? getI18n('vxe.base.pleaseSelect') : getConfig().cascader.placeholder
75
- },
76
- readonly: {
77
- type: Boolean as PropType<VxeCascaderPropTypes.Readonly>,
78
- default: null
79
- },
80
- loading: Boolean as PropType<VxeCascaderPropTypes.Loading>,
81
- disabled: {
82
- type: Boolean as PropType<VxeCascaderPropTypes.Disabled>,
83
- default: null
84
- },
85
- filterable: Boolean as PropType<VxeCascaderPropTypes.Filterable>,
86
- filterConfig: Object as PropType<VxeCascaderPropTypes.FilterConfig>,
87
- showFullLabel: {
88
- type: Boolean as PropType<VxeCascaderPropTypes.ShowFullLabel>,
89
- default: () => getConfig().cascader.showFullLabel
90
- },
91
- separator: {
92
- type: String as PropType<VxeCascaderPropTypes.Separator>,
93
- default: () => getConfig().cascader.separator
94
- },
95
- multiple: Boolean as PropType<VxeCascaderPropTypes.Multiple>,
96
- className: [String, Function] as PropType<VxeCascaderPropTypes.ClassName>,
97
- prefixIcon: String as PropType<VxeCascaderPropTypes.PrefixIcon>,
98
- lazyOptions: Array as PropType<VxeCascaderPropTypes.LazyOptions>,
99
- options: Array as PropType<VxeCascaderPropTypes.Options>,
100
- optionProps: Object as PropType<VxeCascaderPropTypes.OptionProps>,
101
- size: {
102
- type: String as PropType<VxeCascaderPropTypes.Size>,
103
- default: () => getConfig().cascader.size || getConfig().size
104
- },
105
- treeConfig: Object as PropType<VxeCascaderPropTypes.TreeConfig>,
106
- showRadio: {
107
- type: Boolean as PropType<VxeCascaderPropTypes.ShowRadio>,
108
- default: () => getConfig().cascader.showRadio
109
- },
110
- radioConfig: Object as PropType<VxeCascaderPropTypes.RadioConfig>,
111
- showCheckbox: {
112
- type: Boolean as PropType<VxeCascaderPropTypes.ShowCheckbox>,
113
- default: () => getConfig().cascader.showCheckbox
114
- },
115
- checkboxConfig: Object as PropType<VxeCascaderPropTypes.CheckboxConfig>,
116
- remote: Boolean as PropType<VxeCascaderPropTypes.Remote>,
117
- remoteConfig: Function as PropType<VxeCascaderPropTypes.RemoteConfig>,
118
- popupConfig: Object as PropType<VxeCascaderPropTypes.PopupConfig>,
119
- checkedClosable: {
120
- type: Boolean as PropType<VxeCascaderPropTypes.CheckedClosable>,
121
- default: () => getConfig().cascader.checkedClosable
122
- },
123
- clearClosable: {
124
- type: Boolean as PropType<VxeCascaderPropTypes.ClearClosable>,
125
- default: () => getConfig().cascader.clearClosable
126
- },
127
- showCloseButton: {
128
- type: Boolean as PropType<VxeCascaderPropTypes.ShowCloseButton>,
129
- default: () => getConfig().cascader.showCloseButton
130
- },
131
- showTotalButton: {
132
- type: Boolean as PropType<VxeCascaderPropTypes.ShowTotalButton>,
133
- default: () => getConfig().cascader.showTotalButton
134
- },
135
- showCheckedButton: {
136
- type: Boolean as PropType<VxeCascaderPropTypes.ShowCheckedButton>,
137
- default: () => getConfig().cascader.showCheckedButton
138
- },
139
- showClearButton: {
140
- type: Boolean as PropType<VxeCascaderPropTypes.ShowClearButton>,
141
- default: () => getConfig().cascader.showClearButton
142
- }
143
- },
144
- emits: [
145
- 'update:modelValue',
146
- 'change',
147
- 'all-change',
148
- 'clear',
149
- 'blur',
150
- 'focus',
151
- 'click',
152
- 'node-click',
153
- 'node-expand',
154
- 'current-change',
155
- 'radio-change',
156
- 'checkbox-change',
157
- 'load-success',
158
- 'load-error',
159
- 'visible-change'
160
- ] as VxeCascaderEmits,
161
- setup (props, context) {
162
- const { emit, slots } = context
163
-
164
- const $xeModal = inject<(VxeModalConstructor & VxeModalMethods)| null>('$xeModal', null)
165
- const $xeDrawer = inject<(VxeDrawerConstructor & VxeDrawerMethods) | null>('$xeDrawer', null)
166
- const $xeTable = inject<(VxeTableConstructor & VxeTablePrivateMethods) | null>('$xeTable', null)
167
- const $xeForm = inject<(VxeFormConstructor & VxeFormPrivateMethods) | null>('$xeForm', null)
168
- const formItemInfo = inject<VxeFormDefines.ProvideItemInfo | null>('xeFormItemInfo', null)
169
-
170
- const xID = XEUtils.uniqueId()
171
-
172
- const { computeSize } = useSize(props)
173
-
174
- const refElem = ref<HTMLDivElement>()
175
- const refInput = ref<VxeInputConstructor>()
176
- const refInpSearch = ref<VxeInputConstructor>()
177
- const refChunkWrapper = ref<HTMLDivElement>()
178
- const refOptionPanel = ref<HTMLDivElement>()
179
-
180
- const reactData = reactive(createReactData())
181
- const internalData = createInternalData()
182
-
183
- const refMaps: CascaderPrivateRef = {
184
- refElem
185
- }
186
-
187
- const computeFormReadonly = computed(() => {
188
- const { readonly } = props
189
- if (readonly === null) {
190
- if ($xeForm) {
191
- return $xeForm.props.readonly
192
- }
193
- return false
194
- }
195
- return readonly
196
- })
197
-
198
- const computeIsDisabled = computed(() => {
199
- const { disabled } = props
200
- if (disabled === null) {
201
- if ($xeForm) {
202
- return $xeForm.props.disabled
203
- }
204
- return false
205
- }
206
- return disabled
207
- })
208
-
209
- const computeBtnTransfer = computed(() => {
210
- const popupOpts = computePopupOpts.value
211
- const { transfer } = popupOpts
212
- if (XEUtils.isBoolean(transfer)) {
213
- return transfer
214
- }
215
- if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
216
- return true
217
- }
218
- return false
219
- })
220
-
221
- const computeTreeOpts = computed(() => {
222
- return Object.assign({}, getConfig().cascader.treeConfig, props.treeConfig)
223
- })
224
-
225
- const computeRadioOpts = computed(() => {
226
- return Object.assign({}, getConfig().cascader.radioConfig, props.radioConfig)
227
- })
228
-
229
- const computeCheckboxOpts = computed(() => {
230
- return Object.assign({}, getConfig().cascader.checkboxConfig, props.checkboxConfig)
231
- })
232
-
233
- const computePopupOpts = computed(() => {
234
- return Object.assign({}, getConfig().cascader.popupConfig, props.popupConfig)
235
- })
236
-
237
- const computePropsOpts = computed(() => {
238
- return props.optionProps || {}
239
- })
240
-
241
- const computeLabelField = computed(() => {
242
- const propsOpts = computePropsOpts.value
243
- return propsOpts.label || 'label'
244
- })
245
-
246
- const computeValueField = computed(() => {
247
- const propsOpts = computePropsOpts.value
248
- return propsOpts.value || 'value'
249
- })
250
-
251
- const computeKeyField = computed(() => {
252
- const treeOpts = computeTreeOpts.value
253
- return treeOpts.keyField || 'id'
254
- })
255
-
256
- const computeParentField = computed(() => {
257
- const treeOpts = computeTreeOpts.value
258
- return treeOpts.parentField || 'parentId'
259
- })
260
-
261
- const computeChildrenField = computed(() => {
262
- const treeOpts = computeTreeOpts.value
263
- return treeOpts.childrenField || 'children'
264
- })
265
-
266
- const computeMapChildrenField = computed(() => {
267
- const treeOpts = computeTreeOpts.value
268
- return treeOpts.mapChildrenField || 'mapChildren'
269
- })
270
-
271
- const computeHasChildField = computed(() => {
272
- const treeOpts = computeTreeOpts.value
273
- return treeOpts.hasChildField || 'hasChild'
274
- })
275
-
276
- const computeRemoteOpts = computed(() => {
277
- return Object.assign({}, getConfig().cascader.remoteConfig, props.remoteConfig)
278
- })
279
-
280
- const computeSelectVals = computed(() => {
281
- const { modelValue } = props
282
- return XEUtils.eqNull(modelValue) ? [] : (XEUtils.isArray(modelValue) ? modelValue : [modelValue])
283
- })
284
-
285
- const computeSelectLabel = computed(() => {
286
- const { showFullLabel } = props
287
- const { fullOptFlag, lazyOptFlag } = reactData
288
- const { fullNodeMaps, lazyNodeMaps } = internalData
289
- const labelField = computeLabelField.value
290
- const selectVals = computeSelectVals.value
291
- return selectVals.map(val => {
292
- const cacheItem = fullNodeMaps[val]
293
- if (fullOptFlag && cacheItem) {
294
- return showFullLabel ? cacheItem.fullLabel : cacheItem.item[labelField]
295
- }
296
- if (lazyOptFlag) {
297
- const lazyCacheItem = lazyNodeMaps[val]
298
- if (lazyCacheItem) {
299
- return showFullLabel ? lazyCacheItem.fullLabel : lazyCacheItem.item[labelField]
300
- }
301
- }
302
- return val
303
- }).join(', ')
304
- })
305
-
306
- const computePopupWrapperStyle = computed(() => {
307
- const { currentCunkList, panelStyle } = reactData
308
- const popupOpts = computePopupOpts.value
309
- const { height, nodeWidth, nodeHeight } = popupOpts
310
- const stys: VxeComponentStyleType = {
311
- ...panelStyle,
312
- '--vxe-ui-cascader-chunk-size': currentCunkList.length
313
- }
314
- if (height) {
315
- stys['--vxe-ui-cascader-chunk-height'] = toCssUnit(height)
316
- }
317
- if (nodeWidth) {
318
- stys['--vxe-ui-cascader-node-width'] = toCssUnit(nodeWidth)
319
- }
320
- if (nodeHeight) {
321
- stys['--vxe-ui-cascader-node-height'] = toCssUnit(nodeHeight)
322
- }
323
- return stys
324
- })
325
-
326
- const computeFilterOpts = computed(() => {
327
- return Object.assign({}, getConfig().cascader.filterConfig, props.filterConfig)
328
- })
329
-
330
- const computeMaps: VxeCascaderPrivateComputed = {
331
- }
332
-
333
- const $xeCascader = {
334
- xID,
335
- props,
336
- context,
337
- reactData,
338
- internalData,
339
-
340
- getRefMaps: () => refMaps,
341
- getComputeMaps: () => computeMaps
342
- } as unknown as VxeCascaderConstructor & VxeCascaderPrivateMethods
343
-
344
- const dispatchEvent = (type: ValueOf<VxeCascaderEmits>, params: Record<string, any>, evnt: Event | null) => {
345
- emit(type, createEvent(evnt, { $cascader: $xeCascader }, params))
346
- }
347
-
348
- const emitModel = (value: any) => {
349
- emit('update:modelValue', value)
350
- }
351
-
352
- const cascaderMethods: CascaderMethods = {
353
- dispatchEvent
354
- }
355
-
356
- const getNodeId = (node: any) => {
357
- if (!node) {
358
- return ''
359
- }
360
- const valueField = computeValueField.value
361
- const nodeKey = node[valueField]
362
- return enNodeValue(nodeKey)
363
- }
364
-
365
- const isPathInTree = (treeData: any[], pathIds: string[]) => {
366
- if (!pathIds || !pathIds.length) {
367
- return false
368
- }
369
- let currentNodes = treeData
370
- for (const nodeid of pathIds) {
371
- const found = currentNodes.find(node => getNodeId(node) === nodeid)
372
- if (!found) {
373
- return false
374
- }
375
- currentNodes = found.children || []
376
- }
377
- return true
378
- }
379
-
380
- const isCheckedByCheckboxNodeId = (nodeid: any) => {
381
- const { updateCheckboxFlag } = reactData
382
- const { selectCheckboxMaps } = internalData
383
- return !!(updateCheckboxFlag && selectCheckboxMaps[nodeid])
384
- }
385
-
386
- const handleCheckedCheckboxNode = (nodeList: any[], checked: boolean) => {
387
- const { selectCheckboxMaps } = internalData
388
- const mapChildrenField = computeMapChildrenField.value
389
- const childrenField = computeChildrenField.value
390
- const checkboxOpts = computeCheckboxOpts.value
391
- const { checkStrictly } = checkboxOpts
392
- const treeOpts = computeTreeOpts.value
393
- const { transform } = treeOpts
394
- const handleSelect = (node: any) => {
395
- const nodeid = getNodeId(node)
396
- if (checked) {
397
- if (!selectCheckboxMaps[nodeid]) {
398
- selectCheckboxMaps[nodeid] = node
399
- }
400
- } else {
401
- if (selectCheckboxMaps[nodeid]) {
402
- delete selectCheckboxMaps[nodeid]
403
- }
404
- }
405
- }
406
- if (checkStrictly) {
407
- nodeList.forEach(handleSelect)
408
- } else {
409
- XEUtils.eachTree(nodeList, handleSelect, { children: transform ? mapChildrenField : childrenField })
410
- }
411
- reactData.updateCheckboxFlag++
412
- updateCheckboxStatus()
413
- }
414
-
415
- const createNode = (records: any[]) => {
416
- const valueField = computeValueField.value
417
- return Promise.resolve(
418
- records.map(obj => {
419
- const item = { ...obj }
420
- let nodeid = getNodeId(item)
421
- if (!nodeid) {
422
- nodeid = getNodeUniqueId()
423
- XEUtils.set(item, valueField, nodeid)
424
- }
425
- return item
426
- })
427
- )
428
- }
429
-
430
- const handleSetCheckboxByNodeId = (nodeKeys: any | any[], checked: boolean) => {
431
- const { nodeMaps } = internalData
432
- if (nodeKeys) {
433
- if (!XEUtils.isArray(nodeKeys)) {
434
- nodeKeys = [nodeKeys]
435
- }
436
- const nodeList: any[] = []
437
- nodeKeys.forEach((nodeKey: string) => {
438
- const nodeid = enNodeValue(nodeKey)
439
- const nodeItem = nodeMaps[nodeid]
440
- if (nodeItem) {
441
- nodeList.push(nodeItem.item)
442
- }
443
- })
444
- handleCheckedCheckboxNode(nodeList, checked)
445
- }
446
- return nextTick()
447
- }
448
-
449
- const updateCheckboxChecked = (nodeKeys: any[]) => {
450
- internalData.selectCheckboxMaps = {}
451
- handleSetCheckboxByNodeId(nodeKeys, true)
452
- }
453
-
454
- const updateModelChecked = () => {
455
- const { modelValue } = props
456
- const { nodeMaps } = internalData
457
- const expandedMaps: Record<string, boolean> = {}
458
- if (props.multiple) {
459
- if (modelValue && modelValue.length) {
460
- updateCheckboxChecked(modelValue)
461
- }
462
- } else {
463
- if (modelValue) {
464
- const nodeid = enNodeValue(XEUtils.isArray(modelValue) ? modelValue[0] : modelValue)
465
- const itemRest = nodeMaps[nodeid]
466
- if (itemRest) {
467
- itemRest.nodes.forEach(item => {
468
- expandedMaps[getNodeId(item)] = true
469
- })
470
- reactData.selectRadioKey = nodeid
471
- }
472
- }
473
- }
474
- internalData.treeExpandedMaps = expandedMaps
475
- }
476
-
477
- const cacheNodeMap = () => {
478
- const { separator } = props
479
- const { treeFullData } = internalData
480
- const valueField = computeValueField.value
481
- const labelField = computeLabelField.value
482
- const childrenField = computeChildrenField.value
483
- const keyMaps: Record<string, VxeCascaderDefines.NodeCacheItem> = {}
484
- const fullMaps: Record<string, VxeCascaderDefines.NodeCacheItem> = {}
485
- XEUtils.eachTree(treeFullData, (item, index, items, path, parenItem, nodes) => {
486
- let nodeid = getNodeId(item)
487
- if (!nodeid) {
488
- nodeid = getNodeUniqueId()
489
- item[valueField] = nodeid
490
- }
491
- const nodeVal = item[valueField]
492
- const itemRest = {
493
- item,
494
- index,
495
- $index: -1,
496
- _index: -1,
497
- items,
498
- parent: parenItem,
499
- nodes,
500
- level: nodes.length - 1,
501
- treeIndex: index,
502
- lineCount: 0,
503
- treeLoaded: false,
504
- fullLabel: nodes.map(item => item[labelField]).join((separator || ' / '))
505
- }
506
- keyMaps[nodeid] = itemRest
507
- fullMaps[nodeVal] = itemRest
508
- }, { children: childrenField })
509
- internalData.nodeMaps = keyMaps
510
- internalData.fullNodeMaps = fullMaps
511
- reactData.fullOptFlag++
512
- }
513
-
514
- const updateAfterDataIndex = () => {
515
- const { separator } = props
516
- const { afterTreeList, nodeMaps } = internalData
517
- const labelField = computeLabelField.value
518
- const childrenField = computeChildrenField.value
519
- const mapChildrenField = computeMapChildrenField.value
520
- const treeOpts = computeTreeOpts.value
521
- const { transform } = treeOpts
522
- let vtIndex = 0
523
- XEUtils.eachTree(afterTreeList, (item, index, items, path, parenItem, nodes) => {
524
- const nodeid = getNodeId(item)
525
- const nodeItem = nodeMaps[nodeid]
526
- if (nodeItem) {
527
- nodeItem.items = items
528
- nodeItem.treeIndex = index
529
- nodeItem._index = vtIndex
530
- } else {
531
- const rest = {
532
- item,
533
- index,
534
- $index: -1,
535
- _index: vtIndex,
536
- items,
537
- parent: parenItem,
538
- nodes,
539
- level: nodes.length - 1,
540
- treeIndex: index,
541
- lineCount: 0,
542
- treeLoaded: false,
543
- fullLabel: nodes.map(item => item[labelField]).join((separator || ' / '))
544
- }
545
- nodeMaps[nodeid] = rest
546
- }
547
- vtIndex++
548
- }, { children: transform ? mapChildrenField : childrenField })
549
- }
550
-
551
- const updateAfterFullData = () => {
552
- const { searchValue } = reactData
553
- const { treeFullData, lastFilterValue } = internalData
554
- const labelField = computeLabelField.value
555
- const childrenField = computeChildrenField.value
556
- const mapChildrenField = computeMapChildrenField.value
557
- const treeOpts = computeTreeOpts.value
558
- const { transform } = treeOpts
559
- const filterOpts = computeFilterOpts.value
560
- const { beforeFilterMethod, filterMethod, afterFilterMethod } = filterOpts
561
- let fullList = treeFullData
562
- let treeList = fullList
563
- let filterStr = ''
564
- if (searchValue) {
565
- filterStr = `${searchValue}`
566
- const handleSearch = filterMethod
567
- ? (item: any) => {
568
- return filterMethod({
569
- $cascader: $xeCascader,
570
- node: item,
571
- filterValue: filterStr
572
- })
573
- }
574
- : (item: any) => {
575
- return String(item[labelField]).toLowerCase().indexOf(filterStr.toLowerCase()) > -1
576
- }
577
- const bafParams = { $cascader: $xeCascader, filterValue: filterStr }
578
- if (beforeFilterMethod) {
579
- beforeFilterMethod(bafParams)
580
- }
581
- if (transform) {
582
- treeList = XEUtils.searchTree(treeFullData, handleSearch, {
583
- original: true,
584
- isEvery: false,
585
- children: childrenField,
586
- mapChildren: mapChildrenField
587
- })
588
- fullList = treeList
589
- } else {
590
- fullList = treeFullData.filter(handleSearch)
591
- }
592
- internalData.lastFilterValue = filterStr
593
- nextTick(() => {
594
- if (afterFilterMethod) {
595
- afterFilterMethod(bafParams)
596
- }
597
- })
598
- } else {
599
- if (transform) {
600
- treeList = XEUtils.searchTree(treeFullData, () => true, {
601
- original: true,
602
- isEvery: false,
603
- children: childrenField,
604
- mapChildren: mapChildrenField
605
- })
606
- fullList = treeList
607
- if (lastFilterValue) {
608
- const bafParams = { $cascader: $xeCascader, filterValue: filterStr }
609
- if (beforeFilterMethod) {
610
- beforeFilterMethod(bafParams)
611
- }
612
- // 取消筛选时自动收起
613
- nextTick(() => {
614
- if (afterFilterMethod) {
615
- afterFilterMethod(bafParams)
616
- }
617
- })
618
- }
619
- }
620
- internalData.lastFilterValue = ''
621
- }
622
- internalData.afterVisibleList = fullList
623
- internalData.afterTreeList = treeList
624
- updateAfterDataIndex()
625
- }
626
-
627
- /**
628
- * 如果为虚拟树、则将树结构拍平
629
- */
630
- const handleTreeToList = () => {
631
- const { afterTreeList, treeExpandedMaps } = internalData
632
- const mapChildrenField = computeMapChildrenField.value
633
- const treeOpts = computeTreeOpts.value
634
- const { transform } = treeOpts
635
- const expandMaps: {
636
- [key: string]: number
637
- } = {}
638
- if (transform) {
639
- const fullData: any[] = []
640
- XEUtils.eachTree(afterTreeList, (item, index, items, path, parentRow) => {
641
- const nodeid = getNodeId(item)
642
- const parentNodeid = getNodeId(parentRow)
643
- if (!parentRow || (expandMaps[parentNodeid] && treeExpandedMaps[parentNodeid])) {
644
- expandMaps[nodeid] = 1
645
- fullData.push(item)
646
- }
647
- }, { children: mapChildrenField })
648
- internalData.afterVisibleList = fullData
649
- return fullData
650
- }
651
- return internalData.afterVisibleList
652
- }
653
-
654
- const handleData = (force?: boolean) => {
655
- let fullList: any[] = internalData.afterVisibleList
656
- if (force) {
657
- // 更新数据,处理筛选和排序
658
- updateAfterFullData()
659
- // 如果为虚拟树,将树结构拍平
660
- fullList = handleTreeToList()
661
- }
662
- const treeList = fullList.slice(0)
663
- reactData.treeList = treeList
664
- }
665
-
666
- /**
667
- * 获取第一个拥有子节点的节点
668
- */
669
- function handleHasChildNodeIds (treeList: any[], type: 'first' | 'last') {
670
- const childrenField = computeChildrenField.value
671
- const mapChildrenField = computeMapChildrenField.value
672
- const treeOpts = computeTreeOpts.value
673
- const { transform } = treeOpts
674
- const childField = transform ? mapChildrenField : childrenField
675
- const nodeIds = []
676
- let currList = treeList
677
- while (currList.length) {
678
- let targetNode = null
679
- for (const item of currList) {
680
- const kids = item[childField]
681
- if (XEUtils.isArray(kids) && kids.length > 0) {
682
- targetNode = item
683
- break
684
- }
685
- }
686
- if (targetNode) {
687
- nodeIds.push(getNodeId(targetNode))
688
- currList = targetNode[childField]
689
- } else {
690
- const endNode = XEUtils[type](currList)
691
- nodeIds.push(getNodeId(endNode))
692
- break
693
- }
694
- }
695
- return nodeIds
696
- }
697
-
698
- const triggerSearchEvent = XEUtils.debounce(() => {
699
- handleData(true)
700
- updateCheckboxStatus()
701
- const { currentItems } = reactData
702
- const { afterTreeList } = internalData
703
- const filterOpts = computeFilterOpts.value
704
- const { autoExpandMode } = filterOpts
705
- // 如果当前不在列表情况下,触发默认行为
706
- if (!isPathInTree(afterTreeList, currentItems)) {
707
- // 默认展开
708
- if (autoExpandMode === 'first' || autoExpandMode === 'last') {
709
- const stItems = handleHasChildNodeIds(afterTreeList, autoExpandMode)
710
- const expandedMaps: Record<string, boolean> = {}
711
- stItems.forEach(nodeid => {
712
- expandedMaps[nodeid] = true
713
- })
714
- internalData.treeExpandedMaps = expandedMaps
715
- reactData.currentItems = stItems
716
- } else {
717
- handleCurrentItems()
718
- }
719
- }
720
- updateCurrentChunk()
721
- }, 350, { trailing: true })
722
-
723
- const loadData = (list: any[]) => {
724
- const treeOpts = computeTreeOpts.value
725
- const keyField = computeKeyField.value
726
- const parentField = computeParentField.value
727
- const childrenField = computeChildrenField.value
728
- const { rootParentValue, rootValues } = treeOpts
729
- const { transform } = treeOpts
730
- const fullData = transform
731
- ? XEUtils.toArrayTree(list, {
732
- key: keyField,
733
- parentKey: parentField,
734
- mapChildren: childrenField,
735
- rootParentValue,
736
- rootValues
737
- })
738
- : list ? list.slice(0) : []
739
- internalData.treeFullData = fullData
740
- cacheNodeMap()
741
- handleData(true)
742
- updateModelChecked()
743
- handleCurrentItems()
744
- updateCurrentChunk()
745
- return nextTick()
746
- }
747
-
748
- const updateCurrentChunk = () => {
749
- const { currentItems } = reactData
750
- const { afterTreeList } = internalData
751
- const childrenField = computeChildrenField.value
752
- const mapChildrenField = computeMapChildrenField.value
753
- const treeOpts = computeTreeOpts.value
754
- const { transform } = treeOpts
755
- const currentCunkList: any[][] = [afterTreeList]
756
- if (currentItems.length) {
757
- let chunkIndex = 0
758
- let stNodeid = currentItems[chunkIndex]
759
- let optList = afterTreeList
760
- while (stNodeid && optList && optList.length) {
761
- stNodeid = currentItems[chunkIndex++]
762
- const currOption = optList.find(item => stNodeid === getNodeId(item))
763
- optList = currOption ? currOption[transform ? mapChildrenField : childrenField] : []
764
- if (!optList || !optList.length) {
765
- break
766
- }
767
- currentCunkList.push(optList)
768
- }
769
- }
770
- reactData.currentCunkList = currentCunkList
771
- }
772
-
773
- const handleCurrentItems = () => {
774
- const { currentNode } = reactData
775
- const { afterTreeList } = internalData
776
- const selectVals = computeSelectVals.value
777
- const childrenField = computeChildrenField.value
778
- const mapChildrenField = computeMapChildrenField.value
779
- const treeOpts = computeTreeOpts.value
780
- const { transform } = treeOpts
781
- const stItems: string[] = []
782
- const expandedMaps: Record<string, boolean> = {}
783
- const lastVal = currentNode ? getNodeId(currentNode) : enNodeValue(XEUtils.last(selectVals))
784
- if (lastVal) {
785
- const stRest = XEUtils.findTree(afterTreeList, (item) => lastVal === getNodeId(item), { children: transform ? mapChildrenField : childrenField })
786
- if (stRest) {
787
- const { nodes } = stRest
788
- nodes.forEach(item => {
789
- const nodeid = getNodeId(item)
790
- expandedMaps[nodeid] = true
791
- stItems.push(nodeid)
792
- })
793
- }
794
- }
795
- reactData.currentItems = stItems
796
- internalData.treeExpandedMaps = expandedMaps
797
- }
798
-
799
- const updateZindex = () => {
800
- const popupOpts = computePopupOpts.value
801
- const { zIndex } = popupOpts
802
- if (zIndex) {
803
- reactData.panelIndex = zIndex
804
- } else if (reactData.panelIndex < getLastZIndex()) {
805
- reactData.panelIndex = nextZIndex()
806
- }
807
- }
808
-
809
- const updatePlacement = () => {
810
- const { panelIndex } = reactData
811
- const targetElem = refElem.value
812
- const panelElem = refOptionPanel.value
813
- const btnTransfer = computeBtnTransfer.value
814
- const popupOpts = computePopupOpts.value
815
- const handleStyle = () => {
816
- const ppObj = updatePanelPlacement(targetElem, panelElem, {
817
- placement: popupOpts.placement,
818
- defaultPlacement: popupOpts.defaultPlacement,
819
- appendTo: popupOpts.appendTo,
820
- teleportTo: btnTransfer,
821
- isMinWidth: false
822
- })
823
- const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
824
- zIndex: panelIndex
825
- })
826
- reactData.panelStyle = panelStyle
827
- reactData.panelPlacement = ppObj.placement
828
- }
829
- handleStyle()
830
- return nextTick().then(handleStyle)
831
- }
832
-
833
- const showOptionPanel = (evnt?: Event) => {
834
- const { loading, remote, filterable } = props
835
- const { treeFullData } = internalData
836
- const isDisabled = computeIsDisabled.value
837
- const remoteOpts = computeRemoteOpts.value
838
- if (!loading && !isDisabled) {
839
- clearTimeout(internalData.hpTimeout)
840
- if (!reactData.initialized) {
841
- reactData.initialized = true
842
- }
843
- reactData.isActivated = true
844
- reactData.isAniVisible = true
845
- if (filterable) {
846
- if (remote && remoteOpts.enabled && remoteOpts.autoLoad && !treeFullData.length) {
847
- handleSearchEvent()
848
- }
849
- }
850
- setTimeout(() => {
851
- reactData.visiblePanel = true
852
- handleFocusSearch()
853
- }, 10)
854
- updateZindex()
855
- updatePlacement()
856
- dispatchEvent('visible-change', { visible: true }, evnt || null)
857
- }
858
- }
859
-
860
- const hideOptionPanel = (evnt?: Event) => {
861
- reactData.visiblePanel = false
862
- internalData.hpTimeout = setTimeout(() => {
863
- reactData.isAniVisible = false
864
- }, 350)
865
- dispatchEvent('visible-change', { visible: false }, evnt || null)
866
- }
867
-
868
- const setCurrentNode = (node: any) => {
869
- reactData.currentNode = node
870
- updateCurrentChunk()
871
- return nextTick()
872
- }
873
-
874
- const setAllCheckboxNode = (checked: boolean) => {
875
- const selectMaps: Record<string, boolean> = {}
876
- const childrenField = computeChildrenField.value
877
- const mapChildrenField = computeMapChildrenField.value
878
- const treeOpts = computeTreeOpts.value
879
- const { transform } = treeOpts
880
- const checkKeys: string[] = []
881
- const checkNodes: any[] = []
882
- if (checked) {
883
- XEUtils.eachTree(internalData.afterTreeList, (node) => {
884
- const nodeid = getNodeId(node)
885
- checkKeys.push(nodeid)
886
- checkNodes.push(node)
887
- selectMaps[nodeid] = true
888
- }, { children: transform ? mapChildrenField : childrenField })
889
- }
890
- internalData.indeterminateRowMaps = {}
891
- internalData.selectCheckboxMaps = selectMaps
892
- reactData.updateCheckboxFlag++
893
- updateCheckboxStatus()
894
- return nextTick().then(() => {
895
- return { checkNodeKeys: checkKeys, checkNodes }
896
- })
897
- }
898
-
899
- const clearSelectedNode = () => {
900
- internalData.indeterminateRowMaps = {}
901
- internalData.selectCheckboxMaps = {}
902
- reactData.updateCheckboxFlag++
903
- reactData.selectRadioKey = null
904
- updateCheckboxStatus()
905
- return nextTick().then(() => {
906
- return { checkNodeKeys: [], checkNodes: [] }
907
- })
908
- }
909
-
910
- const changeEvent = (evnt: Event, selectValue: any, node: any) => {
911
- const value = XEUtils.isArray(selectValue) ? selectValue.map(deNodeValue) : deNodeValue(selectValue)
912
- internalData.isUpdateMode = true
913
- emitModel(value)
914
- if (value !== props.modelValue) {
915
- dispatchEvent('change', { value, node, option: node }, evnt)
916
- // 自动更新校验状态
917
- if ($xeForm && formItemInfo) {
918
- $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
919
- }
920
- }
921
- }
922
-
923
- const clearValueEvent = (evnt: Event, selectValue: any) => {
924
- changeEvent(evnt, selectValue, null)
925
- dispatchEvent('clear', { value: selectValue }, evnt)
926
- }
927
-
928
- const clearEvent = (params: any, evnt: Event) => {
929
- clearValueEvent(evnt, null)
930
- hideOptionPanel(evnt)
931
- }
932
-
933
- const allCheckedPanelEvent: VxeButtonEvents.Click = (params) => {
934
- const { $event } = params
935
- const { multiple, checkedClosable } = props
936
- if (multiple) {
937
- setAllCheckboxNode(true).then(({ checkNodeKeys, checkNodes }) => {
938
- changeEvent($event, checkNodeKeys, checkNodes[0])
939
- dispatchEvent('all-change', { value: checkNodeKeys }, $event)
940
- if (checkedClosable) {
941
- hideOptionPanel($event)
942
- }
943
- })
944
- }
945
- }
946
-
947
- const clearCheckedPanelEvent: VxeButtonEvents.Click = (params) => {
948
- const { $event } = params
949
- const { multiple, checkedClosable } = props
950
- const value = multiple ? [] : null
951
- clearSelectedNode().then(() => {
952
- if (checkedClosable) {
953
- hideOptionPanel($event)
954
- }
955
- })
956
- changeEvent($event, value, null)
957
- dispatchEvent('clear', { value }, $event)
958
- }
959
-
960
- const closePanelEvent: VxeButtonEvents.Click = (params) => {
961
- const { $event } = params
962
- hideOptionPanel($event)
963
- }
964
-
965
- const handleGlobalMousedownEvent = (evnt: MouseEvent) => {
966
- const { visiblePanel } = reactData
967
- const isDisabled = computeIsDisabled.value
968
- if (!isDisabled) {
969
- const el = refElem.value
970
- const panelElem = refOptionPanel.value
971
- reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag
972
- if (visiblePanel && !reactData.isActivated) {
973
- hideOptionPanel(evnt)
974
- }
975
- }
976
- }
977
-
978
- const handleGlobalBlurEvent = (evnt: Event) => {
979
- const { visiblePanel, isActivated } = reactData
980
- if (visiblePanel) {
981
- hideOptionPanel(evnt)
982
- }
983
- if (isActivated) {
984
- reactData.isActivated = false
985
- }
986
- if (visiblePanel || isActivated) {
987
- const $input = refInput.value
988
- if ($input) {
989
- $input.blur()
990
- }
991
- }
992
- }
993
-
994
- const handleGlobalResizeEvent = () => {
995
- const { visiblePanel } = reactData
996
- if (visiblePanel) {
997
- updatePlacement()
998
- }
999
- }
1000
-
1001
- const handleGlobalScrollEvent = () => {
1002
- const { visiblePanel } = reactData
1003
- if (visiblePanel) {
1004
- updatePlacement()
1005
- }
1006
- }
1007
-
1008
- const handleFocusSearch = () => {
1009
- if (props.filterable) {
1010
- nextTick(() => {
1011
- const inpSearch = refInpSearch.value
1012
- if (inpSearch) {
1013
- inpSearch.focus()
1014
- }
1015
- })
1016
- }
1017
- }
1018
-
1019
- const changeCurrentEvent = (evnt: MouseEvent, node: any) => {
1020
- evnt.preventDefault()
1021
- const isChecked = true
1022
- reactData.currentNode = node
1023
- dispatchEvent('current-change', { node, checked: isChecked }, evnt)
1024
- }
1025
-
1026
- const changeRadioEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1027
- evnt.preventDefault()
1028
- evnt.stopPropagation()
1029
- const { currentItems } = reactData
1030
- const { nodeMaps } = internalData
1031
- const radioOpts = computeRadioOpts.value
1032
- const childrenField = computeChildrenField.value
1033
- const treeOpts = computeTreeOpts.value
1034
- const { transform } = treeOpts
1035
- const mapChildrenField = computeMapChildrenField.value
1036
- const { checkMode, checkMethod } = radioOpts
1037
- const nodeid = getNodeId(node)
1038
- const childList: any[] = node[transform ? mapChildrenField : childrenField]
1039
- const isExistChild = childList && childList.length > 0
1040
- const nodeItem = nodeMaps[nodeid] || {}
1041
- const nLevel = nodeItem.level
1042
- const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1043
- if (isDisabled) {
1044
- return
1045
- }
1046
- const value = nodeid
1047
- reactData.selectRadioKey = value
1048
- changeEvent(evnt, value, node)
1049
- if (!currentItems.includes(nodeid)) {
1050
- changeCurrentEvent(evnt, node)
1051
- toggleExpandEvent(evnt, node, chunks, chunkIndex)
1052
- }
1053
- hideOptionPanel(evnt)
1054
- }
1055
-
1056
- const handleAsyncTreeExpandChilds = (node: any) => {
1057
- const checkboxOpts = computeCheckboxOpts.value
1058
- const treeOpts = computeTreeOpts.value
1059
- const { loadMethod } = treeOpts
1060
- const { checkStrictly } = checkboxOpts
1061
- return new Promise<void>(resolve => {
1062
- if (loadMethod) {
1063
- const { nodeMaps } = internalData
1064
- const nodeid = getNodeId(node)
1065
- const nodeItem = nodeMaps[nodeid]
1066
- internalData.treeExpandLazyLoadedMaps[nodeid] = true
1067
- Promise.resolve(
1068
- loadMethod({ $cascader: $xeCascader, node })
1069
- ).then((childRecords: any) => {
1070
- const { treeExpandLazyLoadedMaps } = internalData
1071
- nodeItem.treeLoaded = true
1072
- if (treeExpandLazyLoadedMaps[nodeid]) {
1073
- treeExpandLazyLoadedMaps[nodeid] = false
1074
- }
1075
- if (!XEUtils.isArray(childRecords)) {
1076
- childRecords = []
1077
- }
1078
- if (childRecords) {
1079
- return $xeCascader.loadChildrenNode(node, childRecords).then(childRows => {
1080
- const { treeExpandedMaps } = internalData
1081
- if (childRows.length && !treeExpandedMaps[nodeid]) {
1082
- treeExpandedMaps[nodeid] = true
1083
- }
1084
- reactData.updateExpandedFlag++
1085
- // 如果当前节点已选中,则展开后子节点也被选中
1086
- if (!checkStrictly && $xeCascader.isCheckedByCheckboxNodeId(nodeid)) {
1087
- handleCheckedCheckboxNode(childRows, true)
1088
- }
1089
- dispatchEvent('load-success', { node, data: childRecords }, new Event('load-success'))
1090
- return nextTick()
1091
- })
1092
- } else {
1093
- dispatchEvent('load-success', { node, data: childRecords }, new Event('load-success'))
1094
- }
1095
- }).catch((e) => {
1096
- const { treeExpandLazyLoadedMaps } = internalData
1097
- nodeItem.treeLoaded = false
1098
- if (treeExpandLazyLoadedMaps[nodeid]) {
1099
- treeExpandLazyLoadedMaps[nodeid] = false
1100
- }
1101
- dispatchEvent('load-error', { node, data: e }, new Event('load-error'))
1102
- }).finally(() => {
1103
- handleTreeToList()
1104
- handleData()
1105
- })
1106
- } else {
1107
- resolve()
1108
- }
1109
- })
1110
- }
1111
-
1112
- /**
1113
- * 展开与收起树节点
1114
- * @param nodeList
1115
- * @param expanded
1116
- * @returns
1117
- */
1118
- const handleBaseTreeExpand = (nodeList: any[], expanded: boolean) => {
1119
- const { treeExpandLazyLoadedMaps, treeExpandedMaps } = internalData
1120
- const { nodeMaps } = internalData
1121
- const childrenField = computeChildrenField.value
1122
- const hasChildField = computeHasChildField.value
1123
- const treeOpts = computeTreeOpts.value
1124
- const { lazy, toggleMethod } = treeOpts
1125
- const result: any[] = []
1126
- let validNodes = toggleMethod ? nodeList.filter((node: any) => toggleMethod({ $cascader: $xeCascader, expanded, node })) : nodeList
1127
-
1128
- validNodes = validNodes.length ? [validNodes[validNodes.length - 1]] : []
1129
- // 同一级只能展开一个
1130
- const nodeid = getNodeId(validNodes[0])
1131
- const nodeItem = nodeMaps[nodeid]
1132
- if (nodeItem) {
1133
- nodeItem.items.forEach(item => {
1134
- const itemNodeId = getNodeId(item)
1135
- if (treeExpandedMaps[itemNodeId]) {
1136
- delete treeExpandedMaps[itemNodeId]
1137
- }
1138
- })
1139
- }
1140
-
1141
- const expandNodes: any[] = []
1142
- if (expanded) {
1143
- validNodes.forEach((item) => {
1144
- const itemNodeId = getNodeId(item)
1145
- if (!treeExpandedMaps[itemNodeId]) {
1146
- const nodeItem = nodeMaps[itemNodeId]
1147
- const isLoad = lazy && item[hasChildField] && !nodeItem.treeLoaded && !treeExpandLazyLoadedMaps[itemNodeId]
1148
- // 是否使用懒加载
1149
- if (isLoad) {
1150
- result.push(handleAsyncTreeExpandChilds(item))
1151
- } else {
1152
- if (item[childrenField] && item[childrenField].length) {
1153
- treeExpandedMaps[itemNodeId] = true
1154
- expandNodes.push(item)
1155
- }
1156
- }
1157
- }
1158
- })
1159
- } else {
1160
- validNodes.forEach(item => {
1161
- const itemNodeId = getNodeId(item)
1162
- if (treeExpandedMaps[itemNodeId]) {
1163
- delete treeExpandedMaps[itemNodeId]
1164
- expandNodes.push(item)
1165
- }
1166
- })
1167
- }
1168
- reactData.updateExpandedFlag++
1169
- handleTreeToList()
1170
- handleData()
1171
- return Promise.all(result)
1172
- }
1173
-
1174
- const toggleExpandEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1175
- const { currentItems } = reactData
1176
- const { treeExpandLazyLoadedMaps } = internalData
1177
- const treeOpts = computeTreeOpts.value
1178
- const { lazy } = treeOpts
1179
- const stItems = currentItems.slice(0, chunkIndex)
1180
- const nodeid = getNodeId(node)
1181
- const expanded = true
1182
- evnt.stopPropagation()
1183
- stItems.push(nodeid)
1184
- reactData.currentItems = stItems
1185
- if (!lazy || !treeExpandLazyLoadedMaps[nodeid]) {
1186
- handleBaseTreeExpand([node], expanded)
1187
- }
1188
- setCurrentNode(node)
1189
- dispatchEvent('node-expand', { node, expanded }, evnt)
1190
- }
1191
-
1192
- const updateCheckboxStatus = () => {
1193
- const { selectCheckboxMaps, indeterminateRowMaps, afterTreeList } = internalData
1194
- const childrenField = computeChildrenField.value
1195
- const mapChildrenField = computeMapChildrenField.value
1196
- const checkboxOpts = computeCheckboxOpts.value
1197
- const { checkStrictly, checkMethod } = checkboxOpts
1198
- const treeOpts = computeTreeOpts.value
1199
- const { transform } = treeOpts
1200
- if (!checkStrictly) {
1201
- const childRowMaps: Record<string, number> = {}
1202
- const childRowList: any[][] = []
1203
- XEUtils.eachTree(afterTreeList, (node) => {
1204
- const nodeid = getNodeId(node)
1205
- const childList = node[transform ? mapChildrenField : childrenField]
1206
- if (childList && childList.length && !childRowMaps[nodeid]) {
1207
- childRowMaps[nodeid] = 1
1208
- childRowList.unshift([node, nodeid, childList])
1209
- }
1210
- }, { children: transform ? mapChildrenField : childrenField })
1211
-
1212
- childRowList.forEach(vals => {
1213
- const node: string = vals[0]
1214
- const nodeid: string = vals[1]
1215
- const childList: any[] = vals[2]
1216
- let sLen = 0 // 已选
1217
- let hLen = 0 // 半选
1218
- let vLen = 0 // 有效子行
1219
- const cLen = childList.length // 子行
1220
- childList.forEach(
1221
- checkMethod
1222
- ? (item) => {
1223
- const childNodeid = getNodeId(item)
1224
- const isSelect = selectCheckboxMaps[childNodeid]
1225
- if (checkMethod({ $cascader: $xeCascader, node: item })) {
1226
- if (isSelect) {
1227
- sLen++
1228
- } else if (indeterminateRowMaps[childNodeid]) {
1229
- hLen++
1230
- }
1231
- vLen++
1232
- } else {
1233
- if (isSelect) {
1234
- sLen++
1235
- } else if (indeterminateRowMaps[childNodeid]) {
1236
- hLen++
1237
- }
1238
- }
1239
- }
1240
- : item => {
1241
- const childNodeid = getNodeId(item)
1242
- const isSelect = selectCheckboxMaps[childNodeid]
1243
- if (isSelect) {
1244
- sLen++
1245
- } else if (indeterminateRowMaps[childNodeid]) {
1246
- hLen++
1247
- }
1248
- vLen++
1249
- }
1250
- )
1251
-
1252
- let isSelected = false
1253
- if (cLen > 0) {
1254
- if (vLen > 0) {
1255
- isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen
1256
- } else {
1257
- // 如果存在子项禁用
1258
- if ((sLen > 0 && sLen >= vLen)) {
1259
- isSelected = true
1260
- } else if (selectCheckboxMaps[nodeid]) {
1261
- isSelected = true
1262
- } else {
1263
- isSelected = false
1264
- }
1265
- }
1266
- } else {
1267
- // 如果无子项
1268
- isSelected = selectCheckboxMaps[nodeid]
1269
- }
1270
- const halfSelect = !isSelected && (sLen > 0 || hLen > 0)
1271
-
1272
- if (isSelected) {
1273
- selectCheckboxMaps[nodeid] = node
1274
- if (indeterminateRowMaps[nodeid]) {
1275
- delete indeterminateRowMaps[nodeid]
1276
- }
1277
- } else {
1278
- if (selectCheckboxMaps[nodeid]) {
1279
- delete selectCheckboxMaps[nodeid]
1280
- }
1281
- if (halfSelect) {
1282
- indeterminateRowMaps[nodeid] = node
1283
- } else {
1284
- if (indeterminateRowMaps[nodeid]) {
1285
- delete indeterminateRowMaps[nodeid]
1286
- }
1287
- }
1288
- }
1289
- })
1290
- reactData.updateCheckboxFlag++
1291
- }
1292
- }
1293
-
1294
- const changeCheckboxEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1295
- evnt.preventDefault()
1296
- evnt.stopPropagation()
1297
- // const { filterable } = props
1298
- const { currentItems } = reactData
1299
- const { selectCheckboxMaps, nodeMaps } = internalData
1300
- const childrenField = computeChildrenField.value
1301
- const mapChildrenField = computeMapChildrenField.value
1302
- const checkboxOpts = computeCheckboxOpts.value
1303
- const { checkStrictly, checkMode, checkMethod } = checkboxOpts
1304
- const treeOpts = computeTreeOpts.value
1305
- const { transform } = treeOpts
1306
- const nodeid = getNodeId(node)
1307
- const childList: any[] = node[transform ? mapChildrenField : childrenField]
1308
- const isExistChild = childList && childList.length > 0
1309
- const nodeItem = nodeMaps[nodeid] || {}
1310
- const nLevel = nodeItem.level
1311
- const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1312
- if (isDisabled) {
1313
- return
1314
- }
1315
- let isChecked = false
1316
- if (selectCheckboxMaps[nodeid]) {
1317
- delete selectCheckboxMaps[nodeid]
1318
- } else {
1319
- isChecked = true
1320
- selectCheckboxMaps[nodeid] = node
1321
- }
1322
- if (!checkStrictly) {
1323
- XEUtils.eachTree(childList, (childNode) => {
1324
- const childNodeid = getNodeId(childNode)
1325
- if (isChecked) {
1326
- if (!selectCheckboxMaps[childNodeid]) {
1327
- selectCheckboxMaps[childNodeid] = childNode
1328
- }
1329
- } else {
1330
- if (selectCheckboxMaps[childNodeid]) {
1331
- delete selectCheckboxMaps[childNodeid]
1332
- }
1333
- }
1334
- }, { children: transform ? mapChildrenField : childrenField })
1335
- }
1336
- selectCheckboxMaps[nodeid] = node
1337
- reactData.updateCheckboxFlag++
1338
- updateCheckboxStatus()
1339
- const nodeids = XEUtils.keys(selectCheckboxMaps)
1340
- const value = nodeids
1341
- changeEvent(evnt, value, node)
1342
- if (!currentItems.includes(nodeid)) {
1343
- changeCurrentEvent(evnt, node)
1344
- toggleExpandEvent(evnt, node, chunks, chunkIndex)
1345
- }
1346
- }
1347
-
1348
- const handleNodeClickEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1349
- const { multiple, showCheckbox, showRadio } = props
1350
- const treeOpts = computeTreeOpts.value
1351
- const radioOpts = computeRadioOpts.value
1352
- const checkboxOpts = computeCheckboxOpts.value
1353
- const childrenField = computeChildrenField.value
1354
- const mapChildrenField = computeMapChildrenField.value
1355
- const { transform, trigger } = treeOpts
1356
- const childList: any[] = node[transform ? mapChildrenField : childrenField]
1357
- let triggerCurrent = false
1358
- let triggerRadio = false
1359
- let triggerCheckbox = false
1360
- let triggerExpand = false
1361
- triggerCurrent = true
1362
- changeCurrentEvent(evnt, node)
1363
- if (trigger !== 'icon') {
1364
- triggerExpand = true
1365
- toggleExpandEvent(evnt, node, chunks, chunkIndex)
1366
- }
1367
- if (multiple) {
1368
- if (checkboxOpts.trigger === 'node' || (!showCheckbox && (!childList || !childList.length))) {
1369
- triggerCheckbox = true
1370
- changeCheckboxEvent(evnt, node, chunks, chunkIndex)
1371
- }
1372
- } else {
1373
- if (radioOpts.trigger === 'node' || (!showRadio && (!childList || !childList.length))) {
1374
- triggerRadio = true
1375
- changeRadioEvent(evnt, node, chunks, chunkIndex)
1376
- }
1377
- }
1378
- dispatchEvent('node-click', { node, triggerCurrent, triggerRadio, triggerCheckbox, triggerExpand }, evnt)
1379
- }
1380
-
1381
- const focusEvent = (evnt: FocusEvent) => {
1382
- const isDisabled = computeIsDisabled.value
1383
- if (!isDisabled) {
1384
- if (!reactData.visiblePanel) {
1385
- reactData.triggerFocusPanel = true
1386
- showOptionPanel(evnt)
1387
- setTimeout(() => {
1388
- reactData.triggerFocusPanel = false
1389
- }, 150)
1390
- }
1391
- }
1392
- dispatchEvent('focus', {}, evnt)
1393
- }
1394
-
1395
- const clickEvent = (evnt: MouseEvent) => {
1396
- evnt.preventDefault()
1397
- if (reactData.triggerFocusPanel) {
1398
- reactData.triggerFocusPanel = false
1399
- } else {
1400
- if (!reactData.visiblePanel) {
1401
- showOptionPanel(evnt)
1402
- }
1403
- }
1404
- dispatchEvent('click', {}, evnt)
1405
- }
1406
-
1407
- const blurEvent = (evnt: FocusEvent) => {
1408
- reactData.isActivated = false
1409
- dispatchEvent('blur', {}, evnt)
1410
- }
1411
-
1412
- const modelSearchEvent = (value: string) => {
1413
- reactData.searchValue = value
1414
- triggerSearchEvent(new Event('filter'))
1415
- }
1416
-
1417
- const handleSearchEvent = () => {
1418
- const { modelValue, remote } = props
1419
- const { searchValue } = reactData
1420
- const remoteOpts = computeRemoteOpts.value
1421
- const queryMethod = remoteOpts.queryMethod
1422
- if (remote && queryMethod && remoteOpts.enabled) {
1423
- reactData.searchLoading = true
1424
- Promise.resolve(
1425
- queryMethod({ $cascader: $xeCascader, searchValue, value: modelValue })
1426
- ).then(() => nextTick())
1427
- .catch(() => nextTick())
1428
- .finally(() => {
1429
- reactData.searchLoading = false
1430
- })
1431
- }
1432
- }
1433
-
1434
- const togglePanelEvent = (params: any) => {
1435
- const { $event } = params
1436
- $event.preventDefault()
1437
- if (reactData.triggerFocusPanel) {
1438
- reactData.triggerFocusPanel = false
1439
- } else {
1440
- if (reactData.visiblePanel) {
1441
- hideOptionPanel($event)
1442
- } else {
1443
- showOptionPanel($event)
1444
- }
1445
- }
1446
- }
1447
-
1448
- const cascaderPrivateMethods: CascaderPrivateMethods = {
1449
- isCheckedByCheckboxNodeId,
1450
- /**
1451
- * 用于树结构,给行数据加载子节点
1452
- */
1453
- loadChildrenNode (node, childRecords) {
1454
- const { separator } = props
1455
- const { nodeMaps } = internalData
1456
- const treeOpts = computeTreeOpts.value
1457
- const labelField = computeLabelField.value
1458
- const { lazy, transform } = treeOpts
1459
- if (!lazy) {
1460
- return Promise.resolve([])
1461
- }
1462
- const childrenField = computeChildrenField.value
1463
- const mapChildrenField = computeMapChildrenField.value
1464
- const parentNodeItem = nodeMaps[getNodeId(node)]
1465
- const parentLevel = parentNodeItem ? parentNodeItem.level : 0
1466
- const parentNodes = parentNodeItem ? parentNodeItem.nodes : []
1467
- return createNode(childRecords).then((nodeList) => {
1468
- XEUtils.eachTree(nodeList, (childRow, index, items, path, parent, nodes) => {
1469
- const itemNodeId = getNodeId(childRow)
1470
- nodeMaps[itemNodeId] = {
1471
- item: childRow,
1472
- index: -1,
1473
- $index: -1,
1474
- _index: -1,
1475
- items,
1476
- parent: parent || parentNodeItem.item,
1477
- nodes: parentNodes.concat(nodes),
1478
- level: parentLevel + nodes.length,
1479
- treeIndex: -1,
1480
- lineCount: 0,
1481
- treeLoaded: false,
1482
- fullLabel: nodes.map(item => item[labelField]).join((separator || ' / '))
1483
- }
1484
- }, { children: childrenField })
1485
- node[childrenField] = nodeList
1486
- if (transform) {
1487
- node[mapChildrenField] = nodeList
1488
- }
1489
- updateAfterDataIndex()
1490
- return nodeList
1491
- })
1492
- }
1493
- }
1494
-
1495
- Object.assign($xeCascader, cascaderMethods, cascaderPrivateMethods)
1496
-
1497
- const handleVisibleOrCheckMode = (mode: '' | 'all' | 'first' | 'last' | null | undefined, isExistChild: boolean, nLevel: number) => {
1498
- if (mode) {
1499
- if (mode === 'first') {
1500
- return !nLevel
1501
- }
1502
- if (mode === 'last') {
1503
- return !isExistChild
1504
- }
1505
- }
1506
- return true
1507
- }
1508
-
1509
- const renderRadio = (node: any, isExistChild: boolean, nLevel: number, isChecked: boolean, chunks: any[], chunkIndex: number) => {
1510
- const { showRadio } = props
1511
- const radioOpts = computeRadioOpts.value
1512
- const { checkMode, checkMethod, visibleMode, visibleMethod } = radioOpts
1513
- const isVisible = visibleMethod ? visibleMethod({ $cascader: $xeCascader, node }) : handleVisibleOrCheckMode(visibleMode, isExistChild, nLevel)
1514
- if (showRadio && isVisible) {
1515
- const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1516
- return h('div', {
1517
- class: ['vxe-tree--radio-option', {
1518
- 'is--checked': isChecked,
1519
- 'is--disabled': isDisabled
1520
- }],
1521
- onClick: (evnt) => {
1522
- if (!isDisabled) {
1523
- changeRadioEvent(evnt, node, chunks, chunkIndex)
1524
- }
1525
- }
1526
- }, [
1527
- h('span', {
1528
- class: ['vxe-radio--icon', isChecked ? getIcon().RADIO_CHECKED : (isDisabled ? getIcon().RADIO_DISABLED_UNCHECKED : getIcon().RADIO_UNCHECKED)]
1529
- })
1530
- ])
1531
- }
1532
- return renderEmptyElement($xeCascader)
1533
- }
1534
-
1535
- const renderCheckbox = (node: any, isExistChild: boolean, nLevel: number, isChecked: boolean, isIndeterminate: boolean, chunks: any[], chunkIndex: number) => {
1536
- const { showCheckbox } = props
1537
- const checkboxOpts = computeCheckboxOpts.value
1538
- const { checkMode, checkMethod, visibleMode, visibleMethod } = checkboxOpts
1539
- const isVisible = visibleMethod ? visibleMethod({ $cascader: $xeCascader, node }) : handleVisibleOrCheckMode(visibleMode, isExistChild, nLevel)
1540
- if (showCheckbox && isVisible) {
1541
- const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1542
- return h('div', {
1543
- class: ['vxe-cascader--checkbox-option', {
1544
- 'is--checked': isChecked,
1545
- 'is--indeterminate': isIndeterminate,
1546
- 'is--disabled': isDisabled
1547
- }],
1548
- onClick: (evnt) => {
1549
- if (!isDisabled) {
1550
- changeCheckboxEvent(evnt, node, chunks, chunkIndex)
1551
- }
1552
- }
1553
- }, [
1554
- h('span', {
1555
- class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().CHECKBOX_INDETERMINATE : (isChecked ? getIcon().CHECKBOX_CHECKED : (isDisabled ? getIcon().CHECKBOX_DISABLED_UNCHECKED : getIcon().CHECKBOX_UNCHECKED))]
1556
- })
1557
- ])
1558
- }
1559
- return renderEmptyElement($xeCascader)
1560
- }
1561
-
1562
- const renderNode = (node: any, nodeid: string, nodeIndex: number, chunks: any[], chunkIndex: number) => {
1563
- const { multiple } = props
1564
- const { currentNode, selectRadioKey, updateCheckboxFlag, updateExpandedFlag } = reactData
1565
- const { nodeMaps, selectCheckboxMaps, indeterminateRowMaps, treeExpandedMaps, treeExpandLazyLoadedMaps } = internalData
1566
- const treeOpts = computeTreeOpts.value
1567
- const { lazy, transform, iconLoaded, iconOpen, iconClose } = treeOpts
1568
- const childrenField = computeChildrenField.value
1569
- const mapChildrenField = computeMapChildrenField.value
1570
- const labelField = computeLabelField.value
1571
- const hasChildField = computeHasChildField.value
1572
- const childList: any[] = node[transform ? mapChildrenField : childrenField]
1573
- const isExistChild = childList && childList.length > 0
1574
- const iconSlot = slots.icon
1575
- const titleSlot = slots.title
1576
- const isExpand = updateExpandedFlag && treeExpandedMaps[nodeid]
1577
- const nodeItem = nodeMaps[nodeid] || {}
1578
- const nodeTitle = node[labelField]
1579
- const nLevel = nodeItem.level
1580
-
1581
- let isRadioChecked = false
1582
- if (!multiple) {
1583
- isRadioChecked = nodeid === selectRadioKey
1584
- }
1585
-
1586
- let isCheckboxChecked = false
1587
- let isIndeterminate = false
1588
- if (multiple) {
1589
- isCheckboxChecked = !!(updateCheckboxFlag && selectCheckboxMaps[nodeid])
1590
- isIndeterminate = !!(updateCheckboxFlag && indeterminateRowMaps[nodeid])
1591
- }
1592
-
1593
- let hasLazyChilds = false
1594
- let isLazyLoading = false
1595
- let isLazyLoaded = false
1596
- if (lazy) {
1597
- isLazyLoading = !!treeExpandLazyLoadedMaps[nodeid]
1598
- hasLazyChilds = node[hasChildField]
1599
- isLazyLoaded = !!nodeItem.treeLoaded
1600
- }
1601
- const nParams = { node }
1602
- return h('div', {
1603
- key: `${chunkIndex}_${nodeIndex}`,
1604
- class: ['vxe-cascader-chunk--node-item', {
1605
- 'is--current': currentNode && (currentNode === node || getNodeId(currentNode) === nodeid),
1606
- 'is-radio--checked': isRadioChecked,
1607
- 'is-checkbox--checked': isCheckboxChecked,
1608
- 'is-checkbox--indeterminate': isIndeterminate,
1609
- 'is--expand': isExpand
1610
- }],
1611
- title: nodeTitle,
1612
- onMousedown: (evnt) => {
1613
- const isLeftBtn = evnt.button === 0
1614
- if (isLeftBtn) {
1615
- evnt.stopPropagation()
1616
- }
1617
- },
1618
- onClick (evnt) {
1619
- handleNodeClickEvent(evnt, node, chunks, chunkIndex)
1620
- }
1621
- }, [
1622
- multiple ? renderCheckbox(node, isExistChild, nLevel, isCheckboxChecked, isIndeterminate, chunks, chunkIndex) : renderRadio(node, isExistChild, nLevel, isRadioChecked, chunks, chunkIndex),
1623
- h('div', {
1624
- class: 'vxe-cascader-chunk--node-item-inner'
1625
- }, [
1626
- h('div', {
1627
- class: 'vxe-cascader-chunk--node-item-title'
1628
- }, titleSlot ? getSlotVNs(titleSlot(nParams)) : nodeTitle)
1629
- ]),
1630
- treeOpts.showIcon && (lazy ? (isLazyLoaded ? isExistChild : hasLazyChilds) : isExistChild)
1631
- ? h('div', {
1632
- class: 'vxe-cascader-chunk--node-item-switcher'
1633
- }, [
1634
- [
1635
- h('div', {
1636
- class: 'vxe-cascader--node-item-icon',
1637
- onClick (evnt) {
1638
- if (treeOpts.trigger === 'icon') {
1639
- toggleExpandEvent(evnt, node, chunks, chunkIndex)
1640
- }
1641
- }
1642
- }, iconSlot
1643
- ? getSlotVNs(iconSlot(nParams))
1644
- : [
1645
- h('i', {
1646
- class: isLazyLoading ? (iconLoaded || getIcon().CASCADER_NODE_LOADED) : (isExpand ? (iconOpen || getIcon().CASCADER_NODE_OPEN) : (iconClose || getIcon().CASCADER_NODE_CLOSE))
1647
- })
1648
- ])
1649
- ]
1650
- ])
1651
- : renderEmptyElement($xeCascader)
1652
- ])
1653
- }
1654
-
1655
- const renderVN = () => {
1656
- const { className, modelValue, multiple, loading, filterable, showTotalButton, showCheckedButton, showClearButton, showCloseButton } = props
1657
- const { initialized, isActivated, isAniVisible, visiblePanel, searchValue, currentCunkList } = reactData
1658
- const { listVirtualYOpts } = internalData
1659
- const vSize = computeSize.value
1660
- const isDisabled = computeIsDisabled.value
1661
- const selectLabel = computeSelectLabel.value
1662
- const btnTransfer = computeBtnTransfer.value
1663
- const formReadonly = computeFormReadonly.value
1664
- const popupWrapperStyle = computePopupWrapperStyle.value
1665
- const headerSlot = slots.header
1666
- const footerSlot = slots.footer
1667
- const prefixSlot = slots.prefix
1668
- const popupOpts = computePopupOpts.value
1669
- const popupClassName = popupOpts.className
1670
-
1671
- if (formReadonly) {
1672
- return h('div', {
1673
- ref: refElem,
1674
- class: ['vxe-cascader--readonly', className]
1675
- }, [
1676
- h('span', {
1677
- class: 'vxe-cascader-label'
1678
- }, selectLabel)
1679
- ])
1680
- }
1681
- const selectVals = XEUtils.eqNull(modelValue) ? [] : (XEUtils.isArray(modelValue) ? modelValue : [modelValue])
1682
- return h('div', {
1683
- ref: refElem,
1684
- class: ['vxe-cascader', className ? (XEUtils.isFunction(className) ? className({ $cascader: $xeCascader }) : className) : '', {
1685
- [`size--${vSize}`]: vSize,
1686
- 'is--filterable': filterable,
1687
- 'is--visible': visiblePanel,
1688
- 'is--disabled': isDisabled,
1689
- 'is--loading': loading,
1690
- 'is--active': isActivated
1691
- }]
1692
- }, [
1693
- h(VxeInputComponent, {
1694
- ref: refInput,
1695
- clearable: props.clearable,
1696
- placeholder: loading ? getI18n('vxe.select.loadingText') : props.placeholder,
1697
- editable: false,
1698
- disabled: isDisabled,
1699
- type: 'text',
1700
- prefixIcon: props.prefixIcon,
1701
- suffixIcon: loading ? getIcon().TREE_SELECT_LOADED : (visiblePanel ? getIcon().TREE_SELECT_OPEN : getIcon().TREE_SELECT_CLOSE),
1702
- modelValue: loading ? '' : selectLabel,
1703
- title: selectLabel,
1704
- onClear: clearEvent,
1705
- onClick: clickEvent,
1706
- onFocus: focusEvent,
1707
- onBlur: blurEvent,
1708
- onSuffixClick: togglePanelEvent
1709
- }, prefixSlot
1710
- ? {
1711
- prefix: () => prefixSlot({})
1712
- }
1713
- : {}),
1714
- h(Teleport, {
1715
- to: 'body',
1716
- disabled: btnTransfer ? !initialized : true
1717
- }, [
1718
- h('div', {
1719
- ref: refOptionPanel,
1720
- class: ['vxe-table--ignore-clear vxe-cascader--panel', popupClassName ? (XEUtils.isFunction(popupClassName) ? popupClassName({ $cascader: $xeCascader }) : popupClassName) : '', {
1721
- [`size--${vSize}`]: vSize,
1722
- 'is--transfer': btnTransfer,
1723
- 'ani--leave': !loading && isAniVisible,
1724
- 'ani--enter': !loading && visiblePanel
1725
- }],
1726
- placement: reactData.panelPlacement,
1727
- style: popupWrapperStyle
1728
- }, initialized
1729
- ? [
1730
- h('div', {
1731
- class: 'vxe-cascader--panel-wrapper'
1732
- }, [
1733
- filterable
1734
- ? h('div', {
1735
- class: 'vxe-cascader--panel-search'
1736
- }, [
1737
- h(VxeInputComponent, {
1738
- ref: refInpSearch,
1739
- class: 'vxe-cascader-search--input',
1740
- modelValue: searchValue,
1741
- clearable: true,
1742
- disabled: false,
1743
- readonly: false,
1744
- placeholder: getI18n('vxe.cascader.search'),
1745
- prefixIcon: getIcon().INPUT_SEARCH,
1746
- 'onUpdate:modelValue': modelSearchEvent
1747
- })
1748
- ])
1749
- : renderEmptyElement($xeCascader),
1750
- (showCheckedButton && multiple) || showClearButton || headerSlot
1751
- ? h('div', {
1752
- class: 'vxe-cascader--panel-header'
1753
- }, headerSlot
1754
- ? headerSlot({})
1755
- : [
1756
- h('div', {
1757
- class: 'vxe-cascader--header-button'
1758
- }, [
1759
- (showCheckedButton && multiple) || showClearButton
1760
- ? h('div', {
1761
- class: 'vxe-cascader--selected-btns'
1762
- }, [
1763
- (showCheckedButton && multiple)
1764
- ? h(VxeButtonComponent, {
1765
- content: getI18n('vxe.treeSelect.allChecked'),
1766
- mode: 'text',
1767
- onClick: allCheckedPanelEvent
1768
- })
1769
- : renderEmptyElement($xeCascader),
1770
- showClearButton
1771
- ? h(VxeButtonComponent, {
1772
- content: getI18n('vxe.treeSelect.clearChecked'),
1773
- mode: 'text',
1774
- onClick: clearCheckedPanelEvent
1775
- })
1776
- : renderEmptyElement($xeCascader)
1777
- ])
1778
- : renderEmptyElement($xeCascader)
1779
- ])
1780
- ])
1781
- : renderEmptyElement($xeCascader),
1782
- h('div', {
1783
- class: 'vxe-cascader--panel-body'
1784
- }, [
1785
- h('div', {
1786
- ref: refChunkWrapper,
1787
- class: 'vxe-cascader-chunk--wrapper'
1788
- }, [
1789
- currentCunkList.map((chunks, chunkIndex) => {
1790
- return h('div', {
1791
- key: chunkIndex,
1792
- class: 'vxe-cascader-chunk--item-wrapper'
1793
- }, [
1794
- h(VxeListComponent, {
1795
- data: chunks,
1796
- virtualYConfig: listVirtualYOpts
1797
- }, {
1798
- default (slotParams: VxeListSlotTypes.DefaultSlotParams) {
1799
- const { items } = slotParams
1800
- return items.map((node, nodeIndex) => {
1801
- const nodeid = getNodeId(node)
1802
- return renderNode(node, nodeid, nodeIndex, chunks, chunkIndex)
1803
- })
1804
- }
1805
- })
1806
- ])
1807
- })
1808
- ])
1809
- ]),
1810
- footerSlot || showTotalButton || showCloseButton
1811
- ? h('div', {
1812
- class: 'vxe-cascader--panel-footer'
1813
- }, footerSlot
1814
- ? footerSlot({})
1815
- : [
1816
- h('div', {
1817
- class: 'vxe-cascader--footer-button'
1818
- }, [
1819
- showTotalButton
1820
- ? h('div', {
1821
- class: 'vxe-cascader--total-btns'
1822
- }, getI18n('vxe.treeSelect.total', [selectVals.length]))
1823
- : renderEmptyElement($xeCascader),
1824
- showCloseButton
1825
- ? h('div', {
1826
- class: 'vxe-cascader--oper-btns'
1827
- }, [
1828
- h(VxeButtonComponent, {
1829
- content: getI18n('vxe.select.close'),
1830
- mode: 'text',
1831
- onClick: closePanelEvent
1832
- })
1833
- ])
1834
- : renderEmptyElement($xeCascader)
1835
- ])
1836
- ])
1837
- : renderEmptyElement($xeCascader)
1838
- ])
1839
- ]
1840
- : [])
1841
- ])
1842
- ])
1843
- }
1844
-
1845
- watch(() => props.modelValue, () => {
1846
- if (!internalData.isUpdateMode) {
1847
- updateModelChecked()
1848
- handleCurrentItems()
1849
- updateCurrentChunk()
1850
- }
1851
- internalData.isUpdateMode = false
1852
- })
1853
-
1854
- watch(() => props.options, () => {
1855
- cacheNodeMap()
1856
- })
1857
-
1858
- const dataFlag = ref(0)
1859
- watch(() => props.options ? props.options.length : 0, () => {
1860
- dataFlag.value++
1861
- })
1862
- watch(() => props.options, () => {
1863
- dataFlag.value++
1864
- })
1865
- watch(dataFlag, () => {
1866
- loadData(props.options || [])
1867
- })
1868
-
1869
- loadData(props.options || [])
1870
-
1871
- onMounted(() => {
1872
- globalEvents.on($xeCascader, 'mousedown', handleGlobalMousedownEvent)
1873
- globalEvents.on($xeCascader, 'blur', handleGlobalBlurEvent)
1874
- globalEvents.on($xeCascader, 'resize', handleGlobalResizeEvent)
1875
- globalEvents.on($xeCascader, 'scroll', handleGlobalScrollEvent)
1876
- })
1877
-
1878
- onUnmounted(() => {
1879
- globalEvents.off($xeCascader, 'mousedown')
1880
- globalEvents.off($xeCascader, 'blur')
1881
- globalEvents.off($xeCascader, 'resize')
1882
- globalEvents.off($xeCascader, 'scroll')
1883
- XEUtils.assign(reactData, createReactData())
1884
- XEUtils.assign(internalData, createInternalData())
1885
- })
1886
-
1887
- provide('$xeCascader', $xeCascader)
1888
-
1889
- $xeCascader.renderVN = renderVN
1890
-
1891
- return $xeCascader
1892
- },
1893
- render () {
1894
- return this.renderVN()
1895
- }
1896
- })
1
+ import { ref, computed, h, PropType, nextTick, inject, provide, reactive, Teleport, onMounted, onUnmounted, watch } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import { VxeUI } from '@vxe-ui/core'
4
+ import { getEventTargetNode, updatePanelPlacement, toCssUnit } from '../../ui/src/dom'
5
+ import { getLastZIndex, nextZIndex } from '../../ui/src/utils'
6
+ import { enNodeValue, deNodeValue } from './util'
7
+ import XEUtils from 'xe-utils'
8
+ import VxeListComponent from '../../list'
9
+ import VxeInputComponent from '../../input'
10
+ import VxeButtonComponent from '../../button'
11
+
12
+ import type {
13
+ CascaderReactData,
14
+ VxeCascaderEmits,
15
+ CascaderInternalData,
16
+ VxeButtonEvents,
17
+ ValueOf,
18
+ VxeComponentStyleType,
19
+ VxeCascaderDefines,
20
+ CascaderPrivateRef,
21
+ CascaderPrivateMethods,
22
+ CascaderMethods,
23
+ VxeCascaderPrivateComputed,
24
+ VxeCascaderPropTypes,
25
+ VxeCascaderConstructor,
26
+ VxeListSlotTypes,
27
+ VxeFormDefines,
28
+ VxeDrawerConstructor,
29
+ VxeDrawerMethods,
30
+ VxeCascaderPrivateMethods,
31
+ VxeFormConstructor,
32
+ VxeFormPrivateMethods,
33
+ VxeInputConstructor,
34
+ VxeModalConstructor,
35
+ VxeModalMethods
36
+ } from '../../../types'
37
+ import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/components/table'
38
+
39
+ const { getConfig, getI18n, getIcon, globalEvents, createEvent, useFns, renderEmptyElement, getSlotVNs } = VxeUI
40
+
41
+ /**
42
+ * 生成节点的唯一主键
43
+ */
44
+ function getNodeUniqueId() {
45
+ return XEUtils.uniqueId('node_')
46
+ }
47
+
48
+ function createReactData(): CascaderReactData {
49
+ return {
50
+ initialized: false,
51
+ searchValue: '',
52
+ searchLoading: false,
53
+ currentCunkList: [],
54
+ currentItems: [],
55
+ currentNode: null,
56
+ panelIndex: 0,
57
+ panelStyle: {},
58
+ panelPlacement: null,
59
+ triggerFocusPanel: false,
60
+ visiblePanel: false,
61
+ isAniVisible: false,
62
+ isActivated: false,
63
+ selectRadioKey: null,
64
+ treeList: [],
65
+ updateExpandedFlag: 1,
66
+ updateCheckboxFlag: 1,
67
+ fullOptFlag: 1,
68
+ lazyOptFlag: 1
69
+ }
70
+ }
71
+
72
+ function createInternalData(): CascaderInternalData {
73
+ return {
74
+ // hpTimeout: undefined,
75
+ listVirtualYOpts: {
76
+ enabled: true,
77
+ gt: 20
78
+ },
79
+ afterTreeList: [],
80
+ treeFullData: [],
81
+ afterVisibleList: [],
82
+ nodeMaps: {},
83
+ fullNodeMaps: {},
84
+ lazyNodeMaps: {},
85
+ indeterminateRowMaps: {},
86
+ selectCheckboxMaps: {},
87
+ treeExpandedMaps: {},
88
+ treeExpandLazyLoadedMaps: {}
89
+ // isUpdateMode: false
90
+ }
91
+ }
92
+
93
+ export default defineVxeComponent({
94
+ name: 'VxeCascader',
95
+ props: {
96
+ modelValue: [String, Number, Array] as PropType<VxeCascaderPropTypes.ModelValue>,
97
+ clearable: Boolean as PropType<VxeCascaderPropTypes.Clearable>,
98
+ placeholder: {
99
+ type: String as PropType<VxeCascaderPropTypes.Placeholder>,
100
+ default: () => (XEUtils.eqNull(getConfig().cascader.placeholder) ? getI18n('vxe.base.pleaseSelect') : getConfig().cascader.placeholder)
101
+ },
102
+ readonly: {
103
+ type: Boolean as PropType<VxeCascaderPropTypes.Readonly>,
104
+ default: null
105
+ },
106
+ loading: Boolean as PropType<VxeCascaderPropTypes.Loading>,
107
+ disabled: {
108
+ type: Boolean as PropType<VxeCascaderPropTypes.Disabled>,
109
+ default: null
110
+ },
111
+ filterable: Boolean as PropType<VxeCascaderPropTypes.Filterable>,
112
+ filterConfig: Object as PropType<VxeCascaderPropTypes.FilterConfig>,
113
+ showFullLabel: {
114
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowFullLabel>,
115
+ default: () => getConfig().cascader.showFullLabel
116
+ },
117
+ separator: {
118
+ type: String as PropType<VxeCascaderPropTypes.Separator>,
119
+ default: () => getConfig().cascader.separator
120
+ },
121
+ multiple: Boolean as PropType<VxeCascaderPropTypes.Multiple>,
122
+ className: [String, Function] as PropType<VxeCascaderPropTypes.ClassName>,
123
+ prefixIcon: String as PropType<VxeCascaderPropTypes.PrefixIcon>,
124
+ lazyOptions: Array as PropType<VxeCascaderPropTypes.LazyOptions>,
125
+ options: Array as PropType<VxeCascaderPropTypes.Options>,
126
+ optionProps: Object as PropType<VxeCascaderPropTypes.OptionProps>,
127
+ size: {
128
+ type: String as PropType<VxeCascaderPropTypes.Size>,
129
+ default: () => getConfig().cascader.size || getConfig().size
130
+ },
131
+ treeConfig: Object as PropType<VxeCascaderPropTypes.TreeConfig>,
132
+ showRadio: {
133
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowRadio>,
134
+ default: () => getConfig().cascader.showRadio
135
+ },
136
+ radioConfig: Object as PropType<VxeCascaderPropTypes.RadioConfig>,
137
+ showCheckbox: {
138
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowCheckbox>,
139
+ default: () => getConfig().cascader.showCheckbox
140
+ },
141
+ checkboxConfig: Object as PropType<VxeCascaderPropTypes.CheckboxConfig>,
142
+ remote: Boolean as PropType<VxeCascaderPropTypes.Remote>,
143
+ remoteConfig: Function as PropType<VxeCascaderPropTypes.RemoteConfig>,
144
+ popupConfig: Object as PropType<VxeCascaderPropTypes.PopupConfig>,
145
+ checkedClosable: {
146
+ type: Boolean as PropType<VxeCascaderPropTypes.CheckedClosable>,
147
+ default: () => getConfig().cascader.checkedClosable
148
+ },
149
+ clearClosable: {
150
+ type: Boolean as PropType<VxeCascaderPropTypes.ClearClosable>,
151
+ default: () => getConfig().cascader.clearClosable
152
+ },
153
+ showCloseButton: {
154
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowCloseButton>,
155
+ default: () => getConfig().cascader.showCloseButton
156
+ },
157
+ showTotalButton: {
158
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowTotalButton>,
159
+ default: () => getConfig().cascader.showTotalButton
160
+ },
161
+ showCheckedButton: {
162
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowCheckedButton>,
163
+ default: () => getConfig().cascader.showCheckedButton
164
+ },
165
+ showClearButton: {
166
+ type: Boolean as PropType<VxeCascaderPropTypes.ShowClearButton>,
167
+ default: () => getConfig().cascader.showClearButton
168
+ }
169
+ },
170
+ emits: ['update:modelValue', 'change', 'all-change', 'clear', 'blur', 'focus', 'click', 'node-click', 'node-expand', 'current-change', 'radio-change', 'checkbox-change', 'load-success', 'load-error', 'visible-change'] as VxeCascaderEmits,
171
+ setup(props, context) {
172
+ const { emit, slots } = context
173
+
174
+ const $xeModal = inject<(VxeModalConstructor & VxeModalMethods) | null>('$xeModal', null)
175
+ const $xeDrawer = inject<(VxeDrawerConstructor & VxeDrawerMethods) | null>('$xeDrawer', null)
176
+ const $xeTable = inject<(VxeTableConstructor & VxeTablePrivateMethods) | null>('$xeTable', null)
177
+ const $xeForm = inject<(VxeFormConstructor & VxeFormPrivateMethods) | null>('$xeForm', null)
178
+ const formItemInfo = inject<VxeFormDefines.ProvideItemInfo | null>('xeFormItemInfo', null)
179
+
180
+ const xID = XEUtils.uniqueId()
181
+
182
+ const { computeSize } = useFns.useSize(props)
183
+
184
+ const refElem = ref<HTMLDivElement>()
185
+ const refInput = ref<VxeInputConstructor>()
186
+ const refInpSearch = ref<VxeInputConstructor>()
187
+ const refChunkWrapper = ref<HTMLDivElement>()
188
+ const refOptionPanel = ref<HTMLDivElement>()
189
+
190
+ const reactData = reactive(createReactData())
191
+ const internalData = createInternalData()
192
+
193
+ const refMaps: CascaderPrivateRef = {
194
+ refElem
195
+ }
196
+
197
+ const computeFormReadonly = computed(() => {
198
+ const { readonly } = props
199
+ if (readonly === null) {
200
+ if ($xeForm) {
201
+ return $xeForm.props.readonly
202
+ }
203
+ return false
204
+ }
205
+ return readonly
206
+ })
207
+
208
+ const computeIsDisabled = computed(() => {
209
+ const { disabled } = props
210
+ if (disabled === null) {
211
+ if ($xeForm) {
212
+ return $xeForm.props.disabled
213
+ }
214
+ return false
215
+ }
216
+ return disabled
217
+ })
218
+
219
+ const computeBtnTransfer = computed(() => {
220
+ const popupOpts = computePopupOpts.value
221
+ const { transfer } = popupOpts
222
+ if (XEUtils.isBoolean(transfer)) {
223
+ return transfer
224
+ }
225
+ if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
226
+ return true
227
+ }
228
+ return false
229
+ })
230
+
231
+ const computeTreeOpts = computed(() => {
232
+ return Object.assign({}, getConfig().cascader.treeConfig, props.treeConfig)
233
+ })
234
+
235
+ const computeRadioOpts = computed(() => {
236
+ return Object.assign({}, getConfig().cascader.radioConfig, props.radioConfig)
237
+ })
238
+
239
+ const computeCheckboxOpts = computed(() => {
240
+ return Object.assign({}, getConfig().cascader.checkboxConfig, props.checkboxConfig)
241
+ })
242
+
243
+ const computePopupOpts = computed(() => {
244
+ return Object.assign({}, getConfig().cascader.popupConfig, props.popupConfig)
245
+ })
246
+
247
+ const computePropsOpts = computed(() => {
248
+ return props.optionProps || {}
249
+ })
250
+
251
+ const computeLabelField = computed(() => {
252
+ const propsOpts = computePropsOpts.value
253
+ return propsOpts.label || 'label'
254
+ })
255
+
256
+ const computeValueField = computed(() => {
257
+ const propsOpts = computePropsOpts.value
258
+ return propsOpts.value || 'value'
259
+ })
260
+
261
+ const computeKeyField = computed(() => {
262
+ const treeOpts = computeTreeOpts.value
263
+ return treeOpts.keyField || 'id'
264
+ })
265
+
266
+ const computeParentField = computed(() => {
267
+ const treeOpts = computeTreeOpts.value
268
+ return treeOpts.parentField || 'parentId'
269
+ })
270
+
271
+ const computeChildrenField = computed(() => {
272
+ const treeOpts = computeTreeOpts.value
273
+ return treeOpts.childrenField || 'children'
274
+ })
275
+
276
+ const computeMapChildrenField = computed(() => {
277
+ const treeOpts = computeTreeOpts.value
278
+ return treeOpts.mapChildrenField || 'mapChildren'
279
+ })
280
+
281
+ const computeHasChildField = computed(() => {
282
+ const treeOpts = computeTreeOpts.value
283
+ return treeOpts.hasChildField || 'hasChild'
284
+ })
285
+
286
+ const computeRemoteOpts = computed(() => {
287
+ return Object.assign({}, getConfig().cascader.remoteConfig, props.remoteConfig)
288
+ })
289
+
290
+ const computeSelectVals = computed(() => {
291
+ const { modelValue } = props
292
+ return XEUtils.eqNull(modelValue) ? [] : XEUtils.isArray(modelValue) ? modelValue : [modelValue]
293
+ })
294
+
295
+ const computeSelectLabel = computed(() => {
296
+ const { showFullLabel } = props
297
+ const { fullOptFlag, lazyOptFlag } = reactData
298
+ const { fullNodeMaps, lazyNodeMaps } = internalData
299
+ const labelField = computeLabelField.value
300
+ const selectVals = computeSelectVals.value
301
+ return selectVals
302
+ .map((val) => {
303
+ const cacheItem = fullNodeMaps[val]
304
+ if (fullOptFlag && cacheItem) {
305
+ return showFullLabel ? cacheItem.fullLabel : cacheItem.item[labelField]
306
+ }
307
+ if (lazyOptFlag) {
308
+ const lazyCacheItem = lazyNodeMaps[val]
309
+ if (lazyCacheItem) {
310
+ return showFullLabel ? lazyCacheItem.fullLabel : lazyCacheItem.item[labelField]
311
+ }
312
+ }
313
+ return val
314
+ })
315
+ .join(', ')
316
+ })
317
+
318
+ const computePopupWrapperStyle = computed(() => {
319
+ const { currentCunkList, panelStyle } = reactData
320
+ const popupOpts = computePopupOpts.value
321
+ const { height, nodeWidth, nodeHeight } = popupOpts
322
+ const stys: VxeComponentStyleType = {
323
+ ...panelStyle,
324
+ '--vxe-ui-cascader-chunk-size': currentCunkList.length
325
+ }
326
+ if (height) {
327
+ stys['--vxe-ui-cascader-chunk-height'] = toCssUnit(height)
328
+ }
329
+ if (nodeWidth) {
330
+ stys['--vxe-ui-cascader-node-width'] = toCssUnit(nodeWidth)
331
+ }
332
+ if (nodeHeight) {
333
+ stys['--vxe-ui-cascader-node-height'] = toCssUnit(nodeHeight)
334
+ }
335
+ return stys
336
+ })
337
+
338
+ const computeFilterOpts = computed(() => {
339
+ return Object.assign({}, getConfig().cascader.filterConfig, props.filterConfig)
340
+ })
341
+
342
+ const computeMaps: VxeCascaderPrivateComputed = {}
343
+
344
+ const $xeCascader = {
345
+ xID,
346
+ props,
347
+ context,
348
+ reactData,
349
+ internalData,
350
+
351
+ getRefMaps: () => refMaps,
352
+ getComputeMaps: () => computeMaps
353
+ } as unknown as VxeCascaderConstructor & VxeCascaderPrivateMethods
354
+
355
+ const dispatchEvent = (type: ValueOf<VxeCascaderEmits>, params: Record<string, any>, evnt: Event | null) => {
356
+ emit(type, createEvent(evnt, { $cascader: $xeCascader }, params))
357
+ }
358
+
359
+ const emitModel = (value: any) => {
360
+ emit('update:modelValue', value)
361
+ }
362
+
363
+ const cascaderMethods: CascaderMethods = {
364
+ dispatchEvent
365
+ }
366
+
367
+ const getNodeId = (node: any) => {
368
+ if (!node) {
369
+ return ''
370
+ }
371
+ const valueField = computeValueField.value
372
+ const nodeKey = node[valueField]
373
+ return enNodeValue(nodeKey)
374
+ }
375
+
376
+ const isPathInTree = (treeData: any[], pathIds: string[]) => {
377
+ if (!pathIds || !pathIds.length) {
378
+ return false
379
+ }
380
+ let currentNodes = treeData
381
+ for (const nodeid of pathIds) {
382
+ const found = currentNodes.find((node) => getNodeId(node) === nodeid)
383
+ if (!found) {
384
+ return false
385
+ }
386
+ currentNodes = found.children || []
387
+ }
388
+ return true
389
+ }
390
+
391
+ const isCheckedByCheckboxNodeId = (nodeid: any) => {
392
+ const { updateCheckboxFlag } = reactData
393
+ const { selectCheckboxMaps } = internalData
394
+ return !!(updateCheckboxFlag && selectCheckboxMaps[nodeid])
395
+ }
396
+
397
+ const handleCheckedCheckboxNode = (nodeList: any[], checked: boolean) => {
398
+ const { selectCheckboxMaps } = internalData
399
+ const mapChildrenField = computeMapChildrenField.value
400
+ const childrenField = computeChildrenField.value
401
+ const checkboxOpts = computeCheckboxOpts.value
402
+ const { checkStrictly } = checkboxOpts
403
+ const treeOpts = computeTreeOpts.value
404
+ const { transform } = treeOpts
405
+ const handleSelect = (node: any) => {
406
+ const nodeid = getNodeId(node)
407
+ if (checked) {
408
+ if (!selectCheckboxMaps[nodeid]) {
409
+ selectCheckboxMaps[nodeid] = node
410
+ }
411
+ } else {
412
+ if (selectCheckboxMaps[nodeid]) {
413
+ delete selectCheckboxMaps[nodeid]
414
+ }
415
+ }
416
+ }
417
+ if (checkStrictly) {
418
+ nodeList.forEach(handleSelect)
419
+ } else {
420
+ XEUtils.eachTree(nodeList, handleSelect, { children: transform ? mapChildrenField : childrenField })
421
+ }
422
+ reactData.updateCheckboxFlag++
423
+ updateCheckboxStatus()
424
+ }
425
+
426
+ const createNode = (records: any[]) => {
427
+ const valueField = computeValueField.value
428
+ return Promise.resolve(
429
+ records.map((obj) => {
430
+ const item = { ...obj }
431
+ let nodeid = getNodeId(item)
432
+ if (!nodeid) {
433
+ nodeid = getNodeUniqueId()
434
+ XEUtils.set(item, valueField, nodeid)
435
+ }
436
+ return item
437
+ })
438
+ )
439
+ }
440
+
441
+ const handleSetCheckboxByNodeId = (nodeKeys: any | any[], checked: boolean) => {
442
+ const { nodeMaps } = internalData
443
+ if (nodeKeys) {
444
+ if (!XEUtils.isArray(nodeKeys)) {
445
+ nodeKeys = [nodeKeys]
446
+ }
447
+ const nodeList: any[] = []
448
+ nodeKeys.forEach((nodeKey: string) => {
449
+ const nodeid = enNodeValue(nodeKey)
450
+ const nodeItem = nodeMaps[nodeid]
451
+ if (nodeItem) {
452
+ nodeList.push(nodeItem.item)
453
+ }
454
+ })
455
+ handleCheckedCheckboxNode(nodeList, checked)
456
+ }
457
+ return nextTick()
458
+ }
459
+
460
+ const updateCheckboxChecked = (nodeKeys: any[]) => {
461
+ internalData.selectCheckboxMaps = {}
462
+ handleSetCheckboxByNodeId(nodeKeys, true)
463
+ }
464
+
465
+ const updateModelChecked = () => {
466
+ const { modelValue } = props
467
+ const { nodeMaps } = internalData
468
+ const expandedMaps: Record<string, boolean> = {}
469
+ if (props.multiple) {
470
+ if (modelValue && modelValue.length) {
471
+ updateCheckboxChecked(modelValue)
472
+ }
473
+ } else {
474
+ if (modelValue) {
475
+ const nodeid = enNodeValue(XEUtils.isArray(modelValue) ? modelValue[0] : modelValue)
476
+ const itemRest = nodeMaps[nodeid]
477
+ if (itemRest) {
478
+ itemRest.nodes.forEach((item) => {
479
+ expandedMaps[getNodeId(item)] = true
480
+ })
481
+ reactData.selectRadioKey = nodeid
482
+ }
483
+ }
484
+ }
485
+ internalData.treeExpandedMaps = expandedMaps
486
+ }
487
+
488
+ const cacheNodeMap = () => {
489
+ const { separator } = props
490
+ const { treeFullData } = internalData
491
+ const valueField = computeValueField.value
492
+ const labelField = computeLabelField.value
493
+ const childrenField = computeChildrenField.value
494
+ const keyMaps: Record<string, VxeCascaderDefines.NodeCacheItem> = {}
495
+ const fullMaps: Record<string, VxeCascaderDefines.NodeCacheItem> = {}
496
+ XEUtils.eachTree(
497
+ treeFullData,
498
+ (item, index, items, path, parenItem, nodes) => {
499
+ let nodeid = getNodeId(item)
500
+ if (!nodeid) {
501
+ nodeid = getNodeUniqueId()
502
+ item[valueField] = nodeid
503
+ }
504
+ const nodeVal = item[valueField]
505
+ const itemRest = {
506
+ item,
507
+ index,
508
+ $index: -1,
509
+ _index: -1,
510
+ items,
511
+ parent: parenItem,
512
+ nodes,
513
+ level: nodes.length - 1,
514
+ treeIndex: index,
515
+ lineCount: 0,
516
+ treeLoaded: false,
517
+ fullLabel: nodes.map((item) => item[labelField]).join(separator || ' / ')
518
+ }
519
+ keyMaps[nodeid] = itemRest
520
+ fullMaps[nodeVal] = itemRest
521
+ },
522
+ { children: childrenField }
523
+ )
524
+ internalData.nodeMaps = keyMaps
525
+ internalData.fullNodeMaps = fullMaps
526
+ reactData.fullOptFlag++
527
+ }
528
+
529
+ const updateAfterDataIndex = () => {
530
+ const { separator } = props
531
+ const { afterTreeList, nodeMaps } = internalData
532
+ const labelField = computeLabelField.value
533
+ const childrenField = computeChildrenField.value
534
+ const mapChildrenField = computeMapChildrenField.value
535
+ const treeOpts = computeTreeOpts.value
536
+ const { transform } = treeOpts
537
+ let vtIndex = 0
538
+ XEUtils.eachTree(
539
+ afterTreeList,
540
+ (item, index, items, path, parenItem, nodes) => {
541
+ const nodeid = getNodeId(item)
542
+ const nodeItem = nodeMaps[nodeid]
543
+ if (nodeItem) {
544
+ nodeItem.items = items
545
+ nodeItem.treeIndex = index
546
+ nodeItem._index = vtIndex
547
+ } else {
548
+ const rest = {
549
+ item,
550
+ index,
551
+ $index: -1,
552
+ _index: vtIndex,
553
+ items,
554
+ parent: parenItem,
555
+ nodes,
556
+ level: nodes.length - 1,
557
+ treeIndex: index,
558
+ lineCount: 0,
559
+ treeLoaded: false,
560
+ fullLabel: nodes.map((item) => item[labelField]).join(separator || ' / ')
561
+ }
562
+ nodeMaps[nodeid] = rest
563
+ }
564
+ vtIndex++
565
+ },
566
+ { children: transform ? mapChildrenField : childrenField }
567
+ )
568
+ }
569
+
570
+ const updateAfterFullData = () => {
571
+ const { searchValue } = reactData
572
+ const { treeFullData, lastFilterValue } = internalData
573
+ const labelField = computeLabelField.value
574
+ const childrenField = computeChildrenField.value
575
+ const mapChildrenField = computeMapChildrenField.value
576
+ const treeOpts = computeTreeOpts.value
577
+ const { transform } = treeOpts
578
+ const filterOpts = computeFilterOpts.value
579
+ const { beforeFilterMethod, filterMethod, afterFilterMethod } = filterOpts
580
+ let fullList = treeFullData
581
+ let treeList = fullList
582
+ let filterStr = ''
583
+ if (searchValue) {
584
+ filterStr = `${searchValue}`
585
+ const handleSearch = filterMethod
586
+ ? (item: any) => {
587
+ return filterMethod({
588
+ $cascader: $xeCascader,
589
+ node: item,
590
+ filterValue: filterStr
591
+ })
592
+ }
593
+ : (item: any) => {
594
+ return String(item[labelField]).toLowerCase().indexOf(filterStr.toLowerCase()) > -1
595
+ }
596
+ const bafParams = { $cascader: $xeCascader, filterValue: filterStr }
597
+ if (beforeFilterMethod) {
598
+ beforeFilterMethod(bafParams)
599
+ }
600
+ if (transform) {
601
+ treeList = XEUtils.searchTree(treeFullData, handleSearch, {
602
+ original: true,
603
+ isEvery: false,
604
+ children: childrenField,
605
+ mapChildren: mapChildrenField
606
+ })
607
+ fullList = treeList
608
+ } else {
609
+ fullList = treeFullData.filter(handleSearch)
610
+ }
611
+ internalData.lastFilterValue = filterStr
612
+ nextTick(() => {
613
+ if (afterFilterMethod) {
614
+ afterFilterMethod(bafParams)
615
+ }
616
+ })
617
+ } else {
618
+ if (transform) {
619
+ treeList = XEUtils.searchTree(treeFullData, () => true, {
620
+ original: true,
621
+ isEvery: false,
622
+ children: childrenField,
623
+ mapChildren: mapChildrenField
624
+ })
625
+ fullList = treeList
626
+ if (lastFilterValue) {
627
+ const bafParams = { $cascader: $xeCascader, filterValue: filterStr }
628
+ if (beforeFilterMethod) {
629
+ beforeFilterMethod(bafParams)
630
+ }
631
+ // 取消筛选时自动收起
632
+ nextTick(() => {
633
+ if (afterFilterMethod) {
634
+ afterFilterMethod(bafParams)
635
+ }
636
+ })
637
+ }
638
+ }
639
+ internalData.lastFilterValue = ''
640
+ }
641
+ internalData.afterVisibleList = fullList
642
+ internalData.afterTreeList = treeList
643
+ updateAfterDataIndex()
644
+ }
645
+
646
+ /**
647
+ * 如果为虚拟树、则将树结构拍平
648
+ */
649
+ const handleTreeToList = () => {
650
+ const { afterTreeList, treeExpandedMaps } = internalData
651
+ const mapChildrenField = computeMapChildrenField.value
652
+ const treeOpts = computeTreeOpts.value
653
+ const { transform } = treeOpts
654
+ const expandMaps: {
655
+ [key: string]: number
656
+ } = {}
657
+ if (transform) {
658
+ const fullData: any[] = []
659
+ XEUtils.eachTree(
660
+ afterTreeList,
661
+ (item, index, items, path, parentRow) => {
662
+ const nodeid = getNodeId(item)
663
+ const parentNodeid = getNodeId(parentRow)
664
+ if (!parentRow || (expandMaps[parentNodeid] && treeExpandedMaps[parentNodeid])) {
665
+ expandMaps[nodeid] = 1
666
+ fullData.push(item)
667
+ }
668
+ },
669
+ { children: mapChildrenField }
670
+ )
671
+ internalData.afterVisibleList = fullData
672
+ return fullData
673
+ }
674
+ return internalData.afterVisibleList
675
+ }
676
+
677
+ const handleData = (force?: boolean) => {
678
+ let fullList: any[] = internalData.afterVisibleList
679
+ if (force) {
680
+ // 更新数据,处理筛选和排序
681
+ updateAfterFullData()
682
+ // 如果为虚拟树,将树结构拍平
683
+ fullList = handleTreeToList()
684
+ }
685
+ const treeList = fullList.slice(0)
686
+ reactData.treeList = treeList
687
+ }
688
+
689
+ /**
690
+ * 获取第一个拥有子节点的节点
691
+ */
692
+ function handleHasChildNodeIds(treeList: any[], type: 'first' | 'last') {
693
+ const childrenField = computeChildrenField.value
694
+ const mapChildrenField = computeMapChildrenField.value
695
+ const treeOpts = computeTreeOpts.value
696
+ const { transform } = treeOpts
697
+ const childField = transform ? mapChildrenField : childrenField
698
+ const nodeIds = []
699
+ let currList = treeList
700
+ while (currList.length) {
701
+ let targetNode = null
702
+ for (const item of currList) {
703
+ const kids = item[childField]
704
+ if (XEUtils.isArray(kids) && kids.length > 0) {
705
+ targetNode = item
706
+ break
707
+ }
708
+ }
709
+ if (targetNode) {
710
+ nodeIds.push(getNodeId(targetNode))
711
+ currList = targetNode[childField]
712
+ } else {
713
+ const endNode = XEUtils[type](currList)
714
+ nodeIds.push(getNodeId(endNode))
715
+ break
716
+ }
717
+ }
718
+ return nodeIds
719
+ }
720
+
721
+ const triggerSearchEvent = XEUtils.debounce(
722
+ () => {
723
+ handleData(true)
724
+ updateCheckboxStatus()
725
+ const { currentItems } = reactData
726
+ const { afterTreeList } = internalData
727
+ const filterOpts = computeFilterOpts.value
728
+ const { autoExpandMode } = filterOpts
729
+ // 如果当前不在列表情况下,触发默认行为
730
+ if (!isPathInTree(afterTreeList, currentItems)) {
731
+ // 默认展开
732
+ if (autoExpandMode === 'first' || autoExpandMode === 'last') {
733
+ const stItems = handleHasChildNodeIds(afterTreeList, autoExpandMode)
734
+ const expandedMaps: Record<string, boolean> = {}
735
+ stItems.forEach((nodeid) => {
736
+ expandedMaps[nodeid] = true
737
+ })
738
+ internalData.treeExpandedMaps = expandedMaps
739
+ reactData.currentItems = stItems
740
+ } else {
741
+ handleCurrentItems()
742
+ }
743
+ }
744
+ updateCurrentChunk()
745
+ },
746
+ 350,
747
+ { trailing: true }
748
+ )
749
+
750
+ const loadData = (list: any[]) => {
751
+ const treeOpts = computeTreeOpts.value
752
+ const keyField = computeKeyField.value
753
+ const parentField = computeParentField.value
754
+ const childrenField = computeChildrenField.value
755
+ const { rootParentValue, rootValues } = treeOpts
756
+ const { transform } = treeOpts
757
+ const fullData = transform
758
+ ? XEUtils.toArrayTree(list, {
759
+ key: keyField,
760
+ parentKey: parentField,
761
+ mapChildren: childrenField,
762
+ rootParentValue,
763
+ rootValues
764
+ })
765
+ : list
766
+ ? list.slice(0)
767
+ : []
768
+ internalData.treeFullData = fullData
769
+ cacheNodeMap()
770
+ handleData(true)
771
+ updateModelChecked()
772
+ handleCurrentItems()
773
+ updateCurrentChunk()
774
+ return nextTick()
775
+ }
776
+
777
+ const updateCurrentChunk = () => {
778
+ const { currentItems } = reactData
779
+ const { afterTreeList } = internalData
780
+ const childrenField = computeChildrenField.value
781
+ const mapChildrenField = computeMapChildrenField.value
782
+ const treeOpts = computeTreeOpts.value
783
+ const { transform } = treeOpts
784
+ const currentCunkList: any[][] = [afterTreeList]
785
+ if (currentItems.length) {
786
+ let chunkIndex = 0
787
+ let stNodeid = currentItems[chunkIndex]
788
+ let optList = afterTreeList
789
+ while (stNodeid && optList && optList.length) {
790
+ stNodeid = currentItems[chunkIndex++]
791
+ const currOption = optList.find((item) => stNodeid === getNodeId(item))
792
+ optList = currOption ? currOption[transform ? mapChildrenField : childrenField] : []
793
+ if (!optList || !optList.length) {
794
+ break
795
+ }
796
+ currentCunkList.push(optList)
797
+ }
798
+ }
799
+ reactData.currentCunkList = currentCunkList
800
+ }
801
+
802
+ const handleCurrentItems = () => {
803
+ const { currentNode } = reactData
804
+ const { afterTreeList } = internalData
805
+ const selectVals = computeSelectVals.value
806
+ const childrenField = computeChildrenField.value
807
+ const mapChildrenField = computeMapChildrenField.value
808
+ const treeOpts = computeTreeOpts.value
809
+ const { transform } = treeOpts
810
+ const stItems: string[] = []
811
+ const expandedMaps: Record<string, boolean> = {}
812
+ const lastVal = currentNode ? getNodeId(currentNode) : enNodeValue(XEUtils.last(selectVals))
813
+ if (lastVal) {
814
+ const stRest = XEUtils.findTree(afterTreeList, (item) => lastVal === getNodeId(item), { children: transform ? mapChildrenField : childrenField })
815
+ if (stRest) {
816
+ const { nodes } = stRest
817
+ nodes.forEach((item) => {
818
+ const nodeid = getNodeId(item)
819
+ expandedMaps[nodeid] = true
820
+ stItems.push(nodeid)
821
+ })
822
+ }
823
+ }
824
+ reactData.currentItems = stItems
825
+ internalData.treeExpandedMaps = expandedMaps
826
+ }
827
+
828
+ const updateZindex = () => {
829
+ const popupOpts = computePopupOpts.value
830
+ const { zIndex } = popupOpts
831
+ if (zIndex) {
832
+ reactData.panelIndex = zIndex
833
+ } else if (reactData.panelIndex < getLastZIndex()) {
834
+ reactData.panelIndex = nextZIndex()
835
+ }
836
+ }
837
+
838
+ const updatePlacement = () => {
839
+ const { panelIndex } = reactData
840
+ const targetElem = refElem.value
841
+ const panelElem = refOptionPanel.value
842
+ const btnTransfer = computeBtnTransfer.value
843
+ const popupOpts = computePopupOpts.value
844
+ const handleStyle = () => {
845
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
846
+ placement: popupOpts.placement,
847
+ defaultPlacement: popupOpts.defaultPlacement,
848
+ appendTo: popupOpts.appendTo,
849
+ teleportTo: btnTransfer,
850
+ isMinWidth: false
851
+ })
852
+ const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
853
+ zIndex: panelIndex
854
+ })
855
+ reactData.panelStyle = panelStyle
856
+ reactData.panelPlacement = ppObj.placement
857
+ }
858
+ handleStyle()
859
+ return nextTick().then(handleStyle)
860
+ }
861
+
862
+ const showOptionPanel = (evnt?: Event) => {
863
+ const { loading, remote, filterable } = props
864
+ const { treeFullData } = internalData
865
+ const isDisabled = computeIsDisabled.value
866
+ const remoteOpts = computeRemoteOpts.value
867
+ if (!loading && !isDisabled) {
868
+ clearTimeout(internalData.hpTimeout)
869
+ if (!reactData.initialized) {
870
+ reactData.initialized = true
871
+ }
872
+ reactData.isActivated = true
873
+ reactData.isAniVisible = true
874
+ if (filterable) {
875
+ if (remote && remoteOpts.enabled && remoteOpts.autoLoad && !treeFullData.length) {
876
+ handleSearchEvent()
877
+ }
878
+ }
879
+ setTimeout(() => {
880
+ reactData.visiblePanel = true
881
+ handleFocusSearch()
882
+ }, 10)
883
+ updateZindex()
884
+ updatePlacement()
885
+ dispatchEvent('visible-change', { visible: true }, evnt || null)
886
+ }
887
+ }
888
+
889
+ const hideOptionPanel = (evnt?: Event) => {
890
+ reactData.visiblePanel = false
891
+ internalData.hpTimeout = setTimeout(() => {
892
+ reactData.isAniVisible = false
893
+ }, 350)
894
+ dispatchEvent('visible-change', { visible: false }, evnt || null)
895
+ }
896
+
897
+ const setCurrentNode = (node: any) => {
898
+ reactData.currentNode = node
899
+ updateCurrentChunk()
900
+ return nextTick()
901
+ }
902
+
903
+ const setAllCheckboxNode = (checked: boolean) => {
904
+ const selectMaps: Record<string, boolean> = {}
905
+ const childrenField = computeChildrenField.value
906
+ const mapChildrenField = computeMapChildrenField.value
907
+ const treeOpts = computeTreeOpts.value
908
+ const { transform } = treeOpts
909
+ const checkKeys: string[] = []
910
+ const checkNodes: any[] = []
911
+ if (checked) {
912
+ XEUtils.eachTree(
913
+ internalData.afterTreeList,
914
+ (node) => {
915
+ const nodeid = getNodeId(node)
916
+ checkKeys.push(nodeid)
917
+ checkNodes.push(node)
918
+ selectMaps[nodeid] = true
919
+ },
920
+ { children: transform ? mapChildrenField : childrenField }
921
+ )
922
+ }
923
+ internalData.indeterminateRowMaps = {}
924
+ internalData.selectCheckboxMaps = selectMaps
925
+ reactData.updateCheckboxFlag++
926
+ updateCheckboxStatus()
927
+ return nextTick().then(() => {
928
+ return { checkNodeKeys: checkKeys, checkNodes }
929
+ })
930
+ }
931
+
932
+ const clearSelectedNode = () => {
933
+ internalData.indeterminateRowMaps = {}
934
+ internalData.selectCheckboxMaps = {}
935
+ reactData.updateCheckboxFlag++
936
+ reactData.selectRadioKey = null
937
+ updateCheckboxStatus()
938
+ return nextTick().then(() => {
939
+ return { checkNodeKeys: [], checkNodes: [] }
940
+ })
941
+ }
942
+
943
+ const changeEvent = (evnt: Event, selectValue: any, node: any) => {
944
+ const value = XEUtils.isArray(selectValue) ? selectValue.map(deNodeValue) : deNodeValue(selectValue)
945
+ internalData.isUpdateMode = true
946
+ emitModel(value)
947
+ if (value !== props.modelValue) {
948
+ dispatchEvent('change', { value, node, option: node }, evnt)
949
+ // 自动更新校验状态
950
+ if ($xeForm && formItemInfo) {
951
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
952
+ }
953
+ }
954
+ }
955
+
956
+ const clearValueEvent = (evnt: Event, selectValue: any) => {
957
+ changeEvent(evnt, selectValue, null)
958
+ dispatchEvent('clear', { value: selectValue }, evnt)
959
+ }
960
+
961
+ const clearEvent = (params: any, evnt: Event) => {
962
+ clearValueEvent(evnt, null)
963
+ hideOptionPanel(evnt)
964
+ }
965
+
966
+ const allCheckedPanelEvent: VxeButtonEvents.Click = (params) => {
967
+ const { $event } = params
968
+ const { multiple, checkedClosable } = props
969
+ if (multiple) {
970
+ setAllCheckboxNode(true).then(({ checkNodeKeys, checkNodes }) => {
971
+ changeEvent($event, checkNodeKeys, checkNodes[0])
972
+ dispatchEvent('all-change', { value: checkNodeKeys }, $event)
973
+ if (checkedClosable) {
974
+ hideOptionPanel($event)
975
+ }
976
+ })
977
+ }
978
+ }
979
+
980
+ const clearCheckedPanelEvent: VxeButtonEvents.Click = (params) => {
981
+ const { $event } = params
982
+ const { multiple, checkedClosable } = props
983
+ const value = multiple ? [] : null
984
+ clearSelectedNode().then(() => {
985
+ if (checkedClosable) {
986
+ hideOptionPanel($event)
987
+ }
988
+ })
989
+ changeEvent($event, value, null)
990
+ dispatchEvent('clear', { value }, $event)
991
+ }
992
+
993
+ const closePanelEvent: VxeButtonEvents.Click = (params) => {
994
+ const { $event } = params
995
+ hideOptionPanel($event)
996
+ }
997
+
998
+ const handleGlobalMousedownEvent = (evnt: MouseEvent) => {
999
+ const { visiblePanel } = reactData
1000
+ const isDisabled = computeIsDisabled.value
1001
+ if (!isDisabled) {
1002
+ const el = refElem.value
1003
+ const panelElem = refOptionPanel.value
1004
+ reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag
1005
+ if (visiblePanel && !reactData.isActivated) {
1006
+ hideOptionPanel(evnt)
1007
+ }
1008
+ }
1009
+ }
1010
+
1011
+ const handleGlobalBlurEvent = (evnt: Event) => {
1012
+ const { visiblePanel, isActivated } = reactData
1013
+ if (visiblePanel) {
1014
+ hideOptionPanel(evnt)
1015
+ }
1016
+ if (isActivated) {
1017
+ reactData.isActivated = false
1018
+ }
1019
+ if (visiblePanel || isActivated) {
1020
+ const $input = refInput.value
1021
+ if ($input) {
1022
+ $input.blur()
1023
+ }
1024
+ }
1025
+ }
1026
+
1027
+ const handleGlobalResizeEvent = () => {
1028
+ const { visiblePanel } = reactData
1029
+ if (visiblePanel) {
1030
+ updatePlacement()
1031
+ }
1032
+ }
1033
+
1034
+ const handleGlobalScrollEvent = () => {
1035
+ const { visiblePanel } = reactData
1036
+ if (visiblePanel) {
1037
+ updatePlacement()
1038
+ }
1039
+ }
1040
+
1041
+ const handleFocusSearch = () => {
1042
+ if (props.filterable) {
1043
+ nextTick(() => {
1044
+ const inpSearch = refInpSearch.value
1045
+ if (inpSearch) {
1046
+ inpSearch.focus()
1047
+ }
1048
+ })
1049
+ }
1050
+ }
1051
+
1052
+ const changeCurrentEvent = (evnt: MouseEvent, node: any) => {
1053
+ evnt.preventDefault()
1054
+ const isChecked = true
1055
+ reactData.currentNode = node
1056
+ dispatchEvent('current-change', { node, checked: isChecked }, evnt)
1057
+ }
1058
+
1059
+ const changeRadioEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1060
+ evnt.preventDefault()
1061
+ evnt.stopPropagation()
1062
+ const { currentItems } = reactData
1063
+ const { nodeMaps } = internalData
1064
+ const radioOpts = computeRadioOpts.value
1065
+ const childrenField = computeChildrenField.value
1066
+ const treeOpts = computeTreeOpts.value
1067
+ const { transform } = treeOpts
1068
+ const mapChildrenField = computeMapChildrenField.value
1069
+ const { checkMode, checkMethod } = radioOpts
1070
+ const nodeid = getNodeId(node)
1071
+ const childList: any[] = node[transform ? mapChildrenField : childrenField]
1072
+ const isExistChild = childList && childList.length > 0
1073
+ const nodeItem = nodeMaps[nodeid] || {}
1074
+ const nLevel = nodeItem.level
1075
+ const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1076
+ if (isDisabled) {
1077
+ return
1078
+ }
1079
+ const value = nodeid
1080
+ reactData.selectRadioKey = value
1081
+ changeEvent(evnt, value, node)
1082
+ if (!currentItems.includes(nodeid)) {
1083
+ changeCurrentEvent(evnt, node)
1084
+ toggleExpandEvent(evnt, node, chunks, chunkIndex)
1085
+ }
1086
+ hideOptionPanel(evnt)
1087
+ }
1088
+
1089
+ const handleAsyncTreeExpandChilds = (node: any) => {
1090
+ const checkboxOpts = computeCheckboxOpts.value
1091
+ const treeOpts = computeTreeOpts.value
1092
+ const { loadMethod } = treeOpts
1093
+ const { checkStrictly } = checkboxOpts
1094
+ return new Promise<void>((resolve) => {
1095
+ if (loadMethod) {
1096
+ const { nodeMaps } = internalData
1097
+ const nodeid = getNodeId(node)
1098
+ const nodeItem = nodeMaps[nodeid]
1099
+ internalData.treeExpandLazyLoadedMaps[nodeid] = true
1100
+ Promise.resolve(loadMethod({ $cascader: $xeCascader, node }))
1101
+ .then((childRecords: any) => {
1102
+ const { treeExpandLazyLoadedMaps } = internalData
1103
+ nodeItem.treeLoaded = true
1104
+ if (treeExpandLazyLoadedMaps[nodeid]) {
1105
+ treeExpandLazyLoadedMaps[nodeid] = false
1106
+ }
1107
+ if (!XEUtils.isArray(childRecords)) {
1108
+ childRecords = []
1109
+ }
1110
+ if (childRecords) {
1111
+ return $xeCascader.loadChildrenNode(node, childRecords).then((childRows) => {
1112
+ const { treeExpandedMaps } = internalData
1113
+ if (childRows.length && !treeExpandedMaps[nodeid]) {
1114
+ treeExpandedMaps[nodeid] = true
1115
+ }
1116
+ reactData.updateExpandedFlag++
1117
+ // 如果当前节点已选中,则展开后子节点也被选中
1118
+ if (!checkStrictly && $xeCascader.isCheckedByCheckboxNodeId(nodeid)) {
1119
+ handleCheckedCheckboxNode(childRows, true)
1120
+ }
1121
+ dispatchEvent('load-success', { node, data: childRecords }, new Event('load-success'))
1122
+ return nextTick()
1123
+ })
1124
+ } else {
1125
+ dispatchEvent('load-success', { node, data: childRecords }, new Event('load-success'))
1126
+ }
1127
+ })
1128
+ .catch((e) => {
1129
+ const { treeExpandLazyLoadedMaps } = internalData
1130
+ nodeItem.treeLoaded = false
1131
+ if (treeExpandLazyLoadedMaps[nodeid]) {
1132
+ treeExpandLazyLoadedMaps[nodeid] = false
1133
+ }
1134
+ dispatchEvent('load-error', { node, data: e }, new Event('load-error'))
1135
+ })
1136
+ .finally(() => {
1137
+ handleTreeToList()
1138
+ handleData()
1139
+ })
1140
+ } else {
1141
+ resolve()
1142
+ }
1143
+ })
1144
+ }
1145
+
1146
+ /**
1147
+ * 展开与收起树节点
1148
+ * @param nodeList
1149
+ * @param expanded
1150
+ * @returns
1151
+ */
1152
+ const handleBaseTreeExpand = (nodeList: any[], expanded: boolean) => {
1153
+ const { treeExpandLazyLoadedMaps, treeExpandedMaps } = internalData
1154
+ const { nodeMaps } = internalData
1155
+ const childrenField = computeChildrenField.value
1156
+ const hasChildField = computeHasChildField.value
1157
+ const treeOpts = computeTreeOpts.value
1158
+ const { lazy, toggleMethod } = treeOpts
1159
+ const result: any[] = []
1160
+ let validNodes = toggleMethod ? nodeList.filter((node: any) => toggleMethod({ $cascader: $xeCascader, expanded, node })) : nodeList
1161
+
1162
+ validNodes = validNodes.length ? [validNodes[validNodes.length - 1]] : []
1163
+ // 同一级只能展开一个
1164
+ const nodeid = getNodeId(validNodes[0])
1165
+ const nodeItem = nodeMaps[nodeid]
1166
+ if (nodeItem) {
1167
+ nodeItem.items.forEach((item) => {
1168
+ const itemNodeId = getNodeId(item)
1169
+ if (treeExpandedMaps[itemNodeId]) {
1170
+ delete treeExpandedMaps[itemNodeId]
1171
+ }
1172
+ })
1173
+ }
1174
+
1175
+ const expandNodes: any[] = []
1176
+ if (expanded) {
1177
+ validNodes.forEach((item) => {
1178
+ const itemNodeId = getNodeId(item)
1179
+ if (!treeExpandedMaps[itemNodeId]) {
1180
+ const nodeItem = nodeMaps[itemNodeId]
1181
+ const isLoad = lazy && item[hasChildField] && !nodeItem.treeLoaded && !treeExpandLazyLoadedMaps[itemNodeId]
1182
+ // 是否使用懒加载
1183
+ if (isLoad) {
1184
+ result.push(handleAsyncTreeExpandChilds(item))
1185
+ } else {
1186
+ if (item[childrenField] && item[childrenField].length) {
1187
+ treeExpandedMaps[itemNodeId] = true
1188
+ expandNodes.push(item)
1189
+ }
1190
+ }
1191
+ }
1192
+ })
1193
+ } else {
1194
+ validNodes.forEach((item) => {
1195
+ const itemNodeId = getNodeId(item)
1196
+ if (treeExpandedMaps[itemNodeId]) {
1197
+ delete treeExpandedMaps[itemNodeId]
1198
+ expandNodes.push(item)
1199
+ }
1200
+ })
1201
+ }
1202
+ reactData.updateExpandedFlag++
1203
+ handleTreeToList()
1204
+ handleData()
1205
+ return Promise.all(result)
1206
+ }
1207
+
1208
+ const toggleExpandEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1209
+ const { currentItems } = reactData
1210
+ const { treeExpandLazyLoadedMaps } = internalData
1211
+ const treeOpts = computeTreeOpts.value
1212
+ const { lazy } = treeOpts
1213
+ const stItems = currentItems.slice(0, chunkIndex)
1214
+ const nodeid = getNodeId(node)
1215
+ const expanded = true
1216
+ evnt.stopPropagation()
1217
+ stItems.push(nodeid)
1218
+ reactData.currentItems = stItems
1219
+ if (!lazy || !treeExpandLazyLoadedMaps[nodeid]) {
1220
+ handleBaseTreeExpand([node], expanded)
1221
+ }
1222
+ setCurrentNode(node)
1223
+ dispatchEvent('node-expand', { node, expanded }, evnt)
1224
+ }
1225
+
1226
+ const updateCheckboxStatus = () => {
1227
+ const { selectCheckboxMaps, indeterminateRowMaps, afterTreeList } = internalData
1228
+ const childrenField = computeChildrenField.value
1229
+ const mapChildrenField = computeMapChildrenField.value
1230
+ const checkboxOpts = computeCheckboxOpts.value
1231
+ const { checkStrictly, checkMethod } = checkboxOpts
1232
+ const treeOpts = computeTreeOpts.value
1233
+ const { transform } = treeOpts
1234
+ if (!checkStrictly) {
1235
+ const childRowMaps: Record<string, number> = {}
1236
+ const childRowList: any[][] = []
1237
+ XEUtils.eachTree(
1238
+ afterTreeList,
1239
+ (node) => {
1240
+ const nodeid = getNodeId(node)
1241
+ const childList = node[transform ? mapChildrenField : childrenField]
1242
+ if (childList && childList.length && !childRowMaps[nodeid]) {
1243
+ childRowMaps[nodeid] = 1
1244
+ childRowList.unshift([node, nodeid, childList])
1245
+ }
1246
+ },
1247
+ { children: transform ? mapChildrenField : childrenField }
1248
+ )
1249
+
1250
+ childRowList.forEach((vals) => {
1251
+ const node: string = vals[0]
1252
+ const nodeid: string = vals[1]
1253
+ const childList: any[] = vals[2]
1254
+ let sLen = 0 // 已选
1255
+ let hLen = 0 // 半选
1256
+ let vLen = 0 // 有效子行
1257
+ const cLen = childList.length // 子行
1258
+ childList.forEach(
1259
+ checkMethod
1260
+ ? (item) => {
1261
+ const childNodeid = getNodeId(item)
1262
+ const isSelect = selectCheckboxMaps[childNodeid]
1263
+ if (checkMethod({ $cascader: $xeCascader, node: item })) {
1264
+ if (isSelect) {
1265
+ sLen++
1266
+ } else if (indeterminateRowMaps[childNodeid]) {
1267
+ hLen++
1268
+ }
1269
+ vLen++
1270
+ } else {
1271
+ if (isSelect) {
1272
+ sLen++
1273
+ } else if (indeterminateRowMaps[childNodeid]) {
1274
+ hLen++
1275
+ }
1276
+ }
1277
+ }
1278
+ : (item) => {
1279
+ const childNodeid = getNodeId(item)
1280
+ const isSelect = selectCheckboxMaps[childNodeid]
1281
+ if (isSelect) {
1282
+ sLen++
1283
+ } else if (indeterminateRowMaps[childNodeid]) {
1284
+ hLen++
1285
+ }
1286
+ vLen++
1287
+ }
1288
+ )
1289
+
1290
+ let isSelected = false
1291
+ if (cLen > 0) {
1292
+ if (vLen > 0) {
1293
+ isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen
1294
+ } else {
1295
+ // 如果存在子项禁用
1296
+ if (sLen > 0 && sLen >= vLen) {
1297
+ isSelected = true
1298
+ } else if (selectCheckboxMaps[nodeid]) {
1299
+ isSelected = true
1300
+ } else {
1301
+ isSelected = false
1302
+ }
1303
+ }
1304
+ } else {
1305
+ // 如果无子项
1306
+ isSelected = selectCheckboxMaps[nodeid]
1307
+ }
1308
+ const halfSelect = !isSelected && (sLen > 0 || hLen > 0)
1309
+
1310
+ if (isSelected) {
1311
+ selectCheckboxMaps[nodeid] = node
1312
+ if (indeterminateRowMaps[nodeid]) {
1313
+ delete indeterminateRowMaps[nodeid]
1314
+ }
1315
+ } else {
1316
+ if (selectCheckboxMaps[nodeid]) {
1317
+ delete selectCheckboxMaps[nodeid]
1318
+ }
1319
+ if (halfSelect) {
1320
+ indeterminateRowMaps[nodeid] = node
1321
+ } else {
1322
+ if (indeterminateRowMaps[nodeid]) {
1323
+ delete indeterminateRowMaps[nodeid]
1324
+ }
1325
+ }
1326
+ }
1327
+ })
1328
+ reactData.updateCheckboxFlag++
1329
+ }
1330
+ }
1331
+
1332
+ const changeCheckboxEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1333
+ evnt.preventDefault()
1334
+ evnt.stopPropagation()
1335
+ // const { filterable } = props
1336
+ const { currentItems } = reactData
1337
+ const { selectCheckboxMaps, nodeMaps } = internalData
1338
+ const childrenField = computeChildrenField.value
1339
+ const mapChildrenField = computeMapChildrenField.value
1340
+ const checkboxOpts = computeCheckboxOpts.value
1341
+ const { checkStrictly, checkMode, checkMethod } = checkboxOpts
1342
+ const treeOpts = computeTreeOpts.value
1343
+ const { transform } = treeOpts
1344
+ const nodeid = getNodeId(node)
1345
+ const childList: any[] = node[transform ? mapChildrenField : childrenField]
1346
+ const isExistChild = childList && childList.length > 0
1347
+ const nodeItem = nodeMaps[nodeid] || {}
1348
+ const nLevel = nodeItem.level
1349
+ const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1350
+ if (isDisabled) {
1351
+ return
1352
+ }
1353
+ let isChecked = false
1354
+ if (selectCheckboxMaps[nodeid]) {
1355
+ delete selectCheckboxMaps[nodeid]
1356
+ } else {
1357
+ isChecked = true
1358
+ selectCheckboxMaps[nodeid] = node
1359
+ }
1360
+ if (!checkStrictly) {
1361
+ XEUtils.eachTree(
1362
+ childList,
1363
+ (childNode) => {
1364
+ const childNodeid = getNodeId(childNode)
1365
+ if (isChecked) {
1366
+ if (!selectCheckboxMaps[childNodeid]) {
1367
+ selectCheckboxMaps[childNodeid] = childNode
1368
+ }
1369
+ } else {
1370
+ if (selectCheckboxMaps[childNodeid]) {
1371
+ delete selectCheckboxMaps[childNodeid]
1372
+ }
1373
+ }
1374
+ },
1375
+ { children: transform ? mapChildrenField : childrenField }
1376
+ )
1377
+ }
1378
+ selectCheckboxMaps[nodeid] = node
1379
+ reactData.updateCheckboxFlag++
1380
+ updateCheckboxStatus()
1381
+ const nodeids = XEUtils.keys(selectCheckboxMaps)
1382
+ const value = nodeids
1383
+ changeEvent(evnt, value, node)
1384
+ if (!currentItems.includes(nodeid)) {
1385
+ changeCurrentEvent(evnt, node)
1386
+ toggleExpandEvent(evnt, node, chunks, chunkIndex)
1387
+ }
1388
+ }
1389
+
1390
+ const handleNodeClickEvent = (evnt: MouseEvent, node: any, chunks: any[], chunkIndex: number) => {
1391
+ const { multiple, showCheckbox, showRadio } = props
1392
+ const treeOpts = computeTreeOpts.value
1393
+ const radioOpts = computeRadioOpts.value
1394
+ const checkboxOpts = computeCheckboxOpts.value
1395
+ const childrenField = computeChildrenField.value
1396
+ const mapChildrenField = computeMapChildrenField.value
1397
+ const { transform, trigger } = treeOpts
1398
+ const childList: any[] = node[transform ? mapChildrenField : childrenField]
1399
+ let triggerCurrent = false
1400
+ let triggerRadio = false
1401
+ let triggerCheckbox = false
1402
+ let triggerExpand = false
1403
+ triggerCurrent = true
1404
+ changeCurrentEvent(evnt, node)
1405
+ if (trigger !== 'icon') {
1406
+ triggerExpand = true
1407
+ toggleExpandEvent(evnt, node, chunks, chunkIndex)
1408
+ }
1409
+ if (multiple) {
1410
+ if (checkboxOpts.trigger === 'node' || (!showCheckbox && (!childList || !childList.length))) {
1411
+ triggerCheckbox = true
1412
+ changeCheckboxEvent(evnt, node, chunks, chunkIndex)
1413
+ }
1414
+ } else {
1415
+ if (radioOpts.trigger === 'node' || (!showRadio && (!childList || !childList.length))) {
1416
+ triggerRadio = true
1417
+ changeRadioEvent(evnt, node, chunks, chunkIndex)
1418
+ }
1419
+ }
1420
+ dispatchEvent('node-click', { node, triggerCurrent, triggerRadio, triggerCheckbox, triggerExpand }, evnt)
1421
+ }
1422
+
1423
+ const focusEvent = (evnt: FocusEvent) => {
1424
+ const isDisabled = computeIsDisabled.value
1425
+ if (!isDisabled) {
1426
+ if (!reactData.visiblePanel) {
1427
+ reactData.triggerFocusPanel = true
1428
+ showOptionPanel(evnt)
1429
+ setTimeout(() => {
1430
+ reactData.triggerFocusPanel = false
1431
+ }, 150)
1432
+ }
1433
+ }
1434
+ dispatchEvent('focus', {}, evnt)
1435
+ }
1436
+
1437
+ const clickEvent = (evnt: MouseEvent) => {
1438
+ evnt.preventDefault()
1439
+ if (reactData.triggerFocusPanel) {
1440
+ reactData.triggerFocusPanel = false
1441
+ } else {
1442
+ if (!reactData.visiblePanel) {
1443
+ showOptionPanel(evnt)
1444
+ }
1445
+ }
1446
+ dispatchEvent('click', {}, evnt)
1447
+ }
1448
+
1449
+ const blurEvent = (evnt: FocusEvent) => {
1450
+ reactData.isActivated = false
1451
+ dispatchEvent('blur', {}, evnt)
1452
+ }
1453
+
1454
+ const modelSearchEvent = (value: string) => {
1455
+ reactData.searchValue = value
1456
+ triggerSearchEvent(new Event('filter'))
1457
+ }
1458
+
1459
+ const handleSearchEvent = () => {
1460
+ const { modelValue, remote } = props
1461
+ const { searchValue } = reactData
1462
+ const remoteOpts = computeRemoteOpts.value
1463
+ const queryMethod = remoteOpts.queryMethod
1464
+ if (remote && queryMethod && remoteOpts.enabled) {
1465
+ reactData.searchLoading = true
1466
+ Promise.resolve(queryMethod({ $cascader: $xeCascader, searchValue, value: modelValue }))
1467
+ .then(() => nextTick())
1468
+ .catch(() => nextTick())
1469
+ .finally(() => {
1470
+ reactData.searchLoading = false
1471
+ })
1472
+ }
1473
+ }
1474
+
1475
+ const togglePanelEvent = (params: any) => {
1476
+ const { $event } = params
1477
+ $event.preventDefault()
1478
+ if (reactData.triggerFocusPanel) {
1479
+ reactData.triggerFocusPanel = false
1480
+ } else {
1481
+ if (reactData.visiblePanel) {
1482
+ hideOptionPanel($event)
1483
+ } else {
1484
+ showOptionPanel($event)
1485
+ }
1486
+ }
1487
+ }
1488
+
1489
+ const cascaderPrivateMethods: CascaderPrivateMethods = {
1490
+ isCheckedByCheckboxNodeId,
1491
+ /**
1492
+ * 用于树结构,给行数据加载子节点
1493
+ */
1494
+ loadChildrenNode(node, childRecords) {
1495
+ const { separator } = props
1496
+ const { nodeMaps } = internalData
1497
+ const treeOpts = computeTreeOpts.value
1498
+ const labelField = computeLabelField.value
1499
+ const { lazy, transform } = treeOpts
1500
+ if (!lazy) {
1501
+ return Promise.resolve([])
1502
+ }
1503
+ const childrenField = computeChildrenField.value
1504
+ const mapChildrenField = computeMapChildrenField.value
1505
+ const parentNodeItem = nodeMaps[getNodeId(node)]
1506
+ const parentLevel = parentNodeItem ? parentNodeItem.level : 0
1507
+ const parentNodes = parentNodeItem ? parentNodeItem.nodes : []
1508
+ return createNode(childRecords).then((nodeList) => {
1509
+ XEUtils.eachTree(
1510
+ nodeList,
1511
+ (childRow, index, items, path, parent, nodes) => {
1512
+ const itemNodeId = getNodeId(childRow)
1513
+ nodeMaps[itemNodeId] = {
1514
+ item: childRow,
1515
+ index: -1,
1516
+ $index: -1,
1517
+ _index: -1,
1518
+ items,
1519
+ parent: parent || parentNodeItem.item,
1520
+ nodes: parentNodes.concat(nodes),
1521
+ level: parentLevel + nodes.length,
1522
+ treeIndex: -1,
1523
+ lineCount: 0,
1524
+ treeLoaded: false,
1525
+ fullLabel: nodes.map((item) => item[labelField]).join(separator || ' / ')
1526
+ }
1527
+ },
1528
+ { children: childrenField }
1529
+ )
1530
+ node[childrenField] = nodeList
1531
+ if (transform) {
1532
+ node[mapChildrenField] = nodeList
1533
+ }
1534
+ updateAfterDataIndex()
1535
+ return nodeList
1536
+ })
1537
+ }
1538
+ }
1539
+
1540
+ Object.assign($xeCascader, cascaderMethods, cascaderPrivateMethods)
1541
+
1542
+ const handleVisibleOrCheckMode = (mode: '' | 'all' | 'first' | 'last' | null | undefined, isExistChild: boolean, nLevel: number) => {
1543
+ if (mode) {
1544
+ if (mode === 'first') {
1545
+ return !nLevel
1546
+ }
1547
+ if (mode === 'last') {
1548
+ return !isExistChild
1549
+ }
1550
+ }
1551
+ return true
1552
+ }
1553
+
1554
+ const renderRadio = (node: any, isExistChild: boolean, nLevel: number, isChecked: boolean, chunks: any[], chunkIndex: number) => {
1555
+ const { showRadio } = props
1556
+ const radioOpts = computeRadioOpts.value
1557
+ const { checkMode, checkMethod, visibleMode, visibleMethod } = radioOpts
1558
+ const isVisible = visibleMethod ? visibleMethod({ $cascader: $xeCascader, node }) : handleVisibleOrCheckMode(visibleMode, isExistChild, nLevel)
1559
+ if (showRadio && isVisible) {
1560
+ const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1561
+ return h(
1562
+ 'div',
1563
+ {
1564
+ class: [
1565
+ 'vxe-tree--radio-option',
1566
+ {
1567
+ 'is--checked': isChecked,
1568
+ 'is--disabled': isDisabled
1569
+ }
1570
+ ],
1571
+ onClick: (evnt) => {
1572
+ if (!isDisabled) {
1573
+ changeRadioEvent(evnt, node, chunks, chunkIndex)
1574
+ }
1575
+ }
1576
+ },
1577
+ [
1578
+ h('span', {
1579
+ class: ['vxe-radio--icon', isChecked ? getIcon().RADIO_CHECKED : isDisabled ? getIcon().RADIO_DISABLED_UNCHECKED : getIcon().RADIO_UNCHECKED]
1580
+ })
1581
+ ]
1582
+ )
1583
+ }
1584
+ return renderEmptyElement($xeCascader)
1585
+ }
1586
+
1587
+ const renderCheckbox = (node: any, isExistChild: boolean, nLevel: number, isChecked: boolean, isIndeterminate: boolean, chunks: any[], chunkIndex: number) => {
1588
+ const { showCheckbox } = props
1589
+ const checkboxOpts = computeCheckboxOpts.value
1590
+ const { checkMode, checkMethod, visibleMode, visibleMethod } = checkboxOpts
1591
+ const isVisible = visibleMethod ? visibleMethod({ $cascader: $xeCascader, node }) : handleVisibleOrCheckMode(visibleMode, isExistChild, nLevel)
1592
+ if (showCheckbox && isVisible) {
1593
+ const isDisabled = checkMethod ? !checkMethod({ $cascader: $xeCascader, node }) : !handleVisibleOrCheckMode(checkMode, isExistChild, nLevel)
1594
+ return h(
1595
+ 'div',
1596
+ {
1597
+ class: [
1598
+ 'vxe-cascader--checkbox-option',
1599
+ {
1600
+ 'is--checked': isChecked,
1601
+ 'is--indeterminate': isIndeterminate,
1602
+ 'is--disabled': isDisabled
1603
+ }
1604
+ ],
1605
+ onClick: (evnt) => {
1606
+ if (!isDisabled) {
1607
+ changeCheckboxEvent(evnt, node, chunks, chunkIndex)
1608
+ }
1609
+ }
1610
+ },
1611
+ [
1612
+ h('span', {
1613
+ class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().CHECKBOX_INDETERMINATE : isChecked ? getIcon().CHECKBOX_CHECKED : isDisabled ? getIcon().CHECKBOX_DISABLED_UNCHECKED : getIcon().CHECKBOX_UNCHECKED]
1614
+ })
1615
+ ]
1616
+ )
1617
+ }
1618
+ return renderEmptyElement($xeCascader)
1619
+ }
1620
+
1621
+ const renderNode = (node: any, nodeid: string, nodeIndex: number, chunks: any[], chunkIndex: number) => {
1622
+ const { multiple } = props
1623
+ const { currentNode, selectRadioKey, updateCheckboxFlag, updateExpandedFlag } = reactData
1624
+ const { nodeMaps, selectCheckboxMaps, indeterminateRowMaps, treeExpandedMaps, treeExpandLazyLoadedMaps } = internalData
1625
+ const treeOpts = computeTreeOpts.value
1626
+ const { lazy, transform, iconLoaded, iconOpen, iconClose } = treeOpts
1627
+ const childrenField = computeChildrenField.value
1628
+ const mapChildrenField = computeMapChildrenField.value
1629
+ const labelField = computeLabelField.value
1630
+ const hasChildField = computeHasChildField.value
1631
+ const childList: any[] = node[transform ? mapChildrenField : childrenField]
1632
+ const isExistChild = childList && childList.length > 0
1633
+ const iconSlot = slots.icon
1634
+ const titleSlot = slots.title
1635
+ const isExpand = updateExpandedFlag && treeExpandedMaps[nodeid]
1636
+ const nodeItem = nodeMaps[nodeid] || {}
1637
+ const nodeTitle = node[labelField]
1638
+ const nLevel = nodeItem.level
1639
+
1640
+ let isRadioChecked = false
1641
+ if (!multiple) {
1642
+ isRadioChecked = nodeid === selectRadioKey
1643
+ }
1644
+
1645
+ let isCheckboxChecked = false
1646
+ let isIndeterminate = false
1647
+ if (multiple) {
1648
+ isCheckboxChecked = !!(updateCheckboxFlag && selectCheckboxMaps[nodeid])
1649
+ isIndeterminate = !!(updateCheckboxFlag && indeterminateRowMaps[nodeid])
1650
+ }
1651
+
1652
+ let hasLazyChilds = false
1653
+ let isLazyLoading = false
1654
+ let isLazyLoaded = false
1655
+ if (lazy) {
1656
+ isLazyLoading = !!treeExpandLazyLoadedMaps[nodeid]
1657
+ hasLazyChilds = node[hasChildField]
1658
+ isLazyLoaded = !!nodeItem.treeLoaded
1659
+ }
1660
+ const nParams = { node }
1661
+ return h(
1662
+ 'div',
1663
+ {
1664
+ key: `${chunkIndex}_${nodeIndex}`,
1665
+ class: [
1666
+ 'vxe-cascader-chunk--node-item',
1667
+ {
1668
+ 'is--current': currentNode && (currentNode === node || getNodeId(currentNode) === nodeid),
1669
+ 'is-radio--checked': isRadioChecked,
1670
+ 'is-checkbox--checked': isCheckboxChecked,
1671
+ 'is-checkbox--indeterminate': isIndeterminate,
1672
+ 'is--expand': isExpand
1673
+ }
1674
+ ],
1675
+ title: nodeTitle,
1676
+ onMousedown: (evnt) => {
1677
+ const isLeftBtn = evnt.button === 0
1678
+ if (isLeftBtn) {
1679
+ evnt.stopPropagation()
1680
+ }
1681
+ },
1682
+ onClick(evnt) {
1683
+ handleNodeClickEvent(evnt, node, chunks, chunkIndex)
1684
+ }
1685
+ },
1686
+ [
1687
+ multiple ? renderCheckbox(node, isExistChild, nLevel, isCheckboxChecked, isIndeterminate, chunks, chunkIndex) : renderRadio(node, isExistChild, nLevel, isRadioChecked, chunks, chunkIndex),
1688
+ h(
1689
+ 'div',
1690
+ {
1691
+ class: 'vxe-cascader-chunk--node-item-inner'
1692
+ },
1693
+ [
1694
+ h(
1695
+ 'div',
1696
+ {
1697
+ class: 'vxe-cascader-chunk--node-item-title'
1698
+ },
1699
+ titleSlot ? getSlotVNs(titleSlot(nParams)) : nodeTitle
1700
+ )
1701
+ ]
1702
+ ),
1703
+ treeOpts.showIcon && (lazy ? (isLazyLoaded ? isExistChild : hasLazyChilds) : isExistChild)
1704
+ ? h(
1705
+ 'div',
1706
+ {
1707
+ class: 'vxe-cascader-chunk--node-item-switcher'
1708
+ },
1709
+ [
1710
+ [
1711
+ h(
1712
+ 'div',
1713
+ {
1714
+ class: 'vxe-cascader--node-item-icon',
1715
+ onClick(evnt) {
1716
+ if (treeOpts.trigger === 'icon') {
1717
+ toggleExpandEvent(evnt, node, chunks, chunkIndex)
1718
+ }
1719
+ }
1720
+ },
1721
+ iconSlot
1722
+ ? getSlotVNs(iconSlot(nParams))
1723
+ : [
1724
+ h('i', {
1725
+ class: isLazyLoading ? iconLoaded || getIcon().CASCADER_NODE_LOADED : isExpand ? iconOpen || getIcon().CASCADER_NODE_OPEN : iconClose || getIcon().CASCADER_NODE_CLOSE
1726
+ })
1727
+ ]
1728
+ )
1729
+ ]
1730
+ ]
1731
+ )
1732
+ : renderEmptyElement($xeCascader)
1733
+ ]
1734
+ )
1735
+ }
1736
+
1737
+ const renderVN = () => {
1738
+ const { className, modelValue, multiple, loading, filterable, showTotalButton, showCheckedButton, showClearButton, showCloseButton } = props
1739
+ const { initialized, isActivated, isAniVisible, visiblePanel, searchValue, currentCunkList } = reactData
1740
+ const { listVirtualYOpts } = internalData
1741
+ const vSize = computeSize.value
1742
+ const isDisabled = computeIsDisabled.value
1743
+ const selectLabel = computeSelectLabel.value
1744
+ const btnTransfer = computeBtnTransfer.value
1745
+ const formReadonly = computeFormReadonly.value
1746
+ const popupWrapperStyle = computePopupWrapperStyle.value
1747
+ const headerSlot = slots.header
1748
+ const footerSlot = slots.footer
1749
+ const prefixSlot = slots.prefix
1750
+ const popupOpts = computePopupOpts.value
1751
+ const popupClassName = popupOpts.className
1752
+
1753
+ if (formReadonly) {
1754
+ return h(
1755
+ 'div',
1756
+ {
1757
+ ref: refElem,
1758
+ class: ['vxe-cascader--readonly', className]
1759
+ },
1760
+ [
1761
+ h(
1762
+ 'span',
1763
+ {
1764
+ class: 'vxe-cascader-label'
1765
+ },
1766
+ selectLabel
1767
+ )
1768
+ ]
1769
+ )
1770
+ }
1771
+ const selectVals = XEUtils.eqNull(modelValue) ? [] : XEUtils.isArray(modelValue) ? modelValue : [modelValue]
1772
+ return h(
1773
+ 'div',
1774
+ {
1775
+ ref: refElem,
1776
+ class: [
1777
+ 'vxe-cascader',
1778
+ className ? (XEUtils.isFunction(className) ? className({ $cascader: $xeCascader }) : className) : '',
1779
+ {
1780
+ [`size--${vSize}`]: vSize,
1781
+ 'is--filterable': filterable,
1782
+ 'is--visible': visiblePanel,
1783
+ 'is--disabled': isDisabled,
1784
+ 'is--loading': loading,
1785
+ 'is--active': isActivated
1786
+ }
1787
+ ]
1788
+ },
1789
+ [
1790
+ h(
1791
+ VxeInputComponent,
1792
+ {
1793
+ ref: refInput,
1794
+ clearable: props.clearable,
1795
+ placeholder: loading ? getI18n('vxe.select.loadingText') : props.placeholder,
1796
+ editable: false,
1797
+ disabled: isDisabled,
1798
+ type: 'text',
1799
+ prefixIcon: props.prefixIcon,
1800
+ suffixIcon: loading ? getIcon().TREE_SELECT_LOADED : visiblePanel ? getIcon().TREE_SELECT_OPEN : getIcon().TREE_SELECT_CLOSE,
1801
+ modelValue: loading ? '' : selectLabel,
1802
+ title: selectLabel,
1803
+ onClear: clearEvent,
1804
+ onClick: clickEvent,
1805
+ onFocus: focusEvent,
1806
+ onBlur: blurEvent,
1807
+ onSuffixClick: togglePanelEvent
1808
+ },
1809
+ prefixSlot
1810
+ ? {
1811
+ prefix: () => prefixSlot({})
1812
+ }
1813
+ : {}
1814
+ ),
1815
+ h(
1816
+ Teleport,
1817
+ {
1818
+ to: 'body',
1819
+ disabled: btnTransfer ? !initialized : true
1820
+ },
1821
+ [
1822
+ h(
1823
+ 'div',
1824
+ {
1825
+ ref: refOptionPanel,
1826
+ class: [
1827
+ 'vxe-table--ignore-clear vxe-cascader--panel',
1828
+ popupClassName ? (XEUtils.isFunction(popupClassName) ? popupClassName({ $cascader: $xeCascader }) : popupClassName) : '',
1829
+ {
1830
+ [`size--${vSize}`]: vSize,
1831
+ 'is--transfer': btnTransfer,
1832
+ 'ani--leave': !loading && isAniVisible,
1833
+ 'ani--enter': !loading && visiblePanel
1834
+ }
1835
+ ],
1836
+ placement: reactData.panelPlacement,
1837
+ style: popupWrapperStyle
1838
+ },
1839
+ initialized
1840
+ ? [
1841
+ h(
1842
+ 'div',
1843
+ {
1844
+ class: 'vxe-cascader--panel-wrapper'
1845
+ },
1846
+ [
1847
+ filterable
1848
+ ? h(
1849
+ 'div',
1850
+ {
1851
+ class: 'vxe-cascader--panel-search'
1852
+ },
1853
+ [
1854
+ h(VxeInputComponent, {
1855
+ ref: refInpSearch,
1856
+ class: 'vxe-cascader-search--input',
1857
+ modelValue: searchValue,
1858
+ clearable: true,
1859
+ disabled: false,
1860
+ readonly: false,
1861
+ placeholder: getI18n('vxe.cascader.search'),
1862
+ prefixIcon: getIcon().INPUT_SEARCH,
1863
+ 'onUpdate:modelValue': modelSearchEvent
1864
+ })
1865
+ ]
1866
+ )
1867
+ : renderEmptyElement($xeCascader),
1868
+ (showCheckedButton && multiple) || showClearButton || headerSlot
1869
+ ? h(
1870
+ 'div',
1871
+ {
1872
+ class: 'vxe-cascader--panel-header'
1873
+ },
1874
+ headerSlot
1875
+ ? headerSlot({})
1876
+ : [
1877
+ h(
1878
+ 'div',
1879
+ {
1880
+ class: 'vxe-cascader--header-button'
1881
+ },
1882
+ [
1883
+ (showCheckedButton && multiple) || showClearButton
1884
+ ? h(
1885
+ 'div',
1886
+ {
1887
+ class: 'vxe-cascader--selected-btns'
1888
+ },
1889
+ [
1890
+ showCheckedButton && multiple
1891
+ ? h(VxeButtonComponent, {
1892
+ content: getI18n('vxe.treeSelect.allChecked'),
1893
+ mode: 'text',
1894
+ onClick: allCheckedPanelEvent
1895
+ })
1896
+ : renderEmptyElement($xeCascader),
1897
+ showClearButton
1898
+ ? h(VxeButtonComponent, {
1899
+ content: getI18n('vxe.treeSelect.clearChecked'),
1900
+ mode: 'text',
1901
+ onClick: clearCheckedPanelEvent
1902
+ })
1903
+ : renderEmptyElement($xeCascader)
1904
+ ]
1905
+ )
1906
+ : renderEmptyElement($xeCascader)
1907
+ ]
1908
+ )
1909
+ ]
1910
+ )
1911
+ : renderEmptyElement($xeCascader),
1912
+ h(
1913
+ 'div',
1914
+ {
1915
+ class: 'vxe-cascader--panel-body'
1916
+ },
1917
+ [
1918
+ h(
1919
+ 'div',
1920
+ {
1921
+ ref: refChunkWrapper,
1922
+ class: 'vxe-cascader-chunk--wrapper'
1923
+ },
1924
+ [
1925
+ currentCunkList.map((chunks, chunkIndex) => {
1926
+ return h(
1927
+ 'div',
1928
+ {
1929
+ key: chunkIndex,
1930
+ class: 'vxe-cascader-chunk--item-wrapper'
1931
+ },
1932
+ [
1933
+ h(
1934
+ VxeListComponent,
1935
+ {
1936
+ data: chunks,
1937
+ virtualYConfig: listVirtualYOpts
1938
+ },
1939
+ {
1940
+ default(slotParams: VxeListSlotTypes.DefaultSlotParams) {
1941
+ const { items } = slotParams
1942
+ return items.map((node, nodeIndex) => {
1943
+ const nodeid = getNodeId(node)
1944
+ return renderNode(node, nodeid, nodeIndex, chunks, chunkIndex)
1945
+ })
1946
+ }
1947
+ }
1948
+ )
1949
+ ]
1950
+ )
1951
+ })
1952
+ ]
1953
+ )
1954
+ ]
1955
+ ),
1956
+ footerSlot || showTotalButton || showCloseButton
1957
+ ? h(
1958
+ 'div',
1959
+ {
1960
+ class: 'vxe-cascader--panel-footer'
1961
+ },
1962
+ footerSlot
1963
+ ? footerSlot({})
1964
+ : [
1965
+ h(
1966
+ 'div',
1967
+ {
1968
+ class: 'vxe-cascader--footer-button'
1969
+ },
1970
+ [
1971
+ showTotalButton
1972
+ ? h(
1973
+ 'div',
1974
+ {
1975
+ class: 'vxe-cascader--total-btns'
1976
+ },
1977
+ getI18n('vxe.treeSelect.total', [selectVals.length])
1978
+ )
1979
+ : renderEmptyElement($xeCascader),
1980
+ showCloseButton
1981
+ ? h(
1982
+ 'div',
1983
+ {
1984
+ class: 'vxe-cascader--oper-btns'
1985
+ },
1986
+ [
1987
+ h(VxeButtonComponent, {
1988
+ content: getI18n('vxe.select.close'),
1989
+ mode: 'text',
1990
+ onClick: closePanelEvent
1991
+ })
1992
+ ]
1993
+ )
1994
+ : renderEmptyElement($xeCascader)
1995
+ ]
1996
+ )
1997
+ ]
1998
+ )
1999
+ : renderEmptyElement($xeCascader)
2000
+ ]
2001
+ )
2002
+ ]
2003
+ : []
2004
+ )
2005
+ ]
2006
+ )
2007
+ ]
2008
+ )
2009
+ }
2010
+
2011
+ watch(
2012
+ () => props.modelValue,
2013
+ () => {
2014
+ if (!internalData.isUpdateMode) {
2015
+ updateModelChecked()
2016
+ handleCurrentItems()
2017
+ updateCurrentChunk()
2018
+ }
2019
+ internalData.isUpdateMode = false
2020
+ }
2021
+ )
2022
+
2023
+ watch(
2024
+ () => props.options,
2025
+ () => {
2026
+ cacheNodeMap()
2027
+ }
2028
+ )
2029
+
2030
+ const dataFlag = ref(0)
2031
+ watch(
2032
+ () => (props.options ? props.options.length : 0),
2033
+ () => {
2034
+ dataFlag.value++
2035
+ }
2036
+ )
2037
+ watch(
2038
+ () => props.options,
2039
+ () => {
2040
+ dataFlag.value++
2041
+ }
2042
+ )
2043
+ watch(dataFlag, () => {
2044
+ loadData(props.options || [])
2045
+ })
2046
+
2047
+ loadData(props.options || [])
2048
+
2049
+ onMounted(() => {
2050
+ globalEvents.on($xeCascader, 'mousedown', handleGlobalMousedownEvent)
2051
+ globalEvents.on($xeCascader, 'blur', handleGlobalBlurEvent)
2052
+ globalEvents.on($xeCascader, 'resize', handleGlobalResizeEvent)
2053
+ globalEvents.on($xeCascader, 'scroll', handleGlobalScrollEvent)
2054
+ })
2055
+
2056
+ onUnmounted(() => {
2057
+ globalEvents.off($xeCascader, 'mousedown')
2058
+ globalEvents.off($xeCascader, 'blur')
2059
+ globalEvents.off($xeCascader, 'resize')
2060
+ globalEvents.off($xeCascader, 'scroll')
2061
+ XEUtils.assign(reactData, createReactData())
2062
+ XEUtils.assign(internalData, createInternalData())
2063
+ })
2064
+
2065
+ provide('$xeCascader', $xeCascader)
2066
+
2067
+ $xeCascader.renderVN = renderVN
2068
+
2069
+ return $xeCascader
2070
+ },
2071
+ render() {
2072
+ return this.renderVN()
2073
+ }
2074
+ })