vue2-client 1.22.2 → 1.22.3

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 (170) hide show
  1. package/.claude/settings.local.json +30 -30
  2. package/.env.his +19 -19
  3. package/.eslintrc.js +74 -74
  4. package/.history/.eslintrc_20260521171150.js +74 -0
  5. package/.history/.eslintrc_20260521171213.js +74 -0
  6. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154443.vue +726 -0
  7. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154700.vue +478 -0
  8. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175435.vue +706 -0
  9. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175450.vue +694 -0
  10. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260611152602.vue +755 -0
  11. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513145941.vue +524 -0
  12. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513153133.vue +731 -0
  13. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513160316.vue +525 -0
  14. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260601144150.vue +1046 -0
  15. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310142713.vue +512 -0
  16. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310145118.vue +511 -0
  17. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260311094834.vue +696 -0
  18. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260320143028.vue +693 -0
  19. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260409101450.vue +677 -0
  20. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508164645.vue +758 -0
  21. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508164714.vue +693 -0
  22. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508171651.vue +716 -0
  23. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260509133717.vue +695 -0
  24. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260509171115.vue +664 -0
  25. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140637.vue +1455 -0
  26. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140935.vue +1441 -0
  27. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513150818.vue +1441 -0
  28. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153119.vue +1442 -0
  29. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153126.vue +1486 -0
  30. package/.history/src/base-client/components/common/XForm/XFormItem_20260513140854.vue +1607 -0
  31. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140403.vue +643 -0
  32. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140829.vue +628 -0
  33. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519142824.vue +104 -0
  34. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519143155.vue +102 -0
  35. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171231.vue +1241 -0
  36. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171441.vue +1223 -0
  37. package/.history/src/base-client/components/his/HAi/HAi_20260612174826.vue +472 -0
  38. package/.history/src/base-client/components/his/HAi/HAi_20260612175839.vue +538 -0
  39. package/.history/src/base-client/components/his/HAi/HAi_20260615103331.vue +650 -0
  40. package/.history/src/base-client/components/his/XHDescriptions/XHDescriptions_20260424134504.vue +1469 -0
  41. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171133.vue +788 -0
  42. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171151.vue +780 -0
  43. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511170841.vue +585 -0
  44. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511171138.vue +787 -0
  45. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260512141830.vue +739 -0
  46. package/.history/src/components/STable/index_20260409155138.js +806 -0
  47. package/.history/src/components/STable/index_20260409155218.js +814 -0
  48. package/.history/src/expression/core/Expression_20260305164427.js +1371 -0
  49. package/.history/src/expression/core/Expression_20260305170258.js +1358 -0
  50. package/.history/src/expression/core/Program_20260305111830.js +944 -0
  51. package/.history/src/expression/core/Program_20260305112041.js +931 -0
  52. package/.history/src/logic/LogicRunner_20260304154306.js +170 -0
  53. package/.history/src/logic/LogicRunner_20260304155553.js +112 -0
  54. package/.history/src/logic/LogicRunner_20260305105834.js +112 -0
  55. package/.history/src/logic/LogicRunner_20260305112718.js +129 -0
  56. package/.history/src/logic/LogicRunner_20260305182436.js +133 -0
  57. package/.history/src/logic/LogicRunner_20260306151301.js +213 -0
  58. package/.history/src/logic/LogicRunner_20260306152419.js +213 -0
  59. package/.history/src/logic/plugins/common/DateTools_20260305154159.js +61 -0
  60. package/.history/src/logic/plugins/common/DateTools_20260305154217.js +44 -0
  61. package/.history/src/logic/plugins/common/DateTools_20260305161014.js +44 -0
  62. package/.history/src/logic/plugins/common/HttpTools_20260305164352.js +80 -0
  63. package/.history/src/logic/plugins/common/HttpTools_20260305170258.js +75 -0
  64. package/.history/src/logic/plugins/common/HttpTools_20260305171634.js +75 -0
  65. package/.history/src/logic/plugins/common/HttpTools_20260306152419.js +72 -0
  66. package/.history/src/services/api/restTools_20260427142149.js +245 -0
  67. package/.history/src/services/api/restTools_20260427142853.js +230 -0
  68. package/.history/src/services/api/restTools_20260519135558.js +230 -0
  69. package/.history/src/services/api/restTools_20260519140825.js +230 -0
  70. package/.history/src/services/api/restTools_20260519151223.js +230 -0
  71. package/.history/src/utils/indexedDB_20260306150918.js +593 -0
  72. package/.history/src/utils/indexedDB_20260306151301.js +586 -0
  73. package/.idea/af-vue2-client.iml +9 -0
  74. package/.idea/codeStyles/Project.xml +62 -0
  75. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  76. package/.idea/misc.xml +6 -0
  77. package/.idea/modules.xml +1 -1
  78. package/Components.md +60 -60
  79. package/index.js +31 -31
  80. package/jest-transform-stub.js +8 -8
  81. package/jest.setup.js +7 -7
  82. package/package.json +1 -1
  83. package/preview-input-box.html +180 -0
  84. package/src/assets/img/querySlotDemo.svg +15 -15
  85. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  86. package/src/base-client/components/common/CitySelect/index.js +3 -3
  87. package/src/base-client/components/common/CitySelect/index.md +109 -109
  88. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  89. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  90. package/src/base-client/components/common/HIS/HButtons/HButtons.vue +55 -1
  91. package/src/base-client/components/common/HIS/HForm/HForm.vue +1186 -1186
  92. package/src/base-client/components/common/HIS/HTab/HTab.vue +88 -1
  93. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  94. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  95. package/src/base-client/components/common/Tree/index.js +2 -2
  96. package/src/base-client/components/common/Upload/index.js +3 -3
  97. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  98. package/src/base-client/components/common/XAddReport/XAddReport.vue +16 -1
  99. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  100. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  101. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  102. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  103. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  104. package/src/base-client/components/common/XDescriptions/index.md +382 -382
  105. package/src/base-client/components/common/XForm/index.md +178 -178
  106. package/src/base-client/components/common/XInput/XInput.vue +32 -1
  107. package/src/base-client/components/common/XInspectionDetailDrawer/index.vue +1 -1
  108. package/src/base-client/components/common/XMarkdownViewer/demo.vue +102 -102
  109. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  110. package/src/base-client/components/common/XStepView/index.js +3 -3
  111. package/src/base-client/components/common/XStepView/index.md +31 -31
  112. package/src/base-client/components/common/XTable/index.md +255 -255
  113. package/src/base-client/components/his/HAi/HAi.vue +1177 -436
  114. package/src/base-client/components/his/XList/XList.vue +337 -58
  115. package/src/base-client/components/his/XSidebar/XSidebar.vue +36 -12
  116. package/src/base-client/components/his/XTransfer/index.md +327 -327
  117. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  118. package/src/base-client/plugins/Config.js +19 -19
  119. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  120. package/src/components/Charts/Bar.vue +62 -62
  121. package/src/components/Charts/ChartCard.vue +134 -134
  122. package/src/components/Charts/Liquid.vue +67 -67
  123. package/src/components/Charts/MiniArea.vue +39 -39
  124. package/src/components/Charts/MiniBar.vue +39 -39
  125. package/src/components/Charts/MiniProgress.vue +75 -75
  126. package/src/components/Charts/MiniSmoothArea.vue +40 -40
  127. package/src/components/Charts/Radar.vue +68 -68
  128. package/src/components/Charts/RankList.vue +77 -77
  129. package/src/components/Charts/TagCloud.vue +113 -113
  130. package/src/components/Charts/TransferBar.vue +64 -64
  131. package/src/components/Charts/Trend.vue +82 -82
  132. package/src/components/Charts/chart.less +12 -12
  133. package/src/components/Charts/smooth.area.less +13 -13
  134. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  135. package/src/components/NumberInfo/index.js +3 -3
  136. package/src/components/NumberInfo/index.less +54 -54
  137. package/src/components/NumberInfo/index.md +43 -43
  138. package/src/components/STable/index.js +953 -953
  139. package/src/components/card/ChartCard.vue +79 -79
  140. package/src/components/chart/Bar.vue +60 -60
  141. package/src/components/chart/MiniArea.vue +67 -67
  142. package/src/components/chart/MiniBar.vue +59 -59
  143. package/src/components/chart/MiniProgress.vue +57 -57
  144. package/src/components/chart/Radar.vue +80 -80
  145. package/src/components/chart/RankingList.vue +60 -60
  146. package/src/components/chart/Trend.vue +79 -79
  147. package/src/components/chart/index.less +9 -9
  148. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  149. package/src/components/input/IInput.vue +66 -66
  150. package/src/components/menu/SideMenu.vue +75 -75
  151. package/src/components/menu/menu.js +273 -273
  152. package/src/components/tool/AStepItem.vue +60 -60
  153. package/src/layouts/CommonLayout.vue +56 -56
  154. package/src/lib.js +1 -1
  155. package/src/mock/extend/index.js +84 -84
  156. package/src/mock/goods/index.js +108 -108
  157. package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
  158. package/src/pages/system/dictionary/index.vue +44 -44
  159. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  160. package/src/pages/system/monitor/operLog/index.vue +37 -37
  161. package/src/services/api/cas.js +79 -79
  162. package/src/store/modules/setting.js +119 -119
  163. package/src/utils/errorCode.js +6 -6
  164. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
  165. package/.idea/MarsCodeWorkspaceAppSettings.xml +0 -7
  166. package/.idea/google-java-format.xml +0 -6
  167. package/.idea/inspectionProfiles/Project_Default.xml +0 -24
  168. package/.idea/jsLinters/eslint.xml +0 -6
  169. package/.idea/vue2-client.iml +0 -12
  170. package/.vscode/settings.json +0 -28
@@ -0,0 +1,1223 @@
1
+ <template>
2
+ <div>
3
+ <!-- 骨架屏 -->
4
+ <a-card v-if="showSkeleton">
5
+ <a-skeleton active />
6
+ </a-card>
7
+ <!-- 主体表格 -->
8
+ <XReportDesign
9
+ @selectRow="selectRow"
10
+ @slotRendered="slotRendered"
11
+ @allSlotsConfigEnded="onAllSlotsConfigEnded"
12
+ v-if="scanFinish"
13
+ :display-only="displayOnly"
14
+ :config="originalConfig"
15
+ :slot-config-name="undefined"
16
+ :for-display="true"
17
+ ref="XReportDesign"
18
+ :server-name="serverName"
19
+ :env="env"
20
+ :show-title="showTitle"
21
+ @listClick="listClick"
22
+ >
23
+ </XReportDesign>
24
+ <a-row
25
+ type="flex"
26
+ justify="end"
27
+ v-if="showSaveButton"
28
+ >
29
+ <a-space>
30
+ <a-button @click="saveConfig">
31
+ 提交
32
+ </a-button>
33
+ <a-button @click="cancelConfig">
34
+ 取消
35
+ </a-button>
36
+ </a-space>
37
+ </a-row>
38
+ <!-- 弹出框 -->
39
+ <x-add-report
40
+ :env="env"
41
+ ref="xAddReport"
42
+ />
43
+ <!-- 弹出框 -->
44
+ <x-report-drawer
45
+ :env="env"
46
+ ref="xReportDrawer"
47
+ />
48
+ </div>
49
+ </template>
50
+ <script>
51
+ /* eslint-disable */
52
+ // 转PDF用
53
+ import { mapState } from 'vuex'
54
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
55
+ import XReportDesign from './XReportDesign.vue'
56
+ import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
57
+
58
+ // import XAddReport from '@vue2-client/base-client/components/common/XAddReport'
59
+
60
+ export default {
61
+ name: 'XReport',
62
+ props: {
63
+ files: {
64
+ type: Array,
65
+ default: () => {
66
+ return []
67
+ },
68
+ },
69
+ // 控制用户权限,user和admin
70
+ authority: {
71
+ type: String,
72
+ default: 'user',
73
+ },
74
+ // 是否为编辑模式
75
+ editMode: {
76
+ type: Boolean,
77
+ default: true,
78
+ },
79
+ // 配置名
80
+ configName: {
81
+ type: String,
82
+ required: true,
83
+ },
84
+ // 插槽名
85
+ activatedSlotName: {
86
+ type: String,
87
+ default: undefined,
88
+ },
89
+ // 本地配置,调试用
90
+ localConfig: {
91
+ type: Object,
92
+ default: undefined,
93
+ },
94
+ // 兼容老版本配置
95
+ dontFormat: {
96
+ type: Boolean,
97
+ default: true,
98
+ },
99
+ showImgInCell: {
100
+ type: Boolean,
101
+ default: false,
102
+ },
103
+ // 数据
104
+ configData: {
105
+ type: Object,
106
+ default: undefined,
107
+ },
108
+ // 命名空间
109
+ serverName: {
110
+ type: String,
111
+ default: process.env.VUE_APP_SYSTEM_NAME,
112
+ },
113
+ // 环境
114
+ env: {
115
+ type: String,
116
+ default: 'prod',
117
+ },
118
+ // 只做展示
119
+ displayOnly: {
120
+ type: Boolean,
121
+ default: true,
122
+ },
123
+ // 表格没有边距
124
+ noPadding: {
125
+ type: Boolean,
126
+ default: true,
127
+ },
128
+ // 表格没有上边框,与noPadding搭配可以实现连续表格
129
+ noTopBorder: {
130
+ type: Boolean,
131
+ default: false,
132
+ },
133
+ // 是否展示标题
134
+ showTitle: {
135
+ type: Boolean,
136
+ default: true,
137
+ },
138
+ // 是否展示保存按钮
139
+ showSaveButton: {
140
+ type: Boolean,
141
+ default: false,
142
+ },
143
+ // 是否将组件注册到外层提供的容器中,方便外侧统一保存
144
+ registerMap: {
145
+ type: Array,
146
+ default: undefined,
147
+ },
148
+ // TAB 页签时由 XTab 传入,仅接收不参与逻辑(注册由 XTab onComponentMounted 完成)
149
+ slotRef: {
150
+ type: String,
151
+ default: undefined,
152
+ },
153
+ // 是否小插件模式,小插件模式不会有各种边境
154
+ isWidget: {
155
+ type: Boolean,
156
+ default: false,
157
+ },
158
+ // 图片是否使用OSS来保存
159
+ useOssForImg: {
160
+ type: Boolean,
161
+ default: true,
162
+ },
163
+ // 图片上传后添加前缀
164
+ imgPrefix: {
165
+ type: String,
166
+ default: undefined,
167
+ },
168
+ },
169
+ components: {
170
+ XAddReport: () =>
171
+ import('@vue2-client/base-client/components/common/XAddReport'),
172
+ XReportDrawer: () =>
173
+ import('@vue2-client/base-client/components/common/XReportDrawer'),
174
+ XReportDesign,
175
+ },
176
+ data () {
177
+ return {
178
+ // 控制骨架屏显隐
179
+ showSkeleton: true,
180
+ // 配置
181
+ config: undefined,
182
+ // 当前显示模式,编辑模式,预览模式
183
+ type: 'design',
184
+ // 仅供展示,不可编辑
185
+ onlyDisplay: false,
186
+ // 每行最大列数,非必要请勿更改,现在的设计器完全是基于每行12列来设计的
187
+ maxColSpan: 12,
188
+ // 定义是否完成配置的扫描,未完成不要渲染子组件
189
+ scanFinish: false,
190
+ // 当前激活的配置文件
191
+ activeConfig: null,
192
+ // 原始配置文件
193
+ // 用于展示。某些情况下“设计页”中的内容仅为“预览页”表格其中的一部分
194
+ originalConfig: null,
195
+ // 扫描到的配置
196
+ configFromWeb: {},
197
+ // 用于获取配置的锁
198
+ timer: undefined,
199
+ // 是否包含图片
200
+ hasImages: false,
201
+ // 图片列表
202
+ imageList: [],
203
+ // 保存最原始的数据,用于判断哪些数据被更改了
204
+ dataCache: undefined,
205
+ // 判断哪些数据被更改了,存储对应的key
206
+ diff: [],
207
+ globalData: {},
208
+ // setData 在 config 未就绪时传入的 data,配置彻底结束后再执行
209
+ // eslint-disable-next-line
210
+ _pendingSetData: undefined,
211
+ // 配置是否彻底结束:本报表配置就绪且所有 slot 子组件配置也结束(由 allSlotsConfigEnded 事件获知)
212
+ configEnded: false,
213
+ // 是否已收到 Design 的 allSlotsConfigEnded(所有 slot 子组件配置结束)
214
+ allSlotsConfigEnded: false,
215
+ // 本报表注册到全局组件注册表的名称(仅当配置了 globalRegistryName 时才有),destroy 时统一注销
216
+ // eslint-disable-next-line
217
+ _globalRegistrySlotNames: [],
218
+ // 等待配置结束的 Promise,供 waitConfigEnd() 使用
219
+ _configEndPromise: null,
220
+ _configEndResolve: null,
221
+ }
222
+ },
223
+ beforeDestroy () {
224
+ clearInterval(this.timer)
225
+ if (this.$componentRegistry && this._globalRegistrySlotNames.length) {
226
+ this._globalRegistrySlotNames.forEach((name) => {
227
+ this.$componentRegistry.unregister(name)
228
+ })
229
+ this._globalRegistrySlotNames = []
230
+ }
231
+ },
232
+ watch: {
233
+ // 如果配置名更改了,重新获取配置
234
+ configName (val) {
235
+ if (val) {
236
+ getConfigByName(
237
+ this.configName,
238
+ undefined,
239
+ (res) => {
240
+ this.config = res
241
+ this.configInit()
242
+ this.$logger('report.configLoad').log('configName 加载完成', { configName: this.configName })
243
+ },
244
+ this.env === 'dev'
245
+ )
246
+ }
247
+ },
248
+ // 如果本地配置更改了,重新初始化
249
+ localConfig: {
250
+ deep: true,
251
+ immediate: true,
252
+ handler (val) {
253
+ if (val) {
254
+ this.config = val
255
+ this.configInit()
256
+ this.$logger('report.configLoad').log('localConfig 变更完成', { configName: this.configName })
257
+ }
258
+ },
259
+ },
260
+ },
261
+ provide () {
262
+ const report = this
263
+ return {
264
+ runLogic: runLogic,
265
+ openDialog: report.openDialog.bind(report),
266
+ openDrawer: report.openDrawer.bind(report),
267
+ registerComponent: report.registerComponent.bind(report),
268
+ getComponentByName: report.getComponentByName.bind(report),
269
+ getParentComponentByName: report.getComponentByName.bind(report),
270
+ getConfigByName: getConfigByName,
271
+ isWidget: report.widget,
272
+ currUser: report.currUser,
273
+ getGlobalData: report.getGlobalData.bind(report),
274
+ setGlobalData: report.setGlobalData.bind(report),
275
+ findComponentByName: report.findComponentByName.bind(report),
276
+ closeAddReport: report.closeAddReport.bind(report),
277
+ setData: report.setData.bind(report),
278
+ getRootReport: () => report,
279
+ }
280
+ },
281
+ methods: {
282
+ findComponentByName (instance, componentName, maxDepth, findType) {
283
+ // 基础判断:如果实例不存在或者已经超过最大深度,返回null
284
+ if (!instance || maxDepth <= 0) {
285
+ return null
286
+ }
287
+
288
+ // 检查当前实例是否有目标组件
289
+ try {
290
+ if (instance.getComponentByName && instance.getComponentByName(componentName)) {
291
+ return instance.getComponentByName(componentName)
292
+ }
293
+ } catch (e) {
294
+ this.$logger('report.findComponent').warn('查找组件时发生错误:', e)
295
+ }
296
+
297
+ // 递归查找子组件
298
+ if (findType === 'parent') {
299
+ // 向上查找父组件
300
+ if (instance.$parent) {
301
+ return this.findComponentByName(instance.$parent, componentName, maxDepth - 1, findType)
302
+ }
303
+ } else {
304
+ if (instance.$children && instance.$children.length) {
305
+ for (const child of instance.$children) {
306
+ const result = this.findComponentByName(child, componentName, maxDepth - 1, findType)
307
+ if (result) {
308
+ return result
309
+ }
310
+ }
311
+ }
312
+ }
313
+ return null
314
+ },
315
+ listClick (data) {
316
+ this.$emit('listClick', data)
317
+ },
318
+ closeAddReport () {
319
+ if (this.$refs.xAddReport) {
320
+ this.$refs.xAddReport.close()
321
+ }
322
+ let parent = this.$parent
323
+ while (parent) {
324
+ if (parent.$refs && parent.$refs.xAddReport) {
325
+ const addReportRefs = parent.$refs.xAddReport
326
+ if (Array.isArray(addReportRefs)) {
327
+ addReportRefs.forEach(ref => {
328
+ if (ref && typeof ref.close === 'function') {
329
+ ref.close()
330
+ }
331
+ })
332
+ } else if (typeof addReportRefs.close === 'function') {
333
+ addReportRefs.close()
334
+ }
335
+ }
336
+ parent = parent.$parent
337
+ }
338
+ },
339
+ slotRendered () {
340
+ this.$logger('report.slotRendered').log('slotRendered 进入', { configName: this.configName, hasPendingSetData: this._pendingSetData !== undefined })
341
+ if (this.config?.mountedFunction) {
342
+ let func = this.config.mountedFunction
343
+ if (func && func.startsWith('function')) {
344
+ func = func.replace('function', 'async function')
345
+ executeStrFunctionByContext(this, func, [this])
346
+ }
347
+ }
348
+ },
349
+ onAllSlotsConfigEnded () {
350
+ this.allSlotsConfigEnded = true
351
+ this._markConfigEnded()
352
+ },
353
+ // 把组件注册到refs中,方便调用;若传入 options.globalRegistryName 则同时注册到全局组件注册表(向后兼容:无该字段则不注册)
354
+ registerComponent (componentName, component, options = {}) {
355
+ this.$refs[componentName] = component
356
+ const globalName = options.globalRegistryName
357
+ if (globalName && this.$componentRegistry) {
358
+ try {
359
+ this.$componentRegistry.register(globalName, component)
360
+ this._globalRegistrySlotNames.push(globalName)
361
+ } catch (e) {
362
+ this.$logger('report.registerComponent').warn('全局组件注册表注册失败:', e?.message || e)
363
+ }
364
+ }
365
+ },
366
+
367
+ // 把设计的table布局转换成可显示的珊格布局
368
+ transformArray (inputList) {
369
+ let operationIndex = 0
370
+ let operationList = []
371
+ const outputList = []
372
+ for (const lst of inputList) {
373
+ // 如果列表为空或只有一个元素,则所有元素相等。比较列表中每个元素是否与第一个元素相等
374
+ if (
375
+ lst.length >= 1 &&
376
+ !lst.every(
377
+ (x) =>
378
+ Array.isArray(x) ||
379
+ Array.isArray(lst[0]) ||
380
+ x.rowSpan === lst[0].rowSpan
381
+ )
382
+ ) {
383
+ operationList = lst
384
+ break // 使用 break 退出整个循环
385
+ } else {
386
+ // 被操作的行
387
+ operationIndex += 1
388
+ }
389
+ }
390
+
391
+ let maxMergeRow = 0
392
+
393
+ // 没有需要合并的行,直接返回
394
+ if (operationList.length === 0) {
395
+ return inputList
396
+ } else {
397
+ // 当前行的最大值
398
+ const maxRow = Math.max(...operationList.map((item) => item.rowSpan))
399
+ let mergeIndexCol = 0
400
+ for (let index = 0; index < operationList.length; index++) {
401
+ const row = operationList[index]
402
+ let rowSpan = row.rowSpan
403
+ // 需要合并的行
404
+ let mergeIndexRow = operationIndex + 1
405
+ // 存放合并后的行
406
+ const rows = []
407
+ // 添加当前行
408
+ if (rowSpan < maxRow && mergeIndexRow < inputList.length) {
409
+ rows.push([row])
410
+ }
411
+ // 当前需要被操作并且操作行没有超出列表的高度
412
+ while (rowSpan < maxRow && mergeIndexRow < inputList.length) {
413
+ rowSpan += inputList[mergeIndexRow][mergeIndexCol].rowSpan
414
+ // 放一行到合并结果
415
+ rows.push([inputList[mergeIndexRow][mergeIndexCol]])
416
+ if (mergeIndexRow > maxMergeRow) {
417
+ // 记录最多操作到了哪行
418
+ maxMergeRow = mergeIndexRow
419
+ }
420
+ mergeIndexRow++
421
+ }
422
+ // operation_list赋值, 没有变化的,不处理
423
+ if (rows.length !== 0) {
424
+ operationList[index] = rows
425
+ }
426
+ if (row.rowSpan !== maxRow) {
427
+ mergeIndexCol++ // 操作列转为下一列
428
+ }
429
+ }
430
+ }
431
+
432
+ // 组成outputlist, operation_list前部填入
433
+ let putindex = 0
434
+ while (operationIndex > 0) {
435
+ outputList.push(inputList[putindex])
436
+ putindex++
437
+ operationIndex -= 1
438
+ }
439
+
440
+ outputList.push(operationList)
441
+
442
+ // 组成outputlist, operation_list后部填入
443
+ while (maxMergeRow < inputList.length - 1) {
444
+ outputList.push(inputList[maxMergeRow + 1])
445
+ maxMergeRow += 1
446
+ }
447
+
448
+ return this.transformArray(outputList)
449
+ },
450
+ // 根据名字从注册到组件中获取组件
451
+ getComponentByName (componentName) {
452
+ return this.$refs[componentName]
453
+ },
454
+ getGlobalData () {
455
+ return this.globalData
456
+ },
457
+ setGlobalData (obj) {
458
+ this.globalData = obj
459
+ },
460
+ /**
461
+ * 配置彻底结束:本报表配置就绪且所有 slot 子组件配置也结束。打标、对外发 configEnd,再执行缓存的 setData。
462
+ * 由 onAllSlotsConfigEnded(有 slot 且收到 allSlotsConfigEnded)或 configInit 的 nextTick(无 slot)调用,仅执行一次。
463
+ */
464
+ _markConfigEnded () {
465
+ if (this.configEnded) return
466
+ const hasSlots = (this.config?.slotsDeclare?.length || 0) > 0
467
+ if (hasSlots && !this.allSlotsConfigEnded) return
468
+ this.configEnded = true
469
+ this.$logger('report.configEnd').log('配置彻底结束,发送 configEnd', { configName: this.configName })
470
+ this.$emit('configEnd')
471
+ if (this._configEndResolve) {
472
+ this._configEndResolve()
473
+ this._configEndResolve = null
474
+ }
475
+ this.$nextTick(() => this._flushPendingSetData())
476
+ this.$nextTick(() => this._runFrontLogic())
477
+ },
478
+ /**
479
+ * 执行配置的 frontLogic
480
+ */
481
+ async _runFrontLogic () {
482
+ const logicName = this.config?.mountedLogicName
483
+ console.log('加载完成',logicName,this.config)
484
+ if (!logicName) return
485
+ const param = { ...(this.config?.mountedLogicParam || {}), proxy: this }
486
+ const mode = this.config?.mountedLogicMode
487
+ this.$logger('report.frontLogic').log('执行 frontLogic', { logicName, mode, paramKeys: Object.keys(param) })
488
+ try {
489
+ await this.$runFrontLogic(logicName, param, mode)
490
+ } catch (e) {
491
+ const cause = e?.cause || e
492
+ const isCanceled = cause?.name === 'AbortError' || cause?.name === 'CanceledError' || cause?.code === 'ERR_CANCELED'
493
+ if (!isCanceled) {
494
+ this.$logger('report.frontLogic').error('frontLogic 执行失败:', e)
495
+ this.$message.error(`前端逻辑执行失败: ${e?.message || e}`)
496
+ }
497
+ }
498
+ },
499
+ /**
500
+ * 等待配置结束的异步方法。配置已结束则立即 resolve,否则在 configEnd 时 resolve。
501
+ * @returns {Promise<void>}
502
+ */
503
+ waitConfigEnd () {
504
+ if (this.configEnded) return Promise.resolve()
505
+ return this._configEndPromise || Promise.resolve()
506
+ },
507
+ /**
508
+ * 内部:直接执行 dataProcessScript。供 setData(configEnded 时)和 _flushPendingSetData 调用。
509
+ */
510
+ async _runDataProcessScript (data) {
511
+ const script = this.config?.dataProcessScript
512
+ if (!script || typeof script !== 'string') return
513
+ try {
514
+ const result = executeStrFunctionByContext(this, script, [data])
515
+ if (result instanceof Promise) await result
516
+ } catch (e) {
517
+ this.$logger('report.dataProcessScript').error('dataProcessScript 执行异常:', e)
518
+ }
519
+ },
520
+ /**
521
+ * 对外数据设置:仅当配置中存在 dataProcessScript 时执行该脚本,传入 data;不修改组件自身任何数据。
522
+ * 无脚本时缓存 data 并 return。有脚本但配置未彻底结束(configEnded 为 false)时也缓存,等 configEnd 后再执行。
523
+ * 只有配置彻底结束后才执行 dataProcessScript。脚本内 this 为当前 XReport 实例。
524
+ * @param {*} data 外部传入的数据,供脚本使用
525
+ * @returns {Promise<void>}
526
+ */
527
+ async setData (data) {
528
+ this.$logger('report.setData').log('setData 进入', { configName: this.configName, configEnded: this.configEnded, hasData: data !== undefined, dataKeys: data && typeof data === 'object' ? Object.keys(data) : [] })
529
+ const script = this.config?.dataProcessScript
530
+ if (!script || typeof script !== 'string') {
531
+ this._pendingSetData = data
532
+ this.$logger('report.setData').warn('分支: 无脚本,已缓存 data', { hasConfig: !!this.config, hasScript: !!(this.config && this.config.dataProcessScript), configName: this.configName })
533
+ return
534
+ }
535
+ if (!this.configEnded) {
536
+ this._pendingSetData = data
537
+ this.$logger('report.setData').log('分支: 配置未结束,已缓存 data,等 configEnd 后执行', { configName: this.configName })
538
+ return
539
+ }
540
+ this._pendingSetData = undefined
541
+ this.$logger('report.setData').log('分支: 配置已结束,立即执行 dataProcessScript', { configName: this.configName })
542
+ await this._runDataProcessScript(data)
543
+ },
544
+ /**
545
+ * 执行缓存的 setData:取 _pendingSetData 并直接执行脚本,不经过 setData,避免 setData 再次判断 defer 导致脚本不执行。
546
+ */
547
+ _flushPendingSetData () {
548
+ const hasPending = this._pendingSetData !== undefined
549
+ this.$logger('report.flushPendingSetData').log('_flushPendingSetData 进入', { configName: this.configName, hasPending })
550
+ if (!hasPending) return
551
+ const d = this._pendingSetData
552
+ this._pendingSetData = undefined
553
+ this.$logger('report.flushPendingSetData').log('_flushPendingSetData 直接执行 dataProcessScript', { configName: this.configName })
554
+ this._runDataProcessScript(d)
555
+ },
556
+ /**
557
+ * @param configName 栅格配置名称
558
+ * @param selectedId 选中得id
559
+ * @param mixinData 需要混入得数据
560
+ * @param outEnv 其他传递给打开窗口的数据
561
+ * @param attr 传递给Modal弹框用的信息
562
+ */
563
+ openDialog (configName, selectedId, mixinData, outEnv = {}, attr = {}, showButtons = true) {
564
+ this.$refs.xAddReport.init({
565
+ configName: configName,
566
+ selectedId: selectedId,
567
+ mixinData: mixinData,
568
+ outEnv: outEnv,
569
+ attr,
570
+ showButtons: showButtons
571
+ })
572
+ },
573
+ openDrawer (configName, selectedId, mixinData, outEnv = {}, attr = {}) {
574
+ this.$refs.xReportDrawer.init({
575
+ configName,
576
+ selectedId,
577
+ mixinData,
578
+ outEnv,
579
+ attr,
580
+ })
581
+ },
582
+ // 向外暴露图片修改后的数据,某些外部需要自己管理图片的保存与修改
583
+ updateImg (data) {
584
+ this.$emit('updateImg', data)
585
+ },
586
+ // 导出数据,某些外部需要统一控制数据的变动
587
+ exportData () {
588
+ // 获取当前修改后的数据
589
+ let tempData
590
+ if (this.activeConfig === undefined || this.activeConfig === null) {
591
+ tempData = this.originalConfig.data
592
+ } else {
593
+ const tempDataKeys = Object.keys(this.activeConfig.tempData)
594
+ tempDataKeys.forEach((key) => {
595
+ this.changeDeepObject(
596
+ this.activeConfig.data,
597
+ key,
598
+ this.activeConfig.tempData[key]
599
+ )
600
+ })
601
+ tempData = this.activeConfig.data
602
+ }
603
+ // 对比数据的差异
604
+ this.diff = []
605
+ this.compareProps(tempData, this.dataCache)
606
+ this.diff.forEach((eachDiff) => {
607
+ const arr = eachDiff.split('.')
608
+ let targetData = tempData[arr[0]]
609
+ if (arr.length !== 1) {
610
+ for (let i = 1; i < arr.length - 1; i++) {
611
+ const path = arr[i]
612
+ targetData = targetData[path]
613
+ }
614
+ }
615
+ // 将修改的数据,添加update = true属性
616
+ targetData.update = true
617
+ })
618
+ return tempData
619
+ },
620
+ // 对比两个obj有哪里不同
621
+ compareProps (obj1, obj2, path = '') {
622
+ for (const key in obj1) {
623
+ // 如果一个是undefined
624
+ if (typeof obj2[key] === 'undefined') {
625
+ this.diff.push(path + key)
626
+ // 如果是数组长度不一样
627
+ } else if (Array.isArray(obj1) && Array.isArray(obj2)) {
628
+ if (obj1[key].length !== obj2[key].length) {
629
+ this.diff.push(path + key)
630
+ }
631
+ // 如果都是对象,并且存在同样的key,递归子key
632
+ } else if (
633
+ typeof obj1[key] === 'object' &&
634
+ typeof obj2[key] === 'object'
635
+ ) {
636
+ this.compareProps(obj1[key], obj2[key], path + key + '.')
637
+ // 如果不是obj,对比其数据
638
+ } else if (obj1[key] !== obj2[key]) {
639
+ this.diff.push(path + key)
640
+ }
641
+ }
642
+ },
643
+ selectRow (selectedRowKeys, selectedRows) {
644
+ this.table_selectedRowKeys = selectedRowKeys
645
+ this.table_selectedRows = selectedRows
646
+ this.$emit('selectRow', selectedRowKeys, selectedRows)
647
+ },
648
+ // 注册组件到$refs中;若传入 options.globalRegistryName 则同时注册到全局组件注册表(向后兼容:无该字段则不注册)
649
+ registerComponentToRefs (componentName, component, options = {}) {
650
+ this.$refs[componentName] = component
651
+ const globalName = options.globalRegistryName
652
+ if (globalName && this.$componentRegistry) {
653
+ try {
654
+ this.$componentRegistry.register(globalName, component)
655
+ this._globalRegistrySlotNames.push(globalName)
656
+ } catch (e) {
657
+ this.$logger('report.registerComponentToRefs').warn('全局组件注册表注册失败:', e?.message || e)
658
+ }
659
+ }
660
+ },
661
+
662
+ // 提交处理,调用配置中的函数
663
+ saveConfig () {
664
+ const funcStr = this.config.confirmFunction
665
+ executeStrFunctionByContext(this, funcStr, [this])
666
+ },
667
+
668
+ // 取消处理
669
+ cancelConfig () {
670
+ this.$emit('cancel')
671
+ },
672
+
673
+ // 通过@@@分割临时变量,找到对应的key,并修改它的值
674
+ changeDeepObject (obj, strPath, newVal) {
675
+ const arr = strPath.split('@@@')
676
+ if (obj[arr[0]] === undefined) {
677
+ obj = obj.images
678
+ }
679
+ if (arr.length === 1) {
680
+ obj[arr[0]] = newVal
681
+ } else {
682
+ let result = obj[arr[0]]
683
+ arr.shift()
684
+ while (arr.length > 1) {
685
+ result = result[arr[0]]
686
+ arr.shift()
687
+ }
688
+ if (result) {
689
+ result[arr[0]] = newVal
690
+ }
691
+ }
692
+ },
693
+ // 检查slot是否在配置文件中包含,如果没有包含,则视为非法获取
694
+ checkSlotDefine (config) {
695
+ const slotsDeclare = config.slotsDeclare
696
+ const total = slotsDeclare.length
697
+ let count = 0
698
+ slotsDeclare.forEach((declare) => {
699
+ config.columns.forEach((row) => {
700
+ row.forEach((cell) => {
701
+ if (cell.slotConfig === declare) {
702
+ count++
703
+ }
704
+ })
705
+ })
706
+ })
707
+
708
+ return count === total
709
+ },
710
+ // 用于分割配置中的colums,将需要处理的数组提取出来
711
+ formatConfigRow () {
712
+ for (let i = 0; i < this.config.columns.length; i++) {
713
+ // 对原始数组进行递归,依次将该位置拆分为三个部分,当前处理位置之前的,当前处理位置,当前处理位置之后的
714
+ const before = this.config.columns.slice(0, i)
715
+ const after = this.config.columns.slice(
716
+ i + 1,
717
+ this.config.columns.length
718
+ )
719
+
720
+ // 将当前处理的数组交给处理的方法
721
+ const x = this.checkRow(this.config.columns[i])
722
+
723
+ const newArr = []
724
+
725
+ // 拼接之前的数组
726
+ if (before.length > 0) {
727
+ if (before.length >= 1) {
728
+ before.forEach((item) => {
729
+ newArr.push(item)
730
+ })
731
+ } else {
732
+ newArr.push(before)
733
+ }
734
+ }
735
+
736
+ // 拼接不需要更改当前节点处理完成的数组
737
+ newArr.push(x.old)
738
+
739
+ // 如果处理了新加的数据,拼接
740
+ if (x.add.length > 0) {
741
+ for (let j = 0; j < x.add.length; j++) {
742
+ if (x.add[j]) {
743
+ newArr.push(x.add[j])
744
+ i++
745
+ }
746
+ }
747
+ }
748
+
749
+ // 拼接之后的数组
750
+ if (after.length > 0) {
751
+ if (after.length >= 1) {
752
+ after.forEach((item) => {
753
+ newArr.push(item)
754
+ })
755
+ } else {
756
+ newArr.push(after)
757
+ }
758
+ }
759
+
760
+ this.config.columns = newArr
761
+ }
762
+ },
763
+ // 路径中含有@@@的key,将其解析,并返回其数据
764
+ getDeepObject (obj, strPath) {
765
+ const arr = strPath.split('@@@')
766
+ let result = obj[arr[0]]
767
+ arr.shift()
768
+ try {
769
+ while (arr.length > 0) {
770
+ result = result[arr[0]]
771
+ arr.shift()
772
+ }
773
+ } catch (e) {
774
+ result = undefined
775
+ }
776
+ return result
777
+ },
778
+ // 处理colums数组,为声明了rowspan的单元格,自动匹配格式
779
+ checkRow (rowArr) {
780
+ // 不需要更改的数据
781
+ const original = []
782
+ // 需要更改新加的数据
783
+ const addArr = []
784
+ // 统计rowspan出现的总和
785
+ let count = 0
786
+ // 统计声明列需要的rowspan总数
787
+ let total = 0
788
+ // 是否为声明行
789
+ let titleCellFlag = false
790
+ // 是否为声明行后第一行
791
+ let firstSubLine = false
792
+ // 需要处理的行,新的index值
793
+ let subRowIndex = 0
794
+ // 新生成的行,临时存储
795
+ const waitForAddArr = []
796
+ // 用于记录声明行的colspan避免格式错误
797
+ let preColSpan = 0
798
+ // 用于统计循环次数,判断是否是最后一次
799
+ let forEachCount = 0
800
+
801
+ // 标记所有数据
802
+ rowArr.forEach((cell) => {
803
+ forEachCount++
804
+ // 如果该行没有rowspan则默认其为1,不要影响统计结果
805
+ if (!cell.rowSpan) {
806
+ cell.rowSpan = 0
807
+ }
808
+
809
+ if (cell.text && total !== 0) {
810
+ // 如果遇到了下一个声明行,证明rowspan少了一行,需要补充一个占位格
811
+ const nullObj = {
812
+ type: 'placeHolderColumn',
813
+ order: subRowIndex,
814
+ noBoarder: true,
815
+ needSplit: true,
816
+ colSpan: preColSpan,
817
+ dontShowRow: true,
818
+ }
819
+ subRowIndex++
820
+ waitForAddArr.push(nullObj)
821
+ total = 0
822
+ count = 0
823
+ titleCellFlag = false
824
+ firstSubLine = false
825
+ } else if (
826
+ total !== count + cell.rowSpan &&
827
+ forEachCount === rowArr.length
828
+ ) {
829
+ // 如果没有遇到了下一个声明行,但已经是当前行最后一个数据,也证明rowspan少了一行,需要补充一个占位格
830
+ const nullObj = {
831
+ type: 'placeHolderColumn',
832
+ order: subRowIndex,
833
+ noBoarder: true,
834
+ needSplit: true,
835
+ colSpan: preColSpan,
836
+ dontShowRow: true,
837
+ }
838
+ subRowIndex++
839
+ waitForAddArr.push(nullObj)
840
+ total = 0
841
+ count = 0
842
+ titleCellFlag = false
843
+ firstSubLine = false
844
+ }
845
+
846
+ // 判断是否为声明行
847
+ if (cell.text && total === 0) {
848
+ // 将声明行声明的rowspan作为总数,判断下方rowspan相加是否等于声明行声明的数量
849
+ total = cell.rowSpan
850
+ titleCellFlag = false
851
+ firstSubLine = true
852
+ subRowIndex = 1
853
+ cell.show = true
854
+ cell.showRowSpan = total
855
+ } else if (cell.rowSpan > 0 && !titleCellFlag && firstSubLine) {
856
+ // 判断是否为声明行后首行,因为首行不需要移动
857
+ count += cell.rowSpan
858
+ firstSubLine = false
859
+ cell.noBoarder = true
860
+ cell.show = true
861
+ cell.showRowSpan = total
862
+ } else if (cell.rowSpan > 0 && !titleCellFlag && !firstSubLine) {
863
+ // 既非声明行,也非首行,需要移动
864
+ count += cell.rowSpan
865
+ // cell.type = 'notShow'
866
+ cell.needSplit = true
867
+ cell.order = subRowIndex
868
+ cell.dontShowRow = true
869
+ subRowIndex++
870
+
871
+ // 如果之前添加过空行补充位置,刚好最后一位还有内容,将其互换
872
+ if (
873
+ forEachCount === rowArr.length &&
874
+ !waitForAddArr[waitForAddArr.length - 1].dataIndex
875
+ ) {
876
+ waitForAddArr[waitForAddArr.length - 1].order += 1
877
+ cell.order -= 1
878
+ waitForAddArr.push(cell)
879
+ } else {
880
+ waitForAddArr.push(cell)
881
+ }
882
+ }
883
+
884
+ // 如果count和total相等了,证明已经处理完成。将计数器还原
885
+ if (count === total) {
886
+ total = 0
887
+ count = 0
888
+ titleCellFlag = false
889
+ firstSubLine = false
890
+ }
891
+ // 保存上一个的colspan保持生成的格子与原格式一致
892
+ preColSpan = cell.colSpan
893
+ })
894
+
895
+ // 将所有不需要移动的放入original
896
+ rowArr.forEach((cell) => {
897
+ if (cell.needSplit !== true) {
898
+ original.push(cell)
899
+ }
900
+ })
901
+
902
+ // 增加新的数组
903
+ waitForAddArr.forEach((cell) => {
904
+ const target = cell.order
905
+ // if (cell.type === 'notShow') {
906
+ // cell.type = 'inputs'
907
+ // }
908
+ cell.noBoarder = true
909
+ if (addArr[target] === undefined) {
910
+ const temp = []
911
+ temp.push(cell)
912
+ addArr[target] = temp
913
+ } else if (addArr[target].length > 0) {
914
+ addArr[target].push(cell)
915
+ }
916
+ })
917
+
918
+ // 如果没有新增,将单元格边框设置为显示
919
+ if (addArr.length < 1) {
920
+ original.forEach((cell) => {
921
+ if (cell.type === 'input' || cell.type === 'inputs') {
922
+ cell.noBoarder = false
923
+ }
924
+ })
925
+ }
926
+
927
+ return {
928
+ old: original,
929
+ add: addArr,
930
+ }
931
+ },
932
+ // 扫描配置,如果有插槽则拼接插槽
933
+ scanConfigSlot (config) {
934
+ const columnsArr = config.columns
935
+ for (let i = 0; i < columnsArr.length; i++) {
936
+ for (let j = 0; j < columnsArr[i].length; j++) {
937
+ // 如果发现type为slot,开始匹配对应的slot配置文件
938
+ if (columnsArr[i][j].type === 'slot') {
939
+ const targetName = columnsArr[i][j].slotConfig
940
+ // 找不到目标插槽配置
941
+ if (
942
+ !this.configFromWeb[targetName] ||
943
+ !this.configFromWeb[targetName].columns
944
+ ) {
945
+ this.$logger('report.slotConfig').error('无法找到目标插槽的配置!')
946
+ return
947
+ }
948
+
949
+ // 替换columns,合并data
950
+ config.columns[i] = []
951
+ const before = config.columns.slice(0, i)
952
+ let after = config.columns.slice(i + 1, config.columns.length)
953
+
954
+ const addArr = []
955
+ for (
956
+ let k = 0;
957
+ k < this.configFromWeb[targetName].columns.length;
958
+ k++
959
+ ) {
960
+ const temp = []
961
+ this.configFromWeb[targetName].columns[k].forEach((cell) => {
962
+ temp.push(cell)
963
+ })
964
+ addArr.push(temp)
965
+ }
966
+
967
+ const newArr = []
968
+ // 拼接之前的数组
969
+ if (before.length > 0) {
970
+ if (before.length >= 1) {
971
+ before.forEach((item) => {
972
+ newArr.push(item)
973
+ })
974
+ } else {
975
+ newArr.push(before)
976
+ }
977
+ }
978
+
979
+ addArr.forEach((arr) => {
980
+ newArr.push(arr)
981
+ })
982
+
983
+ // 拼接之后的数组
984
+ if (after.length === 1) {
985
+ if (after[0].type === 'slot' || after[0][0].type === 'slot') {
986
+ after = []
987
+ }
988
+ }
989
+ if (after.length > 0) {
990
+ if (after.length >= 1) {
991
+ after.forEach((item) => {
992
+ newArr.push(item)
993
+ })
994
+ } else {
995
+ newArr.push(after)
996
+ }
997
+ }
998
+
999
+ config.columns = newArr
1000
+ if (this.configFromWeb[targetName].slotsDeclare) {
1001
+ config.slotsDeclare = this.configFromWeb[targetName].slotsDeclare
1002
+ } else {
1003
+ config.slotsDeclare = []
1004
+ }
1005
+
1006
+ if (
1007
+ config.data.images &&
1008
+ this.configFromWeb[targetName].data.images
1009
+ ) {
1010
+ config.data.images = {
1011
+ ...config.data.images,
1012
+ ...this.configFromWeb[targetName].data.images,
1013
+ }
1014
+ delete this.configFromWeb[targetName].data.images
1015
+ }
1016
+ config.data = {
1017
+ ...config.data,
1018
+ ...this.configFromWeb[targetName].data,
1019
+ }
1020
+ }
1021
+ }
1022
+ }
1023
+ this.config = config
1024
+ },
1025
+ // 扫描所有插槽名
1026
+ scanConfigName (config, resut) {
1027
+ if (config.slotsDeclare) {
1028
+ config.slotsDeclare.forEach((name) => {
1029
+ resut.push(name)
1030
+ })
1031
+ }
1032
+ },
1033
+ // 获取插槽
1034
+ getConfigAndJoin (config, outerLock) {
1035
+ // 检查主配置插槽声明是否合法
1036
+ const check = this.checkSlotDefine(config)
1037
+ const waitForDownloadSlotName = []
1038
+ if (check) {
1039
+ // 扫描主配置中声明的插槽名
1040
+ this.scanConfigName(config, waitForDownloadSlotName)
1041
+
1042
+ const total = waitForDownloadSlotName.length
1043
+ let count = 0
1044
+
1045
+ // 挨个获取插槽
1046
+ waitForDownloadSlotName.forEach((configName) => {
1047
+ getConfigByName(
1048
+ configName,
1049
+ this.serverName,
1050
+ (res) => {
1051
+ this.configFromWeb[configName] = res
1052
+ count++
1053
+ },
1054
+ this.env === 'dev'
1055
+ )
1056
+ })
1057
+
1058
+ // 使用定时器循环判断锁状态,用于多个插槽,要等待统一获取完成之后,再进行下一步初始化
1059
+ const timer = setInterval(() => {
1060
+ if (count >= total) {
1061
+ clearInterval(timer)
1062
+ this.scanConfigSlot(config)
1063
+ if (config.slotsDeclare.length > 0) {
1064
+ const lock = { status: true }
1065
+ this.getConfigAndJoin(config, lock)
1066
+ const innerTimer = setInterval(() => {
1067
+ if (!lock.status) {
1068
+ clearInterval(innerTimer)
1069
+ outerLock.status = false
1070
+ }
1071
+ }, 100)
1072
+ } else {
1073
+ outerLock.status = false
1074
+ }
1075
+ }
1076
+ }, 100)
1077
+ } else {
1078
+ this.$logger('report.slotConfig').error('插槽配置有误!')
1079
+ outerLock.status = false
1080
+ }
1081
+ },
1082
+ // 获取配置之后的初始化
1083
+ configInit () {
1084
+ this.configEnded = false
1085
+ this.allSlotsConfigEnded = false
1086
+ this._configEndPromise = new Promise(resolve => { this._configEndResolve = resolve })
1087
+ // 将初始化好的配置拷贝一份留存
1088
+ this.originalConfig = Object.assign({}, this.config)
1089
+ if (!this.dontFormat) {
1090
+ // 扫描配置文件中有没有rowSpan,进行格式化调整
1091
+ this.formatConfigRow(this.config)
1092
+ }
1093
+ this.activeConfig = this.config
1094
+ this.showSkeleton = false
1095
+ // 判断是否有动态Index
1096
+ this.activeConfig.columns.forEach((row) => {
1097
+ row.forEach((cell) => {
1098
+ if (cell.dynamicDataIndex === true) {
1099
+ // 如果有动态index,取其函数,运行函数得到真实index保存
1100
+ // eslint-disable-next-line no-eval
1101
+ const func = eval(
1102
+ '(' + cell.customFunctionForDynamicDataIndex + ')'
1103
+ )
1104
+ cell.dataIndex = func(this.config)
1105
+ }
1106
+ // 处理 自定义函数的旧逻辑
1107
+ if (
1108
+ ['action', 'click'].includes(cell.eventType) &&
1109
+ cell.customFunction &&
1110
+ !cell.events
1111
+ ) {
1112
+ cell.events = []
1113
+ cell.events.push({
1114
+ type: cell.eventType,
1115
+ customFunction: cell.customFunction,
1116
+ })
1117
+ }
1118
+ })
1119
+ })
1120
+ // 将数据复制到临时数据中,带有@@@的数据,我们将其整体作为一个key保存,当编辑完成后,再将其解析,回填到需要的数据中
1121
+ this.activeConfig.tempData = {}
1122
+ // 是否有@@@深层引用
1123
+ this.activeConfig.columns.forEach((row) => {
1124
+ row.forEach((cell) => {
1125
+ // 将@@@解析
1126
+ if (
1127
+ cell.dataIndex !== undefined &&
1128
+ cell.dataIndex.indexOf('@@@') !== -1
1129
+ ) {
1130
+ this.activeConfig.tempData[cell.dataIndex] = this.getDeepObject(
1131
+ this.activeConfig.data,
1132
+ cell.dataIndex
1133
+ )
1134
+ }
1135
+ })
1136
+ })
1137
+
1138
+ // 对配置进行转换
1139
+ this.originalConfig.columns = this.transformArray(
1140
+ JSON.parse(JSON.stringify(this.config.columns))
1141
+ )
1142
+
1143
+ this.$nextTick(() => {
1144
+ this.scanFinish = true
1145
+ // 无 slot 时不会触发 slotRendered,在此视为配置彻底结束
1146
+ if (!this.config?.slotsDeclare?.length) {
1147
+ this._markConfigEnded()
1148
+ }
1149
+ })
1150
+ },
1151
+ },
1152
+ beforeMount () {
1153
+ // 如果只是展示
1154
+ if (this.displayOnly) {
1155
+ this.onlyDisplay = true
1156
+ this.type = 'display'
1157
+ }
1158
+ // 如果有本地配置,优先使用本地配置
1159
+ if (this.localConfig) {
1160
+ // 如果配置是普通渲染器
1161
+ this.config = this.localConfig
1162
+ if (this.configData !== undefined) {
1163
+ this.config.data = this.configData
1164
+ }
1165
+ if (this.config.data.images === undefined) {
1166
+ this.config.data.images = {}
1167
+ }
1168
+ this.configInit()
1169
+ this.$logger('report.beforeMount').log('本地 config 就绪', { configName: this.configName })
1170
+ } else {
1171
+ // 如果本地配置没有值,则从琉璃中获取
1172
+ getConfigByName(
1173
+ this.configName,
1174
+ this.serverName,
1175
+ (res) => {
1176
+ this.config = JSON.parse(JSON.stringify(res))
1177
+ if (this.configData !== undefined) {
1178
+ this.config.data = this.configData
1179
+ }
1180
+ if (this.config.data.images === undefined) {
1181
+ this.config.data.images = {}
1182
+ }
1183
+ this.configInit()
1184
+ this.$logger('report.beforeMount').log('远程 config 加载完成', { configName: this.configName })
1185
+ },
1186
+ this.env === 'dev'
1187
+ )
1188
+ }
1189
+ },
1190
+ computed: {
1191
+ ...mapState('account', { currUser: 'user' }),
1192
+ widget () {
1193
+ return this.isWidget // 返回isWidget的值
1194
+ },
1195
+ },
1196
+ mounted () {
1197
+ // 如果外界传来了registerMap,我们将本VM对象注册到map中
1198
+ if (this.registerMap !== undefined) {
1199
+ this.registerMap.push(this)
1200
+ }
1201
+ // TAB 页签的 slotRef 由 XTab 在 onComponentMounted 中统一注册(与 Cover 普通子组件一致),此处不再自我注册
1202
+ // 将原始数据备份保存
1203
+ if (this.configData) {
1204
+ this.dataCache = JSON.parse(JSON.stringify(this.configData))
1205
+ } else {
1206
+ if (this.config?.data) {
1207
+ this.dataCache = JSON.parse(JSON.stringify(this.config.data))
1208
+ }
1209
+ }
1210
+ },
1211
+ }
1212
+ </script>
1213
+
1214
+ <style lang="less" scoped>
1215
+ .tools {
1216
+ text-align: center;
1217
+ cursor: pointer;
1218
+
1219
+ .toolsItem {
1220
+ display: inline-block;
1221
+ }
1222
+ }
1223
+ </style>