vue2-client 1.9.13 → 1.9.14

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