Commit b2572cd4f7d5ccb7553b1ee75cb502fd3a1d6827
1 parent
358d6e00
公司地址变成地图选择地址
Showing
3 changed files
with
150 additions
and
4 deletions
trash-ui/src/views/unit/enterprise/info.vue
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | <el-row :gutter="30"> |
| 61 | 61 | <el-col :span="7"> |
| 62 | 62 | <el-form-item label="办公地址" prop="officeAddress"> |
| 63 | - <el-input v-model="form.officeAddress" placeholder="请输入内容" /> | |
| 63 | + <el-input v-model="form.officeAddress" placeholder="请输入内容" @focus="openMapDialog"/> | |
| 64 | 64 | </el-form-item> |
| 65 | 65 | </el-col> |
| 66 | 66 | <el-col :span="7"> |
| ... | ... | @@ -339,6 +339,40 @@ |
| 339 | 339 | <el-button type="primary" @click="submitForm">确 定</el-button> |
| 340 | 340 | <el-button @click="cancel">取 消</el-button> |
| 341 | 341 | </div> |
| 342 | + <el-dialog title="高德地图" :visible.sync="openMap" width="1600px" height="750px" append-to-body> | |
| 343 | + <div class="serach_map"> | |
| 344 | + 搜索: | |
| 345 | + <el-select | |
| 346 | + v-model="keywords" | |
| 347 | + filterable | |
| 348 | + remote | |
| 349 | + placeholder="请输入关键词" | |
| 350 | + :remote-method="remoteMethod" | |
| 351 | + :loading="loading" | |
| 352 | + :clearable="true" | |
| 353 | + size="mini" | |
| 354 | + @change="currentSelect" | |
| 355 | + style="width: 250px" | |
| 356 | + > | |
| 357 | + <el-option | |
| 358 | + v-for="item in mapOptions" | |
| 359 | + :key="item.id" | |
| 360 | + :label="item.name" | |
| 361 | + :value="item" | |
| 362 | + class="one-text" | |
| 363 | + > | |
| 364 | + <span style="float: left">{{ item.name }}</span> | |
| 365 | + <span style="float: right; color: #8492a6; font-size: 13px">{{ | |
| 366 | + item.district | |
| 367 | + }}</span> | |
| 368 | + </el-option> | |
| 369 | + </el-select> | |
| 370 | + </div> | |
| 371 | + <div v-loading="loading" id="enterpriseContainer" class="am-map" style="width:100%;height: 700px;"></div> | |
| 372 | + <div slot="footer" class="dialog-footer"> | |
| 373 | + <el-button type="primary" @click="openMap = false">确 定</el-button> | |
| 374 | + </div> | |
| 375 | + </el-dialog> | |
| 342 | 376 | </div> |
| 343 | 377 | </template> |
| 344 | 378 | |
| ... | ... | @@ -347,10 +381,15 @@ import { listEnterprise, getEnterprise, delEnterprise, addEnterprise, updateEnte |
| 347 | 381 | import Treeselect from "@riophae/vue-treeselect"; |
| 348 | 382 | import '@riophae/vue-treeselect/dist/vue-treeselect.css' |
| 349 | 383 | import {getAreaList} from "@/api/casefile/remoteServer"; |
| 384 | +import AMapLoader from '@amap/amap-jsapi-loader'; | |
| 350 | 385 | |
| 386 | +// 设置安全密钥 | |
| 387 | +window._AMapSecurityConfig = { | |
| 388 | + securityJsCode: 'aa1db7d8f534f3da3f6d8a6a71382802', | |
| 389 | +} | |
| 351 | 390 | export default { |
| 352 | 391 | name: "DisposalSite", |
| 353 | - components: {Treeselect}, | |
| 392 | + components: {Treeselect,AMapLoader}, | |
| 354 | 393 | data() { |
| 355 | 394 | return { |
| 356 | 395 | // 遮罩层 |
| ... | ... | @@ -371,6 +410,7 @@ export default { |
| 371 | 410 | title: "", |
| 372 | 411 | // 是否显示弹出层 |
| 373 | 412 | open: false, |
| 413 | + openMap: false, | |
| 374 | 414 | // 表单参数 |
| 375 | 415 | form: {}, |
| 376 | 416 | // 表单校验 |
| ... | ... | @@ -435,9 +475,16 @@ export default { |
| 435 | 475 | safetyCertificate:[], |
| 436 | 476 | // 停车场全景图 |
| 437 | 477 | carParkPanorama:[], |
| 438 | - enterpriseList:[] | |
| 478 | + enterpriseList:[], | |
| 479 | + // 地图 | |
| 480 | + map: null, | |
| 481 | + keywords: "", | |
| 482 | + mapOptions: [], | |
| 483 | + AutoComplete: null, | |
| 484 | + searchMarker: null, | |
| 439 | 485 | }; |
| 440 | 486 | }, |
| 487 | + | |
| 441 | 488 | created() { |
| 442 | 489 | getAreaList().then(res => { |
| 443 | 490 | this.areas = res.data; |
| ... | ... | @@ -454,6 +501,90 @@ export default { |
| 454 | 501 | '$route.query.enterpriseId': 'initData' |
| 455 | 502 | }, |
| 456 | 503 | methods: { |
| 504 | + openMapDialog(){ | |
| 505 | + this.openMap = true; | |
| 506 | + if(this.map==null){ | |
| 507 | + this.initAMap(); | |
| 508 | + } | |
| 509 | + }, | |
| 510 | + // 选中提示 | |
| 511 | + currentSelect(val) { | |
| 512 | + console.log(val); | |
| 513 | + // 清空时不执行后面代码 | |
| 514 | + if (!val) { | |
| 515 | + return ; | |
| 516 | + } | |
| 517 | + // 自动适应显示想显示的范围区域 | |
| 518 | + this.map.setFitView(); | |
| 519 | + //清除marker | |
| 520 | + if (this.searchMarker){ | |
| 521 | + this.map.remove(this.searchMarker) | |
| 522 | + } | |
| 523 | + //设置marker | |
| 524 | + this.searchMarker = new AMap.Marker({ | |
| 525 | + map: this.map, | |
| 526 | + position: [val.location.lng, val.location.lat], | |
| 527 | + }); | |
| 528 | + | |
| 529 | + this.keywords = val.name | |
| 530 | + //定位 | |
| 531 | + this.map.setCenter([val.location.lng, val.location.lat]) | |
| 532 | + this.form.officeAddressGps = val.location.lng+","+val.location.lat; | |
| 533 | + this.form.officeAddress = val.district + val.name; | |
| 534 | + }, | |
| 535 | + // 搜索地址 | |
| 536 | + remoteMethod(query) { | |
| 537 | + if (query !== "") { | |
| 538 | + this.loading = true; | |
| 539 | + setTimeout(() => { | |
| 540 | + this.loading = false; | |
| 541 | + this.AutoComplete.search(query, (status, result) => { | |
| 542 | + this.mapOptions = result.tips; | |
| 543 | + }); | |
| 544 | + }, 200); | |
| 545 | + } else { | |
| 546 | + this.mapOptions = []; | |
| 547 | + } | |
| 548 | + }, | |
| 549 | + initAMap() { | |
| 550 | + const _this = this | |
| 551 | + // 加载高德地图 | |
| 552 | + AMapLoader.load({ | |
| 553 | + key: _this.$aMapKey, //设置高德地图申请的key | |
| 554 | + version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 | |
| 555 | + plugins: ['AMap.ToolBar', 'AMap.PolygonEditor','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Marker'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 | |
| 556 | + AMapUI: { | |
| 557 | + version: "1.1", | |
| 558 | + plugins: [] | |
| 559 | + }, | |
| 560 | + Loca: { | |
| 561 | + version: "2.0" | |
| 562 | + }, | |
| 563 | + }).then(async (AMap) => { | |
| 564 | + _this.map = await new AMap.Map("enterpriseContainer", { //设置地图容器id | |
| 565 | + viewMode: "2D", // 默认使用 2D 模式 | |
| 566 | + center: [113.01814545605467, 28.201039299894283], // 初始化地图中心点位置 | |
| 567 | + zoom: 11, //初始化地图层级 | |
| 568 | + resizeEnable: true, | |
| 569 | + willreadoften: true | |
| 570 | + }); | |
| 571 | + | |
| 572 | + _this.AutoComplete = await new AMap.AutoComplete({city:'长沙'}); | |
| 573 | + | |
| 574 | + // 图层样式切换控件(卫星图) | |
| 575 | + AMapUI.loadUI(['control/BasicControl'], function(BasicControl) { | |
| 576 | + //图层切换控件 | |
| 577 | + _this.map.addControl(new BasicControl.LayerSwitcher({ | |
| 578 | + position: 'rb' // 右下角 | |
| 579 | + })); | |
| 580 | + | |
| 581 | + }); | |
| 582 | + }).catch(e => { | |
| 583 | + console.log(e); | |
| 584 | + }); | |
| 585 | + this.loading = false; | |
| 586 | + // this.openMap = false; | |
| 587 | + }, | |
| 457 | 588 | reset(){ |
| 458 | 589 | this.form = {}; |
| 459 | 590 | this.transportPermission = []; | ... | ... |
trash-unit/src/main/java/com/trash/enterprise/domain/TransportationEnterprise.java
| ... | ... | @@ -52,6 +52,9 @@ public class TransportationEnterprise extends BaseEntity |
| 52 | 52 | @Excel(name = "办公地址") |
| 53 | 53 | private String officeAddress; |
| 54 | 54 | |
| 55 | + /** 办公地址gps,经纬度 */ | |
| 56 | + private String officeAddressGps; | |
| 57 | + | |
| 55 | 58 | /** 停车场位置 */ |
| 56 | 59 | @Excel(name = "停车场位置") |
| 57 | 60 | private String parkingLotLocation; |
| ... | ... | @@ -126,6 +129,14 @@ public class TransportationEnterprise extends BaseEntity |
| 126 | 129 | @Excel(name = "公司类型") |
| 127 | 130 | private String servicePhone; |
| 128 | 131 | |
| 132 | + public String getOfficeAddressGps() { | |
| 133 | + return officeAddressGps; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public void setOfficeAddressGps(String officeAddressGps) { | |
| 137 | + this.officeAddressGps = officeAddressGps; | |
| 138 | + } | |
| 139 | + | |
| 129 | 140 | public String getServicePhone() { |
| 130 | 141 | return servicePhone; |
| 131 | 142 | } | ... | ... |
trash-unit/src/main/resources/mapper/unit/TransportationEnterpriseMapper.xml
| ... | ... | @@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 13 | 13 | <result property="enterDate" column="enter_date" /> |
| 14 | 14 | <result property="businessLicenseDate" column="business_license_date" /> |
| 15 | 15 | <result property="officeAddress" column="office_address" /> |
| 16 | + <result property="officeAddressGps" column="office_address_gps" /> | |
| 16 | 17 | <result property="parkingLotLocation" column="parking_lot_location" /> |
| 17 | 18 | <result property="parkingArea" column="parking_area" /> |
| 18 | 19 | <result property="carNumber" column="car_number" /> |
| ... | ... | @@ -42,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 42 | 43 | </resultMap> |
| 43 | 44 | |
| 44 | 45 | <sql id="selectTransportationEnterpriseVo"> |
| 45 | - select id, name, abbreviation, registration_area, transport_permission_date, enter_date, business_license_date, office_address, parking_lot_location, parking_area, (select count(id) from car_info where company_id = te.id) car_number, safety_manager_name, safety_manager_phone, social_uniform_credit_code_number, legal_representative, legal_representative_phone, safety_people_name, remark, transport_permission, enterprise_business_license, safety_officer_qualification_certificate, safety_certificate, car_park_panorama, business_unit, status, create_time, create_by, update_time, update_by, parent_id, company_type, credit_status, qr_code,service_phone from transportation_enterprise te | |
| 46 | + select id, name, abbreviation, registration_area, transport_permission_date, enter_date, business_license_date, office_address, parking_lot_location, parking_area, (select count(id) from car_info where company_id = te.id) car_number, safety_manager_name, safety_manager_phone, social_uniform_credit_code_number, legal_representative, legal_representative_phone, safety_people_name, remark, transport_permission, enterprise_business_license, safety_officer_qualification_certificate, safety_certificate, car_park_panorama, business_unit, status, create_time, create_by, update_time, update_by, parent_id, company_type, credit_status, qr_code,service_phone,office_address_gps from transportation_enterprise te | |
| 46 | 47 | </sql> |
| 47 | 48 | |
| 48 | 49 | <select id="selectTransportationEnterpriseList" parameterType="TransportationEnterprise" resultMap="TransportationEnterpriseResult"> |
| ... | ... | @@ -120,6 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 120 | 121 | <if test="creditStatus != null">credit_status,</if> |
| 121 | 122 | <if test="qrCode != null">qr_code,</if> |
| 122 | 123 | <if test="servicePhone != null">service_phone,</if> |
| 124 | + <if test="officeAddressGps != null">office_address_gps,</if> | |
| 123 | 125 | </trim> |
| 124 | 126 | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| 125 | 127 | <if test="name != null">#{name},</if> |
| ... | ... | @@ -155,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 155 | 157 | <if test="creditStatus != null">#{creditStatus},</if> |
| 156 | 158 | <if test="qrCode != null">#{qrCode},</if> |
| 157 | 159 | <if test="servicePhone != null">#{servicePhone},</if> |
| 160 | + <if test="officeAddressGps != null">#{officeAddressGps},</if> | |
| 158 | 161 | </trim> |
| 159 | 162 | </insert> |
| 160 | 163 | |
| ... | ... | @@ -194,6 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 194 | 197 | <if test="creditStatus != null">credit_status = #{creditStatus},</if> |
| 195 | 198 | <if test="qrCode != null">qr_code = #{qrCode},</if> |
| 196 | 199 | <if test="servicePhone != null">service_phone = #{servicePhone},</if> |
| 200 | + <if test="officeAddressGps != null">office_address_gps = #{officeAddressGps},</if> | |
| 197 | 201 | </trim> |
| 198 | 202 | where id = #{id} |
| 199 | 203 | </update> | ... | ... |