vue2-client 1.17.21 → 1.17.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/.claude/settings.local.json +20 -20
  2. package/.cursorrules +19 -19
  3. package/.env.apply +19 -19
  4. package/.env.gaslink +19 -19
  5. package/.env.his +19 -19
  6. package/.env.liuli +20 -20
  7. package/.env.message +19 -19
  8. package/.env.scada +19 -19
  9. package/.eslintrc.js +90 -90
  10. package/.serena/memories/code_style_conventions.md +217 -217
  11. package/.serena/memories/project_overview.md +54 -54
  12. package/.serena/memories/project_structure.md +329 -329
  13. package/.serena/memories/suggested_commands.md +127 -127
  14. package/.serena/memories/task_completion_checklist.md +183 -183
  15. package/.serena/memories/tech_stack.md +94 -94
  16. package/CHANGELOG.md +830 -830
  17. package/CLAUDE.md +97 -97
  18. package/Components.md +60 -60
  19. package/docs/LowCode/lowcode.md +155 -155
  20. package/docs/LowCode/lowcodeForDeveloper.md +230 -230
  21. package/docs/index.md +30 -30
  22. package/index.js +31 -31
  23. package/jest-transform-stub.js +8 -8
  24. package/jest.setup.js +7 -7
  25. package/jsconfig.json +19 -19
  26. package/package.json +112 -112
  27. package/public/his/editor/editor.html +51 -51
  28. package/public/his/editor/mock/bind_data.html +779 -779
  29. package/public/his/editor/mock/data_table.html +40 -40
  30. package/public/his/editor/mock/sign.html +75 -75
  31. package/public/his/editor/vender/JsBarcode.all.js +3669 -3669
  32. package/public/his/editor/vender/date97/My97DatePicker.htm +65 -65
  33. package/public/his/editor/vender/date97/WdatePicker.js +677 -677
  34. package/public/his/editor/vender/date97/calendar.js +4 -4
  35. package/public/his/editor/vender/date97/lang/en.js +13 -13
  36. package/public/his/editor/vender/date97/lang/zh-cn.js +13 -13
  37. package/public/his/editor/vender/date97/lang/zh-tw.js +13 -13
  38. package/public/his/editor/vender/date97/skin/WdatePicker.css +10 -10
  39. package/public/his/editor/vender/date97/skin/default/datepicker.css +328 -328
  40. package/public/his/editor/vender/date97/skin/ext/datepicker.css +308 -308
  41. package/public/his/editor/vender/date97/skin/whyGreen/datepicker.css +255 -255
  42. package/public/his/editor/vender/diff.js +1627 -1627
  43. package/public/his/editor/vender/editor.js +1 -1
  44. package/public/his/editor/vender/fabric.js +31187 -31187
  45. package/public/his/editor/vender/jquery/jquery.base64.js +190 -190
  46. package/public/his/editor/vender/jquery/jquery.js +10872 -10872
  47. package/public/his/editor/vender/jquery/jquery.print.js +255 -255
  48. package/public/his/editor/vender/jquery/zTreeStyle/zTreeStyle.css +96 -96
  49. package/public/his/editor/vender/mui/mui.min.css +4 -4
  50. package/public/his/editor/vender/mui/mui.min.js +5 -5
  51. package/public/his/editor/vender/mui/mui.picker.min.css +6 -6
  52. package/public/his/editor/vender/mui/mui.picker.min.js +6 -6
  53. package/public/his/editor/vender/qrcode.js +7 -7
  54. package/public/his/editor/vender/requirejs/require.js +2145 -2145
  55. package/public/his/editor/vender/signature/jSignature.CompressorSVG.js +518 -518
  56. package/public/his/editor/vender/signature/jSignature.UndoButton.js +164 -164
  57. package/public/his/editor/vender/signature/jSignature.js +1486 -1486
  58. package/public/his/editor/vender/validator.js +5094 -5094
  59. package/public/his/editor/vender/weui/weui.css +5659 -5659
  60. package/public/his/editor/vender/weui/weui.min.css +4 -4
  61. package/public/his/editor/vender/weui/weui.min.js +11 -11
  62. package/src/assets/img/querySlotDemo.svg +15 -15
  63. package/src/assets/svg/badtwo.svg +1 -1
  64. package/src/assets/svg/goodtwo.svg +1 -1
  65. package/src/base-client/components/AI/AskAiBtn.vue +136 -136
  66. package/src/base-client/components/AI/demo.vue +31 -31
  67. package/src/base-client/components/common/AddressSearchCombobox/IcMapIcon.vue +16 -16
  68. package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
  69. package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
  70. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  71. package/src/base-client/components/common/CitySelect/index.js +3 -3
  72. package/src/base-client/components/common/CitySelect/index.md +109 -109
  73. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  74. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  75. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  76. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  77. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  78. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  79. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  80. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  81. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  82. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  83. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  84. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  85. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  86. package/src/base-client/components/common/HIS/demo.vue +61 -61
  87. package/src/base-client/components/common/ImagePreviewModal/ImagePreviewModal.vue +427 -0
  88. package/src/base-client/components/common/ImagePreviewModal/index.js +3 -0
  89. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  90. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
  91. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +413 -413
  92. package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
  93. package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +728 -728
  94. package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
  95. package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +219 -219
  96. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
  97. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
  98. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
  99. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
  100. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
  101. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
  102. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
  103. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  104. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  105. package/src/base-client/components/common/Recording/Recording.vue +243 -243
  106. package/src/base-client/components/common/Recording/index.js +3 -3
  107. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  108. package/src/base-client/components/common/Tree/index.js +2 -2
  109. package/src/base-client/components/common/Upload/Upload.vue +53 -49
  110. package/src/base-client/components/common/Upload/index.js +3 -3
  111. package/src/base-client/components/common/XAddForm/XAddForm.vue +113 -113
  112. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +1288 -1288
  113. package/src/base-client/components/common/XAddNativeForm/demo.vue +54 -54
  114. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  115. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +304 -304
  116. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  117. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  118. package/src/base-client/components/common/XAddReport/index.js +3 -3
  119. package/src/base-client/components/common/XAddReport/index.md +56 -56
  120. package/src/base-client/components/common/XBadge/XBadge.vue +94 -94
  121. package/src/base-client/components/common/XButtons/XButtonDemo.vue +28 -28
  122. package/src/base-client/components/common/XButtons/index.js +3 -3
  123. package/src/base-client/components/common/XButtons/index.md +61 -61
  124. package/src/base-client/components/common/XCalendar/XCalendar.vue +4 -4
  125. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  126. package/src/base-client/components/common/XCheckList/XCheckList.vue +106 -106
  127. package/src/base-client/components/common/XCheckList/XCheckListDemo.vue +41 -41
  128. package/src/base-client/components/common/XDataCard/index.js +3 -3
  129. package/src/base-client/components/common/XDataCard/index.md +1 -1
  130. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  131. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  132. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  133. package/src/base-client/components/common/XDatePicker/demo.vue +153 -153
  134. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  135. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  136. package/src/base-client/components/common/XDetailsView/XDetailsView.vue +238 -238
  137. package/src/base-client/components/common/XDetailsView/index.js +3 -3
  138. package/src/base-client/components/common/XForm/XStatusButton.vue +54 -54
  139. package/src/base-client/components/common/XForm/index.md +178 -178
  140. package/src/base-client/components/common/XForm/itemComponent/XClickChangeBtn/index.vue +49 -49
  141. package/src/base-client/components/common/XFormGroup/index.js +3 -3
  142. package/src/base-client/components/common/XFormGroup/index.md +38 -38
  143. package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
  144. package/src/base-client/components/common/XFormTable/index.md +92 -92
  145. package/src/base-client/components/common/XLabelSelect/XLabelSelect.vue +110 -110
  146. package/src/base-client/components/common/XLabelSelect/XLabelSelectDemo.vue +35 -35
  147. package/src/base-client/components/common/XLicensePlate/XLicensePlate.vue +193 -193
  148. package/src/base-client/components/common/XLicensePlate/XLicensePlateDemo.vue +48 -48
  149. package/src/base-client/components/common/XPrint/OpenInvoice.vue +21 -21
  150. package/src/base-client/components/common/XPrint/PrintHtml.js +98 -98
  151. package/src/base-client/components/common/XPrint/css/hiPrintCss.js +359 -359
  152. package/src/base-client/components/common/XPrint/css/lodopCss.js +26 -26
  153. package/src/base-client/components/common/XPrint/css/print-lock.css +351 -351
  154. package/src/base-client/components/common/XPrint/index.vue +97 -97
  155. package/src/base-client/components/common/XReport/XReportDesign.vue +463 -463
  156. package/src/base-client/components/common/XReport/XReportJsonRender.vue +381 -381
  157. package/src/base-client/components/common/XReport/index.js +3 -3
  158. package/src/base-client/components/common/XReport/print.js +186 -186
  159. package/src/base-client/components/common/XReportDrawer/index.js +3 -3
  160. package/src/base-client/components/common/XReportGrid/index.js +3 -3
  161. package/src/base-client/components/common/XReportGrid/index.md +44 -44
  162. package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
  163. package/src/base-client/components/common/XReportSlot/index.js +3 -3
  164. package/src/base-client/components/common/XReportSlot/index.md +48 -48
  165. package/src/base-client/components/common/XSimpleDescriptions/XSimpleDescriptions.vue +166 -166
  166. package/src/base-client/components/common/XSimpleDescriptions/index.js +3 -3
  167. package/src/base-client/components/common/XSimpleDescriptions/index.md +7 -7
  168. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  169. package/src/base-client/components/common/XStepView/index.js +3 -3
  170. package/src/base-client/components/common/XStepView/index.md +31 -31
  171. package/src/base-client/components/common/XTab/XTab.vue +612 -614
  172. package/src/base-client/components/common/XTab/XTabDemo.vue +22 -22
  173. package/src/base-client/components/common/XTab/index.js +3 -3
  174. package/src/base-client/components/common/XTable/CustomFuncCel.vue +51 -51
  175. package/src/base-client/components/common/XTable/TableCellRenderer.vue +161 -161
  176. package/src/base-client/components/common/XTable/index.md +255 -255
  177. package/src/base-client/components/common/XTagGroup/index.vue +52 -52
  178. package/src/base-client/components/common/XTree/XTree.vue +424 -424
  179. package/src/base-client/components/common/XTree/index.js +3 -3
  180. package/src/base-client/components/common/XTree/index.md +36 -36
  181. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +113 -113
  182. package/src/base-client/components/common/XTreeOne/XTreeOnePro.vue +128 -128
  183. package/src/base-client/components/common/richTextModal/index.vue +56 -56
  184. package/src/base-client/components/common/richTextModal/richDemo.vue +48 -48
  185. package/src/base-client/components/his/XCharge/XChargeDemo.vue +145 -145
  186. package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +109 -10
  187. package/src/base-client/components/his/XHisEditor/index.js +3 -3
  188. package/src/base-client/components/index.js +51 -51
  189. package/src/base-client/components/layout/XTreeView/XTreeView.vue +130 -130
  190. package/src/base-client/components/layout/XTreeView/index.js +3 -3
  191. package/src/base-client/components/layout/XTreeView/index.md +46 -46
  192. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  193. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  194. package/src/base-client/plugins/Config.js +19 -19
  195. package/src/base-client/plugins/GetLoginInfoService.js +183 -183
  196. package/src/base-client/plugins/Recording.js +258 -258
  197. package/src/base-client/plugins/index.js +23 -23
  198. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  199. package/src/components/Charts/Bar.vue +62 -62
  200. package/src/components/Charts/ChartCard.vue +134 -134
  201. package/src/components/Charts/Liquid.vue +67 -67
  202. package/src/components/Charts/MiniArea.vue +39 -39
  203. package/src/components/Charts/MiniBar.vue +39 -39
  204. package/src/components/Charts/MiniProgress.vue +75 -75
  205. package/src/components/Charts/MiniSmoothArea.vue +40 -40
  206. package/src/components/Charts/Radar.vue +68 -68
  207. package/src/components/Charts/RankList.vue +77 -77
  208. package/src/components/Charts/TagCloud.vue +113 -113
  209. package/src/components/Charts/TransferBar.vue +64 -64
  210. package/src/components/Charts/Trend.vue +82 -82
  211. package/src/components/Charts/chart.less +12 -12
  212. package/src/components/Charts/smooth.area.less +13 -13
  213. package/src/components/CodeMirror/inedx.vue +118 -118
  214. package/src/components/CodeMirror/setting.js +40 -40
  215. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  216. package/src/components/NumberInfo/index.js +3 -3
  217. package/src/components/NumberInfo/index.less +54 -54
  218. package/src/components/NumberInfo/index.md +43 -43
  219. package/src/components/card/ChartCard.vue +79 -79
  220. package/src/components/chart/Bar.vue +60 -60
  221. package/src/components/chart/MiniArea.vue +67 -67
  222. package/src/components/chart/MiniBar.vue +59 -59
  223. package/src/components/chart/MiniProgress.vue +57 -57
  224. package/src/components/chart/Radar.vue +80 -80
  225. package/src/components/chart/RankingList.vue +60 -60
  226. package/src/components/chart/Trend.vue +79 -79
  227. package/src/components/chart/index.less +9 -9
  228. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  229. package/src/components/checkbox/ImgCheckbox.vue +117 -117
  230. package/src/components/checkbox/ImgCheckboxGroup.vue +76 -76
  231. package/src/components/checkbox/index.js +9 -9
  232. package/src/components/exception/ExceptionPage.vue +70 -70
  233. package/src/components/g2Charts/constants.js +202 -202
  234. package/src/components/g2Charts/demo.vue +808 -808
  235. package/src/components/g2Charts/designer.vue +228 -228
  236. package/src/components/g2Charts/designerBaseConfig.vue +61 -61
  237. package/src/components/g2Charts/designerDataConfig.vue +259 -259
  238. package/src/components/g2Charts/designerStyleConfig.vue +16 -16
  239. package/src/components/g2Charts/index.vue +397 -397
  240. package/src/components/index.js +36 -36
  241. package/src/components/input/IInput.vue +66 -66
  242. package/src/components/menu/SideMenu.vue +75 -75
  243. package/src/components/menu/menu.js +273 -273
  244. package/src/components/setting/Setting.vue +234 -234
  245. package/src/components/tool/AStepItem.vue +60 -60
  246. package/src/config/CreateQueryConfig.js +325 -325
  247. package/src/config/default/antd.config.js +89 -89
  248. package/src/config/default/setting.config.js +55 -55
  249. package/src/font-style/font.css +60 -60
  250. package/src/layouts/CommonLayout.vue +56 -56
  251. package/src/layouts/PageLayout.vue +151 -151
  252. package/src/layouts/SinglePageView.vue +136 -136
  253. package/src/layouts/header/AdminHeader.vue +132 -132
  254. package/src/layouts/header/HeaderNotice.vue +177 -177
  255. package/src/layouts/header/InstitutionDetail.vue +181 -181
  256. package/src/layouts/tabs/TabsHead.vue +189 -189
  257. package/src/lib.js +1 -1
  258. package/src/mock/extend/index.js +84 -84
  259. package/src/mock/goods/index.js +108 -108
  260. package/src/pages/DefaultExample/index.vue +77 -77
  261. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  262. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  263. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  264. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  265. package/src/pages/DynamicStatistics/FavoriteList.vue +50 -50
  266. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  267. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  268. package/src/pages/DynamicStatistics/index.vue +282 -282
  269. package/src/pages/Example/childIndex.vue +15 -15
  270. package/src/pages/Example/index.vue +30 -30
  271. package/src/pages/NewDynamicStatistics/ChartSelector.vue +331 -331
  272. package/src/pages/NewDynamicStatistics/DataTabs.vue +122 -122
  273. package/src/pages/NewDynamicStatistics/DynamicTable.vue +128 -128
  274. package/src/pages/NewDynamicStatistics/EvaluationArea.vue +69 -69
  275. package/src/pages/NewDynamicStatistics/FavoriteList.vue +50 -50
  276. package/src/pages/NewDynamicStatistics/QuestionHistoryAndFavorites.vue +289 -289
  277. package/src/pages/NewDynamicStatistics/SearchBar.vue +193 -193
  278. package/src/pages/NewDynamicStatistics/index.vue +258 -258
  279. package/src/pages/Recording/index.vue +77 -77
  280. package/src/pages/ServiceReview/index.vue +284 -284
  281. package/src/pages/SubExample/index.vue +26 -26
  282. package/src/pages/WorkflowDetail/WorkflowPageDetail/TrimTextTail.vue +23 -23
  283. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +1811 -1811
  284. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +1014 -1014
  285. package/src/pages/XReportView/index.vue +64 -64
  286. package/src/pages/XTreeOneProExample/index.vue +67 -67
  287. package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
  288. package/src/pages/login/Login.vue +379 -379
  289. package/src/pages/login/LoginV3.vue +389 -389
  290. package/src/pages/lowCode/lowCodeEditor.vue +1219 -1219
  291. package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
  292. package/src/pages/report/ReportTable.js +124 -124
  293. package/src/pages/resourceManage/orgListManage.vue +98 -98
  294. package/src/pages/system/dictionary/index.vue +44 -44
  295. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  296. package/src/pages/system/monitor/operLog/index.vue +37 -37
  297. package/src/pages/system/settings/modifyPassword.vue +117 -117
  298. package/src/pages/system/ticket/index.vue +480 -480
  299. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  300. package/src/pages/userInfoDetailManage/ChangeMeterRecordQuery/index.vue +64 -64
  301. package/src/pages/userInfoDetailManage/InfoChangeRecordQuery/index.vue +64 -64
  302. package/src/pages/userInfoDetailManage/InstructRecordQuery/index.vue +64 -64
  303. package/src/pages/userInfoDetailManage/MeterParamRecordQuery/index.vue +64 -64
  304. package/src/pages/userInfoDetailManage/TransferRecordQuery/index.vue +66 -66
  305. package/src/pages/userInfoDetailManage/WatchCollectionRecordQuery/index.vue +64 -64
  306. package/src/plugins/EventLogPlugin.js +33 -33
  307. package/src/plugins/FindParentsData.js +17 -17
  308. package/src/router/async/router.map.js +133 -133
  309. package/src/services/DataModel.js +30 -30
  310. package/src/services/LodopFuncs.js +137 -137
  311. package/src/services/api/TicketDetailsViewApi.js +46 -46
  312. package/src/services/api/cas.js +79 -79
  313. package/src/services/api/entity.js +18 -18
  314. package/src/services/api/index.js +17 -17
  315. package/src/store/modules/account.js +121 -121
  316. package/src/store/modules/index.js +5 -5
  317. package/src/store/modules/lowCode.js +33 -33
  318. package/src/store/modules/setting.js +119 -119
  319. package/src/theme/default/style.less +58 -58
  320. package/src/utils/authority-utils.js +85 -85
  321. package/src/utils/errorCode.js +6 -6
  322. package/src/utils/formatter.js +74 -74
  323. package/src/utils/htmlToPDF.js +108 -108
  324. package/src/utils/htmlToPDFApi.js +5 -5
  325. package/src/utils/login.js +188 -188
  326. package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
  327. package/src/utils/lowcode/lowcodeLog.js +29 -29
  328. package/src/utils/lowcode/lowcodeUtils.js +373 -373
  329. package/src/utils/lowcode/registerComponentForEditor.js +1 -1
  330. package/src/utils/lowcode/registerComponentForRender.js +11 -11
  331. package/src/utils/map-utils.js +47 -47
  332. package/src/utils/reg.js +95 -95
  333. package/src/utils/runEvalFunction.js +14 -14
  334. package/src/utils/theme-color-replacer-extend.js +92 -92
  335. package/src/utils/util.js +329 -329
  336. package/src/utils/waterMark.js +31 -31
  337. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,614 +1,612 @@
1
- <template>
2
- <a-card v-if="config" :bordered="false" :body-style="bodyStyle">
3
- <a-tabs
4
- :tabBarGutter="tabBarGutter"
5
- :activeKey="activeKey"
6
- @change="(activeKey) => tabPaneChange(activeKey, false)"
7
- :hideAdd="true"
8
- :tabBarStyle="{ display: showTabBar ? 'block' : 'none' }"
9
- >
10
- <template #tabBarExtraContent v-if="$slots.tabBarExtraContent || tabBarExtraContent">
11
- <slot name="tabBarExtraContent"></slot>
12
- </template>
13
- <slot name="extraBeforeTabs"></slot>
14
- <a-tab-pane
15
- v-for="(tab, index) in config.data"
16
- :key="index"
17
- :tab="tab.title"
18
- :forceRender="isTabLoaded(index)"
19
- >
20
- <component
21
- v-if="isTabLoaded(index)"
22
- :is="tab.slotType"
23
- :key="'xTabPaneComp' + index"
24
- :ref="`tab_com_${tab.slotType}_${index}`"
25
- :serviceName="tab.serviceName"
26
- :serverName="tab.serviceName"
27
- :queryParamsName="tab.slotConfig"
28
- v-on="getEventHandlers(tab,index)"
29
- @hook:mounted="(h)=>onComponentMounted(h,tab,index)"
30
- :config-name="tab.slotConfig"
31
- :env="env"
32
- v-bind="compProp"
33
- :extra-data="extraData"
34
- />
35
- </a-tab-pane>
36
- </a-tabs>
37
- </a-card>
38
- </template>
39
-
40
- <script>
41
- import { getConfigByName, getConfigByNameAsync, runLogic } from '@vue2-client/services/api/common'
42
- import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
43
- import { getRealKeyData } from '@vue2-client/utils/util'
44
- import { getMicroData, getWindow, isMicroAppEnv, microDispatch } from '@vue2-client/utils/microAppUtils'
45
- import { mapState } from 'vuex'
46
-
47
- export default {
48
- name: 'XTab',
49
- components: {
50
- XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable'),
51
- XAddNativeForm: () => import('@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'),
52
- XReportGrid: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue')
53
- },
54
- inject: {
55
- isInAModal: { default: false },
56
- getSelectedId: { default: false },
57
- getSelectedData: { default: false },
58
- getOutEnv: { default: false },
59
- setGlobalData: { default: false },
60
- getGlobalData: { default: false },
61
- generalFunction: { default: false },
62
- },
63
- provide () {
64
- return {
65
- currUser: this.currUser,
66
- getSelectedId: this.getSelectedId,
67
- // 暴露页签加载相关方法,供子组件调用
68
- ensureTabLoaded: this.ensureTabLoaded,
69
- getTabComponent: this.getTabComponent,
70
- isTabLoaded: this.isTabLoaded
71
- }
72
- },
73
- data () {
74
- return {
75
- activeKey: 0,
76
- // 配置
77
- config: undefined,
78
- tabBarExtraContent: undefined,
79
- attr: {},
80
- showTabBar: true, // 默认显示页签
81
- loadedTabs: [] // 记录已加载的页签索引
82
- }
83
- },
84
- computed: {
85
- ...mapState('account', { currUser: 'user' })
86
- },
87
- mounted () {
88
- this.activeKey = this.defaultActiveKey
89
- // 标记默认激活的页签为已加载
90
- this.markTabAsLoaded(this.defaultActiveKey)
91
- this.tabPaneChange('initTabLoading', true)
92
- },
93
- methods: {
94
- // 自定义函数中调用的方法 这个不能删
95
- getWindow,
96
- runLogic,
97
- isMicroAppEnv,
98
- microDispatch,
99
- getMicroData,
100
- getRealKeyData,
101
- getConfigByName,
102
- getConfigByNameAsync,
103
- async tabPaneChange (newKey, initStatus = false) {
104
- let result = {}
105
- if (this.activeKey === newKey) {
106
- return
107
- }
108
-
109
- const oldKey = this.activeKey
110
-
111
- // 标记新页签为已加载
112
- if (this.config && this.config.data && this.config.data[newKey] !== undefined) {
113
- this.markTabAsLoaded(newKey)
114
- }
115
-
116
- if (this.config && this.config.changeFunc) {
117
- let oldRef
118
- let oldTabName
119
- let newRef
120
- let newTabName
121
-
122
- if (!this.config.data[oldKey]) {
123
- oldTabName = `tab_com_${oldKey}`
124
- oldRef = this.$refs[oldTabName]
125
- } else {
126
- const oldTabSlotType = this.config.data[oldKey].slotType
127
- oldTabName = `tab_com_${oldTabSlotType}_${oldKey}`
128
- oldRef = this.$refs[oldTabName]
129
- }
130
-
131
- if (!this.config.data[newKey]) {
132
- newTabName = `tab_com_${newKey}`
133
- newRef = this.$refs[newTabName]
134
- } else {
135
- const newTabSlotType = this.config.data[newKey].slotType
136
- newTabName = `tab_com_${newTabSlotType}_${newKey}`
137
- newRef = this.$refs[newTabName]
138
- }
139
-
140
- const args = [
141
- oldKey,
142
- newKey,
143
- this.config.data[oldKey],
144
- this.config.data[newKey],
145
- oldRef ? oldRef[0] : undefined,
146
- ]
147
- args.push(newTabName)
148
-
149
- // 关键修改:确保新组件实例存在
150
- if (!newRef || !newRef[0]) {
151
- console.log('等待新页签组件初始化...')
152
- // 等待组件挂载完成
153
- await this.waitForComponentReady(newKey)
154
- newRef = this.$refs[newTabName]
155
- }
156
-
157
- if (newRef && newRef[0]) {
158
- args.push(newRef[0])
159
- } else {
160
- args.push(null)
161
- console.warn('新页签组件实例获取失败')
162
- }
163
-
164
- args.push(this.extraData)
165
-
166
- // 使用 $nextTick 确保 DOM 更新完成
167
- await this.$nextTick()
168
-
169
- // 确保组件完全就绪后再执行 changeFunc
170
- if (newRef && newRef[0]) {
171
- // 等待组件完全就绪(包括内部异步初始化)
172
- await this.waitForComponentFullyReady(newRef[0], newKey)
173
- } else {
174
- // 如果没有组件实例,等待一个 tick 确保 DOM 更新
175
- await this.$nextTick()
176
- }
177
-
178
- result = executeStrFunctionByContext(this, this.config.changeFunc, args)
179
-
180
- if (result && result.noChange) {
181
- console.info('不切换页签作为按钮使用')
182
- // 如果返回 noChange,恢复原来的 activeKey
183
- if (this.activeKey === newKey) {
184
- this.activeKey = oldKey
185
- }
186
- } else {
187
- // 确保 activeKey 已更新(如果还没更新的话)
188
- if (this.activeKey !== newKey) {
189
- this.activeKey = newKey
190
- }
191
- // 确保回调在组件完全就绪后执行
192
- if (result && result.callback && typeof result.callback === 'function') {
193
- await this.$nextTick()
194
- result.callback()
195
- }
196
- }
197
- } else {
198
- this.activeKey = newKey
199
- }
200
-
201
- if (initStatus) {
202
- this.activeKey = this.defaultActiveKey
203
- }
204
- },
205
-
206
- // 新增:等待组件就绪的方法
207
- waitForComponentReady (index) {
208
- return new Promise((resolve) => {
209
- const checkComponent = () => {
210
- const tab = this.config.data[index]
211
- const refName = `tab_com_${tab.slotType}_${index}`
212
- const ref = this.$refs[refName]
213
-
214
- if (ref && ref[0]) {
215
- // 额外检查组件内部是否已初始化(如果有相关状态的话)
216
- if (ref[0].isReady !== undefined) {
217
- if (ref[0].isReady) {
218
- resolve(ref[0])
219
- } else {
220
- setTimeout(checkComponent, 50)
221
- }
222
- } else {
223
- resolve(ref[0])
224
- }
225
- } else {
226
- setTimeout(checkComponent, 50)
227
- }
228
- }
229
-
230
- checkComponent()
231
- })
232
- },
233
- // 等待组件完全就绪(包括内部异步初始化)
234
- waitForComponentFullyReady (component, index) {
235
- return new Promise((resolve) => {
236
- if (!component) {
237
- resolve()
238
- return
239
- }
240
-
241
- let attempts = 0
242
- const maxAttempts = 60 // 最多等待3秒
243
- const checkInterval = 50
244
-
245
- const checkReady = () => {
246
- attempts++
247
-
248
- // 1. 检查组件是否有 loading 状态,确保不在加载中
249
- if (component.loading === true) {
250
- if (attempts < maxAttempts) {
251
- setTimeout(checkReady, checkInterval)
252
- return
253
- }
254
- }
255
-
256
- // 2. 检查组件是否有 loaded 状态(如 XAddNativeForm)
257
- if (component.loaded === false) {
258
- if (attempts < maxAttempts) {
259
- setTimeout(checkReady, checkInterval)
260
- return
261
- }
262
- }
263
-
264
- // 3. 检查组件是否有 realQueryConfig(如 XFormTable)
265
- const tab = this.config.data[index]
266
- const isFormTableType = tab?.slotType === 'x-form-table' ||
267
- tab?.slotType === 'XFormTable' ||
268
- tab?.slotType?.toLowerCase() === 'xformtable'
269
- if (isFormTableType && component.realQueryConfig === undefined && !component.loadError) {
270
- if (attempts < maxAttempts) {
271
- setTimeout(checkReady, checkInterval)
272
- return
273
- }
274
- }
275
-
276
- // 4. 检查关键方法是否存在(如 setForm、setFormWithKey)
277
- const hasSetForm = typeof component.setForm === 'function'
278
- const hasSetFormWithKey = typeof component.setFormWithKey === 'function'
279
- const hasSetFormWithNoKey = typeof component.setFormWithNoKey === 'function'
280
-
281
- // 5. 如果组件有这些方法,确保表单对象存在
282
- if (hasSetForm || hasSetFormWithKey || hasSetFormWithNoKey) {
283
- // 检查组件是否有 form 对象
284
- if (component.form && Object.keys(component.form).length > 0) {
285
- // 表单已初始化,等待 DOM 渲染完成
286
- this.$nextTick(() => {
287
- // 额外等待一个 tick,确保所有子组件也渲染完成
288
- this.$nextTick(() => {
289
- resolve()
290
- })
291
- })
292
- return
293
- } else if (component.loaded !== false) {
294
- // 如果没有 form 对象但 loaded 不为 false,可能还在初始化
295
- if (attempts < maxAttempts) {
296
- setTimeout(checkReady, checkInterval)
297
- return
298
- }
299
- }
300
- }
301
-
302
- // 6. 如果以上都通过,或者超时,等待 DOM 渲染完成
303
- if (attempts >= 3 || attempts >= maxAttempts) {
304
- // 至少等待几次检查,确保有时间初始化
305
- this.$nextTick(() => {
306
- this.$nextTick(() => {
307
- resolve()
308
- })
309
- })
310
- return
311
- }
312
-
313
- // 继续等待
314
- setTimeout(checkReady, checkInterval)
315
- }
316
-
317
- // 首次检查前等待一个 tick
318
- this.$nextTick(() => {
319
- checkReady()
320
- })
321
- })
322
- },
323
- initConfig () {
324
- if (this.configName) {
325
- this.getConfig()
326
- } else if (this.localConfig) {
327
- this.config = this.localConfig
328
- // 设置是否显示页签
329
- this.showTabBar = this.localConfig.showTabBar !== false
330
- }
331
- // 重置已加载页签集合,确保配置变更后重新加载
332
- this.loadedTabs = []
333
- // 标记默认激活的页签为已加载
334
- if (this.config && this.config.data) {
335
- this.markTabAsLoaded(this.defaultActiveKey)
336
- }
337
- },
338
- getConfig () {
339
- getConfigByName(this.configName, this.serverName, res => {
340
- this.config = res
341
- // 设置是否显示页签
342
- this.showTabBar = res.showTabBar !== false
343
- // 标记默认激活的页签为已加载
344
- if (this.config && this.config.data) {
345
- this.markTabAsLoaded(this.defaultActiveKey)
346
- }
347
- }, this.env === 'dev')
348
- },
349
- getEventHandlers (tab, index) {
350
- const handlers = {}
351
- if (!tab?.events || tab?.events?.length === 0) {
352
- return handlers
353
- }
354
- tab.events.forEach(event => {
355
- handlers[event.type] = (...args) => {
356
- executeStrFunctionByContext(this.$refs[`tab_com_${tab.slotType}_${index}`][0], event.customFunction, args)
357
- }
358
- })
359
- return handlers
360
- },
361
- onComponentMounted (h, tab, index) {
362
- if (tab.slotType === 'x-add-native-form') {
363
- // 建议表单需要主动调用初始化方法
364
- getConfigByName(tab.slotConfig, tab.serviceName, async (res) => {
365
- // 如果配置了 表单初始化logic
366
- // 调用 logic 获取参数
367
- let param = {}
368
- let selectedId
369
- if (res.paramLogicName) {
370
- if (!!this.getSelectedId) {
371
- selectedId = this.getSelectedId()
372
- if (typeof selectedId !== 'object') {
373
- selectedId = { selectedId: selectedId }
374
- }
375
- }
376
- param = Object.assign(param, await runLogic(res.paramLogicName, selectedId, tab.serviceName))
377
- }
378
- this.$refs[`tab_com_${tab.slotType}_${index}`][0].init({
379
- formItems: res.formJson,
380
- showSubmitBtn: !this.isInAModal,
381
- businessType: '新增',
382
- layout: res.xAddFormLayout,
383
- ...res,
384
- fixedAddForm: param,
385
- modifyModelData: {
386
- files: param.files,
387
- images: param.images
388
- }
389
- })
390
- }, this.env === 'dev')
391
- }
392
- },
393
- // 判断页签是否已加载
394
- isTabLoaded (index) {
395
- const numIndex = Number(index)
396
- return this.loadedTabs.includes(numIndex) || Number(this.activeKey) === numIndex
397
- },
398
- // 标记页签为已加载
399
- markTabAsLoaded (index) {
400
- const numIndex = Number(index)
401
- // 确保是有效的数字索引,且未添加过
402
- if (!isNaN(numIndex) && numIndex >= 0 && !this.loadedTabs.includes(numIndex)) {
403
- this.loadedTabs.push(numIndex)
404
- }
405
- },
406
- // 确保页签已加载,如果未加载则先加载,返回 Promise 等待组件渲染完成
407
- ensureTabLoaded (index, options = {}) {
408
- return new Promise((resolve, reject) => {
409
- const numIndex = Number(index)
410
- const innerRefs = Array.isArray(options.innerRefs) ? options.innerRefs : []
411
- const allowSwitch = options.allowSwitch !== false
412
- // 验证索引有效性
413
- if (isNaN(numIndex) || numIndex < 0) {
414
- reject(new Error(`无效的页签索引: ${index}`))
415
- return
416
- }
417
- if (!this.config || !this.config.data || !this.config.data[numIndex]) {
418
- reject(new Error(`页签索引 ${index} 不存在`))
419
- return
420
- }
421
- // 如果已经加载,直接返回组件实例
422
- if (this.isTabLoaded(numIndex)) {
423
- const component = this.getTabComponent(numIndex)
424
- if (component) {
425
- if (innerRefs.length === 0) {
426
- resolve(component)
427
- } else {
428
- this.waitForInnerRefs(component, innerRefs, resolve, reject)
429
- }
430
- } else {
431
- // 已标记但组件可能还在渲染中,等待一下
432
- this.$nextTick(() => {
433
- const comp = this.getTabComponent(numIndex)
434
- if (comp) {
435
- if (innerRefs.length === 0) {
436
- resolve(comp)
437
- } else {
438
- this.waitForInnerRefs(comp, innerRefs, resolve, reject)
439
- }
440
- } else {
441
- // 等待组件mounted
442
- this.waitForComponent(numIndex, (c) => {
443
- if (innerRefs.length === 0) {
444
- resolve(c)
445
- } else {
446
- this.waitForInnerRefs(c, innerRefs, resolve, reject)
447
- }
448
- }, reject)
449
- }
450
- })
451
- }
452
- return
453
- }
454
- // 标记为已加载,触发渲染
455
- this.markTabAsLoaded(numIndex)
456
- // 优先尝试在不切换页签的情况下获取组件
457
- this.$nextTick(() => {
458
- const comp = this.getTabComponent(numIndex)
459
- if (comp) {
460
- if (innerRefs.length === 0) resolve(comp)
461
- else this.waitForInnerRefs(comp, innerRefs, resolve, reject)
462
- return
463
- }
464
- // 若仍未渲染,且允许临时切换,则进行一次激活-恢复回退
465
- if (!allowSwitch) {
466
- // 不允许切换则进入常规等待(可能更慢)
467
- this.waitForComponent(numIndex, (c) => {
468
- if (innerRefs.length === 0) resolve(c)
469
- else this.waitForInnerRefs(c, innerRefs, resolve, reject)
470
- }, reject)
471
- return
472
- }
473
- const prevActive = this.activeKey
474
- this.activeKey = numIndex
475
- this.$nextTick(() => {
476
- this.waitForComponent(numIndex, (c) => {
477
- // 组件到位后再恢复原激活页签
478
- if (prevActive !== numIndex) {
479
- this.$nextTick(() => { this.activeKey = prevActive })
480
- }
481
- if (innerRefs.length === 0) resolve(c)
482
- else this.waitForInnerRefs(c, innerRefs, resolve, reject)
483
- }, reject)
484
- })
485
- })
486
- })
487
- },
488
- // 等待组件渲染完成
489
- waitForComponent (index, resolve, reject) {
490
- const maxAttempts = 50 // 最多尝试50次
491
- let attempts = 0
492
- const checkInterval = 50 // 每50ms检查一次
493
- const tab = this.config.data[index]
494
- const refName = `tab_com_${tab.slotType}_${index}`
495
- const checkComponent = () => {
496
- attempts++
497
- const component = this.$refs[refName]
498
- if (component && component[0]) {
499
- resolve(component[0])
500
- return
501
- }
502
- if (attempts >= maxAttempts) {
503
- reject(new Error(`等待页签 ${index} 组件加载超时`))
504
- return
505
- }
506
- setTimeout(checkComponent, checkInterval)
507
- }
508
- // 首次检查
509
- this.$nextTick(() => {
510
- checkComponent()
511
- })
512
- },
513
- // 等待内部 $refs 就绪
514
- waitForInnerRefs (component, innerRefs, resolve, reject) {
515
- const maxAttempts = 50
516
- let attempts = 0
517
- const checkInterval = 50
518
- const allReady = () => innerRefs.every(name => component.$refs && component.$refs[name])
519
- const check = () => {
520
- attempts++
521
- if (allReady()) {
522
- resolve(component)
523
- return
524
- }
525
- if (attempts >= maxAttempts) {
526
- reject(new Error(`等待内部 refs [${innerRefs.join(', ')}] 就绪超时`))
527
- return
528
- }
529
- setTimeout(check, checkInterval)
530
- }
531
- this.$nextTick(() => check())
532
- },
533
- // 获取页签的组件实例
534
- getTabComponent (index) {
535
- const numIndex = Number(index)
536
- if (isNaN(numIndex) || numIndex < 0 || !this.config || !this.config.data || !this.config.data[numIndex]) {
537
- return null
538
- }
539
- const tab = this.config.data[numIndex]
540
- const refName = `tab_com_${tab.slotType}_${numIndex}`
541
- const ref = this.$refs[refName]
542
- return ref && ref[0] ? ref[0] : null
543
- },
544
-
545
- },
546
- props: {
547
- // 配置名
548
- configName: {
549
- type: String,
550
- default: undefined
551
- },
552
- serverName: {
553
- type: String,
554
- default: undefined
555
- },
556
- env: {
557
- type: String,
558
- default: 'prod'
559
- },
560
- // 本地配置,调试用
561
- localConfig: {
562
- type: Object,
563
- default: undefined
564
- },
565
- tabBarGutter: {
566
- type: Number,
567
- default: 10
568
- },
569
- bodyStyle: {
570
- type: Object,
571
- default: () => {
572
- return {}
573
- }
574
- },
575
- defaultActiveKey: {
576
- type: [String, Number],
577
- default: 0
578
- },
579
- // 新增compProp参数,用于穿透到动态组件
580
- compProp: {
581
- type: Object,
582
- default: () => {
583
- return {}
584
- }
585
- },
586
- // 额外数据
587
- extraData: {
588
- type: Object,
589
- default: () => {
590
- return {}
591
- }
592
- }
593
- },
594
- watch: {
595
- configName: {
596
- deep: true,
597
- immediate: true,
598
- handler (val) {
599
- this.initConfig()
600
- }
601
- },
602
- // 如果本地配置更改了,重新初始化
603
- localConfig: {
604
- deep: true,
605
- immediate: true,
606
- handler (val) {
607
- this.initConfig()
608
- }
609
- },
610
- },
611
- }
612
- </script>
613
- <style scoped>
614
- </style>
1
+ <template>
2
+ <a-card v-if="config" :bordered="false" :body-style="bodyStyle">
3
+ <a-tabs
4
+ :tabBarGutter="tabBarGutter"
5
+ :activeKey="activeKey"
6
+ @change="(activeKey) => tabPaneChange(activeKey, false)"
7
+ :hideAdd="true"
8
+ :tabBarStyle="{ display: showTabBar ? 'block' : 'none' }"
9
+ >
10
+ <template #tabBarExtraContent v-if="$slots.tabBarExtraContent || tabBarExtraContent">
11
+ <slot name="tabBarExtraContent"></slot>
12
+ </template>
13
+ <slot name="extraBeforeTabs"></slot>
14
+ <a-tab-pane
15
+ v-for="(tab, index) in config.data"
16
+ :key="index"
17
+ :tab="tab.title"
18
+ :forceRender="isTabLoaded(index)"
19
+ >
20
+ <component
21
+ v-if="isTabLoaded(index)"
22
+ :is="tab.slotType"
23
+ :key="'xTabPaneComp' + index"
24
+ :ref="`tab_com_${tab.slotType}_${index}`"
25
+ :serviceName="tab.serviceName"
26
+ :serverName="tab.serviceName"
27
+ :queryParamsName="tab.slotConfig"
28
+ v-on="getEventHandlers(tab,index)"
29
+ @hook:mounted="(h)=>onComponentMounted(h,tab,index)"
30
+ :config-name="tab.slotConfig"
31
+ :env="env"
32
+ v-bind="compProp"
33
+ :extra-data="extraData"
34
+ />
35
+ </a-tab-pane>
36
+ </a-tabs>
37
+ </a-card>
38
+ </template>
39
+
40
+ <script>
41
+ import { getConfigByName, getConfigByNameAsync, runLogic } from '@vue2-client/services/api/common'
42
+ import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
43
+ import { getRealKeyData } from '@vue2-client/utils/util'
44
+ import { getMicroData, getWindow, isMicroAppEnv, microDispatch } from '@vue2-client/utils/microAppUtils'
45
+ import { mapState } from 'vuex'
46
+
47
+ export default {
48
+ name: 'XTab',
49
+ components: {
50
+ XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable'),
51
+ XAddNativeForm: () => import('@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'),
52
+ XReportGrid: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue')
53
+ },
54
+ inject: {
55
+ isInAModal: { default: false },
56
+ getSelectedId: { default: false },
57
+ getSelectedData: { default: false },
58
+ getOutEnv: { default: false },
59
+ setGlobalData: { default: false },
60
+ getGlobalData: { default: false },
61
+ generalFunction: { default: false },
62
+ },
63
+ provide () {
64
+ return {
65
+ currUser: this.currUser,
66
+ getSelectedId: this.getSelectedId,
67
+ // 暴露页签加载相关方法,供子组件调用
68
+ ensureTabLoaded: this.ensureTabLoaded,
69
+ getTabComponent: this.getTabComponent,
70
+ isTabLoaded: this.isTabLoaded
71
+ }
72
+ },
73
+ data () {
74
+ return {
75
+ activeKey: 0,
76
+ // 配置
77
+ config: undefined,
78
+ tabBarExtraContent: undefined,
79
+ attr: {},
80
+ showTabBar: true, // 默认显示页签
81
+ loadedTabs: [] // 记录已加载的页签索引
82
+ }
83
+ },
84
+ computed: {
85
+ ...mapState('account', { currUser: 'user' })
86
+ },
87
+ mounted () {
88
+ this.activeKey = this.defaultActiveKey
89
+ // 标记默认激活的页签为已加载
90
+ this.markTabAsLoaded(this.defaultActiveKey)
91
+ this.tabPaneChange('initTabLoading', true)
92
+ },
93
+ methods: {
94
+ // 自定义函数中调用的方法 这个不能删
95
+ getWindow,
96
+ runLogic,
97
+ isMicroAppEnv,
98
+ microDispatch,
99
+ getMicroData,
100
+ getRealKeyData,
101
+ getConfigByName,
102
+ getConfigByNameAsync,
103
+ async tabPaneChange (newKey, initStatus = false) {
104
+ let result = {}
105
+ if (this.activeKey === newKey) {
106
+ return
107
+ }
108
+
109
+ const oldKey = this.activeKey
110
+
111
+ // 标记新页签为已加载
112
+ if (this.config && this.config.data && this.config.data[newKey] !== undefined) {
113
+ this.markTabAsLoaded(newKey)
114
+ }
115
+
116
+ if (this.config && this.config.changeFunc) {
117
+ let oldRef
118
+ let oldTabName
119
+ let newRef
120
+ let newTabName
121
+
122
+ if (!this.config.data[oldKey]) {
123
+ oldTabName = `tab_com_${oldKey}`
124
+ oldRef = this.$refs[oldTabName]
125
+ } else {
126
+ const oldTabSlotType = this.config.data[oldKey].slotType
127
+ oldTabName = `tab_com_${oldTabSlotType}_${oldKey}`
128
+ oldRef = this.$refs[oldTabName]
129
+ }
130
+
131
+ if (!this.config.data[newKey]) {
132
+ newTabName = `tab_com_${newKey}`
133
+ newRef = this.$refs[newTabName]
134
+ } else {
135
+ const newTabSlotType = this.config.data[newKey].slotType
136
+ newTabName = `tab_com_${newTabSlotType}_${newKey}`
137
+ newRef = this.$refs[newTabName]
138
+ }
139
+
140
+ const args = [
141
+ oldKey,
142
+ newKey,
143
+ this.config.data[oldKey],
144
+ this.config.data[newKey],
145
+ oldRef ? oldRef[0] : undefined,
146
+ ]
147
+ args.push(newTabName)
148
+
149
+ // 关键修改:确保新组件实例存在
150
+ if (!newRef || !newRef[0]) {
151
+ console.log('等待新页签组件初始化...')
152
+ // 等待组件挂载完成
153
+ await this.waitForComponentReady(newKey)
154
+ newRef = this.$refs[newTabName]
155
+ }
156
+
157
+ if (newRef && newRef[0]) {
158
+ args.push(newRef[0])
159
+ } else {
160
+ args.push(null)
161
+ console.warn('新页签组件实例获取失败')
162
+ }
163
+
164
+ args.push(this.extraData)
165
+
166
+ // 使用 $nextTick 确保 DOM 更新完成
167
+ await this.$nextTick()
168
+
169
+ // 确保组件完全就绪后再执行 changeFunc
170
+ if (newRef && newRef[0]) {
171
+ // 等待组件完全就绪(包括内部异步初始化)
172
+ await this.waitForComponentFullyReady(newRef[0], newKey)
173
+ } else {
174
+ // 如果没有组件实例,等待一个 tick 确保 DOM 更新
175
+ await this.$nextTick()
176
+ }
177
+
178
+ result = executeStrFunctionByContext(this, this.config.changeFunc, args)
179
+
180
+ if (result && result.noChange) {
181
+ console.info('不切换页签作为按钮使用')
182
+ // 如果返回 noChange,恢复原来的 activeKey
183
+ if (this.activeKey === newKey) {
184
+ this.activeKey = oldKey
185
+ }
186
+ } else {
187
+ // 确保 activeKey 已更新(如果还没更新的话)
188
+ if (this.activeKey !== newKey) {
189
+ this.activeKey = newKey
190
+ }
191
+ // 确保回调在组件完全就绪后执行
192
+ if (result && result.callback && typeof result.callback === 'function') {
193
+ await this.$nextTick()
194
+ result.callback()
195
+ }
196
+ }
197
+ } else {
198
+ this.activeKey = newKey
199
+ }
200
+
201
+ if (initStatus) {
202
+ this.activeKey = this.defaultActiveKey
203
+ }
204
+ },
205
+
206
+ // 新增:等待组件就绪的方法
207
+ waitForComponentReady (index) {
208
+ return new Promise((resolve) => {
209
+ const checkComponent = () => {
210
+ const tab = this.config.data[index]
211
+ const refName = `tab_com_${tab.slotType}_${index}`
212
+ const ref = this.$refs[refName]
213
+
214
+ if (ref && ref[0]) {
215
+ // 额外检查组件内部是否已初始化(如果有相关状态的话)
216
+ if (ref[0].isReady !== undefined) {
217
+ if (ref[0].isReady) {
218
+ resolve(ref[0])
219
+ } else {
220
+ setTimeout(checkComponent, 50)
221
+ }
222
+ } else {
223
+ resolve(ref[0])
224
+ }
225
+ } else {
226
+ setTimeout(checkComponent, 50)
227
+ }
228
+ }
229
+
230
+ checkComponent()
231
+ })
232
+ },
233
+ // 等待组件完全就绪(包括内部异步初始化)
234
+ waitForComponentFullyReady (component, index) {
235
+ return new Promise((resolve) => {
236
+ if (!component) {
237
+ resolve()
238
+ return
239
+ }
240
+
241
+ let attempts = 0
242
+ const maxAttempts = 60 // 最多等待3秒
243
+ const checkInterval = 50
244
+
245
+ const checkReady = () => {
246
+ attempts++
247
+ // 1. 检查组件是否有 loading 状态,确保不在加载中
248
+ if (component.loading === true) {
249
+ if (attempts < maxAttempts) {
250
+ setTimeout(checkReady, checkInterval)
251
+ return
252
+ }
253
+ }
254
+
255
+ // 2. 检查组件是否有 loaded 状态(如 XAddNativeForm)
256
+ if (component.loaded === false) {
257
+ if (attempts < maxAttempts) {
258
+ setTimeout(checkReady, checkInterval)
259
+ return
260
+ }
261
+ }
262
+
263
+ // 3. 检查组件是否有 realQueryConfig(如 XFormTable)
264
+ const tab = this.config.data[index]
265
+ const isFormTableType = tab?.slotType === 'x-form-table' ||
266
+ tab?.slotType === 'XFormTable' ||
267
+ tab?.slotType?.toLowerCase() === 'xformtable'
268
+ if (isFormTableType && component.realQueryConfig === undefined && !component.loadError) {
269
+ if (attempts < maxAttempts) {
270
+ setTimeout(checkReady, checkInterval)
271
+ return
272
+ }
273
+ }
274
+
275
+ // 4. 检查关键方法是否存在(如 setForm、setFormWithKey)
276
+ const hasSetForm = typeof component.setForm === 'function'
277
+ const hasSetFormWithKey = typeof component.setFormWithKey === 'function'
278
+ const hasSetFormWithNoKey = typeof component.setFormWithNoKey === 'function'
279
+ // 5. 如果组件有这些方法,确保表单对象存在
280
+ if (hasSetForm || hasSetFormWithKey || hasSetFormWithNoKey) {
281
+ // 检查组件是否有 form 对象
282
+ if (component.form && Object.keys(component.form).length > 0) {
283
+ // 表单已初始化,等待 DOM 渲染完成
284
+ this.$nextTick(() => {
285
+ // 额外等待一个 tick,确保所有子组件也渲染完成
286
+ this.$nextTick(() => {
287
+ resolve()
288
+ })
289
+ })
290
+ return
291
+ } else if (component.loaded !== false) {
292
+ // 如果没有 form 对象但 loaded 不为 false,可能还在初始化
293
+ if (attempts < maxAttempts) {
294
+ setTimeout(checkReady, checkInterval)
295
+ return
296
+ }
297
+ }
298
+ }
299
+
300
+ // 6. 如果以上都通过,或者超时,等待 DOM 渲染完成
301
+ if (attempts >= 3 || attempts >= maxAttempts) {
302
+ // 至少等待几次检查,确保有时间初始化
303
+ this.$nextTick(() => {
304
+ this.$nextTick(() => {
305
+ resolve()
306
+ })
307
+ })
308
+ return
309
+ }
310
+
311
+ // 继续等待
312
+ setTimeout(checkReady, checkInterval)
313
+ }
314
+
315
+ // 首次检查前等待一个 tick
316
+ this.$nextTick(() => {
317
+ checkReady()
318
+ })
319
+ })
320
+ },
321
+ initConfig () {
322
+ if (this.configName) {
323
+ this.getConfig()
324
+ } else if (this.localConfig) {
325
+ this.config = this.localConfig
326
+ // 设置是否显示页签
327
+ this.showTabBar = this.localConfig.showTabBar !== false
328
+ }
329
+ // 重置已加载页签集合,确保配置变更后重新加载
330
+ this.loadedTabs = []
331
+ // 标记默认激活的页签为已加载
332
+ if (this.config && this.config.data) {
333
+ this.markTabAsLoaded(this.defaultActiveKey)
334
+ }
335
+ },
336
+ getConfig () {
337
+ getConfigByName(this.configName, this.serverName, res => {
338
+ this.config = res
339
+ // 设置是否显示页签
340
+ this.showTabBar = res.showTabBar !== false
341
+ // 标记默认激活的页签为已加载
342
+ if (this.config && this.config.data) {
343
+ this.markTabAsLoaded(this.defaultActiveKey)
344
+ }
345
+ }, this.env === 'dev')
346
+ },
347
+ getEventHandlers (tab, index) {
348
+ const handlers = {}
349
+ if (!tab?.events || tab?.events?.length === 0) {
350
+ return handlers
351
+ }
352
+ tab.events.forEach(event => {
353
+ handlers[event.type] = (...args) => {
354
+ executeStrFunctionByContext(this.$refs[`tab_com_${tab.slotType}_${index}`][0], event.customFunction, args)
355
+ }
356
+ })
357
+ return handlers
358
+ },
359
+ onComponentMounted (h, tab, index) {
360
+ if (tab.slotType === 'x-add-native-form') {
361
+ // 建议表单需要主动调用初始化方法
362
+ getConfigByName(tab.slotConfig, tab.serviceName, async (res) => {
363
+ // 如果配置了 表单初始化logic
364
+ // 调用 logic 获取参数
365
+ let param = {}
366
+ let selectedId
367
+ if (res.paramLogicName) {
368
+ if (!!this.getSelectedId) {
369
+ selectedId = this.getSelectedId()
370
+ if (typeof selectedId !== 'object') {
371
+ selectedId = { selectedId: selectedId }
372
+ }
373
+ }
374
+ param = Object.assign(param, await runLogic(res.paramLogicName, selectedId, tab.serviceName))
375
+ }
376
+ this.$refs[`tab_com_${tab.slotType}_${index}`][0].init({
377
+ formItems: res.formJson,
378
+ showSubmitBtn: !this.isInAModal,
379
+ businessType: '新增',
380
+ layout: res.xAddFormLayout,
381
+ ...res,
382
+ fixedAddForm: param,
383
+ modifyModelData: {
384
+ files: param.files,
385
+ images: param.images
386
+ }
387
+ })
388
+ }, this.env === 'dev')
389
+ }
390
+ },
391
+ // 判断页签是否已加载
392
+ isTabLoaded (index) {
393
+ const numIndex = Number(index)
394
+ return this.loadedTabs.includes(numIndex) || Number(this.activeKey) === numIndex
395
+ },
396
+ // 标记页签为已加载
397
+ markTabAsLoaded (index) {
398
+ const numIndex = Number(index)
399
+ // 确保是有效的数字索引,且未添加过
400
+ if (!isNaN(numIndex) && numIndex >= 0 && !this.loadedTabs.includes(numIndex)) {
401
+ this.loadedTabs.push(numIndex)
402
+ }
403
+ },
404
+ // 确保页签已加载,如果未加载则先加载,返回 Promise 等待组件渲染完成
405
+ ensureTabLoaded (index, options = {}) {
406
+ return new Promise((resolve, reject) => {
407
+ const numIndex = Number(index)
408
+ const innerRefs = Array.isArray(options.innerRefs) ? options.innerRefs : []
409
+ const allowSwitch = options.allowSwitch !== false
410
+ // 验证索引有效性
411
+ if (isNaN(numIndex) || numIndex < 0) {
412
+ reject(new Error(`无效的页签索引: ${index}`))
413
+ return
414
+ }
415
+ if (!this.config || !this.config.data || !this.config.data[numIndex]) {
416
+ reject(new Error(`页签索引 ${index} 不存在`))
417
+ return
418
+ }
419
+ // 如果已经加载,直接返回组件实例
420
+ if (this.isTabLoaded(numIndex)) {
421
+ const component = this.getTabComponent(numIndex)
422
+ if (component) {
423
+ if (innerRefs.length === 0) {
424
+ resolve(component)
425
+ } else {
426
+ this.waitForInnerRefs(component, innerRefs, resolve, reject)
427
+ }
428
+ } else {
429
+ // 已标记但组件可能还在渲染中,等待一下
430
+ this.$nextTick(() => {
431
+ const comp = this.getTabComponent(numIndex)
432
+ if (comp) {
433
+ if (innerRefs.length === 0) {
434
+ resolve(comp)
435
+ } else {
436
+ this.waitForInnerRefs(comp, innerRefs, resolve, reject)
437
+ }
438
+ } else {
439
+ // 等待组件mounted
440
+ this.waitForComponent(numIndex, (c) => {
441
+ if (innerRefs.length === 0) {
442
+ resolve(c)
443
+ } else {
444
+ this.waitForInnerRefs(c, innerRefs, resolve, reject)
445
+ }
446
+ }, reject)
447
+ }
448
+ })
449
+ }
450
+ return
451
+ }
452
+ // 标记为已加载,触发渲染
453
+ this.markTabAsLoaded(numIndex)
454
+ // 优先尝试在不切换页签的情况下获取组件
455
+ this.$nextTick(() => {
456
+ const comp = this.getTabComponent(numIndex)
457
+ if (comp) {
458
+ if (innerRefs.length === 0) resolve(comp)
459
+ else this.waitForInnerRefs(comp, innerRefs, resolve, reject)
460
+ return
461
+ }
462
+ // 若仍未渲染,且允许临时切换,则进行一次激活-恢复回退
463
+ if (!allowSwitch) {
464
+ // 不允许切换则进入常规等待(可能更慢)
465
+ this.waitForComponent(numIndex, (c) => {
466
+ if (innerRefs.length === 0) resolve(c)
467
+ else this.waitForInnerRefs(c, innerRefs, resolve, reject)
468
+ }, reject)
469
+ return
470
+ }
471
+ const prevActive = this.activeKey
472
+ this.activeKey = numIndex
473
+ this.$nextTick(() => {
474
+ this.waitForComponent(numIndex, (c) => {
475
+ // 组件到位后再恢复原激活页签
476
+ if (prevActive !== numIndex) {
477
+ this.$nextTick(() => { this.activeKey = prevActive })
478
+ }
479
+ if (innerRefs.length === 0) resolve(c)
480
+ else this.waitForInnerRefs(c, innerRefs, resolve, reject)
481
+ }, reject)
482
+ })
483
+ })
484
+ })
485
+ },
486
+ // 等待组件渲染完成
487
+ waitForComponent (index, resolve, reject) {
488
+ const maxAttempts = 50 // 最多尝试50次
489
+ let attempts = 0
490
+ const checkInterval = 50 // 每50ms检查一次
491
+ const tab = this.config.data[index]
492
+ const refName = `tab_com_${tab.slotType}_${index}`
493
+ const checkComponent = () => {
494
+ attempts++
495
+ const component = this.$refs[refName]
496
+ if (component && component[0]) {
497
+ resolve(component[0])
498
+ return
499
+ }
500
+ if (attempts >= maxAttempts) {
501
+ reject(new Error(`等待页签 ${index} 组件加载超时`))
502
+ return
503
+ }
504
+ setTimeout(checkComponent, checkInterval)
505
+ }
506
+ // 首次检查
507
+ this.$nextTick(() => {
508
+ checkComponent()
509
+ })
510
+ },
511
+ // 等待内部 $refs 就绪
512
+ waitForInnerRefs (component, innerRefs, resolve, reject) {
513
+ const maxAttempts = 50
514
+ let attempts = 0
515
+ const checkInterval = 50
516
+ const allReady = () => innerRefs.every(name => component.$refs && component.$refs[name])
517
+ const check = () => {
518
+ attempts++
519
+ if (allReady()) {
520
+ resolve(component)
521
+ return
522
+ }
523
+ if (attempts >= maxAttempts) {
524
+ reject(new Error(`等待内部 refs [${innerRefs.join(', ')}] 就绪超时`))
525
+ return
526
+ }
527
+ setTimeout(check, checkInterval)
528
+ }
529
+ this.$nextTick(() => check())
530
+ },
531
+ // 获取页签的组件实例
532
+ getTabComponent (index) {
533
+ const numIndex = Number(index)
534
+ if (isNaN(numIndex) || numIndex < 0 || !this.config || !this.config.data || !this.config.data[numIndex]) {
535
+ return null
536
+ }
537
+ const tab = this.config.data[numIndex]
538
+ const refName = `tab_com_${tab.slotType}_${numIndex}`
539
+ const ref = this.$refs[refName]
540
+ return ref && ref[0] ? ref[0] : null
541
+ },
542
+
543
+ },
544
+ props: {
545
+ // 配置名
546
+ configName: {
547
+ type: String,
548
+ default: undefined
549
+ },
550
+ serverName: {
551
+ type: String,
552
+ default: undefined
553
+ },
554
+ env: {
555
+ type: String,
556
+ default: 'prod'
557
+ },
558
+ // 本地配置,调试用
559
+ localConfig: {
560
+ type: Object,
561
+ default: undefined
562
+ },
563
+ tabBarGutter: {
564
+ type: Number,
565
+ default: 10
566
+ },
567
+ bodyStyle: {
568
+ type: Object,
569
+ default: () => {
570
+ return {}
571
+ }
572
+ },
573
+ defaultActiveKey: {
574
+ type: [String, Number],
575
+ default: 0
576
+ },
577
+ // 新增compProp参数,用于穿透到动态组件
578
+ compProp: {
579
+ type: Object,
580
+ default: () => {
581
+ return {}
582
+ }
583
+ },
584
+ // 额外数据
585
+ extraData: {
586
+ type: Object,
587
+ default: () => {
588
+ return {}
589
+ }
590
+ }
591
+ },
592
+ watch: {
593
+ configName: {
594
+ deep: true,
595
+ immediate: true,
596
+ handler (val) {
597
+ this.initConfig()
598
+ }
599
+ },
600
+ // 如果本地配置更改了,重新初始化
601
+ localConfig: {
602
+ deep: true,
603
+ immediate: true,
604
+ handler (val) {
605
+ this.initConfig()
606
+ }
607
+ },
608
+ },
609
+ }
610
+ </script>
611
+ <style scoped>
612
+ </style>