vue2-client 1.9.78 → 1.9.79

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 (337) hide show
  1. package/.env +19 -19
  2. package/.env.gaslink +19 -19
  3. package/.env.his +19 -19
  4. package/.env.revenue +19 -19
  5. package/.eslintrc.js +90 -90
  6. package/CHANGELOG.md +824 -824
  7. package/Components.md +60 -60
  8. package/babel.config.js +21 -21
  9. package/docs/Logic/345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +45 -45
  10. package/docs/LowCode/lowcode.md +155 -155
  11. package/docs/LowCode/lowcodeForDeveloper.md +230 -230
  12. package/docs/index.md +30 -30
  13. package/docs//345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +143 -143
  14. package/index.js +31 -31
  15. package/jest-transform-stub.js +8 -8
  16. package/jest.config.js +21 -21
  17. package/jest.setup.js +7 -7
  18. package/package.json +1 -1
  19. package/public/his/editor/editor.html +51 -51
  20. package/public/his/editor/mock/bind_data.html +779 -779
  21. package/public/his/editor/mock/data_table.html +40 -40
  22. package/public/his/editor/mock/sign.html +75 -75
  23. package/public/his/editor/vender/JsBarcode.all.js +3669 -3669
  24. package/public/his/editor/vender/date97/My97DatePicker.htm +65 -65
  25. package/public/his/editor/vender/date97/WdatePicker.js +677 -677
  26. package/public/his/editor/vender/date97/calendar.js +4 -4
  27. package/public/his/editor/vender/date97/lang/en.js +13 -13
  28. package/public/his/editor/vender/date97/lang/zh-cn.js +13 -13
  29. package/public/his/editor/vender/date97/lang/zh-tw.js +13 -13
  30. package/public/his/editor/vender/date97/skin/WdatePicker.css +10 -10
  31. package/public/his/editor/vender/date97/skin/default/datepicker.css +328 -328
  32. package/public/his/editor/vender/date97/skin/ext/datepicker.css +308 -308
  33. package/public/his/editor/vender/date97/skin/whyGreen/datepicker.css +255 -255
  34. package/public/his/editor/vender/diff.js +1627 -1627
  35. package/public/his/editor/vender/editor.js +1 -1
  36. package/public/his/editor/vender/fabric.js +31187 -31187
  37. package/public/his/editor/vender/jquery/jquery.base64.js +190 -190
  38. package/public/his/editor/vender/jquery/jquery.js +10872 -10872
  39. package/public/his/editor/vender/jquery/jquery.print.js +255 -255
  40. package/public/his/editor/vender/jquery/zTreeStyle/zTreeStyle.css +96 -96
  41. package/public/his/editor/vender/mui/mui.min.css +4 -4
  42. package/public/his/editor/vender/mui/mui.min.js +5 -5
  43. package/public/his/editor/vender/mui/mui.picker.min.css +6 -6
  44. package/public/his/editor/vender/mui/mui.picker.min.js +6 -6
  45. package/public/his/editor/vender/qrcode.js +7 -7
  46. package/public/his/editor/vender/requirejs/require.js +2145 -2145
  47. package/public/his/editor/vender/signature/jSignature.CompressorSVG.js +518 -518
  48. package/public/his/editor/vender/signature/jSignature.UndoButton.js +164 -164
  49. package/public/his/editor/vender/signature/jSignature.js +1486 -1486
  50. package/public/his/editor/vender/validator.js +5094 -5094
  51. package/public/his/editor/vender/weui/weui.css +5659 -5659
  52. package/public/his/editor/vender/weui/weui.min.css +4 -4
  53. package/public/his/editor/vender/weui/weui.min.js +11 -11
  54. package/public/index.html +27 -27
  55. package/src/App.vue +192 -192
  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/common/AMisRender/index.js +3 -3
  61. package/src/base-client/components/common/AMisRender/index.vue +263 -263
  62. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +470 -470
  63. package/src/base-client/components/common/AddressSearchCombobox/IcMapIcon.vue +16 -16
  64. package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
  65. package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
  66. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  67. package/src/base-client/components/common/CitySelect/CitySelect.vue +342 -342
  68. package/src/base-client/components/common/CitySelect/index.js +3 -3
  69. package/src/base-client/components/common/CitySelect/index.md +109 -109
  70. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  71. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  72. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  73. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  74. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  75. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  76. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  77. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  78. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  79. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  80. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  81. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  82. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  83. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  84. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  85. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
  86. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +413 -413
  87. package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
  88. package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +728 -728
  89. package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
  90. package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +219 -219
  91. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
  92. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
  93. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
  94. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
  95. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
  96. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
  97. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
  98. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  99. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  100. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  101. package/src/base-client/components/common/Tree/index.js +2 -2
  102. package/src/base-client/components/common/Upload/Upload.vue +239 -239
  103. package/src/base-client/components/common/Upload/index.js +3 -3
  104. package/src/base-client/components/common/XAddForm/XAddForm.vue +107 -107
  105. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +868 -868
  106. package/src/base-client/components/common/XAddNativeForm/demo.vue +30 -30
  107. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  108. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
  109. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  110. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  111. package/src/base-client/components/common/XAddReport/XAddReport.vue +207 -207
  112. package/src/base-client/components/common/XBadge/XBadge.vue +94 -94
  113. package/src/base-client/components/common/XButtons/XButtonDemo.vue +28 -28
  114. package/src/base-client/components/common/XButtons/XButtons.vue +71 -71
  115. package/src/base-client/components/common/XButtons/index.js +3 -3
  116. package/src/base-client/components/common/XButtons/index.md +61 -61
  117. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  118. package/src/base-client/components/common/XConversation/XConversation.vue +140 -140
  119. package/src/base-client/components/common/XConversation/XConversationDemo.vue +28 -28
  120. package/src/base-client/components/common/XDataCard/XDataCard.vue +420 -420
  121. package/src/base-client/components/common/XDataCard/index.js +3 -3
  122. package/src/base-client/components/common/XDataCard/index.md +1 -1
  123. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  124. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  125. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  126. package/src/base-client/components/common/XDescriptions/XDescriptions.vue +169 -169
  127. package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +304 -304
  128. package/src/base-client/components/common/XDescriptions/demo.vue +50 -50
  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 +340 -340
  134. package/src/base-client/components/common/XForm/XFormItem.vue +4 -3
  135. package/src/base-client/components/common/XForm/XTreeSelect.vue +250 -250
  136. package/src/base-client/components/common/XForm/index.md +178 -178
  137. package/src/base-client/components/common/XFormCol/XFormCol.vue +96 -96
  138. package/src/base-client/components/common/XFormGroup/XFormGroup.vue +261 -261
  139. package/src/base-client/components/common/XFormGroup/demo.vue +45 -45
  140. package/src/base-client/components/common/XFormGroup/index.js +3 -3
  141. package/src/base-client/components/common/XFormGroup/index.md +38 -38
  142. package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
  143. package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
  144. package/src/base-client/components/common/XFormTable/XFormTable.vue +713 -713
  145. package/src/base-client/components/common/XFormTable/demo.vue +76 -76
  146. package/src/base-client/components/common/XFormTable/index.md +92 -92
  147. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +162 -162
  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/XReport/XReport.vue +892 -892
  151. package/src/base-client/components/common/XReport/XReportDemo.vue +304 -304
  152. package/src/base-client/components/common/XReport/XReportDesign.vue +463 -463
  153. package/src/base-client/components/common/XReport/XReportJsonRender.vue +381 -381
  154. package/src/base-client/components/common/XReport/XReportTrGroup.vue +808 -808
  155. package/src/base-client/components/common/XReport/index.js +3 -3
  156. package/src/base-client/components/common/XReport/index.md +44 -44
  157. package/src/base-client/components/common/XReport/print.js +186 -186
  158. package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +201 -201
  159. package/src/base-client/components/common/XReportDrawer/index.js +3 -3
  160. package/src/base-client/components/common/XReportGrid/XReport.vue +995 -959
  161. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +42 -42
  162. package/src/base-client/components/common/XReportGrid/XReportDesign.vue +557 -557
  163. package/src/base-client/components/common/XReportGrid/XReportJsonRender.vue +380 -380
  164. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +999 -999
  165. package/src/base-client/components/common/XReportGrid/index.js +3 -3
  166. package/src/base-client/components/common/XReportGrid/index.md +44 -44
  167. package/src/base-client/components/common/XReportGrid/print.js +184 -184
  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/XTab.vue +201 -201
  178. package/src/base-client/components/common/XTab/XTabDemo.vue +22 -22
  179. package/src/base-client/components/common/XTab/index.js +3 -3
  180. package/src/base-client/components/common/XTable/TableCellRenderer.vue +161 -161
  181. package/src/base-client/components/common/XTable/XTable.vue +1191 -1191
  182. package/src/base-client/components/common/XTable/index.md +255 -255
  183. package/src/base-client/components/common/XTree/XTree.vue +423 -423
  184. package/src/base-client/components/common/XTree/XTreePro.vue +434 -434
  185. package/src/base-client/components/common/XTree/index.js +3 -3
  186. package/src/base-client/components/common/XTree/index.md +36 -36
  187. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +113 -113
  188. package/src/base-client/components/common/XTreeOne/XTreeOnePro.vue +128 -128
  189. package/src/base-client/components/common/richTextModal/index.vue +56 -56
  190. package/src/base-client/components/common/richTextModal/richDemo.vue +48 -48
  191. package/src/base-client/components/his/XHisEditor/XHisEditor.vue +203 -203
  192. package/src/base-client/components/his/XHisEditor/index.js +3 -3
  193. package/src/base-client/components/index.js +51 -51
  194. package/src/base-client/components/layout/XPageView/RenderRow.vue +63 -63
  195. package/src/base-client/components/layout/XPageView/XErrorView.vue +11 -11
  196. package/src/base-client/components/layout/XPageView/XPageView.vue +155 -155
  197. package/src/base-client/components/layout/XPageView/index.js +3 -3
  198. package/src/base-client/components/layout/XPageView/index.md +38 -38
  199. package/src/base-client/components/layout/XTreeView/XTreeView.vue +130 -130
  200. package/src/base-client/components/layout/XTreeView/index.js +3 -3
  201. package/src/base-client/components/layout/XTreeView/index.md +46 -46
  202. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  203. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  204. package/src/base-client/plugins/AppData.js +121 -121
  205. package/src/base-client/plugins/Config.js +19 -19
  206. package/src/base-client/plugins/GetLoginInfoService.js +183 -183
  207. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  208. package/src/bootstrap.js +39 -39
  209. package/src/components/CodeMirror/inedx.vue +118 -118
  210. package/src/components/CodeMirror/setting.js +40 -40
  211. package/src/components/FilePreview/FilePreview.vue +166 -166
  212. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  213. package/src/components/STable/index.js +380 -380
  214. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  215. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  216. package/src/components/exception/ExceptionPage.vue +70 -70
  217. package/src/components/menu/SideMenu.vue +75 -75
  218. package/src/components/menu/menu.js +273 -273
  219. package/src/components/tool/AStepItem.vue +60 -60
  220. package/src/config/default/antd.config.js +89 -89
  221. package/src/config/default/setting.config.js +55 -55
  222. package/src/font-style/font.css +4 -4
  223. package/src/layouts/CommonLayout.vue +56 -56
  224. package/src/layouts/GridView.vue +45 -45
  225. package/src/layouts/PageLayout.vue +151 -151
  226. package/src/layouts/SinglePageView.vue +136 -136
  227. package/src/layouts/header/AdminHeader.vue +132 -132
  228. package/src/layouts/header/HeaderNotice.vue +177 -177
  229. package/src/layouts/tabs/TabsHead.vue +189 -189
  230. package/src/layouts/tabs/TabsView.vue +389 -389
  231. package/src/lib.js +1 -1
  232. package/src/main.js +30 -30
  233. package/src/mock/extend/index.js +84 -84
  234. package/src/mock/goods/index.js +108 -108
  235. package/src/pages/AMisDemo/AMisDemo.vue +325 -325
  236. package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
  237. package/src/pages/DefaultExample/index.vue +77 -77
  238. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  239. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  240. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  241. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  242. package/src/pages/DynamicStatistics/FavoriteList.vue +50 -50
  243. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  244. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  245. package/src/pages/DynamicStatistics/index.vue +282 -282
  246. package/src/pages/Example/childIndex.vue +15 -15
  247. package/src/pages/Example/index.vue +30 -30
  248. package/src/pages/NewDynamicStatistics/ChartSelector.vue +331 -331
  249. package/src/pages/NewDynamicStatistics/DataTabs.vue +122 -122
  250. package/src/pages/NewDynamicStatistics/DynamicTable.vue +128 -128
  251. package/src/pages/NewDynamicStatistics/EvaluationArea.vue +69 -69
  252. package/src/pages/NewDynamicStatistics/FavoriteList.vue +50 -50
  253. package/src/pages/NewDynamicStatistics/QuestionHistoryAndFavorites.vue +289 -289
  254. package/src/pages/NewDynamicStatistics/SearchBar.vue +193 -193
  255. package/src/pages/NewDynamicStatistics/index.vue +258 -258
  256. package/src/pages/Recording/index.vue +76 -0
  257. package/src/pages/ReportGrid/index.vue +76 -76
  258. package/src/pages/ServiceReview/index.vue +284 -284
  259. package/src/pages/SubExample/index.vue +26 -26
  260. package/src/pages/WorkflowDetail/WorkFlowDemo.vue +32 -32
  261. package/src/pages/WorkflowDetail/WorkflowDetail.vue +230 -230
  262. package/src/pages/WorkflowDetail/WorkflowPageDetail/LeaveMessage.vue +131 -131
  263. package/src/pages/WorkflowDetail/WorkflowPageDetail/TrimTextTail.vue +23 -23
  264. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformation.vue +302 -302
  265. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformationDetails.vue +276 -276
  266. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +864 -864
  267. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandleReso.vue +997 -997
  268. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +222 -222
  269. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkOrderParentDetails.vue +233 -233
  270. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowDetailResso.vue +261 -261
  271. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowListResolution.vue +248 -248
  272. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowLog.vue +73 -73
  273. package/src/pages/XPageViewExample/index.vue +38 -38
  274. package/src/pages/XReportView/index.vue +64 -64
  275. package/src/pages/XTreeOneProExample/index.vue +67 -67
  276. package/src/pages/login/Login.vue +378 -378
  277. package/src/pages/login/LoginV3.vue +389 -389
  278. package/src/pages/lowCode/lowCodeEditor.vue +1219 -1219
  279. package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
  280. package/src/pages/resourceManage/orgListManage.vue +98 -98
  281. package/src/pages/system/dictionary/index.vue +44 -44
  282. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  283. package/src/pages/system/monitor/operLog/index.vue +37 -37
  284. package/src/pages/system/settings/modifyPassword.vue +117 -117
  285. package/src/pages/system/ticket/index.vue +480 -480
  286. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  287. package/src/plugins/EventLogPlugin.js +33 -33
  288. package/src/plugins/FindParentsData.js +17 -17
  289. package/src/router/async/config.async.js +1 -0
  290. package/src/router/async/router.map.js +183 -183
  291. package/src/router/guards.js +263 -263
  292. package/src/router/index.js +27 -27
  293. package/src/router.js +19 -19
  294. package/src/services/api/TicketDetailsViewApi.js +46 -46
  295. package/src/services/api/cas.js +79 -79
  296. package/src/services/api/common.js +329 -329
  297. package/src/services/api/entity.js +18 -18
  298. package/src/services/api/index.js +17 -17
  299. package/src/services/api/restTools.js +67 -67
  300. package/src/services/api/workFlow.js +63 -63
  301. package/src/services/apiService.js +15 -15
  302. package/src/services/user.js +90 -90
  303. package/src/services/v3Api.js +116 -116
  304. package/src/store/modules/account.js +115 -115
  305. package/src/store/modules/index.js +5 -5
  306. package/src/store/modules/lowCode.js +33 -33
  307. package/src/store/modules/setting.js +119 -119
  308. package/src/theme/default/style.less +58 -58
  309. package/src/theme/global.less +159 -159
  310. package/src/utils/authority-utils.js +85 -85
  311. package/src/utils/errorCode.js +6 -6
  312. package/src/utils/formatter.js +74 -74
  313. package/src/utils/htmlToPDF.js +108 -108
  314. package/src/utils/htmlToPDFApi.js +5 -5
  315. package/src/utils/indexedDB.js +263 -263
  316. package/src/utils/login.js +188 -188
  317. package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
  318. package/src/utils/lowcode/lowcodeLog.js +29 -29
  319. package/src/utils/lowcode/lowcodeUtils.js +373 -373
  320. package/src/utils/lowcode/registerComponentForEditor.js +1 -1
  321. package/src/utils/lowcode/registerComponentForRender.js +11 -11
  322. package/src/utils/map-utils.js +47 -47
  323. package/src/utils/microAppUtils.js +40 -40
  324. package/src/utils/reg.js +95 -95
  325. package/src/utils/request.js +362 -362
  326. package/src/utils/routerUtil.js +450 -450
  327. package/src/utils/runEvalFunction.js +14 -14
  328. package/src/utils/util.js +313 -313
  329. package/src/utils/waterMark.js +31 -31
  330. package/test/Amis.spec.js +163 -163
  331. package/test/Tree.spec.js +167 -167
  332. package/test/myDialog.spec.js +46 -46
  333. package/test/util.test.js +36 -36
  334. package/test/v3Api.test.js +1983 -1983
  335. package/vue.config.js +199 -199
  336. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
  337. /package/src/base-client/components/common/Recording/{Recoding.vue → Recording.vue} +0 -0
@@ -1,1191 +1,1191 @@
1
- <template>
2
- <div v-show="tableColumns.length > 0">
3
- <a-row :gutter="48">
4
- <a-col v-show="showLeftOperaBtn">
5
- <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
- <a-space>
7
- <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
8
- <a-button v-if="buttonState.add && buttonRendering('add')" type="primary" @click="add">
9
- <a-icon type="plus"/>新增
10
- </a-button>
11
- <a-button v-if="buttonState.move && buttonRendering('move')" type="primary" @click="move">
12
- <a-icon type="plus"/>添加
13
- </a-button>
14
- <a-button v-if="buttonState.choose && buttonRendering('choose')" :disabled="!isChoose" type="primary" @click="choose">
15
- <a-icon type="check-square"/>选择
16
- </a-button>
17
- <a-button
18
- v-if="buttonState.edit && buttonRendering('edit')"
19
- :disabled="!isModify"
20
- :loading="editLoading"
21
- class="btn-success"
22
- type="dashed"
23
- @click="edit()">
24
- <a-icon :style="iconStyle" type="form"/>修改
25
- </a-button>
26
- <template
27
- v-if="buttonState.editRow && buttonRendering('editRow')">
28
- <a-button
29
- v-if="isEditMode"
30
- class="ant-btn-hover"
31
- @click="editRowSave">
32
- <a-icon :style="iconStyle" type="save"/>保存
33
- </a-button>
34
- <a-button
35
- v-else
36
- @click="openEditMode">
37
- <a-icon :style="iconStyle" type="edit"/>行编辑
38
- </a-button>
39
- </template>
40
- <a-button
41
- v-if="buttonState.delete && buttonRendering('delete')"
42
- :disabled="!isDelete"
43
- type="danger"
44
- @click="deleteItem">
45
- <a-icon :style="iconStyle" type="delete"/>删除
46
- </a-button>
47
- <a-button
48
- v-if="buttonState.import && buttonRendering('import')"
49
- type="dashed"
50
- @click="importData">
51
- <a-icon :style="iconStyle" type="import"/>导入
52
- </a-button>
53
- <a-dropdown v-if="!buttonState || buttonState.export && buttonRendering('export')">
54
- <a-menu slot="overlay">
55
- <a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon
56
- :style="iconStyle"
57
- type="ordered-list"/>导出选中数据</a-menu-item>
58
- <a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets"/>导出本页数据</a-menu-item>
59
- <a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download"/>导出所有符合条件的数据</a-menu-item>
60
- <!-- <a-menu-item key="4" @click="handleAsyncExportByQuery"><a-icon :style="iconStyle" type="download"/>异步导出所有符合条件的数据</a-menu-item>-->
61
- </a-menu>
62
- <a-button>导出 <a-icon type="down" :style="iconStyle"/> </a-button>
63
- </a-dropdown>
64
- <!-- 遍历按钮配置数组,动态生成按钮 -->
65
- <a-button
66
- v-for="(button, index) in editButtonStateData"
67
- :key="index"
68
- :type="button.type || 'dashed'"
69
- @click="editButtonStateDataClick(index)"
70
- class="btn-success"
71
- >
72
- <a-icon type="dashed" :style="iconStyle"/>
73
- {{ button.buttonName }}
74
- </a-button>
75
-
76
- <a-button v-if="allowedCardMode && !simpleMode" @click="changeViewMode" :type="isTableMode ? '' : 'primary'">
77
- 看板模式
78
- </a-button>
79
- <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
80
- </a-space>
81
- </span>
82
- </a-col>
83
- <a-col v-show="showRightTools && !simpleMode">
84
- <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
85
- <a-button-group>
86
- <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
87
- <a-tooltip title="汇总" placement="bottom">
88
- <a-button @click="showDrawer">
89
- <a-icon :style="iconStyle" type="project"/>
90
- </a-button>
91
- </a-tooltip>
92
- <a-tooltip title="重新查询" placement="bottom">
93
- <a-button @click="refresh(true)">
94
- <a-icon :style="iconStyle" type="reload"/>
95
- </a-button>
96
- </a-tooltip>
97
- <a-tooltip title="列展示/排序" placement="bottom">
98
- <table-setting v-if="columnSelectLoaded" v-model="tableColumns"/>
99
- </a-tooltip>
100
- </a-button-group>
101
- </span>
102
- </a-col>
103
- </a-row>
104
- <!-- 如果当前是表格模式 -->
105
- <template v-if="isTableMode && !simpleMode">
106
- <s-table
107
- ref="table"
108
- :id="uniqueId"
109
- :alert="true"
110
- :columns="tableColumns"
111
- :data="loadData"
112
- :rowKey="rowKey"
113
- :showSummary="showSummary"
114
- :rowSelection="rowSelection"
115
- :scroll="{ x: scrollXWidth, y: scrollYHeight }"
116
- :showPagination="showPagination"
117
- :setScrollYHeight="setScrollYHeight"
118
- size="default"
119
- >
120
- <template
121
- v-for="(item, c_index) in tableColumns"
122
- :slot="item.dataIndex"
123
- slot-scope="text, record, index">
124
- <template v-if="isEditMode && getFromItem(item.dataIndex)">
125
- <x-form-item
126
- class="innerTable"
127
- :form="record"
128
- :attr="getFromItem(item.dataIndex)"
129
- :service-name="serviceName"
130
- mode="新增/修改"
131
- :env="env"
132
- :showLabel="false"
133
- :key="'editRow-' + c_index"
134
- />
135
- </template>
136
- <!-- 序号列 -->
137
- <span v-else-if="item.slotType === 'index'" :key="'index-' + c_index">
138
- {{ index + 1 }}
139
- </span>
140
- <!-- 行链接 -->
141
- <span v-else-if="item.slotType === 'link'" :key="'link-' + c_index">
142
- <a @click="columnClick(item.dataIndex,text,record)">{{ text }}</a>
143
- </span>
144
- <!-- 文本溢出省略(ellipsis) -->
145
- <span v-else-if="item.slotType === 'ellipsis'" :key="'ellipsis-' + c_index">
146
- <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
147
- </span>
148
- <!-- 徽标(badge) -->
149
- <span v-else-if="item.slotType === 'badge'" :key="'badge-' + c_index">
150
- <x-badge
151
- :service-name="serviceName"
152
- :env="env"
153
- v-if="text !== null && text !== undefined"
154
- :badge-key="item.slotKeyMap"
155
- :value="text"/>
156
- </span>
157
- <!-- 日期(date) -->
158
- <span v-else-if="item.slotType === 'date'" :key="'date-' + c_index">
159
- {{ format(text, 'yyyy-MM-dd') }}
160
- </span>
161
- <!-- 日期时间(datetime) -->
162
- <span v-else-if="item.slotType === 'dateTime'" :key="'dateTime-' + c_index">
163
- {{ format(text, 'yyyy-MM-dd hh:mm:ss') }}
164
- </span>
165
- <!-- 两位小数 -->
166
- <span v-else-if="item.slotType === 'towDecimal'" :key="'towDecimal-' + c_index">
167
- {{ numberFormat(text, 2) }}
168
- </span>
169
- <!-- 四位小数 -->
170
- <span v-else-if="item.slotType === 'fourDecimal'" :key="'fourDecimal-' + c_index">
171
- {{ numberFormat(text, 4) }}
172
- </span>
173
- <!-- 整数 -->
174
- <span v-else-if="item.slotType === 'int'" :key="'int-' + c_index">
175
- {{ numberFormat(text, 0) }}
176
- </span>
177
- <!-- 操作列(action) -->
178
- <span v-else-if="item.slotType === 'action'" :key="'action-' + c_index">
179
- <template v-if="item.actionArr && item.actionArr.length > 0">
180
- <a-dropdown>
181
- <a class="ant-dropdown-link" @click="e => e.preventDefault()">
182
- {{ item.scopedSlots?.customRender || item.slotValue }} <a-icon type="down"/>
183
- </a>
184
- <a-menu slot="overlay" style="min-width: 60px">
185
- <a-menu-item
186
- v-for="(action_item, actionIndex) in item.actionArr"
187
- :key="actionIndex"
188
- v-if="!action_item.customFunction || executeStrFunction( action_item.customFunction,[record,c_index])">
189
- <a
190
- style="text-align: center"
191
- @click="action(record, item.dataIndex, action_item.func)"
192
- >{{ action_item.text }}</a>
193
- </a-menu-item>
194
- </a-menu>
195
- </a-dropdown>
196
- </template>
197
- <template v-if="!item.actionArr || item.actionArr.length === 0">
198
- <a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
199
- </template>
200
- </span>
201
- </template>
202
- <template slot="footer">
203
- <slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
204
- </template>
205
- </s-table>
206
- </template>
207
- <!-- 如果当前是看板模式 -->
208
- <template v-else>
209
- <XDataCard
210
- ref="table"
211
- @cardEmit="handleCardEmit"
212
- :tableColumns="tableColumns"
213
- :card-config="cardModeConfig"
214
- :show-pagination="true"
215
- :serviceName="serviceName"
216
- :card-data="loadData"
217
- :env="env"
218
- :createdQuery="createdQuery"
219
- :simple-mode="simpleMode"/>
220
- </template>
221
- <!-- 上传文件 -->
222
- <a-drawer
223
- title="汇总信息"
224
- placement="right"
225
- :closable="false"
226
- :visible="summaryDrawerVisible"
227
- :z-index="2000"
228
- width="25%"
229
- :after-visible-change="afterVisibleChange"
230
- @close="onClose"
231
- >
232
- <template>
233
- <a-row>
234
- <a-col :span="8" v-for="(f,index) in summaryData" :key="index">
235
- <a-statistic
236
- :title="f.title + ':'"
237
- :value="f.value"
238
- :precision="2">
239
- <template #prefix>
240
- <a-spin :spinning="f.loading">
241
- </a-spin>
242
- </template>
243
- <template #suffix>
244
- <a-icon
245
- v-show="!f.loading"
246
- :type="f.success !== false ? 'check-circle' : 'close-circle'"
247
- :style="{color: f.success !== false ? 'green' : 'red'}"/>
248
- </template>
249
- </a-statistic>
250
- </a-col>
251
- </a-row>
252
- </template>
253
- </a-drawer>
254
- <x-import-excel
255
- ref="importExcel"
256
- @ok="importExcelOk"
257
- :title="title"
258
- :service-name="serviceName"
259
- :env="env"
260
- :query-params-name="queryParamsName"
261
- >
262
- <template #importExcelSlot>
263
- <slot name="importExcelSlot"></slot>
264
- </template>
265
- </x-import-excel>
266
- </div>
267
- </template>
268
- <script>
269
- import { Ellipsis, STable } from '@vue2-client/components'
270
- import { formatDate, getChangedData } from '@vue2-client/utils/util'
271
- import XBadge from '@vue2-client/base-client/components/common/XBadge'
272
- import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
273
- import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
274
- import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
275
- import {
276
- exportData,
277
- query,
278
- querySummary,
279
- queryWithResource,
280
- remove,
281
- asyncRunTask,
282
- editRowSave,
283
- runLogic
284
- } from '@vue2-client/services/api/common'
285
- import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
286
- import { Modal } from 'ant-design-vue'
287
- import { mapState } from 'vuex'
288
- import { executeStrFunction } from '@vue2-client/utils/runEvalFunction'
289
- import debounce from 'lodash.debounce'
290
- import XDataCard from '@vue2-client/base-client/components/common/XDataCard/XDataCard.vue'
291
- import { getRealKeyData } from '@vue2-client/utils/formatter'
292
-
293
- export default {
294
- name: 'XTable',
295
- components: {
296
- XDataCard,
297
- TableSetting,
298
- STable,
299
- Ellipsis,
300
- XBadge,
301
- XImportExcel,
302
- XFormItem
303
- },
304
- data () {
305
- return {
306
- uniqueId: `x-table-${this._uid}`, // 使用 _uid 生成唯一 ID
307
- // 筛选列加载状态
308
- columnSelectLoaded: false,
309
- // 预览模式
310
- viewMode: false,
311
- // 本地编辑模式
312
- localEditMode: false,
313
- // 本地编辑模式所用数据源
314
- localEditModeDataSource: [],
315
- // 本地编辑模式数据源是否已由外部加载
316
- isLocalDataSourceLoadedExternally: false,
317
- // 行选择模式
318
- rowSelectMode: false,
319
- // 行选择模式-允许选中行数量,0:任意数量行,大于0:指定值数量的行
320
- allowSelectRowNum: 0,
321
- // 是否展示右侧工具栏
322
- showRightTools: true,
323
- // 是否展示左边按钮栏
324
- showLeftOperaBtn: true,
325
- // 加载数据方法 必须为 Promise 对象
326
- loadData: parameter => {
327
- // 取到表格携带的表单参数
328
- const requestParameters = Object.assign({}, parameter)
329
- // 取到父组件传入的表单参数
330
- const conditionParams = {}
331
- Object.assign(conditionParams, this.fixedQueryForm)
332
- Object.assign(conditionParams, this.form)
333
- // 如果传了燃气公司字段,则进行数据处理
334
- if (conditionParams.orgName) {
335
- requestParameters.orgName = conditionParams.orgName
336
- delete conditionParams.orgName
337
- }
338
- Object.keys(conditionParams).forEach(key => {
339
- if (Array.isArray(conditionParams[key])) {
340
- // 检查数组中是否包含 null
341
- const hasNull = conditionParams[key].every(item => item === '') || conditionParams[key].length === 0
342
- // 如果包含 null,则删除该属性
343
- if (hasNull) {
344
- delete conditionParams[key]
345
- }
346
- }
347
- })
348
- requestParameters.conditionParams = conditionParams
349
- requestParameters.queryParamsName = this.queryParamsName
350
- requestParameters.queryParams = this.queryParams
351
- this.requestParameters = requestParameters
352
- // 加载数据
353
- return this.loadTableData(requestParameters)
354
- },
355
- requestParameters: {},
356
- rowKey: undefined,
357
- // x滚动条宽度
358
- scrollXWidth: 1600,
359
- // y滚动条高度
360
- scrollYHeight: 'calc(100vh - 31rem)',
361
- // 表格选择列Key集合
362
- selectedRowKeys: [],
363
- // 表格选择Row集合
364
- selectedRows: [],
365
- // 禁止表格选择Row集合
366
- selectedDisableRows: [],
367
- // 业务标题
368
- title: '',
369
- // 数据列
370
- tableColumns: [],
371
- // 查询用表单
372
- form: {},
373
- oldForm: {},
374
- // 是否允许修改
375
- isModify: false,
376
- // 是否允许删除
377
- isDelete: false,
378
- // 是否允许选择
379
- isChoose: false,
380
- // 服务名称
381
- serviceName: undefined,
382
- // 选中用于修改的id
383
- selectId: undefined,
384
- // 是否显示展示列抽屉
385
- visible: false,
386
- // 编辑按钮加载状态
387
- editLoading: false,
388
- // 按钮状态
389
- buttonState: {},
390
- // 自定义按钮数组
391
- editButtonStateData: [],
392
- // 按钮权限
393
- buttonPermissions: [],
394
- // 是否展示汇总
395
- showSummary: false,
396
- // 自定义汇总
397
- showCustomSummary: false,
398
- summaryData: [],
399
- // 图标样式
400
- iconStyle: {
401
- position: 'relative',
402
- top: '1px'
403
- },
404
- // 当前环境
405
- env: 'prod',
406
- // 预览模式(表格 or 看板)
407
- isTableMode: true,
408
- // 汇总抽屉是否显示
409
- summaryDrawerVisible: false,
410
- // 汇总更新标志
411
- summaryUpdate: false,
412
- customSummaryArray: [],
413
- formItems: [],
414
- // 是否为行编辑模式
415
- isEditMode: false,
416
- // 定义主键
417
- primaryKey: '',
418
- // 是否进行初始化查询
419
- createdQuery: true,
420
- // 允许看板模式
421
- allowedCardMode: false,
422
- // 看板模式配置
423
- cardModeConfig: undefined,
424
- // 暂存行编辑前数据 用于比较哪些变化了才需要保存
425
- editRowBeforeData: [],
426
- // 是否简易模式
427
- simpleMode: false
428
- }
429
- },
430
- props: {
431
- // 查询配置文件名
432
- queryParamsName: {
433
- type: String,
434
- default: () => {
435
- return ''
436
- }
437
- },
438
- // 查询配置文件Json
439
- queryParamsJson: {
440
- type: Object,
441
- default: null
442
- },
443
- // 固定查询表单
444
- fixedQueryForm: {
445
- type: Object,
446
- default: () => {
447
- return {}
448
- }
449
- },
450
- // 数据只有一页时是否展示分页,true:展示,auto:隐藏
451
- showPagination: {
452
- type: Boolean,
453
- default: true
454
- },
455
- // 是否自定义删除功能
456
- customDelete: {
457
- type: Boolean,
458
- default: false
459
- },
460
- // 自适应底部编剧
461
- extraHeight: {
462
- type: Number,
463
- default: 80
464
- }
465
- },
466
- computed: {
467
- rowSelection () {
468
- return {
469
- selectedRowKeys: this.selectedRowKeys,
470
- onChange: this.onSelectChange,
471
- getCheckboxProps: record => ({
472
- props: {
473
- disabled: this.selectedDisableRows.includes(record[this.rowKey]), // Column configuration not to be checked
474
- name: record.name,
475
- },
476
- }),
477
- }
478
- },
479
- ...mapState('account', { currUser: 'user' }),
480
- ...mapState('setting', ['compatible'])
481
- },
482
- mounted () {
483
- window.addEventListener('resize', this.handleResize)
484
- },
485
- beforeDestroy () {
486
- window.removeEventListener('resize', this.handleResize)
487
- },
488
- methods: {
489
- columnClick (key, value, record) {
490
- this.$emit('columnClick', key, value, record)
491
- },
492
- getFromItem (model) {
493
- const aa = this.formItems.find(item => item.model === model && item.editRow)
494
- if (aa) {
495
- return JSON.parse(JSON.stringify(aa))
496
- }
497
- return false
498
- },
499
- // 打开行编辑
500
- openEditMode () {
501
- this.isEditMode = true
502
- this.editRowBeforeData = JSON.parse(JSON.stringify(this.getTableData()))
503
- },
504
- // 标记行保存
505
- editRowSave () {
506
- // 获取最新数据
507
- const editRowAfterData = this.getTableData()
508
- const changeData = getChangedData(this.editRowBeforeData, editRowAfterData)
509
- if (changeData.length === 0) {
510
- this.$message.info('没有数据发生变化')
511
- } else {
512
- Modal.confirm({
513
- title: '是否确认保存?',
514
- content: `此操作将保存当前行编辑的数据,共修改${changeData.length}条数据`,
515
- zIndex: 1001,
516
- onOk: () => {
517
- return new Promise((resolve, reject) => {
518
- const requestParameters = {
519
- queryParamsName: this.queryParamsName,
520
- changeData: changeData.map(h => getRealKeyData(h)),
521
- operaInfo: this.currUser.operaInfo
522
- }
523
- editRowSave(requestParameters, this.serviceName, this.env === 'dev').then(res => {
524
- this.$message.success('行内数据保存成功')
525
- this.isEditMode = false
526
- this.refresh()
527
- resolve(res)
528
- }).catch(e => {
529
- reject(e)
530
- this.$message.error('保存失败!')
531
- })
532
- })
533
- },
534
- onCancel () {
535
- }
536
- })
537
- }
538
- },
539
- importExcelOk () {
540
- this.refresh(true)
541
- this.$emit('importExcelOk')
542
- },
543
- handleResize () {
544
- debounce(() => {
545
- this.setScrollYHeight({})
546
- }, 100)()
547
- },
548
- isInAModal () {
549
- let parent = this.$parent
550
- while (parent) {
551
- // 检查组件名称,这里假设a-modal组件的名称为AModal,根据实际情况可能需要调整
552
- if (parent.$options.name === 'AModal') {
553
- return true
554
- }
555
- parent = parent.$parent
556
- }
557
- return false
558
- },
559
- executeStrFunction,
560
- // 切换看板模式和表格模式
561
- changeViewMode () {
562
- this.isTableMode = !this.isTableMode
563
- // 看板切换回表格模式 刷新列表
564
- if (this.isTableMode) {
565
- this.refresh(true)
566
- }
567
- },
568
- /**
569
- * 初始化表格参数
570
- */
571
- init (params) {
572
- const {
573
- // 查询参数对象, 用于没有对应查询配置文件名时
574
- queryParams,
575
- tableColumns,
576
- buttonState,
577
- buttonPermissions,
578
- editButtonStateData = [],
579
- title,
580
- form,
581
- serviceName,
582
- tableSummaryMap = {},
583
- customTableSummaryArray = [],
584
- viewMode,
585
- localEditMode,
586
- rowSelectMode,
587
- allowSelectRowNum = 0,
588
- formItems,
589
- env = 'prod',
590
- createdQuery = true,
591
- createdEditMode = false,
592
- primaryKey,
593
- allowedCardMode = false,
594
- simpleMode = false,
595
- cardModeConfig,
596
- summaryUpdate
597
- } = params
598
- this.showSummary = Object.keys(tableSummaryMap).length > 0
599
- if (this.showSummary) {
600
- Object.keys(tableSummaryMap).forEach(item => {
601
- this.summaryData.push({
602
- key: item,
603
- title: tableSummaryMap[item],
604
- value: ' ',
605
- loading: true,
606
- success: false
607
- })
608
- })
609
- }
610
- if (customTableSummaryArray.length > 0) {
611
- customTableSummaryArray.forEach(item => {
612
- this.summaryData.push({
613
- key: item.key,
614
- title: item.title,
615
- value: ' ',
616
- loading: true,
617
- success: false
618
- })
619
- })
620
- this.showCustomSummary = true
621
- this.customSummaryArray = customTableSummaryArray
622
- }
623
- this.queryParams = queryParams
624
- this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
625
- if (this.tableColumns.length === 0) {
626
- return
627
- }
628
- this.viewMode = viewMode
629
- this.localEditMode = localEditMode
630
- this.rowSelectMode = rowSelectMode
631
- this.allowSelectRowNum = allowSelectRowNum
632
- this.simpleMode = simpleMode
633
- this.formItems = formItems
634
- this.createdQuery = createdQuery
635
- this.primaryKey = primaryKey
636
- this.buttonState = buttonState
637
- if (this.localEditMode) {
638
- this.localEditModeDataSource = []
639
- this.isLocalDataSourceLoadedExternally = false
640
- this.buttonState.import = false
641
- this.buttonState.export = false
642
- this.showRightTools = false
643
- }
644
- if (this.rowSelectMode) {
645
- this.buttonState = {
646
- choose: true
647
- }
648
- this.showRightTools = false
649
- }
650
- this.buttonPermissions = buttonPermissions
651
- this.editButtonStateData = editButtonStateData
652
- this.title = title
653
- this.serviceName = serviceName
654
- this.env = env
655
- this.rowKey = this.getPrimaryKeyName()
656
- this.allowedCardMode = allowedCardMode
657
- this.cardModeConfig = cardModeConfig
658
- this.summaryUpdate = summaryUpdate
659
- this.isEditMode = createdEditMode
660
- let totalWidth = 0
661
- for (let i = 0; i < this.tableColumns.length; i++) {
662
- const item = this.tableColumns[i]
663
- // 设置操作列
664
- if (item.slotType === 'action') {
665
- item.fixed = 'right'
666
- item.width = 70
667
- }
668
- // 设置表格宽度
669
- if (item.width) {
670
- totalWidth = totalWidth + item.width
671
- } else {
672
- totalWidth = totalWidth + 180
673
- }
674
- }
675
- // 横向滚动长度大于所有宽度,才能实现固定表头
676
- this.scrollXWidth = totalWidth
677
- // 加载筛选列完成
678
- this.columnSelectLoaded = true
679
- this.setQueryForm(form || {})
680
- },
681
- // 操作面板按钮渲染
682
- buttonRendering (button) {
683
- if (!this.buttonPermissions) {
684
- return true
685
- }
686
- try {
687
- const existingItem = this.buttonPermissions.find(item => item.btnName === button)
688
- const rolestr = this.currUser.rolestr?.split(',')
689
- if (existingItem?.state) {
690
- const currUserRole = existingItem.roleStr
691
- return rolestr.some(item => currUserRole && currUserRole.includes(item))
692
- } else {
693
- return true
694
- }
695
- } catch (e) {
696
- console.error(e)
697
- return false
698
- }
699
- },
700
- /**
701
- * 加载表格数据
702
- * @param requestParameters 请求参数
703
- */
704
- async loadTableData (requestParameters) {
705
- let result
706
- if (this.localEditMode) {
707
- if (!this.isLocalDataSourceLoadedExternally && requestParameters?.conditionParams && Object.keys(requestParameters?.conditionParams).length > 0) {
708
- const result = await query(Object.assign(requestParameters, { userId: this.currUser?.id }),
709
- this.serviceName, this.env === 'dev')
710
- if (result.data) {
711
- let no = 0
712
- this.localEditModeDataSource = result.data.map(item => {
713
- item['序号'] = no
714
- no++
715
- return item
716
- })
717
- }
718
- this.isLocalDataSourceLoadedExternally = true
719
- }
720
- result = new Promise((resolve) => {
721
- resolve({
722
- data: this.localEditModeDataSource
723
- })
724
- })
725
- } else {
726
- result = query(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
727
- }
728
- if (this.isTableMode && !this.simpleMode) {
729
- this.clearRowKeys()
730
- }
731
- this.$emit('afterQuery', result, requestParameters.conditionParams)
732
- return result
733
- },
734
- /**
735
- * 操作列事件
736
- * @param record 本条数据
737
- * @param actionType 操作类型
738
- * @param func 事件默认 action
739
- */
740
- action (record, actionType, func = 'action') {
741
- this.$emit('action', record, record[this.getPrimaryKeyName()], actionType, func)
742
- },
743
- // 看板点击事件
744
- handleCardEmit (data, eventName) {
745
- this.action(data, undefined, eventName)
746
- },
747
- /**
748
- * 选择列事件
749
- * @param selectedRowKeys 被选择的列Key集合
750
- * @param selectedRows 被选择的列集合
751
- */
752
- onSelectChange (selectedRowKeys, selectedRows) {
753
- this.selectedRowKeys = selectedRowKeys
754
- this.selectedRows = selectedRows
755
- this.isModify = this.selectedRowKeys.length === 1
756
- this.isDelete = this.selectedRowKeys.length > 0
757
- this.isChoose = this.allowSelectRowNum === 0 ? this.selectedRowKeys.length > 0 : this.selectedRowKeys.length === this.allowSelectRowNum
758
- this.$emit('selectRow', selectedRowKeys, selectedRows)
759
- },
760
- /**
761
- * 清除表格选中项
762
- */
763
- clearRowKeys () {
764
- this.$refs.table.clearSelected()
765
- },
766
- /**
767
- * 为表格附加查询条件
768
- */
769
- setQueryForm (form = {}) {
770
- this.form = form
771
- if (this.createdQuery) {
772
- this.refresh(true)
773
- }
774
- },
775
- /**
776
- * 表格重新加载方法
777
- * 如果参数为 true, 则强制刷新到第一页
778
- */
779
- refresh (bool) {
780
- this.$nextTick(() => {
781
- this.$refs.table.refresh(bool)
782
- })
783
- },
784
- setScrollYHeight ({ extraHeight = this.extraHeight, id = this.uniqueId, type = '' }) {
785
- this.$nextTick(() => {
786
- setTimeout(() => {
787
- const curDocument = window?.rawDocument || document
788
- const innerHeight = window?.rawWindow?.innerHeight || window.innerHeight || 0
789
- if (typeof extraHeight == 'undefined') {
790
- // 默认底部分页32 + 边距48
791
- extraHeight = 48 + 32
792
- }
793
- let tHeader = null
794
- if (id) {
795
- tHeader = curDocument.getElementById(id) ? curDocument.getElementById(id).getElementsByClassName('ant-table-thead')[0] : null
796
- } else {
797
- tHeader = curDocument.getElementsByClassName('ant-table-thead')[0]
798
- }
799
- // 表格内容距离顶部的距离
800
- let tHeaderBottom = 0
801
- if (tHeader) {
802
- tHeaderBottom = tHeader.getBoundingClientRect().bottom
803
- }
804
- if (tHeaderBottom === 0) {
805
- this.scrollYHeight = 'calc(100vh - 31rem)'
806
- if (window.__MICRO_APP_ENVIRONMENT__) {
807
- this.scrollYHeight = 'calc(100vh - 28.5rem)'
808
- }
809
- return
810
- }
811
-
812
- // 判断是否在 modal 中
813
- if (this.isInAModal()) {
814
- let modalElement = null
815
- if (tHeader) {
816
- modalElement = tHeader.closest('.ant-modal-body')
817
- } else {
818
- modalElement = curDocument.querySelector('.ant-modal-body')
819
- }
820
- if (modalElement) {
821
- const modalRect = modalElement.getBoundingClientRect()
822
- // 48 是 modal 通常的边距 32 是分页
823
- extraHeight = innerHeight - modalRect.bottom + 32 + 48
824
- }
825
- }
826
- if (innerHeight - (tHeaderBottom + extraHeight) < 210) {
827
- this.scrollYHeight = 'calc(100vh - 31rem)'
828
- return
829
- }
830
- // 窗体高度-表格内容顶部的高度-表格内容底部的高度
831
- // this.scrollYHeight = document.body.clientHeight - tHeaderBottom - extraHeight
832
- this.scrollYHeight = `calc(100vh - ${tHeaderBottom + extraHeight}px)`
833
- }, 60)
834
- })
835
- },
836
- /**
837
- * 格式化日期
838
- * @param date 日期字符串
839
- * @param format 格式化方式
840
- */
841
- format (date, format) {
842
- return formatDate(date, format)
843
- },
844
- /**
845
- * 格式化数字
846
- * @param number string 或者 number
847
- * @param decimalPlaces 小数位数
848
- */
849
- numberFormat (number, decimalPlaces = 2) {
850
- const value = parseFloat(number)
851
- if (!isNaN(value)) {
852
- return value.toFixed(decimalPlaces)
853
- } else {
854
- return ''
855
- }
856
- },
857
- /**
858
- * 获取主键列名称
859
- */
860
- getPrimaryKeyName () {
861
- if (this.primaryKey) {
862
- return this.primaryKey
863
- }
864
- const indexColumn = this.tableColumns.find(i => i?.slotType === 'index')
865
- return indexColumn ? indexColumn.dataIndex : this.tableColumns[0].dataIndex
866
- },
867
- // 导出选中或本页数据
868
- handleExport (isSelected) {
869
- const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
870
- const filterVal = this.tableColumns.map(res => res.dataIndex)
871
- let exportData
872
- if (isSelected) {
873
- exportData = this.selectedRows
874
- } else {
875
- exportData = this.$refs.table.localDataSource
876
- }
877
- exportJson(tHeader, exportData.map(v => filterVal.map(j => v[j])), this.title + `数据_${new Date().toLocaleString()}`)
878
- },
879
- // 导出符合条件的数据
880
- handleExportByQuery () {
881
- const that = this
882
- const conditionParams = Object.assign(that.form, that.fixedQueryForm)
883
- this.$confirm({
884
- title: '是否确认导出?',
885
- content: '此操作将导出当前条件下所有数据而非选中数据',
886
- onOk () {
887
- exportData({
888
- queryParamsName: that.queryParamsName,
889
- queryParams: that.queryParams,
890
- form: conditionParams,
891
- userId: that.currUser.id
892
- }, that.serviceName, that.env === 'dev').then(res => {
893
- let value = res
894
- if (that.compatible === 'V4' || (Object.keys(res).length === 1 && Object.prototype.hasOwnProperty.call(res, 'value'))) {
895
- value = res.value
896
- }
897
- // window.open('/res/excel/export/' + value)
898
- window.open(value)
899
- })
900
- },
901
- onCancel () {
902
- }
903
- })
904
- },
905
- handleAsyncExportByQuery () {
906
- const that = this
907
- const conditionParams = Object.assign(that.form, that.fixedQueryForm)
908
- this.$confirm({
909
- title: '是否确认导出?',
910
- content: (h) => (
911
- <div>
912
- <p>此操作将导出当前条件下所有数据而非选中数据</p>
913
- {/* eslint-disable-next-line no-return-assign */}
914
- <a-input placeholder="请输入导出文件名" onChange={(e) => this.exportFileName = e.target.value}/>
915
- </div>
916
- ),
917
- onOk: () => {
918
- if (!this.exportFileName) {
919
- this.$message.error('文件名不能为空')
920
- // eslint-disable-next-line prefer-promise-reject-errors
921
- return Promise.reject() // 阻止对话框关闭
922
- }
923
- // 在这里执行导出的逻辑,并使用 this.exportFileName 作为文件名
924
- const queryData = {
925
- queryParamsName: that.queryParamsName,
926
- queryParams: that.queryParams,
927
- form: conditionParams,
928
- userId: that.currUser.id
929
- }
930
- const date = formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
931
-
932
- asyncRunTask({
933
- f_task_type: '导出',
934
- f_task_class: 'com.af.v4.impl.CommonExportHandlerImpl',
935
- f_user_id: that.currUser.id,
936
- // 导出条件
937
- f_tag1: queryData,
938
- // 导出文件名
939
- f_tag2: this.exportFileName + '_' + that.currUser.username,
940
- // 执行数据源
941
- f_tag3: process.env.VUE_APP_SYSTEM_NAME,
942
- f_service_name: that.serviceName || process.env.VUE_APP_SYSTEM_NAME,
943
- f_task_name: `${this.exportFileName}_${that.currUser.username}_${date}`
944
- }, that.serviceName, that.env === 'dev')
945
- .then(res => {
946
- }).catch(error => {
947
- // 失败时的处理
948
- console.log('失败:', error)
949
- })
950
- },
951
- onCancel () {
952
- }
953
- })
954
- },
955
- // 新增业务
956
- add () {
957
- this.$emit('add')
958
- },
959
- // 添加业务
960
- move () {
961
- this.$emit('move')
962
- },
963
- // 编辑业务
964
- edit (id) {
965
- this.editLoading = true
966
- this.getEditData(id).then(modifyModelData => {
967
- this.$emit('edit', modifyModelData)
968
- this.editLoading = false
969
- })
970
- },
971
- // 行选择业务
972
- choose () {
973
- if (this.isChoose) {
974
- // 如果配置了自定义函数
975
- this.$emit('rowChoose', this.selectedRows)
976
- } else {
977
- this.$message.warning(this.allowSelectRowNum === 0 ? '请选择数据' : `请选择${this.allowSelectRowNum}条数据`)
978
- }
979
- },
980
- // 自定义按钮点击
981
- editButtonStateDataClick (index) {
982
- this.$emit('editButtonStateDataClick', this.editButtonStateData[index].functionName, this.selectedRows)
983
- },
984
- // 获取被编辑的数据
985
- getEditData (id) {
986
- if (!id) {
987
- this.selectId = this.selectedRowKeys[0]
988
- } else {
989
- this.selectId = id
990
- }
991
- const primaryKeyName = this.getPrimaryKeyName()
992
- if (this.tableColumns[0].dataIndex !== primaryKeyName) {
993
- this.selectId = this.selectedRows[0][primaryKeyName]
994
- }
995
- // 将更新需要的主键值加入到primaryKeyData中
996
- const primaryKeyData = {}
997
- primaryKeyData[primaryKeyName] = this.selectId
998
- if (this.localEditMode) {
999
- return new Promise((resolve) => {
1000
- const modifyData = this.getDataByRowKeyValue(this.selectId)
1001
- resolve({
1002
- data: modifyData,
1003
- primaryKeyData: primaryKeyData
1004
- })
1005
- })
1006
- }
1007
- const requestParameters = {
1008
- queryParamsName: this.queryParamsName,
1009
- queryParams: this.queryParams,
1010
- conditionParams: {},
1011
- pageNo: 1,
1012
- pageSize: 1
1013
- }
1014
- requestParameters.conditionParams[primaryKeyName] = this.selectId
1015
- requestParameters.f_businessid = this.selectId
1016
- return queryWithResource(requestParameters, this.serviceName, this.env === 'dev').then(res => {
1017
- return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
1018
- })
1019
- },
1020
- // 删除业务
1021
- deleteItem () {
1022
- if (this.viewMode) {
1023
- this.$message.info('预览模式禁止删除')
1024
- return
1025
- }
1026
- Modal.confirm({
1027
- title: '提示',
1028
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
1029
- zIndex: 1001,
1030
- onOk: () => {
1031
- const requestParameters = {
1032
- queryParamsName: this.queryParamsName,
1033
- idList: this.selectedRowKeys
1034
- }
1035
- return new Promise((resolve, reject) => {
1036
- if (this.localEditMode) {
1037
- this.localEditModeDataSource = this.getLocalData().filter(item => !this.selectedRowKeys.includes(item[this.rowKey]))
1038
- resolve(200)
1039
- this.$message.success('删除成功!')
1040
- this.refresh(true)
1041
- // afterDelete
1042
- this.$emit('afterDelete', requestParameters)
1043
- } else if (this.customDelete) {
1044
- this.$emit('del', this.selectedRows, resolve)
1045
- } else {
1046
- remove(requestParameters, this.serviceName, this.env === 'dev').then(res => {
1047
- resolve(res)
1048
- this.$message.success('删除成功!')
1049
- this.refresh(true)
1050
- // afterDelete
1051
- this.$emit('afterDelete', requestParameters)
1052
- }).catch(e => {
1053
- reject(e)
1054
- this.$message.error('删除失败!')
1055
- })
1056
- }
1057
- })
1058
- },
1059
- onCancel () {
1060
- }
1061
- })
1062
- },
1063
- // 导入业务
1064
- importData () {
1065
- this.$refs.importExcel.importExcelHandleOpen()
1066
- },
1067
- afterVisibleChange () {
1068
- this.retrieveSummaryData()
1069
- },
1070
- async retrieveSummaryData () {
1071
- if (this.requestParameters.querySummary) {
1072
- querySummary(Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev').then(res => {
1073
- if (res.length > 0) {
1074
- this.summaryData.forEach(item => {
1075
- res.forEach(summary => {
1076
- if (item.title === summary.title) {
1077
- item.value = summary.value
1078
- item.success = true
1079
- item.loading = false
1080
- }
1081
- })
1082
- })
1083
- }
1084
- })
1085
- }
1086
- if (this.showCustomSummary) {
1087
- this.customSummaryArray.forEach(item => {
1088
- runLogic(item.source, Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev').then((res) => {
1089
- this.summaryData.forEach(summary => {
1090
- if (item.key === summary.key) {
1091
- summary.value = res.value
1092
- summary.success = true
1093
- summary.loading = false
1094
- }
1095
- })
1096
- }).catch(e => {
1097
- this.summaryData.forEach(summary => {
1098
- if (item.key === summary.key) {
1099
- summary.value = 0
1100
- summary.success = false
1101
- summary.loading = false
1102
- }
1103
- })
1104
- })
1105
- })
1106
- }
1107
- },
1108
- showDrawer () {
1109
- if (this.summaryUpdate) {
1110
- this.summaryData.forEach(item => {
1111
- item.loading = true
1112
- item.success = false
1113
- item.value = ' '
1114
- })
1115
- this.summaryDrawerVisible = true
1116
- } else {
1117
- this.$message.warning('请查询后再来查看')
1118
- }
1119
- },
1120
- onClose () {
1121
- this.summaryDrawerVisible = false
1122
- },
1123
- // 获取表格内所有数据
1124
- getTableData () {
1125
- return this.$refs.table.localDataSource
1126
- },
1127
- // 获取所有本地数据
1128
- getLocalData () {
1129
- return this.localEditModeDataSource
1130
- },
1131
- // 获取指定rowKey的value的本地数据
1132
- getDataByRowKeyValue (rowKeyValue) {
1133
- return this.getLocalData().find(item => {
1134
- return item[this.rowKey] === rowKeyValue
1135
- })
1136
- },
1137
- // 修改本地数据
1138
- modifyLocalData (rowKeyValue, data) {
1139
- const modifyItem = this.getDataByRowKeyValue(rowKeyValue)
1140
- if (modifyItem) {
1141
- Object.assign(modifyItem, data)
1142
- }
1143
- },
1144
- // 追加本地数据
1145
- appendLocalData (item) {
1146
- item['序号'] = this.localEditModeDataSource.length
1147
- this.localEditModeDataSource.push(item)
1148
- }
1149
- }
1150
- }
1151
- </script>
1152
- <style lang="less" scoped>
1153
- :deep(.ant-table-thead > tr > th) {
1154
- font-weight: 600;
1155
- }
1156
-
1157
- :deep(.table-wrapper .ant-pagination) {
1158
- display: flex;
1159
- flex-direction: row;
1160
- align-items: center;
1161
- padding: 0;
1162
- }
1163
-
1164
- :deep(.table-wrapper .ant-pagination .ant-pagination-total-text) {
1165
- white-space: nowrap;
1166
- }
1167
-
1168
- :deep(.ant-table td) {
1169
- white-space: nowrap;
1170
- }
1171
-
1172
- .footer_sum_title {
1173
- color: @primary-color;
1174
- font-weight: bold;
1175
- }
1176
-
1177
- .footer_sum_item {
1178
- white-space: nowrap;
1179
- }
1180
-
1181
- .ant-btn-hover {
1182
- border-color: @primary-color;
1183
- color: @primary-color;
1184
- }
1185
-
1186
- .innerTable {
1187
- :deep(.ant-form-item) {
1188
- margin: 0;
1189
- }
1190
- }
1191
- </style>
1
+ <template>
2
+ <div v-show="tableColumns.length > 0">
3
+ <a-row :gutter="48">
4
+ <a-col v-show="showLeftOperaBtn">
5
+ <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
+ <a-space>
7
+ <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
8
+ <a-button v-if="buttonState.add && buttonRendering('add')" type="primary" @click="add">
9
+ <a-icon type="plus"/>新增
10
+ </a-button>
11
+ <a-button v-if="buttonState.move && buttonRendering('move')" type="primary" @click="move">
12
+ <a-icon type="plus"/>添加
13
+ </a-button>
14
+ <a-button v-if="buttonState.choose && buttonRendering('choose')" :disabled="!isChoose" type="primary" @click="choose">
15
+ <a-icon type="check-square"/>选择
16
+ </a-button>
17
+ <a-button
18
+ v-if="buttonState.edit && buttonRendering('edit')"
19
+ :disabled="!isModify"
20
+ :loading="editLoading"
21
+ class="btn-success"
22
+ type="dashed"
23
+ @click="edit()">
24
+ <a-icon :style="iconStyle" type="form"/>修改
25
+ </a-button>
26
+ <template
27
+ v-if="buttonState.editRow && buttonRendering('editRow')">
28
+ <a-button
29
+ v-if="isEditMode"
30
+ class="ant-btn-hover"
31
+ @click="editRowSave">
32
+ <a-icon :style="iconStyle" type="save"/>保存
33
+ </a-button>
34
+ <a-button
35
+ v-else
36
+ @click="openEditMode">
37
+ <a-icon :style="iconStyle" type="edit"/>行编辑
38
+ </a-button>
39
+ </template>
40
+ <a-button
41
+ v-if="buttonState.delete && buttonRendering('delete')"
42
+ :disabled="!isDelete"
43
+ type="danger"
44
+ @click="deleteItem">
45
+ <a-icon :style="iconStyle" type="delete"/>删除
46
+ </a-button>
47
+ <a-button
48
+ v-if="buttonState.import && buttonRendering('import')"
49
+ type="dashed"
50
+ @click="importData">
51
+ <a-icon :style="iconStyle" type="import"/>导入
52
+ </a-button>
53
+ <a-dropdown v-if="!buttonState || buttonState.export && buttonRendering('export')">
54
+ <a-menu slot="overlay">
55
+ <a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon
56
+ :style="iconStyle"
57
+ type="ordered-list"/>导出选中数据</a-menu-item>
58
+ <a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets"/>导出本页数据</a-menu-item>
59
+ <a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download"/>导出所有符合条件的数据</a-menu-item>
60
+ <!-- <a-menu-item key="4" @click="handleAsyncExportByQuery"><a-icon :style="iconStyle" type="download"/>异步导出所有符合条件的数据</a-menu-item>-->
61
+ </a-menu>
62
+ <a-button>导出 <a-icon type="down" :style="iconStyle"/> </a-button>
63
+ </a-dropdown>
64
+ <!-- 遍历按钮配置数组,动态生成按钮 -->
65
+ <a-button
66
+ v-for="(button, index) in editButtonStateData"
67
+ :key="index"
68
+ :type="button.type || 'dashed'"
69
+ @click="editButtonStateDataClick(index)"
70
+ class="btn-success"
71
+ >
72
+ <a-icon type="dashed" :style="iconStyle"/>
73
+ {{ button.buttonName }}
74
+ </a-button>
75
+
76
+ <a-button v-if="allowedCardMode && !simpleMode" @click="changeViewMode" :type="isTableMode ? '' : 'primary'">
77
+ 看板模式
78
+ </a-button>
79
+ <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
80
+ </a-space>
81
+ </span>
82
+ </a-col>
83
+ <a-col v-show="showRightTools && !simpleMode">
84
+ <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
85
+ <a-button-group>
86
+ <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
87
+ <a-tooltip title="汇总" placement="bottom">
88
+ <a-button @click="showDrawer">
89
+ <a-icon :style="iconStyle" type="project"/>
90
+ </a-button>
91
+ </a-tooltip>
92
+ <a-tooltip title="重新查询" placement="bottom">
93
+ <a-button @click="refresh(true)">
94
+ <a-icon :style="iconStyle" type="reload"/>
95
+ </a-button>
96
+ </a-tooltip>
97
+ <a-tooltip title="列展示/排序" placement="bottom">
98
+ <table-setting v-if="columnSelectLoaded" v-model="tableColumns"/>
99
+ </a-tooltip>
100
+ </a-button-group>
101
+ </span>
102
+ </a-col>
103
+ </a-row>
104
+ <!-- 如果当前是表格模式 -->
105
+ <template v-if="isTableMode && !simpleMode">
106
+ <s-table
107
+ ref="table"
108
+ :id="uniqueId"
109
+ :alert="true"
110
+ :columns="tableColumns"
111
+ :data="loadData"
112
+ :rowKey="rowKey"
113
+ :showSummary="showSummary"
114
+ :rowSelection="rowSelection"
115
+ :scroll="{ x: scrollXWidth, y: scrollYHeight }"
116
+ :showPagination="showPagination"
117
+ :setScrollYHeight="setScrollYHeight"
118
+ size="default"
119
+ >
120
+ <template
121
+ v-for="(item, c_index) in tableColumns"
122
+ :slot="item.dataIndex"
123
+ slot-scope="text, record, index">
124
+ <template v-if="isEditMode && getFromItem(item.dataIndex)">
125
+ <x-form-item
126
+ class="innerTable"
127
+ :form="record"
128
+ :attr="getFromItem(item.dataIndex)"
129
+ :service-name="serviceName"
130
+ mode="新增/修改"
131
+ :env="env"
132
+ :showLabel="false"
133
+ :key="'editRow-' + c_index"
134
+ />
135
+ </template>
136
+ <!-- 序号列 -->
137
+ <span v-else-if="item.slotType === 'index'" :key="'index-' + c_index">
138
+ {{ index + 1 }}
139
+ </span>
140
+ <!-- 行链接 -->
141
+ <span v-else-if="item.slotType === 'link'" :key="'link-' + c_index">
142
+ <a @click="columnClick(item.dataIndex,text,record)">{{ text }}</a>
143
+ </span>
144
+ <!-- 文本溢出省略(ellipsis) -->
145
+ <span v-else-if="item.slotType === 'ellipsis'" :key="'ellipsis-' + c_index">
146
+ <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
147
+ </span>
148
+ <!-- 徽标(badge) -->
149
+ <span v-else-if="item.slotType === 'badge'" :key="'badge-' + c_index">
150
+ <x-badge
151
+ :service-name="serviceName"
152
+ :env="env"
153
+ v-if="text !== null && text !== undefined"
154
+ :badge-key="item.slotKeyMap"
155
+ :value="text"/>
156
+ </span>
157
+ <!-- 日期(date) -->
158
+ <span v-else-if="item.slotType === 'date'" :key="'date-' + c_index">
159
+ {{ format(text, 'yyyy-MM-dd') }}
160
+ </span>
161
+ <!-- 日期时间(datetime) -->
162
+ <span v-else-if="item.slotType === 'dateTime'" :key="'dateTime-' + c_index">
163
+ {{ format(text, 'yyyy-MM-dd hh:mm:ss') }}
164
+ </span>
165
+ <!-- 两位小数 -->
166
+ <span v-else-if="item.slotType === 'towDecimal'" :key="'towDecimal-' + c_index">
167
+ {{ numberFormat(text, 2) }}
168
+ </span>
169
+ <!-- 四位小数 -->
170
+ <span v-else-if="item.slotType === 'fourDecimal'" :key="'fourDecimal-' + c_index">
171
+ {{ numberFormat(text, 4) }}
172
+ </span>
173
+ <!-- 整数 -->
174
+ <span v-else-if="item.slotType === 'int'" :key="'int-' + c_index">
175
+ {{ numberFormat(text, 0) }}
176
+ </span>
177
+ <!-- 操作列(action) -->
178
+ <span v-else-if="item.slotType === 'action'" :key="'action-' + c_index">
179
+ <template v-if="item.actionArr && item.actionArr.length > 0">
180
+ <a-dropdown>
181
+ <a class="ant-dropdown-link" @click="e => e.preventDefault()">
182
+ {{ item.scopedSlots?.customRender || item.slotValue }} <a-icon type="down"/>
183
+ </a>
184
+ <a-menu slot="overlay" style="min-width: 60px">
185
+ <a-menu-item
186
+ v-for="(action_item, actionIndex) in item.actionArr"
187
+ :key="actionIndex"
188
+ v-if="!action_item.customFunction || executeStrFunction( action_item.customFunction,[record,c_index])">
189
+ <a
190
+ style="text-align: center"
191
+ @click="action(record, item.dataIndex, action_item.func)"
192
+ >{{ action_item.text }}</a>
193
+ </a-menu-item>
194
+ </a-menu>
195
+ </a-dropdown>
196
+ </template>
197
+ <template v-if="!item.actionArr || item.actionArr.length === 0">
198
+ <a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
199
+ </template>
200
+ </span>
201
+ </template>
202
+ <template slot="footer">
203
+ <slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
204
+ </template>
205
+ </s-table>
206
+ </template>
207
+ <!-- 如果当前是看板模式 -->
208
+ <template v-else>
209
+ <XDataCard
210
+ ref="table"
211
+ @cardEmit="handleCardEmit"
212
+ :tableColumns="tableColumns"
213
+ :card-config="cardModeConfig"
214
+ :show-pagination="true"
215
+ :serviceName="serviceName"
216
+ :card-data="loadData"
217
+ :env="env"
218
+ :createdQuery="createdQuery"
219
+ :simple-mode="simpleMode"/>
220
+ </template>
221
+ <!-- 上传文件 -->
222
+ <a-drawer
223
+ title="汇总信息"
224
+ placement="right"
225
+ :closable="false"
226
+ :visible="summaryDrawerVisible"
227
+ :z-index="2000"
228
+ width="25%"
229
+ :after-visible-change="afterVisibleChange"
230
+ @close="onClose"
231
+ >
232
+ <template>
233
+ <a-row>
234
+ <a-col :span="8" v-for="(f,index) in summaryData" :key="index">
235
+ <a-statistic
236
+ :title="f.title + ':'"
237
+ :value="f.value"
238
+ :precision="2">
239
+ <template #prefix>
240
+ <a-spin :spinning="f.loading">
241
+ </a-spin>
242
+ </template>
243
+ <template #suffix>
244
+ <a-icon
245
+ v-show="!f.loading"
246
+ :type="f.success !== false ? 'check-circle' : 'close-circle'"
247
+ :style="{color: f.success !== false ? 'green' : 'red'}"/>
248
+ </template>
249
+ </a-statistic>
250
+ </a-col>
251
+ </a-row>
252
+ </template>
253
+ </a-drawer>
254
+ <x-import-excel
255
+ ref="importExcel"
256
+ @ok="importExcelOk"
257
+ :title="title"
258
+ :service-name="serviceName"
259
+ :env="env"
260
+ :query-params-name="queryParamsName"
261
+ >
262
+ <template #importExcelSlot>
263
+ <slot name="importExcelSlot"></slot>
264
+ </template>
265
+ </x-import-excel>
266
+ </div>
267
+ </template>
268
+ <script>
269
+ import { Ellipsis, STable } from '@vue2-client/components'
270
+ import { formatDate, getChangedData } from '@vue2-client/utils/util'
271
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
272
+ import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
273
+ import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
274
+ import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
275
+ import {
276
+ exportData,
277
+ query,
278
+ querySummary,
279
+ queryWithResource,
280
+ remove,
281
+ asyncRunTask,
282
+ editRowSave,
283
+ runLogic
284
+ } from '@vue2-client/services/api/common'
285
+ import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
286
+ import { Modal } from 'ant-design-vue'
287
+ import { mapState } from 'vuex'
288
+ import { executeStrFunction } from '@vue2-client/utils/runEvalFunction'
289
+ import debounce from 'lodash.debounce'
290
+ import XDataCard from '@vue2-client/base-client/components/common/XDataCard/XDataCard.vue'
291
+ import { getRealKeyData } from '@vue2-client/utils/formatter'
292
+
293
+ export default {
294
+ name: 'XTable',
295
+ components: {
296
+ XDataCard,
297
+ TableSetting,
298
+ STable,
299
+ Ellipsis,
300
+ XBadge,
301
+ XImportExcel,
302
+ XFormItem
303
+ },
304
+ data () {
305
+ return {
306
+ uniqueId: `x-table-${this._uid}`, // 使用 _uid 生成唯一 ID
307
+ // 筛选列加载状态
308
+ columnSelectLoaded: false,
309
+ // 预览模式
310
+ viewMode: false,
311
+ // 本地编辑模式
312
+ localEditMode: false,
313
+ // 本地编辑模式所用数据源
314
+ localEditModeDataSource: [],
315
+ // 本地编辑模式数据源是否已由外部加载
316
+ isLocalDataSourceLoadedExternally: false,
317
+ // 行选择模式
318
+ rowSelectMode: false,
319
+ // 行选择模式-允许选中行数量,0:任意数量行,大于0:指定值数量的行
320
+ allowSelectRowNum: 0,
321
+ // 是否展示右侧工具栏
322
+ showRightTools: true,
323
+ // 是否展示左边按钮栏
324
+ showLeftOperaBtn: true,
325
+ // 加载数据方法 必须为 Promise 对象
326
+ loadData: parameter => {
327
+ // 取到表格携带的表单参数
328
+ const requestParameters = Object.assign({}, parameter)
329
+ // 取到父组件传入的表单参数
330
+ const conditionParams = {}
331
+ Object.assign(conditionParams, this.fixedQueryForm)
332
+ Object.assign(conditionParams, this.form)
333
+ // 如果传了燃气公司字段,则进行数据处理
334
+ if (conditionParams.orgName) {
335
+ requestParameters.orgName = conditionParams.orgName
336
+ delete conditionParams.orgName
337
+ }
338
+ Object.keys(conditionParams).forEach(key => {
339
+ if (Array.isArray(conditionParams[key])) {
340
+ // 检查数组中是否包含 null
341
+ const hasNull = conditionParams[key].every(item => item === '') || conditionParams[key].length === 0
342
+ // 如果包含 null,则删除该属性
343
+ if (hasNull) {
344
+ delete conditionParams[key]
345
+ }
346
+ }
347
+ })
348
+ requestParameters.conditionParams = conditionParams
349
+ requestParameters.queryParamsName = this.queryParamsName
350
+ requestParameters.queryParams = this.queryParams
351
+ this.requestParameters = requestParameters
352
+ // 加载数据
353
+ return this.loadTableData(requestParameters)
354
+ },
355
+ requestParameters: {},
356
+ rowKey: undefined,
357
+ // x滚动条宽度
358
+ scrollXWidth: 1600,
359
+ // y滚动条高度
360
+ scrollYHeight: 'calc(100vh - 31rem)',
361
+ // 表格选择列Key集合
362
+ selectedRowKeys: [],
363
+ // 表格选择Row集合
364
+ selectedRows: [],
365
+ // 禁止表格选择Row集合
366
+ selectedDisableRows: [],
367
+ // 业务标题
368
+ title: '',
369
+ // 数据列
370
+ tableColumns: [],
371
+ // 查询用表单
372
+ form: {},
373
+ oldForm: {},
374
+ // 是否允许修改
375
+ isModify: false,
376
+ // 是否允许删除
377
+ isDelete: false,
378
+ // 是否允许选择
379
+ isChoose: false,
380
+ // 服务名称
381
+ serviceName: undefined,
382
+ // 选中用于修改的id
383
+ selectId: undefined,
384
+ // 是否显示展示列抽屉
385
+ visible: false,
386
+ // 编辑按钮加载状态
387
+ editLoading: false,
388
+ // 按钮状态
389
+ buttonState: {},
390
+ // 自定义按钮数组
391
+ editButtonStateData: [],
392
+ // 按钮权限
393
+ buttonPermissions: [],
394
+ // 是否展示汇总
395
+ showSummary: false,
396
+ // 自定义汇总
397
+ showCustomSummary: false,
398
+ summaryData: [],
399
+ // 图标样式
400
+ iconStyle: {
401
+ position: 'relative',
402
+ top: '1px'
403
+ },
404
+ // 当前环境
405
+ env: 'prod',
406
+ // 预览模式(表格 or 看板)
407
+ isTableMode: true,
408
+ // 汇总抽屉是否显示
409
+ summaryDrawerVisible: false,
410
+ // 汇总更新标志
411
+ summaryUpdate: false,
412
+ customSummaryArray: [],
413
+ formItems: [],
414
+ // 是否为行编辑模式
415
+ isEditMode: false,
416
+ // 定义主键
417
+ primaryKey: '',
418
+ // 是否进行初始化查询
419
+ createdQuery: true,
420
+ // 允许看板模式
421
+ allowedCardMode: false,
422
+ // 看板模式配置
423
+ cardModeConfig: undefined,
424
+ // 暂存行编辑前数据 用于比较哪些变化了才需要保存
425
+ editRowBeforeData: [],
426
+ // 是否简易模式
427
+ simpleMode: false
428
+ }
429
+ },
430
+ props: {
431
+ // 查询配置文件名
432
+ queryParamsName: {
433
+ type: String,
434
+ default: () => {
435
+ return ''
436
+ }
437
+ },
438
+ // 查询配置文件Json
439
+ queryParamsJson: {
440
+ type: Object,
441
+ default: null
442
+ },
443
+ // 固定查询表单
444
+ fixedQueryForm: {
445
+ type: Object,
446
+ default: () => {
447
+ return {}
448
+ }
449
+ },
450
+ // 数据只有一页时是否展示分页,true:展示,auto:隐藏
451
+ showPagination: {
452
+ type: Boolean,
453
+ default: true
454
+ },
455
+ // 是否自定义删除功能
456
+ customDelete: {
457
+ type: Boolean,
458
+ default: false
459
+ },
460
+ // 自适应底部编剧
461
+ extraHeight: {
462
+ type: Number,
463
+ default: 80
464
+ }
465
+ },
466
+ computed: {
467
+ rowSelection () {
468
+ return {
469
+ selectedRowKeys: this.selectedRowKeys,
470
+ onChange: this.onSelectChange,
471
+ getCheckboxProps: record => ({
472
+ props: {
473
+ disabled: this.selectedDisableRows.includes(record[this.rowKey]), // Column configuration not to be checked
474
+ name: record.name,
475
+ },
476
+ }),
477
+ }
478
+ },
479
+ ...mapState('account', { currUser: 'user' }),
480
+ ...mapState('setting', ['compatible'])
481
+ },
482
+ mounted () {
483
+ window.addEventListener('resize', this.handleResize)
484
+ },
485
+ beforeDestroy () {
486
+ window.removeEventListener('resize', this.handleResize)
487
+ },
488
+ methods: {
489
+ columnClick (key, value, record) {
490
+ this.$emit('columnClick', key, value, record)
491
+ },
492
+ getFromItem (model) {
493
+ const aa = this.formItems.find(item => item.model === model && item.editRow)
494
+ if (aa) {
495
+ return JSON.parse(JSON.stringify(aa))
496
+ }
497
+ return false
498
+ },
499
+ // 打开行编辑
500
+ openEditMode () {
501
+ this.isEditMode = true
502
+ this.editRowBeforeData = JSON.parse(JSON.stringify(this.getTableData()))
503
+ },
504
+ // 标记行保存
505
+ editRowSave () {
506
+ // 获取最新数据
507
+ const editRowAfterData = this.getTableData()
508
+ const changeData = getChangedData(this.editRowBeforeData, editRowAfterData)
509
+ if (changeData.length === 0) {
510
+ this.$message.info('没有数据发生变化')
511
+ } else {
512
+ Modal.confirm({
513
+ title: '是否确认保存?',
514
+ content: `此操作将保存当前行编辑的数据,共修改${changeData.length}条数据`,
515
+ zIndex: 1001,
516
+ onOk: () => {
517
+ return new Promise((resolve, reject) => {
518
+ const requestParameters = {
519
+ queryParamsName: this.queryParamsName,
520
+ changeData: changeData.map(h => getRealKeyData(h)),
521
+ operaInfo: this.currUser.operaInfo
522
+ }
523
+ editRowSave(requestParameters, this.serviceName, this.env === 'dev').then(res => {
524
+ this.$message.success('行内数据保存成功')
525
+ this.isEditMode = false
526
+ this.refresh()
527
+ resolve(res)
528
+ }).catch(e => {
529
+ reject(e)
530
+ this.$message.error('保存失败!')
531
+ })
532
+ })
533
+ },
534
+ onCancel () {
535
+ }
536
+ })
537
+ }
538
+ },
539
+ importExcelOk () {
540
+ this.refresh(true)
541
+ this.$emit('importExcelOk')
542
+ },
543
+ handleResize () {
544
+ debounce(() => {
545
+ this.setScrollYHeight({})
546
+ }, 100)()
547
+ },
548
+ isInAModal () {
549
+ let parent = this.$parent
550
+ while (parent) {
551
+ // 检查组件名称,这里假设a-modal组件的名称为AModal,根据实际情况可能需要调整
552
+ if (parent.$options.name === 'AModal') {
553
+ return true
554
+ }
555
+ parent = parent.$parent
556
+ }
557
+ return false
558
+ },
559
+ executeStrFunction,
560
+ // 切换看板模式和表格模式
561
+ changeViewMode () {
562
+ this.isTableMode = !this.isTableMode
563
+ // 看板切换回表格模式 刷新列表
564
+ if (this.isTableMode) {
565
+ this.refresh(true)
566
+ }
567
+ },
568
+ /**
569
+ * 初始化表格参数
570
+ */
571
+ init (params) {
572
+ const {
573
+ // 查询参数对象, 用于没有对应查询配置文件名时
574
+ queryParams,
575
+ tableColumns,
576
+ buttonState,
577
+ buttonPermissions,
578
+ editButtonStateData = [],
579
+ title,
580
+ form,
581
+ serviceName,
582
+ tableSummaryMap = {},
583
+ customTableSummaryArray = [],
584
+ viewMode,
585
+ localEditMode,
586
+ rowSelectMode,
587
+ allowSelectRowNum = 0,
588
+ formItems,
589
+ env = 'prod',
590
+ createdQuery = true,
591
+ createdEditMode = false,
592
+ primaryKey,
593
+ allowedCardMode = false,
594
+ simpleMode = false,
595
+ cardModeConfig,
596
+ summaryUpdate
597
+ } = params
598
+ this.showSummary = Object.keys(tableSummaryMap).length > 0
599
+ if (this.showSummary) {
600
+ Object.keys(tableSummaryMap).forEach(item => {
601
+ this.summaryData.push({
602
+ key: item,
603
+ title: tableSummaryMap[item],
604
+ value: ' ',
605
+ loading: true,
606
+ success: false
607
+ })
608
+ })
609
+ }
610
+ if (customTableSummaryArray.length > 0) {
611
+ customTableSummaryArray.forEach(item => {
612
+ this.summaryData.push({
613
+ key: item.key,
614
+ title: item.title,
615
+ value: ' ',
616
+ loading: true,
617
+ success: false
618
+ })
619
+ })
620
+ this.showCustomSummary = true
621
+ this.customSummaryArray = customTableSummaryArray
622
+ }
623
+ this.queryParams = queryParams
624
+ this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
625
+ if (this.tableColumns.length === 0) {
626
+ return
627
+ }
628
+ this.viewMode = viewMode
629
+ this.localEditMode = localEditMode
630
+ this.rowSelectMode = rowSelectMode
631
+ this.allowSelectRowNum = allowSelectRowNum
632
+ this.simpleMode = simpleMode
633
+ this.formItems = formItems
634
+ this.createdQuery = createdQuery
635
+ this.primaryKey = primaryKey
636
+ this.buttonState = buttonState
637
+ if (this.localEditMode) {
638
+ this.localEditModeDataSource = []
639
+ this.isLocalDataSourceLoadedExternally = false
640
+ this.buttonState.import = false
641
+ this.buttonState.export = false
642
+ this.showRightTools = false
643
+ }
644
+ if (this.rowSelectMode) {
645
+ this.buttonState = {
646
+ choose: true
647
+ }
648
+ this.showRightTools = false
649
+ }
650
+ this.buttonPermissions = buttonPermissions
651
+ this.editButtonStateData = editButtonStateData
652
+ this.title = title
653
+ this.serviceName = serviceName
654
+ this.env = env
655
+ this.rowKey = this.getPrimaryKeyName()
656
+ this.allowedCardMode = allowedCardMode
657
+ this.cardModeConfig = cardModeConfig
658
+ this.summaryUpdate = summaryUpdate
659
+ this.isEditMode = createdEditMode
660
+ let totalWidth = 0
661
+ for (let i = 0; i < this.tableColumns.length; i++) {
662
+ const item = this.tableColumns[i]
663
+ // 设置操作列
664
+ if (item.slotType === 'action') {
665
+ item.fixed = 'right'
666
+ item.width = 70
667
+ }
668
+ // 设置表格宽度
669
+ if (item.width) {
670
+ totalWidth = totalWidth + item.width
671
+ } else {
672
+ totalWidth = totalWidth + 180
673
+ }
674
+ }
675
+ // 横向滚动长度大于所有宽度,才能实现固定表头
676
+ this.scrollXWidth = totalWidth
677
+ // 加载筛选列完成
678
+ this.columnSelectLoaded = true
679
+ this.setQueryForm(form || {})
680
+ },
681
+ // 操作面板按钮渲染
682
+ buttonRendering (button) {
683
+ if (!this.buttonPermissions) {
684
+ return true
685
+ }
686
+ try {
687
+ const existingItem = this.buttonPermissions.find(item => item.btnName === button)
688
+ const rolestr = this.currUser.rolestr?.split(',')
689
+ if (existingItem?.state) {
690
+ const currUserRole = existingItem.roleStr
691
+ return rolestr.some(item => currUserRole && currUserRole.includes(item))
692
+ } else {
693
+ return true
694
+ }
695
+ } catch (e) {
696
+ console.error(e)
697
+ return false
698
+ }
699
+ },
700
+ /**
701
+ * 加载表格数据
702
+ * @param requestParameters 请求参数
703
+ */
704
+ async loadTableData (requestParameters) {
705
+ let result
706
+ if (this.localEditMode) {
707
+ if (!this.isLocalDataSourceLoadedExternally && requestParameters?.conditionParams && Object.keys(requestParameters?.conditionParams).length > 0) {
708
+ const result = await query(Object.assign(requestParameters, { userId: this.currUser?.id }),
709
+ this.serviceName, this.env === 'dev')
710
+ if (result.data) {
711
+ let no = 0
712
+ this.localEditModeDataSource = result.data.map(item => {
713
+ item['序号'] = no
714
+ no++
715
+ return item
716
+ })
717
+ }
718
+ this.isLocalDataSourceLoadedExternally = true
719
+ }
720
+ result = new Promise((resolve) => {
721
+ resolve({
722
+ data: this.localEditModeDataSource
723
+ })
724
+ })
725
+ } else {
726
+ result = query(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
727
+ }
728
+ if (this.isTableMode && !this.simpleMode) {
729
+ this.clearRowKeys()
730
+ }
731
+ this.$emit('afterQuery', result, requestParameters.conditionParams)
732
+ return result
733
+ },
734
+ /**
735
+ * 操作列事件
736
+ * @param record 本条数据
737
+ * @param actionType 操作类型
738
+ * @param func 事件默认 action
739
+ */
740
+ action (record, actionType, func = 'action') {
741
+ this.$emit('action', record, record[this.getPrimaryKeyName()], actionType, func)
742
+ },
743
+ // 看板点击事件
744
+ handleCardEmit (data, eventName) {
745
+ this.action(data, undefined, eventName)
746
+ },
747
+ /**
748
+ * 选择列事件
749
+ * @param selectedRowKeys 被选择的列Key集合
750
+ * @param selectedRows 被选择的列集合
751
+ */
752
+ onSelectChange (selectedRowKeys, selectedRows) {
753
+ this.selectedRowKeys = selectedRowKeys
754
+ this.selectedRows = selectedRows
755
+ this.isModify = this.selectedRowKeys.length === 1
756
+ this.isDelete = this.selectedRowKeys.length > 0
757
+ this.isChoose = this.allowSelectRowNum === 0 ? this.selectedRowKeys.length > 0 : this.selectedRowKeys.length === this.allowSelectRowNum
758
+ this.$emit('selectRow', selectedRowKeys, selectedRows)
759
+ },
760
+ /**
761
+ * 清除表格选中项
762
+ */
763
+ clearRowKeys () {
764
+ this.$refs.table.clearSelected()
765
+ },
766
+ /**
767
+ * 为表格附加查询条件
768
+ */
769
+ setQueryForm (form = {}) {
770
+ this.form = form
771
+ if (this.createdQuery) {
772
+ this.refresh(true)
773
+ }
774
+ },
775
+ /**
776
+ * 表格重新加载方法
777
+ * 如果参数为 true, 则强制刷新到第一页
778
+ */
779
+ refresh (bool) {
780
+ this.$nextTick(() => {
781
+ this.$refs.table.refresh(bool)
782
+ })
783
+ },
784
+ setScrollYHeight ({ extraHeight = this.extraHeight, id = this.uniqueId, type = '' }) {
785
+ this.$nextTick(() => {
786
+ setTimeout(() => {
787
+ const curDocument = window?.rawDocument || document
788
+ const innerHeight = window?.rawWindow?.innerHeight || window.innerHeight || 0
789
+ if (typeof extraHeight == 'undefined') {
790
+ // 默认底部分页32 + 边距48
791
+ extraHeight = 48 + 32
792
+ }
793
+ let tHeader = null
794
+ if (id) {
795
+ tHeader = curDocument.getElementById(id) ? curDocument.getElementById(id).getElementsByClassName('ant-table-thead')[0] : null
796
+ } else {
797
+ tHeader = curDocument.getElementsByClassName('ant-table-thead')[0]
798
+ }
799
+ // 表格内容距离顶部的距离
800
+ let tHeaderBottom = 0
801
+ if (tHeader) {
802
+ tHeaderBottom = tHeader.getBoundingClientRect().bottom
803
+ }
804
+ if (tHeaderBottom === 0) {
805
+ this.scrollYHeight = 'calc(100vh - 31rem)'
806
+ if (window.__MICRO_APP_ENVIRONMENT__) {
807
+ this.scrollYHeight = 'calc(100vh - 28.5rem)'
808
+ }
809
+ return
810
+ }
811
+
812
+ // 判断是否在 modal 中
813
+ if (this.isInAModal()) {
814
+ let modalElement = null
815
+ if (tHeader) {
816
+ modalElement = tHeader.closest('.ant-modal-body')
817
+ } else {
818
+ modalElement = curDocument.querySelector('.ant-modal-body')
819
+ }
820
+ if (modalElement) {
821
+ const modalRect = modalElement.getBoundingClientRect()
822
+ // 48 是 modal 通常的边距 32 是分页
823
+ extraHeight = innerHeight - modalRect.bottom + 32 + 48
824
+ }
825
+ }
826
+ if (innerHeight - (tHeaderBottom + extraHeight) < 210) {
827
+ this.scrollYHeight = 'calc(100vh - 31rem)'
828
+ return
829
+ }
830
+ // 窗体高度-表格内容顶部的高度-表格内容底部的高度
831
+ // this.scrollYHeight = document.body.clientHeight - tHeaderBottom - extraHeight
832
+ this.scrollYHeight = `calc(100vh - ${tHeaderBottom + extraHeight}px)`
833
+ }, 60)
834
+ })
835
+ },
836
+ /**
837
+ * 格式化日期
838
+ * @param date 日期字符串
839
+ * @param format 格式化方式
840
+ */
841
+ format (date, format) {
842
+ return formatDate(date, format)
843
+ },
844
+ /**
845
+ * 格式化数字
846
+ * @param number string 或者 number
847
+ * @param decimalPlaces 小数位数
848
+ */
849
+ numberFormat (number, decimalPlaces = 2) {
850
+ const value = parseFloat(number)
851
+ if (!isNaN(value)) {
852
+ return value.toFixed(decimalPlaces)
853
+ } else {
854
+ return ''
855
+ }
856
+ },
857
+ /**
858
+ * 获取主键列名称
859
+ */
860
+ getPrimaryKeyName () {
861
+ if (this.primaryKey) {
862
+ return this.primaryKey
863
+ }
864
+ const indexColumn = this.tableColumns.find(i => i?.slotType === 'index')
865
+ return indexColumn ? indexColumn.dataIndex : this.tableColumns[0].dataIndex
866
+ },
867
+ // 导出选中或本页数据
868
+ handleExport (isSelected) {
869
+ const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
870
+ const filterVal = this.tableColumns.map(res => res.dataIndex)
871
+ let exportData
872
+ if (isSelected) {
873
+ exportData = this.selectedRows
874
+ } else {
875
+ exportData = this.$refs.table.localDataSource
876
+ }
877
+ exportJson(tHeader, exportData.map(v => filterVal.map(j => v[j])), this.title + `数据_${new Date().toLocaleString()}`)
878
+ },
879
+ // 导出符合条件的数据
880
+ handleExportByQuery () {
881
+ const that = this
882
+ const conditionParams = Object.assign(that.form, that.fixedQueryForm)
883
+ this.$confirm({
884
+ title: '是否确认导出?',
885
+ content: '此操作将导出当前条件下所有数据而非选中数据',
886
+ onOk () {
887
+ exportData({
888
+ queryParamsName: that.queryParamsName,
889
+ queryParams: that.queryParams,
890
+ form: conditionParams,
891
+ userId: that.currUser.id
892
+ }, that.serviceName, that.env === 'dev').then(res => {
893
+ let value = res
894
+ if (that.compatible === 'V4' || (Object.keys(res).length === 1 && Object.prototype.hasOwnProperty.call(res, 'value'))) {
895
+ value = res.value
896
+ }
897
+ // window.open('/res/excel/export/' + value)
898
+ window.open(value)
899
+ })
900
+ },
901
+ onCancel () {
902
+ }
903
+ })
904
+ },
905
+ handleAsyncExportByQuery () {
906
+ const that = this
907
+ const conditionParams = Object.assign(that.form, that.fixedQueryForm)
908
+ this.$confirm({
909
+ title: '是否确认导出?',
910
+ content: (h) => (
911
+ <div>
912
+ <p>此操作将导出当前条件下所有数据而非选中数据</p>
913
+ {/* eslint-disable-next-line no-return-assign */}
914
+ <a-input placeholder="请输入导出文件名" onChange={(e) => this.exportFileName = e.target.value}/>
915
+ </div>
916
+ ),
917
+ onOk: () => {
918
+ if (!this.exportFileName) {
919
+ this.$message.error('文件名不能为空')
920
+ // eslint-disable-next-line prefer-promise-reject-errors
921
+ return Promise.reject() // 阻止对话框关闭
922
+ }
923
+ // 在这里执行导出的逻辑,并使用 this.exportFileName 作为文件名
924
+ const queryData = {
925
+ queryParamsName: that.queryParamsName,
926
+ queryParams: that.queryParams,
927
+ form: conditionParams,
928
+ userId: that.currUser.id
929
+ }
930
+ const date = formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
931
+
932
+ asyncRunTask({
933
+ f_task_type: '导出',
934
+ f_task_class: 'com.af.v4.impl.CommonExportHandlerImpl',
935
+ f_user_id: that.currUser.id,
936
+ // 导出条件
937
+ f_tag1: queryData,
938
+ // 导出文件名
939
+ f_tag2: this.exportFileName + '_' + that.currUser.username,
940
+ // 执行数据源
941
+ f_tag3: process.env.VUE_APP_SYSTEM_NAME,
942
+ f_service_name: that.serviceName || process.env.VUE_APP_SYSTEM_NAME,
943
+ f_task_name: `${this.exportFileName}_${that.currUser.username}_${date}`
944
+ }, that.serviceName, that.env === 'dev')
945
+ .then(res => {
946
+ }).catch(error => {
947
+ // 失败时的处理
948
+ console.log('失败:', error)
949
+ })
950
+ },
951
+ onCancel () {
952
+ }
953
+ })
954
+ },
955
+ // 新增业务
956
+ add () {
957
+ this.$emit('add')
958
+ },
959
+ // 添加业务
960
+ move () {
961
+ this.$emit('move')
962
+ },
963
+ // 编辑业务
964
+ edit (id) {
965
+ this.editLoading = true
966
+ this.getEditData(id).then(modifyModelData => {
967
+ this.$emit('edit', modifyModelData)
968
+ this.editLoading = false
969
+ })
970
+ },
971
+ // 行选择业务
972
+ choose () {
973
+ if (this.isChoose) {
974
+ // 如果配置了自定义函数
975
+ this.$emit('rowChoose', this.selectedRows)
976
+ } else {
977
+ this.$message.warning(this.allowSelectRowNum === 0 ? '请选择数据' : `请选择${this.allowSelectRowNum}条数据`)
978
+ }
979
+ },
980
+ // 自定义按钮点击
981
+ editButtonStateDataClick (index) {
982
+ this.$emit('editButtonStateDataClick', this.editButtonStateData[index].functionName, this.selectedRows)
983
+ },
984
+ // 获取被编辑的数据
985
+ getEditData (id) {
986
+ if (!id) {
987
+ this.selectId = this.selectedRowKeys[0]
988
+ } else {
989
+ this.selectId = id
990
+ }
991
+ const primaryKeyName = this.getPrimaryKeyName()
992
+ if (this.tableColumns[0].dataIndex !== primaryKeyName) {
993
+ this.selectId = this.selectedRows[0][primaryKeyName]
994
+ }
995
+ // 将更新需要的主键值加入到primaryKeyData中
996
+ const primaryKeyData = {}
997
+ primaryKeyData[primaryKeyName] = this.selectId
998
+ if (this.localEditMode) {
999
+ return new Promise((resolve) => {
1000
+ const modifyData = this.getDataByRowKeyValue(this.selectId)
1001
+ resolve({
1002
+ data: modifyData,
1003
+ primaryKeyData: primaryKeyData
1004
+ })
1005
+ })
1006
+ }
1007
+ const requestParameters = {
1008
+ queryParamsName: this.queryParamsName,
1009
+ queryParams: this.queryParams,
1010
+ conditionParams: {},
1011
+ pageNo: 1,
1012
+ pageSize: 1
1013
+ }
1014
+ requestParameters.conditionParams[primaryKeyName] = this.selectId
1015
+ requestParameters.f_businessid = this.selectId
1016
+ return queryWithResource(requestParameters, this.serviceName, this.env === 'dev').then(res => {
1017
+ return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
1018
+ })
1019
+ },
1020
+ // 删除业务
1021
+ deleteItem () {
1022
+ if (this.viewMode) {
1023
+ this.$message.info('预览模式禁止删除')
1024
+ return
1025
+ }
1026
+ Modal.confirm({
1027
+ title: '提示',
1028
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
1029
+ zIndex: 1001,
1030
+ onOk: () => {
1031
+ const requestParameters = {
1032
+ queryParamsName: this.queryParamsName,
1033
+ idList: this.selectedRowKeys
1034
+ }
1035
+ return new Promise((resolve, reject) => {
1036
+ if (this.localEditMode) {
1037
+ this.localEditModeDataSource = this.getLocalData().filter(item => !this.selectedRowKeys.includes(item[this.rowKey]))
1038
+ resolve(200)
1039
+ this.$message.success('删除成功!')
1040
+ this.refresh(true)
1041
+ // afterDelete
1042
+ this.$emit('afterDelete', requestParameters)
1043
+ } else if (this.customDelete) {
1044
+ this.$emit('del', this.selectedRows, resolve)
1045
+ } else {
1046
+ remove(requestParameters, this.serviceName, this.env === 'dev').then(res => {
1047
+ resolve(res)
1048
+ this.$message.success('删除成功!')
1049
+ this.refresh(true)
1050
+ // afterDelete
1051
+ this.$emit('afterDelete', requestParameters)
1052
+ }).catch(e => {
1053
+ reject(e)
1054
+ this.$message.error('删除失败!')
1055
+ })
1056
+ }
1057
+ })
1058
+ },
1059
+ onCancel () {
1060
+ }
1061
+ })
1062
+ },
1063
+ // 导入业务
1064
+ importData () {
1065
+ this.$refs.importExcel.importExcelHandleOpen()
1066
+ },
1067
+ afterVisibleChange () {
1068
+ this.retrieveSummaryData()
1069
+ },
1070
+ async retrieveSummaryData () {
1071
+ if (this.requestParameters.querySummary) {
1072
+ querySummary(Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev').then(res => {
1073
+ if (res.length > 0) {
1074
+ this.summaryData.forEach(item => {
1075
+ res.forEach(summary => {
1076
+ if (item.title === summary.title) {
1077
+ item.value = summary.value
1078
+ item.success = true
1079
+ item.loading = false
1080
+ }
1081
+ })
1082
+ })
1083
+ }
1084
+ })
1085
+ }
1086
+ if (this.showCustomSummary) {
1087
+ this.customSummaryArray.forEach(item => {
1088
+ runLogic(item.source, Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev').then((res) => {
1089
+ this.summaryData.forEach(summary => {
1090
+ if (item.key === summary.key) {
1091
+ summary.value = res.value
1092
+ summary.success = true
1093
+ summary.loading = false
1094
+ }
1095
+ })
1096
+ }).catch(e => {
1097
+ this.summaryData.forEach(summary => {
1098
+ if (item.key === summary.key) {
1099
+ summary.value = 0
1100
+ summary.success = false
1101
+ summary.loading = false
1102
+ }
1103
+ })
1104
+ })
1105
+ })
1106
+ }
1107
+ },
1108
+ showDrawer () {
1109
+ if (this.summaryUpdate) {
1110
+ this.summaryData.forEach(item => {
1111
+ item.loading = true
1112
+ item.success = false
1113
+ item.value = ' '
1114
+ })
1115
+ this.summaryDrawerVisible = true
1116
+ } else {
1117
+ this.$message.warning('请查询后再来查看')
1118
+ }
1119
+ },
1120
+ onClose () {
1121
+ this.summaryDrawerVisible = false
1122
+ },
1123
+ // 获取表格内所有数据
1124
+ getTableData () {
1125
+ return this.$refs.table.localDataSource
1126
+ },
1127
+ // 获取所有本地数据
1128
+ getLocalData () {
1129
+ return this.localEditModeDataSource
1130
+ },
1131
+ // 获取指定rowKey的value的本地数据
1132
+ getDataByRowKeyValue (rowKeyValue) {
1133
+ return this.getLocalData().find(item => {
1134
+ return item[this.rowKey] === rowKeyValue
1135
+ })
1136
+ },
1137
+ // 修改本地数据
1138
+ modifyLocalData (rowKeyValue, data) {
1139
+ const modifyItem = this.getDataByRowKeyValue(rowKeyValue)
1140
+ if (modifyItem) {
1141
+ Object.assign(modifyItem, data)
1142
+ }
1143
+ },
1144
+ // 追加本地数据
1145
+ appendLocalData (item) {
1146
+ item['序号'] = this.localEditModeDataSource.length
1147
+ this.localEditModeDataSource.push(item)
1148
+ }
1149
+ }
1150
+ }
1151
+ </script>
1152
+ <style lang="less" scoped>
1153
+ :deep(.ant-table-thead > tr > th) {
1154
+ font-weight: 600;
1155
+ }
1156
+
1157
+ :deep(.table-wrapper .ant-pagination) {
1158
+ display: flex;
1159
+ flex-direction: row;
1160
+ align-items: center;
1161
+ padding: 0;
1162
+ }
1163
+
1164
+ :deep(.table-wrapper .ant-pagination .ant-pagination-total-text) {
1165
+ white-space: nowrap;
1166
+ }
1167
+
1168
+ :deep(.ant-table td) {
1169
+ white-space: nowrap;
1170
+ }
1171
+
1172
+ .footer_sum_title {
1173
+ color: @primary-color;
1174
+ font-weight: bold;
1175
+ }
1176
+
1177
+ .footer_sum_item {
1178
+ white-space: nowrap;
1179
+ }
1180
+
1181
+ .ant-btn-hover {
1182
+ border-color: @primary-color;
1183
+ color: @primary-color;
1184
+ }
1185
+
1186
+ .innerTable {
1187
+ :deep(.ant-form-item) {
1188
+ margin: 0;
1189
+ }
1190
+ }
1191
+ </style>