@mapgis/mapgis-pan-spatial-map-widgets-config-ui 16.0.0

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 (118) hide show
  1. package/.browserslistrc +3 -0
  2. package/.env.production +5 -0
  3. package/.eslintignore +5 -0
  4. package/.eslintrc.js +18 -0
  5. package/README.md +24 -0
  6. package/babel.config.js +5 -0
  7. package/dist-libs/demo.html +10 -0
  8. package/dist-libs/fonts/ionicons.99ac3308.woff +0 -0
  9. package/dist-libs/fonts/ionicons.d535a25a.ttf +0 -0
  10. package/dist-libs/img/iconfont.573255ce.svg +36 -0
  11. package/dist-libs/img/image-icon.dd06d30b.dd06d30b.png +0 -0
  12. package/dist-libs/img/ionicons.17bf2ac0.svg +870 -0
  13. package/dist-libs/img/jsoneditor-icons.2b9b4872.2b9b4872.svg +749 -0
  14. package/dist-libs/img/plus.bdc6b5b1.bdc6b5b1.svg +1 -0
  15. package/dist-libs/img/text-icon.dd1b3d87.dd1b3d87.png +0 -0
  16. package/dist-libs/img/video-icon.499ddeb4.499ddeb4.png +0 -0
  17. package/dist-libs/mapgis-pan-spatial-map-widgets-config-ui.common.js +33467 -0
  18. package/dist-libs/mapgis-pan-spatial-map-widgets-config-ui.css +6 -0
  19. package/dist-libs/mapgis-pan-spatial-map-widgets-config-ui.umd.js +33477 -0
  20. package/dist-libs/mapgis-pan-spatial-map-widgets-config-ui.umd.min.js +1183 -0
  21. package/docs/.vuepress/config.js +81 -0
  22. package/docs/.vuepress/public/favicon.ico +0 -0
  23. package/docs/.vuepress/public/logo.svg +7 -0
  24. package/docs/.vuepress/styles/palette.styl +1 -0
  25. package/docs/README.md +35 -0
  26. package/docs/api/common/MultiImgWithForm.md +87 -0
  27. package/docs/api/common/MultiTypeForm.md +113 -0
  28. package/docs/api/images/basemapConfigUI.png +0 -0
  29. package/docs/api/images/comprehensiveQueryConfigUI.png +0 -0
  30. package/docs/guide/README.md +42 -0
  31. package/docs/guide/publish.md +84 -0
  32. package/docs/guide/yarn/mapgis.png +0 -0
  33. package/docs/guide/yarn/use_mapgis.png +0 -0
  34. package/package.json +58 -0
  35. package/postcss.config.js +5 -0
  36. package/public/favicon.ico +0 -0
  37. package/public/index.html +17 -0
  38. package/src/api/app/config.js +10 -0
  39. package/src/assets/iviewIcon/fonts/ionicons.svg +870 -0
  40. package/src/assets/iviewIcon/fonts/ionicons.ttf +0 -0
  41. package/src/assets/iviewIcon/fonts/ionicons.woff +0 -0
  42. package/src/assets/iviewIcon/iview.css +3461 -0
  43. package/src/assets/logo.png +0 -0
  44. package/src/components/BasemapManagerSetting/BasemapManagerSetting.vue +461 -0
  45. package/src/components/CityGrowSetting/CityGrowSetting.vue +145 -0
  46. package/src/components/CityGrowSetting/EditableCell.vue +103 -0
  47. package/src/components/CommonComponents/MultiImgWithForm/MultiImgWithForm.scss +106 -0
  48. package/src/components/CommonComponents/MultiImgWithForm/MultiImgWithForm.vue +128 -0
  49. package/src/components/CommonComponents/MultiTypeForm/MultiTypeForm.vue +78 -0
  50. package/src/components/CommonComponents/ServiceSelect/index.vue +325 -0
  51. package/src/components/ComprehensiveQuerySetting/ComprehensiveQuerySetting.vue +745 -0
  52. package/src/components/ComprehensiveQuerySetting/EditAttrs.vue +254 -0
  53. package/src/components/DataCatalogSetting/DataCatalogSetting.vue +71 -0
  54. package/src/components/DataCatalogSetting/components/DataSetting.vue +126 -0
  55. package/src/components/DataCatalogSetting/components/IconSetting.vue +160 -0
  56. package/src/components/DataCatalogSetting/components/NoSpatialSetting.vue +37 -0
  57. package/src/components/DataCatalogSetting/components/OtherSetting.vue +54 -0
  58. package/src/components/DataCatalogSetting/components/ParamSetting.vue +95 -0
  59. package/src/components/DataCatalogSetting/components/component/DataSourceSetting.vue +929 -0
  60. package/src/components/DataCatalogSetting/components/component/NodeDataSetting.vue +644 -0
  61. package/src/components/DataCatalogSetting/components/component/ServiceSelectWithData.vue +413 -0
  62. package/src/components/DataCatalogSetting/index.js +29 -0
  63. package/src/components/FeatureQuerySetting/FeatureQuerySetting.vue +121 -0
  64. package/src/components/KibanaVSetting/KibanaVSetting.vue +152 -0
  65. package/src/components/LegendSetting/LegendSetting.vue +85 -0
  66. package/src/components/MapDataVSetting/MapDataVSetting.vue +41 -0
  67. package/src/components/OverlayManagerSetting/OverlayManagerSetting.vue +248 -0
  68. package/src/components/ParticleEffectsSetting/ParticleEffectsSetting.vue +166 -0
  69. package/src/components/PlotManagerSetting/EditableCell.vue +103 -0
  70. package/src/components/PlotManagerSetting/PlotManagerSetting.vue +229 -0
  71. package/src/components/ThematicMapSetting/BaseConfigSetting.vue +76 -0
  72. package/src/components/ThematicMapSetting/SubjectConfigSetting.vue +346 -0
  73. package/src/components/ThematicMapSetting/ThematicMapSetting.vue +44 -0
  74. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/common/AnimationItems.vue +141 -0
  75. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/common/ColorPickerSetting.vue +260 -0
  76. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/common/EditableFieldTable.vue +187 -0
  77. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/BaseItems/index.vue +161 -0
  78. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/AttributeTable.vue +122 -0
  79. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/Common.vue +376 -0
  80. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/Popup.vue +138 -0
  81. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/StatisticGragh.vue +189 -0
  82. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/BaseMapWithGraph.vue +73 -0
  83. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/HeatMap.vue +124 -0
  84. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/HexBin.vue +100 -0
  85. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/Label.vue +139 -0
  86. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/StatisticLabel.vue +43 -0
  87. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/SubSectionMap.vue +42 -0
  88. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/components/SubjectStyles/index.vue +56 -0
  89. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/index.less +101 -0
  90. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/components/SubjectItems/index.vue +236 -0
  91. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/index.less +22 -0
  92. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/index.vue +226 -0
  93. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/mixins/subject-styles-mixin.js +138 -0
  94. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/store/dep.js +21 -0
  95. package/src/components/ThematicMapSetting/ThematicMapSubjectAdd/store/fields.ts +111 -0
  96. package/src/components/ThematicMapSetting/ThematicMapSubjectList/index.vue +76 -0
  97. package/src/components/ThematicMapSetting/store/index.js +19 -0
  98. package/src/components/ThematicMapSetting/store/module/getters.js +28 -0
  99. package/src/components/ThematicMapSetting/store/module/index.js +53 -0
  100. package/src/components/ThematicMapSetting/store/module/mutations.js +272 -0
  101. package/src/components/ThematicMapSetting/store/module/state.js +36 -0
  102. package/src/components/ThematicMapSetting/store/types.js +0 -0
  103. package/src/components/WidgetSetting/WidgetJsonConfig.vue +28 -0
  104. package/src/components/WidgetSetting/components/JsonEditor/index.vue +77 -0
  105. package/src/components/WidgetSetting/widget-setting-mixin.js +22 -0
  106. package/src/components/index.js +17 -0
  107. package/src/index.js +63 -0
  108. package/src/shims-tsx.d.ts +13 -0
  109. package/src/shims-vue.d.ts +4 -0
  110. package/src/store/index.ts +15 -0
  111. package/src/utils/auth.js +18 -0
  112. package/src/utils/normal-request.js +63 -0
  113. package/src/utils/request.js +92 -0
  114. package/src/utils/settings.js +50 -0
  115. package/src/utils/uuid.js +17 -0
  116. package/src/utils/validate.js +175 -0
  117. package/tsconfig.json +40 -0
  118. package/vue.config.js +13 -0
@@ -0,0 +1,929 @@
1
+ <template>
2
+ <div class="data-source-setting-wrapper">
3
+ <div
4
+ style="height: unset; margin-bottom: 25px; margin-left: 15px"
5
+ class="setting-header"
6
+ >
7
+ <mapgis-ui-dropdown>
8
+ <mapgis-ui-button type="primary" class="setting-item">
9
+ 添加父节点<i class="el-icon-arrow-down el-icon--right" />
10
+ </mapgis-ui-button>
11
+ <mapgis-ui-menu slot="overlay" trigger="hover">
12
+ <mapgis-ui-menu-item @click.native="addNode('normal')">
13
+ 普通节点
14
+ </mapgis-ui-menu-item>
15
+ <mapgis-ui-menu-item @click.native="addNode('server')">
16
+ 二维节点
17
+ </mapgis-ui-menu-item>
18
+ <mapgis-ui-menu-item @click.native="addNode('globe')">
19
+ 三维节点
20
+ </mapgis-ui-menu-item>
21
+ <mapgis-ui-menu-item @click.native="addNode('data')">
22
+ 非空间数据节点
23
+ </mapgis-ui-menu-item>
24
+ </mapgis-ui-menu>
25
+ </mapgis-ui-dropdown>
26
+ <label
27
+ :for="randomInputId"
28
+ style="display: inline-block; cursor: pointer"
29
+ >
30
+ <mapgis-ui-button
31
+ type="vertical-align-bottom"
32
+ icon="vertical-align-bottom"
33
+ class="import-cover setting-item"
34
+ >
35
+ 导入
36
+ </mapgis-ui-button>
37
+ </label>
38
+ <input
39
+ :id="randomInputId"
40
+ type="file"
41
+ @change="importData($event)"
42
+ accept="application/json"
43
+ style="visibility: hidden; width: 0"
44
+ />
45
+ <mapgis-ui-popconfirm
46
+ title="确定清空节点吗?"
47
+ @confirm="clearData"
48
+ placement="bottom"
49
+ ok-text="确认"
50
+ cancel-text="取消"
51
+ >
52
+ <mapgis-ui-button
53
+ :disabled="isDataEmpty"
54
+ type="danger"
55
+ icon="delete"
56
+ class="icon-danger setting-item"
57
+ >
58
+ 清空
59
+ </mapgis-ui-button>
60
+ </mapgis-ui-popconfirm>
61
+ <mapgis-ui-button
62
+ type="vertical-align-top"
63
+ icon="vertical-align-top"
64
+ @click="exportData"
65
+ class="icon-warning setting-item"
66
+ >
67
+ 导出
68
+ </mapgis-ui-button>
69
+ </div>
70
+ <div class="setting-content" style="margin-left: 15px">
71
+ <mapgis-ui-input-search
72
+ v-model="searchStr"
73
+ placeholder="输入搜索项"
74
+ style="width: 200px; margin-bottom: 7px"
75
+ @change="onSearch"
76
+ ></mapgis-ui-input-search>
77
+ <mapgis-ui-tree
78
+ ref="treeData"
79
+ :tree-data="config.treeConfig.treeData"
80
+ :replace-fields="{ key: 'label', title: 'label', children: 'children' }"
81
+ show-icon
82
+ draggable
83
+ :expandedKeys="expandedKeys"
84
+ autoExpandParent
85
+ @expand="onExpand"
86
+ @select="onSelect"
87
+ @rightClick="onRightClick"
88
+ @drop="onDrop"
89
+ >
90
+ <template v-slot:title="nodeData">
91
+ <span>
92
+ <img :src="computedIcon(nodeData)" class="tree-data-icon" />
93
+ <span>{{ nodeData.label }}</span>
94
+ </span>
95
+ <mapgis-ui-button-group style="float: right">
96
+ <mapgis-ui-button
97
+ type="text"
98
+ size="small"
99
+ title="编辑"
100
+ @click="editNode(nodeData.dataRef, nodeData)"
101
+ ><i class="el-icon-edit-outline"
102
+ /></mapgis-ui-button>
103
+ <mapgis-ui-button
104
+ type="text"
105
+ size="small"
106
+ title="删除"
107
+ @click.stop="deleteNode(nodeData)"
108
+ ><i class="el-icon-delete"
109
+ /></mapgis-ui-button>
110
+ </mapgis-ui-button-group>
111
+ </template>
112
+ </mapgis-ui-tree>
113
+ <v-contextmenu ref="contextmenu">
114
+ <v-contextmenu-item @click="addNode('normal', rightClickNode)"
115
+ >添加普通节点</v-contextmenu-item
116
+ >
117
+ <v-contextmenu-item @click="addNode('server', rightClickNode)"
118
+ >添加二维节点</v-contextmenu-item
119
+ >
120
+ <v-contextmenu-item @click="addNode('globe', rightClickNode)"
121
+ >添加三维节点</v-contextmenu-item
122
+ >
123
+ <v-contextmenu-item @click="addNode('data', rightClickNode)"
124
+ >添加非空间数据节点</v-contextmenu-item
125
+ >
126
+ </v-contextmenu>
127
+ </div>
128
+ <mapgis-ui-modal
129
+ :visible.sync="nodeInfoVisible"
130
+ width="500px"
131
+ append-to-body
132
+ :close-on-click-modal="false"
133
+ :close-on-press-escape="false"
134
+ @cancel="cancleModal"
135
+ >
136
+ <div slot="title" class="header-title">
137
+ <span class="title-name">
138
+ <!-- <mapgis-ui-tooltip effect="dark" placement="right">
139
+ <div slot="content" style="max-width: 450px">
140
+ SceneServer服务请直接输入服务地址,G3D服务既可以通过ip、port、服务
141
+ 名配置,也可以直接输入服务地址!
142
+ </div>
143
+ <i
144
+ class="el-icon-warning"
145
+ style="color: #e6a23c; margin-right: 10px"
146
+ ></i>
147
+ </mapgis-ui-tooltip> -->
148
+ <mapgis-ui-tooltip
149
+ placement="topLeft"
150
+ :overlayStyle="{ maxWidth: '450px' }"
151
+ class="tooltip-inner"
152
+ >
153
+ <template slot="title">
154
+ <div style="max-width: 450px">
155
+ SceneServer服务请直接输入服务地址,G3D服务既可以通过ip、port、服务
156
+ 名配置,也可以直接输入服务地址!
157
+ </div>
158
+ </template>
159
+ <mapgis-ui-iconfont
160
+ v-if="nodeInfoTitle === '添加节点'"
161
+ type="mapgis-info-circle"
162
+ :style="{ color: '#d89614' }"
163
+ ></mapgis-ui-iconfont>
164
+ {{ nodeInfoTitle === "添加节点" ? nodeInfoTitle : "" }}
165
+ </mapgis-ui-tooltip>
166
+ </span>
167
+
168
+ <span class="title-age" v-if="nodeInfoTitle !== '添加节点'"
169
+ >修改节点</span
170
+ >
171
+ </div>
172
+ <node-data-setting
173
+ @change-node-data="changeNodeData"
174
+ :base-config="baseConfig"
175
+ :node-data="newData"
176
+ :server-types="serverTypes"
177
+ :add-node-type="addNodeType"
178
+ :right-click-node="rightClickNode"
179
+ :right-click-data="rightClickData"
180
+ :current-edit-node="currentEditNode"
181
+ />
182
+ <span slot="footer">
183
+ <mapgis-ui-button type="primary" @click="addNodeCallBack"
184
+ >确 定</mapgis-ui-button
185
+ >
186
+ </span>
187
+ </mapgis-ui-modal>
188
+ </div>
189
+ </template>
190
+
191
+ <script>
192
+ import { mapGetters } from "vuex";
193
+ import NodeDataSetting from "./NodeDataSetting";
194
+ import { uuid } from "@/utils/uuid";
195
+
196
+ export default {
197
+ components: { NodeDataSetting },
198
+ props: {
199
+ config: {
200
+ type: [Object, Array],
201
+ },
202
+ baseConfig: {
203
+ type: Object,
204
+ },
205
+ },
206
+ data() {
207
+ if (!this.config.treeConfig.treeData) {
208
+ this.$set(this.config.treeConfig, "treeData", []);
209
+ }
210
+
211
+ return {
212
+ searchStr: "",
213
+ randomInputId: +new Date(),
214
+ defaultProps: {
215
+ key: "label",
216
+ label: "label",
217
+ children: "children",
218
+ },
219
+ addEditNode: {},
220
+ treeMenuVisible: false,
221
+ nodeInfoVisible: false,
222
+ addNodeType: "normal",
223
+ rightClickNode: {},
224
+ rightClickData: {},
225
+ currentEditNode: {},
226
+ newData: {},
227
+ addParent: true,
228
+ nodeType: "",
229
+ nodeInfoTitle: "",
230
+ deleteDialog: false,
231
+ expandedKeys: [],
232
+ autoExpandParent: true,
233
+ defaultExpandAll: true,
234
+ backupsExpandedKeys: [],
235
+ serverTypes: [
236
+ {
237
+ name: "MapGIS 矢量地图服务",
238
+ value: "IGSIMAGE",
239
+ type: "server",
240
+ },
241
+ {
242
+ name: "MapGIS瓦片地图服务",
243
+ value: "IGSTILED",
244
+ type: "server",
245
+ },
246
+ {
247
+ name: "MapGIS 图层地图服务",
248
+ value: "IGSVECTOR",
249
+ type: "server",
250
+ },
251
+ {
252
+ name: "MapGIS 矢量瓦片服务",
253
+ value: "VTTILES",
254
+ type: "server",
255
+ },
256
+ {
257
+ name: "IGSPanoramic 服务",
258
+ value: "IGSPanoramic",
259
+ type: "server",
260
+ },
261
+ {
262
+ name: "Plot 标绘服务",
263
+ value: "Plot",
264
+ type: "server",
265
+ },
266
+ {
267
+ name: "MapGIS 场景服务",
268
+ value: "IGSScene",
269
+ type: "globe",
270
+ },
271
+ {
272
+ name: "MapGIS 数据流服务",
273
+ value: "DataFlow",
274
+ type: "server",
275
+ },
276
+ {
277
+ name: "3DTiles服务",
278
+ value: "TILE3D",
279
+ type: "globe",
280
+ },
281
+ {
282
+ name: "MapGIS M3D模型缓存服务",
283
+ value: "ModelCache",
284
+ type: "globe",
285
+ },
286
+ {
287
+ name: "STK地形",
288
+ value: "STKTerrain",
289
+ type: "globe",
290
+ },
291
+ // {
292
+ // name: 'GEOJSON',
293
+ // value: 'GEOJSON',
294
+ // type: 'globe'
295
+ // },
296
+ {
297
+ name: "KML",
298
+ value: "KML",
299
+ type: "globe",
300
+ },
301
+ {
302
+ name: "KMZ",
303
+ value: "KMZ",
304
+ type: "globe",
305
+ },
306
+ {
307
+ name: "CZML",
308
+ value: "CZML",
309
+ type: "globe",
310
+ },
311
+ {
312
+ name: "ArcGIS 地图服务",
313
+ value: "IMAGEARCGIS",
314
+ type: "server",
315
+ },
316
+ {
317
+ name: "ArcGIS 瓦片服务",
318
+ value: "TILEARCGIS",
319
+ type: "server",
320
+ },
321
+ {
322
+ name: "OGC WMS 服务",
323
+ value: "WMS",
324
+ type: "server",
325
+ },
326
+ // {
327
+ // name: 'OGC WFS 服务',
328
+ // value: 'WFS',
329
+ // type: 'server'
330
+ // },
331
+ {
332
+ name: "OGC WMTS 服务",
333
+ value: "WMTS",
334
+ type: "server",
335
+ },
336
+ ],
337
+ preEditData: undefined,
338
+ };
339
+ },
340
+ computed: {
341
+ ...mapGetters(["baseApi"]),
342
+ isDataEmpty() {
343
+ return (
344
+ !this.config.treeConfig.treeData ||
345
+ this.config.treeConfig.treeData.length === 0
346
+ );
347
+ },
348
+ },
349
+ created() {},
350
+
351
+ methods: {
352
+ cancleModal() {
353
+ this.nodeInfoVisible = false;
354
+ },
355
+ // 计算图标
356
+ computedIcon(nodeData) {
357
+ let iconUrl;
358
+ const iconLength = nodeData.pos.split("-").length - 1;
359
+ iconUrl = this.baseApi + this.config.iconConfig[iconLength];
360
+
361
+ return iconUrl;
362
+ },
363
+ // 解决受控参数变化后展开失效
364
+ onExpand(expandedKeys) {
365
+ this.expandedKeys = expandedKeys;
366
+ this.autoExpandParent = false;
367
+ },
368
+ // 点击搜索进行模糊筛选
369
+ onSearch() {
370
+ const _this = this;
371
+ _this.searchValue = _this.searchStr;
372
+ if (_this.searchValue === "") {
373
+ _this.expandedKeys = [];
374
+ } else {
375
+ _this.expandedKeys = [];
376
+ _this.backupsExpandedKeys = [];
377
+ let candidateKeysList = _this.getkeyList(
378
+ _this.searchValue,
379
+ _this.config.treeConfig.treeData,
380
+ []
381
+ );
382
+ candidateKeysList.map((item) => {
383
+ let key = _this.getParentKey(item, _this.config.treeConfig.treeData);
384
+ if (key && !_this.backupsExpandedKeys.some((item) => item === key)) {
385
+ _this.backupsExpandedKeys.push(key);
386
+ }
387
+ });
388
+ let length = _this.backupsExpandedKeys.length;
389
+ for (let i = 0; i < length; i++) {
390
+ _this.getAllParentKey(
391
+ _this.backupsExpandedKeys[i],
392
+ _this.config.treeConfig.treeData
393
+ );
394
+ }
395
+ if (_this.backupsExpandedKeys.slice.length > 0) {
396
+ _this.expandedKeys = _this.backupsExpandedKeys.slice();
397
+ } else {
398
+ _this.expandedKeys = [];
399
+ }
400
+ _this.autoExpandParent = true;
401
+ }
402
+ },
403
+ // 获取节点中含有value的所有key集合
404
+ getkeyList(value, tree, keyList) {
405
+ for (let i = 0; i < tree.length; i++) {
406
+ let node = tree[i];
407
+ node.scopedSlots = { title: "label" };
408
+ if (node.label.indexOf(value) > -1) {
409
+ keyList.push(node.label);
410
+ }
411
+ if (node.children) {
412
+ this.getkeyList(value, node.children, keyList);
413
+ }
414
+ }
415
+ return keyList;
416
+ },
417
+
418
+ // 该递归主要用于获取key的父亲节点的key值
419
+ getParentKey(key, tree) {
420
+ let parentKey;
421
+ for (let i = 0; i < tree.length; i++) {
422
+ const node = tree[i];
423
+ if (node.children) {
424
+ if (node.children.some((item) => item.label === key)) {
425
+ parentKey = node.label;
426
+ } else if (this.getParentKey(key, node.children)) {
427
+ parentKey = this.getParentKey(key, node.children);
428
+ }
429
+ }
430
+ }
431
+ return parentKey;
432
+ },
433
+ // 获取该节点的所有祖先节点
434
+ getAllParentKey(key, tree) {
435
+ let parentKey;
436
+ if (key) {
437
+ parentKey = this.getParentKey(key, tree);
438
+ if (parentKey) {
439
+ if (!this.backupsExpandedKeys.some((item) => item === parentKey)) {
440
+ this.backupsExpandedKeys.push(parentKey);
441
+ }
442
+ this.getAllParentKey(parentKey, tree);
443
+ }
444
+ }
445
+ },
446
+ // 拖拽
447
+ onDrop(info) {
448
+ const dropKey = info.node.eventKey;
449
+ const dragLabel = info.dragNode.dataRef.label;
450
+ const dragKey = info.dragNode.eventKey;
451
+ const dropLabel = info.node.dataRef.label;
452
+ const dropPos = info.node.pos.split("-");
453
+ const dropPosition =
454
+ info.dropPosition - Number(dropPos[dropPos.length - 1]);
455
+ const loop = (data, key, callback) => {
456
+ data.forEach((item, index, arr) => {
457
+ if (item.label === key) {
458
+ return callback(item, index, arr);
459
+ }
460
+ if (item.children) {
461
+ return loop(item.children, key, callback);
462
+ }
463
+ });
464
+ };
465
+ const data = [...this.config.treeConfig.treeData];
466
+
467
+ // Find dragObject
468
+ let dragObj;
469
+ loop(data, dragLabel, (item, index, arr) => {
470
+ arr.splice(index, 1);
471
+ dragObj = item;
472
+ });
473
+ if (!info.dropToGap) {
474
+ // Drop on the content
475
+ loop(data, dropLabel, (item) => {
476
+ item.children = item.children || [];
477
+ // where to insert 示例添加到尾部,可以是随意位置
478
+ item.children.push(dragObj);
479
+ });
480
+ } else if (
481
+ (info.node.children || []).length > 0 && // Has children
482
+ info.node.expanded && // Is expanded
483
+ dropPosition === 1 // On the bottom gap
484
+ ) {
485
+ loop(data, dropLabel, (item) => {
486
+ item.children = item.children || [];
487
+ // where to insert 示例添加到尾部,可以是随意位置
488
+ item.children.unshift(dragObj);
489
+ });
490
+ } else {
491
+ let ar;
492
+ let i;
493
+ loop(data, dropLabel, (item, index, arr) => {
494
+ ar = arr;
495
+ i = index;
496
+ });
497
+ if (dropPosition === -1) {
498
+ ar.splice(i, 0, dragObj);
499
+ } else {
500
+ ar.splice(i + 1, 0, dragObj);
501
+ }
502
+ }
503
+ this.config.treeConfig.treeData = data;
504
+ },
505
+ // 右键点击显示菜单
506
+ onRightClick({ event, node }) {
507
+ this.addEditNode = node;
508
+ const answer = node._props.dataRef.anwer;
509
+ if (answer) {
510
+ this.$refs.contextmenu.hide();
511
+ this.answer = answer;
512
+ return;
513
+ }
514
+ this.NodeTreeItem = {
515
+ id: node._props.eventKey,
516
+ title: node._props.title,
517
+ parentId: node._props.dataRef.parentId || null,
518
+ };
519
+ const x = event.clientX;
520
+ const y = event.clientY;
521
+ const postition = {
522
+ top: y,
523
+ left: x,
524
+ };
525
+ this.$refs.contextmenu.show(postition);
526
+ },
527
+ // 拖拽事件 参数依次为:被拖拽节点对应的 Node、结束拖拽时最后进入的节点、被拖拽节点的放置位置(before、after、inner)、event
528
+ async handleDrop(draggingNode, dropNode, dropType, ev) {
529
+ var paramData = [];
530
+ // 当拖拽类型不为inner,说明只是同级或者跨级排序,只需要寻找目标节点的父ID,获取其对象以及所有的子节点,并为子节点设置当前对象的ID为父ID即可
531
+ // 当拖拽类型为inner,说明拖拽节点成为了目标节点的子节点,只需要获取目标节点对象即可
532
+ var data = dropType !== "inner" ? dropNode.parent.data : dropNode.data;
533
+ var nodeData =
534
+ dropNode.level === 1 && dropType !== "inner" ? data : data.children;
535
+ // 设置父ID,当level为1说明在第一级,pid为空
536
+ nodeData.forEach((element) => {
537
+ element.pid = data.id;
538
+ });
539
+ nodeData.forEach((element, i) => {
540
+ var dept = {
541
+ deptId: element.id,
542
+ parentDeptId: element.pid,
543
+ order: i,
544
+ };
545
+ paramData.push(dept);
546
+ });
547
+
548
+ this.loading = true;
549
+ },
550
+
551
+ changeNodeData(val) {
552
+ this.newData["name"] = val;
553
+ },
554
+ importData(e) {
555
+ // 利用fileReader对象获取file
556
+ const file = e.target.files[0];
557
+ const reader = new FileReader();
558
+ reader.readAsText(file);
559
+ reader.onload = (e) => {
560
+ this.$set(
561
+ this.config.treeConfig,
562
+ "treeData",
563
+ JSON.parse(e.target.result)
564
+ );
565
+ };
566
+ },
567
+ clearData() {
568
+ this.config.treeConfig.treeData = [];
569
+ },
570
+ onSelect(data, node) {
571
+ console.log(data, node.halfCheckedKeys);
572
+ },
573
+ exportData() {
574
+ const eleLink = document.createElement("a");
575
+ eleLink.download = "配置数据.json";
576
+ eleLink.style.display = "none";
577
+ // 字符内容转变成blob地址
578
+ const blob = new Blob([JSON.stringify(this.config.treeConfig.treeData)]);
579
+ eleLink.href = URL.createObjectURL(blob);
580
+ // 触发点击
581
+ document.body.appendChild(eleLink);
582
+ eleLink.click();
583
+ // 然后移除
584
+ document.body.removeChild(eleLink);
585
+ },
586
+ addNode(type, node) {
587
+ this.treeMenuVisible = false;
588
+ this.currentEditNode = null;
589
+ this.addNodeType = type;
590
+ let data = {};
591
+ if (type === "normal") {
592
+ data = {
593
+ label: "",
594
+ describe: "",
595
+ };
596
+ } else if (type === "globe") {
597
+ data = {
598
+ label: "",
599
+ describe: "",
600
+ ip: "",
601
+ port: "",
602
+ layerServiceType: "IGSScene",
603
+ name: "",
604
+ searchName: "",
605
+ serverUrl: "",
606
+ model: "surface",
607
+ guid: "",
608
+ };
609
+ } else if (type === "server") {
610
+ data = {
611
+ label: "",
612
+ describe: "",
613
+ ip: "",
614
+ port: "",
615
+ layerServiceType: "IGSIMAGE",
616
+ name: "",
617
+ searchName: "",
618
+ serverUrl: "",
619
+ tokenKey: "",
620
+ token: "",
621
+ wfsUrl: "",
622
+ extent: "",
623
+ guid: "",
624
+ };
625
+ } else if (type === "data") {
626
+ data = {
627
+ label: "",
628
+ describe: this.config.otherConfig.nonSpatial,
629
+ data: "",
630
+ };
631
+ }
632
+ this.newData = data;
633
+ this.nodeInfoVisible = true;
634
+ if (node) {
635
+ this.addParent = false;
636
+ } else {
637
+ this.addParent = true;
638
+ }
639
+ this.nodeInfoTitle = "添加节点";
640
+ },
641
+ // nodeContextmenu(event, obj, data, tree) {
642
+ // this.treeMenuVisible = true;
643
+ // this.rightClickData = data.data;
644
+ // this.rightClickNode = data;
645
+ // const menu = document.querySelector("#treeDataMenu");
646
+ // const bodyHeight = document.getElementsByTagName("body")[0].clientHeight;
647
+ // const menuHeight = 154; // menu.clientHeight的高度
648
+ // /* 菜单定位基于鼠标点击位置 */
649
+ // menu.style.left = `${event.clientX}px`;
650
+ // if (event.clientY + menuHeight > bodyHeight) {
651
+ // // 如果鼠标点击高度和右键菜单高度加起来比整个页面高度大,那么右键菜单就向
652
+
653
+ // 上显示;
654
+ // menu.style.top = ``;
655
+ // menu.style.bottom = `${bodyHeight - event.clientY}px`;
656
+ // } else {
657
+ // menu.style.bottom = ``;
658
+ // menu.style.top = `${event.clientY}px`;
659
+ // }
660
+ // if (
661
+ // Object.prototype.hasOwnProperty.call(
662
+ // this.rightClickData,
663
+ // "layerServiceType"
664
+ // )
665
+ // ) {
666
+ // if (
667
+ // Object.prototype.hasOwnProperty.call(this.rightClickData, "model")
668
+ // ) {
669
+ // this.nodeType = "globe";
670
+ // } else {
671
+ // this.nodeType = "server";
672
+ // }
673
+ // } else if (
674
+ // Object.prototype.hasOwnProperty.call(this.rightClickData, "data")
675
+ // ) {
676
+ // this.nodeType = "data";
677
+ // } else {
678
+ // this.nodeType = "normal";
679
+ // }
680
+ // },
681
+ selectTreeNode(data, node, tree) {
682
+ this.treeMenuVisible = false;
683
+ },
684
+ editNode(data, node) {
685
+ this.rightClickNode = null;
686
+ this.currentEditNode = node;
687
+ this.newData = data;
688
+ this.preEditData = JSON.parse(JSON.stringify(data));
689
+ this.nodeInfoVisible = true;
690
+ this.nodeInfoTitle = "修改节点";
691
+ if (Object.prototype.hasOwnProperty.call(data, "model")) {
692
+ this.addNodeType = "globe";
693
+ } else if (
694
+ Object.prototype.hasOwnProperty.call(data, "layerServiceType")
695
+ ) {
696
+ this.addNodeType = "server";
697
+ } else if (Object.prototype.hasOwnProperty.call(data, "data")) {
698
+ this.addNodeType = "data";
699
+ } else {
700
+ this.addNodeType = "normal";
701
+ }
702
+ },
703
+ deleteNode(node) {
704
+ const vm = this;
705
+ const modal = this.$confirm({
706
+ title: "提示",
707
+ content: "是否删除该节点?",
708
+ okText: "确认",
709
+ cancelText: "取消",
710
+ onOk(e) {
711
+ return new Promise((resolve, reject) => {
712
+ try {
713
+ const treeData = vm.config.treeConfig.treeData;
714
+ vm.config.treeConfig.treeData = vm.deleteParentNode(
715
+ treeData,
716
+ node.label
717
+ );
718
+ vm.$message.success("删除成功! ");
719
+ } catch (error) {
720
+ vm.$message.error("删除失败! ");
721
+ } finally {
722
+ resolve();
723
+ }
724
+ });
725
+ },
726
+ });
727
+ },
728
+ deleteParentNode(data, key) {
729
+ const ret = [];
730
+ const vm = this;
731
+ data.forEach((ele) => {
732
+ if (ele.label !== key) {
733
+ if (ele.children) {
734
+ ele.children = vm.deleteParentNode(ele.children, key);
735
+ }
736
+ ret.push(ele);
737
+ }
738
+ });
739
+ return ret;
740
+ },
741
+ addNodeCallBack() {
742
+ const data = this.newData;
743
+ if (
744
+ data.label === "" ||
745
+ (Object.prototype.hasOwnProperty.call(data, "name") &&
746
+ data.name === "" &&
747
+ data.serverUrl === "")
748
+ ) {
749
+ this.$message.error("参数错误!");
750
+ } else {
751
+ let flag = true;
752
+ let msg = "";
753
+ // const datas = this.filtTreeData('label', data.label)
754
+ const nonSpatial = this.config.treeConfig.useLocalData
755
+ ? this.config.defaultNonSpatial
756
+ : this.config.otherConfig.nonSpatial;
757
+ const clickData =
758
+ this.currentEditNode && Object.keys(this.currentEditNode).length > 0
759
+ ? this.currentEditNode.parent.data
760
+ : this.rightClickData;
761
+ const clickDataChildren =
762
+ clickData && clickData.children ? clickData.children : undefined;
763
+ const datas = this.filtNodeData("label", data.label, clickDataChildren);
764
+ if (
765
+ data.label !== nonSpatial &&
766
+ ((this.currentEditNode && datas.length > 1) ||
767
+ (!this.currentEditNode && datas.length > 0))
768
+ ) {
769
+ // 只要保证同级没有相同名称的节点即可
770
+ flag = false;
771
+ msg = "已存在相同名称的节点";
772
+ if (this.currentEditNode) {
773
+ // 编辑的时候如果存在相同值,则恢复之前的值
774
+ this.newData = { ...this.preEditData };
775
+ this.currentEditNode.data = { ...this.preEditData };
776
+ this.restoreTreeData(this.currentEditNode);
777
+ }
778
+ }
779
+ if (flag) {
780
+ if (
781
+ Object.prototype.hasOwnProperty.call(data, "guid") &&
782
+ data.guid === ""
783
+ ) {
784
+ data.guid = uuid();
785
+ }
786
+ if (this.currentEditNode) {
787
+ this.currentEditNode.setData(data);
788
+ } else {
789
+ if (!this.addParent) {
790
+ if (this.addEditNode.dataRef.children) {
791
+ this.addEditNode.dataRef.children.push(data);
792
+ } else {
793
+ this.addEditNode.dataRef.children = [];
794
+ this.addEditNode.dataRef.children.push(data);
795
+ }
796
+ } else {
797
+ this.config.treeConfig.treeData.push(data);
798
+ }
799
+ }
800
+ this.nodeInfoVisible = false;
801
+ } else {
802
+ this.$message.error(msg);
803
+ }
804
+ }
805
+ },
806
+ filtNodeData(key, value, data, array) {
807
+ if (!array) {
808
+ array = [];
809
+ }
810
+ if (!data) {
811
+ data = this.config.treeConfig.treeData;
812
+ }
813
+ for (let i = 0; i < data.length; i++) {
814
+ if (data[i][key] === value) {
815
+ array.push(data[i]);
816
+ }
817
+ }
818
+ return array;
819
+ },
820
+ /**
821
+ * 恢复基础目录树数据
822
+ */
823
+ restoreTreeData(node) {
824
+ if (node.parent) {
825
+ const children = [];
826
+ const { childNodes } = node.parent;
827
+ for (let i = 0; i < childNodes.length; i++) {
828
+ children.push(childNodes[i].data);
829
+ }
830
+ node.parent.data.children = [...children];
831
+ this.restoreTreeData(node.parent);
832
+ } else {
833
+ this.treeData = { ...node.data };
834
+ }
835
+ },
836
+ filtTreeData(key, value, data, array) {
837
+ if (!array) {
838
+ array = [];
839
+ }
840
+ if (!data) {
841
+ data = this.config.treeConfig.treeData;
842
+ }
843
+ for (let i = 0; i < data.length; i++) {
844
+ if (data[i][key] === value) {
845
+ array.push(data[i]);
846
+ }
847
+ if (data[i].children) {
848
+ this.filtTreeData(key, value, data[i].children, array);
849
+ }
850
+ }
851
+ return array;
852
+ },
853
+ },
854
+ };
855
+ </script>
856
+
857
+ <style lang="scss" scoped>
858
+ .data-source-setting-wrapper {
859
+ .import-cover {
860
+ pointer-events: none;
861
+ color: #fff;
862
+ background-color: #49aa19;
863
+ border: #49aa19;
864
+ }
865
+ .icon-danger {
866
+ color: #fff;
867
+ background-color: #a61d24;
868
+ border: #a61d24;
869
+ }
870
+ .icon-warning {
871
+ color: #fff;
872
+ background-color: #d89614;
873
+ border: #d89614;
874
+ }
875
+ #treeDataMenu {
876
+ position: fixed;
877
+ z-index: 10000;
878
+ padding: 0;
879
+ margin: 0;
880
+ border-radius: 2px;
881
+ box-shadow: 0 2px 12px 0 hsla(0, 0%, 60%, 0.15);
882
+ .el-menu-item {
883
+ height: 36px;
884
+ line-height: 36px;
885
+ &.is-active {
886
+ color: unset;
887
+ }
888
+ }
889
+ }
890
+ .tree-data-icon {
891
+ width: 18px;
892
+ height: 18px;
893
+ vertical-align: middle;
894
+ }
895
+ }
896
+ </style>
897
+
898
+ <style lang="scss">
899
+ .mapgis-ui-popover {
900
+ background: unset;
901
+ }
902
+ .mapgis-ui-btn-sm {
903
+ border: unset;
904
+ }
905
+ .data-source-setting-wrapper {
906
+ .setting-header {
907
+ .setting-item {
908
+ margin-right: 8px;
909
+ }
910
+ }
911
+ .setting-content {
912
+ .mapgis-ui-tooltip-arrow::before {
913
+ background-color: "#141414";
914
+ }
915
+ .tooltip-inner {
916
+ background-color: "#141414";
917
+ }
918
+ .node-actions {
919
+ display: none;
920
+ .mapgis-ui-btn-text {
921
+ border: unset;
922
+ }
923
+ }
924
+ .el-tree-node__content:hover .node-actions {
925
+ display: unset;
926
+ }
927
+ }
928
+ }
929
+ </style>