vue2-client 1.15.87 → 1.15.88

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 (377) hide show
  1. package/.editorconfig +9 -9
  2. package/.env +20 -20
  3. package/.env.development +1 -1
  4. package/.env.iot +19 -19
  5. package/.env.message +19 -19
  6. package/.env.revenue +19 -19
  7. package/.env.runtime +19 -19
  8. package/.eslintrc.json +5 -5
  9. package/CLAUDE.md +89 -89
  10. package/README.md +65 -65
  11. package/babel.config.js +21 -21
  12. package/docs/Logic/345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +46 -46
  13. package/docs/notice.md +22 -22
  14. package/docs//345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +179 -179
  15. package/jest.config.js +22 -22
  16. package/package.json +111 -111
  17. package/src/App.vue +196 -196
  18. package/src/ReportView.js +13 -13
  19. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +532 -532
  20. package/src/base-client/components/common/AddressSearchCombobox/index.js +3 -3
  21. package/src/base-client/components/common/AmapMarker/index.js +3 -3
  22. package/src/base-client/components/common/CitySelect/CitySelect.vue +376 -376
  23. package/src/base-client/components/common/CitySelect/demo.vue +43 -43
  24. package/src/base-client/components/common/ColorPickerCombobox/ColorPickerCombobox.vue +99 -99
  25. package/src/base-client/components/common/ColorPickerCombobox/demo.vue +34 -34
  26. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +146 -146
  27. package/src/base-client/components/common/JSONToTree/index.js +3 -3
  28. package/src/base-client/components/common/Upload/Upload.vue +323 -323
  29. package/src/base-client/components/common/XAddForm/index.js +3 -3
  30. package/src/base-client/components/common/XAddForm/index.md +61 -61
  31. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +1169 -1169
  32. package/src/base-client/components/common/XAddNativeForm/demo.vue +54 -54
  33. package/src/base-client/components/common/XAddNativeForm/index.js +3 -3
  34. package/src/base-client/components/common/XAddReport/XAddReport.vue +212 -212
  35. package/src/base-client/components/common/XBadge/index.js +3 -3
  36. package/src/base-client/components/common/XBadge/index.md +39 -39
  37. package/src/base-client/components/common/XButtons/XButtons.vue +284 -284
  38. package/src/base-client/components/common/XCalendar/XCalendar.vue +369 -369
  39. package/src/base-client/components/common/XCalendar/index.md +284 -284
  40. package/src/base-client/components/common/XCard/index.js +3 -3
  41. package/src/base-client/components/common/XCard/index.md +43 -43
  42. package/src/base-client/components/common/XCardSet/XCardSet.vue +300 -300
  43. package/src/base-client/components/common/XCollapse/XCollapse.vue +354 -354
  44. package/src/base-client/components/common/XConversation/XConversation.vue +576 -576
  45. package/src/base-client/components/common/XConversation/XConversationDemo.vue +28 -28
  46. package/src/base-client/components/common/XDataCard/XDataCard.vue +629 -629
  47. package/src/base-client/components/common/XDatePicker/index.vue +276 -276
  48. package/src/base-client/components/common/XDescriptions/XDescriptions.vue +174 -174
  49. package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +314 -314
  50. package/src/base-client/components/common/XDescriptions/demo.vue +51 -51
  51. package/src/base-client/components/common/XForm/XForm.vue +420 -420
  52. package/src/base-client/components/common/XForm/XFormItem.vue +1474 -1474
  53. package/src/base-client/components/common/XForm/XTreeSelect.vue +276 -276
  54. package/src/base-client/components/common/XForm/demo.vue +105 -105
  55. package/src/base-client/components/common/XForm/index.js +3 -3
  56. package/src/base-client/components/common/XFormCol/XFormCol.vue +157 -157
  57. package/src/base-client/components/common/XFormCol/index.js +3 -3
  58. package/src/base-client/components/common/XFormCol/index.md +35 -35
  59. package/src/base-client/components/common/XFormGroup/XFormGroup.vue +301 -301
  60. package/src/base-client/components/common/XFormGroup/demo.vue +41 -41
  61. package/src/base-client/components/common/XFormTable/XFormTable.vue +938 -938
  62. package/src/base-client/components/common/XFormTable/demo.vue +87 -87
  63. package/src/base-client/components/common/XFormTable/index.js +3 -3
  64. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +174 -174
  65. package/src/base-client/components/common/XImportExcel/index.js +3 -3
  66. package/src/base-client/components/common/XImportExcel/index.md +38 -38
  67. package/src/base-client/components/common/XInput/XInput.vue +128 -128
  68. package/src/base-client/components/common/XInput/index.js +3 -3
  69. package/src/base-client/components/common/XInput/index.md +97 -97
  70. package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +121 -121
  71. package/src/base-client/components/common/XLicensePlate/index.js +3 -3
  72. package/src/base-client/components/common/XLicensePlate/index.md +38 -38
  73. package/src/base-client/components/common/XPrint/Demo.vue +41 -41
  74. package/src/base-client/components/common/XPrint/PrintBill.vue +308 -308
  75. package/src/base-client/components/common/XRate/demo.vue +102 -102
  76. package/src/base-client/components/common/XRate/index.vue +149 -149
  77. package/src/base-client/components/common/XReport/XReport.vue +963 -963
  78. package/src/base-client/components/common/XReport/XReportDemo.vue +70 -70
  79. package/src/base-client/components/common/XReport/XReportTrGroup.vue +1005 -1005
  80. package/src/base-client/components/common/XReport/index.md +103 -103
  81. package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +201 -201
  82. package/src/base-client/components/common/XReportGrid/XReport.vue +1075 -1075
  83. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +44 -44
  84. package/src/base-client/components/common/XReportGrid/XReportDesign.vue +620 -620
  85. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +723 -723
  86. package/src/base-client/components/common/XReportGrid/print.js +184 -184
  87. package/src/base-client/components/common/XTab/XTab.vue +299 -299
  88. package/src/base-client/components/common/XTable/ExportExcel.vue +283 -283
  89. package/src/base-client/components/common/XTable/XTable.vue +1599 -1599
  90. package/src/base-client/components/common/XTable/XTableWrapper.vue +597 -597
  91. package/src/base-client/components/common/XTable/index.js +3 -3
  92. package/src/base-client/components/common/XTimeline/XTimeline.vue +358 -358
  93. package/src/base-client/components/common/XTimeline/index.md +191 -191
  94. package/src/base-client/components/common/XTree/XTreePro.vue +452 -450
  95. package/src/base-client/components/common/XTreeOne/index.js +3 -3
  96. package/src/base-client/components/common/XUploadFilesView/index.vue +485 -485
  97. package/src/base-client/components/his/XCharge/XCharge.vue +238 -238
  98. package/src/base-client/components/his/XCheckbox/XCheckbox.vue +105 -105
  99. package/src/base-client/components/his/XCheckbox/index.md +253 -253
  100. package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +430 -430
  101. package/src/base-client/components/his/XHDescriptions/index.md +217 -217
  102. package/src/base-client/components/his/XHisEditor/XHisEditor.vue +629 -629
  103. package/src/base-client/components/his/XHisEditor/diagnosisAutocomplete.js +263 -263
  104. package/src/base-client/components/his/XList/XList.vue +495 -495
  105. package/src/base-client/components/his/XQuestionnaire/XQuestionnaire.json +3 -3
  106. package/src/base-client/components/his/XQuestionnaire/XQuestionnaire.vue +106 -106
  107. package/src/base-client/components/his/XQuestionnaire/XQuestionnaireDemo.vue +51 -51
  108. package/src/base-client/components/his/XQuestionnaire/XQuestionnaireItem.vue +269 -269
  109. package/src/base-client/components/his/XRadio/XRadio.vue +125 -125
  110. package/src/base-client/components/his/XRadio/index.md +234 -234
  111. package/src/base-client/components/his/XSelect/XSelect.vue +72 -72
  112. package/src/base-client/components/his/XShiftSchedule/XShiftSchedule.vue +234 -234
  113. package/src/base-client/components/his/XShiftSchedule/dome.vue +29 -29
  114. package/src/base-client/components/his/XSidebar/XSidebar.vue +240 -240
  115. package/src/base-client/components/his/XTextCard/XTextCard.vue +207 -207
  116. package/src/base-client/components/his/XTimeSelect/XTimeSelect.vue +162 -162
  117. package/src/base-client/components/his/XTimeSelect/XTimeSelectDemo.vue +23 -23
  118. package/src/base-client/components/his/XTitle/README.md +113 -113
  119. package/src/base-client/components/his/XTitle/XTitle.vue +123 -123
  120. package/src/base-client/components/his/XTreeRows/TreeNode.vue +107 -107
  121. package/src/base-client/components/his/XTreeRows/XTreeRows.vue +307 -307
  122. package/src/base-client/components/his/threeTestOrders/dome.vue +68 -68
  123. package/src/base-client/components/his/threeTestOrders/editor.vue +111 -111
  124. package/src/base-client/components/his/threeTestOrders/textBox.vue +457 -457
  125. package/src/base-client/components/his/threeTestOrders/threeTestOrders.vue +475 -475
  126. package/src/base-client/components/layout/XPageView/RenderRow.vue +88 -88
  127. package/src/base-client/components/layout/XPageView/XErrorView.vue +22 -22
  128. package/src/base-client/components/layout/XPageView/XPageRowTemplate.vue +37 -37
  129. package/src/base-client/components/layout/XPageView/XPageView.vue +223 -223
  130. package/src/base-client/components/layout/XPageView/XTab/XTab.vue +96 -96
  131. package/src/base-client/components/layout/XPageView/XTab/index.js +3 -3
  132. package/src/base-client/components/layout/XPageView/componentTypes.js +22 -22
  133. package/src/base-client/components/layout/XPageView/index.js +2 -2
  134. package/src/base-client/components/layout/XPageView/index.md +96 -96
  135. package/src/base-client/components/system/DictionaryDetailsView/index.js +3 -3
  136. package/src/base-client/components/system/DictionaryDetailsView/index.md +41 -41
  137. package/src/base-client/components/system/LogDetailsView/LogDetailsView.vue +376 -376
  138. package/src/base-client/components/system/LogDetailsView/index.js +3 -3
  139. package/src/base-client/components/system/LogDetailsView/index.md +41 -41
  140. package/src/base-client/components/system/QueryParamsDetailsView/index.js +3 -3
  141. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +807 -807
  142. package/src/base-client/components/ticket/TicketDetailsView/index.js +3 -3
  143. package/src/base-client/components/ticket/TicketDetailsView/index.md +29 -29
  144. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
  145. package/src/base-client/components/ticket/TicketDetailsView/part/index.js +3 -3
  146. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  147. package/src/base-client/components/ticket/TicketSubmitSuccessView/index.js +3 -3
  148. package/src/base-client/components/ticket/TicketSubmitSuccessView/index.md +29 -29
  149. package/src/base-client/plugins/AppData.js +126 -126
  150. package/src/base-client/plugins/PagedList.js +177 -177
  151. package/src/base-client/plugins/__tests__/selectValueTypeHelper.test.js +154 -154
  152. package/src/base-client/plugins/authority-plugin.js +167 -167
  153. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  154. package/src/base-client/plugins/i18n-extend.js +32 -32
  155. package/src/base-client/plugins/moment.js +8 -8
  156. package/src/base-client/plugins/selectValueTypeHelper.js +281 -281
  157. package/src/bootstrap.js +51 -51
  158. package/src/components/Ellipsis/Ellipsis.vue +65 -65
  159. package/src/components/Ellipsis/index.js +3 -3
  160. package/src/components/Ellipsis/index.md +38 -38
  161. package/src/components/FileImageItem/FileItem.vue +320 -320
  162. package/src/components/FileImageItem/FileItemGroup.vue +197 -197
  163. package/src/components/FileImageItem/ImageItem.vue +107 -107
  164. package/src/components/FileImageItem/index.js +4 -4
  165. package/src/components/FilePreview/FilePreview.vue +181 -181
  166. package/src/components/FilePreview/FilePreviewDemo.vue +30 -30
  167. package/src/components/FilePreview/index.js +3 -3
  168. package/src/components/HeightScanner/index.vue +615 -615
  169. package/src/components/STable/README.md +341 -341
  170. package/src/components/STable/index.js +558 -558
  171. package/src/components/TableSetting/TableSetting.vue +143 -143
  172. package/src/components/TableSetting/index.js +3 -3
  173. package/src/components/Trend/Trend.vue +41 -41
  174. package/src/components/Trend/index.js +3 -3
  175. package/src/components/Trend/index.less +41 -41
  176. package/src/components/Trend/index.md +45 -45
  177. package/src/components/_util/util.js +46 -46
  178. package/src/components/cache/AKeepAlive.js +179 -179
  179. package/src/components/exception/typeConfig.js +19 -19
  180. package/src/components/form/FormRow.vue +52 -52
  181. package/src/components/index.less +5 -5
  182. package/src/components/menu/Contextmenu.vue +84 -84
  183. package/src/components/menu/index.less +38 -38
  184. package/src/components/page/header/PageHeader.vue +64 -64
  185. package/src/components/page/header/index.less +40 -40
  186. package/src/components/result/Result.vue +77 -77
  187. package/src/components/setting/SettingItem.vue +26 -26
  188. package/src/components/setting/i18n.js +117 -117
  189. package/src/components/table/StandardTable.vue +141 -141
  190. package/src/components/table/advance/ActionColumns.vue +158 -158
  191. package/src/components/table/advance/ActionSize.vue +45 -45
  192. package/src/components/table/advance/AdvanceTable.vue +275 -275
  193. package/src/components/table/advance/SearchArea.vue +355 -355
  194. package/src/components/table/advance/index.js +2 -2
  195. package/src/components/table/api/ApiTable.vue +50 -50
  196. package/src/components/task/TaskGroup.vue +80 -80
  197. package/src/components/task/TaskItem.vue +26 -26
  198. package/src/components/tool/AvatarList.vue +68 -68
  199. package/src/components/tool/DetailList.vue +157 -157
  200. package/src/components/tool/Drawer.vue +142 -142
  201. package/src/components/tool/FooterToolBar.vue +30 -30
  202. package/src/components/tool/HeadInfo.vue +35 -35
  203. package/src/components/tool/TagSelect.vue +83 -83
  204. package/src/components/tool/TagSelectOption.vue +33 -33
  205. package/src/components/transition/PageToggleTransition.vue +97 -97
  206. package/src/config/default/admin.config.js +18 -18
  207. package/src/config/default/animate.config.js +21 -21
  208. package/src/config/default/index.js +6 -6
  209. package/src/config/index.js +3 -3
  210. package/src/config/replacer/index.js +10 -10
  211. package/src/config/replacer/resolve.config.js +67 -67
  212. package/src/expression/ExpressionRunner.js +26 -26
  213. package/src/expression/TestExpression.js +509 -509
  214. package/src/expression/core/Delegate.js +115 -115
  215. package/src/expression/core/Expression.js +1358 -1358
  216. package/src/expression/core/Program.js +932 -932
  217. package/src/expression/core/Token.js +27 -27
  218. package/src/expression/enums/ExpressionType.js +81 -81
  219. package/src/expression/enums/TokenType.js +11 -11
  220. package/src/expression/exception/BreakWayException.js +2 -2
  221. package/src/expression/exception/ContinueWayException.js +2 -2
  222. package/src/expression/exception/ExpressionException.js +28 -28
  223. package/src/expression/exception/ReturnWayException.js +14 -14
  224. package/src/expression/exception/ServiceException.js +22 -22
  225. package/src/expression/instances/LogicConsole.js +44 -44
  226. package/src/expression/ts/ExpressionRunner.ts +28 -28
  227. package/src/expression/ts/TestExpression.ts +509 -509
  228. package/src/expression/ts/core/Delegate.ts +114 -114
  229. package/src/expression/ts/core/Expression.ts +1309 -1309
  230. package/src/expression/ts/core/Program.ts +950 -950
  231. package/src/expression/ts/core/Token.ts +29 -29
  232. package/src/expression/ts/enums/ExpressionType.ts +81 -81
  233. package/src/expression/ts/enums/TokenType.ts +13 -13
  234. package/src/expression/ts/exception/BreakWayException.ts +2 -2
  235. package/src/expression/ts/exception/ContinueWayException.ts +2 -2
  236. package/src/expression/ts/exception/ExpressionException.ts +28 -28
  237. package/src/expression/ts/exception/ReturnWayException.ts +14 -14
  238. package/src/expression/ts/exception/ServiceException.ts +22 -22
  239. package/src/expression/ts/instances/JSONArray.ts +48 -48
  240. package/src/expression/ts/instances/JSONObject.ts +109 -109
  241. package/src/expression/ts/instances/LogicConsole.ts +32 -32
  242. package/src/layouts/AdminLayout.vue +176 -176
  243. package/src/layouts/BlankView.vue +79 -79
  244. package/src/layouts/ComponentLayoutOne.vue +47 -47
  245. package/src/layouts/GridView.vue +43 -43
  246. package/src/layouts/PageView.vue +55 -55
  247. package/src/layouts/footer/PageFooter.vue +49 -49
  248. package/src/layouts/header/HeaderAvatar.vue +64 -64
  249. package/src/layouts/header/HeaderSearch.vue +67 -67
  250. package/src/layouts/header/index.less +92 -92
  251. package/src/layouts/tabs/TabsView.vue +383 -383
  252. package/src/layouts/tabs/i18n.js +25 -25
  253. package/src/layouts/tabs/index.js +2 -2
  254. package/src/logic/LogicRunner.js +62 -62
  255. package/src/logic/TestLogic.js +13 -13
  256. package/src/logic/plugins/common/DateTools.js +35 -35
  257. package/src/logic/plugins/common/VueTools.js +30 -30
  258. package/src/logic/plugins/index.js +7 -7
  259. package/src/logic/ts/LogicRunner.ts +67 -67
  260. package/src/logic/ts/TestLogic.ts +13 -13
  261. package/src/main.js +33 -33
  262. package/src/mixins/formValidationMixin.js +46 -46
  263. package/src/mock/common/activityData.js +32 -32
  264. package/src/mock/common/index.js +89 -89
  265. package/src/mock/common/reportData.js +20 -20
  266. package/src/mock/common/tableData.js +118 -118
  267. package/src/mock/index.js +12 -12
  268. package/src/mock/project/index.js +17 -17
  269. package/src/mock/user/current.js +13 -13
  270. package/src/mock/user/login.js +39 -39
  271. package/src/mock/user/routes.js +61 -61
  272. package/src/mock/workplace/index.js +15 -15
  273. package/src/pages/LogicCallExample/index.vue +46 -46
  274. package/src/pages/ReportGrid/index.vue +76 -76
  275. package/src/pages/ReportView.vue +50 -50
  276. package/src/pages/WorkflowDetail/WorkFlowDemo.vue +47 -47
  277. package/src/pages/WorkflowDetail/WorkFlowDemo2.vue +204 -204
  278. package/src/pages/WorkflowDetail/WorkFlowDemo3.vue +203 -203
  279. package/src/pages/WorkflowDetail/WorkflowDetail.vue +391 -391
  280. package/src/pages/WorkflowDetail/WorkflowPageDetail/LeaveMessage.vue +388 -388
  281. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformation.vue +415 -415
  282. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +1766 -1766
  283. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandleReso.vue +975 -975
  284. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowPreview.vue +109 -109
  285. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +929 -929
  286. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkOrderParentDetails.vue +222 -222
  287. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowDetailResso.vue +243 -243
  288. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowLog.vue +188 -188
  289. package/src/pages/WorkflowDetail/WorkflowPageDetail/components/WorkflowPersonSelector.vue +109 -109
  290. package/src/pages/WorkflowDetail/WorkflowPageDetail/worklog.vue +97 -97
  291. package/src/pages/XPageViewExample/index.vue +149 -149
  292. package/src/pages/addressSelect/addressDemo.vue +24 -24
  293. package/src/pages/addressSelect/index.vue +270 -270
  294. package/src/pages/dashboard/workplace/i18n.js +40 -40
  295. package/src/pages/dashboard/workplace/index.js +2 -2
  296. package/src/pages/dashboard/workplace/index.less +59 -59
  297. package/src/pages/exception/403.vue +21 -21
  298. package/src/pages/exception/404.vue +24 -24
  299. package/src/pages/exception/500.vue +21 -21
  300. package/src/pages/login/index.js +2 -2
  301. package/src/pages/report/ReportTableHome.vue +28 -28
  302. package/src/pages/resourceManage/depListManage.vue +23 -23
  303. package/src/pages/resourceManage/funListManage.vue +23 -23
  304. package/src/pages/resourceManage/index.js +15 -15
  305. package/src/pages/resourceManage/resourceManageMain.vue +57 -57
  306. package/src/pages/resourceManage/roleListManage.vue +23 -23
  307. package/src/pages/resourceManage/staffListManage.vue +23 -23
  308. package/src/pages/system/file/Info.vue +56 -56
  309. package/src/pages/system/file/index.vue +317 -317
  310. package/src/pages/system/settings/index.vue +126 -126
  311. package/src/pages/userInfoDetailManage/FillCardRecordQuery/index.vue +77 -77
  312. package/src/pages/userInfoDetailManage/FillGasRecordQuery/index.vue +75 -75
  313. package/src/pages/userInfoDetailManage/InsuranceDetailQuery/index.vue +64 -64
  314. package/src/pages/userInfoDetailManage/MachineRecordQuery/index.vue +75 -75
  315. package/src/pages/userInfoDetailManage/OtherChargeRecordQuery/index.vue +75 -75
  316. package/src/pages/userInfoDetailManage/PriceAdjustments/index.vue +64 -64
  317. package/src/pages/userInfoDetailManage/UserChargeRecordQuery/index.vue +94 -94
  318. package/src/pages/userInfoDetailManage/UserException/index.vue +64 -64
  319. package/src/pages/userInfoDetailManage/UserHandRecordQuery/index.vue +87 -87
  320. package/src/pages/userInfoDetailManage/UserRecordQuery/index.vue +74 -74
  321. package/src/pages/userInfoDetailManage/index.vue +290 -290
  322. package/src/pages/userInfoDetailManage/uploadFilesHistory/ImagePreview.vue +101 -101
  323. package/src/pages/userInfoDetailManage/uploadFilesHistory/index.vue +129 -129
  324. package/src/pages/userInfoDetailManage/userInfoDetailQueryTabs.vue +144 -144
  325. package/src/plugins/HiPrintPlugin.js +164 -164
  326. package/src/router/async/router.map.js +126 -126
  327. package/src/router/guards.js +262 -262
  328. package/src/router/i18n.js +57 -57
  329. package/src/router.js +17 -17
  330. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  331. package/src/services/api/LogDetailsViewApi.js +10 -10
  332. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  333. package/src/services/api/logininfor/index.js +6 -6
  334. package/src/services/api/manage.js +8 -8
  335. package/src/services/api/restTools.js +215 -215
  336. package/src/services/api/workFlow.js +57 -57
  337. package/src/services/apiService.js +16 -16
  338. package/src/services/dataSource.js +12 -12
  339. package/src/services/index.js +7 -7
  340. package/src/services/user.js +92 -92
  341. package/src/services/v3Api.js +116 -116
  342. package/src/store/index.js +5 -5
  343. package/src/store/mutation-types.js +4 -4
  344. package/src/theme/antd/ant-menu.less +2 -2
  345. package/src/theme/antd/ant-message.less +3 -3
  346. package/src/theme/antd/ant-table.less +22 -22
  347. package/src/theme/antd/ant-time-picker.less +3 -3
  348. package/src/theme/antd/index.less +3 -3
  349. package/src/theme/default/color.less +43 -43
  350. package/src/theme/default/index.less +3 -3
  351. package/src/theme/default/nprogress.less +76 -76
  352. package/src/theme/global.less +279 -279
  353. package/src/theme/index.less +5 -5
  354. package/src/theme/reportTable.less +58 -58
  355. package/src/theme/theme.less +1 -1
  356. package/src/utils/EncryptUtil.js +162 -162
  357. package/src/utils/Objects.js +25 -25
  358. package/src/utils/axios-interceptors.js +100 -100
  359. package/src/utils/colors.js +107 -107
  360. package/src/utils/common.js +10 -10
  361. package/src/utils/excel/Blob.js +180 -180
  362. package/src/utils/excel/Export2Excel.js +141 -141
  363. package/src/utils/filter.js +21 -21
  364. package/src/utils/i18n.js +80 -80
  365. package/src/utils/indexedDB.js +549 -549
  366. package/src/utils/microAppUtils.js +49 -49
  367. package/src/utils/request.js +395 -395
  368. package/src/utils/routerUtil.js +553 -553
  369. package/src/utils/themeUtil.js +100 -100
  370. package/test/Tree.spec.js +168 -168
  371. package/test/myDialog.spec.js +47 -47
  372. package/test/request.test.js +17 -17
  373. package/test/util.test.js +53 -53
  374. package/test/v3Api.test.js +1984 -1984
  375. package/tests/unit/ReportTable.spec.js +16 -16
  376. package/vue.config.js +222 -222
  377. package/.claude/settings.local.json +0 -12
@@ -1,1169 +1,1169 @@
1
- <template>
2
- <div id="XAddNativeForm">
3
- <a-form-model
4
- v-if="loaded"
5
- ref="selectForm"
6
- :zIndex="1001"
7
- :model="form"
8
- v-bind="formItemLayoutGen"
9
- :layout="layout">
10
- <template v-for="(item, key) in childTableData">
11
- <a-row
12
- v-if="childTablePriority"
13
- :gutter="16"
14
- :key="'childTableRow' + key">
15
- <a-card :title="item.name" :bordered="false" size="small">
16
- <x-form-table
17
- :key="'childTable_' + item.model"
18
- :title="item.name"
19
- :queryParamsName="item.childTableConfigName"
20
- :localEditMode="true"
21
- :fixed-query-form="childTableFixedQueryForm(item)"
22
- :service-name="serviceName"
23
- @innerXFormTableEmit="innerXFormTableEmit"
24
- @afterTableInit="childTableMounted(item)"
25
- :ref="'childXFormTable_' + item.model">
26
- </x-form-table>
27
- </a-card>
28
- </a-row>
29
- </template>
30
- <a-row ref="GroupItemRow">
31
- <a-col :span="3" v-if="!inXFormGroup && !(groups[0].groupName === DEFAULT_GROUP_NAME)">
32
- <a-tabs tab-position="left" v-model="activeTab" @change="scrollToGroup">
33
- <a-tab-pane
34
- v-for="(groupsItem,groupsIndex) in groups"
35
- :tab="groupsItem.groupName"
36
- :key="groupsIndex">
37
- </a-tab-pane>
38
- </a-tabs>
39
- </a-col>
40
- <a-col
41
- :span="(!inXFormGroup && !(groups[0].groupName === DEFAULT_GROUP_NAME)) ? 21: 24">
42
- <a-row
43
- :gutter="16"
44
- type="flex"
45
- :key="groupsIndex"
46
- v-for="(groupsItem,groupsIndex) in groups"
47
- >
48
- <a-col
49
- :span="24"
50
- :style="{ marginTop: groupsIndex === 0 ? '' : '8px',fontSize:inXFormGroup?'15px':'14px', marginLeft:'-5px' }"
51
- v-if="groupsItem.groupName !== DEFAULT_GROUP_NAME">
52
- <span class="xFormGroupTitle" :ref="`group-title-${groupsIndex}`">{{ groupsItem.groupName }}</span>
53
- </a-col>
54
- <x-form-item
55
- v-for="(item, index) in groupsItem.realJsonData"
56
- :key="index"
57
- :attr="item"
58
- :disabled="itemDisabled(item)"
59
- :read-only="readonly(item)"
60
- :files="files"
61
- v-bind="formItemLayoutGen"
62
- :style="layout === 'inline' ? { marginTop:'5px' } : undefined"
63
- :form="form"
64
- :images="images"
65
- :service-name="serviceName"
66
- mode="新增/修改"
67
- :layout="layout"
68
- :rules="rules[`${item.name}${item.model}`]"
69
- :get-data-params="getDataParams"
70
- :env="env"
71
- @x-form-item-emit-func="emitFunc"
72
- @rowChoose="rowChoose"
73
- :setForm="setForm"
74
- />
75
- </a-row>
76
- </a-col>
77
- </a-row>
78
- <a-row :gutter="16" v-for="(groupItem, groupIndex) in groupJsonData" :key="groupIndex">
79
- <a-card v-if="groupItem.groupItems.length > 0" :title="groupItem.name" :bordered="false" size="small">
80
- <x-form-item
81
- v-for="(item, index) in groupItem.groupItems"
82
- :key="index"
83
- :attr="item"
84
- :disabled="itemDisabled(item)"
85
- :readonly="readonly(item)"
86
- :files="files"
87
- v-bind="formItemLayoutGen"
88
- :style="layout ==='inline'?{marginTop:'5px'}:undefined"
89
- :form="form[groupItem.model]"
90
- :images="images"
91
- :service-name="serviceName"
92
- mode="新增/修改"
93
- :rules="rules[`${item.name}${item.model}`]"
94
- :get-data-params="getDataParams"
95
- :env="env"
96
- :setForm="setForm"
97
- @rowChoose="rowChoose"
98
- />
99
- </a-card>
100
- <template v-else>
101
- <slot
102
- name="groupFormItems"
103
- :form="form"
104
- :model="groupItem.model"
105
- :rules="rules"
106
- :modifyModelData="modifyModelData"></slot>
107
- </template>
108
- </a-row>
109
- <a-row :gutter="16" v-for="(item, key) in simpleFormJsonData" :key="'row' + key">
110
- <a-card v-if="item.value.length > 0" :title="item.name" :bordered="false" size="small">
111
- <x-form-item
112
- v-for="(formItem, formItemIndex) in item.value"
113
- :key="key + formItemIndex"
114
- :attr="formItem"
115
- :disabled="itemDisabled(formItem)"
116
- :readonly="readonly(formItem)"
117
- :files="files"
118
- v-bind="formItemLayoutGen"
119
- :style="layout ==='inline'?{marginTop:'5px'}:undefined"
120
- :form="form[groupItem.model]"
121
- :images="images"
122
- :service-name="serviceName"
123
- mode="新增/修改"
124
- :rules="rules[`${item.name}${item.model}`]"
125
- :get-data-params="getDataParams"
126
- :env="env"
127
- :setForm="setForm"
128
- @rowChoose="rowChoose"
129
- />
130
- </a-card>
131
- </a-row>
132
- <template v-for="(item, key) in childTableData">
133
- <a-row
134
- v-if="!childTablePriority"
135
- :gutter="16"
136
- :key="'childTableRow' + key">
137
- <a-card :title="item.name" :bordered="false" size="small">
138
- <x-form-table
139
- :key="'childTable_' + item.model"
140
- :title="item.name"
141
- :queryParamsName="item.childTableConfigName"
142
- :localEditMode="true"
143
- @innerXFormTableEmit="innerXFormTableEmit"
144
- :fixed-query-form="childTableFixedQueryForm(item)"
145
- :service-name="serviceName"
146
- @afterTableInit="childTableMounted(item)"
147
- :ref="'childXFormTable_' + item.model">
148
- </x-form-table>
149
- </a-card>
150
- </a-row>
151
- </template>
152
- <a-row type="flex" :justify="btnPlace" :style="{paddingLeft: '16px',paddingRight: '16px'}">
153
- <slot name="footer" :loading="loading">
154
- <a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">{{ btnName }}</a-button>
155
- </slot>
156
- </a-row>
157
- </a-form-model>
158
- </div>
159
- </template>
160
- <script>
161
- import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
162
- import { formatDate, setDataByRealKey } from '@vue2-client/utils/util'
163
- import * as util from '@vue2-client/utils/util'
164
- import { mapState } from 'vuex'
165
- import { addOrModify, getConfigByName, getConfigByNameAsync, runLogic } from '@vue2-client/services/api/common'
166
- import { checkIdNumber, REG_EMAIL, REG_LANDLINE, REG_PHONE } from '@vue2-client/utils/reg'
167
- import moment from 'moment/moment'
168
- import { executeStrFunction, executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
169
- import formValidationMixin from '@vue2-client/mixins/formValidationMixin'
170
-
171
- const DEFAULT_GROUP_NAME = '__default__'
172
- export default {
173
- name: 'XAddNativeForm',
174
- components: {
175
- XFormItem,
176
- XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue')
177
- },
178
- inject: {
179
- inXFormGroup: {
180
- default: false
181
- },
182
- formGroupContext: {
183
- default: null
184
- },
185
- formDataChange: {
186
- default: null
187
- }
188
- },
189
- props: {},
190
- data () {
191
- return {
192
- DEFAULT_GROUP_NAME,
193
- // 预览模式
194
- viewMode: false,
195
- // 是否处理表单Key值
196
- isHandleFormKey: true,
197
- // 内容加载是否完成
198
- loaded: false,
199
- // 业务类型
200
- businessType: '',
201
- // 业务标题
202
- title: '',
203
- // 新增或修改业务是否执行中
204
- loading: false,
205
- // 表单Model
206
- form: {},
207
- // 配置名称
208
- configName: undefined,
209
- // 配置内容,用于查询配置生成器的预览
210
- configContent: undefined,
211
- // 表单项集合
212
- formItems: [],
213
- // 服务名称
214
- serviceName: undefined,
215
- // 是否显示提交按钮
216
- showSubmitBtn: true,
217
- // 修改有文件的表单时使用
218
- files: [],
219
- images: [],
220
- // 校验
221
- rules: {},
222
- // 调用logic获取数据源的追加参数
223
- getDataParams: {},
224
- // 动态简易表单集合
225
- simpleFormJsonData: {},
226
- // 待修改的数据集
227
- modifyModelData: {},
228
- // 当前环境
229
- env: 'prod',
230
- // 表单主键
231
- primaryKey: null,
232
- // 表单模式 horizontal | vertical | inline
233
- layout: 'horizontal',
234
- // 提交按钮名称
235
- btnName: '提交',
236
- // 提交按钮位置 start / center / end
237
- btnPlace: 'center',
238
- // 子表是否排在前面
239
- childTablePriority: false
240
- }
241
- },
242
- computed: {
243
- // 过滤出用于新增/修改场景的表单项
244
- realJsonData: function () {
245
- return this.formItems.filter((item) => {
246
- return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
247
- })
248
- },
249
- // 表单项组 / 不是 数据组
250
- groups: function () {
251
- if (!this.realJsonData || this.realJsonData.length === 0) {
252
- return [{
253
- groupName: DEFAULT_GROUP_NAME,
254
- realJsonData: this.realJsonData,
255
- xAddFormLayout: 'horizontal'
256
- }]
257
- }
258
- const uniqueGroups = new Set(this.realJsonData.map(item => item.group).filter(Boolean))
259
- const allGroup = Array.from(uniqueGroups).map(group => {
260
- return {
261
- groupName: group,
262
- realJsonData: this.realJsonData.filter(item => item.group === group),
263
- xAddFormLayout: 'horizontal'
264
- }
265
- })
266
- // 判断每一组得formJson 长度相加是否等于 realJsonData 长度 避免错误数据
267
- if (allGroup.reduce((total, item) => total + item.realJsonData.length, 0) === this.realJsonData.length) {
268
- return allGroup
269
- } else {
270
- return [{
271
- groupName: DEFAULT_GROUP_NAME,
272
- realJsonData: this.realJsonData,
273
- xAddFormLayout: 'horizontal'
274
- }]
275
- }
276
- },
277
- // 拥有自定义校验函数得表单项
278
- customValidateItems: function () {
279
- return this.formItems.filter((item) => {
280
- return item?.rule?.type === 'customJs'
281
- })
282
- },
283
- // 过滤出用于新增/修改场景的表单项
284
- groupJsonData: function () {
285
- return this.formItems.filter((item) => {
286
- return item.type === 'group'
287
- }).map((item) => {
288
- item.groupItems = item.groupItems.filter((item) => {
289
- return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
290
- }).map((groupItem) => {
291
- // 只保留第一个下划线后面的内容
292
- // 多层校验规则需要将prop设置为 key1.key2.....
293
- groupItem.prop = `${item.model}.${groupItem.model.substring(groupItem.model.indexOf('_') + 1)}`
294
- groupItem.model = groupItem.model.substring(groupItem.model.indexOf('_') + 1)
295
- return groupItem
296
- })
297
- return item
298
- }
299
- )
300
- },
301
- // 过滤出用于子表数据新增/修改场景的表单项
302
- childTableData: function () {
303
- return this.formItems.filter((item) => {
304
- return item.type === 'childTable'
305
- })
306
- },
307
- // 过滤出用于form子表数据新增/修改场景的表单项
308
- childFormData: function () {
309
- return this.formItems.filter((item) => {
310
- return item.type === 'rowEdit'
311
- })
312
- },
313
- // 过滤出用于静默新增场景的表单项
314
- silenceAddJsonData: function () {
315
- return this.formItems.filter(function (item) {
316
- return item.addOrEdit === 'silenceAdd'
317
- })
318
- },
319
- // 过滤出版本号表单项
320
- versionJsonData: function () {
321
- return this.formItems.filter(function (item) {
322
- return item.addOrEdit === 'version'
323
- })
324
- },
325
- formItemLayoutGen () {
326
- if (this.layout === 'horizontal') {
327
- return {
328
- labelCol: { span: 4, offset: 2 },
329
- wrapperCol: { span: 14 },
330
- }
331
- } else if (this.layout === 'vertical') {
332
- return {}
333
- } else {
334
- if (!this.formItemLayout.labelCol || !this.formItemLayout.wrapperCol) {
335
- return {
336
- labelCol: { span: 8 },
337
- wrapperCol: { span: 16 },
338
- }
339
- }
340
- return {
341
- labelCol: { span: this.formItemLayout.labelCol },
342
- wrapperCol: { span: this.formItemLayout.wrapperCol },
343
- }
344
- }
345
- },
346
- ...mapState('account', { currUser: 'user' })
347
- },
348
- provide () {
349
- return {
350
- getComponentByName: this.getComponentByName,
351
- registerComponent: this.registerComponent,
352
- XFormContext: this,
353
- // 移除必填项
354
- removeRequired: this.removeRequired,
355
- // 设置必填项
356
- setRequired: this.setRequired,
357
- getSelf: () => this,
358
- }
359
- },
360
- watch: {
361
- form: {
362
- handler (val) {
363
- if (this.formDataChange && typeof this.formDataChange === 'function') {
364
- this.formDataChange(val)
365
- }
366
- },
367
- deep: true
368
- }
369
- },
370
- /** //todo 本来想要实现 配置 自定义函数时,表单项得红星提示,根据自定义校验函数得返回值来判断
371
- * 但是监听不到父组件formgorup得其他form得变化,所以暂时不实现
372
- */
373
- //
374
- // watch: {
375
- // form: {
376
- // handler (val) {
377
- // // 遍历表单配置
378
- // if (this.customValidateItems.length > 0) {
379
- // for (const item of this.customValidateItems) {
380
- // const itemIndex = this.formItems.findIndex(formItem => formItem.model === item.model)
381
- // if (itemIndex < 0) {
382
- // continue
383
- // }
384
- // try {
385
- // this.customJsValidate(null, val[item.model], (res) => {
386
- // // 如果返回error则设置错误信息
387
- // if (res instanceof Error) {
388
- // // 设置表单项的错误状态
389
- // this.$set(this.formItems[itemIndex], 'tempRequired', true)
390
- // } else {
391
- // // 清除错误状态
392
- // this.$set(this.formItems[itemIndex], 'tempRequired', true)
393
- // }
394
- // }, item)
395
- // } catch (e) {
396
- // console.error(e)
397
- // this.$set(this.formItems[itemIndex], 'tempRequired', true)
398
- // }
399
- // }
400
- // console.log('customValidateItems', JSON.stringify(this.customValidateItems))
401
- // }
402
- // },
403
- // deep: true
404
- // }
405
- // },
406
- mixins: [formValidationMixin],
407
- methods: {
408
- runLogic,
409
- getConfigByNameAsync,
410
- getConfigByName,
411
- init (params) {
412
- const {
413
- configName,
414
- configContent,
415
- formItems,
416
- formJson,
417
- viewMode,
418
- isHandleFormKey,
419
- isKeyHandle = true,
420
- showSubmitBtn = true,
421
- serviceName,
422
- primaryKey,
423
- modifyModelData = {},
424
- businessType,
425
- title,
426
- fixedAddForm = {},
427
- getDataParams = {},
428
- simpleFormJsonData = {},
429
- env = 'prod',
430
- layout,
431
- xAddFormLayout = 'horizontal',
432
- formItemLayout = {},
433
- btnName = '提交',
434
- childTablePriority = false,
435
- btnPlace = 'center'
436
- } = params
437
- this.loaded = false
438
- // 兼容需要省略 传递 layout: res.xAddFormLayout 可以使用 ...res 展开运算符 直接转递
439
- if (xAddFormLayout && layout === undefined) {
440
- this.layout = xAddFormLayout
441
- } else {
442
- this.layout = layout
443
- }
444
- this.formItemLayout = formItemLayout
445
- if ((isHandleFormKey === null || isHandleFormKey === undefined) && !isKeyHandle) {
446
- this.isHandleFormKey = isKeyHandle
447
- } else if (isHandleFormKey) {
448
- this.isHandleFormKey = isHandleFormKey
449
- } else {
450
- this.isHandleFormKey = isKeyHandle
451
- }
452
- this.childTablePriority = childTablePriority
453
- this.configName = configName
454
- this.configContent = configContent
455
- this.formItems = this.getFromItem(formItems, formJson)
456
- this.viewMode = viewMode
457
- this.showSubmitBtn = showSubmitBtn
458
- this.primaryKey = primaryKey
459
- this.serviceName = serviceName
460
- this.businessType = businessType
461
- this.title = title
462
- this.getDataParams = getDataParams
463
- this.simpleFormJsonData = simpleFormJsonData
464
- this.env = env
465
- this.btnName = btnName
466
- this.btnPlace = btnPlace
467
- // 如果 fixedAddForm 有 selected_id 值,并且设置了处理表单key值,则多给 selected_id 加前缀 避免处理错误
468
- if (fixedAddForm.selected_id && this.isHandleFormKey) {
469
- fixedAddForm._selected_id = fixedAddForm.selected_id
470
- delete fixedAddForm.selected_id
471
- }
472
- // 设置普通表单项的相关参数
473
- const formData = Object.assign({}, fixedAddForm)
474
- for (let i = 0; i < this.realJsonData.length; i++) {
475
- const item = this.realJsonData[i]
476
- this.setFormProps(formData, item, null)
477
- }
478
- // 设置表单分组项目相关参数
479
- for (let i = 0; i < this.groupJsonData.length; i++) {
480
- const groupItem = this.groupJsonData[i]
481
- formData[groupItem.model] = {}
482
- for (let j = 0; j < groupItem.groupItems.length; j++) {
483
- const item = groupItem.groupItems[j]
484
- this.setFormProps(formData[groupItem.model], item, item.prop)
485
- }
486
- }
487
- // 设置动态简易表单项的相关参数
488
- for (const key in this.simpleFormJsonData) {
489
- for (const item of this.simpleFormJsonData[key].value) {
490
- item.model = key + '@' + item.model
491
- this.setFormProps(formData, item, null)
492
- }
493
- }
494
-
495
- this.form = formData
496
- // 修改场景下对表单项赋值
497
- if (modifyModelData && modifyModelData.data) {
498
- this.modifyModelData = modifyModelData
499
- if (Object.keys(modifyModelData.data).length > 0) {
500
- this.getModifyModelData(modifyModelData)
501
- }
502
- }
503
- // 处理表单得附件
504
- if (modifyModelData && modifyModelData.files) {
505
- this.files = modifyModelData.files
506
- }
507
- if (modifyModelData && modifyModelData.images) {
508
- this.images = modifyModelData.images
509
- }
510
- this.loaded = true
511
- },
512
- scrollToGroup (index) {
513
- const groupElement = this.$refs[`group-title-${index}`][0]
514
- if (groupElement) {
515
- groupElement.scrollIntoView({ behavior: 'smooth' })
516
- }
517
- },
518
- registerComponent (componentName, component) {
519
- console.log('内部注册', this.$options.name, componentName)
520
- this.$refs[componentName] = component
521
- console.log('内部注册完成', this.$refs)
522
- },
523
- // 根据名字从注册到组件中获取组件
524
- getComponentByName (componentName) {
525
- console.log('内部取组件', this.$options.name, componentName)
526
- console.log('内部组件内容', this.$refs)
527
- return this.$refs[componentName]
528
- },
529
- // 兼容需要省略 传递 [formItems: res.formJson ] 可以使用 ...res 展开运算符 直接转递
530
- getFromItem (formItems, formJson) {
531
- const _formItems = formItems || formJson
532
- if (typeof formItems === 'string') {
533
- return JSON.parse(_formItems)
534
- } else {
535
- return JSON.parse(JSON.stringify(_formItems))
536
- }
537
- },
538
- innerXFormTableEmit (fun, record, id, actionType, index) {
539
- this.$emit(fun, record, id, actionType, index)
540
- },
541
- // 时间组件赋默认值
542
- // .type, item.formDefault
543
- getDateRange ({ type, formDefault: defaultValue, formValueFormat }) {
544
- // const format = type === 'datePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
545
- let format = 'YYYY-MM-DD HH:mm:ss'
546
- if (formValueFormat) {
547
- format = formValueFormat
548
- }
549
- let start
550
- switch (defaultValue) {
551
- case 'curYear':
552
- start = moment().startOf('year').format(format)
553
- break
554
- case 'curMonth':
555
- start = moment().startOf('month').format(format)
556
- break
557
- case 'curDay':
558
- start = moment().startOf('day').format(format)
559
- break
560
- case 'curTime':
561
- start = moment().format(format)
562
- break
563
- default:
564
- return defaultValue
565
- }
566
- return start
567
- },
568
- setFormProps (formData, item, groupItem) {
569
- const rulesKey = `${item.name}${item.model}`
570
- if (formData[item.model] === undefined || formData[item.model] === null) {
571
- formData[item.model] = undefined
572
- }
573
- if (!formData[item.model] && item.formDefault) {
574
- if (['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(item.type)) {
575
- formData[item.model] = this.getDateRange(item)
576
- } else if (['treeSelect', 'select', 'checkbox'].includes(item.type) && ['curOrgId', 'curDepId', 'curUserId'].includes(item.formDefault)) {
577
- if (item.formDefault === 'curOrgId') {
578
- formData[item.model] = item.type === 'select' ? this.currUser.orgid : [this.currUser.orgid]
579
- }
580
- if (item.formDefault === 'curDepId') {
581
- formData[item.model] = item.type === 'select' ? this.currUser.depids : [this.currUser.depids]
582
- }
583
- if (item.formDefault === 'curUserId') {
584
- formData[item.model] = item.type === 'select' ? this.currUser.id : [this.currUser.id]
585
- }
586
- } else {
587
- formData[item.model] = item.formDefault
588
- }
589
- }
590
- // 处理表单校验情况
591
- if (item.rule) {
592
- if (groupItem) {
593
- this.rules[groupItem] = []
594
- } else {
595
- this.rules[rulesKey] = []
596
- }
597
- const required = item.rule.required ? item.rule.required === true || item.rule.required === 'true' : false
598
- let trigger
599
- let message
600
- if (required) {
601
- switch (item.type) {
602
- case 'select':
603
- case 'checkbox':
604
- case 'radio':
605
- case 'treeSelect':
606
- case 'rangePicker':
607
- case 'monthPicker':
608
- case 'yearPicker':
609
- case 'datePicker':
610
- case 'file':
611
- case 'image':
612
- case 'citySelect':
613
- case 'addressSearch':
614
- case 'personSetting':
615
- message = '请选择' + item.name
616
- trigger = 'change'
617
- break
618
- default:
619
- message = '请输入' + item.name
620
- trigger = 'blur'
621
- }
622
- if (groupItem) {
623
- this.rules[groupItem].push({
624
- required: true,
625
- message: message,
626
- trigger: trigger
627
- })
628
- } else {
629
- this.rules[rulesKey].push({
630
- required: true,
631
- message: message,
632
- trigger: trigger
633
- })
634
- }
635
- }
636
-
637
- switch (item.rule.type) {
638
- case 'number':
639
- case 'integer':
640
- case 'float':
641
- // eslint-disable-next-line no-case-declarations
642
- let defaultValue
643
- // eslint-disable-next-line no-case-declarations
644
- let message
645
- switch (item.rule.type) {
646
- case 'number':
647
- item.numberInput = true
648
- message = '数字'
649
- defaultValue = 0
650
- break
651
- case 'integer':
652
- item.numberInput = true
653
- message = '整数'
654
- defaultValue = 0
655
- break
656
- case 'float':
657
- item.numberInput = true
658
- message = '小数'
659
- defaultValue = 0.0
660
- break
661
- }
662
- if (groupItem) {
663
- this.rules[groupItem].push({
664
- type: item.rule.type,
665
- message: item.name + '必须为' + message,
666
- transform: (value) => {
667
- if (value && value.length !== 0) {
668
- return Number(value)
669
- } else {
670
- return defaultValue
671
- }
672
- },
673
- trigger: 'blur'
674
- })
675
- } else {
676
- this.rules[rulesKey].push({
677
- type: item.rule.type,
678
- message: item.name + '必须为' + message,
679
- transform: (value) => {
680
- if (value && value.length !== 0) {
681
- return Number(value)
682
- } else {
683
- return defaultValue
684
- }
685
- },
686
- trigger: 'blur'
687
- })
688
- }
689
- break
690
- case 'email': {
691
- const validator = (rule, value, callback) => {
692
- if (value && !REG_EMAIL.test(value)) {
693
- callback(new Error('请输入正确的邮箱地址'))
694
- } else {
695
- callback()
696
- }
697
- }
698
- this.rules[groupItem || rulesKey].push({
699
- type: 'email',
700
- validator: validator,
701
- message: '请输入正确的邮箱地址',
702
- trigger: 'blur'
703
- })
704
- break
705
- }
706
- case 'userPhone': {
707
- this.rules[groupItem || rulesKey].push({
708
- type: 'userPhone',
709
- validator: (rule, value, callback) => {
710
- if (value && !REG_PHONE.test(value)) {
711
- callback(new Error('请输入正确的手机号码'))
712
- } else {
713
- callback()
714
- }
715
- },
716
- message: '请输入正确的手机号码',
717
- trigger: 'blur'
718
- })
719
- break
720
- }
721
- case 'idNumber': {
722
- this.rules[groupItem || rulesKey].push({
723
- validator: (rule, value, callback) => {
724
- if (value && !checkIdNumber(value)) {
725
- callback(new Error('请输入正确的身份证号码'))
726
- } else {
727
- callback()
728
- }
729
- },
730
- trigger: 'blur'
731
- })
732
- break
733
- }
734
- case 'landlineNumber': {
735
- this.rules[rulesKey].push({
736
- validator: (rule, value, callback) => {
737
- if (value && !REG_LANDLINE.test(value)) {
738
- callback(new Error('请输入正确的座机号码'))
739
- } else {
740
- callback()
741
- }
742
- },
743
- trigger: 'blur'
744
- })
745
- break
746
- }
747
- // 大于0
748
- case 'greaterThanZero': {
749
- item.numberInput = true
750
- this.rules[rulesKey].push({
751
- validator: (rule, value, callback) => {
752
- if (isNaN(value) || value <= 0) {
753
- callback(new Error('请输入一个大于0的数字'))
754
- } else {
755
- callback()
756
- }
757
- },
758
- trigger: 'blur'
759
- })
760
- break
761
- }
762
- // 大于等于0
763
- case 'greaterThanOrEqualZero': {
764
- item.numberInput = true
765
- this.rules[rulesKey].push({
766
- validator: (rule, value, callback) => {
767
- if (isNaN(value) || value < 0) {
768
- callback(new Error('请输入一个大于等于0的数字'))
769
- } else {
770
- callback()
771
- }
772
- },
773
- trigger: 'blur'
774
- })
775
- break
776
- }
777
- case 'stringLength': {
778
- this.rules[rulesKey].push({
779
- validator: (rule, value, callback) => {
780
- if (value && value.length < item.rule.minLen) {
781
- callback(new Error('长度不能少于' + item.rule.minLen + '个字符'))
782
- } else if (value && value.length > item.rule.maxLen) {
783
- callback(new Error('长度不能超过' + item.rule.maxLen + '个字符'))
784
- } else {
785
- callback()
786
- }
787
- },
788
- trigger: 'blur'
789
- })
790
- break
791
- }
792
- case 'customJs': {
793
- this.rules[rulesKey].push({
794
- validator: (rule, value, callback) => {
795
- this.customJsValidate(rule, value, callback, item)
796
- },
797
- trigger: 'blur'
798
- })
799
- break
800
- }
801
- }
802
- }
803
- },
804
- childTableMounted (item) {
805
- // 子表初始化时,设置表格数据
806
- if (this.form[item.model] && this.form[item.model].length > 0) {
807
- this.$refs[`childXFormTable_${item.model}`][0].setTableData(this.form[item.model])
808
- }
809
- },
810
- customJsValidate (rule, value, callback, item) {
811
- if (item.rule.customValidatorFunc) {
812
- executeStrFunctionByContext(this, item.rule.customValidatorFunc, [rule, value, callback, this.form, item, this.util, runLogic, getConfigByNameAsync])
813
- } else {
814
- callback()
815
- }
816
- },
817
- itemDisabled (value) {
818
- return (this.businessType === '新增' && value.addOrEdit === 'edit') ||
819
- (this.businessType === '修改' && value.addOrEdit === 'add')
820
- },
821
- readonly (value) {
822
- return value.addOrEdit === 'readonly'
823
- },
824
- async onSubmit () {
825
- const valid = await this.validateForm()
826
- if (!valid) return false
827
- if (this.viewMode) {
828
- this.$message.info('预览模式禁止新增和修改')
829
- return false
830
- }
831
- this.loading = true
832
- const requestForm = this.prepareForm()
833
- await this.appendSilenceAddFields(requestForm)
834
- const realForm = this.handleFormKeys(requestForm)
835
- // 增加子表数据
836
- if (this.childTableData.length > 0) {
837
- for (const item of this.childTableData) {
838
- const childModel = item.model
839
- const childDataRef = this.$refs['childXFormTable_' + item.model][0].getTableData()
840
- const childData = []
841
- for (const item of childDataRef) {
842
- childData.push(JSON.parse(JSON.stringify(item)))
843
- }
844
- for (let i = 0; i < childData.length; i++) {
845
- childData[i] = this.handleFormKeys(childData[i])
846
- // 外键不需要带表别名,所以此处放到表单处理后赋值
847
- if (realForm.id) {
848
- childData[i][item.childTableForeignKeyName] = realForm.id
849
- }
850
- }
851
- realForm[childModel] = childData
852
- }
853
- }
854
- // 增加form子表数据
855
- if (this.childFormData.length > 0) {
856
- for (const item of this.childFormData) {
857
- const childModel = item.model
858
- const childData = this.$refs[item.model].getTableData()
859
- for (let i = 0; i < childData.length; i++) {
860
- childData[i] = this.handleFormKeys(childData[i], true)
861
- // 外键不需要带表别名,所以此处放到表单处理后赋值
862
- if (realForm.id) {
863
- childData[i][item.foreignKey] = realForm.id
864
- }
865
- }
866
- realForm[childModel] = childData
867
- }
868
- }
869
- if (this.$listeners.onSubmit) {
870
- // 交由父级处理
871
- this.$emit('onSubmit', {
872
- businessType: this.businessType,
873
- serviceName: this.serviceName,
874
- realForm: realForm,
875
- currUserName: this.currUser.name,
876
- currUserId: this.currUser.id,
877
- orgId: this.currUser.orgid
878
- })
879
- } else {
880
- this.defaultSubmit(realForm)
881
- }
882
- },
883
-
884
- async asyncSubmit () {
885
- return new Promise((resolve, reject) => {
886
- this.$refs.selectForm.validate(async valid => {
887
- if (!valid) {
888
- reject(new Error('Form validation failed'))
889
- return
890
- }
891
- this.loading = true
892
- const requestForm = this.prepareForm()
893
- await this.appendSilenceAddFields(requestForm)
894
- const realForm = this.handleFormKeys(requestForm)
895
- resolve({
896
- realForm,
897
- businessType: this.businessType,
898
- serviceName: this.serviceName,
899
- currUserName: this.currUser.name,
900
- currUserId: this.currUser.id,
901
- orgId: this.currUser.orgid
902
- })
903
- })
904
- })
905
- },
906
-
907
- validateForm () {
908
- return new Promise((resolve) => {
909
- this.$refs.selectForm.validate(valid => resolve(valid))
910
- })
911
- },
912
-
913
- childTableFixedQueryForm (item) {
914
- if (this.modifyModelData?.primaryKeyData) {
915
- const fixedForm = {}
916
- fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
917
- return fixedForm
918
- }
919
- return null
920
- },
921
-
922
- prepareForm () {
923
- const form = { ...this.form }
924
- for (const key of Object.keys(form)) {
925
- const value = form[key]
926
- if (value === null || (typeof value === 'object' && Object.keys(value).length === 0)) {
927
- form[key] = undefined
928
- }
929
- }
930
- return form
931
- },
932
-
933
- async appendSilenceAddFields (form) {
934
- if (this.businessType === '新增') {
935
- for (const item of this.silenceAddJsonData) {
936
- switch (item.silencePurpose) {
937
- case 'createTime':
938
- form[item.model] = formatDate('now')
939
- break
940
- case 'operator':
941
- form[item.model] = this.currUser.name
942
- break
943
- case 'operatorId':
944
- form[item.model] = this.currUser.id
945
- break
946
- case 'orgId':
947
- form[item.model] = this.currUser.orgid
948
- break
949
- case 'orgName':
950
- form[item.model] = this.currUser.orgs
951
- break
952
- case 'depId':
953
- form[item.model] = this.currUser.depids
954
- break
955
- case 'depName':
956
- form[item.model] = this.currUser.deps
957
- break
958
- }
959
- }
960
- for (const item of this.silenceAddJsonData.filter((item) => item.silencePurpose === 'customize')) {
961
- const result = await runLogic(item.silenceSource, form, this.serviceName)
962
- if (result) {
963
- const keys = Object.keys(result)
964
- if (keys.length === 1 && keys[0] === 'value') {
965
- form[item.model] = result.value
966
- } else {
967
- form[item.model] = result
968
- }
969
- } else {
970
- form[item.model] = result
971
- }
972
- }
973
- }
974
- },
975
-
976
- handleFormKeys (form, mustHandleKey = false) {
977
- const realForm = {}
978
- for (const key of Object.keys(form)) {
979
- const value = form[key]
980
- const extraFormKeyTagIndex = key.indexOf('@')
981
- if (extraFormKeyTagIndex !== -1) {
982
- const extraFormKey = key.substring(0, extraFormKeyTagIndex)
983
- const realKey = key.substring(extraFormKeyTagIndex + 1)
984
- if (!realForm[extraFormKey]) {
985
- realForm[extraFormKey] = {}
986
- }
987
- realForm[extraFormKey][realKey] = value
988
- } else {
989
- const realKey = this.isHandleFormKey || mustHandleKey ? this.getRealKey(key, mustHandleKey) : key
990
- // 如果发生重名,不覆盖,把key的别名带上
991
- if (realForm[realKey]) {
992
- realForm[key] = value
993
- } else {
994
- realForm[realKey] = value
995
- }
996
- }
997
- }
998
- return realForm
999
- },
1000
- // 默认提交事件
1001
- defaultSubmit (realForm, callback) {
1002
- // 新增移除id
1003
- if (this.businessType === '新增') {
1004
- delete realForm.id
1005
- }
1006
- // 组织请求
1007
- const requestParameters = {
1008
- queryParamsName: this.configName,
1009
- queryParams: this.configContent,
1010
- form: realForm,
1011
- businessType: this.businessType,
1012
- operator: this.currUser.name
1013
- }
1014
- addOrModify(requestParameters, this.serviceName, this.env === 'dev').then(data => {
1015
- this.$message.success(this.businessType + '成功!')
1016
- // commit
1017
- this.$emit('afterSubmit', { type: this.businessType, id: data.id, data: data, form: requestParameters.form })
1018
- this.loading = false
1019
- if (callback) {
1020
- callback()
1021
- }
1022
- }).catch(e => {
1023
- this.loading = false
1024
- this.$message.error(this.businessType + '失败:' + e)
1025
- })
1026
- },
1027
- // 获取表单字段实际值
1028
- getRealKey (key, mustHandleKey = false) {
1029
- if (key === 'selected_id') return key
1030
- if (this.isHandleFormKey || mustHandleKey) {
1031
- return key.substring(key.indexOf('_') + 1)
1032
- } else {
1033
- return key
1034
- }
1035
- },
1036
- /**
1037
- * 获取被修改记录数据
1038
- * @param modifyModelData 被修改记录的数据
1039
- */
1040
- getModifyModelData (modifyModelData) {
1041
- if (modifyModelData.primaryKeyData) {
1042
- this.form = Object.assign(this.form, modifyModelData.primaryKeyData)
1043
- }
1044
- // 对动态简易表单项特殊处理
1045
- for (const key in modifyModelData.data) {
1046
- const realKey = this.isHandleFormKey ? this.getRealKey(key) : key
1047
- if (this.simpleFormJsonData[realKey]) {
1048
- const extraForm = JSON.parse(modifyModelData.data[key])
1049
- for (const key in extraForm) {
1050
- const model = realKey + '@' + key
1051
- this.form[model] = extraForm[key]
1052
- }
1053
- }
1054
- }
1055
- // 对普通表单项处理
1056
- for (let i = 0; i < this.realJsonData.length; i++) {
1057
- if (['FilesId', 'Images'].includes(this.realJsonData[i])) {
1058
- // 附件需要跳过 因为会通过 modifyModelData中的files,images属性给upload赋值
1059
- // 新增修改表单每次提交时只会提交最新添加的文件
1060
- continue
1061
- }
1062
- const item = this.realJsonData[i]
1063
- if (modifyModelData.data[item.model] || modifyModelData.data[item.model] === 0) {
1064
- if (modifyModelData.data[item.model] instanceof Array) {
1065
- this.form[item.model] = modifyModelData.data[item.model]
1066
- } else {
1067
- this.form[item.model] = modifyModelData.data[item.model] + ''
1068
- }
1069
- }
1070
- }
1071
- // 对分组表单进行处理
1072
- for (let i = 0; i < this.groupJsonData.length; i++) {
1073
- const item = this.groupJsonData[i]
1074
- try {
1075
- if (modifyModelData.data[item.model]) {
1076
- this.form[item.model] = JSON.parse(modifyModelData.data[item.model])
1077
- }
1078
- } catch (e) {
1079
- if (modifyModelData.data[item.model]) {
1080
- this.form[item.model] = modifyModelData.data[item.model]
1081
- }
1082
- }
1083
- }
1084
- // 追加版本号信息
1085
- for (const item of this.versionJsonData) {
1086
- if (!modifyModelData.data[item.model]) {
1087
- this.form[item.model] = 0
1088
- } else {
1089
- this.form[item.model] = modifyModelData.data[item.model] + ''
1090
- }
1091
- }
1092
- },
1093
- setForm (obj) {
1094
- this.form = Object.assign(this.form, obj)
1095
- // 给子表赋外键条件
1096
- if (this.childFormData.length > 0) {
1097
- for (const item of this.childFormData) {
1098
- const child = this.$refs[item.model]
1099
- // 获取子表别名,以便在条件上添加别名
1100
- const alias = child.realQueryConfig.tableAliasName
1101
- // 有主键,且主键有值,添加主键条件
1102
- if (this.primaryKey && this.form[this.primaryKey]) {
1103
- const foreignKey = item.foreignKey
1104
- const fixedQueryForm = { [alias + '_' + foreignKey]: this.form[this.primaryKey] }
1105
- if (!child.fixedQueryForm) {
1106
- child.fixedQueryForm = fixedQueryForm
1107
- } else {
1108
- Object.assign(child.fixedQueryForm, fixedQueryForm)
1109
- }
1110
- child.refreshTable()
1111
- }
1112
- }
1113
- }
1114
- },
1115
- setFormWithKey (obj) {
1116
- setDataByRealKey(this.form, obj)
1117
- },
1118
- setFormWithNoKey (obj) {
1119
- setDataByRealKey(this.form, obj)
1120
- },
1121
- emitFunc (func, data, value) {
1122
- this.$emit(func, data, value)
1123
- this.$emit('x-form-item-emit-func', func, data, value)
1124
- },
1125
- // 直接转发事件的函数
1126
- emitEvent (event, ...args) {
1127
- this.$emit(event, ...args)
1128
- },
1129
- close () {
1130
- this.loaded = false
1131
- },
1132
- /**
1133
- * 行选择事件
1134
- * @param row 选中行集合
1135
- * @param attr 表单项属性
1136
- */
1137
- async rowChoose (row, attr, callback) {
1138
- // 如果配置了自定义函数
1139
- if (attr.dataChangeFunc) {
1140
- await executeStrFunction(attr.dataChangeFunc, [this.form, this.setForm, {
1141
- ...attr,
1142
- selectRows: row
1143
- }, util, this.mode, runLogic, getConfigByNameAsync])
1144
- } else {
1145
- // 默认填充选中行数据到当前表单
1146
- setDataByRealKey(this.form, row[0])
1147
- }
1148
- if (callback) {
1149
- callback()
1150
- }
1151
- },
1152
- }
1153
- }
1154
- </script>
1155
-
1156
- <style scoped lang="less">
1157
- :deep(.ant-form-inline .ant-form-item ) {
1158
- display: block !important;
1159
- }
1160
-
1161
- :deep(.ant-form-item-with-help) {
1162
- margin-bottom: 0;
1163
- }
1164
-
1165
- .xFormGroupTitle {
1166
- font-weight: bold;
1167
- color: @primary-color;
1168
- }
1169
- </style>
1
+ <template>
2
+ <div id="XAddNativeForm">
3
+ <a-form-model
4
+ v-if="loaded"
5
+ ref="selectForm"
6
+ :zIndex="1001"
7
+ :model="form"
8
+ v-bind="formItemLayoutGen"
9
+ :layout="layout">
10
+ <template v-for="(item, key) in childTableData">
11
+ <a-row
12
+ v-if="childTablePriority"
13
+ :gutter="16"
14
+ :key="'childTableRow' + key">
15
+ <a-card :title="item.name" :bordered="false" size="small">
16
+ <x-form-table
17
+ :key="'childTable_' + item.model"
18
+ :title="item.name"
19
+ :queryParamsName="item.childTableConfigName"
20
+ :localEditMode="true"
21
+ :fixed-query-form="childTableFixedQueryForm(item)"
22
+ :service-name="serviceName"
23
+ @innerXFormTableEmit="innerXFormTableEmit"
24
+ @afterTableInit="childTableMounted(item)"
25
+ :ref="'childXFormTable_' + item.model">
26
+ </x-form-table>
27
+ </a-card>
28
+ </a-row>
29
+ </template>
30
+ <a-row ref="GroupItemRow">
31
+ <a-col :span="3" v-if="!inXFormGroup && !(groups[0].groupName === DEFAULT_GROUP_NAME)">
32
+ <a-tabs tab-position="left" v-model="activeTab" @change="scrollToGroup">
33
+ <a-tab-pane
34
+ v-for="(groupsItem,groupsIndex) in groups"
35
+ :tab="groupsItem.groupName"
36
+ :key="groupsIndex">
37
+ </a-tab-pane>
38
+ </a-tabs>
39
+ </a-col>
40
+ <a-col
41
+ :span="(!inXFormGroup && !(groups[0].groupName === DEFAULT_GROUP_NAME)) ? 21: 24">
42
+ <a-row
43
+ :gutter="16"
44
+ type="flex"
45
+ :key="groupsIndex"
46
+ v-for="(groupsItem,groupsIndex) in groups"
47
+ >
48
+ <a-col
49
+ :span="24"
50
+ :style="{ marginTop: groupsIndex === 0 ? '' : '8px',fontSize:inXFormGroup?'15px':'14px', marginLeft:'-5px' }"
51
+ v-if="groupsItem.groupName !== DEFAULT_GROUP_NAME">
52
+ <span class="xFormGroupTitle" :ref="`group-title-${groupsIndex}`">{{ groupsItem.groupName }}</span>
53
+ </a-col>
54
+ <x-form-item
55
+ v-for="(item, index) in groupsItem.realJsonData"
56
+ :key="index"
57
+ :attr="item"
58
+ :disabled="itemDisabled(item)"
59
+ :read-only="readonly(item)"
60
+ :files="files"
61
+ v-bind="formItemLayoutGen"
62
+ :style="layout === 'inline' ? { marginTop:'5px' } : undefined"
63
+ :form="form"
64
+ :images="images"
65
+ :service-name="serviceName"
66
+ mode="新增/修改"
67
+ :layout="layout"
68
+ :rules="rules[`${item.name}${item.model}`]"
69
+ :get-data-params="getDataParams"
70
+ :env="env"
71
+ @x-form-item-emit-func="emitFunc"
72
+ @rowChoose="rowChoose"
73
+ :setForm="setForm"
74
+ />
75
+ </a-row>
76
+ </a-col>
77
+ </a-row>
78
+ <a-row :gutter="16" v-for="(groupItem, groupIndex) in groupJsonData" :key="groupIndex">
79
+ <a-card v-if="groupItem.groupItems.length > 0" :title="groupItem.name" :bordered="false" size="small">
80
+ <x-form-item
81
+ v-for="(item, index) in groupItem.groupItems"
82
+ :key="index"
83
+ :attr="item"
84
+ :disabled="itemDisabled(item)"
85
+ :readonly="readonly(item)"
86
+ :files="files"
87
+ v-bind="formItemLayoutGen"
88
+ :style="layout ==='inline'?{marginTop:'5px'}:undefined"
89
+ :form="form[groupItem.model]"
90
+ :images="images"
91
+ :service-name="serviceName"
92
+ mode="新增/修改"
93
+ :rules="rules[`${item.name}${item.model}`]"
94
+ :get-data-params="getDataParams"
95
+ :env="env"
96
+ :setForm="setForm"
97
+ @rowChoose="rowChoose"
98
+ />
99
+ </a-card>
100
+ <template v-else>
101
+ <slot
102
+ name="groupFormItems"
103
+ :form="form"
104
+ :model="groupItem.model"
105
+ :rules="rules"
106
+ :modifyModelData="modifyModelData"></slot>
107
+ </template>
108
+ </a-row>
109
+ <a-row :gutter="16" v-for="(item, key) in simpleFormJsonData" :key="'row' + key">
110
+ <a-card v-if="item.value.length > 0" :title="item.name" :bordered="false" size="small">
111
+ <x-form-item
112
+ v-for="(formItem, formItemIndex) in item.value"
113
+ :key="key + formItemIndex"
114
+ :attr="formItem"
115
+ :disabled="itemDisabled(formItem)"
116
+ :readonly="readonly(formItem)"
117
+ :files="files"
118
+ v-bind="formItemLayoutGen"
119
+ :style="layout ==='inline'?{marginTop:'5px'}:undefined"
120
+ :form="form[groupItem.model]"
121
+ :images="images"
122
+ :service-name="serviceName"
123
+ mode="新增/修改"
124
+ :rules="rules[`${item.name}${item.model}`]"
125
+ :get-data-params="getDataParams"
126
+ :env="env"
127
+ :setForm="setForm"
128
+ @rowChoose="rowChoose"
129
+ />
130
+ </a-card>
131
+ </a-row>
132
+ <template v-for="(item, key) in childTableData">
133
+ <a-row
134
+ v-if="!childTablePriority"
135
+ :gutter="16"
136
+ :key="'childTableRow' + key">
137
+ <a-card :title="item.name" :bordered="false" size="small">
138
+ <x-form-table
139
+ :key="'childTable_' + item.model"
140
+ :title="item.name"
141
+ :queryParamsName="item.childTableConfigName"
142
+ :localEditMode="true"
143
+ @innerXFormTableEmit="innerXFormTableEmit"
144
+ :fixed-query-form="childTableFixedQueryForm(item)"
145
+ :service-name="serviceName"
146
+ @afterTableInit="childTableMounted(item)"
147
+ :ref="'childXFormTable_' + item.model">
148
+ </x-form-table>
149
+ </a-card>
150
+ </a-row>
151
+ </template>
152
+ <a-row type="flex" :justify="btnPlace" :style="{paddingLeft: '16px',paddingRight: '16px'}">
153
+ <slot name="footer" :loading="loading">
154
+ <a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">{{ btnName }}</a-button>
155
+ </slot>
156
+ </a-row>
157
+ </a-form-model>
158
+ </div>
159
+ </template>
160
+ <script>
161
+ import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
162
+ import { formatDate, setDataByRealKey } from '@vue2-client/utils/util'
163
+ import * as util from '@vue2-client/utils/util'
164
+ import { mapState } from 'vuex'
165
+ import { addOrModify, getConfigByName, getConfigByNameAsync, runLogic } from '@vue2-client/services/api/common'
166
+ import { checkIdNumber, REG_EMAIL, REG_LANDLINE, REG_PHONE } from '@vue2-client/utils/reg'
167
+ import moment from 'moment/moment'
168
+ import { executeStrFunction, executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
169
+ import formValidationMixin from '@vue2-client/mixins/formValidationMixin'
170
+
171
+ const DEFAULT_GROUP_NAME = '__default__'
172
+ export default {
173
+ name: 'XAddNativeForm',
174
+ components: {
175
+ XFormItem,
176
+ XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue')
177
+ },
178
+ inject: {
179
+ inXFormGroup: {
180
+ default: false
181
+ },
182
+ formGroupContext: {
183
+ default: null
184
+ },
185
+ formDataChange: {
186
+ default: null
187
+ }
188
+ },
189
+ props: {},
190
+ data () {
191
+ return {
192
+ DEFAULT_GROUP_NAME,
193
+ // 预览模式
194
+ viewMode: false,
195
+ // 是否处理表单Key值
196
+ isHandleFormKey: true,
197
+ // 内容加载是否完成
198
+ loaded: false,
199
+ // 业务类型
200
+ businessType: '',
201
+ // 业务标题
202
+ title: '',
203
+ // 新增或修改业务是否执行中
204
+ loading: false,
205
+ // 表单Model
206
+ form: {},
207
+ // 配置名称
208
+ configName: undefined,
209
+ // 配置内容,用于查询配置生成器的预览
210
+ configContent: undefined,
211
+ // 表单项集合
212
+ formItems: [],
213
+ // 服务名称
214
+ serviceName: undefined,
215
+ // 是否显示提交按钮
216
+ showSubmitBtn: true,
217
+ // 修改有文件的表单时使用
218
+ files: [],
219
+ images: [],
220
+ // 校验
221
+ rules: {},
222
+ // 调用logic获取数据源的追加参数
223
+ getDataParams: {},
224
+ // 动态简易表单集合
225
+ simpleFormJsonData: {},
226
+ // 待修改的数据集
227
+ modifyModelData: {},
228
+ // 当前环境
229
+ env: 'prod',
230
+ // 表单主键
231
+ primaryKey: null,
232
+ // 表单模式 horizontal | vertical | inline
233
+ layout: 'horizontal',
234
+ // 提交按钮名称
235
+ btnName: '提交',
236
+ // 提交按钮位置 start / center / end
237
+ btnPlace: 'center',
238
+ // 子表是否排在前面
239
+ childTablePriority: false
240
+ }
241
+ },
242
+ computed: {
243
+ // 过滤出用于新增/修改场景的表单项
244
+ realJsonData: function () {
245
+ return this.formItems.filter((item) => {
246
+ return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
247
+ })
248
+ },
249
+ // 表单项组 / 不是 数据组
250
+ groups: function () {
251
+ if (!this.realJsonData || this.realJsonData.length === 0) {
252
+ return [{
253
+ groupName: DEFAULT_GROUP_NAME,
254
+ realJsonData: this.realJsonData,
255
+ xAddFormLayout: 'horizontal'
256
+ }]
257
+ }
258
+ const uniqueGroups = new Set(this.realJsonData.map(item => item.group).filter(Boolean))
259
+ const allGroup = Array.from(uniqueGroups).map(group => {
260
+ return {
261
+ groupName: group,
262
+ realJsonData: this.realJsonData.filter(item => item.group === group),
263
+ xAddFormLayout: 'horizontal'
264
+ }
265
+ })
266
+ // 判断每一组得formJson 长度相加是否等于 realJsonData 长度 避免错误数据
267
+ if (allGroup.reduce((total, item) => total + item.realJsonData.length, 0) === this.realJsonData.length) {
268
+ return allGroup
269
+ } else {
270
+ return [{
271
+ groupName: DEFAULT_GROUP_NAME,
272
+ realJsonData: this.realJsonData,
273
+ xAddFormLayout: 'horizontal'
274
+ }]
275
+ }
276
+ },
277
+ // 拥有自定义校验函数得表单项
278
+ customValidateItems: function () {
279
+ return this.formItems.filter((item) => {
280
+ return item?.rule?.type === 'customJs'
281
+ })
282
+ },
283
+ // 过滤出用于新增/修改场景的表单项
284
+ groupJsonData: function () {
285
+ return this.formItems.filter((item) => {
286
+ return item.type === 'group'
287
+ }).map((item) => {
288
+ item.groupItems = item.groupItems.filter((item) => {
289
+ return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
290
+ }).map((groupItem) => {
291
+ // 只保留第一个下划线后面的内容
292
+ // 多层校验规则需要将prop设置为 key1.key2.....
293
+ groupItem.prop = `${item.model}.${groupItem.model.substring(groupItem.model.indexOf('_') + 1)}`
294
+ groupItem.model = groupItem.model.substring(groupItem.model.indexOf('_') + 1)
295
+ return groupItem
296
+ })
297
+ return item
298
+ }
299
+ )
300
+ },
301
+ // 过滤出用于子表数据新增/修改场景的表单项
302
+ childTableData: function () {
303
+ return this.formItems.filter((item) => {
304
+ return item.type === 'childTable'
305
+ })
306
+ },
307
+ // 过滤出用于form子表数据新增/修改场景的表单项
308
+ childFormData: function () {
309
+ return this.formItems.filter((item) => {
310
+ return item.type === 'rowEdit'
311
+ })
312
+ },
313
+ // 过滤出用于静默新增场景的表单项
314
+ silenceAddJsonData: function () {
315
+ return this.formItems.filter(function (item) {
316
+ return item.addOrEdit === 'silenceAdd'
317
+ })
318
+ },
319
+ // 过滤出版本号表单项
320
+ versionJsonData: function () {
321
+ return this.formItems.filter(function (item) {
322
+ return item.addOrEdit === 'version'
323
+ })
324
+ },
325
+ formItemLayoutGen () {
326
+ if (this.layout === 'horizontal') {
327
+ return {
328
+ labelCol: { span: 4, offset: 2 },
329
+ wrapperCol: { span: 14 },
330
+ }
331
+ } else if (this.layout === 'vertical') {
332
+ return {}
333
+ } else {
334
+ if (!this.formItemLayout.labelCol || !this.formItemLayout.wrapperCol) {
335
+ return {
336
+ labelCol: { span: 8 },
337
+ wrapperCol: { span: 16 },
338
+ }
339
+ }
340
+ return {
341
+ labelCol: { span: this.formItemLayout.labelCol },
342
+ wrapperCol: { span: this.formItemLayout.wrapperCol },
343
+ }
344
+ }
345
+ },
346
+ ...mapState('account', { currUser: 'user' })
347
+ },
348
+ provide () {
349
+ return {
350
+ getComponentByName: this.getComponentByName,
351
+ registerComponent: this.registerComponent,
352
+ XFormContext: this,
353
+ // 移除必填项
354
+ removeRequired: this.removeRequired,
355
+ // 设置必填项
356
+ setRequired: this.setRequired,
357
+ getSelf: () => this,
358
+ }
359
+ },
360
+ watch: {
361
+ form: {
362
+ handler (val) {
363
+ if (this.formDataChange && typeof this.formDataChange === 'function') {
364
+ this.formDataChange(val)
365
+ }
366
+ },
367
+ deep: true
368
+ }
369
+ },
370
+ /** //todo 本来想要实现 配置 自定义函数时,表单项得红星提示,根据自定义校验函数得返回值来判断
371
+ * 但是监听不到父组件formgorup得其他form得变化,所以暂时不实现
372
+ */
373
+ //
374
+ // watch: {
375
+ // form: {
376
+ // handler (val) {
377
+ // // 遍历表单配置
378
+ // if (this.customValidateItems.length > 0) {
379
+ // for (const item of this.customValidateItems) {
380
+ // const itemIndex = this.formItems.findIndex(formItem => formItem.model === item.model)
381
+ // if (itemIndex < 0) {
382
+ // continue
383
+ // }
384
+ // try {
385
+ // this.customJsValidate(null, val[item.model], (res) => {
386
+ // // 如果返回error则设置错误信息
387
+ // if (res instanceof Error) {
388
+ // // 设置表单项的错误状态
389
+ // this.$set(this.formItems[itemIndex], 'tempRequired', true)
390
+ // } else {
391
+ // // 清除错误状态
392
+ // this.$set(this.formItems[itemIndex], 'tempRequired', true)
393
+ // }
394
+ // }, item)
395
+ // } catch (e) {
396
+ // console.error(e)
397
+ // this.$set(this.formItems[itemIndex], 'tempRequired', true)
398
+ // }
399
+ // }
400
+ // console.log('customValidateItems', JSON.stringify(this.customValidateItems))
401
+ // }
402
+ // },
403
+ // deep: true
404
+ // }
405
+ // },
406
+ mixins: [formValidationMixin],
407
+ methods: {
408
+ runLogic,
409
+ getConfigByNameAsync,
410
+ getConfigByName,
411
+ init (params) {
412
+ const {
413
+ configName,
414
+ configContent,
415
+ formItems,
416
+ formJson,
417
+ viewMode,
418
+ isHandleFormKey,
419
+ isKeyHandle = true,
420
+ showSubmitBtn = true,
421
+ serviceName,
422
+ primaryKey,
423
+ modifyModelData = {},
424
+ businessType,
425
+ title,
426
+ fixedAddForm = {},
427
+ getDataParams = {},
428
+ simpleFormJsonData = {},
429
+ env = 'prod',
430
+ layout,
431
+ xAddFormLayout = 'horizontal',
432
+ formItemLayout = {},
433
+ btnName = '提交',
434
+ childTablePriority = false,
435
+ btnPlace = 'center'
436
+ } = params
437
+ this.loaded = false
438
+ // 兼容需要省略 传递 layout: res.xAddFormLayout 可以使用 ...res 展开运算符 直接转递
439
+ if (xAddFormLayout && layout === undefined) {
440
+ this.layout = xAddFormLayout
441
+ } else {
442
+ this.layout = layout
443
+ }
444
+ this.formItemLayout = formItemLayout
445
+ if ((isHandleFormKey === null || isHandleFormKey === undefined) && !isKeyHandle) {
446
+ this.isHandleFormKey = isKeyHandle
447
+ } else if (isHandleFormKey) {
448
+ this.isHandleFormKey = isHandleFormKey
449
+ } else {
450
+ this.isHandleFormKey = isKeyHandle
451
+ }
452
+ this.childTablePriority = childTablePriority
453
+ this.configName = configName
454
+ this.configContent = configContent
455
+ this.formItems = this.getFromItem(formItems, formJson)
456
+ this.viewMode = viewMode
457
+ this.showSubmitBtn = showSubmitBtn
458
+ this.primaryKey = primaryKey
459
+ this.serviceName = serviceName
460
+ this.businessType = businessType
461
+ this.title = title
462
+ this.getDataParams = getDataParams
463
+ this.simpleFormJsonData = simpleFormJsonData
464
+ this.env = env
465
+ this.btnName = btnName
466
+ this.btnPlace = btnPlace
467
+ // 如果 fixedAddForm 有 selected_id 值,并且设置了处理表单key值,则多给 selected_id 加前缀 避免处理错误
468
+ if (fixedAddForm.selected_id && this.isHandleFormKey) {
469
+ fixedAddForm._selected_id = fixedAddForm.selected_id
470
+ delete fixedAddForm.selected_id
471
+ }
472
+ // 设置普通表单项的相关参数
473
+ const formData = Object.assign({}, fixedAddForm)
474
+ for (let i = 0; i < this.realJsonData.length; i++) {
475
+ const item = this.realJsonData[i]
476
+ this.setFormProps(formData, item, null)
477
+ }
478
+ // 设置表单分组项目相关参数
479
+ for (let i = 0; i < this.groupJsonData.length; i++) {
480
+ const groupItem = this.groupJsonData[i]
481
+ formData[groupItem.model] = {}
482
+ for (let j = 0; j < groupItem.groupItems.length; j++) {
483
+ const item = groupItem.groupItems[j]
484
+ this.setFormProps(formData[groupItem.model], item, item.prop)
485
+ }
486
+ }
487
+ // 设置动态简易表单项的相关参数
488
+ for (const key in this.simpleFormJsonData) {
489
+ for (const item of this.simpleFormJsonData[key].value) {
490
+ item.model = key + '@' + item.model
491
+ this.setFormProps(formData, item, null)
492
+ }
493
+ }
494
+
495
+ this.form = formData
496
+ // 修改场景下对表单项赋值
497
+ if (modifyModelData && modifyModelData.data) {
498
+ this.modifyModelData = modifyModelData
499
+ if (Object.keys(modifyModelData.data).length > 0) {
500
+ this.getModifyModelData(modifyModelData)
501
+ }
502
+ }
503
+ // 处理表单得附件
504
+ if (modifyModelData && modifyModelData.files) {
505
+ this.files = modifyModelData.files
506
+ }
507
+ if (modifyModelData && modifyModelData.images) {
508
+ this.images = modifyModelData.images
509
+ }
510
+ this.loaded = true
511
+ },
512
+ scrollToGroup (index) {
513
+ const groupElement = this.$refs[`group-title-${index}`][0]
514
+ if (groupElement) {
515
+ groupElement.scrollIntoView({ behavior: 'smooth' })
516
+ }
517
+ },
518
+ registerComponent (componentName, component) {
519
+ console.log('内部注册', this.$options.name, componentName)
520
+ this.$refs[componentName] = component
521
+ console.log('内部注册完成', this.$refs)
522
+ },
523
+ // 根据名字从注册到组件中获取组件
524
+ getComponentByName (componentName) {
525
+ console.log('内部取组件', this.$options.name, componentName)
526
+ console.log('内部组件内容', this.$refs)
527
+ return this.$refs[componentName]
528
+ },
529
+ // 兼容需要省略 传递 [formItems: res.formJson ] 可以使用 ...res 展开运算符 直接转递
530
+ getFromItem (formItems, formJson) {
531
+ const _formItems = formItems || formJson
532
+ if (typeof formItems === 'string') {
533
+ return JSON.parse(_formItems)
534
+ } else {
535
+ return JSON.parse(JSON.stringify(_formItems))
536
+ }
537
+ },
538
+ innerXFormTableEmit (fun, record, id, actionType, index) {
539
+ this.$emit(fun, record, id, actionType, index)
540
+ },
541
+ // 时间组件赋默认值
542
+ // .type, item.formDefault
543
+ getDateRange ({ type, formDefault: defaultValue, formValueFormat }) {
544
+ // const format = type === 'datePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
545
+ let format = 'YYYY-MM-DD HH:mm:ss'
546
+ if (formValueFormat) {
547
+ format = formValueFormat
548
+ }
549
+ let start
550
+ switch (defaultValue) {
551
+ case 'curYear':
552
+ start = moment().startOf('year').format(format)
553
+ break
554
+ case 'curMonth':
555
+ start = moment().startOf('month').format(format)
556
+ break
557
+ case 'curDay':
558
+ start = moment().startOf('day').format(format)
559
+ break
560
+ case 'curTime':
561
+ start = moment().format(format)
562
+ break
563
+ default:
564
+ return defaultValue
565
+ }
566
+ return start
567
+ },
568
+ setFormProps (formData, item, groupItem) {
569
+ const rulesKey = `${item.name}${item.model}`
570
+ if (formData[item.model] === undefined || formData[item.model] === null) {
571
+ formData[item.model] = undefined
572
+ }
573
+ if (!formData[item.model] && item.formDefault) {
574
+ if (['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(item.type)) {
575
+ formData[item.model] = this.getDateRange(item)
576
+ } else if (['treeSelect', 'select', 'checkbox'].includes(item.type) && ['curOrgId', 'curDepId', 'curUserId'].includes(item.formDefault)) {
577
+ if (item.formDefault === 'curOrgId') {
578
+ formData[item.model] = item.type === 'select' ? this.currUser.orgid : [this.currUser.orgid]
579
+ }
580
+ if (item.formDefault === 'curDepId') {
581
+ formData[item.model] = item.type === 'select' ? this.currUser.depids : [this.currUser.depids]
582
+ }
583
+ if (item.formDefault === 'curUserId') {
584
+ formData[item.model] = item.type === 'select' ? this.currUser.id : [this.currUser.id]
585
+ }
586
+ } else {
587
+ formData[item.model] = item.formDefault
588
+ }
589
+ }
590
+ // 处理表单校验情况
591
+ if (item.rule) {
592
+ if (groupItem) {
593
+ this.rules[groupItem] = []
594
+ } else {
595
+ this.rules[rulesKey] = []
596
+ }
597
+ const required = item.rule.required ? item.rule.required === true || item.rule.required === 'true' : false
598
+ let trigger
599
+ let message
600
+ if (required) {
601
+ switch (item.type) {
602
+ case 'select':
603
+ case 'checkbox':
604
+ case 'radio':
605
+ case 'treeSelect':
606
+ case 'rangePicker':
607
+ case 'monthPicker':
608
+ case 'yearPicker':
609
+ case 'datePicker':
610
+ case 'file':
611
+ case 'image':
612
+ case 'citySelect':
613
+ case 'addressSearch':
614
+ case 'personSetting':
615
+ message = '请选择' + item.name
616
+ trigger = 'change'
617
+ break
618
+ default:
619
+ message = '请输入' + item.name
620
+ trigger = 'blur'
621
+ }
622
+ if (groupItem) {
623
+ this.rules[groupItem].push({
624
+ required: true,
625
+ message: message,
626
+ trigger: trigger
627
+ })
628
+ } else {
629
+ this.rules[rulesKey].push({
630
+ required: true,
631
+ message: message,
632
+ trigger: trigger
633
+ })
634
+ }
635
+ }
636
+
637
+ switch (item.rule.type) {
638
+ case 'number':
639
+ case 'integer':
640
+ case 'float':
641
+ // eslint-disable-next-line no-case-declarations
642
+ let defaultValue
643
+ // eslint-disable-next-line no-case-declarations
644
+ let message
645
+ switch (item.rule.type) {
646
+ case 'number':
647
+ item.numberInput = true
648
+ message = '数字'
649
+ defaultValue = 0
650
+ break
651
+ case 'integer':
652
+ item.numberInput = true
653
+ message = '整数'
654
+ defaultValue = 0
655
+ break
656
+ case 'float':
657
+ item.numberInput = true
658
+ message = '小数'
659
+ defaultValue = 0.0
660
+ break
661
+ }
662
+ if (groupItem) {
663
+ this.rules[groupItem].push({
664
+ type: item.rule.type,
665
+ message: item.name + '必须为' + message,
666
+ transform: (value) => {
667
+ if (value && value.length !== 0) {
668
+ return Number(value)
669
+ } else {
670
+ return defaultValue
671
+ }
672
+ },
673
+ trigger: 'blur'
674
+ })
675
+ } else {
676
+ this.rules[rulesKey].push({
677
+ type: item.rule.type,
678
+ message: item.name + '必须为' + message,
679
+ transform: (value) => {
680
+ if (value && value.length !== 0) {
681
+ return Number(value)
682
+ } else {
683
+ return defaultValue
684
+ }
685
+ },
686
+ trigger: 'blur'
687
+ })
688
+ }
689
+ break
690
+ case 'email': {
691
+ const validator = (rule, value, callback) => {
692
+ if (value && !REG_EMAIL.test(value)) {
693
+ callback(new Error('请输入正确的邮箱地址'))
694
+ } else {
695
+ callback()
696
+ }
697
+ }
698
+ this.rules[groupItem || rulesKey].push({
699
+ type: 'email',
700
+ validator: validator,
701
+ message: '请输入正确的邮箱地址',
702
+ trigger: 'blur'
703
+ })
704
+ break
705
+ }
706
+ case 'userPhone': {
707
+ this.rules[groupItem || rulesKey].push({
708
+ type: 'userPhone',
709
+ validator: (rule, value, callback) => {
710
+ if (value && !REG_PHONE.test(value)) {
711
+ callback(new Error('请输入正确的手机号码'))
712
+ } else {
713
+ callback()
714
+ }
715
+ },
716
+ message: '请输入正确的手机号码',
717
+ trigger: 'blur'
718
+ })
719
+ break
720
+ }
721
+ case 'idNumber': {
722
+ this.rules[groupItem || rulesKey].push({
723
+ validator: (rule, value, callback) => {
724
+ if (value && !checkIdNumber(value)) {
725
+ callback(new Error('请输入正确的身份证号码'))
726
+ } else {
727
+ callback()
728
+ }
729
+ },
730
+ trigger: 'blur'
731
+ })
732
+ break
733
+ }
734
+ case 'landlineNumber': {
735
+ this.rules[rulesKey].push({
736
+ validator: (rule, value, callback) => {
737
+ if (value && !REG_LANDLINE.test(value)) {
738
+ callback(new Error('请输入正确的座机号码'))
739
+ } else {
740
+ callback()
741
+ }
742
+ },
743
+ trigger: 'blur'
744
+ })
745
+ break
746
+ }
747
+ // 大于0
748
+ case 'greaterThanZero': {
749
+ item.numberInput = true
750
+ this.rules[rulesKey].push({
751
+ validator: (rule, value, callback) => {
752
+ if (isNaN(value) || value <= 0) {
753
+ callback(new Error('请输入一个大于0的数字'))
754
+ } else {
755
+ callback()
756
+ }
757
+ },
758
+ trigger: 'blur'
759
+ })
760
+ break
761
+ }
762
+ // 大于等于0
763
+ case 'greaterThanOrEqualZero': {
764
+ item.numberInput = true
765
+ this.rules[rulesKey].push({
766
+ validator: (rule, value, callback) => {
767
+ if (isNaN(value) || value < 0) {
768
+ callback(new Error('请输入一个大于等于0的数字'))
769
+ } else {
770
+ callback()
771
+ }
772
+ },
773
+ trigger: 'blur'
774
+ })
775
+ break
776
+ }
777
+ case 'stringLength': {
778
+ this.rules[rulesKey].push({
779
+ validator: (rule, value, callback) => {
780
+ if (value && value.length < item.rule.minLen) {
781
+ callback(new Error('长度不能少于' + item.rule.minLen + '个字符'))
782
+ } else if (value && value.length > item.rule.maxLen) {
783
+ callback(new Error('长度不能超过' + item.rule.maxLen + '个字符'))
784
+ } else {
785
+ callback()
786
+ }
787
+ },
788
+ trigger: 'blur'
789
+ })
790
+ break
791
+ }
792
+ case 'customJs': {
793
+ this.rules[rulesKey].push({
794
+ validator: (rule, value, callback) => {
795
+ this.customJsValidate(rule, value, callback, item)
796
+ },
797
+ trigger: 'blur'
798
+ })
799
+ break
800
+ }
801
+ }
802
+ }
803
+ },
804
+ childTableMounted (item) {
805
+ // 子表初始化时,设置表格数据
806
+ if (this.form[item.model] && this.form[item.model].length > 0) {
807
+ this.$refs[`childXFormTable_${item.model}`][0].setTableData(this.form[item.model])
808
+ }
809
+ },
810
+ customJsValidate (rule, value, callback, item) {
811
+ if (item.rule.customValidatorFunc) {
812
+ executeStrFunctionByContext(this, item.rule.customValidatorFunc, [rule, value, callback, this.form, item, this.util, runLogic, getConfigByNameAsync])
813
+ } else {
814
+ callback()
815
+ }
816
+ },
817
+ itemDisabled (value) {
818
+ return (this.businessType === '新增' && value.addOrEdit === 'edit') ||
819
+ (this.businessType === '修改' && value.addOrEdit === 'add')
820
+ },
821
+ readonly (value) {
822
+ return value.addOrEdit === 'readonly'
823
+ },
824
+ async onSubmit () {
825
+ const valid = await this.validateForm()
826
+ if (!valid) return false
827
+ if (this.viewMode) {
828
+ this.$message.info('预览模式禁止新增和修改')
829
+ return false
830
+ }
831
+ this.loading = true
832
+ const requestForm = this.prepareForm()
833
+ await this.appendSilenceAddFields(requestForm)
834
+ const realForm = this.handleFormKeys(requestForm)
835
+ // 增加子表数据
836
+ if (this.childTableData.length > 0) {
837
+ for (const item of this.childTableData) {
838
+ const childModel = item.model
839
+ const childDataRef = this.$refs['childXFormTable_' + item.model][0].getTableData()
840
+ const childData = []
841
+ for (const item of childDataRef) {
842
+ childData.push(JSON.parse(JSON.stringify(item)))
843
+ }
844
+ for (let i = 0; i < childData.length; i++) {
845
+ childData[i] = this.handleFormKeys(childData[i])
846
+ // 外键不需要带表别名,所以此处放到表单处理后赋值
847
+ if (realForm.id) {
848
+ childData[i][item.childTableForeignKeyName] = realForm.id
849
+ }
850
+ }
851
+ realForm[childModel] = childData
852
+ }
853
+ }
854
+ // 增加form子表数据
855
+ if (this.childFormData.length > 0) {
856
+ for (const item of this.childFormData) {
857
+ const childModel = item.model
858
+ const childData = this.$refs[item.model].getTableData()
859
+ for (let i = 0; i < childData.length; i++) {
860
+ childData[i] = this.handleFormKeys(childData[i], true)
861
+ // 外键不需要带表别名,所以此处放到表单处理后赋值
862
+ if (realForm.id) {
863
+ childData[i][item.foreignKey] = realForm.id
864
+ }
865
+ }
866
+ realForm[childModel] = childData
867
+ }
868
+ }
869
+ if (this.$listeners.onSubmit) {
870
+ // 交由父级处理
871
+ this.$emit('onSubmit', {
872
+ businessType: this.businessType,
873
+ serviceName: this.serviceName,
874
+ realForm: realForm,
875
+ currUserName: this.currUser.name,
876
+ currUserId: this.currUser.id,
877
+ orgId: this.currUser.orgid
878
+ })
879
+ } else {
880
+ this.defaultSubmit(realForm)
881
+ }
882
+ },
883
+
884
+ async asyncSubmit () {
885
+ return new Promise((resolve, reject) => {
886
+ this.$refs.selectForm.validate(async valid => {
887
+ if (!valid) {
888
+ reject(new Error('Form validation failed'))
889
+ return
890
+ }
891
+ this.loading = true
892
+ const requestForm = this.prepareForm()
893
+ await this.appendSilenceAddFields(requestForm)
894
+ const realForm = this.handleFormKeys(requestForm)
895
+ resolve({
896
+ realForm,
897
+ businessType: this.businessType,
898
+ serviceName: this.serviceName,
899
+ currUserName: this.currUser.name,
900
+ currUserId: this.currUser.id,
901
+ orgId: this.currUser.orgid
902
+ })
903
+ })
904
+ })
905
+ },
906
+
907
+ validateForm () {
908
+ return new Promise((resolve) => {
909
+ this.$refs.selectForm.validate(valid => resolve(valid))
910
+ })
911
+ },
912
+
913
+ childTableFixedQueryForm (item) {
914
+ if (this.modifyModelData?.primaryKeyData) {
915
+ const fixedForm = {}
916
+ fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
917
+ return fixedForm
918
+ }
919
+ return null
920
+ },
921
+
922
+ prepareForm () {
923
+ const form = { ...this.form }
924
+ for (const key of Object.keys(form)) {
925
+ const value = form[key]
926
+ if (value === null || (typeof value === 'object' && Object.keys(value).length === 0)) {
927
+ form[key] = undefined
928
+ }
929
+ }
930
+ return form
931
+ },
932
+
933
+ async appendSilenceAddFields (form) {
934
+ if (this.businessType === '新增') {
935
+ for (const item of this.silenceAddJsonData) {
936
+ switch (item.silencePurpose) {
937
+ case 'createTime':
938
+ form[item.model] = formatDate('now')
939
+ break
940
+ case 'operator':
941
+ form[item.model] = this.currUser.name
942
+ break
943
+ case 'operatorId':
944
+ form[item.model] = this.currUser.id
945
+ break
946
+ case 'orgId':
947
+ form[item.model] = this.currUser.orgid
948
+ break
949
+ case 'orgName':
950
+ form[item.model] = this.currUser.orgs
951
+ break
952
+ case 'depId':
953
+ form[item.model] = this.currUser.depids
954
+ break
955
+ case 'depName':
956
+ form[item.model] = this.currUser.deps
957
+ break
958
+ }
959
+ }
960
+ for (const item of this.silenceAddJsonData.filter((item) => item.silencePurpose === 'customize')) {
961
+ const result = await runLogic(item.silenceSource, form, this.serviceName)
962
+ if (result) {
963
+ const keys = Object.keys(result)
964
+ if (keys.length === 1 && keys[0] === 'value') {
965
+ form[item.model] = result.value
966
+ } else {
967
+ form[item.model] = result
968
+ }
969
+ } else {
970
+ form[item.model] = result
971
+ }
972
+ }
973
+ }
974
+ },
975
+
976
+ handleFormKeys (form, mustHandleKey = false) {
977
+ const realForm = {}
978
+ for (const key of Object.keys(form)) {
979
+ const value = form[key]
980
+ const extraFormKeyTagIndex = key.indexOf('@')
981
+ if (extraFormKeyTagIndex !== -1) {
982
+ const extraFormKey = key.substring(0, extraFormKeyTagIndex)
983
+ const realKey = key.substring(extraFormKeyTagIndex + 1)
984
+ if (!realForm[extraFormKey]) {
985
+ realForm[extraFormKey] = {}
986
+ }
987
+ realForm[extraFormKey][realKey] = value
988
+ } else {
989
+ const realKey = this.isHandleFormKey || mustHandleKey ? this.getRealKey(key, mustHandleKey) : key
990
+ // 如果发生重名,不覆盖,把key的别名带上
991
+ if (realForm[realKey]) {
992
+ realForm[key] = value
993
+ } else {
994
+ realForm[realKey] = value
995
+ }
996
+ }
997
+ }
998
+ return realForm
999
+ },
1000
+ // 默认提交事件
1001
+ defaultSubmit (realForm, callback) {
1002
+ // 新增移除id
1003
+ if (this.businessType === '新增') {
1004
+ delete realForm.id
1005
+ }
1006
+ // 组织请求
1007
+ const requestParameters = {
1008
+ queryParamsName: this.configName,
1009
+ queryParams: this.configContent,
1010
+ form: realForm,
1011
+ businessType: this.businessType,
1012
+ operator: this.currUser.name
1013
+ }
1014
+ addOrModify(requestParameters, this.serviceName, this.env === 'dev').then(data => {
1015
+ this.$message.success(this.businessType + '成功!')
1016
+ // commit
1017
+ this.$emit('afterSubmit', { type: this.businessType, id: data.id, data: data, form: requestParameters.form })
1018
+ this.loading = false
1019
+ if (callback) {
1020
+ callback()
1021
+ }
1022
+ }).catch(e => {
1023
+ this.loading = false
1024
+ this.$message.error(this.businessType + '失败:' + e)
1025
+ })
1026
+ },
1027
+ // 获取表单字段实际值
1028
+ getRealKey (key, mustHandleKey = false) {
1029
+ if (key === 'selected_id') return key
1030
+ if (this.isHandleFormKey || mustHandleKey) {
1031
+ return key.substring(key.indexOf('_') + 1)
1032
+ } else {
1033
+ return key
1034
+ }
1035
+ },
1036
+ /**
1037
+ * 获取被修改记录数据
1038
+ * @param modifyModelData 被修改记录的数据
1039
+ */
1040
+ getModifyModelData (modifyModelData) {
1041
+ if (modifyModelData.primaryKeyData) {
1042
+ this.form = Object.assign(this.form, modifyModelData.primaryKeyData)
1043
+ }
1044
+ // 对动态简易表单项特殊处理
1045
+ for (const key in modifyModelData.data) {
1046
+ const realKey = this.isHandleFormKey ? this.getRealKey(key) : key
1047
+ if (this.simpleFormJsonData[realKey]) {
1048
+ const extraForm = JSON.parse(modifyModelData.data[key])
1049
+ for (const key in extraForm) {
1050
+ const model = realKey + '@' + key
1051
+ this.form[model] = extraForm[key]
1052
+ }
1053
+ }
1054
+ }
1055
+ // 对普通表单项处理
1056
+ for (let i = 0; i < this.realJsonData.length; i++) {
1057
+ if (['FilesId', 'Images'].includes(this.realJsonData[i])) {
1058
+ // 附件需要跳过 因为会通过 modifyModelData中的files,images属性给upload赋值
1059
+ // 新增修改表单每次提交时只会提交最新添加的文件
1060
+ continue
1061
+ }
1062
+ const item = this.realJsonData[i]
1063
+ if (modifyModelData.data[item.model] || modifyModelData.data[item.model] === 0) {
1064
+ if (modifyModelData.data[item.model] instanceof Array) {
1065
+ this.form[item.model] = modifyModelData.data[item.model]
1066
+ } else {
1067
+ this.form[item.model] = modifyModelData.data[item.model] + ''
1068
+ }
1069
+ }
1070
+ }
1071
+ // 对分组表单进行处理
1072
+ for (let i = 0; i < this.groupJsonData.length; i++) {
1073
+ const item = this.groupJsonData[i]
1074
+ try {
1075
+ if (modifyModelData.data[item.model]) {
1076
+ this.form[item.model] = JSON.parse(modifyModelData.data[item.model])
1077
+ }
1078
+ } catch (e) {
1079
+ if (modifyModelData.data[item.model]) {
1080
+ this.form[item.model] = modifyModelData.data[item.model]
1081
+ }
1082
+ }
1083
+ }
1084
+ // 追加版本号信息
1085
+ for (const item of this.versionJsonData) {
1086
+ if (!modifyModelData.data[item.model]) {
1087
+ this.form[item.model] = 0
1088
+ } else {
1089
+ this.form[item.model] = modifyModelData.data[item.model] + ''
1090
+ }
1091
+ }
1092
+ },
1093
+ setForm (obj) {
1094
+ this.form = Object.assign(this.form, obj)
1095
+ // 给子表赋外键条件
1096
+ if (this.childFormData.length > 0) {
1097
+ for (const item of this.childFormData) {
1098
+ const child = this.$refs[item.model]
1099
+ // 获取子表别名,以便在条件上添加别名
1100
+ const alias = child.realQueryConfig.tableAliasName
1101
+ // 有主键,且主键有值,添加主键条件
1102
+ if (this.primaryKey && this.form[this.primaryKey]) {
1103
+ const foreignKey = item.foreignKey
1104
+ const fixedQueryForm = { [alias + '_' + foreignKey]: this.form[this.primaryKey] }
1105
+ if (!child.fixedQueryForm) {
1106
+ child.fixedQueryForm = fixedQueryForm
1107
+ } else {
1108
+ Object.assign(child.fixedQueryForm, fixedQueryForm)
1109
+ }
1110
+ child.refreshTable()
1111
+ }
1112
+ }
1113
+ }
1114
+ },
1115
+ setFormWithKey (obj) {
1116
+ setDataByRealKey(this.form, obj)
1117
+ },
1118
+ setFormWithNoKey (obj) {
1119
+ setDataByRealKey(this.form, obj)
1120
+ },
1121
+ emitFunc (func, data, value) {
1122
+ this.$emit(func, data, value)
1123
+ this.$emit('x-form-item-emit-func', func, data, value)
1124
+ },
1125
+ // 直接转发事件的函数
1126
+ emitEvent (event, ...args) {
1127
+ this.$emit(event, ...args)
1128
+ },
1129
+ close () {
1130
+ this.loaded = false
1131
+ },
1132
+ /**
1133
+ * 行选择事件
1134
+ * @param row 选中行集合
1135
+ * @param attr 表单项属性
1136
+ */
1137
+ async rowChoose (row, attr, callback) {
1138
+ // 如果配置了自定义函数
1139
+ if (attr.dataChangeFunc) {
1140
+ await executeStrFunction(attr.dataChangeFunc, [this.form, this.setForm, {
1141
+ ...attr,
1142
+ selectRows: row
1143
+ }, util, this.mode, runLogic, getConfigByNameAsync])
1144
+ } else {
1145
+ // 默认填充选中行数据到当前表单
1146
+ setDataByRealKey(this.form, row[0])
1147
+ }
1148
+ if (callback) {
1149
+ callback()
1150
+ }
1151
+ },
1152
+ }
1153
+ }
1154
+ </script>
1155
+
1156
+ <style scoped lang="less">
1157
+ :deep(.ant-form-inline .ant-form-item ) {
1158
+ display: block !important;
1159
+ }
1160
+
1161
+ :deep(.ant-form-item-with-help) {
1162
+ margin-bottom: 0;
1163
+ }
1164
+
1165
+ .xFormGroupTitle {
1166
+ font-weight: bold;
1167
+ color: @primary-color;
1168
+ }
1169
+ </style>