vue2-client 1.8.310 → 1.8.311

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 (215) hide show
  1. package/.env +19 -19
  2. package/.eslintrc.js +90 -90
  3. package/CHANGELOG.md +824 -824
  4. package/Components.md +60 -60
  5. package/babel.config.js +21 -21
  6. package/docs/LowCode/lowcode.md +155 -155
  7. package/docs/LowCode/lowcodeForDeveloper.md +230 -230
  8. package/docs/index.md +30 -30
  9. package/index.js +31 -31
  10. package/jest-transform-stub.js +8 -8
  11. package/jest.config.js +21 -21
  12. package/jest.setup.js +7 -7
  13. package/package.json +97 -97
  14. package/public/index.html +27 -27
  15. package/src/App.vue +188 -188
  16. package/src/ReportView.js +19 -19
  17. package/src/assets/img/querySlotDemo.svg +15 -15
  18. package/src/assets/svg/badtwo.svg +1 -1
  19. package/src/assets/svg/goodtwo.svg +1 -1
  20. package/src/base-client/components/common/AMisRender/index.js +3 -3
  21. package/src/base-client/components/common/AMisRender/index.vue +263 -263
  22. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +438 -416
  23. package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
  24. package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
  25. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  26. package/src/base-client/components/common/CitySelect/CitySelect.vue +342 -342
  27. package/src/base-client/components/common/CitySelect/index.js +3 -3
  28. package/src/base-client/components/common/CitySelect/index.md +109 -109
  29. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  30. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  31. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  32. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  33. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  34. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  35. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  36. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  37. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  38. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  39. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  40. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  41. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  42. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  43. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  44. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
  45. package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +350 -350
  46. package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
  47. package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +699 -699
  48. package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
  49. package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +162 -162
  50. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
  51. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
  52. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
  53. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
  54. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
  55. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
  56. package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
  57. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  58. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  59. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  60. package/src/base-client/components/common/Tree/index.js +2 -2
  61. package/src/base-client/components/common/Upload/Upload.vue +239 -239
  62. package/src/base-client/components/common/Upload/index.js +3 -3
  63. package/src/base-client/components/common/XAddForm/XAddForm.vue +105 -105
  64. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +807 -807
  65. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  66. package/src/base-client/components/common/XAddNativeForm/lowcodeEditorRegister.js +16 -16
  67. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
  68. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  69. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  70. package/src/base-client/components/common/XBadge/XBadge.vue +78 -78
  71. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  72. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  73. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  74. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  75. package/src/base-client/components/common/XDescriptions/XDescriptions.vue +187 -187
  76. package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +306 -306
  77. package/src/base-client/components/common/XDescriptions/demo.vue +50 -50
  78. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  79. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  80. package/src/base-client/components/common/XDescriptions/lowcodeEditorRegister.js +31 -31
  81. package/src/base-client/components/common/XDetailsView/XDetailsView.vue +214 -214
  82. package/src/base-client/components/common/XDetailsView/index.js +3 -3
  83. package/src/base-client/components/common/XForm/XForm.vue +294 -294
  84. package/src/base-client/components/common/XForm/XFormItem.vue +911 -911
  85. package/src/base-client/components/common/XForm/XTreeSelect.vue +207 -207
  86. package/src/base-client/components/common/XForm/index.md +178 -178
  87. package/src/base-client/components/common/XFormCol/XFormCol.vue +36 -36
  88. package/src/base-client/components/common/XFormGroup/XFormGroup.vue +241 -241
  89. package/src/base-client/components/common/XFormGroup/demo.vue +40 -40
  90. package/src/base-client/components/common/XFormGroup/index.js +3 -3
  91. package/src/base-client/components/common/XFormGroup/index.md +38 -38
  92. package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
  93. package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
  94. package/src/base-client/components/common/XFormTable/XFormTable.vue +539 -539
  95. package/src/base-client/components/common/XFormTable/demo.vue +72 -72
  96. package/src/base-client/components/common/XFormTable/index.md +98 -98
  97. package/src/base-client/components/common/XFormTable/lowcodeEditorRegister.js +30 -30
  98. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +147 -147
  99. package/src/base-client/components/common/XReport/XReport.vue +858 -858
  100. package/src/base-client/components/common/XReport/XReportDemo.vue +266 -266
  101. package/src/base-client/components/common/XReport/XReportDesign.vue +509 -509
  102. package/src/base-client/components/common/XReport/XReportJsonRender.vue +295 -295
  103. package/src/base-client/components/common/XReport/XReportTrGroup.vue +801 -801
  104. package/src/base-client/components/common/XReport/index.js +3 -3
  105. package/src/base-client/components/common/XReport/index.md +44 -44
  106. package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
  107. package/src/base-client/components/common/XReportSlot/index.js +3 -3
  108. package/src/base-client/components/common/XReportSlot/index.md +48 -48
  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/XTable.vue +676 -676
  113. package/src/base-client/components/common/XTable/index.md +255 -255
  114. package/src/base-client/components/common/XTree/XTree.vue +423 -423
  115. package/src/base-client/components/common/XTree/index.js +3 -3
  116. package/src/base-client/components/common/XTree/index.md +36 -36
  117. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +114 -114
  118. package/src/base-client/components/common/XTreeOne/lowcodeEditorRegister.js +11 -11
  119. package/src/base-client/components/index.js +51 -51
  120. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  121. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  122. package/src/base-client/plugins/AppData.js +121 -121
  123. package/src/base-client/plugins/Config.js +19 -19
  124. package/src/base-client/plugins/GetLoginInfoService.js +183 -183
  125. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  126. package/src/bootstrap.js +39 -39
  127. package/src/components/FilePreview/FilePreview.vue +166 -166
  128. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  129. package/src/components/STable/index.js +361 -361
  130. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  131. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  132. package/src/components/menu/SideMenu.vue +75 -75
  133. package/src/components/menu/menu.js +273 -273
  134. package/src/components/tool/AStepItem.vue +60 -60
  135. package/src/config/default/antd.config.js +89 -89
  136. package/src/config/default/setting.config.js +55 -55
  137. package/src/font-style/font.css +4 -4
  138. package/src/layouts/CommonLayout.vue +56 -56
  139. package/src/layouts/PageLayout.vue +151 -151
  140. package/src/layouts/SinglePageView.vue +138 -138
  141. package/src/layouts/header/AdminHeader.vue +132 -132
  142. package/src/layouts/header/HeaderNotice.vue +177 -177
  143. package/src/layouts/tabs/TabsHead.vue +189 -189
  144. package/src/layouts/tabs/TabsView.vue +387 -387
  145. package/src/lib.js +1 -1
  146. package/src/main.js +26 -26
  147. package/src/mock/extend/index.js +84 -84
  148. package/src/mock/goods/index.js +108 -108
  149. package/src/pages/AMisDemo/AMisDemo.vue +325 -325
  150. package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
  151. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  152. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  153. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  154. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  155. package/src/pages/DynamicStatistics/FavoriteList.vue +51 -51
  156. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  157. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  158. package/src/pages/DynamicStatistics/index.vue +282 -282
  159. package/src/pages/Example/index.vue +33 -33
  160. package/src/pages/ServiceReview/index.vue +284 -284
  161. package/src/pages/XReportView/index.vue +62 -62
  162. package/src/pages/login/Login.vue +378 -378
  163. package/src/pages/login/LoginV3.vue +389 -389
  164. package/src/pages/lowCode/lowCodeEditor.vue +1030 -1030
  165. package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
  166. package/src/pages/resourceManage/orgListManage.vue +98 -98
  167. package/src/pages/system/dictionary/index.vue +44 -44
  168. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  169. package/src/pages/system/monitor/operLog/index.vue +37 -37
  170. package/src/pages/system/settings/modifyPassword.vue +117 -117
  171. package/src/pages/system/ticket/index.vue +480 -480
  172. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  173. package/src/router/async/config.async.js +34 -34
  174. package/src/router/async/router.map.js +104 -104
  175. package/src/router/guards.js +223 -223
  176. package/src/router/index.js +27 -27
  177. package/src/router.js +19 -19
  178. package/src/services/api/TicketDetailsViewApi.js +46 -46
  179. package/src/services/api/cas.js +79 -79
  180. package/src/services/api/common.js +307 -307
  181. package/src/services/api/entity.js +18 -18
  182. package/src/services/api/index.js +17 -17
  183. package/src/services/api/restTools.js +46 -46
  184. package/src/services/apiService.js +14 -14
  185. package/src/services/user.js +71 -71
  186. package/src/services/v3Api.js +81 -81
  187. package/src/store/modules/index.js +5 -5
  188. package/src/store/modules/lowCode.js +33 -33
  189. package/src/store/modules/setting.js +119 -119
  190. package/src/theme/default/style.less +58 -58
  191. package/src/theme/global.less +139 -139
  192. package/src/utils/authority-utils.js +85 -85
  193. package/src/utils/errorCode.js +6 -6
  194. package/src/utils/formatter.js +80 -80
  195. package/src/utils/htmlToPDF.js +108 -108
  196. package/src/utils/htmlToPDFApi.js +5 -5
  197. package/src/utils/indexedDB.js +258 -258
  198. package/src/utils/login.js +188 -188
  199. package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
  200. package/src/utils/lowcode/lowcodeLog.js +29 -29
  201. package/src/utils/lowcode/lowcodeUtils.js +373 -373
  202. package/src/utils/lowcode/registerComponentForEditor.js +11 -11
  203. package/src/utils/lowcode/registerComponentForRender.js +11 -11
  204. package/src/utils/map-utils.js +47 -47
  205. package/src/utils/reg.js +95 -95
  206. package/src/utils/request.js +347 -347
  207. package/src/utils/routerUtil.js +435 -435
  208. package/src/utils/runEvalFunction.js +6 -6
  209. package/src/utils/util.js +241 -241
  210. package/src/utils/waterMark.js +31 -31
  211. package/test/Amis.spec.js +163 -163
  212. package/test/Tree.spec.js +167 -167
  213. package/test/myDialog.spec.js +46 -46
  214. package/vue.config.js +181 -181
  215. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,858 +1,858 @@
1
- <template>
2
- <div>
3
- <!-- 骨架屏 -->
4
- <a-card v-if="showSkeleton">
5
- <a-skeleton active/>
6
- </a-card>
7
- <template v-if="noPadding">
8
- <!-- 主体表格 -->
9
- <XReportDesign
10
- @updateImg="updateImg"
11
- v-if="scanFinish"
12
- :show-img-in-cell="showImgInCell"
13
- :img-prefix="imgPrefix"
14
- :use-oss-for-img="useOssForImg"
15
- :display-only="displayOnly"
16
- :config="type === 'display' ? originalConfig : activeConfig"
17
- :slot-config-name="type === 'display' ? undefined : activatedSlotName"
18
- :for-display="type === 'display'"
19
- ref="XReportDesign"
20
- id="printReady"
21
- :server-name="serverName"
22
- :show-title="showTitle"
23
- :no-padding="noPadding"
24
- :no-top-border="noTopBorder"
25
- :show-images="hasImages"
26
- :image-list="imageList">
27
- </XReportDesign>
28
- </template>
29
- <template v-else>
30
- <!-- 用以包裹整个页面 -->
31
- <a-card v-if="!showSkeleton">
32
- <!-- 切换菜单 -->
33
- <a-radio-group v-model="type" default-value="a" button-style="solid" @change="tabChanged" v-show="!onlyDisplay && editMode">
34
- <a-radio-button value="design" v-if="!onlyDisplay">
35
- 设计
36
- </a-radio-button>
37
- <a-radio-button value="display" style="border-radius: 0">
38
- 预览
39
- </a-radio-button>
40
- </a-radio-group>
41
- <a-radio-button @click="saveConfig" style="border-radius: 0 4px 4px 0" v-if="showSaveButton">
42
- 保存
43
- </a-radio-button>
44
- <!-- 主体表格 -->
45
- <XReportDesign
46
- v-if="scanFinish"
47
- @updateImg="updateImg"
48
- :show-img-in-cell="showImgInCell"
49
- :img-prefix="imgPrefix"
50
- :use-oss-for-img="useOssForImg"
51
- :display-only="displayOnly"
52
- :config="type === 'display' ? originalConfig : activeConfig"
53
- :slot-config-name="type === 'display' ? undefined : activatedSlotName"
54
- :for-display="type === 'display'"
55
- :no-padding="noPadding"
56
- :no-top-border="noTopBorder"
57
- :show-title="showTitle"
58
- ref="XReportDesign"
59
- id="printReady"
60
- :server-name="serverName"
61
- :show-images="hasImages"
62
- :image-list="imageList">
63
- </XReportDesign>
64
- <!-- 导出按钮 -->
65
- <template v-if="type === 'display'">
66
- <div class="tools">
67
- <div class="toolsItem" @click="exportPDF">
68
- <a-button type="primary">
69
- 导出PDF
70
- </a-button>
71
- </div>
72
- </div>
73
- </template>
74
- </a-card>
75
- </template>
76
- </div>
77
- </template>
78
-
79
- <script>
80
- // 转PDF用
81
- import HtmlToPdf from '@vue2-client/utils/htmlToPDF'
82
- import { getConfigByName } from '@vue2-client/services/api/common'
83
- import XReportDesign from '@vue2-client/base-client/components/common/XReport/XReportDesign.vue'
84
-
85
- export default {
86
- name: 'XReport',
87
- props: {
88
- files: {
89
- type: Array,
90
- default: () => {
91
- return []
92
- }
93
- },
94
- // 控制用户权限,user和admin
95
- authority: {
96
- type: String,
97
- default: 'user'
98
- },
99
- // 是否为编辑模式
100
- editMode: {
101
- type: Boolean,
102
- default: true
103
- },
104
- // 配置名
105
- configName: {
106
- type: String,
107
- required: true
108
- },
109
- // 插槽名
110
- activatedSlotName: {
111
- type: String,
112
- default: undefined
113
- },
114
- // 本地配置,调试用
115
- localConfig: {
116
- type: Object,
117
- default: undefined
118
- },
119
- // 兼容老版本配置
120
- dontFormat: {
121
- type: Boolean,
122
- default: true
123
- },
124
- showImgInCell: {
125
- type: Boolean,
126
- default: false
127
- },
128
- // 数据
129
- configData: {
130
- type: Object,
131
- default: undefined
132
- },
133
- // 命名空间
134
- serverName: {
135
- type: String,
136
- default: 'af-system'
137
- },
138
- // 只做展示
139
- displayOnly: {
140
- type: Boolean,
141
- default: false
142
- },
143
- // 表格没有边距
144
- noPadding: {
145
- type: Boolean,
146
- default: false
147
- },
148
- // 表格没有上边框,与noPadding搭配可以实现连续表格
149
- noTopBorder: {
150
- type: Boolean,
151
- default: false
152
- },
153
- // 是否展示标题
154
- showTitle: {
155
- type: Boolean,
156
- default: true
157
- },
158
- // 是否展示保存按钮
159
- showSaveButton: {
160
- type: Boolean,
161
- default: true
162
- },
163
- // 是否将组件注册到外层提供的容器中,方便外侧统一保存
164
- registerMap: {
165
- type: Array,
166
- default: undefined
167
- },
168
- // 图片是否使用OSS来保存
169
- useOssForImg: {
170
- type: Boolean,
171
- default: true
172
- },
173
- // 图片上传后添加前缀
174
- imgPrefix: {
175
- type: String,
176
- default: undefined
177
- }
178
- },
179
- components: {
180
- XReportDesign
181
- },
182
- data () {
183
- return {
184
- // 控制骨架屏显隐
185
- showSkeleton: true,
186
- // 配置
187
- config: undefined,
188
- // 当前显示模式,编辑模式,预览模式
189
- type: 'design',
190
- // 仅供展示,不可编辑
191
- onlyDisplay: false,
192
- // 每行最大列数,非必要请勿更改,现在的设计器完全是基于每行12列来设计的
193
- maxColSpan: 12,
194
- // 定义是否完成配置的扫描,未完成不要渲染子组件
195
- scanFinish: false,
196
- // 当前激活的配置文件
197
- activeConfig: null,
198
- // 原始配置文件
199
- // 用于展示。某些情况下“设计页”中的内容仅为“预览页”表格其中的一部分
200
- originalConfig: null,
201
- // 扫描到的配置
202
- configFromWeb: {},
203
- // 用于获取配置的锁
204
- timer: undefined,
205
- // 是否包含图片
206
- hasImages: false,
207
- // 图片列表
208
- imageList: [],
209
- // 保存最原始的数据,用于判断哪些数据被更改了
210
- dataCache: undefined,
211
- // 判断哪些数据被更改了,存储对应的key
212
- diff: []
213
- }
214
- },
215
- watch: {
216
- // 如果配置名更改了,重新获取配置
217
- configName (val) {
218
- if (val) {
219
- getConfigByName(this.configName, undefined, res => {
220
- this.config = res
221
- this.configInit()
222
- })
223
- }
224
- },
225
- // 如果本地配置更改了,重新初始化
226
- localConfig (val) {
227
- if (val) {
228
- this.config = val
229
- this.configInit()
230
- }
231
- }
232
- },
233
- methods: {
234
- // 向外暴露图片修改后的数据,某些外部需要自己管理图片的保存与修改
235
- updateImg (data) {
236
- this.$emit('updateImg', data)
237
- },
238
- // 导出数据,某些外部需要统一控制数据的变动
239
- exportData () {
240
- // 获取当前修改后的数据
241
- let tempData
242
- if (this.activeConfig === undefined || this.activeConfig === null) {
243
- tempData = this.originalConfig.data
244
- } else {
245
- const tempDataKeys = Object.keys(this.activeConfig.tempData)
246
- tempDataKeys.forEach(key => {
247
- this.changeDeepObject(this.activeConfig.data, key, this.activeConfig.tempData[key])
248
- })
249
- tempData = this.activeConfig.data
250
- }
251
- // 对比数据的差异
252
- this.diff = []
253
- this.compareProps(tempData, this.dataCache)
254
- this.diff.forEach(eachDiff => {
255
- const arr = eachDiff.split('.')
256
- let targetData = tempData[arr[0]]
257
- if (arr.length !== 1) {
258
- for (let i = 1; i < arr.length - 1; i++) {
259
- const path = arr[i]
260
- targetData = targetData[path]
261
- }
262
- }
263
- // 将修改的数据,添加update = true属性
264
- targetData.update = true
265
- })
266
- return tempData
267
- },
268
- // 对比两个obj有哪里不同
269
- compareProps (obj1, obj2, path = '') {
270
- for (const key in obj1) {
271
- // 如果一个是undefined
272
- if (typeof obj2[key] === 'undefined') {
273
- this.diff.push(path + key)
274
- // 如果是数组长度不一样
275
- } else if (Array.isArray(obj1) && Array.isArray(obj2)) {
276
- if (obj1[key].length !== obj2[key].length) {
277
- this.diff.push(path + key)
278
- }
279
- // 如果都是对象,并且存在同样的key,递归子key
280
- } else if (typeof obj1[key] === 'object' && typeof obj2[key] === 'object') {
281
- this.compareProps(obj1[key], obj2[key], path + key + '.')
282
- // 如果不是obj,对比其数据
283
- } else if (obj1[key] !== obj2[key]) {
284
- this.diff.push(path + key)
285
- }
286
- }
287
- },
288
- // 正常的保存方法,当前修改内容会直接全部导出到外部
289
- saveConfig () {
290
- if (this.activeConfig === undefined || this.activeConfig === null) {
291
- return this.originalConfig.data
292
- } else {
293
- const tempDataKeys = Object.keys(this.activeConfig.tempData)
294
- tempDataKeys.forEach(key => {
295
- this.changeDeepObject(this.activeConfig.data, key, this.activeConfig.tempData[key])
296
- })
297
- this.$emit('saveConfig', this.$refs.XReportDesign.activatedConfig)
298
- }
299
- },
300
- // 通过@@@分割临时变量,找到对应的key,并修改它的值
301
- changeDeepObject (obj, strPath, newVal) {
302
- const arr = strPath.split('@@@')
303
- if (obj[arr[0]] === undefined) {
304
- obj = obj.images
305
- }
306
- if (arr.length === 1) {
307
- obj[arr[0]] = newVal
308
- } else {
309
- let result = obj[arr[0]]
310
- arr.shift()
311
- while (arr.length > 1) {
312
- result = result[arr[0]]
313
- arr.shift()
314
- }
315
- result[arr[0]] = newVal
316
- }
317
- },
318
- // 检查slot是否在配置文件中包含,如果没有包含,则视为非法获取
319
- checkSlotDefine (config) {
320
- const slotsDeclare = config.slotsDeclare
321
- const total = slotsDeclare.length
322
- let count = 0
323
- slotsDeclare.forEach(declare => {
324
- config.columns.forEach(row => {
325
- row.forEach(cell => {
326
- if (cell.slotConfig === declare) {
327
- count++
328
- }
329
- })
330
- })
331
- })
332
-
333
- return count === total
334
- },
335
- // 切换了标签页
336
- tabChanged (key) {
337
- this.scanFinish = false
338
- this.originalConfig.data = { ...this.originalConfig.data, ...this.config.data }
339
- this.config.data = this.originalConfig.data
340
- if (this.type === 'display') {
341
- const tempDataKeys = Object.keys(this.activeConfig.tempData)
342
- tempDataKeys.forEach(key => {
343
- this.changeDeepObject(this.activeConfig.data, key, this.activeConfig.tempData[key])
344
- })
345
- let count = 0
346
- this.imageList = []
347
- const keys = Object.keys(this.config.data.images)
348
- keys.forEach(key => {
349
- if (this.config.data.images[key].length > 0) {
350
- this.imageList = [...this.imageList, ...this.config.data.images[key]]
351
- count++
352
- }
353
- })
354
- this.hasImages = count > 0
355
- } else {
356
- this.hasImages = false
357
- }
358
- this.$nextTick(() => {
359
- this.scanFinish = true
360
- })
361
- },
362
- // 获取当前日期,为保存文件命名用
363
- getDate () {
364
- const currentDate = new Date()
365
-
366
- const year = currentDate.getFullYear()
367
- const month = String(currentDate.getMonth() + 1).padStart(2, '0')
368
- const day = String(currentDate.getDate()).padStart(2, '0')
369
-
370
- const formattedDate = `${year}_${month}_${day}`
371
-
372
- return formattedDate
373
- },
374
- // 导出PDF
375
- exportPDF () {
376
- const date = this.getDate()
377
- let title = this.config.title
378
- title = title.replace(/<[^>]+>/g, '')
379
- const fileName = date + '' + title
380
- HtmlToPdf.getPdf(fileName, '#printReady')
381
- },
382
- // 用于分割配置中的colums,将需要处理的数组提取出来
383
- formatConfigRow () {
384
- for (let i = 0; i < this.config.columns.length; i++) {
385
- // 对原始数组进行递归,依次将该位置拆分为三个部分,当前处理位置之前的,当前处理位置,当前处理位置之后的
386
- const before = this.config.columns.slice(0, i)
387
- const after = this.config.columns.slice(i + 1, this.config.columns.length)
388
-
389
- // 将当前处理的数组交给处理的方法
390
- const x = this.checkRow(this.config.columns[i])
391
-
392
- const newArr = []
393
-
394
- // 拼接之前的数组
395
- if (before.length > 0) {
396
- if (before.length >= 1) {
397
- before.forEach(item => {
398
- newArr.push(item)
399
- })
400
- } else {
401
- newArr.push(before)
402
- }
403
- }
404
-
405
- // 拼接不需要更改当前节点处理完成的数组
406
- newArr.push(x.old)
407
-
408
- // 如果处理了新加的数据,拼接
409
- if (x.add.length > 0) {
410
- for (let j = 0; j < x.add.length; j++) {
411
- if (x.add[j]) {
412
- newArr.push(x.add[j])
413
- i++
414
- }
415
- }
416
- }
417
-
418
- // 拼接之后的数组
419
- if (after.length > 0) {
420
- if (after.length >= 1) {
421
- after.forEach(item => {
422
- newArr.push(item)
423
- })
424
- } else {
425
- newArr.push(after)
426
- }
427
- }
428
-
429
- this.config.columns = newArr
430
- }
431
- },
432
- // 路径中含有@@@的key,将其解析,并返回其数据
433
- getDeepObject (obj, strPath) {
434
- const arr = strPath.split('@@@')
435
- let result = obj[arr[0]]
436
- arr.shift()
437
- try {
438
- while (arr.length > 0) {
439
- result = result[arr[0]]
440
- arr.shift()
441
- }
442
- } catch (e) {
443
- result = undefined
444
- }
445
- return result
446
- },
447
- // 处理colums数组,为声明了rowspan的单元格,自动匹配格式
448
- checkRow (rowArr) {
449
- // 不需要更改的数据
450
- const original = []
451
- // 需要更改新加的数据
452
- const addArr = []
453
- // 统计rowspan出现的总和
454
- let count = 0
455
- // 统计声明列需要的rowspan总数
456
- let total = 0
457
- // 是否为声明行
458
- let titleCellFlag = false
459
- // 是否为声明行后第一行
460
- let firstSubLine = false
461
- // 需要处理的行,新的index值
462
- let subRowIndex = 0
463
- // 新生成的行,临时存储
464
- const waitForAddArr = []
465
- // 用于记录声明行的colspan避免格式错误
466
- let preColSpan = 0
467
- // 用于统计循环次数,判断是否是最后一次
468
- let forEachCount = 0
469
-
470
- // 标记所有数据
471
- rowArr.forEach(cell => {
472
- forEachCount++
473
- // 如果该行没有rowspan则默认其为1,不要影响统计结果
474
- if (!cell.rowSpan) {
475
- cell.rowSpan = 0
476
- }
477
-
478
- if (cell.text && total !== 0) { // 如果遇到了下一个声明行,证明rowspan少了一行,需要补充一个占位格
479
- const nullObj = {
480
- type: 'placeHolderColumn',
481
- order: subRowIndex,
482
- noBoarder: true,
483
- needSplit: true,
484
- colSpan: preColSpan,
485
- dontShowRow: true
486
- }
487
- subRowIndex++
488
- waitForAddArr.push(nullObj)
489
- total = 0
490
- count = 0
491
- titleCellFlag = false
492
- firstSubLine = false
493
- } else if ((total !== count + cell.rowSpan) && forEachCount === rowArr.length) {
494
- // 如果没有遇到了下一个声明行,但已经是当前行最后一个数据,也证明rowspan少了一行,需要补充一个占位格
495
- const nullObj = {
496
- type: 'placeHolderColumn',
497
- order: subRowIndex,
498
- noBoarder: true,
499
- needSplit: true,
500
- colSpan: preColSpan,
501
- dontShowRow: true
502
- }
503
- subRowIndex++
504
- waitForAddArr.push(nullObj)
505
- total = 0
506
- count = 0
507
- titleCellFlag = false
508
- firstSubLine = false
509
- }
510
-
511
- // 判断是否为声明行
512
- if (cell.text && total === 0) {
513
- // 将声明行声明的rowspan作为总数,判断下方rowspan相加是否等于声明行声明的数量
514
- total = cell.rowSpan
515
- titleCellFlag = false
516
- firstSubLine = true
517
- subRowIndex = 1
518
- cell.show = true
519
- cell.showRowSpan = total
520
- } else if (cell.rowSpan > 0 && !titleCellFlag && firstSubLine) { // 判断是否为声明行后首行,因为首行不需要移动
521
- count += cell.rowSpan
522
- firstSubLine = false
523
- cell.noBoarder = true
524
- cell.show = true
525
- cell.showRowSpan = total
526
- } else if (cell.rowSpan > 0 && !titleCellFlag && !firstSubLine) { // 既非声明行,也非首行,需要移动
527
- count += cell.rowSpan
528
- // cell.type = 'notShow'
529
- cell.needSplit = true
530
- cell.order = subRowIndex
531
- cell.dontShowRow = true
532
- subRowIndex++
533
-
534
- // 如果之前添加过空行补充位置,刚好最后一位还有内容,将其互换
535
- if (forEachCount === rowArr.length && !waitForAddArr[waitForAddArr.length - 1].dataIndex) {
536
- waitForAddArr[waitForAddArr.length - 1].order += 1
537
- cell.order -= 1
538
- waitForAddArr.push(cell)
539
- } else {
540
- waitForAddArr.push(cell)
541
- }
542
- }
543
-
544
- // 如果count和total相等了,证明已经处理完成。将计数器还原
545
- if (count === total) {
546
- total = 0
547
- count = 0
548
- titleCellFlag = false
549
- firstSubLine = false
550
- }
551
- // 保存上一个的colspan,保持生成的格子与原格式一致
552
- preColSpan = cell.colSpan
553
- })
554
-
555
- // 将所有不需要移动的放入original
556
- rowArr.forEach(cell => {
557
- if (cell.needSplit !== true) {
558
- original.push(cell)
559
- }
560
- })
561
-
562
- // 增加新的数组
563
- waitForAddArr.forEach(cell => {
564
- const target = cell.order
565
- // if (cell.type === 'notShow') {
566
- // cell.type = 'inputs'
567
- // }
568
- cell.noBoarder = true
569
- if (addArr[target] === undefined) {
570
- const temp = []
571
- temp.push(cell)
572
- addArr[target] = temp
573
- } else if (addArr[target].length > 0) {
574
- addArr[target].push(cell)
575
- }
576
- })
577
-
578
- // 如果没有新增,将单元格边框设置为显示
579
- if (addArr.length < 1) {
580
- original.forEach(cell => {
581
- if (cell.type === 'input' || cell.type === 'inputs') {
582
- cell.noBoarder = false
583
- }
584
- })
585
- }
586
-
587
- return {
588
- old: original,
589
- add: addArr
590
- }
591
- },
592
- // 扫描配置,如果有插槽则拼接插槽
593
- scanConfigSlot (config) {
594
- const columnsArr = config.columns
595
- for (let i = 0; i < columnsArr.length; i++) {
596
- for (let j = 0; j < columnsArr[i].length; j++) {
597
- // 如果发现type为slot,开始匹配对应的slot配置文件
598
- if (columnsArr[i][j].type === 'slot') {
599
- const targetName = columnsArr[i][j].slotConfig
600
- // 找不到目标插槽配置
601
- if (!this.configFromWeb[targetName] || !this.configFromWeb[targetName].columns) {
602
- console.error('无法找到目标插槽的配置!')
603
- return
604
- }
605
-
606
- // 替换columns,合并data
607
- config.columns[i] = []
608
- const before = config.columns.slice(0, i)
609
- let after = config.columns.slice(i + 1, config.columns.length)
610
-
611
- const addArr = []
612
- for (let k = 0; k < this.configFromWeb[targetName].columns.length; k++) {
613
- const temp = []
614
- this.configFromWeb[targetName].columns[k].forEach(cell => {
615
- temp.push(cell)
616
- })
617
- addArr.push(temp)
618
- }
619
-
620
- const newArr = []
621
- // 拼接之前的数组
622
- if (before.length > 0) {
623
- if (before.length >= 1) {
624
- before.forEach(item => {
625
- newArr.push(item)
626
- })
627
- } else {
628
- newArr.push(before)
629
- }
630
- }
631
-
632
- addArr.forEach(arr => {
633
- newArr.push(arr)
634
- })
635
-
636
- // 拼接之后的数组
637
- if (after.length === 1) {
638
- if (after[0].type === 'slot' || after[0][0].type === 'slot') {
639
- after = []
640
- }
641
- }
642
- if (after.length > 0) {
643
- if (after.length >= 1) {
644
- after.forEach(item => {
645
- newArr.push(item)
646
- })
647
- } else {
648
- newArr.push(after)
649
- }
650
- }
651
-
652
- config.columns = newArr
653
- if (this.configFromWeb[targetName].slotsDeclare) {
654
- config.slotsDeclare = this.configFromWeb[targetName].slotsDeclare
655
- } else {
656
- config.slotsDeclare = []
657
- }
658
-
659
- if (config.data.images && this.configFromWeb[targetName].data.images) {
660
- config.data.images = { ...config.data.images, ...this.configFromWeb[targetName].data.images }
661
- delete this.configFromWeb[targetName].data.images
662
- }
663
- config.data = { ...config.data, ...this.configFromWeb[targetName].data }
664
- }
665
- }
666
- }
667
- this.config = config
668
- },
669
- // 扫描所有插槽名
670
- scanConfigName (config, resut) {
671
- if (config.slotsDeclare) {
672
- config.slotsDeclare.forEach(name => {
673
- resut.push(name)
674
- })
675
- }
676
- },
677
- // 获取插槽
678
- getConfigAndJoin (config, outerLock) {
679
- // 检查主配置插槽声明是否合法
680
- const check = this.checkSlotDefine(config)
681
- const waitForDownloadSlotName = []
682
- if (check) {
683
- // 扫描主配置中声明的插槽名
684
- this.scanConfigName(config, waitForDownloadSlotName)
685
-
686
- const total = waitForDownloadSlotName.length
687
- let count = 0
688
-
689
- // 挨个获取插槽
690
- waitForDownloadSlotName.forEach(configName => {
691
- getConfigByName(configName, this.serverName, res => {
692
- this.configFromWeb[configName] = res
693
- count++
694
- })
695
- })
696
-
697
- // 使用定时器循环判断锁状态,用于多个插槽,要等待统一获取完成之后,再进行下一步初始化
698
- const timer = setInterval(() => {
699
- console.log('插槽下载进度,当前:' + count + '/' + total)
700
- if (count >= total) {
701
- clearInterval(timer)
702
- this.scanConfigSlot(config)
703
- if (config.slotsDeclare.length > 0) {
704
- const lock = { status: true }
705
- this.getConfigAndJoin(config, lock)
706
- const innerTimer = setInterval(() => {
707
- if (!lock.status) {
708
- clearInterval(innerTimer)
709
- outerLock.status = false
710
- }
711
- }, 100)
712
- } else {
713
- outerLock.status = false
714
- }
715
- }
716
- }, 100)
717
- } else {
718
- console.error('插槽配置有误!')
719
- outerLock.status = false
720
- }
721
- },
722
- // 获取配置之后的初始化
723
- configInit () {
724
- // 上锁,等待所有配置获取完成
725
- const lock = { status: true }
726
-
727
- // 获取插槽
728
- this.getConfigAndJoin(this.config, lock)
729
-
730
- // 用定时器循环查看锁状态
731
- this.timer = setInterval(() => {
732
- if (!lock.status) {
733
- clearInterval(this.timer)
734
- console.log('拼接完成', this.config)
735
- // 将初始化好的配置拷贝一份留存
736
- this.originalConfig = Object.assign({}, this.config)
737
- if (!this.dontFormat) {
738
- // 扫描配置文件中有没有rowSpan,进行格式化调整
739
- this.formatConfigRow(this.config)
740
- }
741
- this.activeConfig = this.config
742
- this.showSkeleton = false
743
- // 判断是否有动态Index
744
- this.activeConfig.columns.forEach(row => {
745
- row.forEach(cell => {
746
- if (cell.dynamicDataIndex === true) {
747
- // 如果有动态index,取其函数,运行函数得到真实index保存
748
- // eslint-disable-next-line no-eval
749
- const func = eval('(' + cell.customFunctionForDynamicDataIndex + ')')
750
- cell.dataIndex = func(this.config)
751
- }
752
- })
753
- })
754
- // 将数据复制到临时数据中,带有@@@的数据,我们将其整体作为一个key保存,当编辑完成后,再将其解析,回填到需要的数据中
755
- this.activeConfig.tempData = {}
756
- // 是否有@@@深层引用
757
- this.activeConfig.columns.forEach(row => {
758
- row.forEach(cell => {
759
- // 将@@@解析
760
- if (cell.dataIndex !== undefined && cell.dataIndex.indexOf('@@@') !== -1) {
761
- this.activeConfig.tempData[cell.dataIndex] = this.getDeepObject(this.activeConfig.data, cell.dataIndex)
762
- }
763
- })
764
- })
765
- this.$nextTick(() => {
766
- this.scanFinish = true
767
- })
768
- }
769
- }, 100)
770
- },
771
- // 初始化JSON配置
772
- jsonConfigInit () {
773
- if (this.configData === undefined) {
774
- console.error('未找到数据!')
775
- } else {
776
- this.originalConfig = Object.assign({}, this.config)
777
- this.originalConfig.data = JSON.parse(JSON.stringify(this.configData))
778
- this.type = 'display'
779
- // this.onlyDisplay = true
780
- this.showSkeleton = false
781
- this.$nextTick(() => {
782
- this.scanFinish = true
783
- })
784
- }
785
- },
786
- },
787
- beforeMount () {
788
- // 如果只是展示
789
- if (this.displayOnly) {
790
- this.onlyDisplay = true
791
- this.type = 'display'
792
- }
793
- // 如果有本地配置,优先使用本地配置
794
- if (this.localConfig) {
795
- // 如果配置是json渲染器
796
- if (this.localConfig.designMode === 'json') {
797
- this.config = this.localConfig
798
- if (this.configData !== undefined) {
799
- this.config.data = this.configData
800
- }
801
- this.jsonConfigInit()
802
- } else {
803
- // 如果配置是普通渲染器
804
- this.config = this.localConfig
805
- if (this.configData !== undefined) {
806
- this.config.data = this.configData
807
- }
808
- if (this.config.data.images === undefined) {
809
- this.config.data.images = {}
810
- }
811
- this.configInit()
812
- }
813
- } else {
814
- // 如果本地配置没有值,则从琉璃中获取
815
- getConfigByName(this.configName, this.serverName, res => {
816
- this.config = res
817
- if (this.config.designMode === 'json') {
818
- if (this.configData !== undefined) {
819
- this.config.data = this.configData
820
- }
821
- this.jsonConfigInit()
822
- } else {
823
- if (this.configData !== undefined) {
824
- this.config.data = this.configData
825
- }
826
- if (this.config.data.images === undefined) {
827
- this.config.data.images = {}
828
- }
829
- this.configInit()
830
- }
831
- })
832
- }
833
- },
834
- mounted () {
835
- // 如果外界传来了registerMap,我们将本VM对象注册到map中
836
- if (this.registerMap !== undefined) {
837
- this.registerMap.push(this)
838
- }
839
- // 将原始数据备份保存
840
- if (this.configData) {
841
- this.dataCache = JSON.parse(JSON.stringify(this.configData))
842
- } else {
843
- this.dataCache = JSON.parse(JSON.stringify(this.config.data))
844
- }
845
- }
846
- }
847
- </script>
848
-
849
- <style lang="less" scoped>
850
- .tools {
851
- text-align: center;
852
- cursor: pointer;
853
-
854
- .toolsItem {
855
- display: inline-block;
856
- }
857
- }
858
- </style>
1
+ <template>
2
+ <div>
3
+ <!-- 骨架屏 -->
4
+ <a-card v-if="showSkeleton">
5
+ <a-skeleton active/>
6
+ </a-card>
7
+ <template v-if="noPadding">
8
+ <!-- 主体表格 -->
9
+ <XReportDesign
10
+ @updateImg="updateImg"
11
+ v-if="scanFinish"
12
+ :show-img-in-cell="showImgInCell"
13
+ :img-prefix="imgPrefix"
14
+ :use-oss-for-img="useOssForImg"
15
+ :display-only="displayOnly"
16
+ :config="type === 'display' ? originalConfig : activeConfig"
17
+ :slot-config-name="type === 'display' ? undefined : activatedSlotName"
18
+ :for-display="type === 'display'"
19
+ ref="XReportDesign"
20
+ id="printReady"
21
+ :server-name="serverName"
22
+ :show-title="showTitle"
23
+ :no-padding="noPadding"
24
+ :no-top-border="noTopBorder"
25
+ :show-images="hasImages"
26
+ :image-list="imageList">
27
+ </XReportDesign>
28
+ </template>
29
+ <template v-else>
30
+ <!-- 用以包裹整个页面 -->
31
+ <a-card v-if="!showSkeleton">
32
+ <!-- 切换菜单 -->
33
+ <a-radio-group v-model="type" default-value="a" button-style="solid" @change="tabChanged" v-show="!onlyDisplay && editMode">
34
+ <a-radio-button value="design" v-if="!onlyDisplay">
35
+ 设计
36
+ </a-radio-button>
37
+ <a-radio-button value="display" style="border-radius: 0">
38
+ 预览
39
+ </a-radio-button>
40
+ </a-radio-group>
41
+ <a-radio-button @click="saveConfig" style="border-radius: 0 4px 4px 0" v-if="showSaveButton">
42
+ 保存
43
+ </a-radio-button>
44
+ <!-- 主体表格 -->
45
+ <XReportDesign
46
+ v-if="scanFinish"
47
+ @updateImg="updateImg"
48
+ :show-img-in-cell="showImgInCell"
49
+ :img-prefix="imgPrefix"
50
+ :use-oss-for-img="useOssForImg"
51
+ :display-only="displayOnly"
52
+ :config="type === 'display' ? originalConfig : activeConfig"
53
+ :slot-config-name="type === 'display' ? undefined : activatedSlotName"
54
+ :for-display="type === 'display'"
55
+ :no-padding="noPadding"
56
+ :no-top-border="noTopBorder"
57
+ :show-title="showTitle"
58
+ ref="XReportDesign"
59
+ id="printReady"
60
+ :server-name="serverName"
61
+ :show-images="hasImages"
62
+ :image-list="imageList">
63
+ </XReportDesign>
64
+ <!-- 导出按钮 -->
65
+ <template v-if="type === 'display'">
66
+ <div class="tools">
67
+ <div class="toolsItem" @click="exportPDF">
68
+ <a-button type="primary">
69
+ 导出PDF
70
+ </a-button>
71
+ </div>
72
+ </div>
73
+ </template>
74
+ </a-card>
75
+ </template>
76
+ </div>
77
+ </template>
78
+
79
+ <script>
80
+ // 转PDF用
81
+ import HtmlToPdf from '@vue2-client/utils/htmlToPDF'
82
+ import { getConfigByName } from '@vue2-client/services/api/common'
83
+ import XReportDesign from '@vue2-client/base-client/components/common/XReport/XReportDesign.vue'
84
+
85
+ export default {
86
+ name: 'XReport',
87
+ props: {
88
+ files: {
89
+ type: Array,
90
+ default: () => {
91
+ return []
92
+ }
93
+ },
94
+ // 控制用户权限,user和admin
95
+ authority: {
96
+ type: String,
97
+ default: 'user'
98
+ },
99
+ // 是否为编辑模式
100
+ editMode: {
101
+ type: Boolean,
102
+ default: true
103
+ },
104
+ // 配置名
105
+ configName: {
106
+ type: String,
107
+ required: true
108
+ },
109
+ // 插槽名
110
+ activatedSlotName: {
111
+ type: String,
112
+ default: undefined
113
+ },
114
+ // 本地配置,调试用
115
+ localConfig: {
116
+ type: Object,
117
+ default: undefined
118
+ },
119
+ // 兼容老版本配置
120
+ dontFormat: {
121
+ type: Boolean,
122
+ default: true
123
+ },
124
+ showImgInCell: {
125
+ type: Boolean,
126
+ default: false
127
+ },
128
+ // 数据
129
+ configData: {
130
+ type: Object,
131
+ default: undefined
132
+ },
133
+ // 命名空间
134
+ serverName: {
135
+ type: String,
136
+ default: 'af-system'
137
+ },
138
+ // 只做展示
139
+ displayOnly: {
140
+ type: Boolean,
141
+ default: false
142
+ },
143
+ // 表格没有边距
144
+ noPadding: {
145
+ type: Boolean,
146
+ default: false
147
+ },
148
+ // 表格没有上边框,与noPadding搭配可以实现连续表格
149
+ noTopBorder: {
150
+ type: Boolean,
151
+ default: false
152
+ },
153
+ // 是否展示标题
154
+ showTitle: {
155
+ type: Boolean,
156
+ default: true
157
+ },
158
+ // 是否展示保存按钮
159
+ showSaveButton: {
160
+ type: Boolean,
161
+ default: true
162
+ },
163
+ // 是否将组件注册到外层提供的容器中,方便外侧统一保存
164
+ registerMap: {
165
+ type: Array,
166
+ default: undefined
167
+ },
168
+ // 图片是否使用OSS来保存
169
+ useOssForImg: {
170
+ type: Boolean,
171
+ default: true
172
+ },
173
+ // 图片上传后添加前缀
174
+ imgPrefix: {
175
+ type: String,
176
+ default: undefined
177
+ }
178
+ },
179
+ components: {
180
+ XReportDesign
181
+ },
182
+ data () {
183
+ return {
184
+ // 控制骨架屏显隐
185
+ showSkeleton: true,
186
+ // 配置
187
+ config: undefined,
188
+ // 当前显示模式,编辑模式,预览模式
189
+ type: 'design',
190
+ // 仅供展示,不可编辑
191
+ onlyDisplay: false,
192
+ // 每行最大列数,非必要请勿更改,现在的设计器完全是基于每行12列来设计的
193
+ maxColSpan: 12,
194
+ // 定义是否完成配置的扫描,未完成不要渲染子组件
195
+ scanFinish: false,
196
+ // 当前激活的配置文件
197
+ activeConfig: null,
198
+ // 原始配置文件
199
+ // 用于展示。某些情况下“设计页”中的内容仅为“预览页”表格其中的一部分
200
+ originalConfig: null,
201
+ // 扫描到的配置
202
+ configFromWeb: {},
203
+ // 用于获取配置的锁
204
+ timer: undefined,
205
+ // 是否包含图片
206
+ hasImages: false,
207
+ // 图片列表
208
+ imageList: [],
209
+ // 保存最原始的数据,用于判断哪些数据被更改了
210
+ dataCache: undefined,
211
+ // 判断哪些数据被更改了,存储对应的key
212
+ diff: []
213
+ }
214
+ },
215
+ watch: {
216
+ // 如果配置名更改了,重新获取配置
217
+ configName (val) {
218
+ if (val) {
219
+ getConfigByName(this.configName, undefined, res => {
220
+ this.config = res
221
+ this.configInit()
222
+ })
223
+ }
224
+ },
225
+ // 如果本地配置更改了,重新初始化
226
+ localConfig (val) {
227
+ if (val) {
228
+ this.config = val
229
+ this.configInit()
230
+ }
231
+ }
232
+ },
233
+ methods: {
234
+ // 向外暴露图片修改后的数据,某些外部需要自己管理图片的保存与修改
235
+ updateImg (data) {
236
+ this.$emit('updateImg', data)
237
+ },
238
+ // 导出数据,某些外部需要统一控制数据的变动
239
+ exportData () {
240
+ // 获取当前修改后的数据
241
+ let tempData
242
+ if (this.activeConfig === undefined || this.activeConfig === null) {
243
+ tempData = this.originalConfig.data
244
+ } else {
245
+ const tempDataKeys = Object.keys(this.activeConfig.tempData)
246
+ tempDataKeys.forEach(key => {
247
+ this.changeDeepObject(this.activeConfig.data, key, this.activeConfig.tempData[key])
248
+ })
249
+ tempData = this.activeConfig.data
250
+ }
251
+ // 对比数据的差异
252
+ this.diff = []
253
+ this.compareProps(tempData, this.dataCache)
254
+ this.diff.forEach(eachDiff => {
255
+ const arr = eachDiff.split('.')
256
+ let targetData = tempData[arr[0]]
257
+ if (arr.length !== 1) {
258
+ for (let i = 1; i < arr.length - 1; i++) {
259
+ const path = arr[i]
260
+ targetData = targetData[path]
261
+ }
262
+ }
263
+ // 将修改的数据,添加update = true属性
264
+ targetData.update = true
265
+ })
266
+ return tempData
267
+ },
268
+ // 对比两个obj有哪里不同
269
+ compareProps (obj1, obj2, path = '') {
270
+ for (const key in obj1) {
271
+ // 如果一个是undefined
272
+ if (typeof obj2[key] === 'undefined') {
273
+ this.diff.push(path + key)
274
+ // 如果是数组长度不一样
275
+ } else if (Array.isArray(obj1) && Array.isArray(obj2)) {
276
+ if (obj1[key].length !== obj2[key].length) {
277
+ this.diff.push(path + key)
278
+ }
279
+ // 如果都是对象,并且存在同样的key,递归子key
280
+ } else if (typeof obj1[key] === 'object' && typeof obj2[key] === 'object') {
281
+ this.compareProps(obj1[key], obj2[key], path + key + '.')
282
+ // 如果不是obj,对比其数据
283
+ } else if (obj1[key] !== obj2[key]) {
284
+ this.diff.push(path + key)
285
+ }
286
+ }
287
+ },
288
+ // 正常的保存方法,当前修改内容会直接全部导出到外部
289
+ saveConfig () {
290
+ if (this.activeConfig === undefined || this.activeConfig === null) {
291
+ return this.originalConfig.data
292
+ } else {
293
+ const tempDataKeys = Object.keys(this.activeConfig.tempData)
294
+ tempDataKeys.forEach(key => {
295
+ this.changeDeepObject(this.activeConfig.data, key, this.activeConfig.tempData[key])
296
+ })
297
+ this.$emit('saveConfig', this.$refs.XReportDesign.activatedConfig)
298
+ }
299
+ },
300
+ // 通过@@@分割临时变量,找到对应的key,并修改它的值
301
+ changeDeepObject (obj, strPath, newVal) {
302
+ const arr = strPath.split('@@@')
303
+ if (obj[arr[0]] === undefined) {
304
+ obj = obj.images
305
+ }
306
+ if (arr.length === 1) {
307
+ obj[arr[0]] = newVal
308
+ } else {
309
+ let result = obj[arr[0]]
310
+ arr.shift()
311
+ while (arr.length > 1) {
312
+ result = result[arr[0]]
313
+ arr.shift()
314
+ }
315
+ result[arr[0]] = newVal
316
+ }
317
+ },
318
+ // 检查slot是否在配置文件中包含,如果没有包含,则视为非法获取
319
+ checkSlotDefine (config) {
320
+ const slotsDeclare = config.slotsDeclare
321
+ const total = slotsDeclare.length
322
+ let count = 0
323
+ slotsDeclare.forEach(declare => {
324
+ config.columns.forEach(row => {
325
+ row.forEach(cell => {
326
+ if (cell.slotConfig === declare) {
327
+ count++
328
+ }
329
+ })
330
+ })
331
+ })
332
+
333
+ return count === total
334
+ },
335
+ // 切换了标签页
336
+ tabChanged (key) {
337
+ this.scanFinish = false
338
+ this.originalConfig.data = { ...this.originalConfig.data, ...this.config.data }
339
+ this.config.data = this.originalConfig.data
340
+ if (this.type === 'display') {
341
+ const tempDataKeys = Object.keys(this.activeConfig.tempData)
342
+ tempDataKeys.forEach(key => {
343
+ this.changeDeepObject(this.activeConfig.data, key, this.activeConfig.tempData[key])
344
+ })
345
+ let count = 0
346
+ this.imageList = []
347
+ const keys = Object.keys(this.config.data.images)
348
+ keys.forEach(key => {
349
+ if (this.config.data.images[key].length > 0) {
350
+ this.imageList = [...this.imageList, ...this.config.data.images[key]]
351
+ count++
352
+ }
353
+ })
354
+ this.hasImages = count > 0
355
+ } else {
356
+ this.hasImages = false
357
+ }
358
+ this.$nextTick(() => {
359
+ this.scanFinish = true
360
+ })
361
+ },
362
+ // 获取当前日期,为保存文件命名用
363
+ getDate () {
364
+ const currentDate = new Date()
365
+
366
+ const year = currentDate.getFullYear()
367
+ const month = String(currentDate.getMonth() + 1).padStart(2, '0')
368
+ const day = String(currentDate.getDate()).padStart(2, '0')
369
+
370
+ const formattedDate = `${year}_${month}_${day}`
371
+
372
+ return formattedDate
373
+ },
374
+ // 导出PDF
375
+ exportPDF () {
376
+ const date = this.getDate()
377
+ let title = this.config.title
378
+ title = title.replace(/<[^>]+>/g, '')
379
+ const fileName = date + '' + title
380
+ HtmlToPdf.getPdf(fileName, '#printReady')
381
+ },
382
+ // 用于分割配置中的colums,将需要处理的数组提取出来
383
+ formatConfigRow () {
384
+ for (let i = 0; i < this.config.columns.length; i++) {
385
+ // 对原始数组进行递归,依次将该位置拆分为三个部分,当前处理位置之前的,当前处理位置,当前处理位置之后的
386
+ const before = this.config.columns.slice(0, i)
387
+ const after = this.config.columns.slice(i + 1, this.config.columns.length)
388
+
389
+ // 将当前处理的数组交给处理的方法
390
+ const x = this.checkRow(this.config.columns[i])
391
+
392
+ const newArr = []
393
+
394
+ // 拼接之前的数组
395
+ if (before.length > 0) {
396
+ if (before.length >= 1) {
397
+ before.forEach(item => {
398
+ newArr.push(item)
399
+ })
400
+ } else {
401
+ newArr.push(before)
402
+ }
403
+ }
404
+
405
+ // 拼接不需要更改当前节点处理完成的数组
406
+ newArr.push(x.old)
407
+
408
+ // 如果处理了新加的数据,拼接
409
+ if (x.add.length > 0) {
410
+ for (let j = 0; j < x.add.length; j++) {
411
+ if (x.add[j]) {
412
+ newArr.push(x.add[j])
413
+ i++
414
+ }
415
+ }
416
+ }
417
+
418
+ // 拼接之后的数组
419
+ if (after.length > 0) {
420
+ if (after.length >= 1) {
421
+ after.forEach(item => {
422
+ newArr.push(item)
423
+ })
424
+ } else {
425
+ newArr.push(after)
426
+ }
427
+ }
428
+
429
+ this.config.columns = newArr
430
+ }
431
+ },
432
+ // 路径中含有@@@的key,将其解析,并返回其数据
433
+ getDeepObject (obj, strPath) {
434
+ const arr = strPath.split('@@@')
435
+ let result = obj[arr[0]]
436
+ arr.shift()
437
+ try {
438
+ while (arr.length > 0) {
439
+ result = result[arr[0]]
440
+ arr.shift()
441
+ }
442
+ } catch (e) {
443
+ result = undefined
444
+ }
445
+ return result
446
+ },
447
+ // 处理colums数组,为声明了rowspan的单元格,自动匹配格式
448
+ checkRow (rowArr) {
449
+ // 不需要更改的数据
450
+ const original = []
451
+ // 需要更改新加的数据
452
+ const addArr = []
453
+ // 统计rowspan出现的总和
454
+ let count = 0
455
+ // 统计声明列需要的rowspan总数
456
+ let total = 0
457
+ // 是否为声明行
458
+ let titleCellFlag = false
459
+ // 是否为声明行后第一行
460
+ let firstSubLine = false
461
+ // 需要处理的行,新的index值
462
+ let subRowIndex = 0
463
+ // 新生成的行,临时存储
464
+ const waitForAddArr = []
465
+ // 用于记录声明行的colspan避免格式错误
466
+ let preColSpan = 0
467
+ // 用于统计循环次数,判断是否是最后一次
468
+ let forEachCount = 0
469
+
470
+ // 标记所有数据
471
+ rowArr.forEach(cell => {
472
+ forEachCount++
473
+ // 如果该行没有rowspan则默认其为1,不要影响统计结果
474
+ if (!cell.rowSpan) {
475
+ cell.rowSpan = 0
476
+ }
477
+
478
+ if (cell.text && total !== 0) { // 如果遇到了下一个声明行,证明rowspan少了一行,需要补充一个占位格
479
+ const nullObj = {
480
+ type: 'placeHolderColumn',
481
+ order: subRowIndex,
482
+ noBoarder: true,
483
+ needSplit: true,
484
+ colSpan: preColSpan,
485
+ dontShowRow: true
486
+ }
487
+ subRowIndex++
488
+ waitForAddArr.push(nullObj)
489
+ total = 0
490
+ count = 0
491
+ titleCellFlag = false
492
+ firstSubLine = false
493
+ } else if ((total !== count + cell.rowSpan) && forEachCount === rowArr.length) {
494
+ // 如果没有遇到了下一个声明行,但已经是当前行最后一个数据,也证明rowspan少了一行,需要补充一个占位格
495
+ const nullObj = {
496
+ type: 'placeHolderColumn',
497
+ order: subRowIndex,
498
+ noBoarder: true,
499
+ needSplit: true,
500
+ colSpan: preColSpan,
501
+ dontShowRow: true
502
+ }
503
+ subRowIndex++
504
+ waitForAddArr.push(nullObj)
505
+ total = 0
506
+ count = 0
507
+ titleCellFlag = false
508
+ firstSubLine = false
509
+ }
510
+
511
+ // 判断是否为声明行
512
+ if (cell.text && total === 0) {
513
+ // 将声明行声明的rowspan作为总数,判断下方rowspan相加是否等于声明行声明的数量
514
+ total = cell.rowSpan
515
+ titleCellFlag = false
516
+ firstSubLine = true
517
+ subRowIndex = 1
518
+ cell.show = true
519
+ cell.showRowSpan = total
520
+ } else if (cell.rowSpan > 0 && !titleCellFlag && firstSubLine) { // 判断是否为声明行后首行,因为首行不需要移动
521
+ count += cell.rowSpan
522
+ firstSubLine = false
523
+ cell.noBoarder = true
524
+ cell.show = true
525
+ cell.showRowSpan = total
526
+ } else if (cell.rowSpan > 0 && !titleCellFlag && !firstSubLine) { // 既非声明行,也非首行,需要移动
527
+ count += cell.rowSpan
528
+ // cell.type = 'notShow'
529
+ cell.needSplit = true
530
+ cell.order = subRowIndex
531
+ cell.dontShowRow = true
532
+ subRowIndex++
533
+
534
+ // 如果之前添加过空行补充位置,刚好最后一位还有内容,将其互换
535
+ if (forEachCount === rowArr.length && !waitForAddArr[waitForAddArr.length - 1].dataIndex) {
536
+ waitForAddArr[waitForAddArr.length - 1].order += 1
537
+ cell.order -= 1
538
+ waitForAddArr.push(cell)
539
+ } else {
540
+ waitForAddArr.push(cell)
541
+ }
542
+ }
543
+
544
+ // 如果count和total相等了,证明已经处理完成。将计数器还原
545
+ if (count === total) {
546
+ total = 0
547
+ count = 0
548
+ titleCellFlag = false
549
+ firstSubLine = false
550
+ }
551
+ // 保存上一个的colspan,保持生成的格子与原格式一致
552
+ preColSpan = cell.colSpan
553
+ })
554
+
555
+ // 将所有不需要移动的放入original
556
+ rowArr.forEach(cell => {
557
+ if (cell.needSplit !== true) {
558
+ original.push(cell)
559
+ }
560
+ })
561
+
562
+ // 增加新的数组
563
+ waitForAddArr.forEach(cell => {
564
+ const target = cell.order
565
+ // if (cell.type === 'notShow') {
566
+ // cell.type = 'inputs'
567
+ // }
568
+ cell.noBoarder = true
569
+ if (addArr[target] === undefined) {
570
+ const temp = []
571
+ temp.push(cell)
572
+ addArr[target] = temp
573
+ } else if (addArr[target].length > 0) {
574
+ addArr[target].push(cell)
575
+ }
576
+ })
577
+
578
+ // 如果没有新增,将单元格边框设置为显示
579
+ if (addArr.length < 1) {
580
+ original.forEach(cell => {
581
+ if (cell.type === 'input' || cell.type === 'inputs') {
582
+ cell.noBoarder = false
583
+ }
584
+ })
585
+ }
586
+
587
+ return {
588
+ old: original,
589
+ add: addArr
590
+ }
591
+ },
592
+ // 扫描配置,如果有插槽则拼接插槽
593
+ scanConfigSlot (config) {
594
+ const columnsArr = config.columns
595
+ for (let i = 0; i < columnsArr.length; i++) {
596
+ for (let j = 0; j < columnsArr[i].length; j++) {
597
+ // 如果发现type为slot,开始匹配对应的slot配置文件
598
+ if (columnsArr[i][j].type === 'slot') {
599
+ const targetName = columnsArr[i][j].slotConfig
600
+ // 找不到目标插槽配置
601
+ if (!this.configFromWeb[targetName] || !this.configFromWeb[targetName].columns) {
602
+ console.error('无法找到目标插槽的配置!')
603
+ return
604
+ }
605
+
606
+ // 替换columns,合并data
607
+ config.columns[i] = []
608
+ const before = config.columns.slice(0, i)
609
+ let after = config.columns.slice(i + 1, config.columns.length)
610
+
611
+ const addArr = []
612
+ for (let k = 0; k < this.configFromWeb[targetName].columns.length; k++) {
613
+ const temp = []
614
+ this.configFromWeb[targetName].columns[k].forEach(cell => {
615
+ temp.push(cell)
616
+ })
617
+ addArr.push(temp)
618
+ }
619
+
620
+ const newArr = []
621
+ // 拼接之前的数组
622
+ if (before.length > 0) {
623
+ if (before.length >= 1) {
624
+ before.forEach(item => {
625
+ newArr.push(item)
626
+ })
627
+ } else {
628
+ newArr.push(before)
629
+ }
630
+ }
631
+
632
+ addArr.forEach(arr => {
633
+ newArr.push(arr)
634
+ })
635
+
636
+ // 拼接之后的数组
637
+ if (after.length === 1) {
638
+ if (after[0].type === 'slot' || after[0][0].type === 'slot') {
639
+ after = []
640
+ }
641
+ }
642
+ if (after.length > 0) {
643
+ if (after.length >= 1) {
644
+ after.forEach(item => {
645
+ newArr.push(item)
646
+ })
647
+ } else {
648
+ newArr.push(after)
649
+ }
650
+ }
651
+
652
+ config.columns = newArr
653
+ if (this.configFromWeb[targetName].slotsDeclare) {
654
+ config.slotsDeclare = this.configFromWeb[targetName].slotsDeclare
655
+ } else {
656
+ config.slotsDeclare = []
657
+ }
658
+
659
+ if (config.data.images && this.configFromWeb[targetName].data.images) {
660
+ config.data.images = { ...config.data.images, ...this.configFromWeb[targetName].data.images }
661
+ delete this.configFromWeb[targetName].data.images
662
+ }
663
+ config.data = { ...config.data, ...this.configFromWeb[targetName].data }
664
+ }
665
+ }
666
+ }
667
+ this.config = config
668
+ },
669
+ // 扫描所有插槽名
670
+ scanConfigName (config, resut) {
671
+ if (config.slotsDeclare) {
672
+ config.slotsDeclare.forEach(name => {
673
+ resut.push(name)
674
+ })
675
+ }
676
+ },
677
+ // 获取插槽
678
+ getConfigAndJoin (config, outerLock) {
679
+ // 检查主配置插槽声明是否合法
680
+ const check = this.checkSlotDefine(config)
681
+ const waitForDownloadSlotName = []
682
+ if (check) {
683
+ // 扫描主配置中声明的插槽名
684
+ this.scanConfigName(config, waitForDownloadSlotName)
685
+
686
+ const total = waitForDownloadSlotName.length
687
+ let count = 0
688
+
689
+ // 挨个获取插槽
690
+ waitForDownloadSlotName.forEach(configName => {
691
+ getConfigByName(configName, this.serverName, res => {
692
+ this.configFromWeb[configName] = res
693
+ count++
694
+ })
695
+ })
696
+
697
+ // 使用定时器循环判断锁状态,用于多个插槽,要等待统一获取完成之后,再进行下一步初始化
698
+ const timer = setInterval(() => {
699
+ console.log('插槽下载进度,当前:' + count + '/' + total)
700
+ if (count >= total) {
701
+ clearInterval(timer)
702
+ this.scanConfigSlot(config)
703
+ if (config.slotsDeclare.length > 0) {
704
+ const lock = { status: true }
705
+ this.getConfigAndJoin(config, lock)
706
+ const innerTimer = setInterval(() => {
707
+ if (!lock.status) {
708
+ clearInterval(innerTimer)
709
+ outerLock.status = false
710
+ }
711
+ }, 100)
712
+ } else {
713
+ outerLock.status = false
714
+ }
715
+ }
716
+ }, 100)
717
+ } else {
718
+ console.error('插槽配置有误!')
719
+ outerLock.status = false
720
+ }
721
+ },
722
+ // 获取配置之后的初始化
723
+ configInit () {
724
+ // 上锁,等待所有配置获取完成
725
+ const lock = { status: true }
726
+
727
+ // 获取插槽
728
+ this.getConfigAndJoin(this.config, lock)
729
+
730
+ // 用定时器循环查看锁状态
731
+ this.timer = setInterval(() => {
732
+ if (!lock.status) {
733
+ clearInterval(this.timer)
734
+ console.log('拼接完成', this.config)
735
+ // 将初始化好的配置拷贝一份留存
736
+ this.originalConfig = Object.assign({}, this.config)
737
+ if (!this.dontFormat) {
738
+ // 扫描配置文件中有没有rowSpan,进行格式化调整
739
+ this.formatConfigRow(this.config)
740
+ }
741
+ this.activeConfig = this.config
742
+ this.showSkeleton = false
743
+ // 判断是否有动态Index
744
+ this.activeConfig.columns.forEach(row => {
745
+ row.forEach(cell => {
746
+ if (cell.dynamicDataIndex === true) {
747
+ // 如果有动态index,取其函数,运行函数得到真实index保存
748
+ // eslint-disable-next-line no-eval
749
+ const func = eval('(' + cell.customFunctionForDynamicDataIndex + ')')
750
+ cell.dataIndex = func(this.config)
751
+ }
752
+ })
753
+ })
754
+ // 将数据复制到临时数据中,带有@@@的数据,我们将其整体作为一个key保存,当编辑完成后,再将其解析,回填到需要的数据中
755
+ this.activeConfig.tempData = {}
756
+ // 是否有@@@深层引用
757
+ this.activeConfig.columns.forEach(row => {
758
+ row.forEach(cell => {
759
+ // 将@@@解析
760
+ if (cell.dataIndex !== undefined && cell.dataIndex.indexOf('@@@') !== -1) {
761
+ this.activeConfig.tempData[cell.dataIndex] = this.getDeepObject(this.activeConfig.data, cell.dataIndex)
762
+ }
763
+ })
764
+ })
765
+ this.$nextTick(() => {
766
+ this.scanFinish = true
767
+ })
768
+ }
769
+ }, 100)
770
+ },
771
+ // 初始化JSON配置
772
+ jsonConfigInit () {
773
+ if (this.configData === undefined) {
774
+ console.error('未找到数据!')
775
+ } else {
776
+ this.originalConfig = Object.assign({}, this.config)
777
+ this.originalConfig.data = JSON.parse(JSON.stringify(this.configData))
778
+ this.type = 'display'
779
+ // this.onlyDisplay = true
780
+ this.showSkeleton = false
781
+ this.$nextTick(() => {
782
+ this.scanFinish = true
783
+ })
784
+ }
785
+ },
786
+ },
787
+ beforeMount () {
788
+ // 如果只是展示
789
+ if (this.displayOnly) {
790
+ this.onlyDisplay = true
791
+ this.type = 'display'
792
+ }
793
+ // 如果有本地配置,优先使用本地配置
794
+ if (this.localConfig) {
795
+ // 如果配置是json渲染器
796
+ if (this.localConfig.designMode === 'json') {
797
+ this.config = this.localConfig
798
+ if (this.configData !== undefined) {
799
+ this.config.data = this.configData
800
+ }
801
+ this.jsonConfigInit()
802
+ } else {
803
+ // 如果配置是普通渲染器
804
+ this.config = this.localConfig
805
+ if (this.configData !== undefined) {
806
+ this.config.data = this.configData
807
+ }
808
+ if (this.config.data.images === undefined) {
809
+ this.config.data.images = {}
810
+ }
811
+ this.configInit()
812
+ }
813
+ } else {
814
+ // 如果本地配置没有值,则从琉璃中获取
815
+ getConfigByName(this.configName, this.serverName, res => {
816
+ this.config = res
817
+ if (this.config.designMode === 'json') {
818
+ if (this.configData !== undefined) {
819
+ this.config.data = this.configData
820
+ }
821
+ this.jsonConfigInit()
822
+ } else {
823
+ if (this.configData !== undefined) {
824
+ this.config.data = this.configData
825
+ }
826
+ if (this.config.data.images === undefined) {
827
+ this.config.data.images = {}
828
+ }
829
+ this.configInit()
830
+ }
831
+ })
832
+ }
833
+ },
834
+ mounted () {
835
+ // 如果外界传来了registerMap,我们将本VM对象注册到map中
836
+ if (this.registerMap !== undefined) {
837
+ this.registerMap.push(this)
838
+ }
839
+ // 将原始数据备份保存
840
+ if (this.configData) {
841
+ this.dataCache = JSON.parse(JSON.stringify(this.configData))
842
+ } else {
843
+ this.dataCache = JSON.parse(JSON.stringify(this.config.data))
844
+ }
845
+ }
846
+ }
847
+ </script>
848
+
849
+ <style lang="less" scoped>
850
+ .tools {
851
+ text-align: center;
852
+ cursor: pointer;
853
+
854
+ .toolsItem {
855
+ display: inline-block;
856
+ }
857
+ }
858
+ </style>