vue2-client 1.9.39 → 1.9.41

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