vue2-client 1.9.13 → 1.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. package/.env +19 -19
  2. package/.env.gaslink +19 -19
  3. package/.env.revenue +19 -19
  4. package/.eslintrc.js +90 -90
  5. package/CHANGELOG.md +824 -824
  6. package/Components.md +60 -60
  7. package/babel.config.js +21 -21
  8. package/docs/Logic/345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +45 -45
  9. package/docs/LowCode/lowcode.md +155 -155
  10. package/docs/LowCode/lowcodeForDeveloper.md +230 -230
  11. package/docs/index.md +30 -30
  12. package/docs//345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +121 -121
  13. package/index.js +31 -31
  14. package/jest-transform-stub.js +8 -8
  15. package/jest.config.js +21 -21
  16. package/jest.setup.js +7 -7
  17. package/package.json +101 -101
  18. package/public/his/editor/editor.html +51 -51
  19. package/public/his/editor/mock/bind_data.html +779 -779
  20. package/public/his/editor/mock/data_table.html +40 -40
  21. package/public/his/editor/mock/sign.html +75 -75
  22. package/public/his/editor/vender/JsBarcode.all.js +3669 -3669
  23. package/public/his/editor/vender/date97/My97DatePicker.htm +65 -65
  24. package/public/his/editor/vender/date97/WdatePicker.js +677 -677
  25. package/public/his/editor/vender/date97/calendar.js +4 -4
  26. package/public/his/editor/vender/date97/lang/en.js +13 -13
  27. package/public/his/editor/vender/date97/lang/zh-cn.js +13 -13
  28. package/public/his/editor/vender/date97/lang/zh-tw.js +13 -13
  29. package/public/his/editor/vender/date97/skin/WdatePicker.css +10 -10
  30. package/public/his/editor/vender/date97/skin/default/datepicker.css +328 -328
  31. package/public/his/editor/vender/date97/skin/ext/datepicker.css +308 -308
  32. package/public/his/editor/vender/date97/skin/whyGreen/datepicker.css +255 -255
  33. package/public/his/editor/vender/diff.js +1627 -1627
  34. package/public/his/editor/vender/editor.js +1 -1
  35. package/public/his/editor/vender/fabric.js +31187 -31187
  36. package/public/his/editor/vender/jquery/jquery.base64.js +190 -190
  37. package/public/his/editor/vender/jquery/jquery.js +10872 -10872
  38. package/public/his/editor/vender/jquery/jquery.print.js +255 -255
  39. package/public/his/editor/vender/jquery/zTreeStyle/zTreeStyle.css +96 -96
  40. package/public/his/editor/vender/mui/mui.min.css +4 -4
  41. package/public/his/editor/vender/mui/mui.min.js +5 -5
  42. package/public/his/editor/vender/mui/mui.picker.min.css +6 -6
  43. package/public/his/editor/vender/mui/mui.picker.min.js +6 -6
  44. package/public/his/editor/vender/qrcode.js +7 -7
  45. package/public/his/editor/vender/requirejs/require.js +2145 -2145
  46. package/public/his/editor/vender/signature/jSignature.CompressorSVG.js +518 -518
  47. package/public/his/editor/vender/signature/jSignature.UndoButton.js +164 -164
  48. package/public/his/editor/vender/signature/jSignature.js +1486 -1486
  49. package/public/his/editor/vender/validator.js +5094 -5094
  50. package/public/his/editor/vender/weui/weui.css +5659 -5659
  51. package/public/his/editor/vender/weui/weui.min.css +4 -4
  52. package/public/his/editor/vender/weui/weui.min.js +11 -11
  53. package/public/index.html +27 -27
  54. package/src/App.vue +188 -188
  55. package/src/ReportView.js +19 -19
  56. package/src/assets/img/querySlotDemo.svg +15 -15
  57. package/src/assets/svg/badtwo.svg +1 -1
  58. package/src/assets/svg/goodtwo.svg +1 -1
  59. package/src/base-client/components/common/AMisRender/index.js +3 -3
  60. package/src/base-client/components/common/AMisRender/index.vue +263 -263
  61. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +470 -470
  62. package/src/base-client/components/common/AddressSearchCombobox/IcMapIcon.vue +16 -16
  63. package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
  64. package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
  65. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  66. package/src/base-client/components/common/CitySelect/CitySelect.vue +342 -342
  67. package/src/base-client/components/common/CitySelect/index.js +3 -3
  68. package/src/base-client/components/common/CitySelect/index.md +109 -109
  69. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  70. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  71. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  72. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  73. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  74. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  75. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  76. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  77. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  78. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  79. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  80. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  81. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  82. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  83. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  84. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
  85. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +413 -413
  86. package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
  87. package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +728 -728
  88. package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
  89. package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +219 -219
  90. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
  91. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
  92. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
  93. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
  94. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
  95. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
  96. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
  97. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  98. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  99. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  100. package/src/base-client/components/common/Tree/index.js +2 -2
  101. package/src/base-client/components/common/Upload/Upload.vue +239 -239
  102. package/src/base-client/components/common/Upload/index.js +3 -3
  103. package/src/base-client/components/common/XAddForm/XAddForm.vue +105 -105
  104. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +803 -803
  105. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  106. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
  107. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  108. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  109. package/src/base-client/components/common/XAddReport/XAddReport.vue +180 -180
  110. package/src/base-client/components/common/XAddReport/index.js +3 -3
  111. package/src/base-client/components/common/XAddReport/index.md +56 -56
  112. package/src/base-client/components/common/XBadge/XBadge.vue +86 -86
  113. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  114. package/src/base-client/components/common/XDataCard/XDataCard.vue +364 -364
  115. package/src/base-client/components/common/XDataCard/index.js +3 -3
  116. package/src/base-client/components/common/XDataCard/index.md +1 -1
  117. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  118. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  119. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  120. package/src/base-client/components/common/XDescriptions/XDescriptions.vue +169 -169
  121. package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +304 -304
  122. package/src/base-client/components/common/XDescriptions/demo.vue +50 -50
  123. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  124. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  125. package/src/base-client/components/common/XDetailsView/XDetailsView.vue +238 -238
  126. package/src/base-client/components/common/XDetailsView/index.js +3 -3
  127. package/src/base-client/components/common/XForm/XForm.vue +316 -316
  128. package/src/base-client/components/common/XForm/XFormItem.vue +1152 -1152
  129. package/src/base-client/components/common/XForm/XTreeSelect.vue +207 -207
  130. package/src/base-client/components/common/XForm/index.md +178 -178
  131. package/src/base-client/components/common/XFormCol/XFormCol.vue +36 -36
  132. package/src/base-client/components/common/XFormGroup/XFormGroup.vue +250 -250
  133. package/src/base-client/components/common/XFormGroup/demo.vue +40 -40
  134. package/src/base-client/components/common/XFormGroup/index.js +3 -3
  135. package/src/base-client/components/common/XFormGroup/index.md +38 -38
  136. package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
  137. package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
  138. package/src/base-client/components/common/XFormTable/XFormTable.vue +638 -638
  139. package/src/base-client/components/common/XFormTable/demo.vue +75 -75
  140. package/src/base-client/components/common/XFormTable/index.md +98 -98
  141. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +162 -162
  142. package/src/base-client/components/common/XLicensePlate/XLicensePlate.vue +193 -193
  143. package/src/base-client/components/common/XLicensePlate/XLicensePlateDemo.vue +48 -48
  144. package/src/base-client/components/common/XReport/XReport.vue +873 -873
  145. package/src/base-client/components/common/XReport/XReportDemo.vue +304 -304
  146. package/src/base-client/components/common/XReport/XReportDesign.vue +508 -508
  147. package/src/base-client/components/common/XReport/XReportJsonRender.vue +381 -381
  148. package/src/base-client/components/common/XReport/XReportTrGroup.vue +802 -802
  149. package/src/base-client/components/common/XReport/index.js +3 -3
  150. package/src/base-client/components/common/XReport/index.md +44 -44
  151. package/src/base-client/components/common/XReport/print.js +186 -186
  152. package/src/base-client/components/common/XReportGrid/XReport.vue +936 -936
  153. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +47 -47
  154. package/src/base-client/components/common/XReportGrid/XReportDesign.vue +556 -556
  155. package/src/base-client/components/common/XReportGrid/XReportJsonRender.vue +381 -381
  156. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +948 -948
  157. package/src/base-client/components/common/XReportGrid/index.js +3 -3
  158. package/src/base-client/components/common/XReportGrid/index.md +44 -44
  159. package/src/base-client/components/common/XReportGrid/print.js +186 -186
  160. package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
  161. package/src/base-client/components/common/XReportSlot/index.js +3 -3
  162. package/src/base-client/components/common/XReportSlot/index.md +48 -48
  163. package/src/base-client/components/common/XSimpleDescriptions/XSimpleDescriptions.vue +166 -166
  164. package/src/base-client/components/common/XSimpleDescriptions/index.js +3 -3
  165. package/src/base-client/components/common/XSimpleDescriptions/index.md +7 -7
  166. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  167. package/src/base-client/components/common/XStepView/index.js +3 -3
  168. package/src/base-client/components/common/XStepView/index.md +31 -31
  169. package/src/base-client/components/common/XTab/XTab.vue +149 -149
  170. package/src/base-client/components/common/XTab/XTabDemo.vue +22 -22
  171. package/src/base-client/components/common/XTab/index.js +3 -3
  172. package/src/base-client/components/common/XTable/XTable.vue +1121 -1121
  173. package/src/base-client/components/common/XTable/index.md +255 -255
  174. package/src/base-client/components/common/XTree/XTree.vue +423 -423
  175. package/src/base-client/components/common/XTree/XTreePro.vue +418 -418
  176. package/src/base-client/components/common/XTree/index.js +3 -3
  177. package/src/base-client/components/common/XTree/index.md +36 -36
  178. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +113 -113
  179. package/src/base-client/components/common/XTreeOne/XTreeOnePro.vue +128 -128
  180. package/src/base-client/components/common/richTextModal/index.vue +56 -56
  181. package/src/base-client/components/common/richTextModal/richDemo.vue +48 -48
  182. package/src/base-client/components/his/XHisEditor/XHisEditor.vue +196 -196
  183. package/src/base-client/components/his/XHisEditor/index.js +3 -3
  184. package/src/base-client/components/index.js +51 -51
  185. package/src/base-client/components/layout/XPageView/RenderRow.vue +63 -63
  186. package/src/base-client/components/layout/XPageView/XErrorView.vue +11 -11
  187. package/src/base-client/components/layout/XPageView/XPageView.vue +155 -155
  188. package/src/base-client/components/layout/XPageView/index.js +3 -3
  189. package/src/base-client/components/layout/XPageView/index.md +38 -38
  190. package/src/base-client/components/layout/XTreeView/XTreeView.vue +130 -130
  191. package/src/base-client/components/layout/XTreeView/index.js +3 -3
  192. package/src/base-client/components/layout/XTreeView/index.md +46 -46
  193. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  194. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  195. package/src/base-client/plugins/AppData.js +121 -121
  196. package/src/base-client/plugins/Config.js +19 -19
  197. package/src/base-client/plugins/GetLoginInfoService.js +183 -183
  198. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  199. package/src/bootstrap.js +39 -39
  200. package/src/components/CodeMirror/inedx.vue +118 -118
  201. package/src/components/CodeMirror/setting.js +40 -40
  202. package/src/components/FilePreview/FilePreview.vue +166 -166
  203. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  204. package/src/components/STable/index.js +380 -380
  205. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  206. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  207. package/src/components/exception/ExceptionPage.vue +70 -70
  208. package/src/components/menu/SideMenu.vue +75 -75
  209. package/src/components/menu/menu.js +273 -273
  210. package/src/components/tool/AStepItem.vue +60 -60
  211. package/src/config/CreateQueryConfig.js +322 -322
  212. package/src/config/default/antd.config.js +89 -89
  213. package/src/config/default/setting.config.js +55 -55
  214. package/src/font-style/font.css +4 -4
  215. package/src/layouts/CommonLayout.vue +56 -56
  216. package/src/layouts/GridView.vue +45 -45
  217. package/src/layouts/PageLayout.vue +151 -151
  218. package/src/layouts/SinglePageView.vue +136 -136
  219. package/src/layouts/header/AdminHeader.vue +132 -132
  220. package/src/layouts/header/HeaderNotice.vue +177 -177
  221. package/src/layouts/tabs/TabsHead.vue +189 -189
  222. package/src/layouts/tabs/TabsView.vue +389 -389
  223. package/src/lib.js +1 -1
  224. package/src/main.js +30 -30
  225. package/src/mock/extend/index.js +84 -84
  226. package/src/mock/goods/index.js +108 -108
  227. package/src/pages/AMisDemo/AMisDemo.vue +325 -325
  228. package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
  229. package/src/pages/DefaultExample/index.vue +77 -77
  230. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  231. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  232. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  233. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  234. package/src/pages/DynamicStatistics/FavoriteList.vue +51 -51
  235. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  236. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  237. package/src/pages/DynamicStatistics/index.vue +282 -282
  238. package/src/pages/Example/childIndex.vue +15 -15
  239. package/src/pages/Example/index.vue +30 -30
  240. package/src/pages/NewDynamicStatistics/ChartSelector.vue +331 -331
  241. package/src/pages/NewDynamicStatistics/DataTabs.vue +122 -122
  242. package/src/pages/NewDynamicStatistics/DynamicTable.vue +128 -128
  243. package/src/pages/NewDynamicStatistics/EvaluationArea.vue +69 -69
  244. package/src/pages/NewDynamicStatistics/FavoriteList.vue +51 -51
  245. package/src/pages/NewDynamicStatistics/QuestionHistoryAndFavorites.vue +289 -289
  246. package/src/pages/NewDynamicStatistics/SearchBar.vue +193 -193
  247. package/src/pages/NewDynamicStatistics/index.vue +258 -258
  248. package/src/pages/ReportGrid/index.vue +76 -76
  249. package/src/pages/ServiceReview/index.vue +284 -284
  250. package/src/pages/SubExample/index.vue +26 -26
  251. package/src/pages/WorkflowDetail/WorkFlowDemo.vue +32 -32
  252. package/src/pages/WorkflowDetail/WorkflowDetail.vue +230 -230
  253. package/src/pages/WorkflowDetail/WorkflowPageDetail/LeaveMessage.vue +131 -131
  254. package/src/pages/WorkflowDetail/WorkflowPageDetail/TrimTextTail.vue +23 -23
  255. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformation.vue +302 -302
  256. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformationDetails.vue +276 -276
  257. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +863 -863
  258. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandleReso.vue +997 -997
  259. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +222 -222
  260. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkOrderParentDetails.vue +233 -233
  261. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowDetailResso.vue +261 -261
  262. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowListResolution.vue +248 -248
  263. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowLog.vue +73 -73
  264. package/src/pages/XPageViewExample/index.vue +38 -38
  265. package/src/pages/XReportView/index.vue +64 -64
  266. package/src/pages/XTreeOneProExample/index.vue +67 -67
  267. package/src/pages/login/Login.vue +378 -378
  268. package/src/pages/login/LoginV3.vue +389 -389
  269. package/src/pages/lowCode/lowCodeEditor.vue +1219 -1219
  270. package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
  271. package/src/pages/resourceManage/orgListManage.vue +98 -98
  272. package/src/pages/system/dictionary/index.vue +44 -44
  273. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  274. package/src/pages/system/monitor/operLog/index.vue +37 -37
  275. package/src/pages/system/settings/modifyPassword.vue +117 -117
  276. package/src/pages/system/ticket/index.vue +480 -480
  277. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  278. package/src/plugins/EventLogPlugin.js +33 -33
  279. package/src/plugins/FindParentsData.js +17 -17
  280. package/src/router/async/config.async.js +34 -34
  281. package/src/router/async/router.map.js +179 -179
  282. package/src/router/guards.js +264 -264
  283. package/src/router/index.js +27 -27
  284. package/src/router.js +19 -19
  285. package/src/services/api/TicketDetailsViewApi.js +46 -46
  286. package/src/services/api/cas.js +79 -79
  287. package/src/services/api/common.js +329 -329
  288. package/src/services/api/entity.js +18 -18
  289. package/src/services/api/index.js +17 -17
  290. package/src/services/api/restTools.js +67 -67
  291. package/src/services/api/workFlow.js +63 -63
  292. package/src/services/apiService.js +15 -15
  293. package/src/services/user.js +90 -90
  294. package/src/services/v3Api.js +81 -81
  295. package/src/store/modules/account.js +115 -115
  296. package/src/store/modules/index.js +5 -5
  297. package/src/store/modules/lowCode.js +33 -33
  298. package/src/store/modules/setting.js +119 -119
  299. package/src/theme/default/style.less +58 -58
  300. package/src/theme/global.less +159 -159
  301. package/src/utils/authority-utils.js +85 -85
  302. package/src/utils/errorCode.js +6 -6
  303. package/src/utils/formatter.js +80 -80
  304. package/src/utils/htmlToPDF.js +108 -108
  305. package/src/utils/htmlToPDFApi.js +5 -5
  306. package/src/utils/indexedDB.js +258 -258
  307. package/src/utils/login.js +188 -188
  308. package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
  309. package/src/utils/lowcode/lowcodeLog.js +29 -29
  310. package/src/utils/lowcode/lowcodeUtils.js +373 -373
  311. package/src/utils/lowcode/registerComponentForEditor.js +1 -1
  312. package/src/utils/lowcode/registerComponentForRender.js +11 -11
  313. package/src/utils/map-utils.js +47 -47
  314. package/src/utils/reg.js +95 -95
  315. package/src/utils/request.js +362 -362
  316. package/src/utils/routerUtil.js +450 -450
  317. package/src/utils/runEvalFunction.js +14 -14
  318. package/src/utils/util.js +281 -281
  319. package/src/utils/waterMark.js +31 -31
  320. package/test/Amis.spec.js +163 -163
  321. package/test/Tree.spec.js +167 -167
  322. package/test/myDialog.spec.js +46 -46
  323. package/vue.config.js +196 -196
  324. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,948 +1,948 @@
1
- <template>
2
- <a-row :gutter="gutter">
3
- <!-- 预览页展示 -->
4
- <template v-if="display">
5
- <template v-if="!inputColumns">
6
- <a-col
7
- name="trGroup"
8
- v-for="(cell, cellIndex) in columns"
9
- v-if="!cell.dontShowRow"
10
- :key="cellIndex"
11
- :style="determineCellStyle(cell)"
12
- :span="cell.colSpan ? cell.colSpan * 2 : undefined">
13
- <!-- 插槽渲染 -->
14
- <template v-if="cell.type === 'slot'">
15
- <template v-if="['x-form-table','x-add-native-form','x-tree-pro', 'x-his-editor', 'x-tab'].includes(cell.slotType)">
16
- <component
17
- :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
18
- :key="cellIndex"
19
- :ref="`dynamicComponent_${ cell.slotRef || cellIndex}`"
20
- :serviceName="cell.serviceName"
21
- :serverName="cell.serviceName"
22
- v-on="getEventHandlers(cell)"
23
- @hook:mounted="(h)=>onComponentMounted(h,cell,cellIndex)"
24
- :queryParamsName="cell.slotConfig"
25
- :configName="cell.slotConfig"
26
- :countVisible="false"
27
- :env="env"
28
- />
29
- </template>
30
- </template>
31
- <!-- button 按钮渲染 -->
32
- <template v-else-if="cell.type === 'button'">
33
- <a-button v-on="getEventHandlers(cell)">
34
- {{ cell.buttonName }}
35
- </a-button>
36
- </template>
37
- <template v-else-if="cell.type === 'column'">
38
- <template v-if="cell.customFunction">
39
- {{ deserializeFunctionAndRun(cell.customFunction, configData[cell.dataIndex], config) }}
40
- </template>
41
- <template v-else>
42
- {{ cell.text }}
43
- </template>
44
- </template>
45
- <!-- 占位 -->
46
- <template v-else-if="cell.type === 'placeHolderColumn'">
47
- </template>
48
- <template v-else-if="cell.type === 'value'">
49
- <template v-if="cell.customFunction === undefined">
50
- {{ cell.value }}
51
- </template>
52
- <template v-else>
53
- {{ deserializeFunctionAndRun(cell.customFunction, cell.value, config) }}
54
- </template>
55
- </template>
56
- <template v-else-if="cell.type === 'input'">
57
- <template v-if="cell.customFunction === undefined">
58
- {{ getDeepObject(configData, cell.dataIndex) }}
59
- </template>
60
- <template v-else>
61
- {{ deserializeFunctionAndRun(cell.customFunction, configData[cell.dataIndex], config) }}
62
- </template>
63
- </template>
64
- <template v-else-if="cell.type === 'inputs'">
65
- <template v-if="cell.customFunction === undefined">
66
- {{ showSubRowValue(cell) }}
67
- </template>
68
- <template v-else>
69
- {{ deserializeFunctionAndRun(cell.customFunction, showSubRowValue(cell), config) }}
70
- </template>
71
- </template>
72
- <template v-else-if="cell.type === 'list'">
73
- <template v-if="listIndex === 0">
74
- <span style="font-weight: bold">{{ cell.listHead }}</span>
75
- </template>
76
- <template v-else-if="cell.listType === 'input'">
77
- {{ getDeepObject(configData, cell.dataIndex)[listIndex] }}
78
- </template>
79
- <template v-else-if="cell.listType === 'value'">
80
- {{ cell.content[listIndex] }}
81
- </template>
82
- <template v-else-if="cell.listType === 'variable'">
83
- {{ configData[cell.dataIndex][listIndex - 1][cell.listDataIndex] }}
84
- </template>
85
- </template>
86
- <template v-else-if="cell.type === 'images'">
87
- <template
88
- v-if="getDeepObject(configData.images, cell.dataIndex) === undefined || getDeepObject(configData.images, cell.dataIndex).length === 0">
89
- <template
90
- v-if="getDeepObject(configData, cell.dataIndex) === undefined || getDeepObject(configData, cell.dataIndex).length === 0">
91
- <span>无</span>
92
- </template>
93
- <template v-else>
94
- <template v-if="typeof getDeepObject(configData, cell.dataIndex) === 'object'">
95
- <div style="display: flex; align-items: end; justify-content: space-evenly; flex-wrap: wrap">
96
- <template v-for="(img,imgIndex) in getDeepObject(configData, cell.dataIndex)">
97
- <template v-if="showImgInCell">
98
- <div :key="imgIndex">
99
- <img :src="img.url" alt="图片"/>
100
- <p>{{ img.name }}</p>
101
- </div>
102
- </template>
103
- <template v-else>
104
- <span :key="imgIndex" style="margin-right: 5%">{{ img.name }}</span>
105
- </template>
106
- </template>
107
- </div>
108
- </template>
109
- <template v-else>
110
- <img :src="getDeepObject(configData, cell.dataIndex)" alt="图片"/>
111
- <p style="margin-right: 5%">{{ formatImgStr(getDeepObject(configData, cell.dataIndex))[0].name }}</p>
112
- </template>
113
- </template>
114
- </template>
115
- <template v-else v-for="(img,imgIndex) in getDeepObject(configData.images, cell.dataIndex)">
116
- <span :key="imgIndex" style="margin-right: 5%">{{ img.name }}</span>
117
- </template>
118
- </template>
119
- </a-col>
120
- </template>
121
- <template v-else>
122
- <a-col
123
- v-for="(cell, cellIndex) in columns"
124
- :key="cellIndex"
125
- :class=" calcTDBorder(cell.noBoarder) "
126
- :span="cell.colSpan ? cell.colSpan * 2 : undefined"
127
- :style="determineCellStyle(cell)"
128
- :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
129
- <template v-if="cell.type === 'column'">
130
- {{ cell.text }}
131
- </template>
132
- <template v-else-if="cell.type === 'value'">
133
- <template v-if="cell.customFunction === undefined">
134
- {{ cell.value }}
135
- </template>
136
- <template v-else>
137
- {{ deserializeFunctionAndRun(cell.customFunction, cell.value, config) }}
138
- </template>
139
- </template>
140
- <template v-else-if="cell.type === 'increment'">
141
- <template v-if="cell.customFunction === undefined">
142
- {{ getDeepObject(configData.arr[inputColumnsDefinitionIndex], cell.dataIndex) }}
143
- </template>
144
- <template v-else>
145
- {{
146
- deserializeFunctionAndRun(cell.customFunction, configData.arr[inputColumnsDefinitionIndex][cell.dataIndex], config)
147
- }}
148
- </template>
149
- </template>
150
- <template v-else-if="cell.type === 'input'">
151
- <template v-if="cell.customFunction === undefined">
152
- {{ getDeepObject(configData.arr[inputColumnsDefinitionIndex], cell.dataIndex) }}
153
- </template>
154
- <template v-else>
155
- {{
156
- deserializeFunctionAndRun(cell.customFunction, configData.arr[inputColumnsDefinitionIndex][cell.dataIndex], config)
157
- }}
158
- </template>
159
- </template>
160
- <template v-else-if="cell.type === 'inputs'">
161
- <template v-if="cell.customFunction === undefined">
162
- {{ getDeepObject(configData.arr[inputColumnsDefinitionIndex], cell.dataIndex) }}
163
- </template>
164
- <template v-else>
165
- {{
166
- deserializeFunctionAndRun(cell.customFunction, configData.arr[inputColumnsDefinitionIndex][cell.dataIndex], config)
167
- }}
168
- </template>
169
- </template>
170
- </a-col>
171
- </template>
172
- </template>
173
- <!-- 不是动态行 -->
174
- <template v-else-if="!inputColumns">
175
- <a-col
176
- v-for="(cell, cellIndex) in columns"
177
- :key="cellIndex"
178
- :class=" calcTDBorder(cell.noBoarder) "
179
- :span="cell.colSpan ? cell.colSpan * 2 : undefined"
180
- :style="determineCellStyle(cell)"
181
- :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
182
- <template v-if="cell.type === 'column'">
183
- <template v-if="cell.customFunction">
184
- {{ deserializeFunctionAndRun(cell.customFunction, configData[cell.dataIndex], config) }}
185
- </template>
186
- <template v-else>
187
- {{ cell.text }}
188
- </template>
189
- </template>
190
- <template v-else-if="cell.type === 'placeHolderColumn'">
191
- <!-- 占位 -->
192
- </template>
193
- <template v-else-if="cell.type === 'value'">
194
- {{ cell.value }}
195
- </template>
196
- <template v-else-if="cell.type === 'curDateInput'">
197
- <a-button type="dashed" v-if="configData[cell.dataIndex]">
198
- {{ configData[cell.dataIndex] }}
199
- </a-button>
200
- <a-button
201
- v-if="!configData[cell.dataIndex]"
202
- type="primary"
203
- @click="getNowDate(cell.dataIndex)"
204
- >{{ cell.text || '确认' }}
205
- </a-button>
206
- </template>
207
- <template v-else-if="cell.type === 'input'">
208
- <template v-if="cell.inputReadOnly === true">
209
- <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
210
- <a-input
211
- @change="handleInputDeepChange($event, cell.dataIndex)"
212
- v-model="config.tempData[cell.dataIndex]"
213
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
214
- :disabled="true"/>
215
- </template>
216
- <template v-else>
217
- <a-input
218
- v-model="configData[cell.dataIndex]"
219
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
220
- :disabled="true"/>
221
- </template>
222
- </template>
223
- <template v-else>
224
- <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
225
- <a-input
226
- @change="handleInputDeepChange($event, cell.dataIndex)"
227
- v-model="config.tempData[cell.dataIndex]"
228
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
229
- </template>
230
- <template v-else>
231
- <a-input
232
- v-model="configData[cell.dataIndex]"
233
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
234
- </template>
235
- </template>
236
- </template>
237
- <template v-else-if="cell.type === 'inputs'">
238
- <template v-if="cell.inputReadOnly === true">
239
- <div class="inputsDiv">
240
- <div class="inputsDivItem" v-for="(num, index) of calcFormatInputNum(cell.format)" :key="index">
241
- <span class="inputsDivItemLabel">{{ displayFormatStartText(cell.format) }}</span>
242
- <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
243
- <a-input
244
- @change="handleInputDeepChange($event, cell.dataIndex)"
245
- v-model="config.tempData[cell.dataIndex][index]"
246
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
247
- :disabled="true"/>
248
- </template>
249
- <template v-else>
250
- <a-input
251
- v-model="configData[cell.dataIndex][index]"
252
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
253
- :disabled="true"/>
254
- </template>
255
- <span class="inputsDivItemLabel">{{ displayFormatText(cell.format, index) }}</span>
256
- </div>
257
- </div>
258
- </template>
259
- <template v-else>
260
- <div class="inputsDiv">
261
- <div class="inputsDivItem" v-for="(num, index) of calcFormatInputNum(cell.format)" :key="index">
262
- <span class="inputsDivItemLabel">{{ displayFormatStartText(cell.format) }}</span>
263
- <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
264
- <a-input
265
- @change="handleInputDeepChange($event, cell.dataIndex)"
266
- v-model="config.tempData[cell.dataIndex][index]"
267
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
268
- </template>
269
- <template v-else>
270
- <a-input
271
- v-model="configData[cell.dataIndex][index]"
272
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
273
- </template>
274
- <span class="inputsDivItemLabel">{{ displayFormatText(cell.format, index) }}</span>
275
- </div>
276
- </div>
277
- </template>
278
- </template>
279
- <template v-else-if="cell.type === 'list'">
280
- <template v-if="cell.listType === 'input'">
281
- <a-input
282
- v-model="configData[cell.dataIndex][listIndex]"
283
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
284
- </template>
285
- <template v-else-if="cell.listType === 'value'">
286
- {{ cell.content[listIndex] }}
287
- </template>
288
- </template>
289
- <template v-else-if="cell.type === 'images'">
290
- <div>
291
- <template v-if="configData.images[cell.dataIndex]?.length > 0">
292
- <upload
293
- :model="uploadParams"
294
- :img-prefix="imgPrefix"
295
- :service-name="serverName"
296
- :images="checkImg(cell.dataIndex, 'configData')"
297
- :outer-container-index="cell.dataIndex"
298
- @setFiles="(...args) => {setImages(args, 'configData')}"
299
- :upload-style="'simple'"
300
- />
301
- </template>
302
- <template v-else>
303
- <upload
304
- :model="uploadParams"
305
- :img-prefix="imgPrefix"
306
- :service-name="serverName"
307
- :images="checkImg(cell.dataIndex, 'config')"
308
- :outer-container-index="cell.dataIndex"
309
- @setFiles="(...args) => {setImages(args, 'config', cell.dataIndex)}"
310
- :upload-style="'simple'"
311
- />
312
- </template>
313
- </div>
314
- </template>
315
- </a-col>
316
- </template>
317
- <!-- 动态行插入按钮 -->
318
- <template v-else-if="inputColumnsButton">
319
- <a-col :span="maxColSpan" :class="calcTDBorder()">
320
- <a-button-group>
321
- <a-button @click="addData(columns[0].dataIndex, columns)">
322
- <a-icon type="plus"/>
323
- </a-button>
324
- <a-button @click="removeData(columns[0].dataIndex)">
325
- <a-icon type="minus"/>
326
- </a-button>
327
- </a-button-group>
328
- </a-col>
329
- </template>
330
- <!-- 其他行 -->
331
- <template v-else>
332
- <a-col
333
- v-for="(cell, cellIndex) in columns"
334
- :key="cellIndex"
335
- :class=" calcTDBorder(cell.noBoarder) "
336
- :span="cell.colSpan ? cell.colSpan * 2 : undefined"
337
- :style="determineCellStyle(cell)"
338
- :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
339
- <template v-if="cell.type === 'column'">
340
- {{ cell.text }}
341
- </template>
342
- <template v-else-if="cell.type === 'value'">
343
- {{ cell.value }}
344
- </template>
345
- <template v-else-if="cell.type === 'curDateInput'">
346
- <a-button type="dashed" v-if="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]">
347
- {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
348
- </a-button>
349
- <a-button
350
- v-if="!configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
351
- type="primary"
352
- @click="getNowDate(inputColumnsDefinitionIndex,cell.dataIndex)"
353
- >{{ cell.text || '确认' }}
354
- </a-button>
355
- </template>
356
- <template v-else-if="cell.type === 'increment'">
357
- {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
358
- </template>
359
- <template v-else-if="cell.type === 'input'">
360
- <template v-if="cell.inputReadOnly === true">
361
- <a-input
362
- v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
363
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
364
- :disabled="true"/>
365
- </template>
366
- <template v-else>
367
- <a-input
368
- v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
369
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
370
- </template>
371
- </template>
372
- <template v-else-if="cell.type === 'inputs'">
373
- <template v-if="cell.inputReadOnly === true">
374
- <a-input
375
- v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
376
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
377
- :disabled="true"/>
378
- </template>
379
- <template v-else>
380
- <a-input
381
- v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
382
- :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
383
- </template>
384
- </template>
385
- </a-col>
386
- </template>
387
- </a-row>
388
- </template>
389
-
390
- <script>
391
- import Upload from '@vue2-client/base-client/components/common/Upload'
392
- import { formatDate } from '@vue2-client/utils/util'
393
- import { nanoid } from 'nanoid'
394
- import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
395
- import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
396
-
397
- export default {
398
- name: 'XReportTrGroup',
399
- components: {
400
- Upload,
401
- XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'),
402
- XAddNativeForm: () => import('@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'),
403
- XTreePro: () => import('@vue2-client/base-client/components/common/XTree/XTreePro.vue'),
404
- XHisEditor: () => import('@vue2-client/base-client/components/his/XHisEditor/XHisEditor.vue'),
405
- XTab: () => import('@vue2-client/base-client/components/common/XTab/XTab.vue')
406
- },
407
- props: {
408
- // 每一行的配置
409
- columns: {
410
- type: Array,
411
- required: true
412
- },
413
- showImgInCell: {
414
- type: Boolean,
415
- default: false
416
- },
417
- config: {
418
- type: Object,
419
- default: function () {
420
- return {}
421
- }
422
- },
423
- // 命名空间
424
- serverName: {
425
- type: String,
426
- default: 'af-system'
427
- },
428
- // 环境
429
- env: {
430
- type: String,
431
- default: 'prod'
432
- },
433
- // 原始配置
434
- configData: {
435
- type: Object,
436
- required: true
437
- },
438
- // 是否为动态行
439
- inputColumns: {
440
- type: Boolean,
441
- default: false
442
- },
443
- // 是否为动态行按钮
444
- inputColumnsButton: {
445
- type: Boolean,
446
- default: false
447
- },
448
- // 动态行的Index
449
- inputColumnsDefinitionIndex: {
450
- type: Number,
451
- default: undefined
452
- },
453
- // 是否为展示行
454
- display: {
455
- type: Boolean,
456
- default: false
457
- },
458
- // list类型的下标,用于遍历列表时,获取对应的数据
459
- listIndex: {
460
- type: Number,
461
- default: undefined
462
- },
463
- // 表格没有上边框
464
- noTopBorder: {
465
- type: Boolean,
466
- default: false
467
- },
468
- // 图片是否使用OSS来保存
469
- useOssForImg: {
470
- type: Boolean,
471
- default: true
472
- },
473
- // 图片上传后添加前缀
474
- imgPrefix: {
475
- type: String,
476
- default: undefined
477
- }
478
- },
479
- data () {
480
- return {
481
- gutter: [16, { xs: 8, sm: 16, md: 24, lg: 32 }], // 设置水槽大小
482
- maxColSpan: 12,
483
- uploadParams: {
484
- type: 'image',
485
- accept: ['*'],
486
- resUploadStock: 1,
487
- pathKey: 'cs'
488
- },
489
- mixinData: {}
490
- // tableConfig: {}
491
- }
492
- },
493
- inject: ['openDialog', 'registerComponent', 'getComponentByName', 'runLogic', 'getMixinData', 'getSelectedId', 'isInAModal', 'getConfigByName', 'getSelectedData', 'getOutEnv'],
494
- methods: {
495
- onComponentMounted (h, cell, cellIndex) {
496
- if (this.getMixinData && this.getMixinData()) {
497
- this.mixinData = this.getMixinData()
498
- }
499
- if (cell.slotRef) {
500
- this.registerComponent(cell.slotRef, this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0])
501
- }
502
- // 传递给祖先组件
503
- console.log(`插槽组件已经初始化 slotType ${cell.slotType},ref= dynamicComponent_${cell.slotRef || cellIndex} , serviceName = ${cell.serviceName}`)
504
- const shouldInit = cell.shouldInit == null ? true : cell.shouldInit
505
- if (shouldInit) {
506
- if (cell.slotType === 'x-add-native-form' && shouldInit) {
507
- // 建议表单需要主动调用初始化方法
508
- getConfigByName(cell.slotConfig, cell.serviceName, async (res) => {
509
- // 如果配置了 表单初始化logic
510
- // 调用 logic 获取参数
511
- let param = { ...this.mixinData }
512
- let selectedId
513
- if (res.paramLogicName) {
514
- if (!!this.getSelectedId) {
515
- selectedId = this.getSelectedId()
516
- if (typeof selectedId !== 'object') {
517
- selectedId = { selectedId: selectedId }
518
- }
519
- }
520
- param = Object.assign(param, await runLogic(res.paramLogicName, selectedId, cell.serviceName))
521
- }
522
- this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
523
- serviceName: cell.serviceName,
524
- formItems: res.formJson,
525
- showSubmitBtn: !this.isInAModal,
526
- businessType: param.businessType || '新增',
527
- layout: res.xAddFormLayout,
528
- ...res,
529
- fixedAddForm: param,
530
- modifyModelData: {
531
- files: param.files,
532
- images: param.images
533
- }
534
- })
535
- }, this.env === 'dev')
536
- }
537
- }
538
- },
539
- getEventHandlers (cell) {
540
- const handlers = {}
541
- if (!cell?.events || cell?.events?.length === 0) {
542
- return handlers
543
- }
544
- cell.events.forEach(event => {
545
- handlers[event.type] = async (...args) => {
546
- console.info('Event handled:', event.type, args)
547
- let func = event.customFunction
548
- if (func && func.startsWith('function')) {
549
- func = func.replace('function', 'async function')
550
- }
551
- const result = await executeStrFunctionByContext(this, func, args)
552
- if (result instanceof Promise) {
553
- result.then((res) => {
554
- if (!res) return
555
- let messageType = 'success'
556
- // 如果传递了组件名字 自动调用刷新
557
- if (res?.name) {
558
- const waitRefreshRef = this.getComponentByName(res.name)
559
- if (waitRefreshRef) {
560
- waitRefreshRef.refresh()
561
- } else {
562
- console.warn(`未找到组件${res.name}无法刷新`)
563
- }
564
- }
565
- // 如果传递消息类型 自动调用消息
566
- if (res?.messageType) {
567
- messageType = res.messageType
568
- }
569
- // 如果传递了提示信息自动调用提示
570
- if (res?.message) {
571
- this.$message[messageType](res?.message)
572
- }
573
- })
574
- }
575
- }
576
- })
577
- return handlers
578
- },
579
- getComponentName (queryParamsName, serviceName, componentName) {
580
- // const config = await getConfigByName(queryParamsName, serviceName)
581
- // const componentName = config.$globalProp.type
582
- return componentName
583
- },
584
- updateImg (data) {
585
- this.$emit('updateImg', data)
586
- },
587
- formatImgStr (str) {
588
- const result = []
589
- if (str !== '') {
590
- const arr = str.split('/')
591
- result.push({
592
- uid: nanoid(6),
593
- url: str,
594
- name: arr[arr.length - 1],
595
- status: 'done'
596
- })
597
- }
598
- this.uploadParams.acceptCount = 1
599
- return result
600
- },
601
- checkImg (index, type) {
602
- let target
603
- if (type === 'configData') {
604
- target = this.configData.images[index]
605
- } else {
606
- target = this.config.tempData[index]
607
- }
608
- if (typeof target !== 'object') {
609
- return this.formatImgStr(target)
610
- }
611
- target.forEach(obj => {
612
- if (obj.uid === undefined) {
613
- obj.uid = obj.id.toString()
614
- }
615
- if (obj.url === undefined) {
616
- if (obj.path) {
617
- obj.url = obj.path
618
- }
619
- }
620
- if (obj.name === undefined) {
621
- const withOutEndFix = obj.url.split('.')[0]
622
- const temp = withOutEndFix.split('/')
623
- obj.name = temp[temp.length - 1]
624
- }
625
- if (obj.status === undefined) {
626
- obj.status = 'done'
627
- }
628
- })
629
- return target
630
- },
631
- // 判断单元格样式
632
- determineCellStyle (cell, color = '#000', borderWidth = '1px') {
633
- // 如果声明了borderColor
634
- if (this.config.style.borderColor) {
635
- color = this.config.style.borderColor
636
- }
637
- // // 如果声明了borderWidth
638
- // if (this.config.style.borderWidth) {
639
- // borderWidth = this.config.style.borderWidth
640
- // }
641
- // // 普通带边框单元格
642
- // const withBorder = {
643
- // border: borderWidth + ' solid ' + color,
644
- // padding: '8px'
645
- // }
646
- // // 只有左右边框的单元格
647
- // const noBorder = {
648
- // borderLeft: borderWidth + ' solid ' + color,
649
- // borderRight: borderWidth + ' solid ' + color,
650
- // padding: '8px'
651
- // }
652
- // // 只没有上边框的单元格
653
- // const NoTopBorder = {
654
- // borderTopStyle: 'none',
655
- // borderLeft: borderWidth + ' solid ' + color,
656
- // borderRight: borderWidth + ' solid ' + color,
657
- // borderBottom: borderWidth + ' solid ' + color,
658
- // padding: '8px'
659
- // }
660
- let result = {}
661
- // 如果表格也声明了样式,用表格样式将样式覆盖
662
- if (cell.style) {
663
- if (cell.noBorder) {
664
- result = { ...cell.style }
665
- } else {
666
- if (this.noTopBorder) {
667
- result = { ...cell.style }
668
- } else {
669
- result = { ...cell.style }
670
- }
671
- }
672
- return result
673
- }
674
- return result
675
- },
676
- // 表格中数据key含有@@@,需要手动触发更新
677
- handleInputDeepChange () {
678
- this.$forceUpdate()
679
- },
680
- // 路径中含有@@@的key,将其解析,并返回其数据
681
- getDeepObject (obj, strPath) {
682
- if (!strPath) {
683
- return ''
684
- }
685
- const arr = strPath.split('@@@')
686
- let result = obj[arr[0]]
687
- arr.shift()
688
- try {
689
- while (arr.length > 0) {
690
- result = result[arr[0]]
691
- arr.shift()
692
- }
693
- } catch (e) {
694
- result = undefined
695
- }
696
- return result
697
- },
698
- // 获取当前日期
699
- getNowDate (index1, index2) {
700
- if (index2) {
701
- // @click="getNowDate(configData.arr[inputColumnsDefinitionIndex][cell.dataIndex])"
702
- this.configData.arr[index1][index2] = formatDate('now')
703
- } else {
704
- this.configData[index1] = formatDate('now')
705
- }
706
- this.configData = Object.assign({}, this.configData)
707
- },
708
- // 反序列化函数并执行
709
- deserializeFunctionAndRun (functionStr, value) {
710
- // eslint-disable-next-line no-eval
711
- const fun = eval('(' + functionStr + ')')
712
- return fun(value, this.config)
713
- },
714
- // 基础上传组件,图片改动后触发
715
- setImages (args, type, index = undefined) {
716
- // 如果基础上传组件在初始化完成后,就调用emit了setImage,此时图片并没有变化,直接返回
717
- if (args[2] === 'created') {
718
- return
719
- }
720
- if (type === 'configData') {
721
- this.configData.images[args[1]] = args[0]
722
- } else {
723
- this.config.tempData[args[1]] = args[0]
724
- if (index) {
725
- this.$emit('updateImg', this.config.tempData[index])
726
- }
727
- }
728
- },
729
- // 动态行删除
730
- removeData (index) {
731
- if (this.configData[index].length === 0) {
732
- this.$message.warn('已经没有更多了')
733
- return
734
- }
735
- this.configData[index].pop()
736
- },
737
- // 添加一行
738
- addData (index, row) {
739
- // 获取定义
740
- const defs = row[0].definition
741
-
742
- // 获取外层对象名
743
- const dataName = row[0].dataIndex
744
- const temp = {}
745
-
746
- defs.forEach(def => {
747
- // 找到数组中最后一个数据的值
748
- let lastDataNo = 0
749
- if (this.configData[dataName][this.configData[dataName].length - 1]) {
750
- lastDataNo = this.configData[dataName][this.configData[dataName].length - 1][def.dataIndex]
751
- }
752
-
753
- // 如果没有值,检查是否声明了初始值
754
- if (lastDataNo === 0 && def.initialValue) {
755
- lastDataNo = def.initialValue
756
- }
757
-
758
- // 检查是否有步长
759
- let step = 1
760
- if (def.step) {
761
- step = def.step
762
- }
763
-
764
- // 如果单元格类型为increment,则进行自增
765
- if (def.type === 'increment') {
766
- temp[def.dataIndex] = lastDataNo + step
767
- }
768
- })
769
- this.configData[index].push(temp)
770
- },
771
- // 根据format计算需要多少个输入框
772
- calcFormatInputNum (formatStr) {
773
- let count = 0
774
- for (let i = 0; i < formatStr.length; i++) {
775
- if (formatStr[i] === '{') {
776
- count++
777
- }
778
- }
779
- return count
780
- },
781
- // 根据format计算输入框之后的文字显示
782
- displayFormatText (formatStr, num) {
783
- let start = 0
784
- let count = 0
785
- num++
786
- for (let i = 0; i < formatStr.length; i++) {
787
- if (formatStr[i] === '}') {
788
- start = i
789
- count++
790
- }
791
- if (count === num) {
792
- for (let j = start + 1; j < formatStr.length; j++) {
793
- if (formatStr[j] === '{') {
794
- return formatStr.slice(start + 1, j)
795
- }
796
- if (j === formatStr.length - 1 && formatStr[j] !== '}') {
797
- return formatStr[j]
798
- }
799
- }
800
- }
801
- }
802
- },
803
- calcTDBorder (cellNoBorder = false) {
804
- if (cellNoBorder) {
805
- return 'tdNoBorder'
806
- } else {
807
- if (this.noTopBorder) {
808
- return 'tdWithNoTopBorder'
809
- } else {
810
- return 'tdWithBorder'
811
- }
812
- }
813
- },
814
- // 根据format计算输入框之前的文字显示
815
- displayFormatStartText (formatStr) {
816
- let count = 0
817
- for (let i = 0; i < formatStr.length; i++) {
818
- if (formatStr[i] === '{') {
819
- break
820
- } else {
821
- count++
822
- }
823
- }
824
- return formatStr.slice(0, count)
825
- },
826
- // 拼接被自动拆分的单元格内容
827
- showSubRowValue (cell) {
828
- const dataName = cell.dataIndex
829
- const formatArr = []
830
- const dataArr = []
831
-
832
- // 从config中取出所有数据,根据dataIndex的开头内容进行拼接
833
- this.config.columns.forEach(row => row.forEach(cell => {
834
- if (cell.dataIndex && cell.dataIndex.startsWith(dataName)) {
835
- formatArr.push(cell.format)
836
- dataArr.push(this.configData[cell.dataIndex])
837
- }
838
- }))
839
-
840
- const text = []
841
- const data = []
842
-
843
- formatArr.forEach(word => {
844
- const temp = word.split('{}')
845
- temp.forEach(char => {
846
- if (char !== '') {
847
- text.push(char)
848
- }
849
- })
850
- })
851
-
852
- dataArr.forEach(item => {
853
- item.forEach(num => {
854
- data.push(num)
855
- })
856
- })
857
-
858
- let result = ''
859
- for (let i = 0; i < data.length; i++) {
860
- result += data[i]
861
- result += text[i]
862
- }
863
-
864
- return result
865
- },
866
- // 把用户定义的组件,传递到整个杉格中,方便调用
867
- passComponentNamesToAncestor (refs) {
868
- console.log('组件的keys', Object.entries(refs), refs)
869
- // 遍历所有 refs
870
- Object.entries(refs).forEach(([refKey, refValue]) => {
871
- // 检查 ref 是否以 dynamicComponent_ 开头
872
- if (refKey.startsWith('dynamicComponent_')) {
873
- console.log('组件名存在')
874
- const componentRef = refValue[0]
875
- if (componentRef) {
876
- // 去掉前缀并获取组件名字
877
- const index = refKey.replace('dynamicComponent_', '') // 去掉前缀
878
- console.log('注册组件', index)
879
- // 传递给祖先组件
880
- this.registerComponent(index, componentRef)
881
- }
882
- }
883
- })
884
- }
885
- },
886
- beforeMount () {
887
- if (this.useOssForImg) {
888
- this.uploadParams.resUploadMode = 'oss'
889
- }
890
- },
891
- mounted () {
892
- },
893
- }
894
-
895
- </script>
896
-
897
- <style scoped lang="less">
898
- .inputsDiv {
899
- display: flex;
900
- justify-content: space-between;
901
-
902
- .inputsDivItem {
903
- display: flex;
904
- align-items: center;
905
- padding: 0 4px;
906
- white-space: nowrap;
907
-
908
- .inputsDivItemLabel {
909
- padding: 0 4px;
910
- }
911
- }
912
- }
913
-
914
- .tdNoBorder {
915
- border-left: 1px solid #000;
916
- border-right: 1px solid #000;
917
- padding: 8px;
918
- }
919
-
920
- .tdWithBorder {
921
- border: 1px solid #000;
922
- padding: 8px;
923
- }
924
-
925
- .tdWithNoTopBorder {
926
- border-top-style: none;
927
- border-left: 1px solid #000;
928
- border-right: 1px solid #000;
929
- border-bottom: 1px solid #000;
930
- padding: 8px;
931
- }
932
-
933
- .grid-content {
934
- border-radius: 4px;
935
- min-height: 36px;
936
- text-align: center;
937
- color: #fff;
938
- background-color: #606266;
939
- }
940
-
941
- .bg-purple {
942
- background: #9254de;
943
- }
944
-
945
- .bg-purple-light {
946
- background: #b37feb;
947
- }
948
- </style>
1
+ <template>
2
+ <a-row :gutter="gutter">
3
+ <!-- 预览页展示 -->
4
+ <template v-if="display">
5
+ <template v-if="!inputColumns">
6
+ <a-col
7
+ name="trGroup"
8
+ v-for="(cell, cellIndex) in columns"
9
+ v-if="!cell.dontShowRow"
10
+ :key="cellIndex"
11
+ :style="determineCellStyle(cell)"
12
+ :span="cell.colSpan ? cell.colSpan * 2 : undefined">
13
+ <!-- 插槽渲染 -->
14
+ <template v-if="cell.type === 'slot'">
15
+ <template v-if="['x-form-table','x-add-native-form','x-tree-pro', 'x-his-editor', 'x-tab'].includes(cell.slotType)">
16
+ <component
17
+ :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
18
+ :key="cellIndex"
19
+ :ref="`dynamicComponent_${ cell.slotRef || cellIndex}`"
20
+ :serviceName="cell.serviceName"
21
+ :serverName="cell.serviceName"
22
+ v-on="getEventHandlers(cell)"
23
+ @hook:mounted="(h)=>onComponentMounted(h,cell,cellIndex)"
24
+ :queryParamsName="cell.slotConfig"
25
+ :configName="cell.slotConfig"
26
+ :countVisible="false"
27
+ :env="env"
28
+ />
29
+ </template>
30
+ </template>
31
+ <!-- button 按钮渲染 -->
32
+ <template v-else-if="cell.type === 'button'">
33
+ <a-button v-on="getEventHandlers(cell)">
34
+ {{ cell.buttonName }}
35
+ </a-button>
36
+ </template>
37
+ <template v-else-if="cell.type === 'column'">
38
+ <template v-if="cell.customFunction">
39
+ {{ deserializeFunctionAndRun(cell.customFunction, configData[cell.dataIndex], config) }}
40
+ </template>
41
+ <template v-else>
42
+ {{ cell.text }}
43
+ </template>
44
+ </template>
45
+ <!-- 占位 -->
46
+ <template v-else-if="cell.type === 'placeHolderColumn'">
47
+ </template>
48
+ <template v-else-if="cell.type === 'value'">
49
+ <template v-if="cell.customFunction === undefined">
50
+ {{ cell.value }}
51
+ </template>
52
+ <template v-else>
53
+ {{ deserializeFunctionAndRun(cell.customFunction, cell.value, config) }}
54
+ </template>
55
+ </template>
56
+ <template v-else-if="cell.type === 'input'">
57
+ <template v-if="cell.customFunction === undefined">
58
+ {{ getDeepObject(configData, cell.dataIndex) }}
59
+ </template>
60
+ <template v-else>
61
+ {{ deserializeFunctionAndRun(cell.customFunction, configData[cell.dataIndex], config) }}
62
+ </template>
63
+ </template>
64
+ <template v-else-if="cell.type === 'inputs'">
65
+ <template v-if="cell.customFunction === undefined">
66
+ {{ showSubRowValue(cell) }}
67
+ </template>
68
+ <template v-else>
69
+ {{ deserializeFunctionAndRun(cell.customFunction, showSubRowValue(cell), config) }}
70
+ </template>
71
+ </template>
72
+ <template v-else-if="cell.type === 'list'">
73
+ <template v-if="listIndex === 0">
74
+ <span style="font-weight: bold">{{ cell.listHead }}</span>
75
+ </template>
76
+ <template v-else-if="cell.listType === 'input'">
77
+ {{ getDeepObject(configData, cell.dataIndex)[listIndex] }}
78
+ </template>
79
+ <template v-else-if="cell.listType === 'value'">
80
+ {{ cell.content[listIndex] }}
81
+ </template>
82
+ <template v-else-if="cell.listType === 'variable'">
83
+ {{ configData[cell.dataIndex][listIndex - 1][cell.listDataIndex] }}
84
+ </template>
85
+ </template>
86
+ <template v-else-if="cell.type === 'images'">
87
+ <template
88
+ v-if="getDeepObject(configData.images, cell.dataIndex) === undefined || getDeepObject(configData.images, cell.dataIndex).length === 0">
89
+ <template
90
+ v-if="getDeepObject(configData, cell.dataIndex) === undefined || getDeepObject(configData, cell.dataIndex).length === 0">
91
+ <span>无</span>
92
+ </template>
93
+ <template v-else>
94
+ <template v-if="typeof getDeepObject(configData, cell.dataIndex) === 'object'">
95
+ <div style="display: flex; align-items: end; justify-content: space-evenly; flex-wrap: wrap">
96
+ <template v-for="(img,imgIndex) in getDeepObject(configData, cell.dataIndex)">
97
+ <template v-if="showImgInCell">
98
+ <div :key="imgIndex">
99
+ <img :src="img.url" alt="图片"/>
100
+ <p>{{ img.name }}</p>
101
+ </div>
102
+ </template>
103
+ <template v-else>
104
+ <span :key="imgIndex" style="margin-right: 5%">{{ img.name }}</span>
105
+ </template>
106
+ </template>
107
+ </div>
108
+ </template>
109
+ <template v-else>
110
+ <img :src="getDeepObject(configData, cell.dataIndex)" alt="图片"/>
111
+ <p style="margin-right: 5%">{{ formatImgStr(getDeepObject(configData, cell.dataIndex))[0].name }}</p>
112
+ </template>
113
+ </template>
114
+ </template>
115
+ <template v-else v-for="(img,imgIndex) in getDeepObject(configData.images, cell.dataIndex)">
116
+ <span :key="imgIndex" style="margin-right: 5%">{{ img.name }}</span>
117
+ </template>
118
+ </template>
119
+ </a-col>
120
+ </template>
121
+ <template v-else>
122
+ <a-col
123
+ v-for="(cell, cellIndex) in columns"
124
+ :key="cellIndex"
125
+ :class=" calcTDBorder(cell.noBoarder) "
126
+ :span="cell.colSpan ? cell.colSpan * 2 : undefined"
127
+ :style="determineCellStyle(cell)"
128
+ :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
129
+ <template v-if="cell.type === 'column'">
130
+ {{ cell.text }}
131
+ </template>
132
+ <template v-else-if="cell.type === 'value'">
133
+ <template v-if="cell.customFunction === undefined">
134
+ {{ cell.value }}
135
+ </template>
136
+ <template v-else>
137
+ {{ deserializeFunctionAndRun(cell.customFunction, cell.value, config) }}
138
+ </template>
139
+ </template>
140
+ <template v-else-if="cell.type === 'increment'">
141
+ <template v-if="cell.customFunction === undefined">
142
+ {{ getDeepObject(configData.arr[inputColumnsDefinitionIndex], cell.dataIndex) }}
143
+ </template>
144
+ <template v-else>
145
+ {{
146
+ deserializeFunctionAndRun(cell.customFunction, configData.arr[inputColumnsDefinitionIndex][cell.dataIndex], config)
147
+ }}
148
+ </template>
149
+ </template>
150
+ <template v-else-if="cell.type === 'input'">
151
+ <template v-if="cell.customFunction === undefined">
152
+ {{ getDeepObject(configData.arr[inputColumnsDefinitionIndex], cell.dataIndex) }}
153
+ </template>
154
+ <template v-else>
155
+ {{
156
+ deserializeFunctionAndRun(cell.customFunction, configData.arr[inputColumnsDefinitionIndex][cell.dataIndex], config)
157
+ }}
158
+ </template>
159
+ </template>
160
+ <template v-else-if="cell.type === 'inputs'">
161
+ <template v-if="cell.customFunction === undefined">
162
+ {{ getDeepObject(configData.arr[inputColumnsDefinitionIndex], cell.dataIndex) }}
163
+ </template>
164
+ <template v-else>
165
+ {{
166
+ deserializeFunctionAndRun(cell.customFunction, configData.arr[inputColumnsDefinitionIndex][cell.dataIndex], config)
167
+ }}
168
+ </template>
169
+ </template>
170
+ </a-col>
171
+ </template>
172
+ </template>
173
+ <!-- 不是动态行 -->
174
+ <template v-else-if="!inputColumns">
175
+ <a-col
176
+ v-for="(cell, cellIndex) in columns"
177
+ :key="cellIndex"
178
+ :class=" calcTDBorder(cell.noBoarder) "
179
+ :span="cell.colSpan ? cell.colSpan * 2 : undefined"
180
+ :style="determineCellStyle(cell)"
181
+ :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
182
+ <template v-if="cell.type === 'column'">
183
+ <template v-if="cell.customFunction">
184
+ {{ deserializeFunctionAndRun(cell.customFunction, configData[cell.dataIndex], config) }}
185
+ </template>
186
+ <template v-else>
187
+ {{ cell.text }}
188
+ </template>
189
+ </template>
190
+ <template v-else-if="cell.type === 'placeHolderColumn'">
191
+ <!-- 占位 -->
192
+ </template>
193
+ <template v-else-if="cell.type === 'value'">
194
+ {{ cell.value }}
195
+ </template>
196
+ <template v-else-if="cell.type === 'curDateInput'">
197
+ <a-button type="dashed" v-if="configData[cell.dataIndex]">
198
+ {{ configData[cell.dataIndex] }}
199
+ </a-button>
200
+ <a-button
201
+ v-if="!configData[cell.dataIndex]"
202
+ type="primary"
203
+ @click="getNowDate(cell.dataIndex)"
204
+ >{{ cell.text || '确认' }}
205
+ </a-button>
206
+ </template>
207
+ <template v-else-if="cell.type === 'input'">
208
+ <template v-if="cell.inputReadOnly === true">
209
+ <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
210
+ <a-input
211
+ @change="handleInputDeepChange($event, cell.dataIndex)"
212
+ v-model="config.tempData[cell.dataIndex]"
213
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
214
+ :disabled="true"/>
215
+ </template>
216
+ <template v-else>
217
+ <a-input
218
+ v-model="configData[cell.dataIndex]"
219
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
220
+ :disabled="true"/>
221
+ </template>
222
+ </template>
223
+ <template v-else>
224
+ <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
225
+ <a-input
226
+ @change="handleInputDeepChange($event, cell.dataIndex)"
227
+ v-model="config.tempData[cell.dataIndex]"
228
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
229
+ </template>
230
+ <template v-else>
231
+ <a-input
232
+ v-model="configData[cell.dataIndex]"
233
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
234
+ </template>
235
+ </template>
236
+ </template>
237
+ <template v-else-if="cell.type === 'inputs'">
238
+ <template v-if="cell.inputReadOnly === true">
239
+ <div class="inputsDiv">
240
+ <div class="inputsDivItem" v-for="(num, index) of calcFormatInputNum(cell.format)" :key="index">
241
+ <span class="inputsDivItemLabel">{{ displayFormatStartText(cell.format) }}</span>
242
+ <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
243
+ <a-input
244
+ @change="handleInputDeepChange($event, cell.dataIndex)"
245
+ v-model="config.tempData[cell.dataIndex][index]"
246
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
247
+ :disabled="true"/>
248
+ </template>
249
+ <template v-else>
250
+ <a-input
251
+ v-model="configData[cell.dataIndex][index]"
252
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
253
+ :disabled="true"/>
254
+ </template>
255
+ <span class="inputsDivItemLabel">{{ displayFormatText(cell.format, index) }}</span>
256
+ </div>
257
+ </div>
258
+ </template>
259
+ <template v-else>
260
+ <div class="inputsDiv">
261
+ <div class="inputsDivItem" v-for="(num, index) of calcFormatInputNum(cell.format)" :key="index">
262
+ <span class="inputsDivItemLabel">{{ displayFormatStartText(cell.format) }}</span>
263
+ <template v-if="cell.dataIndex.indexOf('@@@') !== -1">
264
+ <a-input
265
+ @change="handleInputDeepChange($event, cell.dataIndex)"
266
+ v-model="config.tempData[cell.dataIndex][index]"
267
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
268
+ </template>
269
+ <template v-else>
270
+ <a-input
271
+ v-model="configData[cell.dataIndex][index]"
272
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
273
+ </template>
274
+ <span class="inputsDivItemLabel">{{ displayFormatText(cell.format, index) }}</span>
275
+ </div>
276
+ </div>
277
+ </template>
278
+ </template>
279
+ <template v-else-if="cell.type === 'list'">
280
+ <template v-if="cell.listType === 'input'">
281
+ <a-input
282
+ v-model="configData[cell.dataIndex][listIndex]"
283
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
284
+ </template>
285
+ <template v-else-if="cell.listType === 'value'">
286
+ {{ cell.content[listIndex] }}
287
+ </template>
288
+ </template>
289
+ <template v-else-if="cell.type === 'images'">
290
+ <div>
291
+ <template v-if="configData.images[cell.dataIndex]?.length > 0">
292
+ <upload
293
+ :model="uploadParams"
294
+ :img-prefix="imgPrefix"
295
+ :service-name="serverName"
296
+ :images="checkImg(cell.dataIndex, 'configData')"
297
+ :outer-container-index="cell.dataIndex"
298
+ @setFiles="(...args) => {setImages(args, 'configData')}"
299
+ :upload-style="'simple'"
300
+ />
301
+ </template>
302
+ <template v-else>
303
+ <upload
304
+ :model="uploadParams"
305
+ :img-prefix="imgPrefix"
306
+ :service-name="serverName"
307
+ :images="checkImg(cell.dataIndex, 'config')"
308
+ :outer-container-index="cell.dataIndex"
309
+ @setFiles="(...args) => {setImages(args, 'config', cell.dataIndex)}"
310
+ :upload-style="'simple'"
311
+ />
312
+ </template>
313
+ </div>
314
+ </template>
315
+ </a-col>
316
+ </template>
317
+ <!-- 动态行插入按钮 -->
318
+ <template v-else-if="inputColumnsButton">
319
+ <a-col :span="maxColSpan" :class="calcTDBorder()">
320
+ <a-button-group>
321
+ <a-button @click="addData(columns[0].dataIndex, columns)">
322
+ <a-icon type="plus"/>
323
+ </a-button>
324
+ <a-button @click="removeData(columns[0].dataIndex)">
325
+ <a-icon type="minus"/>
326
+ </a-button>
327
+ </a-button-group>
328
+ </a-col>
329
+ </template>
330
+ <!-- 其他行 -->
331
+ <template v-else>
332
+ <a-col
333
+ v-for="(cell, cellIndex) in columns"
334
+ :key="cellIndex"
335
+ :class=" calcTDBorder(cell.noBoarder) "
336
+ :span="cell.colSpan ? cell.colSpan * 2 : undefined"
337
+ :style="determineCellStyle(cell)"
338
+ :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
339
+ <template v-if="cell.type === 'column'">
340
+ {{ cell.text }}
341
+ </template>
342
+ <template v-else-if="cell.type === 'value'">
343
+ {{ cell.value }}
344
+ </template>
345
+ <template v-else-if="cell.type === 'curDateInput'">
346
+ <a-button type="dashed" v-if="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]">
347
+ {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
348
+ </a-button>
349
+ <a-button
350
+ v-if="!configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
351
+ type="primary"
352
+ @click="getNowDate(inputColumnsDefinitionIndex,cell.dataIndex)"
353
+ >{{ cell.text || '确认' }}
354
+ </a-button>
355
+ </template>
356
+ <template v-else-if="cell.type === 'increment'">
357
+ {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
358
+ </template>
359
+ <template v-else-if="cell.type === 'input'">
360
+ <template v-if="cell.inputReadOnly === true">
361
+ <a-input
362
+ v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
363
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
364
+ :disabled="true"/>
365
+ </template>
366
+ <template v-else>
367
+ <a-input
368
+ v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
369
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
370
+ </template>
371
+ </template>
372
+ <template v-else-if="cell.type === 'inputs'">
373
+ <template v-if="cell.inputReadOnly === true">
374
+ <a-input
375
+ v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
376
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"
377
+ :disabled="true"/>
378
+ </template>
379
+ <template v-else>
380
+ <a-input
381
+ v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]"
382
+ :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
383
+ </template>
384
+ </template>
385
+ </a-col>
386
+ </template>
387
+ </a-row>
388
+ </template>
389
+
390
+ <script>
391
+ import Upload from '@vue2-client/base-client/components/common/Upload'
392
+ import { formatDate } from '@vue2-client/utils/util'
393
+ import { nanoid } from 'nanoid'
394
+ import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
395
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
396
+
397
+ export default {
398
+ name: 'XReportTrGroup',
399
+ components: {
400
+ Upload,
401
+ XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'),
402
+ XAddNativeForm: () => import('@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'),
403
+ XTreePro: () => import('@vue2-client/base-client/components/common/XTree/XTreePro.vue'),
404
+ XHisEditor: () => import('@vue2-client/base-client/components/his/XHisEditor/XHisEditor.vue'),
405
+ XTab: () => import('@vue2-client/base-client/components/common/XTab/XTab.vue')
406
+ },
407
+ props: {
408
+ // 每一行的配置
409
+ columns: {
410
+ type: Array,
411
+ required: true
412
+ },
413
+ showImgInCell: {
414
+ type: Boolean,
415
+ default: false
416
+ },
417
+ config: {
418
+ type: Object,
419
+ default: function () {
420
+ return {}
421
+ }
422
+ },
423
+ // 命名空间
424
+ serverName: {
425
+ type: String,
426
+ default: 'af-system'
427
+ },
428
+ // 环境
429
+ env: {
430
+ type: String,
431
+ default: 'prod'
432
+ },
433
+ // 原始配置
434
+ configData: {
435
+ type: Object,
436
+ required: true
437
+ },
438
+ // 是否为动态行
439
+ inputColumns: {
440
+ type: Boolean,
441
+ default: false
442
+ },
443
+ // 是否为动态行按钮
444
+ inputColumnsButton: {
445
+ type: Boolean,
446
+ default: false
447
+ },
448
+ // 动态行的Index
449
+ inputColumnsDefinitionIndex: {
450
+ type: Number,
451
+ default: undefined
452
+ },
453
+ // 是否为展示行
454
+ display: {
455
+ type: Boolean,
456
+ default: false
457
+ },
458
+ // list类型的下标,用于遍历列表时,获取对应的数据
459
+ listIndex: {
460
+ type: Number,
461
+ default: undefined
462
+ },
463
+ // 表格没有上边框
464
+ noTopBorder: {
465
+ type: Boolean,
466
+ default: false
467
+ },
468
+ // 图片是否使用OSS来保存
469
+ useOssForImg: {
470
+ type: Boolean,
471
+ default: true
472
+ },
473
+ // 图片上传后添加前缀
474
+ imgPrefix: {
475
+ type: String,
476
+ default: undefined
477
+ }
478
+ },
479
+ data () {
480
+ return {
481
+ gutter: [16, { xs: 8, sm: 16, md: 24, lg: 32 }], // 设置水槽大小
482
+ maxColSpan: 12,
483
+ uploadParams: {
484
+ type: 'image',
485
+ accept: ['*'],
486
+ resUploadStock: 1,
487
+ pathKey: 'cs'
488
+ },
489
+ mixinData: {}
490
+ // tableConfig: {}
491
+ }
492
+ },
493
+ inject: ['openDialog', 'registerComponent', 'getComponentByName', 'runLogic', 'getMixinData', 'getSelectedId', 'isInAModal', 'getConfigByName', 'getSelectedData', 'getOutEnv'],
494
+ methods: {
495
+ onComponentMounted (h, cell, cellIndex) {
496
+ if (this.getMixinData && this.getMixinData()) {
497
+ this.mixinData = this.getMixinData()
498
+ }
499
+ if (cell.slotRef) {
500
+ this.registerComponent(cell.slotRef, this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0])
501
+ }
502
+ // 传递给祖先组件
503
+ console.log(`插槽组件已经初始化 slotType ${cell.slotType},ref= dynamicComponent_${cell.slotRef || cellIndex} , serviceName = ${cell.serviceName}`)
504
+ const shouldInit = cell.shouldInit == null ? true : cell.shouldInit
505
+ if (shouldInit) {
506
+ if (cell.slotType === 'x-add-native-form' && shouldInit) {
507
+ // 建议表单需要主动调用初始化方法
508
+ getConfigByName(cell.slotConfig, cell.serviceName, async (res) => {
509
+ // 如果配置了 表单初始化logic
510
+ // 调用 logic 获取参数
511
+ let param = { ...this.mixinData }
512
+ let selectedId
513
+ if (res.paramLogicName) {
514
+ if (!!this.getSelectedId) {
515
+ selectedId = this.getSelectedId()
516
+ if (typeof selectedId !== 'object') {
517
+ selectedId = { selectedId: selectedId }
518
+ }
519
+ }
520
+ param = Object.assign(param, await runLogic(res.paramLogicName, selectedId, cell.serviceName))
521
+ }
522
+ this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
523
+ serviceName: cell.serviceName,
524
+ formItems: res.formJson,
525
+ showSubmitBtn: !this.isInAModal,
526
+ businessType: param.businessType || '新增',
527
+ layout: res.xAddFormLayout,
528
+ ...res,
529
+ fixedAddForm: param,
530
+ modifyModelData: {
531
+ files: param.files,
532
+ images: param.images
533
+ }
534
+ })
535
+ }, this.env === 'dev')
536
+ }
537
+ }
538
+ },
539
+ getEventHandlers (cell) {
540
+ const handlers = {}
541
+ if (!cell?.events || cell?.events?.length === 0) {
542
+ return handlers
543
+ }
544
+ cell.events.forEach(event => {
545
+ handlers[event.type] = async (...args) => {
546
+ console.info('Event handled:', event.type, args)
547
+ let func = event.customFunction
548
+ if (func && func.startsWith('function')) {
549
+ func = func.replace('function', 'async function')
550
+ }
551
+ const result = await executeStrFunctionByContext(this, func, args)
552
+ if (result instanceof Promise) {
553
+ result.then((res) => {
554
+ if (!res) return
555
+ let messageType = 'success'
556
+ // 如果传递了组件名字 自动调用刷新
557
+ if (res?.name) {
558
+ const waitRefreshRef = this.getComponentByName(res.name)
559
+ if (waitRefreshRef) {
560
+ waitRefreshRef.refresh()
561
+ } else {
562
+ console.warn(`未找到组件${res.name}无法刷新`)
563
+ }
564
+ }
565
+ // 如果传递消息类型 自动调用消息
566
+ if (res?.messageType) {
567
+ messageType = res.messageType
568
+ }
569
+ // 如果传递了提示信息自动调用提示
570
+ if (res?.message) {
571
+ this.$message[messageType](res?.message)
572
+ }
573
+ })
574
+ }
575
+ }
576
+ })
577
+ return handlers
578
+ },
579
+ getComponentName (queryParamsName, serviceName, componentName) {
580
+ // const config = await getConfigByName(queryParamsName, serviceName)
581
+ // const componentName = config.$globalProp.type
582
+ return componentName
583
+ },
584
+ updateImg (data) {
585
+ this.$emit('updateImg', data)
586
+ },
587
+ formatImgStr (str) {
588
+ const result = []
589
+ if (str !== '') {
590
+ const arr = str.split('/')
591
+ result.push({
592
+ uid: nanoid(6),
593
+ url: str,
594
+ name: arr[arr.length - 1],
595
+ status: 'done'
596
+ })
597
+ }
598
+ this.uploadParams.acceptCount = 1
599
+ return result
600
+ },
601
+ checkImg (index, type) {
602
+ let target
603
+ if (type === 'configData') {
604
+ target = this.configData.images[index]
605
+ } else {
606
+ target = this.config.tempData[index]
607
+ }
608
+ if (typeof target !== 'object') {
609
+ return this.formatImgStr(target)
610
+ }
611
+ target.forEach(obj => {
612
+ if (obj.uid === undefined) {
613
+ obj.uid = obj.id.toString()
614
+ }
615
+ if (obj.url === undefined) {
616
+ if (obj.path) {
617
+ obj.url = obj.path
618
+ }
619
+ }
620
+ if (obj.name === undefined) {
621
+ const withOutEndFix = obj.url.split('.')[0]
622
+ const temp = withOutEndFix.split('/')
623
+ obj.name = temp[temp.length - 1]
624
+ }
625
+ if (obj.status === undefined) {
626
+ obj.status = 'done'
627
+ }
628
+ })
629
+ return target
630
+ },
631
+ // 判断单元格样式
632
+ determineCellStyle (cell, color = '#000', borderWidth = '1px') {
633
+ // 如果声明了borderColor
634
+ if (this.config.style.borderColor) {
635
+ color = this.config.style.borderColor
636
+ }
637
+ // // 如果声明了borderWidth
638
+ // if (this.config.style.borderWidth) {
639
+ // borderWidth = this.config.style.borderWidth
640
+ // }
641
+ // // 普通带边框单元格
642
+ // const withBorder = {
643
+ // border: borderWidth + ' solid ' + color,
644
+ // padding: '8px'
645
+ // }
646
+ // // 只有左右边框的单元格
647
+ // const noBorder = {
648
+ // borderLeft: borderWidth + ' solid ' + color,
649
+ // borderRight: borderWidth + ' solid ' + color,
650
+ // padding: '8px'
651
+ // }
652
+ // // 只没有上边框的单元格
653
+ // const NoTopBorder = {
654
+ // borderTopStyle: 'none',
655
+ // borderLeft: borderWidth + ' solid ' + color,
656
+ // borderRight: borderWidth + ' solid ' + color,
657
+ // borderBottom: borderWidth + ' solid ' + color,
658
+ // padding: '8px'
659
+ // }
660
+ let result = {}
661
+ // 如果表格也声明了样式,用表格样式将样式覆盖
662
+ if (cell.style) {
663
+ if (cell.noBorder) {
664
+ result = { ...cell.style }
665
+ } else {
666
+ if (this.noTopBorder) {
667
+ result = { ...cell.style }
668
+ } else {
669
+ result = { ...cell.style }
670
+ }
671
+ }
672
+ return result
673
+ }
674
+ return result
675
+ },
676
+ // 表格中数据key含有@@@,需要手动触发更新
677
+ handleInputDeepChange () {
678
+ this.$forceUpdate()
679
+ },
680
+ // 路径中含有@@@的key,将其解析,并返回其数据
681
+ getDeepObject (obj, strPath) {
682
+ if (!strPath) {
683
+ return ''
684
+ }
685
+ const arr = strPath.split('@@@')
686
+ let result = obj[arr[0]]
687
+ arr.shift()
688
+ try {
689
+ while (arr.length > 0) {
690
+ result = result[arr[0]]
691
+ arr.shift()
692
+ }
693
+ } catch (e) {
694
+ result = undefined
695
+ }
696
+ return result
697
+ },
698
+ // 获取当前日期
699
+ getNowDate (index1, index2) {
700
+ if (index2) {
701
+ // @click="getNowDate(configData.arr[inputColumnsDefinitionIndex][cell.dataIndex])"
702
+ this.configData.arr[index1][index2] = formatDate('now')
703
+ } else {
704
+ this.configData[index1] = formatDate('now')
705
+ }
706
+ this.configData = Object.assign({}, this.configData)
707
+ },
708
+ // 反序列化函数并执行
709
+ deserializeFunctionAndRun (functionStr, value) {
710
+ // eslint-disable-next-line no-eval
711
+ const fun = eval('(' + functionStr + ')')
712
+ return fun(value, this.config)
713
+ },
714
+ // 基础上传组件,图片改动后触发
715
+ setImages (args, type, index = undefined) {
716
+ // 如果基础上传组件在初始化完成后,就调用emit了setImage,此时图片并没有变化,直接返回
717
+ if (args[2] === 'created') {
718
+ return
719
+ }
720
+ if (type === 'configData') {
721
+ this.configData.images[args[1]] = args[0]
722
+ } else {
723
+ this.config.tempData[args[1]] = args[0]
724
+ if (index) {
725
+ this.$emit('updateImg', this.config.tempData[index])
726
+ }
727
+ }
728
+ },
729
+ // 动态行删除
730
+ removeData (index) {
731
+ if (this.configData[index].length === 0) {
732
+ this.$message.warn('已经没有更多了')
733
+ return
734
+ }
735
+ this.configData[index].pop()
736
+ },
737
+ // 添加一行
738
+ addData (index, row) {
739
+ // 获取定义
740
+ const defs = row[0].definition
741
+
742
+ // 获取外层对象名
743
+ const dataName = row[0].dataIndex
744
+ const temp = {}
745
+
746
+ defs.forEach(def => {
747
+ // 找到数组中最后一个数据的值
748
+ let lastDataNo = 0
749
+ if (this.configData[dataName][this.configData[dataName].length - 1]) {
750
+ lastDataNo = this.configData[dataName][this.configData[dataName].length - 1][def.dataIndex]
751
+ }
752
+
753
+ // 如果没有值,检查是否声明了初始值
754
+ if (lastDataNo === 0 && def.initialValue) {
755
+ lastDataNo = def.initialValue
756
+ }
757
+
758
+ // 检查是否有步长
759
+ let step = 1
760
+ if (def.step) {
761
+ step = def.step
762
+ }
763
+
764
+ // 如果单元格类型为increment,则进行自增
765
+ if (def.type === 'increment') {
766
+ temp[def.dataIndex] = lastDataNo + step
767
+ }
768
+ })
769
+ this.configData[index].push(temp)
770
+ },
771
+ // 根据format计算需要多少个输入框
772
+ calcFormatInputNum (formatStr) {
773
+ let count = 0
774
+ for (let i = 0; i < formatStr.length; i++) {
775
+ if (formatStr[i] === '{') {
776
+ count++
777
+ }
778
+ }
779
+ return count
780
+ },
781
+ // 根据format计算输入框之后的文字显示
782
+ displayFormatText (formatStr, num) {
783
+ let start = 0
784
+ let count = 0
785
+ num++
786
+ for (let i = 0; i < formatStr.length; i++) {
787
+ if (formatStr[i] === '}') {
788
+ start = i
789
+ count++
790
+ }
791
+ if (count === num) {
792
+ for (let j = start + 1; j < formatStr.length; j++) {
793
+ if (formatStr[j] === '{') {
794
+ return formatStr.slice(start + 1, j)
795
+ }
796
+ if (j === formatStr.length - 1 && formatStr[j] !== '}') {
797
+ return formatStr[j]
798
+ }
799
+ }
800
+ }
801
+ }
802
+ },
803
+ calcTDBorder (cellNoBorder = false) {
804
+ if (cellNoBorder) {
805
+ return 'tdNoBorder'
806
+ } else {
807
+ if (this.noTopBorder) {
808
+ return 'tdWithNoTopBorder'
809
+ } else {
810
+ return 'tdWithBorder'
811
+ }
812
+ }
813
+ },
814
+ // 根据format计算输入框之前的文字显示
815
+ displayFormatStartText (formatStr) {
816
+ let count = 0
817
+ for (let i = 0; i < formatStr.length; i++) {
818
+ if (formatStr[i] === '{') {
819
+ break
820
+ } else {
821
+ count++
822
+ }
823
+ }
824
+ return formatStr.slice(0, count)
825
+ },
826
+ // 拼接被自动拆分的单元格内容
827
+ showSubRowValue (cell) {
828
+ const dataName = cell.dataIndex
829
+ const formatArr = []
830
+ const dataArr = []
831
+
832
+ // 从config中取出所有数据,根据dataIndex的开头内容进行拼接
833
+ this.config.columns.forEach(row => row.forEach(cell => {
834
+ if (cell.dataIndex && cell.dataIndex.startsWith(dataName)) {
835
+ formatArr.push(cell.format)
836
+ dataArr.push(this.configData[cell.dataIndex])
837
+ }
838
+ }))
839
+
840
+ const text = []
841
+ const data = []
842
+
843
+ formatArr.forEach(word => {
844
+ const temp = word.split('{}')
845
+ temp.forEach(char => {
846
+ if (char !== '') {
847
+ text.push(char)
848
+ }
849
+ })
850
+ })
851
+
852
+ dataArr.forEach(item => {
853
+ item.forEach(num => {
854
+ data.push(num)
855
+ })
856
+ })
857
+
858
+ let result = ''
859
+ for (let i = 0; i < data.length; i++) {
860
+ result += data[i]
861
+ result += text[i]
862
+ }
863
+
864
+ return result
865
+ },
866
+ // 把用户定义的组件,传递到整个杉格中,方便调用
867
+ passComponentNamesToAncestor (refs) {
868
+ console.log('组件的keys', Object.entries(refs), refs)
869
+ // 遍历所有 refs
870
+ Object.entries(refs).forEach(([refKey, refValue]) => {
871
+ // 检查 ref 是否以 dynamicComponent_ 开头
872
+ if (refKey.startsWith('dynamicComponent_')) {
873
+ console.log('组件名存在')
874
+ const componentRef = refValue[0]
875
+ if (componentRef) {
876
+ // 去掉前缀并获取组件名字
877
+ const index = refKey.replace('dynamicComponent_', '') // 去掉前缀
878
+ console.log('注册组件', index)
879
+ // 传递给祖先组件
880
+ this.registerComponent(index, componentRef)
881
+ }
882
+ }
883
+ })
884
+ }
885
+ },
886
+ beforeMount () {
887
+ if (this.useOssForImg) {
888
+ this.uploadParams.resUploadMode = 'oss'
889
+ }
890
+ },
891
+ mounted () {
892
+ },
893
+ }
894
+
895
+ </script>
896
+
897
+ <style scoped lang="less">
898
+ .inputsDiv {
899
+ display: flex;
900
+ justify-content: space-between;
901
+
902
+ .inputsDivItem {
903
+ display: flex;
904
+ align-items: center;
905
+ padding: 0 4px;
906
+ white-space: nowrap;
907
+
908
+ .inputsDivItemLabel {
909
+ padding: 0 4px;
910
+ }
911
+ }
912
+ }
913
+
914
+ .tdNoBorder {
915
+ border-left: 1px solid #000;
916
+ border-right: 1px solid #000;
917
+ padding: 8px;
918
+ }
919
+
920
+ .tdWithBorder {
921
+ border: 1px solid #000;
922
+ padding: 8px;
923
+ }
924
+
925
+ .tdWithNoTopBorder {
926
+ border-top-style: none;
927
+ border-left: 1px solid #000;
928
+ border-right: 1px solid #000;
929
+ border-bottom: 1px solid #000;
930
+ padding: 8px;
931
+ }
932
+
933
+ .grid-content {
934
+ border-radius: 4px;
935
+ min-height: 36px;
936
+ text-align: center;
937
+ color: #fff;
938
+ background-color: #606266;
939
+ }
940
+
941
+ .bg-purple {
942
+ background: #9254de;
943
+ }
944
+
945
+ .bg-purple-light {
946
+ background: #b37feb;
947
+ }
948
+ </style>