Commit 31daa822269096b2b0c8d6ad3e1b65492d3e7a9e

Authored by 2c2c2c
1 parent 2d39ce9e

投放点信息,新增投放点经纬度

trash-ui/src/views/unit/dropPointInfo/index.vue
... ... @@ -242,6 +242,12 @@
242 242 <el-input v-model="form.transportUnit" placeholder="请输入运输单位"/>
243 243 </el-form-item>
244 244 </el-col>
  245 + <el-col :span="12">
  246 + <el-form-item label="坐标点" prop="coordinatePoint">
  247 + <el-input v-model="form.coordinatePoint" placeholder="请输入坐标点经纬度" readonly/>
  248 + </el-form-item>
  249 + <el-button type="primary" @click="handleOpenMap">坐标点</el-button>
  250 + </el-col>
245 251 </el-row>
246 252 </el-form>
247 253 <div slot="footer" class="dialog-footer">
... ... @@ -249,6 +255,41 @@
249 255 <el-button @click="cancel">取 消</el-button>
250 256 </div>
251 257 </el-dialog>
  258 + <el-dialog title="高德地图" :visible.sync="openMap" width="1600px" height="750px" append-to-body>
  259 + <div class="serach_map">
  260 + 搜索:
  261 + <el-select
  262 + v-model="keywords"
  263 + filterable
  264 + remote
  265 + placeholder="请输入关键词"
  266 + :remote-method="remoteMethod"
  267 + :loading="loading"
  268 + :clearable="true"
  269 + size="mini"
  270 + @change="currentSelect"
  271 + style="width: 250px"
  272 + >
  273 + <el-option
  274 + v-for="item in mapOptions"
  275 + :key="item.id"
  276 + :label="item.name"
  277 + :value="item"
  278 + class="one-text"
  279 + >
  280 + <span style="float: left">{{ item.name }}</span>
  281 + <span style="float: right; color: #8492a6; font-size: 13px">{{
  282 + item.district
  283 + }}</span>
  284 + </el-option>
  285 + </el-select>
  286 + </div>
  287 + <div v-loading="loading" id="dropPointInfoContainer" class="am-map" style="width:100%;height: 700px;"></div>
  288 + <div slot="footer" class="dialog-footer">
  289 + <el-button type="primary" @click="clearCoordinatePoint">清除坐标点</el-button>
  290 + <el-button type="primary" @click="openMap = false">确 定</el-button>
  291 + </div>
  292 + </el-dialog>
252 293 </div>
253 294 </template>
254 295  
... ... @@ -262,9 +303,17 @@ import {
262 303 exportDropPointInfo
263 304 } from "@/api/unit/dropPointInfo";
264 305 import {getAreaList} from "@/api/casefile/remoteServer";
  306 +import AMapLoader from "@amap/amap-jsapi-loader";
  307 +import Treeselect from "@riophae/vue-treeselect";
  308 +
  309 +// 设置安全密钥
  310 +window._AMapSecurityConfig = {
  311 + securityJsCode: 'aa1db7d8f534f3da3f6d8a6a71382802',
  312 +}
265 313  
266 314 export default {
267 315 name: "DropPointInfo",
  316 + components: {AMapLoader},
268 317 data() {
269 318 return {
270 319 // 遮罩层
... ... @@ -347,6 +396,9 @@ export default {
347 396 ],
348 397 transportUnit: [
349 398 {required: true, message: "请输入运输单位", trigger: "blur"}
  399 + ],
  400 + coordinatePoint: [
  401 + {required: true, message: "请点击坐标点按钮选择坐标点", trigger: "blur"}
350 402 ]
351 403 },
352 404 areas: [
... ... @@ -502,13 +554,152 @@ export default {
502 554 ]
503 555 }
504 556 ],
505   - streets:[]
  557 + streets:[],
  558 + // 地图
  559 + map: null,
  560 + keywords: "",
  561 + mapOptions: [],
  562 + openMap:false,
  563 + center: null,
506 564 };
507 565 },
508 566 created() {
509 567 this.getList();
  568 + // this.initAMap();
510 569 },
511 570 methods: {
  571 + clearCoordinatePoint(){
  572 + this.center = null;
  573 + this.form.coordinatePoint = null;
  574 + this.map = null;
  575 + this.initAMap();
  576 + },
  577 + handleOpenMap(){
  578 + this.openMap = true;
  579 + this.initAMap();
  580 + },
  581 + initAMap() {
  582 + const _this = this
  583 + // 加载高德地图
  584 + AMapLoader.load({
  585 + key: _this.$aMapKey, //设置高德地图申请的key
  586 + version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
  587 + plugins: ['AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Marker','AMap.CircleMarker'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
  588 + AMapUI: {
  589 + version: "1.1",
  590 + plugins: []
  591 + },
  592 + Loca: {
  593 + version: "2.0"
  594 + },
  595 + }).then(async (AMap) => {
  596 + _this.map = await new AMap.Map("dropPointInfoContainer", { //设置地图容器id
  597 + viewMode: "2D", // 默认使用 2D 模式
  598 + center: [113.01814545605467, 28.201039299894283], // 初始化地图中心点位置
  599 + zoom: 11, //初始化地图层级
  600 + resizeEnable: true,
  601 + willreadoften: true
  602 + });
  603 + _this.AutoComplete = await new AMap.AutoComplete({city:'长沙'});
  604 + // 数据回显
  605 + if(_this.form.coordinatePoint!=null&&_this.form.coordinatePoint!==""){
  606 + //设置圆形位置
  607 + _this.center = new AMap.LngLat(_this.form.coordinatePoint.split(",")[0], _this.form.coordinatePoint.split(",")[1]);
  608 + //设置圆的半径大小
  609 + var radius = 10 //单位:px
  610 +
  611 + //创建圆形点标记 CircleMarker 实例
  612 + var circleMarker = new AMap.CircleMarker({
  613 + center: _this.center, //圆心
  614 + radius: radius, //半径
  615 + strokeColor: "white", //轮廓线颜色
  616 + strokeWeight: 2, //轮廓线宽度
  617 + strokeOpacity: 0.5, //轮廓线透明度
  618 + fillColor: "rgba(0,0,255,1)", //圆点填充颜色
  619 + fillOpacity: 0.5, //圆点填充透明度
  620 + zIndex: 10, //圆点覆盖物的叠加顺序
  621 + cursor: "pointer", //鼠标悬停时的鼠标样式
  622 + });
  623 + //圆形 circleMarker 对象添加到 Map
  624 + _this.map.add(circleMarker);
  625 + //将覆盖物调整到合适视野
  626 + _this.map.setFitView([circleMarker]);
  627 +
  628 + _this.form.coordinatePoint = e.lnglat.lng+","+e.lnglat.lat;
  629 + }
  630 + // 监听地图点击事件
  631 + _this.map.on("click", (e) => {
  632 + //判断是否已有圆点标记
  633 + if(_this.center==null){
  634 + //设置圆形位置
  635 + _this.center = new AMap.LngLat(e.lnglat.lng, e.lnglat.lat);
  636 + //设置圆的半径大小
  637 + var radius = 10 //单位:px
  638 +
  639 + //创建圆形点标记 CircleMarker 实例
  640 + var circleMarker = new AMap.CircleMarker({
  641 + center: _this.center, //圆心
  642 + radius: radius, //半径
  643 + strokeColor: "white", //轮廓线颜色
  644 + strokeWeight: 2, //轮廓线宽度
  645 + strokeOpacity: 0.5, //轮廓线透明度
  646 + fillColor: "rgba(0,0,255,1)", //圆点填充颜色
  647 + fillOpacity: 0.5, //圆点填充透明度
  648 + zIndex: 10, //圆点覆盖物的叠加顺序
  649 + cursor: "pointer", //鼠标悬停时的鼠标样式
  650 + });
  651 + //圆形 circleMarker 对象添加到 Map
  652 + _this.map.add(circleMarker);
  653 + //将覆盖物调整到合适视野
  654 + _this.map.setFitView([circleMarker]);
  655 +
  656 + _this.$set(_this.form, "coordinatePoint", e.lnglat.lng+","+e.lnglat.lat);
  657 + }
  658 + });
  659 + }).catch(e => {
  660 + console.log(e);
  661 + });
  662 + this.loading = false;
  663 + // this.openMap = false;
  664 + },
  665 + // 选中提示
  666 + currentSelect(val) {
  667 + console.log(val);
  668 + // 清空时不执行后面代码
  669 + if (!val) {
  670 + return ;
  671 + }
  672 +
  673 + //清除marker
  674 + if (this.searchMarker){
  675 + this.map.remove(this.searchMarker)
  676 + }
  677 + //设置marker
  678 + // this.searchMarker = new AMap.Marker({
  679 + // map: this.map,
  680 + // position: [val.location.lng, val.location.lat],
  681 + // });
  682 + // 自动适应显示想显示的范围区域
  683 + //定位
  684 + this.map.setCenter([val.location.lng, val.location.lat])
  685 + this.map.setZoom(18);
  686 + this.keywords = val.name
  687 +
  688 + },
  689 + // 搜索地址
  690 + remoteMethod(query) {
  691 + if (query !== "") {
  692 + this.loading = true;
  693 + setTimeout(() => {
  694 + this.loading = false;
  695 + this.AutoComplete.search(query, (status, result) => {
  696 + this.mapOptions = result.tips;
  697 + });
  698 + }, 200);
  699 + } else {
  700 + this.mapOptions = [];
  701 + }
  702 + },
512 703 createDropPointNo(area){
513 704 listDropPointInfo({dropPointNo: area.code}).then(response => {
514 705 const total = response.total+1;
... ... @@ -561,6 +752,8 @@ export default {
561 752 updateTime: null,
562 753 updateBy: null
563 754 };
  755 + this.map = null;
  756 + this.center = null;
564 757 this.resetForm("form");
565 758 },
566 759 /** 搜索按钮操作 */
... ...
trash-unit/src/main/java/com/trash/dropPointInfo/domain/DropPointInfo.java
... ... @@ -81,10 +81,23 @@ public class DropPointInfo extends BaseEntity
81 81 @Excel(name = "运输单位")
82 82 private String transportUnit;
83 83  
  84 + /** 坐标点 */
  85 + @Excel(name = "坐标点")
  86 + private String coordinatePoint;
  87 +
84 88 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
85 89 @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
86 90 private Date createTime;
87 91  
  92 +
  93 + public String getCoordinatePoint() {
  94 + return coordinatePoint;
  95 + }
  96 +
  97 + public void setCoordinatePoint(String coordinatePoint) {
  98 + this.coordinatePoint = coordinatePoint;
  99 + }
  100 +
88 101 @Override
89 102 public Date getCreateTime() {
90 103 return createTime;
... ...
trash-unit/src/main/resources/mapper/unit/DropPointInfoMapper.xml
... ... @@ -21,6 +21,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
21 21 <result property="dropPointNo" column="drop_point_no" />
22 22 <result property="operatingUnit" column="operating_unit" />
23 23 <result property="transportUnit" column="transport_unit" />
  24 + <result property="coordinatePoint" column="coordinate_point" />
24 25 <result property="createTime" column="create_time" />
25 26 <result property="createBy" column="create_by" />
26 27 <result property="updateTime" column="update_time" />
... ... @@ -28,7 +29,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
28 29 </resultMap>
29 30  
30 31 <sql id="selectDropPointInfoVo">
31   - select id, drop_point_name, district, street, community, address, type, area, capacity, management_unit, custodian, custodian_phone, drop_time, drop_point_no, operating_unit, transport_unit, create_time, create_by, update_time, update_by from drop_point_info
  32 + select id, drop_point_name, district, street, community, address, type, area, capacity, management_unit, custodian, custodian_phone, drop_time, drop_point_no, operating_unit, transport_unit,coordinate_point, create_time, create_by, update_time, update_by from drop_point_info
32 33 </sql>
33 34  
34 35 <select id="selectDropPointInfoList" parameterType="DropPointInfo" resultMap="DropPointInfoResult">
... ... @@ -64,6 +65,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
64 65 <if test="dropPointNo != null">drop_point_no,</if>
65 66 <if test="operatingUnit != null">operating_unit,</if>
66 67 <if test="transportUnit != null">transport_unit,</if>
  68 + <if test="coordinatePoint != null">coordinate_point,</if>
67 69 <if test="createTime != null">create_time,</if>
68 70 <if test="createBy != null">create_by,</if>
69 71 <if test="updateTime != null">update_time,</if>
... ... @@ -85,6 +87,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
85 87 <if test="dropPointNo != null">#{dropPointNo},</if>
86 88 <if test="operatingUnit != null">#{operatingUnit},</if>
87 89 <if test="transportUnit != null">#{transportUnit},</if>
  90 + <if test="coordinatePoint != null">#{coordinatePoint},</if>
88 91 <if test="createTime != null">#{createTime},</if>
89 92 <if test="createBy != null">#{createBy},</if>
90 93 <if test="updateTime != null">#{updateTime},</if>
... ... @@ -110,6 +113,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
110 113 <if test="dropPointNo != null">drop_point_no = #{dropPointNo},</if>
111 114 <if test="operatingUnit != null">operating_unit = #{operatingUnit},</if>
112 115 <if test="transportUnit != null">transport_unit = #{transportUnit},</if>
  116 + <if test="coordinatePoint != null">coordinate_point = #{coordinatePoint},</if>
113 117 <if test="createTime != null">create_time = #{createTime},</if>
114 118 <if test="createBy != null">create_by = #{createBy},</if>
115 119 <if test="updateTime != null">update_time = #{updateTime},</if>
... ...