bri-components 1.5.21 → 1.6.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 (153) hide show
  1. package/README.md +83 -83
  2. package/lib/styles/bundle.css +12 -12
  3. package/lib/styles/font/fontello.svg +31 -31
  4. package/package.json +125 -125
  5. package/src/components/Error/Error403.vue +42 -42
  6. package/src/components/Error/Error404.vue +40 -40
  7. package/src/components/Error/Error500.vue +51 -51
  8. package/src/components/Error/error.less +162 -162
  9. package/src/components/Error/errorBack.vue +40 -40
  10. package/src/components/controls/DshControlInput.vue +195 -195
  11. package/src/components/controls/base/BriUpload/BriUpload.vue +434 -434
  12. package/src/components/controls/base/BriUpload/BriUploadImage.vue +377 -377
  13. package/src/components/controls/base/BriUpload/uploadList.vue +727 -727
  14. package/src/components/controls/base/BriUpload/uploadMixin.js +446 -446
  15. package/src/components/controls/base/DshCascader/DshCascader.vue +215 -215
  16. package/src/components/controls/base/DshCascader/components/cascaderModal.vue +366 -366
  17. package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +416 -416
  18. package/src/components/controls/base/DshCascader/components/cascaderSimple.vue +141 -141
  19. package/src/components/controls/base/DshCascader/components/cascaderTree.vue +151 -151
  20. package/src/components/controls/base/DshCoordinates.vue +585 -577
  21. package/src/components/controls/base/DshDate/DshDate.vue +191 -191
  22. package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
  23. package/src/components/controls/base/DshDivider.vue +201 -201
  24. package/src/components/controls/base/DshEditor.vue +274 -274
  25. package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
  26. package/src/components/controls/base/DshInput/DshInput.vue +260 -260
  27. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
  28. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
  29. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
  30. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
  31. package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
  32. package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
  33. package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
  34. package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
  35. package/src/components/controls/base/DshSelect/DshSelectAll.vue +269 -269
  36. package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
  37. package/src/components/controls/control.less +324 -324
  38. package/src/components/controls/controlMap.js +117 -117
  39. package/src/components/controls/extra/DshColor.vue +81 -81
  40. package/src/components/controls/extra/DshThemeColor.vue +100 -100
  41. package/src/components/controls/extra/DshThemeIcon.vue +122 -122
  42. package/src/components/controls/mixins/cascaderMixin.js +325 -325
  43. package/src/components/controls/mixins/cascaderPickerMixin.js +227 -227
  44. package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
  45. package/src/components/controls/mixins/controlMixin.js +393 -393
  46. package/src/components/controls/mixins/dateMixin.js +149 -149
  47. package/src/components/controls/mixins/flatTableMixin.js +111 -111
  48. package/src/components/controls/mixins/numberMixin.js +112 -112
  49. package/src/components/controls/mixins/selectMixin.js +233 -233
  50. package/src/components/controls/mixins/switchMixin.js +87 -87
  51. package/src/components/controls/mixins/userAndDepartMixin.js +260 -260
  52. package/src/components/controls/senior/DshLabels.vue +333 -333
  53. package/src/components/controls/senior/DshPackage.vue +57 -57
  54. package/src/components/controls/senior/cascaderTable.vue +213 -213
  55. package/src/components/controls/senior/correlation.vue +135 -135
  56. package/src/components/controls/senior/flatTable.vue +138 -138
  57. package/src/components/controls/senior/selectDepartments.vue +399 -399
  58. package/src/components/controls/senior/selectUsers/departMenu.vue +293 -293
  59. package/src/components/controls/senior/selectUsers/selectUsers.vue +712 -712
  60. package/src/components/controls/special/DshBack.vue +42 -42
  61. package/src/components/controls/special/DshUndeveloped.vue +41 -41
  62. package/src/components/form/DshAdvSearch.vue +510 -510
  63. package/src/components/form/DshDefaultSearch.vue +260 -260
  64. package/src/components/form/DshForm.vue +494 -494
  65. package/src/components/form/searchMixin.js +376 -376
  66. package/src/components/list/BriCard.vue +95 -95
  67. package/src/components/list/BriTable.vue +205 -205
  68. package/src/components/list/BriTree.vue +529 -529
  69. package/src/components/list/BriTreeItem.vue +163 -163
  70. package/src/components/list/DshBox/DshBox.vue +219 -219
  71. package/src/components/list/DshBox/DshCard.vue +446 -446
  72. package/src/components/list/DshBox/DshCrossTable.vue +827 -827
  73. package/src/components/list/DshBox/DshList.vue +404 -404
  74. package/src/components/list/DshBox/DshPanel.vue +669 -669
  75. package/src/components/list/DshBox/DshSingleData.vue +119 -119
  76. package/src/components/list/DshBox/DshTable.vue +239 -239
  77. package/src/components/list/DshCascaderTable.vue +115 -115
  78. package/src/components/list/DshFlatTable.vue +337 -337
  79. package/src/components/list/DshPage.vue +194 -194
  80. package/src/components/list/DshTreeTable.vue +113 -113
  81. package/src/components/list/common/importModal.vue +243 -243
  82. package/src/components/list/common/quoteListModal.vue +206 -206
  83. package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
  84. package/src/components/list/mixins/DshFlatTableMixin.js +509 -509
  85. package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
  86. package/src/components/list/mixins/tableBaseMixin.js +1653 -1653
  87. package/src/components/list/mixins/treeTableBaseMixin.js +145 -145
  88. package/src/components/other/BriAvatar.vue +166 -166
  89. package/src/components/other/BriCode.vue +125 -125
  90. package/src/components/other/BriCollapseTree.vue +207 -207
  91. package/src/components/other/BriGantt.vue +1087 -1087
  92. package/src/components/other/BriIframe.vue +116 -116
  93. package/src/components/other/BriLoading.vue +171 -171
  94. package/src/components/other/BriSvg.vue +27 -27
  95. package/src/components/other/DshColorPanel.vue +128 -128
  96. package/src/components/other/DshMenuNav.vue +188 -188
  97. package/src/components/small/BriButton.vue +71 -71
  98. package/src/components/small/BriDrawer.vue +169 -169
  99. package/src/components/small/BriTooltip.vue +87 -87
  100. package/src/components/small/DshBtnModal.vue +68 -68
  101. package/src/components/small/DshButtons.vue +324 -324
  102. package/src/components/small/DshDropdown.vue +225 -225
  103. package/src/components/small/DshIcons.vue +59 -59
  104. package/src/components/small/DshListRender.js +21 -21
  105. package/src/components/small/DshModal.vue +160 -160
  106. package/src/components/small/DshSteps.vue +141 -141
  107. package/src/components/small/DshTabs.vue +598 -598
  108. package/src/components/small/DshTabsSet.vue +309 -309
  109. package/src/components/small/DshTags.vue +251 -251
  110. package/src/components/small/DshTitle.vue +50 -50
  111. package/src/components/small/render.js +20 -20
  112. package/src/components/unit/DshFormUnit.vue +398 -398
  113. package/src/components/unit/DshListUnit.vue +115 -115
  114. package/src/components/unit/unitMixin.js +86 -86
  115. package/src/data/index.js +4 -4
  116. package/src/index.js +285 -285
  117. package/src/styles/bundle.css +12 -12
  118. package/src/styles/components/BriButton.less +307 -307
  119. package/src/styles/components/BriTable.less +344 -344
  120. package/src/styles/components/DshModal.less +257 -257
  121. package/src/styles/components/index.less +3 -3
  122. package/src/styles/global/animate.less +11 -11
  123. package/src/styles/global/base.less +45 -45
  124. package/src/styles/global/box.less +186 -186
  125. package/src/styles/global/control.less +122 -122
  126. package/src/styles/global/flex.less +282 -282
  127. package/src/styles/global/global.less +8 -8
  128. package/src/styles/global/text.less +59 -59
  129. package/src/styles/global/variables.less +85 -85
  130. package/src/styles/iconfont/iconfont.css +254 -254
  131. package/src/styles/iconfont/iconfont.json +422 -422
  132. package/src/styles/iconfont/iconfont.svg +137 -137
  133. package/src/styles/index.less +26 -26
  134. package/src/styles/reset-easytable.less +21 -21
  135. package/src/styles/reset-iview-controls.less +145 -145
  136. package/src/styles/reset-iview-other.less +49 -49
  137. package/src/styles/reset-iview-variables.less +43 -43
  138. package/src/styles/reset.less +45 -45
  139. package/src/utils/index.js +3 -5
  140. package/lib/0.bri-components.min.js +0 -1
  141. package/lib/1.bri-components.min.js +0 -1
  142. package/lib/10.bri-components.min.js +0 -1
  143. package/lib/11.bri-components.min.js +0 -1
  144. package/lib/2.bri-components.min.js +0 -1
  145. package/lib/3.bri-components.min.js +0 -1
  146. package/lib/4.bri-components.min.js +0 -1
  147. package/lib/5.bri-components.min.js +0 -1
  148. package/lib/6.bri-components.min.js +0 -1
  149. package/lib/7.bri-components.min.js +0 -1
  150. package/lib/8.bri-components.min.js +0 -1
  151. package/lib/9.bri-components.min.js +0 -1
  152. package/lib/bri-components.min.js +0 -18
  153. package/src/utils/table.js +0 -175
@@ -1,577 +1,585 @@
1
- <template>
2
- <!-- 单选模式 编辑 -->
3
- <div
4
- v-if="!multipleMode && canEdit"
5
- class="DshCoordinates"
6
- >
7
- <bri-tooltip
8
- :content="showVal"
9
- :transfer="true"
10
- >
11
- <!-- 编辑 -->
12
- <dsh-control-input
13
- :class="commonClass"
14
- :value="curVal"
15
- :disabled="disabled"
16
- :propsObj="selfPropsObj"
17
- @clear="clickClear"
18
- @click.native="clickInput"
19
- ></dsh-control-input>
20
- </bri-tooltip>
21
-
22
- <!-- 模态框 -->
23
- <Modal
24
- class="DshCoordinates-modal"
25
- v-model="showModal"
26
- :styles="modalStyles"
27
- :footer-hide="true"
28
- >
29
- <!-- 顶部 -->
30
- <div
31
- slot="header"
32
- class="DshCoordinates-modal-header"
33
- >
34
- <!-- 可编辑 -->
35
- <Row
36
- v-if="!disabled"
37
- class="header-edit"
38
- type="flex"
39
- justify="center"
40
- align="bottom"
41
- >
42
- <i-col span="8">
43
- <radio-group v-model="formData.kind">
44
- <Radio label="keyword">按关键字搜索</Radio>
45
- <Radio label="coordinate">按坐标搜索</Radio>
46
- </radio-group>
47
-
48
- <Row class="header-edit-row">
49
- <i-col span="16">
50
- <Input
51
- v-model="formData.searchText"
52
- placeholder="请输入..."
53
- :clearable="true"
54
- @on-enter="clickSearch"
55
- />
56
- <span class="header-edit-message">{{ searchMessage }}</span>
57
- </i-col>
58
-
59
- <i-col span="8">
60
- <Button
61
- type="primary"
62
- @click="clickSearch"
63
- >搜索</Button>
64
- </i-col>
65
- </Row>
66
- </i-col>
67
-
68
- <i-col span="8">
69
- <div class="header-edit-text">坐标获取结果</div>
70
- <Row class="header-edit-row">
71
- <i-col span="16">
72
- <Input
73
- :value="newVal.name"
74
- :readonly="true"
75
- :clearable="true"
76
- @on-clear="clickModalClear"
77
- @click.native="clickMapFitView"
78
- />
79
- </i-col>
80
-
81
- <i-col span="8">
82
- <Button
83
- type="primary"
84
- @click="clickConfirm"
85
- >确认</Button>
86
- </i-col>
87
- </Row>
88
- </i-col>
89
- </Row>
90
-
91
- <!-- 不可编辑 -->
92
- <Row
93
- v-else
94
- class="header-show"
95
- >
96
- <i-col
97
- span="6"
98
- class="header-show-text"
99
- >
100
- 当前位置:
101
- </i-col>
102
-
103
- <i-col span="12">
104
- <Input
105
- :value="newVal.name"
106
- :readonly="true"
107
- @click.native="clickMapFitView"
108
- />
109
- </i-col>
110
-
111
- <i-col span="6"></i-col>
112
- </Row>
113
- </div>
114
-
115
- <!-- 地图 -->
116
- <transition>
117
- <div
118
- v-if="showModal"
119
- id="DshCoordinatesMap"
120
- class="DshCoordinates-modal-map"
121
- ></div>
122
- </transition>
123
-
124
- <!-- 实时坐标 -->
125
- <div
126
- ref="lnglatRef"
127
- class="DshCoordinates-modal-lnglat"
128
- ></div>
129
- </Modal>
130
- </div>
131
-
132
- <!-- 单选模式 查看 -->
133
- <div
134
- v-else-if="!multipleMode && !canEdit"
135
- class="DshCoordinates-show"
136
- >
137
- <!-- 有值 -->
138
- <template v-if="!$isEmptyData(curVal)">
139
- <!-- 高度自由时 -->
140
- <div
141
- v-if="isHeightAuto"
142
- :class="{
143
- ...commonClass,
144
- 'DshCoordinates-show-auto': true
145
- }"
146
- >
147
- {{ showVal }}
148
- </div>
149
-
150
- <!-- 高度不自由(不换行) -->
151
- <bri-tooltip
152
- v-else
153
- :content="showVal"
154
- :transfer="true"
155
- >
156
- <div :class="{
157
- ...commonClass,
158
- 'DshCoordinates-show-ellipsis': true
159
- }">
160
- {{ showVal }}
161
- </div>
162
- </bri-tooltip>
163
- </template>
164
-
165
- <!-- 无值 -->
166
- <div
167
- v-else
168
- :class="commonClass"
169
- >
170
- {{ emptyShowVal }}
171
- </div>
172
- </div>
173
- </template>
174
-
175
- <script>
176
- import controlMixin from "../mixins/controlMixin.js";
177
-
178
- const plotStrokeColor = "#4575EF";
179
- const plotFillColor = "#4575EF";
180
- let polygonOpt = {
181
- fillColor: plotFillColor,
182
- fillOpacity: 0.4,
183
- strokeColor: plotStrokeColor,
184
- strokeWeight: 5
185
- };
186
- let lineOpt = {
187
- strokeColor: plotStrokeColor,
188
- strokeWeight: 5
189
- };
190
- let markerOpt = {};
191
-
192
- export default {
193
- name: "DshCoordinates",
194
- mixins: [
195
- controlMixin
196
- ],
197
- data () {
198
- return {
199
- showModal: false,
200
- newVal: {
201
- name: "",
202
- lnglat: []
203
- },
204
- modalStyles: {
205
- height: document.body.clientHeight * 0.96 + "px",
206
- width: document.body.clientWidth * 0.96 + "px",
207
- top: "2%"
208
- },
209
- formData: {
210
- kind: "keyword",
211
- searchText: ""
212
- },
213
-
214
- // 地图相应控件
215
- map: null,
216
- placeSearch: null,
217
- mouseTool: null,
218
- marker: null, // 标记点
219
- plot: null, // 标记图形
220
- searchMessage: "" // 提示信息
221
- };
222
- },
223
- computed: {
224
- selfPropsObj () {
225
- return {
226
- _mapType: "2D", // "2D", "3D"
227
- _showType: "marker", // "marker", "multipleMarker", "polyline", "polygon", "rectangle"
228
- _icon: "ios-map-outline",
229
-
230
- ...this.propsObj,
231
- ...this.commonDealPropsObj
232
- };
233
- },
234
- subType () {
235
- return this.selfPropsObj._mapType;
236
- },
237
- showMode () {
238
- return this.selfPropsObj._showType;
239
- },
240
-
241
- curVal: {
242
- get () {
243
- return this.value[this.controlKey] || {
244
- name: "",
245
- lnglat: []
246
- };
247
- },
248
- set (val) {
249
- this.value[this.controlKey] = val;
250
- this.change();
251
- }
252
- },
253
- showVal () {
254
- return this.$isEmptyData(this.curVal)
255
- ? this.emptyShowVal
256
- : this.curVal.name;
257
- }
258
- },
259
- created () {},
260
- methods: {
261
- // 打开窗体
262
- clickInput () {
263
- if (this.canEdit) {
264
- this.showModal = true;
265
- this.newVal = this.$deepCopy(this.curVal);
266
- this.getMap();
267
- }
268
- },
269
- // 点击确认
270
- clickConfirm () {
271
- this.showModal = false;
272
- this.curVal = this.newVal;
273
- },
274
- // 清除已选内容
275
- clickModalClear () {
276
- this.newVal = {
277
- name: "",
278
- lnglat: []
279
- }; // 清除当前标记
280
- this.handleRmoveMarker("default"); // 清除地图内标记
281
- this.handleOpenDraw(); // 打开绘图功能
282
- },
283
- // 点击搜索
284
- clickSearch () {
285
- if (!this.formData.searchText) {
286
- this.searchMessage = "请输入搜索内容!";
287
- return;
288
- }
289
- if (this.formData.kind === "coordinate") {
290
- let lnglat = this.formData.searchText.split(",");
291
- let lng = Number(lnglat[0]);
292
- let lat = Number(lnglat[1]);
293
- if (isNaN(lng) || isNaN(lat) || lng < -180 || lng > 180 || lat < -90 || lat > 90) {
294
- this.searchMessage = "请输入正确的经纬度坐标!";
295
- } else {
296
- lnglat = new AMap.LngLat(lng, lat);
297
- this.searchMessage = "";
298
- this.handleAddMarker([lnglat.lng, lnglat.lat], true, "default");
299
- }
300
- } else {
301
- this.placeSearch.search(this.formData.searchText, this.handlePlaceSearchCallback);
302
- }
303
- },
304
- // 地图自适应点
305
- clickMapFitView (view = this.plot) {
306
- this.map.setFitView(view);
307
- },
308
- getMap () {
309
- this.$nextTick(() => {
310
- let lnglatRef = this.$refs.lnglatRef;
311
- this.map = new AMap.Map("DshCoordinatesMap", {
312
- rotateEnable: true,
313
- pitchEnable: true,
314
- zoom: this.propsObj._zoom || 12,
315
- pitch: 50,
316
- viewMode: this.subType,
317
- center: this.propsObj._center && this.propsObj._center.split(",").map(i => Number(i)) || undefined
318
- });
319
-
320
- // 滑动显示坐标点
321
- this.map.on("mouseover", function (e) {
322
- lnglatRef.style.display = "block";
323
- });
324
- this.map.on("mousemove", function (e) {
325
- lnglatRef.innerHTML = e.lnglat.toString();
326
- lnglatRef.style.top = (e.pixel.y + 120) + "px";
327
- lnglatRef.style.left = (e.pixel.x + 6) + "px";
328
- });
329
- this.map.on("mouseout", function (e) {
330
- lnglatRef.style.display = "none";
331
- });
332
-
333
- // 集成插件
334
- AMap.plugin(["AMap.PlaceSearch", "AMap.Scale", "AMap.ControlBar", "AMap.MouseTool"], this.handlePluginCallback);
335
-
336
- });
337
- },
338
- handlePluginCallback () {
339
- // 构造地点查询类
340
- this.placeSearch = new AMap.PlaceSearch();
341
- this.placeSearch.on("complete", this.handlePlaceSearchCallback);
342
- this.placeSearch.on("error", this.handlePlaceSearchCallback);
343
-
344
- // 加载集成工具
345
- this.map.addControl(new AMap.Scale());
346
- this.map.addControl(new AMap.ControlBar());
347
- // this.map.addControl(new AMap.ToolBar());
348
-
349
- // 监听draw事件可获取画好的覆盖物
350
- this.mouseTool = new AMap.MouseTool(this.map);
351
- this.mouseTool.on("draw", this.handleMouseToolCallback);
352
- // 设置默认坐标
353
- if (!this.$isEmptyData(this.newVal)) {
354
- this.handleAddMarker(this.newVal.lnglat, true);
355
-
356
- if (this.showMode === "multipleMarker") { // 多选打开绘图功能
357
- !this.disabled && this.handleOpenDraw();
358
- }
359
- } else {
360
- !this.disabled && this.handleOpenDraw();
361
- }
362
- },
363
- handleMouseToolCallback (e) {
364
- if (e.obj.CLASS_NAME === "AMap.Marker") {
365
- if (this.showMode === "marker") {
366
- this.plot = e.obj;
367
- this.handleCloseDraw();
368
- } else if (this.showMode === "multipleMarker") {
369
- if (this.plot) {
370
- this.plot.push(e.obj);
371
- } else {
372
- this.plot = [e.obj];
373
- }
374
- }
375
- // 设置坐标
376
- let lnglat = e.obj.getPosition();
377
- this.newVal.lnglat.push([lnglat.lng, lnglat.lat]);
378
- this.getRegeoCode();
379
-
380
- } else {
381
- this.plot = e.obj;
382
- // 设置坐标
383
- this.newVal.lnglat.push(...e.obj.getPath().map(lnglat => [lnglat.lng, lnglat.lat]));
384
- this.getRegeoCode();
385
- this.handleCloseDraw();
386
- }
387
- },
388
- handlePlaceSearchCallback (result) {
389
- if (result == "complete") {
390
- return;
391
- }
392
- if (result.poiList && result.poiList.pois && result.poiList.pois.length) {
393
- this.searchMessage = "";
394
- let poi = result.poiList.pois[0];
395
- this.handleAddMarker([poi.location.lng, poi.location.lat], true, "default");
396
- this.marker.setTitle([poi.name, poi.address].join(poi.name && poi.address ? "\n" : ""));
397
- } else {
398
- this.searchMessage = "没有搜索到结果!";
399
- }
400
- },
401
- // 打开绘图
402
- handleOpenDraw (type = this.showMode) {
403
- switch (type) {
404
- case "marker": {
405
- this.mouseTool.marker(markerOpt);
406
- break;
407
- }
408
- case "multipleMarker": {
409
- this.mouseTool.marker(markerOpt);
410
- break;
411
- }
412
- case "polyline": {
413
- this.mouseTool.polyline(lineOpt);
414
- break;
415
- }
416
- case "polygon": {
417
- this.mouseTool.polygon(polygonOpt);
418
- break;
419
- }
420
- case "rectangle": {
421
- this.mouseTool.rectangle(polygonOpt);
422
- break;
423
- }
424
- case "circle": {
425
- this.mouseTool.circle(polygonOpt);
426
- break;
427
- }
428
- }
429
- },
430
- // 关闭绘图
431
- handleCloseDraw () {
432
- this.mouseTool.close();
433
- },
434
- // 添加图形
435
- handleAddMarker (location, centerView = true, type = this.showMode) {
436
- location = JSON.parse(JSON.stringify(location));
437
- // 分类型添加
438
- if (["polygon", "rectangle", "circle"].includes(type)) {
439
- // 图形类
440
- this.plot = new AMap.Polygon({
441
- ...polygonOpt,
442
- path: location
443
- });
444
- this.map.add(this.plot);
445
- centerView && this.map.setFitView(this.plot);// 视口自适应
446
- } else if (["default"].includes(type)) {
447
- !this.marker && (this.marker = new AMap.Marker());
448
- this.marker.setPosition(location);
449
- this.marker.setMap(this.map);
450
- if (this.showMode === "marker") {
451
- this.handleRmoveMarker();
452
- this.handleCloseDraw();
453
- this.newVal.lnglat = [location];
454
- this.getRegeoCode();
455
- } else if (this.showMode === "multipleMarker") {
456
- this.newVal.lnglat.push(location);
457
- this.getRegeoCode();
458
- }
459
- centerView && this.map.setFitView(this.marker);
460
- } else if (["polyline"].includes(type)) {
461
- this.plot = new AMap.Polyline({
462
- ...polygonOpt,
463
- path: location
464
- });
465
- this.map.add(this.plot);
466
- centerView && this.map.setFitView(this.plot);// 视口自适应
467
- } else if (["multipleMarker", "marker"].includes(type)) {
468
- this.plot = location.map(position => {
469
- return new AMap.Marker({
470
- map: this.map,
471
- position: position
472
- });
473
- });
474
- centerView && this.map.setFitView(this.plot);
475
- }
476
- },
477
- // 移除图形
478
- handleRmoveMarker (type = this.showMode) {
479
- if (["default"].includes(type)) {
480
- this.marker && this.map.remove(this.marker);
481
- this.plot && this.map.remove(this.plot);
482
- } else {
483
- this.plot && this.map.remove(this.plot);
484
- }
485
- },
486
- // 获取逆地理编码
487
- getRegeoCode (value, scuessFun) {
488
- let params = {
489
- key: window.config.amapKey,
490
- location: this.newVal.lnglat[0],
491
- radius: 1000,
492
- extensions: "base",
493
- batch: false,
494
- roadlevel: 1
495
- };
496
-
497
- let paramStr = "";
498
- for (let attr in params) {
499
- paramStr += attr + "=" + params[attr] + "&";
500
- }
501
-
502
- fetch("http://restapi.amap.com/v3/geocode/regeo?" + paramStr)
503
- .then(res => res.json())
504
- .then(response => {
505
- if (response.status === "1" && response.regeocode) {
506
- let address = response.regeocode.formatted_address;
507
- this.newVal.name = address;
508
- }
509
- });
510
- }
511
- }
512
- };
513
- </script>
514
-
515
- <style lang="less">
516
- @import url("../control.less");
517
-
518
- .DshCoordinates {
519
- #control-show();
520
-
521
- &-modal {
522
- &-header {
523
- padding: 5px 0px;
524
-
525
- .header {
526
- &-edit {
527
- &-message {
528
- position: absolute;
529
- color: red;
530
- font-size: 12px;
531
- bottom: -16px;
532
- left: 0px;
533
- }
534
-
535
- &-text {
536
- font-size: @textSize;
537
- line-height: 18px;
538
- }
539
-
540
- &-row {
541
- margin-top: 5px;
542
- }
543
- }
544
-
545
- &-show {
546
- &-text {
547
- text-align: right;
548
- .dsh-padding-top10();
549
- }
550
- }
551
- }
552
- }
553
-
554
- &-map {
555
- width: 100%;
556
- height: 100%;
557
- }
558
-
559
- &-lnglat {
560
- padding: 5px 10px;
561
- background:#fff;
562
- display: none;
563
- position:absolute;
564
- }
565
-
566
- .ivu-modal-content {
567
- overflow: hidden;
568
- height: 100%;
569
-
570
- .ivu-modal-body {
571
- padding: 0px;
572
- height: 100%;
573
- }
574
- }
575
- }
576
- }
577
- </style>
1
+ <template>
2
+ <!-- 单选模式 编辑 -->
3
+ <div
4
+ v-if="!multipleMode && canEdit && propsObj._enterType !== 'calculate'"
5
+ class="DshCoordinates"
6
+ >
7
+ <bri-tooltip
8
+ :content="showVal"
9
+ :transfer="true"
10
+ >
11
+ <!-- 编辑 -->
12
+ <dsh-control-input
13
+ :class="commonClass"
14
+ :value="curVal"
15
+ :disabled="disabled"
16
+ :propsObj="selfPropsObj"
17
+ @clear="clickClear"
18
+ @click.native="clickInput"
19
+ ></dsh-control-input>
20
+ </bri-tooltip>
21
+
22
+ <!-- 模态框 -->
23
+ <Modal
24
+ class="DshCoordinates-modal"
25
+ v-model="showModal"
26
+ :styles="modalStyles"
27
+ :footer-hide="true"
28
+ >
29
+ <!-- 顶部 -->
30
+ <div
31
+ slot="header"
32
+ class="DshCoordinates-modal-header"
33
+ >
34
+ <!-- 可编辑 -->
35
+ <Row
36
+ v-if="!disabled"
37
+ class="header-edit"
38
+ type="flex"
39
+ justify="center"
40
+ align="bottom"
41
+ >
42
+ <i-col span="8">
43
+ <radio-group v-model="formData.kind">
44
+ <Radio label="keyword">按关键字搜索</Radio>
45
+ <Radio label="coordinate">按坐标搜索</Radio>
46
+ </radio-group>
47
+
48
+ <Row class="header-edit-row">
49
+ <i-col span="16">
50
+ <Input
51
+ v-model="formData.searchText"
52
+ placeholder="请输入..."
53
+ :clearable="true"
54
+ @on-enter="clickSearch"
55
+ />
56
+ <span class="header-edit-message">{{ searchMessage }}</span>
57
+ </i-col>
58
+
59
+ <i-col span="8">
60
+ <Button
61
+ type="primary"
62
+ @click="clickSearch"
63
+ >搜索</Button>
64
+ </i-col>
65
+ </Row>
66
+ </i-col>
67
+
68
+ <i-col span="8">
69
+ <div class="header-edit-text">坐标获取结果</div>
70
+ <Row class="header-edit-row">
71
+ <i-col span="16">
72
+ <Input
73
+ :value="newVal.name"
74
+ :readonly="true"
75
+ :clearable="true"
76
+ @on-clear="clickModalClear"
77
+ @click.native="clickMapFitView"
78
+ />
79
+ </i-col>
80
+
81
+ <i-col span="8">
82
+ <Button
83
+ type="primary"
84
+ @click="clickConfirm"
85
+ >确认</Button>
86
+ </i-col>
87
+ </Row>
88
+ </i-col>
89
+ </Row>
90
+
91
+ <!-- 不可编辑 -->
92
+ <Row
93
+ v-else
94
+ class="header-show"
95
+ >
96
+ <i-col
97
+ span="6"
98
+ class="header-show-text"
99
+ >
100
+ 当前位置:
101
+ </i-col>
102
+
103
+ <i-col span="12">
104
+ <Input
105
+ :value="newVal.name"
106
+ :readonly="true"
107
+ @click.native="clickMapFitView"
108
+ />
109
+ </i-col>
110
+
111
+ <i-col span="6"></i-col>
112
+ </Row>
113
+ </div>
114
+
115
+ <!-- 地图 -->
116
+ <transition>
117
+ <div
118
+ v-if="showModal"
119
+ id="DshCoordinatesMap"
120
+ class="DshCoordinates-modal-map"
121
+ ></div>
122
+ </transition>
123
+
124
+ <!-- 实时坐标 -->
125
+ <div
126
+ ref="lnglatRef"
127
+ class="DshCoordinates-modal-lnglat"
128
+ ></div>
129
+ </Modal>
130
+ </div>
131
+
132
+ <!-- 单选模式 查看 -->
133
+ <div
134
+ v-else-if="!multipleMode && !canEdit"
135
+ class="DshCoordinates-show"
136
+ >
137
+ <!-- 有值 -->
138
+ <template v-if="!$isEmptyData(curVal)">
139
+ <!-- 高度自由时 -->
140
+ <div
141
+ v-if="isHeightAuto"
142
+ :class="{
143
+ ...commonClass,
144
+ 'DshCoordinates-show-auto': true
145
+ }"
146
+ >
147
+ {{ showVal }}
148
+ </div>
149
+
150
+ <!-- 高度不自由(不换行) -->
151
+ <bri-tooltip
152
+ v-else
153
+ :content="showVal"
154
+ :transfer="true"
155
+ >
156
+ <div :class="{
157
+ ...commonClass,
158
+ 'DshCoordinates-show-ellipsis': true
159
+ }">
160
+ {{ showVal }}
161
+ </div>
162
+ </bri-tooltip>
163
+ </template>
164
+
165
+ <!-- 无值 -->
166
+ <div
167
+ v-else
168
+ :class="commonClass"
169
+ >
170
+ {{ emptyShowVal }}
171
+ </div>
172
+ </div>
173
+ <div v-else-if="propsObj._enterType === 'calculate'"
174
+ class="DshCoordinates-show"
175
+ >
176
+ <span :class="{'nodata': !showVal}">{{ showVal || '暂无内容' }}</span>
177
+ </div>
178
+ </template>
179
+
180
+ <script>
181
+ import controlMixin from "../mixins/controlMixin.js";
182
+
183
+ const plotStrokeColor = "#4575EF";
184
+ const plotFillColor = "#4575EF";
185
+ let polygonOpt = {
186
+ fillColor: plotFillColor,
187
+ fillOpacity: 0.4,
188
+ strokeColor: plotStrokeColor,
189
+ strokeWeight: 5
190
+ };
191
+ let lineOpt = {
192
+ strokeColor: plotStrokeColor,
193
+ strokeWeight: 5
194
+ };
195
+ let markerOpt = {};
196
+
197
+ export default {
198
+ name: "DshCoordinates",
199
+ mixins: [
200
+ controlMixin
201
+ ],
202
+ data () {
203
+ return {
204
+ showModal: false,
205
+ newVal: {
206
+ name: "",
207
+ lnglat: []
208
+ },
209
+ modalStyles: {
210
+ height: document.body.clientHeight * 0.96 + "px",
211
+ width: document.body.clientWidth * 0.96 + "px",
212
+ top: "2%"
213
+ },
214
+ formData: {
215
+ kind: "keyword",
216
+ searchText: ""
217
+ },
218
+
219
+ // 地图相应控件
220
+ map: null,
221
+ placeSearch: null,
222
+ mouseTool: null,
223
+ marker: null, // 标记点
224
+ plot: null, // 标记图形
225
+ searchMessage: "" // 提示信息
226
+ };
227
+ },
228
+ computed: {
229
+ selfPropsObj () {
230
+ return {
231
+ _mapType: "2D", // "2D", "3D"
232
+ _showType: "marker", // "marker", "multipleMarker", "polyline", "polygon", "rectangle"
233
+ _icon: "ios-map-outline",
234
+
235
+ ...this.propsObj,
236
+ ...this.commonDealPropsObj
237
+ };
238
+ },
239
+ subType () {
240
+ return this.selfPropsObj._mapType;
241
+ },
242
+ showMode () {
243
+ return this.selfPropsObj._showType;
244
+ },
245
+
246
+ curVal: {
247
+ get () {
248
+ return this.value[this.controlKey] || {
249
+ name: "",
250
+ lnglat: []
251
+ };
252
+ },
253
+ set (val) {
254
+ this.value[this.controlKey] = val;
255
+ this.change();
256
+ }
257
+ },
258
+ showVal () {
259
+ return this.$isEmptyData(this.curVal)
260
+ ? this.emptyShowVal
261
+ : this.curVal.name;
262
+ }
263
+ },
264
+ created () {},
265
+ methods: {
266
+ // 打开窗体
267
+ clickInput () {
268
+ if (this.canEdit) {
269
+ this.showModal = true;
270
+ this.newVal = this.$deepCopy(this.curVal);
271
+ this.getMap();
272
+ }
273
+ },
274
+ // 点击确认
275
+ clickConfirm () {
276
+ this.showModal = false;
277
+ this.curVal = this.newVal;
278
+ },
279
+ // 清除已选内容
280
+ clickModalClear () {
281
+ this.newVal = {
282
+ name: "",
283
+ lnglat: []
284
+ }; // 清除当前标记
285
+ this.handleRmoveMarker("default"); // 清除地图内标记
286
+ this.handleOpenDraw(); // 打开绘图功能
287
+ },
288
+ // 点击搜索
289
+ clickSearch () {
290
+ if (!this.formData.searchText) {
291
+ this.searchMessage = "请输入搜索内容!";
292
+ return;
293
+ }
294
+ if (this.formData.kind === "coordinate") {
295
+ let lnglat = this.formData.searchText.split(",");
296
+ let lng = Number(lnglat[0]);
297
+ let lat = Number(lnglat[1]);
298
+ if (isNaN(lng) || isNaN(lat) || lng < -180 || lng > 180 || lat < -90 || lat > 90) {
299
+ this.searchMessage = "请输入正确的经纬度坐标!";
300
+ } else {
301
+ lnglat = new AMap.LngLat(lng, lat);
302
+ this.searchMessage = "";
303
+ this.handleAddMarker([lnglat.lng, lnglat.lat], true, "default");
304
+ }
305
+ } else {
306
+ this.placeSearch.search(this.formData.searchText, this.handlePlaceSearchCallback);
307
+ }
308
+ },
309
+ // 地图自适应点
310
+ clickMapFitView (view = this.plot) {
311
+ this.map.setFitView(view);
312
+ },
313
+ getMap () {
314
+ this.$nextTick(() => {
315
+ let lnglatRef = this.$refs.lnglatRef;
316
+ this.map = new AMap.Map("DshCoordinatesMap", {
317
+ rotateEnable: true,
318
+ pitchEnable: true,
319
+ zoom: this.propsObj._zoom || 12,
320
+ pitch: 50,
321
+ viewMode: this.subType,
322
+ center: this.propsObj._center && this.propsObj._center.split(",").map(i => Number(i)) || undefined
323
+ });
324
+
325
+ // 滑动显示坐标点
326
+ this.map.on("mouseover", function (e) {
327
+ lnglatRef.style.display = "block";
328
+ });
329
+ this.map.on("mousemove", function (e) {
330
+ lnglatRef.innerHTML = e.lnglat.toString();
331
+ lnglatRef.style.top = (e.pixel.y + 120) + "px";
332
+ lnglatRef.style.left = (e.pixel.x + 6) + "px";
333
+ });
334
+ this.map.on("mouseout", function (e) {
335
+ lnglatRef.style.display = "none";
336
+ });
337
+
338
+ // 集成插件
339
+ AMap.plugin(["AMap.PlaceSearch", "AMap.Scale", "AMap.ControlBar", "AMap.MouseTool"], this.handlePluginCallback);
340
+
341
+ });
342
+ },
343
+ handlePluginCallback () {
344
+ // 构造地点查询类
345
+ this.placeSearch = new AMap.PlaceSearch();
346
+ this.placeSearch.on("complete", this.handlePlaceSearchCallback);
347
+ this.placeSearch.on("error", this.handlePlaceSearchCallback);
348
+
349
+ // 加载集成工具
350
+ this.map.addControl(new AMap.Scale());
351
+ this.map.addControl(new AMap.ControlBar());
352
+ // this.map.addControl(new AMap.ToolBar());
353
+
354
+ // 监听draw事件可获取画好的覆盖物
355
+ this.mouseTool = new AMap.MouseTool(this.map);
356
+ this.mouseTool.on("draw", this.handleMouseToolCallback);
357
+ // 设置默认坐标
358
+ if (!this.$isEmptyData(this.newVal)) {
359
+ this.handleAddMarker(this.newVal.lnglat, true);
360
+
361
+ if (this.showMode === "multipleMarker") { // 多选打开绘图功能
362
+ !this.disabled && this.handleOpenDraw();
363
+ }
364
+ } else {
365
+ !this.disabled && this.handleOpenDraw();
366
+ }
367
+ },
368
+ handleMouseToolCallback (e) {
369
+ if (e.obj.CLASS_NAME === "AMap.Marker") {
370
+ if (this.showMode === "marker") {
371
+ this.plot = e.obj;
372
+ this.handleCloseDraw();
373
+ } else if (this.showMode === "multipleMarker") {
374
+ if (this.plot) {
375
+ this.plot.push(e.obj);
376
+ } else {
377
+ this.plot = [e.obj];
378
+ }
379
+ }
380
+ // 设置坐标
381
+ let lnglat = e.obj.getPosition();
382
+ this.newVal.lnglat.push([lnglat.lng, lnglat.lat]);
383
+ this.getRegeoCode();
384
+
385
+ } else {
386
+ this.plot = e.obj;
387
+ // 设置坐标
388
+ this.newVal.lnglat.push(...e.obj.getPath().map(lnglat => [lnglat.lng, lnglat.lat]));
389
+ this.getRegeoCode();
390
+ this.handleCloseDraw();
391
+ }
392
+ },
393
+ handlePlaceSearchCallback (result) {
394
+ if (result == "complete") {
395
+ return;
396
+ }
397
+ if (result.poiList && result.poiList.pois && result.poiList.pois.length) {
398
+ this.searchMessage = "";
399
+ let poi = result.poiList.pois[0];
400
+ this.handleAddMarker([poi.location.lng, poi.location.lat], true, "default");
401
+ this.marker.setTitle([poi.name, poi.address].join(poi.name && poi.address ? "\n" : ""));
402
+ } else {
403
+ this.searchMessage = "没有搜索到结果!";
404
+ }
405
+ },
406
+ // 打开绘图
407
+ handleOpenDraw (type = this.showMode) {
408
+ switch (type) {
409
+ case "marker": {
410
+ this.mouseTool.marker(markerOpt);
411
+ break;
412
+ }
413
+ case "multipleMarker": {
414
+ this.mouseTool.marker(markerOpt);
415
+ break;
416
+ }
417
+ case "polyline": {
418
+ this.mouseTool.polyline(lineOpt);
419
+ break;
420
+ }
421
+ case "polygon": {
422
+ this.mouseTool.polygon(polygonOpt);
423
+ break;
424
+ }
425
+ case "rectangle": {
426
+ this.mouseTool.rectangle(polygonOpt);
427
+ break;
428
+ }
429
+ case "circle": {
430
+ this.mouseTool.circle(polygonOpt);
431
+ break;
432
+ }
433
+ }
434
+ },
435
+ // 关闭绘图
436
+ handleCloseDraw () {
437
+ this.mouseTool.close();
438
+ },
439
+ // 添加图形
440
+ handleAddMarker (location, centerView = true, type = this.showMode) {
441
+ location = JSON.parse(JSON.stringify(location));
442
+ // 分类型添加
443
+ if (["polygon", "rectangle", "circle"].includes(type)) {
444
+ // 图形类
445
+ this.plot = new AMap.Polygon({
446
+ ...polygonOpt,
447
+ path: location
448
+ });
449
+ this.map.add(this.plot);
450
+ centerView && this.map.setFitView(this.plot);// 视口自适应
451
+ } else if (["default"].includes(type)) {
452
+ !this.marker && (this.marker = new AMap.Marker());
453
+ this.marker.setPosition(location);
454
+ this.marker.setMap(this.map);
455
+ if (this.showMode === "marker") {
456
+ this.handleRmoveMarker();
457
+ this.handleCloseDraw();
458
+ this.newVal.lnglat = [location];
459
+ this.getRegeoCode();
460
+ } else if (this.showMode === "multipleMarker") {
461
+ this.newVal.lnglat.push(location);
462
+ this.getRegeoCode();
463
+ }
464
+ centerView && this.map.setFitView(this.marker);
465
+ } else if (["polyline"].includes(type)) {
466
+ this.plot = new AMap.Polyline({
467
+ ...polygonOpt,
468
+ path: location
469
+ });
470
+ this.map.add(this.plot);
471
+ centerView && this.map.setFitView(this.plot);// 视口自适应
472
+ } else if (["multipleMarker", "marker"].includes(type)) {
473
+ this.plot = location.map(position => {
474
+ return new AMap.Marker({
475
+ map: this.map,
476
+ position: position
477
+ });
478
+ });
479
+ centerView && this.map.setFitView(this.plot);
480
+ }
481
+ },
482
+ // 移除图形
483
+ handleRmoveMarker (type = this.showMode) {
484
+ if (["default"].includes(type)) {
485
+ this.marker && this.map.remove(this.marker);
486
+ this.plot && this.map.remove(this.plot);
487
+ } else {
488
+ this.plot && this.map.remove(this.plot);
489
+ }
490
+ },
491
+ // 获取逆地理编码
492
+ getRegeoCode (value, scuessFun) {
493
+ let params = {
494
+ key: window.config.amapKey,
495
+ location: this.newVal.lnglat[0],
496
+ radius: 1000,
497
+ extensions: "base",
498
+ batch: false,
499
+ roadlevel: 1
500
+ };
501
+
502
+ let paramStr = "";
503
+ for (let attr in params) {
504
+ paramStr += attr + "=" + params[attr] + "&";
505
+ }
506
+
507
+ fetch("http://restapi.amap.com/v3/geocode/regeo?" + paramStr)
508
+ .then(res => res.json())
509
+ .then(response => {
510
+ if (response.status === "1" && response.regeocode) {
511
+ let address = response.regeocode.formatted_address;
512
+ this.newVal.name = address;
513
+ }
514
+ });
515
+ }
516
+ }
517
+ };
518
+ </script>
519
+
520
+ <style lang="less">
521
+ @import url("../control.less");
522
+
523
+ .DshCoordinates {
524
+ #control-show();
525
+
526
+ &-modal {
527
+ &-header {
528
+ padding: 5px 0px;
529
+
530
+ .header {
531
+ &-edit {
532
+ &-message {
533
+ position: absolute;
534
+ color: red;
535
+ font-size: 12px;
536
+ bottom: -16px;
537
+ left: 0px;
538
+ }
539
+
540
+ &-text {
541
+ font-size: @textSize;
542
+ line-height: 18px;
543
+ }
544
+
545
+ &-row {
546
+ margin-top: 5px;
547
+ }
548
+ }
549
+
550
+ &-show {
551
+ &-text {
552
+ text-align: right;
553
+ .dsh-padding-top10();
554
+ }
555
+ }
556
+ }
557
+ }
558
+
559
+ &-map {
560
+ width: 100%;
561
+ height: 100%;
562
+ }
563
+
564
+ &-lnglat {
565
+ padding: 5px 10px;
566
+ background:#fff;
567
+ display: none;
568
+ position:absolute;
569
+ }
570
+
571
+ .ivu-modal-content {
572
+ overflow: hidden;
573
+ height: 100%;
574
+
575
+ .ivu-modal-body {
576
+ padding: 0px;
577
+ height: 100%;
578
+ }
579
+ }
580
+ }
581
+ }
582
+ .nodata{
583
+ color: #999;
584
+ }
585
+ </style>