vue2-client 1.13.10 → 1.13.12

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 (388) hide show
  1. package/.cursorrules +19 -19
  2. package/.env.gaslink +19 -19
  3. package/.env.his +19 -19
  4. package/.env.iot +19 -19
  5. package/.env.liuli +19 -19
  6. package/.env.revenue +19 -19
  7. package/.env.scada +19 -19
  8. package/.eslintrc.js +90 -90
  9. package/CHANGELOG.md +824 -824
  10. package/Components.md +60 -60
  11. package/docs/Logic/345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +45 -45
  12. package/docs/LowCode/lowcode.md +155 -155
  13. package/docs/LowCode/lowcodeForDeveloper.md +230 -230
  14. package/docs/index.md +30 -30
  15. package/index.js +31 -31
  16. package/jest-transform-stub.js +8 -8
  17. package/jest.setup.js +7 -7
  18. package/jsconfig.json +19 -19
  19. package/package.json +1 -1
  20. package/public/his/editor/editor.html +51 -51
  21. package/public/his/editor/mock/bind_data.html +779 -779
  22. package/public/his/editor/mock/data_table.html +40 -40
  23. package/public/his/editor/mock/sign.html +75 -75
  24. package/public/his/editor/vender/JsBarcode.all.js +3669 -3669
  25. package/public/his/editor/vender/date97/My97DatePicker.htm +65 -65
  26. package/public/his/editor/vender/date97/WdatePicker.js +677 -677
  27. package/public/his/editor/vender/date97/calendar.js +4 -4
  28. package/public/his/editor/vender/date97/lang/en.js +13 -13
  29. package/public/his/editor/vender/date97/lang/zh-cn.js +13 -13
  30. package/public/his/editor/vender/date97/lang/zh-tw.js +13 -13
  31. package/public/his/editor/vender/date97/skin/WdatePicker.css +10 -10
  32. package/public/his/editor/vender/date97/skin/default/datepicker.css +328 -328
  33. package/public/his/editor/vender/date97/skin/ext/datepicker.css +308 -308
  34. package/public/his/editor/vender/date97/skin/whyGreen/datepicker.css +255 -255
  35. package/public/his/editor/vender/diff.js +1627 -1627
  36. package/public/his/editor/vender/editor.js +1 -1
  37. package/public/his/editor/vender/fabric.js +31187 -31187
  38. package/public/his/editor/vender/jquery/jquery.base64.js +190 -190
  39. package/public/his/editor/vender/jquery/jquery.js +10872 -10872
  40. package/public/his/editor/vender/jquery/jquery.print.js +255 -255
  41. package/public/his/editor/vender/jquery/zTreeStyle/zTreeStyle.css +96 -96
  42. package/public/his/editor/vender/mui/mui.min.css +4 -4
  43. package/public/his/editor/vender/mui/mui.min.js +5 -5
  44. package/public/his/editor/vender/mui/mui.picker.min.css +6 -6
  45. package/public/his/editor/vender/mui/mui.picker.min.js +6 -6
  46. package/public/his/editor/vender/qrcode.js +7 -7
  47. package/public/his/editor/vender/requirejs/require.js +2145 -2145
  48. package/public/his/editor/vender/signature/jSignature.CompressorSVG.js +518 -518
  49. package/public/his/editor/vender/signature/jSignature.UndoButton.js +164 -164
  50. package/public/his/editor/vender/signature/jSignature.js +1486 -1486
  51. package/public/his/editor/vender/validator.js +5094 -5094
  52. package/public/his/editor/vender/weui/weui.css +5659 -5659
  53. package/public/his/editor/vender/weui/weui.min.css +4 -4
  54. package/public/his/editor/vender/weui/weui.min.js +11 -11
  55. package/public/index.html +27 -27
  56. package/src/ReportView.js +19 -19
  57. package/src/assets/img/querySlotDemo.svg +15 -15
  58. package/src/assets/svg/badtwo.svg +1 -1
  59. package/src/assets/svg/goodtwo.svg +1 -1
  60. package/src/base-client/components/AI/AskAiBtn.vue +136 -136
  61. package/src/base-client/components/AI/demo.vue +31 -31
  62. package/src/base-client/components/common/AMisRender/index.js +3 -3
  63. package/src/base-client/components/common/AMisRender/index.vue +263 -263
  64. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +470 -470
  65. package/src/base-client/components/common/AddressSearchCombobox/IcMapIcon.vue +16 -16
  66. package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
  67. package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
  68. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  69. package/src/base-client/components/common/CitySelect/index.js +3 -3
  70. package/src/base-client/components/common/CitySelect/index.md +109 -109
  71. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  72. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  73. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  74. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  75. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  76. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  77. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  78. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  79. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  80. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  81. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  82. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  83. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  84. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  85. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  86. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
  87. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +413 -413
  88. package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
  89. package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +728 -728
  90. package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
  91. package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +219 -219
  92. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
  93. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
  94. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
  95. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
  96. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
  97. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
  98. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
  99. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  100. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  101. package/src/base-client/components/common/Recording/Recording.vue +243 -243
  102. package/src/base-client/components/common/Recording/index.js +3 -3
  103. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  104. package/src/base-client/components/common/Tree/index.js +2 -2
  105. package/src/base-client/components/common/Upload/index.js +3 -3
  106. package/src/base-client/components/common/XAddForm/XAddForm.vue +113 -113
  107. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +1156 -1156
  108. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  109. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
  110. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  111. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  112. package/src/base-client/components/common/XAddReport/index.js +3 -3
  113. package/src/base-client/components/common/XAddReport/index.md +56 -56
  114. package/src/base-client/components/common/XBadge/XBadge.vue +94 -94
  115. package/src/base-client/components/common/XButtons/XButtonDemo.vue +28 -28
  116. package/src/base-client/components/common/XButtons/XButtons.vue +71 -71
  117. package/src/base-client/components/common/XButtons/index.js +3 -3
  118. package/src/base-client/components/common/XButtons/index.md +61 -61
  119. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  120. package/src/base-client/components/common/XCheckList/XCheckList.vue +106 -106
  121. package/src/base-client/components/common/XCheckList/XCheckListDemo.vue +41 -41
  122. package/src/base-client/components/common/XCollapse/XCollapseDemo.vue +15 -0
  123. package/src/base-client/components/common/XDataCard/index.js +3 -3
  124. package/src/base-client/components/common/XDataCard/index.md +1 -1
  125. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  126. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  127. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  128. package/src/base-client/components/common/XDatePicker/demo.vue +153 -153
  129. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  130. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  131. package/src/base-client/components/common/XDetailsView/XDetailsView.vue +238 -238
  132. package/src/base-client/components/common/XDetailsView/index.js +3 -3
  133. package/src/base-client/components/common/XForm/XForm.vue +404 -404
  134. package/src/base-client/components/common/XForm/XFormItem.vue +1310 -1310
  135. package/src/base-client/components/common/XForm/XStatusButton.vue +54 -54
  136. package/src/base-client/components/common/XForm/XTreeSelect.vue +270 -270
  137. package/src/base-client/components/common/XForm/index.md +178 -178
  138. package/src/base-client/components/common/XForm/itemComponent/XClickChangeBtn/index.vue +49 -49
  139. package/src/base-client/components/common/XFormGroup/index.js +3 -3
  140. package/src/base-client/components/common/XFormGroup/index.md +38 -38
  141. package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
  142. package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
  143. package/src/base-client/components/common/XFormTable/demo.vue +76 -76
  144. package/src/base-client/components/common/XFormTable/index.md +92 -92
  145. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +167 -167
  146. package/src/base-client/components/common/XLabelSelect/XLabelSelect.vue +110 -110
  147. package/src/base-client/components/common/XLabelSelect/XLabelSelectDemo.vue +35 -35
  148. package/src/base-client/components/common/XLicensePlate/XLicensePlate.vue +193 -193
  149. package/src/base-client/components/common/XLicensePlate/XLicensePlateDemo.vue +48 -48
  150. package/src/base-client/components/common/XPrint/OpenInvoice.vue +21 -21
  151. package/src/base-client/components/common/XPrint/PrintBill.vue +302 -302
  152. package/src/base-client/components/common/XPrint/PrintHtml.js +98 -98
  153. package/src/base-client/components/common/XPrint/css/hiPrintCss.js +359 -359
  154. package/src/base-client/components/common/XPrint/css/lodopCss.js +26 -26
  155. package/src/base-client/components/common/XPrint/css/print-lock.css +351 -351
  156. package/src/base-client/components/common/XPrint/index.vue +97 -97
  157. package/src/base-client/components/common/XReport/XReport.vue +892 -892
  158. package/src/base-client/components/common/XReport/XReportDesign.vue +463 -463
  159. package/src/base-client/components/common/XReport/XReportJsonRender.vue +381 -381
  160. package/src/base-client/components/common/XReport/index.js +3 -3
  161. package/src/base-client/components/common/XReport/index.md +44 -44
  162. package/src/base-client/components/common/XReport/print.js +186 -186
  163. package/src/base-client/components/common/XReportDrawer/index.js +3 -3
  164. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +44 -44
  165. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +712 -712
  166. package/src/base-client/components/common/XReportGrid/index.js +3 -3
  167. package/src/base-client/components/common/XReportGrid/index.md +44 -44
  168. package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
  169. package/src/base-client/components/common/XReportSlot/index.js +3 -3
  170. package/src/base-client/components/common/XReportSlot/index.md +48 -48
  171. package/src/base-client/components/common/XSimpleDescriptions/XSimpleDescriptions.vue +166 -166
  172. package/src/base-client/components/common/XSimpleDescriptions/index.js +3 -3
  173. package/src/base-client/components/common/XSimpleDescriptions/index.md +7 -7
  174. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  175. package/src/base-client/components/common/XStepView/index.js +3 -3
  176. package/src/base-client/components/common/XStepView/index.md +31 -31
  177. package/src/base-client/components/common/XTab/XTabDemo.vue +22 -22
  178. package/src/base-client/components/common/XTab/index.js +3 -3
  179. package/src/base-client/components/common/XTable/CustomFuncCel.vue +51 -51
  180. package/src/base-client/components/common/XTable/TableCellRenderer.vue +161 -161
  181. package/src/base-client/components/common/XTable/XTable.vue +1361 -1361
  182. package/src/base-client/components/common/XTable/XTableWrapper.vue +257 -257
  183. package/src/base-client/components/common/XTable/index.md +255 -255
  184. package/src/base-client/components/common/XTagGroup/index.vue +52 -52
  185. package/src/base-client/components/common/XTree/XTree.vue +424 -424
  186. package/src/base-client/components/common/XTree/index.js +3 -3
  187. package/src/base-client/components/common/XTree/index.md +36 -36
  188. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +113 -113
  189. package/src/base-client/components/common/XTreeOne/XTreeOnePro.vue +128 -128
  190. package/src/base-client/components/common/richTextModal/index.vue +56 -56
  191. package/src/base-client/components/common/richTextModal/richDemo.vue +48 -48
  192. package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +38 -5
  193. package/src/base-client/components/his/XHisEditor/XHisEditor.vue +3 -0
  194. package/src/base-client/components/his/XHisEditor/index.js +3 -3
  195. package/src/base-client/components/his/XSelect/XSelect.vue +72 -72
  196. package/src/base-client/components/his/XTitle/XTitle.vue +39 -39
  197. package/src/base-client/components/index.js +51 -51
  198. package/src/base-client/components/layout/XPageView/XErrorView.vue +11 -11
  199. package/src/base-client/components/layout/XPageView/XPageView.vue +155 -155
  200. package/src/base-client/components/layout/XPageView/index.js +3 -3
  201. package/src/base-client/components/layout/XPageView/index.md +38 -38
  202. package/src/base-client/components/layout/XTreeView/XTreeView.vue +130 -130
  203. package/src/base-client/components/layout/XTreeView/index.js +3 -3
  204. package/src/base-client/components/layout/XTreeView/index.md +46 -46
  205. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  206. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  207. package/src/base-client/plugins/AppData.js +126 -126
  208. package/src/base-client/plugins/Config.js +19 -19
  209. package/src/base-client/plugins/GetLoginInfoService.js +183 -183
  210. package/src/base-client/plugins/Recording.js +258 -258
  211. package/src/base-client/plugins/index.js +23 -23
  212. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  213. package/src/components/Charts/Bar.vue +62 -62
  214. package/src/components/Charts/ChartCard.vue +134 -134
  215. package/src/components/Charts/Liquid.vue +67 -67
  216. package/src/components/Charts/MiniArea.vue +39 -39
  217. package/src/components/Charts/MiniBar.vue +39 -39
  218. package/src/components/Charts/MiniProgress.vue +75 -75
  219. package/src/components/Charts/MiniSmoothArea.vue +40 -40
  220. package/src/components/Charts/Radar.vue +68 -68
  221. package/src/components/Charts/RankList.vue +77 -77
  222. package/src/components/Charts/TagCloud.vue +113 -113
  223. package/src/components/Charts/TransferBar.vue +64 -64
  224. package/src/components/Charts/Trend.vue +82 -82
  225. package/src/components/Charts/chart.less +12 -12
  226. package/src/components/Charts/smooth.area.less +13 -13
  227. package/src/components/CodeMirror/inedx.vue +118 -118
  228. package/src/components/CodeMirror/setting.js +40 -40
  229. package/src/components/FilePreview/FilePreviewDemo.vue +30 -30
  230. package/src/components/HeightScanner/index.vue +571 -571
  231. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  232. package/src/components/NumberInfo/index.js +3 -3
  233. package/src/components/NumberInfo/index.less +54 -54
  234. package/src/components/NumberInfo/index.md +43 -43
  235. package/src/components/STable/index.js +437 -437
  236. package/src/components/card/ChartCard.vue +79 -79
  237. package/src/components/chart/Bar.vue +60 -60
  238. package/src/components/chart/MiniArea.vue +67 -67
  239. package/src/components/chart/MiniBar.vue +59 -59
  240. package/src/components/chart/MiniProgress.vue +57 -57
  241. package/src/components/chart/Radar.vue +80 -80
  242. package/src/components/chart/RankingList.vue +60 -60
  243. package/src/components/chart/Trend.vue +79 -79
  244. package/src/components/chart/index.less +9 -9
  245. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  246. package/src/components/checkbox/ImgCheckbox.vue +117 -117
  247. package/src/components/checkbox/ImgCheckboxGroup.vue +76 -76
  248. package/src/components/checkbox/index.js +9 -9
  249. package/src/components/exception/ExceptionPage.vue +70 -70
  250. package/src/components/g2Charts/constants.js +202 -202
  251. package/src/components/g2Charts/demo.vue +808 -808
  252. package/src/components/g2Charts/designer.vue +228 -228
  253. package/src/components/g2Charts/designerBaseConfig.vue +61 -61
  254. package/src/components/g2Charts/designerDataConfig.vue +259 -259
  255. package/src/components/g2Charts/designerStyleConfig.vue +16 -16
  256. package/src/components/g2Charts/index.vue +397 -397
  257. package/src/components/index.js +36 -36
  258. package/src/components/input/IInput.vue +66 -66
  259. package/src/components/menu/SideMenu.vue +75 -75
  260. package/src/components/menu/menu.js +273 -273
  261. package/src/components/setting/Setting.vue +234 -234
  262. package/src/components/tool/AStepItem.vue +60 -60
  263. package/src/config/CreateQueryConfig.js +325 -325
  264. package/src/config/default/antd.config.js +89 -89
  265. package/src/config/default/setting.config.js +55 -55
  266. package/src/font-style/font.css +4 -4
  267. package/src/layouts/CommonLayout.vue +56 -56
  268. package/src/layouts/PageLayout.vue +151 -151
  269. package/src/layouts/SinglePageView.vue +136 -136
  270. package/src/layouts/header/AdminHeader.vue +132 -132
  271. package/src/layouts/header/HeaderNotice.vue +177 -177
  272. package/src/layouts/header/InstitutionDetail.vue +181 -181
  273. package/src/layouts/tabs/TabsHead.vue +189 -189
  274. package/src/layouts/tabs/TabsView.vue +389 -389
  275. package/src/lib.js +1 -1
  276. package/src/main.js +34 -34
  277. package/src/mixins/formValidationMixin.js +46 -46
  278. package/src/mock/extend/index.js +84 -84
  279. package/src/mock/goods/index.js +108 -108
  280. package/src/pages/AMisDemo/AMisDemo.vue +325 -325
  281. package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
  282. package/src/pages/DefaultExample/index.vue +77 -77
  283. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  284. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  285. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  286. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  287. package/src/pages/DynamicStatistics/FavoriteList.vue +50 -50
  288. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  289. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  290. package/src/pages/DynamicStatistics/index.vue +282 -282
  291. package/src/pages/Example/childIndex.vue +15 -15
  292. package/src/pages/Example/index.vue +30 -30
  293. package/src/pages/NewDynamicStatistics/ChartSelector.vue +331 -331
  294. package/src/pages/NewDynamicStatistics/DataTabs.vue +122 -122
  295. package/src/pages/NewDynamicStatistics/DynamicTable.vue +128 -128
  296. package/src/pages/NewDynamicStatistics/EvaluationArea.vue +69 -69
  297. package/src/pages/NewDynamicStatistics/FavoriteList.vue +50 -50
  298. package/src/pages/NewDynamicStatistics/QuestionHistoryAndFavorites.vue +289 -289
  299. package/src/pages/NewDynamicStatistics/SearchBar.vue +193 -193
  300. package/src/pages/NewDynamicStatistics/index.vue +258 -258
  301. package/src/pages/Recording/index.vue +77 -77
  302. package/src/pages/ReportGrid/index.vue +76 -76
  303. package/src/pages/ServiceReview/index.vue +284 -284
  304. package/src/pages/SubExample/index.vue +26 -26
  305. package/src/pages/WorkflowDetail/WorkflowDetail.vue +235 -235
  306. package/src/pages/WorkflowDetail/WorkflowPageDetail/LeaveMessage.vue +131 -131
  307. package/src/pages/WorkflowDetail/WorkflowPageDetail/TrimTextTail.vue +23 -23
  308. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformation.vue +302 -302
  309. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformationDetails.vue +276 -276
  310. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandleReso.vue +997 -997
  311. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +222 -222
  312. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkOrderParentDetails.vue +233 -233
  313. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowDetailResso.vue +261 -261
  314. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowListResolution.vue +248 -248
  315. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowLog.vue +73 -73
  316. package/src/pages/XPageViewExample/index.vue +38 -38
  317. package/src/pages/XReportView/index.vue +64 -64
  318. package/src/pages/XTreeOneProExample/index.vue +67 -67
  319. package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
  320. package/src/pages/login/Login.vue +378 -378
  321. package/src/pages/login/LoginV3.vue +389 -389
  322. package/src/pages/lowCode/lowCodeEditor.vue +1219 -1219
  323. package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
  324. package/src/pages/report/ReportTable.js +124 -124
  325. package/src/pages/resourceManage/orgListManage.vue +98 -98
  326. package/src/pages/system/dictionary/index.vue +44 -44
  327. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  328. package/src/pages/system/monitor/operLog/index.vue +37 -37
  329. package/src/pages/system/settings/modifyPassword.vue +117 -117
  330. package/src/pages/system/ticket/index.vue +480 -480
  331. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  332. package/src/pages/userInfoDetailManage/ChangeMeterRecordQuery/index.vue +64 -64
  333. package/src/pages/userInfoDetailManage/FillCardRecordQuery/index.vue +76 -76
  334. package/src/pages/userInfoDetailManage/FillGasRecordQuery/index.vue +74 -74
  335. package/src/pages/userInfoDetailManage/InfoChangeRecordQuery/index.vue +64 -64
  336. package/src/pages/userInfoDetailManage/InstructRecordQuery/index.vue +64 -64
  337. package/src/pages/userInfoDetailManage/MachineRecordQuery/index.vue +74 -74
  338. package/src/pages/userInfoDetailManage/MeterParamRecordQuery/index.vue +64 -64
  339. package/src/pages/userInfoDetailManage/OtherChargeRecordQuery/index.vue +74 -74
  340. package/src/pages/userInfoDetailManage/TransferRecordQuery/index.vue +66 -66
  341. package/src/pages/userInfoDetailManage/UserHandRecordQuery/index.vue +86 -86
  342. package/src/pages/userInfoDetailManage/UserRecordQuery/index.vue +73 -73
  343. package/src/pages/userInfoDetailManage/WatchCollectionRecordQuery/index.vue +64 -64
  344. package/src/plugins/EventLogPlugin.js +33 -33
  345. package/src/plugins/FindParentsData.js +17 -17
  346. package/src/router/async/config.async.js +35 -35
  347. package/src/router/async/router.map.js +126 -119
  348. package/src/router/index.js +27 -27
  349. package/src/router.js +19 -19
  350. package/src/services/DataModel.js +30 -30
  351. package/src/services/LodopFuncs.js +137 -137
  352. package/src/services/api/TicketDetailsViewApi.js +46 -46
  353. package/src/services/api/cas.js +79 -79
  354. package/src/services/api/common.js +346 -346
  355. package/src/services/api/entity.js +18 -18
  356. package/src/services/api/index.js +17 -17
  357. package/src/services/api/restTools.js +145 -145
  358. package/src/services/api/workFlow.js +63 -63
  359. package/src/services/apiService.js +16 -16
  360. package/src/store/modules/account.js +115 -115
  361. package/src/store/modules/index.js +5 -5
  362. package/src/store/modules/lowCode.js +33 -33
  363. package/src/store/modules/setting.js +119 -119
  364. package/src/theme/default/style.less +58 -58
  365. package/src/theme/global.less +159 -159
  366. package/src/utils/authority-utils.js +85 -85
  367. package/src/utils/errorCode.js +6 -6
  368. package/src/utils/formatter.js +74 -74
  369. package/src/utils/htmlToPDF.js +108 -108
  370. package/src/utils/htmlToPDFApi.js +5 -5
  371. package/src/utils/login.js +188 -188
  372. package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
  373. package/src/utils/lowcode/lowcodeLog.js +29 -29
  374. package/src/utils/lowcode/lowcodeUtils.js +373 -373
  375. package/src/utils/lowcode/registerComponentForEditor.js +1 -1
  376. package/src/utils/lowcode/registerComponentForRender.js +11 -11
  377. package/src/utils/map-utils.js +47 -47
  378. package/src/utils/reg.js +95 -95
  379. package/src/utils/runEvalFunction.js +14 -14
  380. package/src/utils/theme-color-replacer-extend.js +92 -92
  381. package/src/utils/util.js +329 -329
  382. package/src/utils/waterMark.js +31 -31
  383. package/test/Amis.spec.js +164 -164
  384. package/test/Tree.spec.js +168 -168
  385. package/test/myDialog.spec.js +47 -47
  386. package/test/util.test.js +53 -53
  387. package/test/v3Api.test.js +1984 -1984
  388. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,1156 +1,1156 @@
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
- },
186
- props: {},
187
- data () {
188
- return {
189
- DEFAULT_GROUP_NAME,
190
- // 预览模式
191
- viewMode: false,
192
- // 是否处理表单Key值
193
- isHandleFormKey: true,
194
- // 内容加载是否完成
195
- loaded: false,
196
- // 业务类型
197
- businessType: '',
198
- // 业务标题
199
- title: '',
200
- // 新增或修改业务是否执行中
201
- loading: false,
202
- // 表单Model
203
- form: {},
204
- // 配置名称
205
- configName: undefined,
206
- // 配置内容,用于查询配置生成器的预览
207
- configContent: undefined,
208
- // 表单项集合
209
- formItems: [],
210
- // 服务名称
211
- serviceName: undefined,
212
- // 是否显示提交按钮
213
- showSubmitBtn: true,
214
- // 修改有文件的表单时使用
215
- files: [],
216
- images: [],
217
- // 校验
218
- rules: {},
219
- // 调用logic获取数据源的追加参数
220
- getDataParams: {},
221
- // 动态简易表单集合
222
- simpleFormJsonData: {},
223
- // 待修改的数据集
224
- modifyModelData: {},
225
- // 当前环境
226
- env: 'prod',
227
- // 表单主键
228
- primaryKey: null,
229
- // 表单模式 horizontal | vertical | inline
230
- layout: 'horizontal',
231
- // 提交按钮名称
232
- btnName: '提交',
233
- // 提交按钮位置 start / center / end
234
- btnPlace: 'center',
235
- // 子表是否排在前面
236
- childTablePriority: false
237
- }
238
- },
239
- computed: {
240
- // 过滤出用于新增/修改场景的表单项
241
- realJsonData: function () {
242
- return this.formItems.filter((item) => {
243
- return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
244
- })
245
- },
246
- // 表单项组 / 不是 数据组
247
- groups: function () {
248
- if (!this.realJsonData || this.realJsonData.length === 0) {
249
- return [{
250
- groupName: DEFAULT_GROUP_NAME,
251
- realJsonData: this.realJsonData,
252
- xAddFormLayout: 'horizontal'
253
- }]
254
- }
255
- const uniqueGroups = new Set(this.realJsonData.map(item => item.group).filter(Boolean))
256
- const allGroup = Array.from(uniqueGroups).map(group => {
257
- return {
258
- groupName: group,
259
- realJsonData: this.realJsonData.filter(item => item.group === group),
260
- xAddFormLayout: 'horizontal'
261
- }
262
- })
263
- // 判断每一组得formJson 长度相加是否等于 realJsonData 长度 避免错误数据
264
- if (allGroup.reduce((total, item) => total + item.realJsonData.length, 0) === this.realJsonData.length) {
265
- return allGroup
266
- } else {
267
- return [{
268
- groupName: DEFAULT_GROUP_NAME,
269
- realJsonData: this.realJsonData,
270
- xAddFormLayout: 'horizontal'
271
- }]
272
- }
273
- },
274
- // 拥有自定义校验函数得表单项
275
- customValidateItems: function () {
276
- return this.formItems.filter((item) => {
277
- return item?.rule?.type === 'customJs'
278
- })
279
- },
280
- // 过滤出用于新增/修改场景的表单项
281
- groupJsonData: function () {
282
- return this.formItems.filter((item) => {
283
- return item.type === 'group'
284
- }).map((item) => {
285
- item.groupItems = item.groupItems.filter((item) => {
286
- return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
287
- }).map((groupItem) => {
288
- // 只保留第一个下划线后面的内容
289
- // 多层校验规则需要将prop设置为 key1.key2.....
290
- groupItem.prop = `${item.model}.${groupItem.model.substring(groupItem.model.indexOf('_') + 1)}`
291
- groupItem.model = groupItem.model.substring(groupItem.model.indexOf('_') + 1)
292
- return groupItem
293
- })
294
- return item
295
- }
296
- )
297
- },
298
- // 过滤出用于子表数据新增/修改场景的表单项
299
- childTableData: function () {
300
- return this.formItems.filter((item) => {
301
- return item.type === 'childTable'
302
- })
303
- },
304
- // 过滤出用于form子表数据新增/修改场景的表单项
305
- childFormData: function () {
306
- return this.formItems.filter((item) => {
307
- return item.type === 'rowEdit'
308
- })
309
- },
310
- // 过滤出用于静默新增场景的表单项
311
- silenceAddJsonData: function () {
312
- return this.formItems.filter(function (item) {
313
- return item.addOrEdit === 'silenceAdd'
314
- })
315
- },
316
- // 过滤出版本号表单项
317
- versionJsonData: function () {
318
- return this.formItems.filter(function (item) {
319
- return item.addOrEdit === 'version'
320
- })
321
- },
322
- formItemLayoutGen () {
323
- if (this.layout === 'horizontal') {
324
- return {
325
- labelCol: { span: 4, offset: 2 },
326
- wrapperCol: { span: 14 },
327
- }
328
- } else if (this.layout === 'vertical') {
329
- return {}
330
- } else {
331
- if (!this.formItemLayout.labelCol || !this.formItemLayout.wrapperCol) {
332
- return {
333
- labelCol: { span: 8 },
334
- wrapperCol: { span: 16 },
335
- }
336
- }
337
- return {
338
- labelCol: { span: this.formItemLayout.labelCol },
339
- wrapperCol: { span: this.formItemLayout.wrapperCol },
340
- }
341
- }
342
- },
343
- ...mapState('account', { currUser: 'user' })
344
- },
345
- provide () {
346
- return {
347
- getComponentByName: this.getComponentByName,
348
- registerComponent: this.registerComponent,
349
- XFormContext: this,
350
- // 移除必填项
351
- removeRequired: this.removeRequired,
352
- // 设置必填项
353
- setRequired: this.setRequired,
354
- getSelf: () => this,
355
- }
356
- },
357
- /** //todo 本来想要实现 配置 自定义函数时,表单项得红星提示,根据自定义校验函数得返回值来判断
358
- * 但是监听不到父组件formgorup得其他form得变化,所以暂时不实现
359
- */
360
- //
361
- // watch: {
362
- // form: {
363
- // handler (val) {
364
- // // 遍历表单配置
365
- // if (this.customValidateItems.length > 0) {
366
- // for (const item of this.customValidateItems) {
367
- // const itemIndex = this.formItems.findIndex(formItem => formItem.model === item.model)
368
- // if (itemIndex < 0) {
369
- // continue
370
- // }
371
- // try {
372
- // this.customJsValidate(null, val[item.model], (res) => {
373
- // // 如果返回error则设置错误信息
374
- // if (res instanceof Error) {
375
- // // 设置表单项的错误状态
376
- // this.$set(this.formItems[itemIndex], 'tempRequired', true)
377
- // } else {
378
- // // 清除错误状态
379
- // this.$set(this.formItems[itemIndex], 'tempRequired', true)
380
- // }
381
- // }, item)
382
- // } catch (e) {
383
- // console.error(e)
384
- // this.$set(this.formItems[itemIndex], 'tempRequired', true)
385
- // }
386
- // }
387
- // console.log('customValidateItems', JSON.stringify(this.customValidateItems))
388
- // }
389
- // },
390
- // deep: true
391
- // }
392
- // },
393
- mixins: [formValidationMixin],
394
- methods: {
395
- runLogic,
396
- getConfigByNameAsync,
397
- getConfigByName,
398
- init (params) {
399
- const {
400
- configName,
401
- configContent,
402
- formItems,
403
- formJson,
404
- viewMode,
405
- isHandleFormKey,
406
- isKeyHandle = true,
407
- showSubmitBtn = true,
408
- serviceName,
409
- primaryKey,
410
- modifyModelData = {},
411
- businessType,
412
- title,
413
- fixedAddForm = {},
414
- getDataParams = {},
415
- simpleFormJsonData = {},
416
- env = 'prod',
417
- layout,
418
- xAddFormLayout = 'horizontal',
419
- formItemLayout = {},
420
- btnName = '提交',
421
- childTablePriority = false,
422
- btnPlace = 'center'
423
- } = params
424
- this.loaded = false
425
- // 兼容需要省略 传递 layout: res.xAddFormLayout 可以使用 ...res 展开运算符 直接转递
426
- if (xAddFormLayout && layout === undefined) {
427
- this.layout = xAddFormLayout
428
- } else {
429
- this.layout = layout
430
- }
431
- this.formItemLayout = formItemLayout
432
- if ((isHandleFormKey === null || isHandleFormKey === undefined) && !isKeyHandle) {
433
- this.isHandleFormKey = isKeyHandle
434
- } else if (isHandleFormKey) {
435
- this.isHandleFormKey = isHandleFormKey
436
- } else {
437
- this.isHandleFormKey = isKeyHandle
438
- }
439
- this.childTablePriority = childTablePriority
440
- this.configName = configName
441
- this.configContent = configContent
442
- this.formItems = this.getFromItem(formItems, formJson)
443
- this.viewMode = viewMode
444
- this.showSubmitBtn = showSubmitBtn
445
- this.primaryKey = primaryKey
446
- this.serviceName = serviceName
447
- this.businessType = businessType
448
- this.title = title
449
- this.getDataParams = getDataParams
450
- this.simpleFormJsonData = simpleFormJsonData
451
- this.env = env
452
- this.btnName = btnName
453
- this.btnPlace = btnPlace
454
- // 如果 fixedAddForm 有 selected_id 值,并且设置了处理表单key值,则多给 selected_id 加前缀 避免处理错误
455
- if (fixedAddForm.selected_id && this.isHandleFormKey) {
456
- fixedAddForm._selected_id = fixedAddForm.selected_id
457
- delete fixedAddForm.selected_id
458
- }
459
- // 设置普通表单项的相关参数
460
- const formData = Object.assign({}, fixedAddForm)
461
- for (let i = 0; i < this.realJsonData.length; i++) {
462
- const item = this.realJsonData[i]
463
- this.setFormProps(formData, item, null)
464
- }
465
- // 设置表单分组项目相关参数
466
- for (let i = 0; i < this.groupJsonData.length; i++) {
467
- const groupItem = this.groupJsonData[i]
468
- formData[groupItem.model] = {}
469
- for (let j = 0; j < groupItem.groupItems.length; j++) {
470
- const item = groupItem.groupItems[j]
471
- this.setFormProps(formData[groupItem.model], item, item.prop)
472
- }
473
- }
474
- // 设置动态简易表单项的相关参数
475
- for (const key in this.simpleFormJsonData) {
476
- for (const item of this.simpleFormJsonData[key].value) {
477
- item.model = key + '@' + item.model
478
- this.setFormProps(formData, item, null)
479
- }
480
- }
481
-
482
- this.form = formData
483
- // 修改场景下对表单项赋值
484
- if (modifyModelData && modifyModelData.data) {
485
- this.modifyModelData = modifyModelData
486
- if (Object.keys(modifyModelData.data).length > 0) {
487
- this.getModifyModelData(modifyModelData)
488
- }
489
- }
490
- // 处理表单得附件
491
- if (modifyModelData && modifyModelData.files) {
492
- this.files = modifyModelData.files
493
- }
494
- if (modifyModelData && modifyModelData.images) {
495
- this.images = modifyModelData.images
496
- }
497
- this.loaded = true
498
- },
499
- scrollToGroup (index) {
500
- const groupElement = this.$refs[`group-title-${index}`][0]
501
- if (groupElement) {
502
- groupElement.scrollIntoView({ behavior: 'smooth' })
503
- }
504
- },
505
- registerComponent (componentName, component) {
506
- console.log('内部注册', this.$options.name, componentName)
507
- this.$refs[componentName] = component
508
- console.log('内部注册完成', this.$refs)
509
- },
510
- // 根据名字从注册到组件中获取组件
511
- getComponentByName (componentName) {
512
- console.log('内部取组件', this.$options.name, componentName)
513
- console.log('内部组件内容', this.$refs)
514
- return this.$refs[componentName]
515
- },
516
- // 兼容需要省略 传递 [formItems: res.formJson ] 可以使用 ...res 展开运算符 直接转递
517
- getFromItem (formItems, formJson) {
518
- const _formItems = formItems || formJson
519
- if (typeof formItems === 'string') {
520
- return JSON.parse(_formItems)
521
- } else {
522
- return JSON.parse(JSON.stringify(_formItems))
523
- }
524
- },
525
- innerXFormTableEmit (fun, record, id, actionType, index) {
526
- this.$emit(fun, record, id, actionType, index)
527
- },
528
- // 时间组件赋默认值
529
- // .type, item.formDefault
530
- getDateRange ({ type, formDefault: defaultValue, formValueFormat }) {
531
- // const format = type === 'datePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
532
- let format = 'YYYY-MM-DD HH:mm:ss'
533
- if (formValueFormat) {
534
- format = formValueFormat
535
- }
536
- let start
537
- switch (defaultValue) {
538
- case 'curYear':
539
- start = moment().startOf('year').format(format)
540
- break
541
- case 'curMonth':
542
- start = moment().startOf('month').format(format)
543
- break
544
- case 'curDay':
545
- start = moment().startOf('day').format(format)
546
- break
547
- case 'curTime':
548
- start = moment().format(format)
549
- break
550
- default:
551
- return defaultValue
552
- }
553
- return start
554
- },
555
- setFormProps (formData, item, groupItem) {
556
- const rulesKey = `${item.name}${item.model}`
557
- if (formData[item.model] === undefined || formData[item.model] === null) {
558
- formData[item.model] = undefined
559
- }
560
- if (!formData[item.model] && item.formDefault) {
561
- if (['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(item.type)) {
562
- formData[item.model] = this.getDateRange(item)
563
- } else if (['treeSelect', 'select', 'checkbox'].includes(item.type) && ['curOrgId', 'curDepId', 'curUserId'].includes(item.formDefault)) {
564
- if (item.formDefault === 'curOrgId') {
565
- formData[item.model] = item.type === 'select' ? this.currUser.orgid : [this.currUser.orgid]
566
- }
567
- if (item.formDefault === 'curDepId') {
568
- formData[item.model] = item.type === 'select' ? this.currUser.depids : [this.currUser.depids]
569
- }
570
- if (item.formDefault === 'curUserId') {
571
- formData[item.model] = item.type === 'select' ? this.currUser.id : [this.currUser.id]
572
- }
573
- } else {
574
- formData[item.model] = item.formDefault
575
- }
576
- }
577
- // 处理表单校验情况
578
- if (item.rule) {
579
- if (groupItem) {
580
- this.rules[groupItem] = []
581
- } else {
582
- this.rules[rulesKey] = []
583
- }
584
- const required = item.rule.required ? item.rule.required === true || item.rule.required === 'true' : false
585
- let trigger
586
- let message
587
- if (required) {
588
- switch (item.type) {
589
- case 'select':
590
- case 'checkbox':
591
- case 'radio':
592
- case 'treeSelect':
593
- case 'rangePicker':
594
- case 'monthPicker':
595
- case 'yearPicker':
596
- case 'datePicker':
597
- case 'file':
598
- case 'image':
599
- case 'citySelect':
600
- case 'addressSearch':
601
- case 'personSetting':
602
- message = '请选择' + item.name
603
- trigger = 'change'
604
- break
605
- default:
606
- message = '请输入' + item.name
607
- trigger = 'blur'
608
- }
609
- if (groupItem) {
610
- this.rules[groupItem].push({
611
- required: true,
612
- message: message,
613
- trigger: trigger
614
- })
615
- } else {
616
- this.rules[rulesKey].push({
617
- required: true,
618
- message: message,
619
- trigger: trigger
620
- })
621
- }
622
- }
623
-
624
- switch (item.rule.type) {
625
- case 'number':
626
- case 'integer':
627
- case 'float':
628
- // eslint-disable-next-line no-case-declarations
629
- let defaultValue
630
- // eslint-disable-next-line no-case-declarations
631
- let message
632
- switch (item.rule.type) {
633
- case 'number':
634
- item.numberInput = true
635
- message = '数字'
636
- defaultValue = 0
637
- break
638
- case 'integer':
639
- item.numberInput = true
640
- message = '整数'
641
- defaultValue = 0
642
- break
643
- case 'float':
644
- item.numberInput = true
645
- message = '小数'
646
- defaultValue = 0.0
647
- break
648
- }
649
- if (groupItem) {
650
- this.rules[groupItem].push({
651
- type: item.rule.type,
652
- message: item.name + '必须为' + message,
653
- transform: (value) => {
654
- if (value && value.length !== 0) {
655
- return Number(value)
656
- } else {
657
- return defaultValue
658
- }
659
- },
660
- trigger: 'blur'
661
- })
662
- } else {
663
- this.rules[rulesKey].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
- }
676
- break
677
- case 'email': {
678
- const validator = (rule, value, callback) => {
679
- if (value && !REG_EMAIL.test(value)) {
680
- callback(new Error('请输入正确的邮箱地址'))
681
- } else {
682
- callback()
683
- }
684
- }
685
- this.rules[groupItem || rulesKey].push({
686
- type: 'email',
687
- validator: validator,
688
- message: '请输入正确的邮箱地址',
689
- trigger: 'blur'
690
- })
691
- break
692
- }
693
- case 'userPhone': {
694
- this.rules[groupItem || rulesKey].push({
695
- type: 'userPhone',
696
- validator: (rule, value, callback) => {
697
- if (value && !REG_PHONE.test(value)) {
698
- callback(new Error('请输入正确的手机号码'))
699
- } else {
700
- callback()
701
- }
702
- },
703
- message: '请输入正确的手机号码',
704
- trigger: 'blur'
705
- })
706
- break
707
- }
708
- case 'idNumber': {
709
- this.rules[groupItem || rulesKey].push({
710
- validator: (rule, value, callback) => {
711
- if (value && !checkIdNumber(value)) {
712
- callback(new Error('请输入正确的身份证号码'))
713
- } else {
714
- callback()
715
- }
716
- },
717
- trigger: 'blur'
718
- })
719
- break
720
- }
721
- case 'landlineNumber': {
722
- this.rules[rulesKey].push({
723
- validator: (rule, value, callback) => {
724
- if (value && !REG_LANDLINE.test(value)) {
725
- callback(new Error('请输入正确的座机号码'))
726
- } else {
727
- callback()
728
- }
729
- },
730
- trigger: 'blur'
731
- })
732
- break
733
- }
734
- // 大于0
735
- case 'greaterThanZero': {
736
- item.numberInput = true
737
- this.rules[rulesKey].push({
738
- validator: (rule, value, callback) => {
739
- if (isNaN(value) || value <= 0) {
740
- callback(new Error('请输入一个大于0的数字'))
741
- } else {
742
- callback()
743
- }
744
- },
745
- trigger: 'blur'
746
- })
747
- break
748
- }
749
- // 大于等于0
750
- case 'greaterThanOrEqualZero': {
751
- item.numberInput = true
752
- this.rules[rulesKey].push({
753
- validator: (rule, value, callback) => {
754
- if (isNaN(value) || value < 0) {
755
- callback(new Error('请输入一个大于等于0的数字'))
756
- } else {
757
- callback()
758
- }
759
- },
760
- trigger: 'blur'
761
- })
762
- break
763
- }
764
- case 'stringLength': {
765
- this.rules[rulesKey].push({
766
- validator: (rule, value, callback) => {
767
- if (value && value.length < item.rule.minLen) {
768
- callback(new Error('长度不能少于' + item.rule.minLen + '个字符'))
769
- } else if (value && value.length > item.rule.maxLen) {
770
- callback(new Error('长度不能超过' + item.rule.maxLen + '个字符'))
771
- } else {
772
- callback()
773
- }
774
- },
775
- trigger: 'blur'
776
- })
777
- break
778
- }
779
- case 'customJs': {
780
- this.rules[rulesKey].push({
781
- validator: (rule, value, callback) => {
782
- this.customJsValidate(rule, value, callback, item)
783
- },
784
- trigger: 'blur'
785
- })
786
- break
787
- }
788
- }
789
- }
790
- },
791
- childTableMounted (item) {
792
- // 子表初始化时,设置表格数据
793
- if (this.form[item.model] && this.form[item.model].length > 0) {
794
- this.$refs[`childXFormTable_${item.model}`][0].setTableData(this.form[item.model])
795
- }
796
- },
797
- customJsValidate (rule, value, callback, item) {
798
- if (item.rule.customValidatorFunc) {
799
- executeStrFunctionByContext(this, item.rule.customValidatorFunc, [rule, value, callback, this.form, item, this.util, runLogic, getConfigByNameAsync])
800
- } else {
801
- callback()
802
- }
803
- },
804
- itemDisabled (value) {
805
- return (this.businessType === '新增' && value.addOrEdit === 'edit') ||
806
- (this.businessType === '修改' && value.addOrEdit === 'add')
807
- },
808
- readonly (value) {
809
- return value.addOrEdit === 'readonly'
810
- },
811
- async onSubmit () {
812
- const valid = await this.validateForm()
813
- if (!valid) return false
814
- if (this.viewMode) {
815
- this.$message.info('预览模式禁止新增和修改')
816
- return false
817
- }
818
- this.loading = true
819
- const requestForm = this.prepareForm()
820
- await this.appendSilenceAddFields(requestForm)
821
- const realForm = this.handleFormKeys(requestForm)
822
- // 增加子表数据
823
- if (this.childTableData.length > 0) {
824
- for (const item of this.childTableData) {
825
- const childModel = item.model
826
- const childDataRef = this.$refs['childXFormTable_' + item.model][0].getTableData()
827
- const childData = []
828
- for (const item of childDataRef) {
829
- childData.push(JSON.parse(JSON.stringify(item)))
830
- }
831
- for (let i = 0; i < childData.length; i++) {
832
- childData[i] = this.handleFormKeys(childData[i])
833
- // 外键不需要带表别名,所以此处放到表单处理后赋值
834
- if (realForm.id) {
835
- childData[i][item.childTableForeignKeyName] = realForm.id
836
- }
837
- }
838
- realForm[childModel] = childData
839
- }
840
- }
841
- // 增加form子表数据
842
- if (this.childFormData.length > 0) {
843
- for (const item of this.childFormData) {
844
- const childModel = item.model
845
- const childData = this.$refs[item.model].getTableData()
846
- for (let i = 0; i < childData.length; i++) {
847
- childData[i] = this.handleFormKeys(childData[i], true)
848
- // 外键不需要带表别名,所以此处放到表单处理后赋值
849
- if (realForm.id) {
850
- childData[i][item.foreignKey] = realForm.id
851
- }
852
- }
853
- realForm[childModel] = childData
854
- }
855
- }
856
- if (this.$listeners.onSubmit) {
857
- // 交由父级处理
858
- this.$emit('onSubmit', {
859
- businessType: this.businessType,
860
- serviceName: this.serviceName,
861
- realForm: realForm,
862
- currUserName: this.currUser.name,
863
- currUserId: this.currUser.id,
864
- orgId: this.currUser.orgid
865
- })
866
- } else {
867
- this.defaultSubmit(realForm)
868
- }
869
- },
870
-
871
- async asyncSubmit () {
872
- return new Promise((resolve, reject) => {
873
- this.$refs.selectForm.validate(async valid => {
874
- if (!valid) {
875
- reject(new Error('Form validation failed'))
876
- return
877
- }
878
- this.loading = true
879
- const requestForm = this.prepareForm()
880
- await this.appendSilenceAddFields(requestForm)
881
- const realForm = this.handleFormKeys(requestForm)
882
- resolve({
883
- realForm,
884
- businessType: this.businessType,
885
- serviceName: this.serviceName,
886
- currUserName: this.currUser.name,
887
- currUserId: this.currUser.id,
888
- orgId: this.currUser.orgid
889
- })
890
- })
891
- })
892
- },
893
-
894
- validateForm () {
895
- return new Promise((resolve) => {
896
- this.$refs.selectForm.validate(valid => resolve(valid))
897
- })
898
- },
899
-
900
- childTableFixedQueryForm (item) {
901
- if (this.modifyModelData?.primaryKeyData) {
902
- const fixedForm = {}
903
- fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
904
- return fixedForm
905
- }
906
- return null
907
- },
908
-
909
- prepareForm () {
910
- const form = { ...this.form }
911
- for (const key of Object.keys(form)) {
912
- const value = form[key]
913
- if (value === null || (typeof value === 'object' && Object.keys(value).length === 0)) {
914
- form[key] = undefined
915
- }
916
- }
917
- return form
918
- },
919
-
920
- async appendSilenceAddFields (form) {
921
- if (this.businessType === '新增') {
922
- for (const item of this.silenceAddJsonData) {
923
- switch (item.silencePurpose) {
924
- case 'createTime':
925
- form[item.model] = formatDate('now')
926
- break
927
- case 'operator':
928
- form[item.model] = this.currUser.name
929
- break
930
- case 'operatorId':
931
- form[item.model] = this.currUser.id
932
- break
933
- case 'orgId':
934
- form[item.model] = this.currUser.orgid
935
- break
936
- case 'orgName':
937
- form[item.model] = this.currUser.orgs
938
- break
939
- case 'depId':
940
- form[item.model] = this.currUser.depids
941
- break
942
- case 'depName':
943
- form[item.model] = this.currUser.deps
944
- break
945
- }
946
- }
947
- for (const item of this.silenceAddJsonData.filter((item) => item.silencePurpose === 'customize')) {
948
- const result = await runLogic(item.silenceSource, form, this.serviceName)
949
- if (result) {
950
- const keys = Object.keys(result)
951
- if (keys.length === 1 && keys[0] === 'value') {
952
- form[item.model] = result.value
953
- } else {
954
- form[item.model] = result
955
- }
956
- } else {
957
- form[item.model] = result
958
- }
959
- }
960
- }
961
- },
962
-
963
- handleFormKeys (form, mustHandleKey = false) {
964
- const realForm = {}
965
- for (const key of Object.keys(form)) {
966
- const value = form[key]
967
- const extraFormKeyTagIndex = key.indexOf('@')
968
- if (extraFormKeyTagIndex !== -1) {
969
- const extraFormKey = key.substring(0, extraFormKeyTagIndex)
970
- const realKey = key.substring(extraFormKeyTagIndex + 1)
971
- if (!realForm[extraFormKey]) {
972
- realForm[extraFormKey] = {}
973
- }
974
- realForm[extraFormKey][realKey] = value
975
- } else {
976
- const realKey = this.isHandleFormKey || mustHandleKey ? this.getRealKey(key, mustHandleKey) : key
977
- // 如果发生重名,不覆盖,把key的别名带上
978
- if (realForm[realKey]) {
979
- realForm[key] = value
980
- } else {
981
- realForm[realKey] = value
982
- }
983
- }
984
- }
985
- return realForm
986
- },
987
- // 默认提交事件
988
- defaultSubmit (realForm, callback) {
989
- // 新增移除id
990
- if (this.businessType === '新增') {
991
- delete realForm.id
992
- }
993
- // 组织请求
994
- const requestParameters = {
995
- queryParamsName: this.configName,
996
- queryParams: this.configContent,
997
- form: realForm,
998
- businessType: this.businessType,
999
- operator: this.currUser.name
1000
- }
1001
- addOrModify(requestParameters, this.serviceName, this.env === 'dev').then(data => {
1002
- this.$message.success(this.businessType + '成功!')
1003
- // commit
1004
- this.$emit('afterSubmit', { type: this.businessType, id: data.id, data: data, form: requestParameters.form })
1005
- this.loading = false
1006
- if (callback) {
1007
- callback()
1008
- }
1009
- }).catch(e => {
1010
- this.loading = false
1011
- this.$message.error(this.businessType + '失败:' + e)
1012
- })
1013
- },
1014
- // 获取表单字段实际值
1015
- getRealKey (key, mustHandleKey = false) {
1016
- if (key === 'selected_id') return key
1017
- if (this.isHandleFormKey || mustHandleKey) {
1018
- return key.substring(key.indexOf('_') + 1)
1019
- } else {
1020
- return key
1021
- }
1022
- },
1023
- /**
1024
- * 获取被修改记录数据
1025
- * @param modifyModelData 被修改记录的数据
1026
- */
1027
- getModifyModelData (modifyModelData) {
1028
- if (modifyModelData.primaryKeyData) {
1029
- this.form = Object.assign(this.form, modifyModelData.primaryKeyData)
1030
- }
1031
- // 对动态简易表单项特殊处理
1032
- for (const key in modifyModelData.data) {
1033
- const realKey = this.isHandleFormKey ? this.getRealKey(key) : key
1034
- if (this.simpleFormJsonData[realKey]) {
1035
- const extraForm = JSON.parse(modifyModelData.data[key])
1036
- for (const key in extraForm) {
1037
- const model = realKey + '@' + key
1038
- this.form[model] = extraForm[key]
1039
- }
1040
- }
1041
- }
1042
- // 对普通表单项处理
1043
- for (let i = 0; i < this.realJsonData.length; i++) {
1044
- if (['FilesId', 'Images'].includes(this.realJsonData[i])) {
1045
- // 附件需要跳过 因为会通过 modifyModelData中的files,images属性给upload赋值
1046
- // 新增修改表单每次提交时只会提交最新添加的文件
1047
- continue
1048
- }
1049
- const item = this.realJsonData[i]
1050
- if (modifyModelData.data[item.model] || modifyModelData.data[item.model] === 0) {
1051
- if (modifyModelData.data[item.model] instanceof Array) {
1052
- this.form[item.model] = modifyModelData.data[item.model]
1053
- } else {
1054
- this.form[item.model] = modifyModelData.data[item.model] + ''
1055
- }
1056
- }
1057
- }
1058
- // 对分组表单进行处理
1059
- for (let i = 0; i < this.groupJsonData.length; i++) {
1060
- const item = this.groupJsonData[i]
1061
- try {
1062
- if (modifyModelData.data[item.model]) {
1063
- this.form[item.model] = JSON.parse(modifyModelData.data[item.model])
1064
- }
1065
- } catch (e) {
1066
- if (modifyModelData.data[item.model]) {
1067
- this.form[item.model] = modifyModelData.data[item.model]
1068
- }
1069
- }
1070
- }
1071
- // 追加版本号信息
1072
- for (const item of this.versionJsonData) {
1073
- if (!modifyModelData.data[item.model]) {
1074
- this.form[item.model] = 0
1075
- } else {
1076
- this.form[item.model] = modifyModelData.data[item.model] + ''
1077
- }
1078
- }
1079
- },
1080
- setForm (obj) {
1081
- this.form = Object.assign(this.form, obj)
1082
- // 给子表赋外键条件
1083
- if (this.childFormData.length > 0) {
1084
- for (const item of this.childFormData) {
1085
- const child = this.$refs[item.model]
1086
- // 获取子表别名,以便在条件上添加别名
1087
- const alias = child.realQueryConfig.tableAliasName
1088
- // 有主键,且主键有值,添加主键条件
1089
- if (this.primaryKey && this.form[this.primaryKey]) {
1090
- const foreignKey = item.foreignKey
1091
- const fixedQueryForm = { [alias + '_' + foreignKey]: this.form[this.primaryKey] }
1092
- if (!child.fixedQueryForm) {
1093
- child.fixedQueryForm = fixedQueryForm
1094
- } else {
1095
- Object.assign(child.fixedQueryForm, fixedQueryForm)
1096
- }
1097
- child.refreshTable()
1098
- }
1099
- }
1100
- }
1101
- },
1102
- setFormWithKey (obj) {
1103
- setDataByRealKey(this.form, obj)
1104
- },
1105
- setFormWithNoKey (obj) {
1106
- setDataByRealKey(this.form, obj)
1107
- },
1108
- emitFunc (func, data, value) {
1109
- this.$emit(func, data, value)
1110
- this.$emit('x-form-item-emit-func', func, data, value)
1111
- },
1112
- // 直接转发事件的函数
1113
- emitEvent (event, ...args) {
1114
- this.$emit(event, ...args)
1115
- },
1116
- close () {
1117
- this.loaded = false
1118
- },
1119
- /**
1120
- * 行选择事件
1121
- * @param row 选中行集合
1122
- * @param attr 表单项属性
1123
- */
1124
- async rowChoose (row, attr, callback) {
1125
- // 如果配置了自定义函数
1126
- if (attr.dataChangeFunc) {
1127
- await executeStrFunction(attr.dataChangeFunc, [this.form, this.setForm, {
1128
- ...attr,
1129
- selectRows: row
1130
- }, util, this.mode, runLogic, getConfigByNameAsync])
1131
- } else {
1132
- // 默认填充选中行数据到当前表单
1133
- setDataByRealKey(this.form, row[0])
1134
- }
1135
- if (callback) {
1136
- callback()
1137
- }
1138
- },
1139
- }
1140
- }
1141
- </script>
1142
-
1143
- <style scoped lang="less">
1144
- :deep(.ant-form-inline .ant-form-item ) {
1145
- display: block !important;
1146
- }
1147
-
1148
- :deep(.ant-form-item-with-help) {
1149
- margin-bottom: 0;
1150
- }
1151
-
1152
- .xFormGroupTitle {
1153
- font-weight: bold;
1154
- color: @primary-color;
1155
- }
1156
- </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
+ },
186
+ props: {},
187
+ data () {
188
+ return {
189
+ DEFAULT_GROUP_NAME,
190
+ // 预览模式
191
+ viewMode: false,
192
+ // 是否处理表单Key值
193
+ isHandleFormKey: true,
194
+ // 内容加载是否完成
195
+ loaded: false,
196
+ // 业务类型
197
+ businessType: '',
198
+ // 业务标题
199
+ title: '',
200
+ // 新增或修改业务是否执行中
201
+ loading: false,
202
+ // 表单Model
203
+ form: {},
204
+ // 配置名称
205
+ configName: undefined,
206
+ // 配置内容,用于查询配置生成器的预览
207
+ configContent: undefined,
208
+ // 表单项集合
209
+ formItems: [],
210
+ // 服务名称
211
+ serviceName: undefined,
212
+ // 是否显示提交按钮
213
+ showSubmitBtn: true,
214
+ // 修改有文件的表单时使用
215
+ files: [],
216
+ images: [],
217
+ // 校验
218
+ rules: {},
219
+ // 调用logic获取数据源的追加参数
220
+ getDataParams: {},
221
+ // 动态简易表单集合
222
+ simpleFormJsonData: {},
223
+ // 待修改的数据集
224
+ modifyModelData: {},
225
+ // 当前环境
226
+ env: 'prod',
227
+ // 表单主键
228
+ primaryKey: null,
229
+ // 表单模式 horizontal | vertical | inline
230
+ layout: 'horizontal',
231
+ // 提交按钮名称
232
+ btnName: '提交',
233
+ // 提交按钮位置 start / center / end
234
+ btnPlace: 'center',
235
+ // 子表是否排在前面
236
+ childTablePriority: false
237
+ }
238
+ },
239
+ computed: {
240
+ // 过滤出用于新增/修改场景的表单项
241
+ realJsonData: function () {
242
+ return this.formItems.filter((item) => {
243
+ return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
244
+ })
245
+ },
246
+ // 表单项组 / 不是 数据组
247
+ groups: function () {
248
+ if (!this.realJsonData || this.realJsonData.length === 0) {
249
+ return [{
250
+ groupName: DEFAULT_GROUP_NAME,
251
+ realJsonData: this.realJsonData,
252
+ xAddFormLayout: 'horizontal'
253
+ }]
254
+ }
255
+ const uniqueGroups = new Set(this.realJsonData.map(item => item.group).filter(Boolean))
256
+ const allGroup = Array.from(uniqueGroups).map(group => {
257
+ return {
258
+ groupName: group,
259
+ realJsonData: this.realJsonData.filter(item => item.group === group),
260
+ xAddFormLayout: 'horizontal'
261
+ }
262
+ })
263
+ // 判断每一组得formJson 长度相加是否等于 realJsonData 长度 避免错误数据
264
+ if (allGroup.reduce((total, item) => total + item.realJsonData.length, 0) === this.realJsonData.length) {
265
+ return allGroup
266
+ } else {
267
+ return [{
268
+ groupName: DEFAULT_GROUP_NAME,
269
+ realJsonData: this.realJsonData,
270
+ xAddFormLayout: 'horizontal'
271
+ }]
272
+ }
273
+ },
274
+ // 拥有自定义校验函数得表单项
275
+ customValidateItems: function () {
276
+ return this.formItems.filter((item) => {
277
+ return item?.rule?.type === 'customJs'
278
+ })
279
+ },
280
+ // 过滤出用于新增/修改场景的表单项
281
+ groupJsonData: function () {
282
+ return this.formItems.filter((item) => {
283
+ return item.type === 'group'
284
+ }).map((item) => {
285
+ item.groupItems = item.groupItems.filter((item) => {
286
+ return item.addOrEdit && item.addOrEdit !== 'no' && item.addOrEdit !== 'silenceAdd' && item.addOrEdit !== 'version' && !this.itemDisabled(item)
287
+ }).map((groupItem) => {
288
+ // 只保留第一个下划线后面的内容
289
+ // 多层校验规则需要将prop设置为 key1.key2.....
290
+ groupItem.prop = `${item.model}.${groupItem.model.substring(groupItem.model.indexOf('_') + 1)}`
291
+ groupItem.model = groupItem.model.substring(groupItem.model.indexOf('_') + 1)
292
+ return groupItem
293
+ })
294
+ return item
295
+ }
296
+ )
297
+ },
298
+ // 过滤出用于子表数据新增/修改场景的表单项
299
+ childTableData: function () {
300
+ return this.formItems.filter((item) => {
301
+ return item.type === 'childTable'
302
+ })
303
+ },
304
+ // 过滤出用于form子表数据新增/修改场景的表单项
305
+ childFormData: function () {
306
+ return this.formItems.filter((item) => {
307
+ return item.type === 'rowEdit'
308
+ })
309
+ },
310
+ // 过滤出用于静默新增场景的表单项
311
+ silenceAddJsonData: function () {
312
+ return this.formItems.filter(function (item) {
313
+ return item.addOrEdit === 'silenceAdd'
314
+ })
315
+ },
316
+ // 过滤出版本号表单项
317
+ versionJsonData: function () {
318
+ return this.formItems.filter(function (item) {
319
+ return item.addOrEdit === 'version'
320
+ })
321
+ },
322
+ formItemLayoutGen () {
323
+ if (this.layout === 'horizontal') {
324
+ return {
325
+ labelCol: { span: 4, offset: 2 },
326
+ wrapperCol: { span: 14 },
327
+ }
328
+ } else if (this.layout === 'vertical') {
329
+ return {}
330
+ } else {
331
+ if (!this.formItemLayout.labelCol || !this.formItemLayout.wrapperCol) {
332
+ return {
333
+ labelCol: { span: 8 },
334
+ wrapperCol: { span: 16 },
335
+ }
336
+ }
337
+ return {
338
+ labelCol: { span: this.formItemLayout.labelCol },
339
+ wrapperCol: { span: this.formItemLayout.wrapperCol },
340
+ }
341
+ }
342
+ },
343
+ ...mapState('account', { currUser: 'user' })
344
+ },
345
+ provide () {
346
+ return {
347
+ getComponentByName: this.getComponentByName,
348
+ registerComponent: this.registerComponent,
349
+ XFormContext: this,
350
+ // 移除必填项
351
+ removeRequired: this.removeRequired,
352
+ // 设置必填项
353
+ setRequired: this.setRequired,
354
+ getSelf: () => this,
355
+ }
356
+ },
357
+ /** //todo 本来想要实现 配置 自定义函数时,表单项得红星提示,根据自定义校验函数得返回值来判断
358
+ * 但是监听不到父组件formgorup得其他form得变化,所以暂时不实现
359
+ */
360
+ //
361
+ // watch: {
362
+ // form: {
363
+ // handler (val) {
364
+ // // 遍历表单配置
365
+ // if (this.customValidateItems.length > 0) {
366
+ // for (const item of this.customValidateItems) {
367
+ // const itemIndex = this.formItems.findIndex(formItem => formItem.model === item.model)
368
+ // if (itemIndex < 0) {
369
+ // continue
370
+ // }
371
+ // try {
372
+ // this.customJsValidate(null, val[item.model], (res) => {
373
+ // // 如果返回error则设置错误信息
374
+ // if (res instanceof Error) {
375
+ // // 设置表单项的错误状态
376
+ // this.$set(this.formItems[itemIndex], 'tempRequired', true)
377
+ // } else {
378
+ // // 清除错误状态
379
+ // this.$set(this.formItems[itemIndex], 'tempRequired', true)
380
+ // }
381
+ // }, item)
382
+ // } catch (e) {
383
+ // console.error(e)
384
+ // this.$set(this.formItems[itemIndex], 'tempRequired', true)
385
+ // }
386
+ // }
387
+ // console.log('customValidateItems', JSON.stringify(this.customValidateItems))
388
+ // }
389
+ // },
390
+ // deep: true
391
+ // }
392
+ // },
393
+ mixins: [formValidationMixin],
394
+ methods: {
395
+ runLogic,
396
+ getConfigByNameAsync,
397
+ getConfigByName,
398
+ init (params) {
399
+ const {
400
+ configName,
401
+ configContent,
402
+ formItems,
403
+ formJson,
404
+ viewMode,
405
+ isHandleFormKey,
406
+ isKeyHandle = true,
407
+ showSubmitBtn = true,
408
+ serviceName,
409
+ primaryKey,
410
+ modifyModelData = {},
411
+ businessType,
412
+ title,
413
+ fixedAddForm = {},
414
+ getDataParams = {},
415
+ simpleFormJsonData = {},
416
+ env = 'prod',
417
+ layout,
418
+ xAddFormLayout = 'horizontal',
419
+ formItemLayout = {},
420
+ btnName = '提交',
421
+ childTablePriority = false,
422
+ btnPlace = 'center'
423
+ } = params
424
+ this.loaded = false
425
+ // 兼容需要省略 传递 layout: res.xAddFormLayout 可以使用 ...res 展开运算符 直接转递
426
+ if (xAddFormLayout && layout === undefined) {
427
+ this.layout = xAddFormLayout
428
+ } else {
429
+ this.layout = layout
430
+ }
431
+ this.formItemLayout = formItemLayout
432
+ if ((isHandleFormKey === null || isHandleFormKey === undefined) && !isKeyHandle) {
433
+ this.isHandleFormKey = isKeyHandle
434
+ } else if (isHandleFormKey) {
435
+ this.isHandleFormKey = isHandleFormKey
436
+ } else {
437
+ this.isHandleFormKey = isKeyHandle
438
+ }
439
+ this.childTablePriority = childTablePriority
440
+ this.configName = configName
441
+ this.configContent = configContent
442
+ this.formItems = this.getFromItem(formItems, formJson)
443
+ this.viewMode = viewMode
444
+ this.showSubmitBtn = showSubmitBtn
445
+ this.primaryKey = primaryKey
446
+ this.serviceName = serviceName
447
+ this.businessType = businessType
448
+ this.title = title
449
+ this.getDataParams = getDataParams
450
+ this.simpleFormJsonData = simpleFormJsonData
451
+ this.env = env
452
+ this.btnName = btnName
453
+ this.btnPlace = btnPlace
454
+ // 如果 fixedAddForm 有 selected_id 值,并且设置了处理表单key值,则多给 selected_id 加前缀 避免处理错误
455
+ if (fixedAddForm.selected_id && this.isHandleFormKey) {
456
+ fixedAddForm._selected_id = fixedAddForm.selected_id
457
+ delete fixedAddForm.selected_id
458
+ }
459
+ // 设置普通表单项的相关参数
460
+ const formData = Object.assign({}, fixedAddForm)
461
+ for (let i = 0; i < this.realJsonData.length; i++) {
462
+ const item = this.realJsonData[i]
463
+ this.setFormProps(formData, item, null)
464
+ }
465
+ // 设置表单分组项目相关参数
466
+ for (let i = 0; i < this.groupJsonData.length; i++) {
467
+ const groupItem = this.groupJsonData[i]
468
+ formData[groupItem.model] = {}
469
+ for (let j = 0; j < groupItem.groupItems.length; j++) {
470
+ const item = groupItem.groupItems[j]
471
+ this.setFormProps(formData[groupItem.model], item, item.prop)
472
+ }
473
+ }
474
+ // 设置动态简易表单项的相关参数
475
+ for (const key in this.simpleFormJsonData) {
476
+ for (const item of this.simpleFormJsonData[key].value) {
477
+ item.model = key + '@' + item.model
478
+ this.setFormProps(formData, item, null)
479
+ }
480
+ }
481
+
482
+ this.form = formData
483
+ // 修改场景下对表单项赋值
484
+ if (modifyModelData && modifyModelData.data) {
485
+ this.modifyModelData = modifyModelData
486
+ if (Object.keys(modifyModelData.data).length > 0) {
487
+ this.getModifyModelData(modifyModelData)
488
+ }
489
+ }
490
+ // 处理表单得附件
491
+ if (modifyModelData && modifyModelData.files) {
492
+ this.files = modifyModelData.files
493
+ }
494
+ if (modifyModelData && modifyModelData.images) {
495
+ this.images = modifyModelData.images
496
+ }
497
+ this.loaded = true
498
+ },
499
+ scrollToGroup (index) {
500
+ const groupElement = this.$refs[`group-title-${index}`][0]
501
+ if (groupElement) {
502
+ groupElement.scrollIntoView({ behavior: 'smooth' })
503
+ }
504
+ },
505
+ registerComponent (componentName, component) {
506
+ console.log('内部注册', this.$options.name, componentName)
507
+ this.$refs[componentName] = component
508
+ console.log('内部注册完成', this.$refs)
509
+ },
510
+ // 根据名字从注册到组件中获取组件
511
+ getComponentByName (componentName) {
512
+ console.log('内部取组件', this.$options.name, componentName)
513
+ console.log('内部组件内容', this.$refs)
514
+ return this.$refs[componentName]
515
+ },
516
+ // 兼容需要省略 传递 [formItems: res.formJson ] 可以使用 ...res 展开运算符 直接转递
517
+ getFromItem (formItems, formJson) {
518
+ const _formItems = formItems || formJson
519
+ if (typeof formItems === 'string') {
520
+ return JSON.parse(_formItems)
521
+ } else {
522
+ return JSON.parse(JSON.stringify(_formItems))
523
+ }
524
+ },
525
+ innerXFormTableEmit (fun, record, id, actionType, index) {
526
+ this.$emit(fun, record, id, actionType, index)
527
+ },
528
+ // 时间组件赋默认值
529
+ // .type, item.formDefault
530
+ getDateRange ({ type, formDefault: defaultValue, formValueFormat }) {
531
+ // const format = type === 'datePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
532
+ let format = 'YYYY-MM-DD HH:mm:ss'
533
+ if (formValueFormat) {
534
+ format = formValueFormat
535
+ }
536
+ let start
537
+ switch (defaultValue) {
538
+ case 'curYear':
539
+ start = moment().startOf('year').format(format)
540
+ break
541
+ case 'curMonth':
542
+ start = moment().startOf('month').format(format)
543
+ break
544
+ case 'curDay':
545
+ start = moment().startOf('day').format(format)
546
+ break
547
+ case 'curTime':
548
+ start = moment().format(format)
549
+ break
550
+ default:
551
+ return defaultValue
552
+ }
553
+ return start
554
+ },
555
+ setFormProps (formData, item, groupItem) {
556
+ const rulesKey = `${item.name}${item.model}`
557
+ if (formData[item.model] === undefined || formData[item.model] === null) {
558
+ formData[item.model] = undefined
559
+ }
560
+ if (!formData[item.model] && item.formDefault) {
561
+ if (['datePicker', 'rangePicker', 'yearPicker', 'monthPicker', 'yearRangePicker', 'monthRangePicker'].includes(item.type)) {
562
+ formData[item.model] = this.getDateRange(item)
563
+ } else if (['treeSelect', 'select', 'checkbox'].includes(item.type) && ['curOrgId', 'curDepId', 'curUserId'].includes(item.formDefault)) {
564
+ if (item.formDefault === 'curOrgId') {
565
+ formData[item.model] = item.type === 'select' ? this.currUser.orgid : [this.currUser.orgid]
566
+ }
567
+ if (item.formDefault === 'curDepId') {
568
+ formData[item.model] = item.type === 'select' ? this.currUser.depids : [this.currUser.depids]
569
+ }
570
+ if (item.formDefault === 'curUserId') {
571
+ formData[item.model] = item.type === 'select' ? this.currUser.id : [this.currUser.id]
572
+ }
573
+ } else {
574
+ formData[item.model] = item.formDefault
575
+ }
576
+ }
577
+ // 处理表单校验情况
578
+ if (item.rule) {
579
+ if (groupItem) {
580
+ this.rules[groupItem] = []
581
+ } else {
582
+ this.rules[rulesKey] = []
583
+ }
584
+ const required = item.rule.required ? item.rule.required === true || item.rule.required === 'true' : false
585
+ let trigger
586
+ let message
587
+ if (required) {
588
+ switch (item.type) {
589
+ case 'select':
590
+ case 'checkbox':
591
+ case 'radio':
592
+ case 'treeSelect':
593
+ case 'rangePicker':
594
+ case 'monthPicker':
595
+ case 'yearPicker':
596
+ case 'datePicker':
597
+ case 'file':
598
+ case 'image':
599
+ case 'citySelect':
600
+ case 'addressSearch':
601
+ case 'personSetting':
602
+ message = '请选择' + item.name
603
+ trigger = 'change'
604
+ break
605
+ default:
606
+ message = '请输入' + item.name
607
+ trigger = 'blur'
608
+ }
609
+ if (groupItem) {
610
+ this.rules[groupItem].push({
611
+ required: true,
612
+ message: message,
613
+ trigger: trigger
614
+ })
615
+ } else {
616
+ this.rules[rulesKey].push({
617
+ required: true,
618
+ message: message,
619
+ trigger: trigger
620
+ })
621
+ }
622
+ }
623
+
624
+ switch (item.rule.type) {
625
+ case 'number':
626
+ case 'integer':
627
+ case 'float':
628
+ // eslint-disable-next-line no-case-declarations
629
+ let defaultValue
630
+ // eslint-disable-next-line no-case-declarations
631
+ let message
632
+ switch (item.rule.type) {
633
+ case 'number':
634
+ item.numberInput = true
635
+ message = '数字'
636
+ defaultValue = 0
637
+ break
638
+ case 'integer':
639
+ item.numberInput = true
640
+ message = '整数'
641
+ defaultValue = 0
642
+ break
643
+ case 'float':
644
+ item.numberInput = true
645
+ message = '小数'
646
+ defaultValue = 0.0
647
+ break
648
+ }
649
+ if (groupItem) {
650
+ this.rules[groupItem].push({
651
+ type: item.rule.type,
652
+ message: item.name + '必须为' + message,
653
+ transform: (value) => {
654
+ if (value && value.length !== 0) {
655
+ return Number(value)
656
+ } else {
657
+ return defaultValue
658
+ }
659
+ },
660
+ trigger: 'blur'
661
+ })
662
+ } else {
663
+ this.rules[rulesKey].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
+ }
676
+ break
677
+ case 'email': {
678
+ const validator = (rule, value, callback) => {
679
+ if (value && !REG_EMAIL.test(value)) {
680
+ callback(new Error('请输入正确的邮箱地址'))
681
+ } else {
682
+ callback()
683
+ }
684
+ }
685
+ this.rules[groupItem || rulesKey].push({
686
+ type: 'email',
687
+ validator: validator,
688
+ message: '请输入正确的邮箱地址',
689
+ trigger: 'blur'
690
+ })
691
+ break
692
+ }
693
+ case 'userPhone': {
694
+ this.rules[groupItem || rulesKey].push({
695
+ type: 'userPhone',
696
+ validator: (rule, value, callback) => {
697
+ if (value && !REG_PHONE.test(value)) {
698
+ callback(new Error('请输入正确的手机号码'))
699
+ } else {
700
+ callback()
701
+ }
702
+ },
703
+ message: '请输入正确的手机号码',
704
+ trigger: 'blur'
705
+ })
706
+ break
707
+ }
708
+ case 'idNumber': {
709
+ this.rules[groupItem || rulesKey].push({
710
+ validator: (rule, value, callback) => {
711
+ if (value && !checkIdNumber(value)) {
712
+ callback(new Error('请输入正确的身份证号码'))
713
+ } else {
714
+ callback()
715
+ }
716
+ },
717
+ trigger: 'blur'
718
+ })
719
+ break
720
+ }
721
+ case 'landlineNumber': {
722
+ this.rules[rulesKey].push({
723
+ validator: (rule, value, callback) => {
724
+ if (value && !REG_LANDLINE.test(value)) {
725
+ callback(new Error('请输入正确的座机号码'))
726
+ } else {
727
+ callback()
728
+ }
729
+ },
730
+ trigger: 'blur'
731
+ })
732
+ break
733
+ }
734
+ // 大于0
735
+ case 'greaterThanZero': {
736
+ item.numberInput = true
737
+ this.rules[rulesKey].push({
738
+ validator: (rule, value, callback) => {
739
+ if (isNaN(value) || value <= 0) {
740
+ callback(new Error('请输入一个大于0的数字'))
741
+ } else {
742
+ callback()
743
+ }
744
+ },
745
+ trigger: 'blur'
746
+ })
747
+ break
748
+ }
749
+ // 大于等于0
750
+ case 'greaterThanOrEqualZero': {
751
+ item.numberInput = true
752
+ this.rules[rulesKey].push({
753
+ validator: (rule, value, callback) => {
754
+ if (isNaN(value) || value < 0) {
755
+ callback(new Error('请输入一个大于等于0的数字'))
756
+ } else {
757
+ callback()
758
+ }
759
+ },
760
+ trigger: 'blur'
761
+ })
762
+ break
763
+ }
764
+ case 'stringLength': {
765
+ this.rules[rulesKey].push({
766
+ validator: (rule, value, callback) => {
767
+ if (value && value.length < item.rule.minLen) {
768
+ callback(new Error('长度不能少于' + item.rule.minLen + '个字符'))
769
+ } else if (value && value.length > item.rule.maxLen) {
770
+ callback(new Error('长度不能超过' + item.rule.maxLen + '个字符'))
771
+ } else {
772
+ callback()
773
+ }
774
+ },
775
+ trigger: 'blur'
776
+ })
777
+ break
778
+ }
779
+ case 'customJs': {
780
+ this.rules[rulesKey].push({
781
+ validator: (rule, value, callback) => {
782
+ this.customJsValidate(rule, value, callback, item)
783
+ },
784
+ trigger: 'blur'
785
+ })
786
+ break
787
+ }
788
+ }
789
+ }
790
+ },
791
+ childTableMounted (item) {
792
+ // 子表初始化时,设置表格数据
793
+ if (this.form[item.model] && this.form[item.model].length > 0) {
794
+ this.$refs[`childXFormTable_${item.model}`][0].setTableData(this.form[item.model])
795
+ }
796
+ },
797
+ customJsValidate (rule, value, callback, item) {
798
+ if (item.rule.customValidatorFunc) {
799
+ executeStrFunctionByContext(this, item.rule.customValidatorFunc, [rule, value, callback, this.form, item, this.util, runLogic, getConfigByNameAsync])
800
+ } else {
801
+ callback()
802
+ }
803
+ },
804
+ itemDisabled (value) {
805
+ return (this.businessType === '新增' && value.addOrEdit === 'edit') ||
806
+ (this.businessType === '修改' && value.addOrEdit === 'add')
807
+ },
808
+ readonly (value) {
809
+ return value.addOrEdit === 'readonly'
810
+ },
811
+ async onSubmit () {
812
+ const valid = await this.validateForm()
813
+ if (!valid) return false
814
+ if (this.viewMode) {
815
+ this.$message.info('预览模式禁止新增和修改')
816
+ return false
817
+ }
818
+ this.loading = true
819
+ const requestForm = this.prepareForm()
820
+ await this.appendSilenceAddFields(requestForm)
821
+ const realForm = this.handleFormKeys(requestForm)
822
+ // 增加子表数据
823
+ if (this.childTableData.length > 0) {
824
+ for (const item of this.childTableData) {
825
+ const childModel = item.model
826
+ const childDataRef = this.$refs['childXFormTable_' + item.model][0].getTableData()
827
+ const childData = []
828
+ for (const item of childDataRef) {
829
+ childData.push(JSON.parse(JSON.stringify(item)))
830
+ }
831
+ for (let i = 0; i < childData.length; i++) {
832
+ childData[i] = this.handleFormKeys(childData[i])
833
+ // 外键不需要带表别名,所以此处放到表单处理后赋值
834
+ if (realForm.id) {
835
+ childData[i][item.childTableForeignKeyName] = realForm.id
836
+ }
837
+ }
838
+ realForm[childModel] = childData
839
+ }
840
+ }
841
+ // 增加form子表数据
842
+ if (this.childFormData.length > 0) {
843
+ for (const item of this.childFormData) {
844
+ const childModel = item.model
845
+ const childData = this.$refs[item.model].getTableData()
846
+ for (let i = 0; i < childData.length; i++) {
847
+ childData[i] = this.handleFormKeys(childData[i], true)
848
+ // 外键不需要带表别名,所以此处放到表单处理后赋值
849
+ if (realForm.id) {
850
+ childData[i][item.foreignKey] = realForm.id
851
+ }
852
+ }
853
+ realForm[childModel] = childData
854
+ }
855
+ }
856
+ if (this.$listeners.onSubmit) {
857
+ // 交由父级处理
858
+ this.$emit('onSubmit', {
859
+ businessType: this.businessType,
860
+ serviceName: this.serviceName,
861
+ realForm: realForm,
862
+ currUserName: this.currUser.name,
863
+ currUserId: this.currUser.id,
864
+ orgId: this.currUser.orgid
865
+ })
866
+ } else {
867
+ this.defaultSubmit(realForm)
868
+ }
869
+ },
870
+
871
+ async asyncSubmit () {
872
+ return new Promise((resolve, reject) => {
873
+ this.$refs.selectForm.validate(async valid => {
874
+ if (!valid) {
875
+ reject(new Error('Form validation failed'))
876
+ return
877
+ }
878
+ this.loading = true
879
+ const requestForm = this.prepareForm()
880
+ await this.appendSilenceAddFields(requestForm)
881
+ const realForm = this.handleFormKeys(requestForm)
882
+ resolve({
883
+ realForm,
884
+ businessType: this.businessType,
885
+ serviceName: this.serviceName,
886
+ currUserName: this.currUser.name,
887
+ currUserId: this.currUser.id,
888
+ orgId: this.currUser.orgid
889
+ })
890
+ })
891
+ })
892
+ },
893
+
894
+ validateForm () {
895
+ return new Promise((resolve) => {
896
+ this.$refs.selectForm.validate(valid => resolve(valid))
897
+ })
898
+ },
899
+
900
+ childTableFixedQueryForm (item) {
901
+ if (this.modifyModelData?.primaryKeyData) {
902
+ const fixedForm = {}
903
+ fixedForm[item.childTableForeignKeyName] = Object.values(this.modifyModelData.primaryKeyData)[0]
904
+ return fixedForm
905
+ }
906
+ return null
907
+ },
908
+
909
+ prepareForm () {
910
+ const form = { ...this.form }
911
+ for (const key of Object.keys(form)) {
912
+ const value = form[key]
913
+ if (value === null || (typeof value === 'object' && Object.keys(value).length === 0)) {
914
+ form[key] = undefined
915
+ }
916
+ }
917
+ return form
918
+ },
919
+
920
+ async appendSilenceAddFields (form) {
921
+ if (this.businessType === '新增') {
922
+ for (const item of this.silenceAddJsonData) {
923
+ switch (item.silencePurpose) {
924
+ case 'createTime':
925
+ form[item.model] = formatDate('now')
926
+ break
927
+ case 'operator':
928
+ form[item.model] = this.currUser.name
929
+ break
930
+ case 'operatorId':
931
+ form[item.model] = this.currUser.id
932
+ break
933
+ case 'orgId':
934
+ form[item.model] = this.currUser.orgid
935
+ break
936
+ case 'orgName':
937
+ form[item.model] = this.currUser.orgs
938
+ break
939
+ case 'depId':
940
+ form[item.model] = this.currUser.depids
941
+ break
942
+ case 'depName':
943
+ form[item.model] = this.currUser.deps
944
+ break
945
+ }
946
+ }
947
+ for (const item of this.silenceAddJsonData.filter((item) => item.silencePurpose === 'customize')) {
948
+ const result = await runLogic(item.silenceSource, form, this.serviceName)
949
+ if (result) {
950
+ const keys = Object.keys(result)
951
+ if (keys.length === 1 && keys[0] === 'value') {
952
+ form[item.model] = result.value
953
+ } else {
954
+ form[item.model] = result
955
+ }
956
+ } else {
957
+ form[item.model] = result
958
+ }
959
+ }
960
+ }
961
+ },
962
+
963
+ handleFormKeys (form, mustHandleKey = false) {
964
+ const realForm = {}
965
+ for (const key of Object.keys(form)) {
966
+ const value = form[key]
967
+ const extraFormKeyTagIndex = key.indexOf('@')
968
+ if (extraFormKeyTagIndex !== -1) {
969
+ const extraFormKey = key.substring(0, extraFormKeyTagIndex)
970
+ const realKey = key.substring(extraFormKeyTagIndex + 1)
971
+ if (!realForm[extraFormKey]) {
972
+ realForm[extraFormKey] = {}
973
+ }
974
+ realForm[extraFormKey][realKey] = value
975
+ } else {
976
+ const realKey = this.isHandleFormKey || mustHandleKey ? this.getRealKey(key, mustHandleKey) : key
977
+ // 如果发生重名,不覆盖,把key的别名带上
978
+ if (realForm[realKey]) {
979
+ realForm[key] = value
980
+ } else {
981
+ realForm[realKey] = value
982
+ }
983
+ }
984
+ }
985
+ return realForm
986
+ },
987
+ // 默认提交事件
988
+ defaultSubmit (realForm, callback) {
989
+ // 新增移除id
990
+ if (this.businessType === '新增') {
991
+ delete realForm.id
992
+ }
993
+ // 组织请求
994
+ const requestParameters = {
995
+ queryParamsName: this.configName,
996
+ queryParams: this.configContent,
997
+ form: realForm,
998
+ businessType: this.businessType,
999
+ operator: this.currUser.name
1000
+ }
1001
+ addOrModify(requestParameters, this.serviceName, this.env === 'dev').then(data => {
1002
+ this.$message.success(this.businessType + '成功!')
1003
+ // commit
1004
+ this.$emit('afterSubmit', { type: this.businessType, id: data.id, data: data, form: requestParameters.form })
1005
+ this.loading = false
1006
+ if (callback) {
1007
+ callback()
1008
+ }
1009
+ }).catch(e => {
1010
+ this.loading = false
1011
+ this.$message.error(this.businessType + '失败:' + e)
1012
+ })
1013
+ },
1014
+ // 获取表单字段实际值
1015
+ getRealKey (key, mustHandleKey = false) {
1016
+ if (key === 'selected_id') return key
1017
+ if (this.isHandleFormKey || mustHandleKey) {
1018
+ return key.substring(key.indexOf('_') + 1)
1019
+ } else {
1020
+ return key
1021
+ }
1022
+ },
1023
+ /**
1024
+ * 获取被修改记录数据
1025
+ * @param modifyModelData 被修改记录的数据
1026
+ */
1027
+ getModifyModelData (modifyModelData) {
1028
+ if (modifyModelData.primaryKeyData) {
1029
+ this.form = Object.assign(this.form, modifyModelData.primaryKeyData)
1030
+ }
1031
+ // 对动态简易表单项特殊处理
1032
+ for (const key in modifyModelData.data) {
1033
+ const realKey = this.isHandleFormKey ? this.getRealKey(key) : key
1034
+ if (this.simpleFormJsonData[realKey]) {
1035
+ const extraForm = JSON.parse(modifyModelData.data[key])
1036
+ for (const key in extraForm) {
1037
+ const model = realKey + '@' + key
1038
+ this.form[model] = extraForm[key]
1039
+ }
1040
+ }
1041
+ }
1042
+ // 对普通表单项处理
1043
+ for (let i = 0; i < this.realJsonData.length; i++) {
1044
+ if (['FilesId', 'Images'].includes(this.realJsonData[i])) {
1045
+ // 附件需要跳过 因为会通过 modifyModelData中的files,images属性给upload赋值
1046
+ // 新增修改表单每次提交时只会提交最新添加的文件
1047
+ continue
1048
+ }
1049
+ const item = this.realJsonData[i]
1050
+ if (modifyModelData.data[item.model] || modifyModelData.data[item.model] === 0) {
1051
+ if (modifyModelData.data[item.model] instanceof Array) {
1052
+ this.form[item.model] = modifyModelData.data[item.model]
1053
+ } else {
1054
+ this.form[item.model] = modifyModelData.data[item.model] + ''
1055
+ }
1056
+ }
1057
+ }
1058
+ // 对分组表单进行处理
1059
+ for (let i = 0; i < this.groupJsonData.length; i++) {
1060
+ const item = this.groupJsonData[i]
1061
+ try {
1062
+ if (modifyModelData.data[item.model]) {
1063
+ this.form[item.model] = JSON.parse(modifyModelData.data[item.model])
1064
+ }
1065
+ } catch (e) {
1066
+ if (modifyModelData.data[item.model]) {
1067
+ this.form[item.model] = modifyModelData.data[item.model]
1068
+ }
1069
+ }
1070
+ }
1071
+ // 追加版本号信息
1072
+ for (const item of this.versionJsonData) {
1073
+ if (!modifyModelData.data[item.model]) {
1074
+ this.form[item.model] = 0
1075
+ } else {
1076
+ this.form[item.model] = modifyModelData.data[item.model] + ''
1077
+ }
1078
+ }
1079
+ },
1080
+ setForm (obj) {
1081
+ this.form = Object.assign(this.form, obj)
1082
+ // 给子表赋外键条件
1083
+ if (this.childFormData.length > 0) {
1084
+ for (const item of this.childFormData) {
1085
+ const child = this.$refs[item.model]
1086
+ // 获取子表别名,以便在条件上添加别名
1087
+ const alias = child.realQueryConfig.tableAliasName
1088
+ // 有主键,且主键有值,添加主键条件
1089
+ if (this.primaryKey && this.form[this.primaryKey]) {
1090
+ const foreignKey = item.foreignKey
1091
+ const fixedQueryForm = { [alias + '_' + foreignKey]: this.form[this.primaryKey] }
1092
+ if (!child.fixedQueryForm) {
1093
+ child.fixedQueryForm = fixedQueryForm
1094
+ } else {
1095
+ Object.assign(child.fixedQueryForm, fixedQueryForm)
1096
+ }
1097
+ child.refreshTable()
1098
+ }
1099
+ }
1100
+ }
1101
+ },
1102
+ setFormWithKey (obj) {
1103
+ setDataByRealKey(this.form, obj)
1104
+ },
1105
+ setFormWithNoKey (obj) {
1106
+ setDataByRealKey(this.form, obj)
1107
+ },
1108
+ emitFunc (func, data, value) {
1109
+ this.$emit(func, data, value)
1110
+ this.$emit('x-form-item-emit-func', func, data, value)
1111
+ },
1112
+ // 直接转发事件的函数
1113
+ emitEvent (event, ...args) {
1114
+ this.$emit(event, ...args)
1115
+ },
1116
+ close () {
1117
+ this.loaded = false
1118
+ },
1119
+ /**
1120
+ * 行选择事件
1121
+ * @param row 选中行集合
1122
+ * @param attr 表单项属性
1123
+ */
1124
+ async rowChoose (row, attr, callback) {
1125
+ // 如果配置了自定义函数
1126
+ if (attr.dataChangeFunc) {
1127
+ await executeStrFunction(attr.dataChangeFunc, [this.form, this.setForm, {
1128
+ ...attr,
1129
+ selectRows: row
1130
+ }, util, this.mode, runLogic, getConfigByNameAsync])
1131
+ } else {
1132
+ // 默认填充选中行数据到当前表单
1133
+ setDataByRealKey(this.form, row[0])
1134
+ }
1135
+ if (callback) {
1136
+ callback()
1137
+ }
1138
+ },
1139
+ }
1140
+ }
1141
+ </script>
1142
+
1143
+ <style scoped lang="less">
1144
+ :deep(.ant-form-inline .ant-form-item ) {
1145
+ display: block !important;
1146
+ }
1147
+
1148
+ :deep(.ant-form-item-with-help) {
1149
+ margin-bottom: 0;
1150
+ }
1151
+
1152
+ .xFormGroupTitle {
1153
+ font-weight: bold;
1154
+ color: @primary-color;
1155
+ }
1156
+ </style>