bri-components 1.5.13 → 1.5.15

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 (151) hide show
  1. package/README.md +83 -83
  2. package/lib/0.bri-components.min.js +1 -1
  3. package/lib/1.bri-components.min.js +1 -1
  4. package/lib/10.bri-components.min.js +1 -1
  5. package/lib/2.bri-components.min.js +1 -1
  6. package/lib/3.bri-components.min.js +1 -1
  7. package/lib/4.bri-components.min.js +1 -1
  8. package/lib/5.bri-components.min.js +1 -1
  9. package/lib/6.bri-components.min.js +1 -1
  10. package/lib/7.bri-components.min.js +1 -1
  11. package/lib/8.bri-components.min.js +1 -1
  12. package/lib/9.bri-components.min.js +1 -1
  13. package/lib/bri-components.min.js +4 -4
  14. package/lib/styles/bundle.css +12 -12
  15. package/lib/styles/font/fontello.svg +31 -31
  16. package/package.json +125 -125
  17. package/src/components/Error/Error403.vue +42 -42
  18. package/src/components/Error/Error404.vue +40 -40
  19. package/src/components/Error/Error500.vue +51 -51
  20. package/src/components/Error/error.less +162 -162
  21. package/src/components/Error/errorBack.vue +40 -40
  22. package/src/components/controls/DshControlInput.vue +195 -195
  23. package/src/components/controls/base/BriUpload/BriUpload.vue +434 -434
  24. package/src/components/controls/base/BriUpload/BriUploadImage.vue +377 -377
  25. package/src/components/controls/base/BriUpload/uploadList.vue +727 -731
  26. package/src/components/controls/base/BriUpload/uploadMixin.js +446 -446
  27. package/src/components/controls/base/DshCascader/DshCascader.vue +215 -215
  28. package/src/components/controls/base/DshCascader/components/cascaderModal.vue +366 -366
  29. package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +416 -416
  30. package/src/components/controls/base/DshCascader/components/cascaderSimple.vue +141 -141
  31. package/src/components/controls/base/DshCascader/components/cascaderTree.vue +151 -151
  32. package/src/components/controls/base/DshCoordinates.vue +577 -577
  33. package/src/components/controls/base/DshDate/DshDate.vue +191 -191
  34. package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
  35. package/src/components/controls/base/DshDivider.vue +201 -201
  36. package/src/components/controls/base/DshEditor.vue +274 -274
  37. package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
  38. package/src/components/controls/base/DshInput/DshInput.vue +260 -260
  39. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
  40. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
  41. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
  42. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
  43. package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
  44. package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
  45. package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
  46. package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
  47. package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
  48. package/src/components/controls/control.less +324 -324
  49. package/src/components/controls/controlMap.js +114 -114
  50. package/src/components/controls/extra/DshColor.vue +81 -81
  51. package/src/components/controls/extra/DshThemeColor.vue +100 -100
  52. package/src/components/controls/extra/DshThemeIcon.vue +122 -122
  53. package/src/components/controls/mixins/cascaderMixin.js +325 -327
  54. package/src/components/controls/mixins/cascaderPickerMixin.js +227 -227
  55. package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
  56. package/src/components/controls/mixins/controlMixin.js +393 -393
  57. package/src/components/controls/mixins/dateMixin.js +149 -149
  58. package/src/components/controls/mixins/flatTableMixin.js +111 -111
  59. package/src/components/controls/mixins/numberMixin.js +112 -112
  60. package/src/components/controls/mixins/selectMixin.js +233 -233
  61. package/src/components/controls/mixins/switchMixin.js +87 -87
  62. package/src/components/controls/mixins/userAndDepartMixin.js +260 -260
  63. package/src/components/controls/senior/DshLabels.vue +333 -333
  64. package/src/components/controls/senior/DshPackage.vue +57 -57
  65. package/src/components/controls/senior/cascaderTable.vue +213 -213
  66. package/src/components/controls/senior/flatTable.vue +138 -138
  67. package/src/components/controls/senior/selectDepartments.vue +399 -399
  68. package/src/components/controls/senior/selectUsers/departMenu.vue +293 -293
  69. package/src/components/controls/senior/selectUsers/selectUsers.vue +712 -712
  70. package/src/components/controls/special/DshBack.vue +42 -42
  71. package/src/components/controls/special/DshUndeveloped.vue +41 -41
  72. package/src/components/form/DshAdvSearch.vue +510 -510
  73. package/src/components/form/DshDefaultSearch.vue +260 -260
  74. package/src/components/form/DshForm.vue +494 -494
  75. package/src/components/form/searchMixin.js +376 -376
  76. package/src/components/list/BriCard.vue +95 -95
  77. package/src/components/list/BriTable.vue +205 -205
  78. package/src/components/list/BriTree.vue +529 -529
  79. package/src/components/list/BriTreeItem.vue +163 -163
  80. package/src/components/list/DshBox/DshBox.vue +219 -219
  81. package/src/components/list/DshBox/DshCard.vue +446 -446
  82. package/src/components/list/DshBox/DshCrossTable.vue +827 -827
  83. package/src/components/list/DshBox/DshList.vue +404 -404
  84. package/src/components/list/DshBox/DshPanel.vue +669 -669
  85. package/src/components/list/DshBox/DshSingleData.vue +119 -119
  86. package/src/components/list/DshBox/DshTable.vue +239 -239
  87. package/src/components/list/DshCascaderTable.vue +115 -115
  88. package/src/components/list/DshFlatTable.vue +337 -337
  89. package/src/components/list/DshPage.vue +194 -194
  90. package/src/components/list/DshTreeTable.vue +113 -113
  91. package/src/components/list/common/importModal.vue +243 -243
  92. package/src/components/list/common/quoteListModal.vue +206 -206
  93. package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
  94. package/src/components/list/mixins/DshFlatTableMixin.js +509 -509
  95. package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
  96. package/src/components/list/mixins/tableBaseMixin.js +1653 -1653
  97. package/src/components/list/mixins/treeTableBaseMixin.js +145 -145
  98. package/src/components/other/BriAvatar.vue +166 -166
  99. package/src/components/other/BriCode.vue +125 -125
  100. package/src/components/other/BriCollapseTree.vue +207 -207
  101. package/src/components/other/BriGantt.vue +1087 -1087
  102. package/src/components/other/BriIframe.vue +116 -116
  103. package/src/components/other/BriLoading.vue +171 -171
  104. package/src/components/other/BriSvg.vue +27 -27
  105. package/src/components/other/DshColorPanel.vue +128 -128
  106. package/src/components/other/DshMenuNav.vue +188 -188
  107. package/src/components/small/BriButton.vue +71 -71
  108. package/src/components/small/BriDrawer.vue +169 -169
  109. package/src/components/small/BriTooltip.vue +87 -87
  110. package/src/components/small/DshBtnModal.vue +68 -68
  111. package/src/components/small/DshButtons.vue +324 -324
  112. package/src/components/small/DshDropdown.vue +225 -225
  113. package/src/components/small/DshIcons.vue +59 -59
  114. package/src/components/small/DshListRender.js +21 -21
  115. package/src/components/small/DshModal.vue +160 -160
  116. package/src/components/small/DshSteps.vue +141 -141
  117. package/src/components/small/DshTabs.vue +598 -598
  118. package/src/components/small/DshTabsSet.vue +309 -309
  119. package/src/components/small/DshTags.vue +251 -251
  120. package/src/components/small/DshTitle.vue +50 -50
  121. package/src/components/small/render.js +20 -20
  122. package/src/components/unit/DshFormUnit.vue +398 -398
  123. package/src/components/unit/DshListUnit.vue +115 -115
  124. package/src/components/unit/unitMixin.js +86 -86
  125. package/src/data/index.js +4 -9
  126. package/src/index.js +282 -282
  127. package/src/styles/bundle.css +12 -12
  128. package/src/styles/components/BriButton.less +307 -307
  129. package/src/styles/components/BriTable.less +344 -344
  130. package/src/styles/components/DshModal.less +257 -257
  131. package/src/styles/components/index.less +3 -3
  132. package/src/styles/global/animate.less +11 -11
  133. package/src/styles/global/base.less +45 -45
  134. package/src/styles/global/box.less +186 -186
  135. package/src/styles/global/control.less +122 -122
  136. package/src/styles/global/flex.less +282 -282
  137. package/src/styles/global/global.less +8 -8
  138. package/src/styles/global/text.less +59 -59
  139. package/src/styles/global/variables.less +85 -85
  140. package/src/styles/iconfont/iconfont.css +254 -254
  141. package/src/styles/iconfont/iconfont.json +422 -422
  142. package/src/styles/iconfont/iconfont.svg +137 -137
  143. package/src/styles/index.less +26 -26
  144. package/src/styles/reset-easytable.less +21 -21
  145. package/src/styles/reset-iview-controls.less +145 -145
  146. package/src/styles/reset-iview-other.less +49 -49
  147. package/src/styles/reset-iview-variables.less +43 -43
  148. package/src/styles/reset.less +45 -45
  149. package/src/utils/index.js +5 -5
  150. package/src/utils/table.js +175 -175
  151. package/lib/11.bri-components.min.js +0 -1
@@ -1,577 +1,577 @@
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"
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>