vxe-pc-ui 3.0.1 → 3.0.2

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 (367) hide show
  1. package/README.md +23 -25
  2. package/es/calendar/index.js +12 -0
  3. package/es/calendar/src/calendar.js +1227 -0
  4. package/es/calendar/style.css +247 -0
  5. package/es/calendar/style.min.css +1 -0
  6. package/es/checkbox/src/checkbox.js +6 -1
  7. package/es/checkbox/src/group.js +6 -1
  8. package/es/collapse/index.js +12 -0
  9. package/es/collapse/src/collapse-pane.js +39 -0
  10. package/es/collapse/src/collapse.js +39 -0
  11. package/es/collapse/style.css +0 -0
  12. package/es/collapse/style.min.css +0 -0
  13. package/es/collapse-pane/index.js +12 -0
  14. package/es/collapse-pane/style.css +0 -0
  15. package/es/collapse-pane/style.min.css +0 -0
  16. package/es/components.js +27 -27
  17. package/es/date-picker/src/date-picker.js +17 -13
  18. package/es/drawer/src/drawer.js +17 -12
  19. package/es/form/index.js +13 -0
  20. package/es/form/render/index.js +461 -0
  21. package/es/form/src/form-config-item.js +201 -0
  22. package/es/form/src/form-gather.js +87 -0
  23. package/es/form/src/form-item.js +291 -0
  24. package/es/form/src/form.js +762 -0
  25. package/es/form/src/itemInfo.js +43 -0
  26. package/es/form/src/render.js +78 -0
  27. package/es/form/src/util.js +66 -0
  28. package/es/form/style.css +470 -0
  29. package/es/form/style.min.css +1 -0
  30. package/es/form-gather/index.js +12 -0
  31. package/es/form-gather/style.css +0 -0
  32. package/es/form-gather/style.min.css +0 -0
  33. package/es/form-item/index.js +12 -0
  34. package/es/form-item/style.css +0 -0
  35. package/es/form-item/style.min.css +0 -0
  36. package/es/icon/style.css +1 -1
  37. package/es/icon-picker/src/icon-picker.js +5 -1
  38. package/es/image/src/preview.js +1 -2
  39. package/es/input/src/input.js +19 -15
  40. package/es/list/index.js +12 -0
  41. package/es/list/src/list.js +373 -0
  42. package/es/list/style.css +28 -0
  43. package/es/list/style.min.css +1 -0
  44. package/es/loading/src/loading.js +5 -0
  45. package/es/menu/src/menu.js +6 -2
  46. package/es/modal/src/modal.js +7 -4
  47. package/es/number-input/src/number-input.js +11 -7
  48. package/es/pager/style.css +303 -0
  49. package/es/pager/style.min.css +1 -0
  50. package/es/password-input/src/password-input.js +7 -3
  51. package/es/pulldown/src/pulldown.js +6 -2
  52. package/es/radio/src/button.js +6 -2
  53. package/es/radio/src/group.js +6 -2
  54. package/es/radio/src/radio.js +6 -2
  55. package/es/select/src/select.js +16 -1
  56. package/es/select/src/util.js +2 -1
  57. package/es/style.css +1 -1
  58. package/es/style.min.css +1 -1
  59. package/es/switch/src/switch.js +6 -2
  60. package/es/tabs/src/tabs.js +8 -3
  61. package/es/textarea/src/textarea.js +9 -5
  62. package/es/tooltip/src/tooltip.js +6 -1
  63. package/es/tree/index.js +12 -0
  64. package/es/tree/src/tree.js +1216 -0
  65. package/es/tree/style.css +219 -0
  66. package/es/tree/style.min.css +1 -0
  67. package/es/tree-select/index.js +12 -0
  68. package/es/tree-select/src/tree-select.js +685 -0
  69. package/es/tree-select/style.css +129 -0
  70. package/es/tree-select/style.min.css +1 -0
  71. package/es/ui/index.js +1 -1
  72. package/es/ui/src/log.js +1 -1
  73. package/es/ui/src/vn.js +1 -1
  74. package/es/upload/src/upload.js +9 -5
  75. package/es/vxe-calendar/index.js +3 -0
  76. package/es/vxe-calendar/style.css +247 -0
  77. package/es/vxe-calendar/style.min.css +1 -0
  78. package/es/vxe-collapse/index.js +3 -0
  79. package/es/vxe-collapse/style.css +0 -0
  80. package/es/vxe-collapse/style.min.css +0 -0
  81. package/es/vxe-collapse-pane/index.js +3 -0
  82. package/es/vxe-collapse-pane/style.css +0 -0
  83. package/es/vxe-collapse-pane/style.min.css +0 -0
  84. package/es/vxe-form/index.js +3 -0
  85. package/es/vxe-form/style.css +470 -0
  86. package/es/vxe-form/style.min.css +1 -0
  87. package/es/vxe-form-gather/index.js +3 -0
  88. package/es/vxe-form-gather/style.css +0 -0
  89. package/es/vxe-form-gather/style.min.css +0 -0
  90. package/es/vxe-form-item/index.js +3 -0
  91. package/es/vxe-form-item/style.css +0 -0
  92. package/es/vxe-form-item/style.min.css +0 -0
  93. package/es/vxe-list/index.js +3 -0
  94. package/es/vxe-list/style.css +28 -0
  95. package/es/vxe-list/style.min.css +1 -0
  96. package/es/vxe-pager/index.js +3 -0
  97. package/es/vxe-pager/style.css +303 -0
  98. package/es/vxe-pager/style.min.css +1 -0
  99. package/es/vxe-tree/index.js +3 -0
  100. package/es/vxe-tree/style.css +219 -0
  101. package/es/vxe-tree/style.min.css +1 -0
  102. package/es/vxe-tree-select/index.js +3 -0
  103. package/es/vxe-tree-select/style.css +129 -0
  104. package/es/vxe-tree-select/style.min.css +1 -0
  105. package/lib/calendar/index.js +19 -0
  106. package/lib/calendar/index.min.js +1 -0
  107. package/lib/calendar/src/calendar.js +1286 -0
  108. package/lib/calendar/src/calendar.min.js +1 -0
  109. package/lib/calendar/style/index.js +1 -0
  110. package/lib/calendar/style/style.css +247 -0
  111. package/lib/calendar/style/style.min.css +1 -0
  112. package/lib/checkbox/src/checkbox.js +6 -1
  113. package/lib/checkbox/src/checkbox.min.js +1 -1
  114. package/lib/checkbox/src/group.js +6 -1
  115. package/lib/checkbox/src/group.min.js +1 -1
  116. package/lib/collapse/index.js +19 -0
  117. package/lib/collapse/index.min.js +1 -0
  118. package/lib/collapse/src/collapse-pane.js +48 -0
  119. package/lib/collapse/src/collapse-pane.min.js +1 -0
  120. package/lib/collapse/src/collapse.js +48 -0
  121. package/lib/collapse/src/collapse.min.js +1 -0
  122. package/lib/collapse/style/index.js +1 -0
  123. package/lib/collapse/style/style.css +0 -0
  124. package/lib/collapse/style/style.min.css +0 -0
  125. package/lib/collapse-pane/index.js +19 -0
  126. package/lib/collapse-pane/index.min.js +1 -0
  127. package/lib/collapse-pane/style/index.js +1 -0
  128. package/lib/collapse-pane/style/style.css +0 -0
  129. package/lib/collapse-pane/style/style.min.css +0 -0
  130. package/lib/components.js +114 -39
  131. package/lib/components.min.js +1 -1
  132. package/lib/date-picker/src/date-picker.js +17 -13
  133. package/lib/date-picker/src/date-picker.min.js +1 -1
  134. package/lib/drawer/src/drawer.js +17 -12
  135. package/lib/drawer/src/drawer.min.js +1 -1
  136. package/lib/form/index.js +20 -0
  137. package/lib/form/index.min.js +1 -0
  138. package/lib/form/render/index.js +509 -0
  139. package/lib/form/render/index.min.js +1 -0
  140. package/lib/form/src/form-config-item.js +210 -0
  141. package/lib/form/src/form-config-item.min.js +1 -0
  142. package/lib/form/src/form-gather.js +99 -0
  143. package/lib/form/src/form-gather.min.js +1 -0
  144. package/lib/form/src/form-item.js +299 -0
  145. package/lib/form/src/form-item.min.js +1 -0
  146. package/lib/form/src/form.js +856 -0
  147. package/lib/form/src/form.min.js +1 -0
  148. package/lib/form/src/itemInfo.js +60 -0
  149. package/lib/form/src/itemInfo.min.js +1 -0
  150. package/lib/form/src/render.js +94 -0
  151. package/lib/form/src/render.min.js +1 -0
  152. package/lib/form/src/util.js +93 -0
  153. package/lib/form/src/util.min.js +1 -0
  154. package/lib/form/style/index.js +1 -0
  155. package/lib/form/style/style.css +470 -0
  156. package/lib/form/style/style.min.css +1 -0
  157. package/lib/form-gather/index.js +19 -0
  158. package/lib/form-gather/index.min.js +1 -0
  159. package/lib/form-gather/style/index.js +1 -0
  160. package/lib/form-gather/style/style.css +0 -0
  161. package/lib/form-gather/style/style.min.css +0 -0
  162. package/lib/form-item/index.js +19 -0
  163. package/lib/form-item/index.min.js +1 -0
  164. package/lib/form-item/style/index.js +1 -0
  165. package/lib/form-item/style/style.css +0 -0
  166. package/lib/form-item/style/style.min.css +0 -0
  167. package/lib/icon/style/style.css +1 -1
  168. package/lib/icon/style/style.min.css +1 -1
  169. package/lib/icon-picker/src/icon-picker.js +5 -1
  170. package/lib/icon-picker/src/icon-picker.min.js +1 -1
  171. package/lib/image/src/preview.js +1 -2
  172. package/lib/image/src/preview.min.js +1 -1
  173. package/lib/index.umd.js +11284 -5009
  174. package/lib/index.umd.min.js +1 -1
  175. package/lib/input/src/input.js +19 -15
  176. package/lib/input/src/input.min.js +1 -1
  177. package/lib/list/index.js +19 -0
  178. package/lib/list/index.min.js +1 -0
  179. package/lib/list/src/list.js +415 -0
  180. package/lib/list/src/list.min.js +1 -0
  181. package/lib/list/style/index.js +1 -0
  182. package/lib/list/style/style.css +28 -0
  183. package/lib/list/style/style.min.css +1 -0
  184. package/lib/loading/src/loading.js +5 -0
  185. package/lib/loading/src/loading.min.js +1 -1
  186. package/lib/menu/src/menu.js +6 -2
  187. package/lib/menu/src/menu.min.js +1 -1
  188. package/lib/modal/src/modal.js +7 -4
  189. package/lib/modal/src/modal.min.js +1 -1
  190. package/lib/number-input/src/number-input.js +11 -7
  191. package/lib/number-input/src/number-input.min.js +1 -1
  192. package/lib/pager/style/index.js +1 -0
  193. package/lib/pager/style/style.css +303 -0
  194. package/lib/pager/style/style.min.css +1 -0
  195. package/lib/password-input/src/password-input.js +7 -3
  196. package/lib/password-input/src/password-input.min.js +1 -1
  197. package/lib/pulldown/src/pulldown.js +6 -2
  198. package/lib/pulldown/src/pulldown.min.js +1 -1
  199. package/lib/radio/src/button.js +6 -2
  200. package/lib/radio/src/button.min.js +1 -1
  201. package/lib/radio/src/group.js +6 -2
  202. package/lib/radio/src/group.min.js +1 -1
  203. package/lib/radio/src/radio.js +6 -2
  204. package/lib/radio/src/radio.min.js +1 -1
  205. package/lib/select/src/select.js +16 -1
  206. package/lib/select/src/select.min.js +1 -1
  207. package/lib/select/src/util.js +2 -1
  208. package/lib/style.css +1 -1
  209. package/lib/style.min.css +1 -1
  210. package/lib/switch/src/switch.js +6 -2
  211. package/lib/switch/src/switch.min.js +1 -1
  212. package/lib/tabs/src/tabs.js +8 -3
  213. package/lib/tabs/src/tabs.min.js +1 -1
  214. package/lib/textarea/src/textarea.js +9 -5
  215. package/lib/textarea/src/textarea.min.js +1 -1
  216. package/lib/tooltip/src/tooltip.js +6 -1
  217. package/lib/tooltip/src/tooltip.min.js +1 -1
  218. package/lib/tree/index.js +19 -0
  219. package/lib/tree/index.min.js +1 -0
  220. package/lib/tree/src/tree.js +1324 -0
  221. package/lib/tree/src/tree.min.js +1 -0
  222. package/lib/tree/style/index.js +1 -0
  223. package/lib/tree/style/style.css +219 -0
  224. package/lib/tree/style/style.min.css +1 -0
  225. package/lib/tree-select/index.js +19 -0
  226. package/lib/tree-select/index.min.js +1 -0
  227. package/lib/tree-select/src/tree-select.js +695 -0
  228. package/lib/tree-select/src/tree-select.min.js +1 -0
  229. package/lib/tree-select/style/index.js +1 -0
  230. package/lib/tree-select/style/style.css +129 -0
  231. package/lib/tree-select/style/style.min.css +1 -0
  232. package/lib/ui/index.js +1 -1
  233. package/lib/ui/index.min.js +1 -1
  234. package/lib/ui/src/log.js +1 -1
  235. package/lib/ui/src/log.min.js +1 -1
  236. package/lib/ui/src/vn.js +1 -1
  237. package/lib/ui/src/vn.min.js +1 -1
  238. package/lib/upload/src/upload.js +9 -5
  239. package/lib/upload/src/upload.min.js +1 -1
  240. package/lib/vxe-calendar/index.js +23 -0
  241. package/lib/vxe-calendar/index.min.js +1 -0
  242. package/lib/vxe-calendar/style/index.js +1 -0
  243. package/lib/vxe-calendar/style/style.css +247 -0
  244. package/lib/vxe-calendar/style/style.min.css +1 -0
  245. package/lib/vxe-collapse/index.js +23 -0
  246. package/lib/vxe-collapse/index.min.js +1 -0
  247. package/lib/vxe-collapse/style/index.js +1 -0
  248. package/lib/vxe-collapse/style/style.css +0 -0
  249. package/lib/vxe-collapse/style/style.min.css +0 -0
  250. package/lib/vxe-collapse-pane/index.js +23 -0
  251. package/lib/vxe-collapse-pane/index.min.js +1 -0
  252. package/lib/vxe-collapse-pane/style/index.js +1 -0
  253. package/lib/vxe-collapse-pane/style/style.css +0 -0
  254. package/lib/vxe-collapse-pane/style/style.min.css +0 -0
  255. package/lib/vxe-form/index.js +23 -0
  256. package/lib/vxe-form/index.min.js +1 -0
  257. package/lib/vxe-form/style/index.js +1 -0
  258. package/lib/vxe-form/style/style.css +470 -0
  259. package/lib/vxe-form/style/style.min.css +1 -0
  260. package/lib/vxe-form-gather/index.js +23 -0
  261. package/lib/vxe-form-gather/index.min.js +1 -0
  262. package/lib/vxe-form-gather/style/index.js +1 -0
  263. package/lib/vxe-form-gather/style/style.css +0 -0
  264. package/lib/vxe-form-gather/style/style.min.css +0 -0
  265. package/lib/vxe-form-item/index.js +23 -0
  266. package/lib/vxe-form-item/index.min.js +1 -0
  267. package/lib/vxe-form-item/style/index.js +1 -0
  268. package/lib/vxe-form-item/style/style.css +0 -0
  269. package/lib/vxe-form-item/style/style.min.css +0 -0
  270. package/lib/vxe-list/index.js +23 -0
  271. package/lib/vxe-list/index.min.js +1 -0
  272. package/lib/vxe-list/style/index.js +1 -0
  273. package/lib/vxe-list/style/style.css +28 -0
  274. package/lib/vxe-list/style/style.min.css +1 -0
  275. package/lib/vxe-pager/index.js +23 -0
  276. package/lib/vxe-pager/index.min.js +1 -0
  277. package/lib/vxe-pager/style/index.js +1 -0
  278. package/lib/vxe-pager/style/style.css +303 -0
  279. package/lib/vxe-pager/style/style.min.css +1 -0
  280. package/lib/vxe-tree/index.js +23 -0
  281. package/lib/vxe-tree/index.min.js +1 -0
  282. package/lib/vxe-tree/style/index.js +1 -0
  283. package/lib/vxe-tree/style/style.css +219 -0
  284. package/lib/vxe-tree/style/style.min.css +1 -0
  285. package/lib/vxe-tree-select/index.js +23 -0
  286. package/lib/vxe-tree-select/index.min.js +1 -0
  287. package/lib/vxe-tree-select/style/index.js +1 -0
  288. package/lib/vxe-tree-select/style/style.css +129 -0
  289. package/lib/vxe-tree-select/style/style.min.css +1 -0
  290. package/package.json +1 -1
  291. package/packages/calendar/index.ts +16 -0
  292. package/packages/calendar/src/calendar.ts +1281 -0
  293. package/packages/checkbox/src/checkbox.ts +7 -1
  294. package/packages/checkbox/src/group.ts +8 -2
  295. package/packages/collapse/index.ts +16 -0
  296. package/packages/collapse/src/collapse-pane.ts +47 -0
  297. package/packages/collapse/src/collapse.ts +47 -0
  298. package/packages/collapse-pane/index.ts +16 -0
  299. package/packages/components.ts +27 -27
  300. package/packages/date-picker/src/date-picker.ts +18 -13
  301. package/packages/drawer/src/drawer.ts +18 -12
  302. package/packages/form/index.ts +17 -0
  303. package/packages/form/render/index.ts +499 -0
  304. package/packages/form/src/form-config-item.ts +219 -0
  305. package/packages/form/src/form-gather.ts +104 -0
  306. package/packages/form/src/form-item.ts +322 -0
  307. package/packages/form/src/form.ts +809 -0
  308. package/packages/form/src/itemInfo.ts +47 -0
  309. package/packages/form/src/render.ts +98 -0
  310. package/packages/form/src/util.ts +80 -0
  311. package/packages/form-gather/index.ts +16 -0
  312. package/packages/form-item/index.ts +16 -0
  313. package/packages/icon-picker/src/icon-picker.ts +6 -1
  314. package/packages/image/src/preview.ts +1 -2
  315. package/packages/input/src/input.ts +20 -15
  316. package/packages/layout-footer/src/layout-footer.ts +1 -0
  317. package/packages/list/index.ts +16 -0
  318. package/packages/list/src/list.ts +403 -0
  319. package/packages/loading/src/loading.ts +6 -0
  320. package/packages/menu/src/menu.ts +7 -2
  321. package/packages/modal/src/modal.ts +8 -4
  322. package/packages/number-input/src/number-input.ts +12 -7
  323. package/packages/password-input/src/password-input.ts +8 -3
  324. package/packages/pulldown/src/pulldown.ts +7 -2
  325. package/packages/radio/src/button.ts +7 -2
  326. package/packages/radio/src/group.ts +7 -2
  327. package/packages/radio/src/radio.ts +7 -2
  328. package/packages/select/src/select.ts +17 -1
  329. package/packages/select/src/util.ts +4 -3
  330. package/packages/switch/src/switch.ts +7 -2
  331. package/packages/tabs/src/tabs.ts +9 -3
  332. package/packages/textarea/src/textarea.ts +10 -5
  333. package/packages/tooltip/src/tooltip.ts +7 -1
  334. package/packages/tree/index.ts +16 -0
  335. package/packages/tree/src/tree.ts +1292 -0
  336. package/packages/tree-select/index.ts +16 -0
  337. package/packages/tree-select/src/tree-select.ts +743 -0
  338. package/packages/ui/src/vn.ts +1 -1
  339. package/packages/upload/src/upload.ts +10 -5
  340. package/types/components/calendar.d.ts +6 -0
  341. package/types/components/colgroup.d.ts +1 -0
  342. package/types/components/column.d.ts +1 -0
  343. package/types/components/drawer.d.ts +11 -10
  344. package/types/components/form-item.d.ts +1 -1
  345. package/types/components/form.d.ts +8 -1
  346. package/types/components/list.d.ts +1 -0
  347. package/types/components/table.d.ts +43 -4
  348. package/types/components/toolbar.d.ts +5 -0
  349. package/types/components/tree-select.d.ts +4 -0
  350. package/types/ui/index.d.ts +0 -5
  351. package/types/ui/renderer.d.ts +37 -36
  352. package/types/handles/form-design.d.ts +0 -4
  353. package/types/handles/index.d.ts +0 -3
  354. package/types/handles/list-design.d.ts +0 -4
  355. package/types/handles/table.d.ts +0 -4
  356. /package/es/icon/style/{iconfont.1725723159302.ttf → iconfont.1725869586078.ttf} +0 -0
  357. /package/es/icon/style/{iconfont.1725723159302.woff → iconfont.1725869586078.woff} +0 -0
  358. /package/es/icon/style/{iconfont.1725723159302.woff2 → iconfont.1725869586078.woff2} +0 -0
  359. /package/es/{iconfont.1725723159302.ttf → iconfont.1725869586078.ttf} +0 -0
  360. /package/es/{iconfont.1725723159302.woff → iconfont.1725869586078.woff} +0 -0
  361. /package/es/{iconfont.1725723159302.woff2 → iconfont.1725869586078.woff2} +0 -0
  362. /package/lib/icon/style/{iconfont.1725723159302.ttf → iconfont.1725869586078.ttf} +0 -0
  363. /package/lib/icon/style/{iconfont.1725723159302.woff → iconfont.1725869586078.woff} +0 -0
  364. /package/lib/icon/style/{iconfont.1725723159302.woff2 → iconfont.1725869586078.woff2} +0 -0
  365. /package/lib/{iconfont.1725723159302.ttf → iconfont.1725869586078.ttf} +0 -0
  366. /package/lib/{iconfont.1725723159302.woff → iconfont.1725869586078.woff} +0 -0
  367. /package/lib/{iconfont.1725723159302.woff2 → iconfont.1725869586078.woff2} +0 -0
@@ -0,0 +1,809 @@
1
+ import { PropType, CreateElement, VNode } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import XEUtils from 'xe-utils'
4
+ import { getConfig, validators, renderer, createEvent, globalMixins } from '../../ui'
5
+ import { getFuncText, isEnableConf, eqEmptyValue } from '../../ui/src/utils'
6
+ import { scrollToView } from '../../ui/src/dom'
7
+ import { createItem, handleFieldOrItem, isHiddenItem, isActiveItem } from './util'
8
+ import VxeTooltipComponent from '../../tooltip/src/tooltip'
9
+ import VxeFormConfigItem from './form-config-item'
10
+ import VxeLoadingComponent from '../../loading/src/loading'
11
+ import { getSlotVNs } from '../../ui/src/vn'
12
+ import { warnLog, errLog } from '../../ui/src/log'
13
+
14
+ import type { VxeFormPropTypes, VxeFormEmits, VxeComponentSizeType, ValueOf, VxeGridConstructor, FormReactData, VxeFormDefines, VxeFormItemPropTypes, FormInternalData, VxeTooltipConstructor } from '../../../types'
15
+
16
+ class Rule {
17
+ constructor (rule: any) {
18
+ Object.assign(this, {
19
+ $options: rule,
20
+ required: rule.required,
21
+ min: rule.min,
22
+ max: rule.min,
23
+ type: rule.type,
24
+ pattern: rule.pattern,
25
+ validator: rule.validator,
26
+ trigger: rule.trigger,
27
+ maxWidth: rule.maxWidth
28
+ })
29
+ }
30
+
31
+ get content () {
32
+ return getFuncText(this.$options.content || this.$options.message)
33
+ }
34
+
35
+ get message () {
36
+ return this.content
37
+ }
38
+
39
+ [key: string]: any
40
+ }
41
+
42
+ const validErrorRuleValue = (rule: VxeFormDefines.FormRule, val: any) => {
43
+ const { type, min, max, pattern } = rule
44
+ const isNumType = type === 'number'
45
+ const numVal = isNumType ? XEUtils.toNumber(val) : XEUtils.getSize(val)
46
+ // 判断数值
47
+ if (isNumType && isNaN(val)) {
48
+ return true
49
+ }
50
+ // 如果存在 min,判断最小值
51
+ if (!XEUtils.eqNull(min) && numVal < XEUtils.toNumber(min)) {
52
+ return true
53
+ }
54
+ // 如果存在 max,判断最大值
55
+ if (!XEUtils.eqNull(max) && numVal > XEUtils.toNumber(max)) {
56
+ return true
57
+ }
58
+ // 如果存在 pattern,正则校验
59
+ if (pattern && !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)) {
60
+ return true
61
+ }
62
+ return false
63
+ }
64
+
65
+ function getResetValue (value: any, resetValue: any) {
66
+ if (XEUtils.isArray(value)) {
67
+ resetValue = []
68
+ }
69
+ return resetValue
70
+ }
71
+
72
+ export default defineVxeComponent({
73
+ name: 'VxeForm',
74
+ mixins: [
75
+ globalMixins.sizeMixin
76
+ ],
77
+ props: {
78
+ collapseStatus: {
79
+ type: Boolean as PropType<VxeFormPropTypes.CollapseStatus>,
80
+ default: true
81
+ },
82
+ loading: Boolean as PropType<VxeFormPropTypes.Loading>,
83
+ data: Object as PropType<VxeFormPropTypes.Data>,
84
+ size: {
85
+ type: String as PropType<VxeFormPropTypes.Size>,
86
+ default: () => getConfig().form.size || getConfig().size
87
+ },
88
+ span: {
89
+ type: [String, Number] as PropType<VxeFormPropTypes.Span>,
90
+ default: () => getConfig().form.span
91
+ },
92
+ align: {
93
+ type: String as PropType<VxeFormPropTypes.Align>,
94
+ default: () => getConfig().form.align
95
+ },
96
+ titleBold: {
97
+ type: Boolean as PropType<VxeFormPropTypes.TitleBold>,
98
+ default: () => getConfig().form.titleBold
99
+ },
100
+ titleAlign: {
101
+ type: String as PropType<VxeFormPropTypes.TitleAlign>,
102
+ default: () => getConfig().form.titleAlign
103
+ },
104
+ titleWidth: {
105
+ type: [String, Number] as PropType<VxeFormPropTypes.TitleWidth>,
106
+ default: () => getConfig().form.titleWidth
107
+ },
108
+ titleColon: {
109
+ type: Boolean as PropType<VxeFormPropTypes.TitleColon>,
110
+ default: () => getConfig().form.titleColon
111
+ },
112
+ titleAsterisk: {
113
+ type: Boolean as PropType<VxeFormPropTypes.TitleAsterisk>,
114
+ default: () => getConfig().form.titleAsterisk
115
+ },
116
+ titleOverflow: {
117
+ type: [Boolean, String] as PropType<VxeFormPropTypes.TitleOverflow>,
118
+ default: () => getConfig().form.titleOverflow
119
+ },
120
+ vertical: {
121
+ type: Boolean as PropType<VxeFormPropTypes.Vertical>,
122
+ default: () => getConfig().form.vertical
123
+ },
124
+ padding: {
125
+ type: Boolean as PropType<VxeFormPropTypes.Padding>,
126
+ default: () => getConfig().form.padding
127
+ },
128
+ className: [String, Function] as PropType<VxeFormPropTypes.ClassName>,
129
+ readonly: Boolean as PropType<VxeFormPropTypes.Readonly>,
130
+ disabled: Boolean as PropType<VxeFormPropTypes.Disabled>,
131
+ items: Array as PropType<VxeFormPropTypes.Items>,
132
+ rules: Object as PropType<VxeFormPropTypes.Rules>,
133
+ preventSubmit: {
134
+ type: Boolean as PropType<VxeFormPropTypes.PreventSubmit>,
135
+ default: () => getConfig().form.preventSubmit
136
+ },
137
+ validConfig: Object as PropType<VxeFormPropTypes.ValidConfig>,
138
+ tooltipConfig: Object as PropType<VxeFormPropTypes.TooltipConfig>,
139
+ customLayout: {
140
+ type: Boolean as PropType<VxeFormPropTypes.CustomLayout>,
141
+ default: () => getConfig().form.customLayout
142
+ }
143
+ },
144
+ inject: {
145
+ $xeGrid: {
146
+ default: null
147
+ }
148
+ },
149
+ provide () {
150
+ const $xeForm = this
151
+ return {
152
+ $xeForm,
153
+ xeFormItemInfo: null,
154
+ $xeFormGather: null,
155
+ $xeFormItem: null
156
+ }
157
+ },
158
+ data () {
159
+ const xID = XEUtils.uniqueId()
160
+ const reactData: FormReactData = {
161
+ collapseAll: false,
162
+ staticItems: [],
163
+ formItems: []
164
+ }
165
+ const internalData: FormInternalData = {
166
+ meTimeout: undefined,
167
+ stTimeout: undefined,
168
+ tooltipStore: {
169
+ item: null,
170
+ visible: false
171
+ }
172
+ }
173
+ return {
174
+ xID,
175
+ reactData,
176
+ internalData
177
+ }
178
+ },
179
+ computed: {
180
+ ...({} as {
181
+ computeSize(): VxeComponentSizeType
182
+ $xeGrid(): VxeGridConstructor | null
183
+ xegrid(): VxeGridConstructor | null
184
+ }),
185
+ computeValidOpts () {
186
+ const $xeForm = this
187
+ const props = $xeForm
188
+
189
+ return Object.assign({}, getConfig().form.validConfig, props.validConfig)
190
+ },
191
+ computeTooltipOpts () {
192
+ const $xeForm = this
193
+ const props = $xeForm
194
+
195
+ return Object.assign({}, getConfig().tooltip, getConfig().form.tooltipConfig, props.tooltipConfig)
196
+ }
197
+ },
198
+ methods: {
199
+ //
200
+ // Method
201
+ //
202
+ dispatchEvent (type: ValueOf<VxeFormEmits>, params: Record<string, any>, evnt: Event | null) {
203
+ const $xeForm = this
204
+ $xeForm.$emit(type, createEvent(evnt, { $form: $xeForm }, params))
205
+ },
206
+ callSlot (slotFunc: ((params: any) => any) | string | null, params: any) {
207
+ const $xeForm = this
208
+ const slots = $xeForm.$scopedSlots
209
+
210
+ if (slotFunc) {
211
+ if (XEUtils.isString(slotFunc)) {
212
+ slotFunc = slots[slotFunc] || null
213
+ }
214
+ if (XEUtils.isFunction(slotFunc)) {
215
+ return getSlotVNs(slotFunc(params))
216
+ }
217
+ }
218
+ return []
219
+ },
220
+ loadItem (list: VxeFormPropTypes.Items) {
221
+ const $xeForm = this
222
+ const slots = $xeForm.$scopedSlots
223
+ const reactData = $xeForm.reactData
224
+
225
+ if (list.length) {
226
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
227
+ list.forEach((item) => {
228
+ if (item.slots) {
229
+ XEUtils.each(item.slots, (func) => {
230
+ if (!XEUtils.isFunction(func)) {
231
+ if (!slots[func]) {
232
+ errLog('vxe.error.notSlot', [func])
233
+ }
234
+ }
235
+ })
236
+ }
237
+ })
238
+ }
239
+ }
240
+ reactData.staticItems = XEUtils.mapTree(list, item => createItem($xeForm, item), { children: 'children' })
241
+ return $xeForm.$nextTick()
242
+ },
243
+ getItems () {
244
+ const $xeForm = this
245
+ const reactData = $xeForm.reactData
246
+
247
+ const itemList: VxeFormDefines.ItemInfo[] = []
248
+ XEUtils.eachTree(reactData.formItems, item => {
249
+ itemList.push(item)
250
+ }, { children: 'children' })
251
+ return itemList
252
+ },
253
+ getItemByField (field: string) {
254
+ const $xeForm = this
255
+ const reactData = $xeForm.reactData
256
+
257
+ const rest = XEUtils.findTree(reactData.formItems, item => item.field === field, { children: 'children' })
258
+ return rest ? rest.item : null
259
+ },
260
+ getCollapseStatus () {
261
+ const $xeForm = this
262
+ const reactData = $xeForm.reactData
263
+
264
+ return reactData.collapseAll
265
+ },
266
+ toggleCollapse () {
267
+ const $xeForm = this
268
+ const reactData = $xeForm.reactData
269
+
270
+ const status = !$xeForm.getCollapseStatus()
271
+ reactData.collapseAll = status
272
+ $xeForm.$emit('update:collapseStatus', status)
273
+ return $xeForm.$nextTick()
274
+ },
275
+ toggleCollapseEvent (evnt: Event) {
276
+ const $xeForm = this
277
+ const props = $xeForm
278
+
279
+ $xeForm.toggleCollapse()
280
+ const status = $xeForm.getCollapseStatus()
281
+ $xeForm.dispatchEvent('toggle-collapse', { status, collapse: status, data: props.data }, evnt)
282
+ $xeForm.dispatchEvent('collapse', { status, collapse: status, data: props.data }, evnt)
283
+ },
284
+ clearValidate (fieldOrItem?: VxeFormItemPropTypes.Field | VxeFormItemPropTypes.Field[] | VxeFormDefines.ItemInfo | VxeFormDefines.ItemInfo[]) {
285
+ const $xeForm = this
286
+
287
+ if (fieldOrItem) {
288
+ let fields: any = fieldOrItem
289
+ if (!XEUtils.isArray(fieldOrItem)) {
290
+ fields = [fieldOrItem]
291
+ }
292
+ fields.forEach((field: any) => {
293
+ if (field) {
294
+ const item = handleFieldOrItem($xeForm, field)
295
+ if (item) {
296
+ item.showError = false
297
+ }
298
+ }
299
+ })
300
+ } else {
301
+ $xeForm.getItems().forEach((item) => {
302
+ item.showError = false
303
+ })
304
+ }
305
+ return $xeForm.$nextTick()
306
+ },
307
+ reset () {
308
+ const $xeForm = this
309
+ const props = $xeForm
310
+
311
+ const { data } = props
312
+ const itemList = $xeForm.getItems()
313
+ if (data) {
314
+ itemList.forEach((item) => {
315
+ const { field, resetValue, itemRender } = item
316
+ if (isEnableConf(itemRender)) {
317
+ const compConf = renderer.get(itemRender.name)
318
+ const fiResetMethod = compConf ? (compConf.formItemResetMethod || compConf.itemResetMethod) : null
319
+ if (compConf && fiResetMethod) {
320
+ fiResetMethod({ data, field, property: field, item, $form: $xeForm, $grid: $xeForm.xegrid })
321
+ } else if (field) {
322
+ XEUtils.set(data, field, resetValue === null ? getResetValue(XEUtils.get(data, field), undefined) : XEUtils.clone(resetValue, true))
323
+ }
324
+ }
325
+ })
326
+ }
327
+ return $xeForm.clearValidate()
328
+ },
329
+ resetEvent (evnt: Event) {
330
+ const $xeForm = this
331
+ const props = $xeForm
332
+
333
+ evnt.preventDefault()
334
+ $xeForm.reset()
335
+ $xeForm.dispatchEvent('reset', { data: props.data }, evnt)
336
+ },
337
+ handleFocus (fields: string[]) {
338
+ const $xeForm = this
339
+ const props = $xeForm
340
+ const $xeGrid = $xeForm.$xeGrid
341
+
342
+ const el = $xeForm.$refs.refElem as HTMLFormElement
343
+ if (el) {
344
+ for (let i = 0; i < fields.length; i++) {
345
+ const field = fields[i]
346
+ const item = $xeForm.getItemByField(field)
347
+ if (item && isEnableConf(item.itemRender)) {
348
+ const { itemRender } = item
349
+ const compConf = renderer.get(itemRender.name)
350
+ // 定位到第一个
351
+ if (!i) {
352
+ scrollToView(el.querySelector(`.${item.id}`))
353
+ }
354
+ let inputElem: HTMLElement | null = null
355
+ const autoFocus = itemRender.autoFocus || itemRender.autofocus || (compConf ? compConf.formItemAutoFocus : null)
356
+ // 如果指定了聚焦 class
357
+ if (XEUtils.isFunction(autoFocus)) {
358
+ inputElem = autoFocus({ $form: $xeForm, $grid: $xeGrid, item, data: props.data, field })
359
+ } else if (autoFocus) {
360
+ inputElem = el.querySelector(`.${item.id} ${autoFocus}`) as HTMLInputElement
361
+ }
362
+ if (inputElem) {
363
+ inputElem.focus()
364
+ break
365
+ }
366
+ }
367
+ }
368
+ }
369
+ },
370
+ /**
371
+ * 校验数据
372
+ * 按表格行、列顺序依次校验(同步或异步)
373
+ * 校验规则根据索引顺序依次校验,如果是异步则会等待校验完成才会继续校验下一列
374
+ * 如果校验失败则,触发回调或者 Promise<(ErrMap 校验不通过列的信息)>
375
+ * 如果是传回调方式这返回一个 (ErrMap 校验不通过列的信息)
376
+ *
377
+ * rule 配置:
378
+ * required=Boolean 是否必填
379
+ * min=Number 最小长度
380
+ * max=Number 最大长度
381
+ * validator=Function({ itemValue, rule, rules, data, property }) 自定义校验,接收一个 Promise
382
+ * trigger=change 触发方式
383
+ */
384
+ validItemRules (validType: string, fields: string | string[], val?: any): Promise<VxeFormDefines.ValidateErrorMapParams | undefined> {
385
+ const $xeForm = this
386
+ const props = $xeForm
387
+
388
+ const { data, rules: formRules } = props
389
+ const errorMaps: VxeFormDefines.ValidateErrorMapParams = {}
390
+ if (!XEUtils.isArray(fields)) {
391
+ fields = [fields]
392
+ }
393
+ return Promise.all(
394
+ fields.map((property) => {
395
+ const errorRules: Rule[] = []
396
+ const syncVailds: Promise<any>[] = []
397
+ if (property && formRules) {
398
+ const rules = XEUtils.get(formRules, property)
399
+ if (rules) {
400
+ const itemValue = XEUtils.isUndefined(val) ? XEUtils.get(data, property) : val
401
+ rules.forEach((rule) => {
402
+ const { type, trigger, required, validator } = rule
403
+ if (validType === 'all' || !trigger || validType === trigger) {
404
+ if (validator) {
405
+ const validParams = {
406
+ itemValue,
407
+ rule,
408
+ rules,
409
+ data,
410
+ field: property,
411
+ property,
412
+ $form: $xeForm
413
+ }
414
+ let customValid: any
415
+ if (XEUtils.isString(validator)) {
416
+ const gvItem = validators.get(validator)
417
+ if (gvItem) {
418
+ const validatorMethod = gvItem.formItemValidatorMethod || gvItem.itemValidatorMethod
419
+ if (validatorMethod) {
420
+ customValid = validatorMethod(validParams)
421
+ } else {
422
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
423
+ warnLog('vxe.error.notValidators', [validator])
424
+ }
425
+ }
426
+ } else {
427
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
428
+ errLog('vxe.error.notValidators', [validator])
429
+ }
430
+ }
431
+ } else {
432
+ customValid = validator(validParams)
433
+ }
434
+ if (customValid) {
435
+ if (XEUtils.isError(customValid)) {
436
+ errorRules.push(new Rule({ type: 'custom', trigger, content: customValid.message, rule: new Rule(rule) }))
437
+ } else if (customValid.catch) {
438
+ // 如果为异步校验(注:异步校验是并发无序的)
439
+ syncVailds.push(
440
+ customValid.catch((e: any) => {
441
+ errorRules.push(new Rule({ type: 'custom', trigger, content: e ? e.message : (rule.content || rule.message), rule: new Rule(rule) }))
442
+ })
443
+ )
444
+ }
445
+ }
446
+ } else {
447
+ const isArrType = type === 'array'
448
+ const isArrVal = XEUtils.isArray(itemValue)
449
+ let hasEmpty = true
450
+ if (isArrType || isArrVal) {
451
+ hasEmpty = !isArrVal || !itemValue.length
452
+ } else if (XEUtils.isString(itemValue)) {
453
+ hasEmpty = eqEmptyValue(itemValue.trim())
454
+ } else {
455
+ hasEmpty = eqEmptyValue(itemValue)
456
+ }
457
+ if (required ? (hasEmpty || validErrorRuleValue(rule, itemValue)) : (!hasEmpty && validErrorRuleValue(rule, itemValue))) {
458
+ errorRules.push(new Rule(rule))
459
+ }
460
+ }
461
+ }
462
+ })
463
+ }
464
+ }
465
+ return Promise.all(syncVailds).then(() => {
466
+ if (errorRules.length) {
467
+ errorMaps[property] = errorRules.map(rule => {
468
+ return {
469
+ $form: $xeForm,
470
+ rule,
471
+ data,
472
+ field: property,
473
+ property
474
+ }
475
+ })
476
+ }
477
+ })
478
+ })
479
+ ).then(() => {
480
+ if (!XEUtils.isEmpty(errorMaps)) {
481
+ return Promise.reject(errorMaps)
482
+ }
483
+ })
484
+ },
485
+ beginValidate (itemList: VxeFormDefines.ItemInfo[], type?: string, callback?: any): Promise<any> {
486
+ const $xeForm = this
487
+ const props = $xeForm
488
+ const internalData = $xeForm.internalData
489
+
490
+ const { data, rules: formRules } = props
491
+ const validOpts = $xeForm.computeValidOpts
492
+ const validRest: any = {}
493
+ const validFields: string[] = []
494
+ const itemValids: any[] = []
495
+ clearTimeout(internalData.meTimeout)
496
+ if (data && formRules) {
497
+ itemList.forEach((item) => {
498
+ const { field } = item
499
+ if (field && !isHiddenItem($xeForm, item) && isActiveItem($xeForm, item)) {
500
+ itemValids.push(
501
+ $xeForm.validItemRules(type || 'all', field).then(() => {
502
+ item.errRule = null
503
+ }).catch((errorMaps: VxeFormDefines.ValidateErrorMapParams) => {
504
+ const rest = errorMaps[field]
505
+ if (!validRest[field]) {
506
+ validRest[field] = []
507
+ }
508
+ validRest[field].push(rest)
509
+ validFields.push(field)
510
+ item.errRule = rest[0].rule
511
+ return Promise.reject(rest)
512
+ })
513
+ )
514
+ }
515
+ })
516
+ return Promise.all(itemValids).then(() => {
517
+ if (callback) {
518
+ callback()
519
+ }
520
+ }).catch(() => {
521
+ return new Promise<void>((resolve) => {
522
+ internalData.meTimeout = window.setTimeout(() => {
523
+ itemList.forEach((item) => {
524
+ if (item.errRule) {
525
+ item.showError = true
526
+ }
527
+ })
528
+ }, 20)
529
+ if (validOpts.autoPos !== false) {
530
+ $xeForm.$nextTick(() => {
531
+ $xeForm.handleFocus(validFields)
532
+ })
533
+ }
534
+ if (callback) {
535
+ callback(validRest)
536
+ resolve()
537
+ } else {
538
+ resolve(validRest)
539
+ }
540
+ })
541
+ })
542
+ }
543
+ if (callback) {
544
+ callback()
545
+ }
546
+ return Promise.resolve()
547
+ },
548
+ validate (callback: any) {
549
+ const $xeForm = this
550
+ const props = $xeForm
551
+
552
+ const { readonly } = props
553
+ $xeForm.clearValidate()
554
+ if (readonly) {
555
+ return $xeForm.$nextTick()
556
+ }
557
+ return $xeForm.beginValidate($xeForm.getItems(), '', callback)
558
+ },
559
+ validateField (fieldOrItem: VxeFormItemPropTypes.Field | VxeFormItemPropTypes.Field[] | VxeFormDefines.ItemInfo | VxeFormDefines.ItemInfo[], callback: any) {
560
+ const $xeForm = this
561
+ const props = $xeForm
562
+
563
+ const { readonly } = props
564
+ if (readonly) {
565
+ return $xeForm.$nextTick()
566
+ }
567
+ let fields: any[] = []
568
+ if (fieldOrItem) {
569
+ if (XEUtils.isArray(fieldOrItem)) {
570
+ fields = fieldOrItem
571
+ } else {
572
+ fields = [fieldOrItem]
573
+ }
574
+ }
575
+ return $xeForm.beginValidate(fields.map(field => handleFieldOrItem($xeForm, field) as VxeFormDefines.ItemInfo), '', callback)
576
+ },
577
+ submitEvent (evnt: Event) {
578
+ const $xeForm = this
579
+ const props = $xeForm
580
+
581
+ const { readonly } = props
582
+ evnt.preventDefault()
583
+ if (!props.preventSubmit) {
584
+ $xeForm.clearValidate()
585
+ if (readonly) {
586
+ $xeForm.dispatchEvent('submit', { data: props.data }, evnt)
587
+ return
588
+ }
589
+ $xeForm.beginValidate($xeForm.getItems()).then((errMap) => {
590
+ if (errMap) {
591
+ $xeForm.dispatchEvent('submit-invalid', { data: props.data, errMap }, evnt)
592
+ } else {
593
+ $xeForm.dispatchEvent('submit', { data: props.data }, evnt)
594
+ }
595
+ })
596
+ }
597
+ },
598
+ closeTooltip () {
599
+ const $xeForm = this
600
+ const internalData = $xeForm.internalData
601
+
602
+ const { tooltipStore } = internalData
603
+ const $tooltip = $xeForm.$refs.refTooltip as VxeTooltipConstructor
604
+ if (tooltipStore.visible) {
605
+ Object.assign(tooltipStore, {
606
+ item: null,
607
+ visible: false
608
+ })
609
+ if ($tooltip) {
610
+ $tooltip.close()
611
+ }
612
+ }
613
+ return $xeForm.$nextTick()
614
+ },
615
+ triggerTitleTipEvent (evnt: MouseEvent, params: {
616
+ item: VxeFormDefines.ItemInfo;
617
+ }) {
618
+ const $xeForm = this
619
+ const internalData = $xeForm.internalData
620
+
621
+ const { item } = params
622
+ const { tooltipStore } = internalData
623
+ const $tooltip = $xeForm.$refs.refTooltip as VxeTooltipConstructor
624
+ const overflowElem = (evnt.currentTarget as HTMLDivElement).children[0]
625
+ const content = (overflowElem.textContent || '').trim()
626
+ const isCellOverflow = overflowElem.scrollWidth > overflowElem.clientWidth
627
+ clearTimeout(internalData.stTimeout)
628
+ if (tooltipStore.item !== item) {
629
+ $xeForm.closeTooltip()
630
+ }
631
+ if (content && isCellOverflow) {
632
+ Object.assign(tooltipStore, {
633
+ item,
634
+ visible: true
635
+ })
636
+ if ($tooltip) {
637
+ $tooltip.open(overflowElem, content)
638
+ }
639
+ }
640
+ },
641
+ handleTitleTipLeaveEvent () {
642
+ const $xeForm = this
643
+ const internalData = $xeForm.internalData
644
+
645
+ const tooltipOpts = $xeForm.computeTooltipOpts
646
+ let $tooltip = $xeForm.$refs.refTooltip as VxeTooltipConstructor
647
+ if ($tooltip) {
648
+ $tooltip.setActived(false)
649
+ }
650
+ if (tooltipOpts.enterable) {
651
+ internalData.stTimeout = setTimeout(() => {
652
+ $tooltip = $xeForm.$refs.refTooltip as VxeTooltipConstructor
653
+ if ($tooltip && !$tooltip.isActived()) {
654
+ $xeForm.closeTooltip()
655
+ }
656
+ }, tooltipOpts.leaveDelay)
657
+ } else {
658
+ $xeForm.closeTooltip()
659
+ }
660
+ },
661
+ triggerItemEvent (evnt: Event, field: string, itemValue?: any) {
662
+ const $xeForm = this
663
+
664
+ if (field) {
665
+ return $xeForm.validItemRules(evnt ? (['blur'].includes(evnt.type) ? 'blur' : 'change') : 'all', field, itemValue)
666
+ .then(() => {
667
+ $xeForm.clearValidate(field)
668
+ })
669
+ .catch((errorMaps: VxeFormDefines.ValidateErrorMapParams) => {
670
+ const rest = errorMaps[field]
671
+ const item = $xeForm.getItemByField(field)
672
+ if (rest && item) {
673
+ item.showError = true
674
+ item.errRule = rest[0].rule
675
+ }
676
+ })
677
+ }
678
+ return $xeForm.$nextTick()
679
+ },
680
+ /**
681
+ * 更新项状态
682
+ * 如果组件值 v-model 发生 change 时,调用改函数用于更新某一项编辑状态
683
+ * 如果单元格配置了校验规则,则会进行校验
684
+ */
685
+ updateStatus (scope: any, itemValue?: any) {
686
+ const $xeForm = this
687
+
688
+ const { field } = scope
689
+ return $xeForm.triggerItemEvent(new Event('change'), field, itemValue)
690
+ },
691
+
692
+ //
693
+ // Render
694
+ //
695
+ renderVN (h: CreateElement): VNode {
696
+ const $xeForm = this
697
+ const props = $xeForm
698
+ const slots = $xeForm.$scopedSlots
699
+ const reactData = $xeForm.reactData
700
+
701
+ const { loading, className, data, customLayout } = props
702
+ const { formItems } = reactData
703
+ // const formItems: any[] = []
704
+ const vSize = $xeForm.computeSize
705
+ const tooltipOpts = $xeForm.computeTooltipOpts
706
+ const defaultSlot = slots.default
707
+ return h('form', {
708
+ ref: 'refElem',
709
+ class: ['vxe-form', className ? (XEUtils.isFunction(className) ? className({ items: formItems, data, $form: $xeForm }) : className) : '', {
710
+ [`size--${vSize}`]: vSize,
711
+ 'custom--layout': customLayout,
712
+ 'is--loading': loading
713
+ }],
714
+ on: {
715
+ submit: $xeForm.submitEvent,
716
+ reset: $xeForm.resetEvent
717
+ }
718
+ }, [
719
+ h('div', {
720
+ class: 'vxe-form--wrapper vxe-form--item-row'
721
+ }, customLayout
722
+ ? (defaultSlot ? defaultSlot({}) : [])
723
+ : formItems.map((item, index) => {
724
+ return h(VxeFormConfigItem, {
725
+ key: index,
726
+ props: {
727
+ itemConfig: item
728
+ }
729
+ })
730
+ })),
731
+ h('div', {
732
+ class: 'vxe-form-slots',
733
+ ref: 'hideItem'
734
+ }, customLayout ? [] : (defaultSlot ? defaultSlot({}) : [])),
735
+ /**
736
+ * 加载中
737
+ */
738
+ h(VxeLoadingComponent, {
739
+ class: 'vxe-form--loading',
740
+ props: {
741
+ value: loading
742
+ }
743
+ }),
744
+ /**
745
+ * 工具提示
746
+ */
747
+ h(VxeTooltipComponent, {
748
+ ref: 'refTooltip',
749
+ ...tooltipOpts
750
+ })
751
+ ])
752
+ }
753
+ },
754
+ watch: {
755
+ 'reactData.staticItems' () {
756
+ const $xeForm = this
757
+ const reactData = $xeForm.reactData
758
+
759
+ reactData.formItems = reactData.staticItems
760
+ },
761
+ items () {
762
+ const $xeForm = this
763
+ const props = $xeForm
764
+
765
+ $xeForm.loadItem(props.items || [])
766
+ },
767
+ collapseStatus (val) {
768
+ const $xeForm = this
769
+ const reactData = $xeForm.reactData
770
+
771
+ reactData.collapseAll = !!val
772
+ },
773
+ readonly () {
774
+ const $xeForm = this
775
+
776
+ $xeForm.clearValidate()
777
+ },
778
+ disabled () {
779
+ const $xeForm = this
780
+
781
+ $xeForm.clearValidate()
782
+ }
783
+ },
784
+ created () {
785
+ const $xeForm = this
786
+ const props = $xeForm
787
+ const reactData = $xeForm.reactData
788
+
789
+ reactData.collapseAll = !!props.collapseStatus
790
+ if (props.items) {
791
+ $xeForm.loadItem(props.items)
792
+ }
793
+ },
794
+ mounted () {
795
+ const $xeForm = this
796
+ const props = $xeForm
797
+
798
+ $xeForm.$nextTick(() => {
799
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
800
+ if (props.customLayout && props.items) {
801
+ errLog('vxe.error.errConflicts', ['custom-layout', 'items'])
802
+ }
803
+ }
804
+ })
805
+ },
806
+ render (this: any, h) {
807
+ return this.renderVN(h)
808
+ }
809
+ })