bri-components 1.5.22 → 1.6.1

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 (154) 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 +127 -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 +435 -434
  12. package/src/components/controls/base/BriUpload/BriUploadImage.vue +430 -377
  13. package/src/components/controls/base/BriUpload/uploadList.vue +738 -727
  14. package/src/components/controls/base/BriUpload/uploadMixin.js +453 -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 +587 -585
  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 +397 -399
  58. package/src/components/controls/senior/selectUsers/departMenu.vue +296 -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 +334 -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/other/DshVideoPlayer.vue +184 -0
  98. package/src/components/small/BriButton.vue +71 -71
  99. package/src/components/small/BriDrawer.vue +169 -169
  100. package/src/components/small/BriTooltip.vue +87 -87
  101. package/src/components/small/DshBtnModal.vue +68 -68
  102. package/src/components/small/DshButtons.vue +324 -324
  103. package/src/components/small/DshDropdown.vue +225 -225
  104. package/src/components/small/DshIcons.vue +59 -59
  105. package/src/components/small/DshListRender.js +21 -21
  106. package/src/components/small/DshModal.vue +160 -160
  107. package/src/components/small/DshSteps.vue +141 -141
  108. package/src/components/small/DshTabs.vue +598 -598
  109. package/src/components/small/DshTabsSet.vue +309 -309
  110. package/src/components/small/DshTags.vue +251 -251
  111. package/src/components/small/DshTitle.vue +50 -50
  112. package/src/components/small/render.js +20 -20
  113. package/src/components/unit/DshFormUnit.vue +398 -398
  114. package/src/components/unit/DshListUnit.vue +115 -115
  115. package/src/components/unit/unitMixin.js +86 -86
  116. package/src/data/index.js +4 -4
  117. package/src/index.js +287 -285
  118. package/src/styles/bundle.css +12 -12
  119. package/src/styles/components/BriButton.less +307 -307
  120. package/src/styles/components/BriTable.less +344 -344
  121. package/src/styles/components/DshModal.less +257 -257
  122. package/src/styles/components/index.less +3 -3
  123. package/src/styles/global/animate.less +11 -11
  124. package/src/styles/global/base.less +45 -45
  125. package/src/styles/global/box.less +186 -186
  126. package/src/styles/global/control.less +122 -122
  127. package/src/styles/global/flex.less +282 -282
  128. package/src/styles/global/global.less +8 -8
  129. package/src/styles/global/text.less +59 -59
  130. package/src/styles/global/variables.less +85 -85
  131. package/src/styles/iconfont/iconfont.css +254 -254
  132. package/src/styles/iconfont/iconfont.json +422 -422
  133. package/src/styles/iconfont/iconfont.svg +137 -137
  134. package/src/styles/index.less +26 -26
  135. package/src/styles/reset-easytable.less +21 -21
  136. package/src/styles/reset-iview-controls.less +145 -145
  137. package/src/styles/reset-iview-other.less +49 -49
  138. package/src/styles/reset-iview-variables.less +43 -43
  139. package/src/styles/reset.less +45 -45
  140. package/src/utils/index.js +3 -5
  141. package/lib/0.bri-components.min.js +0 -1
  142. package/lib/1.bri-components.min.js +0 -1
  143. package/lib/10.bri-components.min.js +0 -1
  144. package/lib/11.bri-components.min.js +0 -1
  145. package/lib/2.bri-components.min.js +0 -1
  146. package/lib/3.bri-components.min.js +0 -1
  147. package/lib/4.bri-components.min.js +0 -1
  148. package/lib/5.bri-components.min.js +0 -1
  149. package/lib/6.bri-components.min.js +0 -1
  150. package/lib/7.bri-components.min.js +0 -1
  151. package/lib/8.bri-components.min.js +0 -1
  152. package/lib/9.bri-components.min.js +0 -1
  153. package/lib/bri-components.min.js +0 -18
  154. package/src/utils/table.js +0 -175
@@ -1,585 +1,587 @@
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>
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
+
174
+ <div
175
+ v-else-if="propsObj._enterType === 'calculate'"
176
+ class="DshCoordinates-show"
177
+ >
178
+ <span :class="{'nodata': !showVal}">{{ showVal || '暂无内容' }}</span>
179
+ </div>
180
+ </template>
181
+
182
+ <script>
183
+ import controlMixin from "../mixins/controlMixin.js";
184
+
185
+ const plotStrokeColor = "#4575EF";
186
+ const plotFillColor = "#4575EF";
187
+ let polygonOpt = {
188
+ fillColor: plotFillColor,
189
+ fillOpacity: 0.4,
190
+ strokeColor: plotStrokeColor,
191
+ strokeWeight: 5
192
+ };
193
+ let lineOpt = {
194
+ strokeColor: plotStrokeColor,
195
+ strokeWeight: 5
196
+ };
197
+ let markerOpt = {};
198
+
199
+ export default {
200
+ name: "DshCoordinates",
201
+ mixins: [
202
+ controlMixin
203
+ ],
204
+ data () {
205
+ return {
206
+ showModal: false,
207
+ newVal: {
208
+ name: "",
209
+ lnglat: []
210
+ },
211
+ modalStyles: {
212
+ height: document.body.clientHeight * 0.96 + "px",
213
+ width: document.body.clientWidth * 0.96 + "px",
214
+ top: "2%"
215
+ },
216
+ formData: {
217
+ kind: "keyword",
218
+ searchText: ""
219
+ },
220
+
221
+ // 地图相应控件
222
+ map: null,
223
+ placeSearch: null,
224
+ mouseTool: null,
225
+ marker: null, // 标记点
226
+ plot: null, // 标记图形
227
+ searchMessage: "" // 提示信息
228
+ };
229
+ },
230
+ computed: {
231
+ selfPropsObj () {
232
+ return {
233
+ _mapType: "2D", // "2D", "3D"
234
+ _showType: "marker", // "marker", "multipleMarker", "polyline", "polygon", "rectangle"
235
+ _icon: "ios-map-outline",
236
+
237
+ ...this.propsObj,
238
+ ...this.commonDealPropsObj
239
+ };
240
+ },
241
+ subType () {
242
+ return this.selfPropsObj._mapType;
243
+ },
244
+ showMode () {
245
+ return this.selfPropsObj._showType;
246
+ },
247
+
248
+ curVal: {
249
+ get () {
250
+ return this.value[this.controlKey] || {
251
+ name: "",
252
+ lnglat: []
253
+ };
254
+ },
255
+ set (val) {
256
+ this.value[this.controlKey] = val;
257
+ this.change();
258
+ }
259
+ },
260
+ showVal () {
261
+ return this.$isEmptyData(this.curVal)
262
+ ? this.emptyShowVal
263
+ : this.curVal.name;
264
+ }
265
+ },
266
+ created () {},
267
+ methods: {
268
+ // 打开窗体
269
+ clickInput () {
270
+ if (this.canEdit) {
271
+ this.showModal = true;
272
+ this.newVal = this.$deepCopy(this.curVal);
273
+ this.getMap();
274
+ }
275
+ },
276
+ // 点击确认
277
+ clickConfirm () {
278
+ this.showModal = false;
279
+ this.curVal = this.newVal;
280
+ },
281
+ // 清除已选内容
282
+ clickModalClear () {
283
+ this.newVal = {
284
+ name: "",
285
+ lnglat: []
286
+ }; // 清除当前标记
287
+ this.handleRmoveMarker("default"); // 清除地图内标记
288
+ this.handleOpenDraw(); // 打开绘图功能
289
+ },
290
+ // 点击搜索
291
+ clickSearch () {
292
+ if (!this.formData.searchText) {
293
+ this.searchMessage = "请输入搜索内容!";
294
+ return;
295
+ }
296
+ if (this.formData.kind === "coordinate") {
297
+ let lnglat = this.formData.searchText.split(",");
298
+ let lng = Number(lnglat[0]);
299
+ let lat = Number(lnglat[1]);
300
+ if (isNaN(lng) || isNaN(lat) || lng < -180 || lng > 180 || lat < -90 || lat > 90) {
301
+ this.searchMessage = "请输入正确的经纬度坐标!";
302
+ } else {
303
+ lnglat = new AMap.LngLat(lng, lat);
304
+ this.searchMessage = "";
305
+ this.handleAddMarker([lnglat.lng, lnglat.lat], true, "default");
306
+ }
307
+ } else {
308
+ this.placeSearch.search(this.formData.searchText, this.handlePlaceSearchCallback);
309
+ }
310
+ },
311
+ // 地图自适应点
312
+ clickMapFitView (view = this.plot) {
313
+ this.map.setFitView(view);
314
+ },
315
+ getMap () {
316
+ this.$nextTick(() => {
317
+ let lnglatRef = this.$refs.lnglatRef;
318
+ this.map = new AMap.Map("DshCoordinatesMap", {
319
+ rotateEnable: true,
320
+ pitchEnable: true,
321
+ zoom: this.propsObj._zoom || 12,
322
+ pitch: 50,
323
+ viewMode: this.subType,
324
+ center: this.propsObj._center && this.propsObj._center.split(",").map(i => Number(i)) || undefined
325
+ });
326
+
327
+ // 滑动显示坐标点
328
+ this.map.on("mouseover", function (e) {
329
+ lnglatRef.style.display = "block";
330
+ });
331
+ this.map.on("mousemove", function (e) {
332
+ lnglatRef.innerHTML = e.lnglat.toString();
333
+ lnglatRef.style.top = (e.pixel.y + 120) + "px";
334
+ lnglatRef.style.left = (e.pixel.x + 6) + "px";
335
+ });
336
+ this.map.on("mouseout", function (e) {
337
+ lnglatRef.style.display = "none";
338
+ });
339
+
340
+ // 集成插件
341
+ AMap.plugin(["AMap.PlaceSearch", "AMap.Scale", "AMap.ControlBar", "AMap.MouseTool"], this.handlePluginCallback);
342
+
343
+ });
344
+ },
345
+ handlePluginCallback () {
346
+ // 构造地点查询类
347
+ this.placeSearch = new AMap.PlaceSearch();
348
+ this.placeSearch.on("complete", this.handlePlaceSearchCallback);
349
+ this.placeSearch.on("error", this.handlePlaceSearchCallback);
350
+
351
+ // 加载集成工具
352
+ this.map.addControl(new AMap.Scale());
353
+ this.map.addControl(new AMap.ControlBar());
354
+ // this.map.addControl(new AMap.ToolBar());
355
+
356
+ // 监听draw事件可获取画好的覆盖物
357
+ this.mouseTool = new AMap.MouseTool(this.map);
358
+ this.mouseTool.on("draw", this.handleMouseToolCallback);
359
+ // 设置默认坐标
360
+ if (!this.$isEmptyData(this.newVal)) {
361
+ this.handleAddMarker(this.newVal.lnglat, true);
362
+
363
+ if (this.showMode === "multipleMarker") { // 多选打开绘图功能
364
+ !this.disabled && this.handleOpenDraw();
365
+ }
366
+ } else {
367
+ !this.disabled && this.handleOpenDraw();
368
+ }
369
+ },
370
+ handleMouseToolCallback (e) {
371
+ if (e.obj.CLASS_NAME === "AMap.Marker") {
372
+ if (this.showMode === "marker") {
373
+ this.plot = e.obj;
374
+ this.handleCloseDraw();
375
+ } else if (this.showMode === "multipleMarker") {
376
+ if (this.plot) {
377
+ this.plot.push(e.obj);
378
+ } else {
379
+ this.plot = [e.obj];
380
+ }
381
+ }
382
+ // 设置坐标
383
+ let lnglat = e.obj.getPosition();
384
+ this.newVal.lnglat.push([lnglat.lng, lnglat.lat]);
385
+ this.getRegeoCode();
386
+
387
+ } else {
388
+ this.plot = e.obj;
389
+ // 设置坐标
390
+ this.newVal.lnglat.push(...e.obj.getPath().map(lnglat => [lnglat.lng, lnglat.lat]));
391
+ this.getRegeoCode();
392
+ this.handleCloseDraw();
393
+ }
394
+ },
395
+ handlePlaceSearchCallback (result) {
396
+ if (result == "complete") {
397
+ return;
398
+ }
399
+ if (result.poiList && result.poiList.pois && result.poiList.pois.length) {
400
+ this.searchMessage = "";
401
+ let poi = result.poiList.pois[0];
402
+ this.handleAddMarker([poi.location.lng, poi.location.lat], true, "default");
403
+ this.marker.setTitle([poi.name, poi.address].join(poi.name && poi.address ? "\n" : ""));
404
+ } else {
405
+ this.searchMessage = "没有搜索到结果!";
406
+ }
407
+ },
408
+ // 打开绘图
409
+ handleOpenDraw (type = this.showMode) {
410
+ switch (type) {
411
+ case "marker": {
412
+ this.mouseTool.marker(markerOpt);
413
+ break;
414
+ }
415
+ case "multipleMarker": {
416
+ this.mouseTool.marker(markerOpt);
417
+ break;
418
+ }
419
+ case "polyline": {
420
+ this.mouseTool.polyline(lineOpt);
421
+ break;
422
+ }
423
+ case "polygon": {
424
+ this.mouseTool.polygon(polygonOpt);
425
+ break;
426
+ }
427
+ case "rectangle": {
428
+ this.mouseTool.rectangle(polygonOpt);
429
+ break;
430
+ }
431
+ case "circle": {
432
+ this.mouseTool.circle(polygonOpt);
433
+ break;
434
+ }
435
+ }
436
+ },
437
+ // 关闭绘图
438
+ handleCloseDraw () {
439
+ this.mouseTool.close();
440
+ },
441
+ // 添加图形
442
+ handleAddMarker (location, centerView = true, type = this.showMode) {
443
+ location = JSON.parse(JSON.stringify(location));
444
+ // 分类型添加
445
+ if (["polygon", "rectangle", "circle"].includes(type)) {
446
+ // 图形类
447
+ this.plot = new AMap.Polygon({
448
+ ...polygonOpt,
449
+ path: location
450
+ });
451
+ this.map.add(this.plot);
452
+ centerView && this.map.setFitView(this.plot);// 视口自适应
453
+ } else if (["default"].includes(type)) {
454
+ !this.marker && (this.marker = new AMap.Marker());
455
+ this.marker.setPosition(location);
456
+ this.marker.setMap(this.map);
457
+ if (this.showMode === "marker") {
458
+ this.handleRmoveMarker();
459
+ this.handleCloseDraw();
460
+ this.newVal.lnglat = [location];
461
+ this.getRegeoCode();
462
+ } else if (this.showMode === "multipleMarker") {
463
+ this.newVal.lnglat.push(location);
464
+ this.getRegeoCode();
465
+ }
466
+ centerView && this.map.setFitView(this.marker);
467
+ } else if (["polyline"].includes(type)) {
468
+ this.plot = new AMap.Polyline({
469
+ ...polygonOpt,
470
+ path: location
471
+ });
472
+ this.map.add(this.plot);
473
+ centerView && this.map.setFitView(this.plot);// 视口自适应
474
+ } else if (["multipleMarker", "marker"].includes(type)) {
475
+ this.plot = location.map(position => {
476
+ return new AMap.Marker({
477
+ map: this.map,
478
+ position: position
479
+ });
480
+ });
481
+ centerView && this.map.setFitView(this.plot);
482
+ }
483
+ },
484
+ // 移除图形
485
+ handleRmoveMarker (type = this.showMode) {
486
+ if (["default"].includes(type)) {
487
+ this.marker && this.map.remove(this.marker);
488
+ this.plot && this.map.remove(this.plot);
489
+ } else {
490
+ this.plot && this.map.remove(this.plot);
491
+ }
492
+ },
493
+ // 获取逆地理编码
494
+ getRegeoCode (value, scuessFun) {
495
+ let params = {
496
+ key: window.config.amapKey,
497
+ location: this.newVal.lnglat[0],
498
+ radius: 1000,
499
+ extensions: "base",
500
+ batch: false,
501
+ roadlevel: 1
502
+ };
503
+
504
+ let paramStr = "";
505
+ for (let attr in params) {
506
+ paramStr += attr + "=" + params[attr] + "&";
507
+ }
508
+
509
+ fetch("http://restapi.amap.com/v3/geocode/regeo?" + paramStr)
510
+ .then(res => res.json())
511
+ .then(response => {
512
+ if (response.status === "1" && response.regeocode) {
513
+ let address = response.regeocode.formatted_address;
514
+ this.newVal.name = address;
515
+ }
516
+ });
517
+ }
518
+ }
519
+ };
520
+ </script>
521
+
522
+ <style lang="less">
523
+ @import url("../control.less");
524
+
525
+ .DshCoordinates {
526
+ #control-show();
527
+
528
+ &-modal {
529
+ &-header {
530
+ padding: 5px 0px;
531
+
532
+ .header {
533
+ &-edit {
534
+ &-message {
535
+ position: absolute;
536
+ color: red;
537
+ font-size: 12px;
538
+ bottom: -16px;
539
+ left: 0px;
540
+ }
541
+
542
+ &-text {
543
+ font-size: @textSize;
544
+ line-height: 18px;
545
+ }
546
+
547
+ &-row {
548
+ margin-top: 5px;
549
+ }
550
+ }
551
+
552
+ &-show {
553
+ &-text {
554
+ text-align: right;
555
+ .dsh-padding-top10();
556
+ }
557
+ }
558
+ }
559
+ }
560
+
561
+ &-map {
562
+ width: 100%;
563
+ height: 100%;
564
+ }
565
+
566
+ &-lnglat {
567
+ padding: 5px 10px;
568
+ background:#fff;
569
+ display: none;
570
+ position:absolute;
571
+ }
572
+
573
+ .ivu-modal-content {
574
+ overflow: hidden;
575
+ height: 100%;
576
+
577
+ .ivu-modal-body {
578
+ padding: 0px;
579
+ height: 100%;
580
+ }
581
+ }
582
+ }
583
+ }
584
+ .nodata{
585
+ color: #999;
586
+ }
587
+ </style>