dropPointinfo.vue
18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
<template>
<div class="app-container">
<!-- 添加或修改处理场所管理对话框 -->
<h3>
基础信息
</h3>
<!-- 添加或修改投放点信息管理对话框 -->
<el-form ref="form" :model="form" :rules="rules" label-width="128px">
<el-form-item label="投放点编号" prop="dropPointNo">
<el-input v-model="form.dropPointNo" placeholder="请输入投放点编号" :disabled="true"/>
</el-form-item>
<el-form-item label="投放点名称" prop="dropPointName">
<el-input v-model="form.dropPointName" placeholder="请输入投放点名称"/>
</el-form-item>
<el-form-item label="所属区域" prop="street">
<el-select v-model="form.district" placeholder="请输入所属区域" style="width: 100%" clearable @change="getStreets">
<el-option v-for="(area,index) in areas" :label="area.name" :value="area.code" :key="index"/>
</el-select>
</el-form-item>
<el-form-item label="所属街道" prop="street">
<el-select v-model="form.street" placeholder="请输入所属街道" style="width: 100%" clearable>
<el-option v-for="(area,index) in streets" :label="area.name" :value="area.code" :key="area.code" @click.native="createDropPointNo(area)"/>
</el-select>
</el-form-item>
<el-form-item label="社区" prop="community">
<el-input v-model="form.community" placeholder="请输入社区"/>
</el-form-item>
<el-form-item label="详细地址" prop="address">
<el-input v-model="form.address" placeholder="请输入详细地址"/>
</el-form-item>
<el-form-item label="投放点形式" prop="type">
<el-select v-model="form.type" placeholder="请选择投放点形式" style="width: 100%">
<el-option label="固定" value="固定"/>
<el-option label="临时" value="临时"/>
</el-select>
</el-form-item>
<el-form-item label="投放点面积(m²)" prop="area">
<el-input v-model="form.area" placeholder="请输入投放点面积"/>
</el-form-item>
<el-form-item label="投放点容量(m³)" prop="capacity">
<el-input v-model="form.capacity" placeholder="请输入投放点容量"/>
</el-form-item>
<el-form-item label="管理单位" prop="managementUnit">
<el-input v-model="form.managementUnit" placeholder="请输入管理单位"/>
</el-form-item>
<el-form-item label="管理人" prop="custodian">
<el-input v-model="form.custodian" placeholder="请输入管理人"/>
</el-form-item>
<el-form-item label="管理员电话" prop="custodianPhone">
<el-input v-model="form.custodianPhone" placeholder="请输入管理员联系电话" :maxlength="11" show-word-limit/>
</el-form-item>
<el-form-item label="投放时间" prop="dropTime">
<el-time-select
v-model="form.dropTime"
style="width: 100%"
:picker-options="{
start: '00:00',
step: '00:30',
end: '23:30'
}"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="运营单位" prop="operatingUnit">
<el-input v-model="form.operatingUnit" placeholder="请输入运营单位"/>
</el-form-item>
<el-form-item label="运输单位" prop="transportUnit">
<el-input v-model="form.transportUnit" placeholder="请输入运输单位"/>
</el-form-item>
<el-form-item label="坐标点" prop="coordinatePoint">
<el-input v-model="form.coordinatePoint" placeholder="请输入坐标点经纬度" readonly @click.native="handleOpenMap"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
<el-dialog title="高德地图" :visible.sync="openMap" width="1600px" height="750px" append-to-body>
<div class="serach_map">
搜索:
<el-select
v-model="keywords"
filterable
remote
placeholder="请输入关键词"
:remote-method="remoteMethod"
:loading="loading"
:clearable="true"
size="mini"
@change="currentSelect"
style="width: 250px"
>
<el-option
v-for="item in mapOptions"
:key="item.id"
:label="item.name"
:value="item"
class="one-text"
>
<span style="float: left">{{ item.name }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{
item.district
}}</span>
</el-option>
</el-select>
</div>
<div v-loading="loading" id="dropPointInfoContainer" class="am-map" style="width:100%;height: 700px;"></div>
<div slot="footer" class="dialog-footer">
<!-- <el-button type="primary" @click="clearCoordinatePoint">清除坐标点</el-button>-->
<el-button type="primary" @click="openMap = false">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listDropPointInfo,
getDropPointInfo,
delDropPointInfo,
addDropPointInfo,
updateDropPointInfo,
exportDropPointInfo
} from "@/api/unit/dropPointInfo";
import {getAreaList} from "@/api/dict"
import AMapLoader from "@amap/amap-jsapi-loader";
import Treeselect from "@riophae/vue-treeselect";
// 设置安全密钥
window._AMapSecurityConfig = {
securityJsCode: 'aa1db7d8f534f3da3f6d8a6a71382802',
}
export default {
name: "DropPointInfo",
components: {AMapLoader},
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 投放点信息管理表格数据
dropPointInfoList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
dropPointName: null,
address: null,
type: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
dropPointName: [
{required: true, message: "请输入投放点名称", trigger: "blur"}
],
district: [
{required: true, message: "请输入所属区域", trigger: "blur"}
],
street: [
{required: true, message: "请输入所属街道", trigger: "blur"}
],
community: [
{required: true, message: "请输入社区", trigger: "blur"}
],
address: [
{required: true, message: "请输入详细地址", trigger: "blur"}
],
type: [
{required: true, message: "请选择投放点形式", trigger: "change"}
],
area: [
{required: true, message: "请输入投放点面积", trigger: "blur"},
//只能填写数字、小数
{pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: "只能填写数字、小数,限制两位小数", trigger: "blur"}
],
capacity: [
{required: true, message: "请输入投放点容量", trigger: "blur"},
//只能填写数字
{pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: "只能填写数字、小数,限制两位小数", trigger: "blur"}
],
managementUnit: [
{required: true, message: "请输入管理单位", trigger: "blur"}
],
custodian: [
{required: true, message: "请输入管理人", trigger: "blur"}
],
custodianPhone: [
{required: true, message: "请输入管理员电话", trigger: "blur"},
{
pattern: /^1(3|4|5|7|8|9)\d{9}$/,
message: '手机号格式错误',
trigger: 'change'
}
],
dropTime: [
{required: true, message: "请选择投放时间", trigger: "change"}
],
operatingUnit: [
{required: true, message: "请输入运营单位", trigger: "blur"}
],
transportUnit: [
{required: true, message: "请输入运输单位", trigger: "blur"}
],
coordinatePoint: [
{required: true, message: "请点击坐标点按钮选择坐标点", trigger: "blur"}
]
},
areas: [],
streets:[],
// 地图
map: null,
keywords: "",
mapOptions: [],
openMap:false,
center: null,
circleMarker: null,
};
},
created() {
getAreaList().then(response => {
if(response==null || response.length===0){
this.$message.error("获取区域列表失败");
return;
}
const data = response;
for (let dataKey in data) {
if(data[dataKey].level === '3'){
this.areas.push({name:data[dataKey].name,code:data[dataKey].id, streets:[]})
}
}
for(let dataKey in data){
for(let areas1Key in this.areas){
if(data[dataKey].pid === this.areas[areas1Key].code){
this.areas[areas1Key].streets.push({code:data[dataKey].id, name:data[dataKey].name})
}
}
}
});
this.getList();
// this.initAMap();
},
methods: {
dict(code){
for(let key in this.areas){
if(this.areas[key].code === code){
return this.areas[key].name;
}
}
},
dictInfo(code){
for(let key in this.areas){
for(let keyInfo in this.areas[key].streets){
if(this.areas[key].streets[keyInfo].code === code){
return this.areas[key].streets[keyInfo].name;
}
}
}
},
clearCoordinatePoint(){
this.center = null;
this.form.coordinatePoint = null;
this.map = null;
this.circleMarker = null;
this.initAMap();
},
handleOpenMap(){
this.openMap = true;
this.initAMap();
},
initAMap() {
const _this = this
// 加载高德地图
AMapLoader.load({
key: _this.$aMapKey, //设置高德地图申请的key
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: ['AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Marker','AMap.CircleMarker'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
AMapUI: {
version: "1.1",
plugins: []
},
Loca: {
version: "2.0"
},
}).then(async (AMap) => {
_this.map = await new AMap.Map("dropPointInfoContainer", { //设置地图容器id
viewMode: "2D", // 默认使用 2D 模式
center: [113.01814545605467, 28.201039299894283], // 初始化地图中心点位置
zoom: 11, //初始化地图层级
resizeEnable: true,
willreadoften: true
});
_this.AutoComplete = await new AMap.AutoComplete({city:'长沙'});
// 数据回显
if(_this.form.coordinatePoint!=null&&_this.form.coordinatePoint!==""){
//设置圆形位置
_this.center = new AMap.LngLat(_this.form.coordinatePoint.split(",")[0], _this.form.coordinatePoint.split(",")[1]);
//设置圆的半径大小
var radius = 10 //单位:px
//创建圆形点标记 CircleMarker 实例
_this.circleMarker = new AMap.CircleMarker({
center: _this.center, //圆心
radius: radius, //半径
strokeColor: "white", //轮廓线颜色
strokeWeight: 2, //轮廓线宽度
strokeOpacity: 0.5, //轮廓线透明度
fillColor: "rgba(0,0,255,1)", //圆点填充颜色
fillOpacity: 0.5, //圆点填充透明度
zIndex: 10, //圆点覆盖物的叠加顺序
cursor: "pointer", //鼠标悬停时的鼠标样式
});
//圆形 circleMarker 对象添加到 Map
_this.map.add(_this.circleMarker);
//将覆盖物调整到合适视野
_this.map.setFitView([_this.circleMarker]);
}
// 监听地图点击事件
_this.map.on("click", (e) => {
console.log(e)
if(_this.center!=null){
_this.map.remove(_this.circleMarker);
_this.center = null;
_this.form.coordinatePoint = null;
}
//判断是否已有圆点标记
if(_this.center==null){
//设置圆形位置
_this.center = new AMap.LngLat(e.lnglat.lng, e.lnglat.lat);
//设置圆的半径大小
var radius = 10 //单位:px
//创建圆形点标记 CircleMarker 实例
_this.circleMarker = new AMap.CircleMarker({
center: _this.center, //圆心
radius: radius, //半径
strokeColor: "white", //轮廓线颜色
strokeWeight: 2, //轮廓线宽度
strokeOpacity: 0.5, //轮廓线透明度
fillColor: "rgba(0,0,255,1)", //圆点填充颜色
fillOpacity: 0.5, //圆点填充透明度
zIndex: 10, //圆点覆盖物的叠加顺序
cursor: "pointer", //鼠标悬停时的鼠标样式
});
//圆形 circleMarker 对象添加到 Map
_this.map.add(_this.circleMarker);
//将覆盖物调整到合适视野
_this.map.setFitView([_this.circleMarker]);
_this.$set(_this.form, "coordinatePoint", e.lnglat.lng+","+e.lnglat.lat);
}
});
}).catch(e => {
console.log(e);
});
this.loading = false;
// this.openMap = false;
},
// 选中提示
currentSelect(val) {
console.log(val);
// 清空时不执行后面代码
if (!val) {
return ;
}
//清除marker
if (this.searchMarker){
this.map.remove(this.searchMarker)
}
//设置marker
// this.searchMarker = new AMap.Marker({
// map: this.map,
// position: [val.location.lng, val.location.lat],
// });
// 自动适应显示想显示的范围区域
//定位
this.map.setCenter([val.location.lng, val.location.lat])
this.map.setZoom(18);
this.keywords = val.name
},
// 搜索地址
remoteMethod(query) {
if (query !== "") {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.AutoComplete.search(query, (status, result) => {
this.mapOptions = result.tips;
});
}, 200);
} else {
this.mapOptions = [];
}
},
createDropPointNo(area){
listDropPointInfo({dropPointNo: area.code}).then(response => {
const total = response.total+1;
this.form.dropPointNo = area.code+total.toString().padStart(3, '0');
});
},
getStreets(regionName) {
this.streets = [];
this.form.dropPointNo = null;
this.form.street = null;
const region = this.areas.find(region => region.code === regionName);
this.streets = region.streets;
},
/** 下载文件 */
/** 查询投放点信息管理列表 */
getList() {
this.loading = true;
listDropPointInfo(this.queryParams).then(response => {
this.dropPointInfoList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
dropPointName: null,
district: null,
street: null,
community: null,
address: null,
type: null,
area: null,
capacity: null,
managementUnit: null,
custodian: null,
custodianPhone: null,
dropTime: null,
dropPointNo: null,
operatingUnit: null,
transportUnit: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null
};
this.map = null;
this.center = null;
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加投放点信息管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getDropPointInfo(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改投放点信息管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateDropPointInfo(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDropPointInfo(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除投放点信息管理编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return delDropPointInfo(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有投放点信息管理数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return exportDropPointInfo(queryParams);
}).then(response => {
this.download(response.message);
})
}
}
};
</script>