mo 4 năm trước cách đây
mục cha
commit
d4e2b46990
1 tập tin đã thay đổi với 72 bổ sung51 xóa
  1. 72 51
      src/views/categroyManager/insideSetting/addressManager.vue

+ 72 - 51
src/views/categroyManager/insideSetting/addressManager.vue

@@ -268,25 +268,39 @@
       :visible.sync="mapStatus"
       width="800px"
     >
-      <el-amap-search-box
-        class="search-box"
-        value="searchValue"
-        :search-option="searchOption"
-        :on-search-result="onSearchResult"
-      ></el-amap-search-box>
-      <el-amap :zoom="zoom" :plugin="plugin" :center="center" :events="events">
-        <el-amap-marker
-          :events="markerEvents()"
-          v-for="(marker, index) in markers"
-          :key="index"
-          :position="marker"
-        ></el-amap-marker>
-      </el-amap>
+      <div style="padding: 0 20px">
+        <el-alert
+          style="margin-bottom: 10px"
+          title="选中地点:"
+          type="info"
+          :description="addressDetail.address"
+        >
+        </el-alert>
+        <el-amap-search-box
+          class="search-box"
+          value="searchValue"
+          :search-option="searchOption"
+          :on-search-result="onSearchResult"
+        ></el-amap-search-box>
+        <el-amap
+          :zoom="zoom"
+          :plugin="plugin"
+          :center="center"
+          :events="events"
+        >
+          <el-amap-marker
+            :events="markerEvents()"
+            v-for="(marker, index) in markers"
+            :key="index"
+            :position="marker"
+          ></el-amap-marker>
+        </el-amap>
+      </div>
+
       <span slot="footer" class="dialog-footer">
-     <el-button @click="mapStatus = false">取 消</el-button>
-      <el-button type="primary" @click="setAddrss">确 定</el-button>
+        <el-button @click="mapStatus = false">取 消</el-button>
+        <el-button type="primary" @click="setAddrss">确 定</el-button>
       </span>
-
     </el-dialog>
   </div>
 </template>
@@ -399,7 +413,7 @@ export default {
           console.log(e);
         },
         click: (e) => {
-          console.log(e);
+          this.getpoient(e);
         },
       },
       addressMessage: true,
@@ -417,6 +431,7 @@ export default {
       },
       cooperationList: [], // 合作单位列表
       searchValue: "测试",
+      activeAddress: {},
     };
   },
   mounted() {
@@ -428,8 +443,6 @@ export default {
       // 添加数据
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          this.form.address = this.addressDetail.address;
-          this.form.longitudeLatitude = this.addressDetail.poi;
           // if(this.form.source == 1) { // 判断是租赁还是合作单位
           //   this.form.organId = this.selectOrganId
           // }
@@ -466,8 +479,9 @@ export default {
     addMap() {
       //
       this.mapStatus = true;
-      let poi = this.addressDetail.poi;
-      let address = this.addressDetail.address;
+
+      let poi = this.form.longitudeLatitude;
+      let address = this.form.address;
       // 获取经纬度
       if (poi) {
         this.markers = [];
@@ -518,42 +532,49 @@ export default {
         this.center = [center.lng, center.lat];
       }
     },
+    getpoient(e) {
+      let geocoder = new AMap.Geocoder();
+      let that = this;
+      geocoder.getAddress(e.lnglat, function (status, result) {
+        if (status === "complete" && result.regeocode) {
+          result.regeocode.lnglat = e.lnglat;
+          let ct = result.regeocode.addressComponent;
+          that.addressDetail = {
+            address:
+              ct.province +
+              "," +
+              ct.city +
+              "," +
+              ct.district +
+              "," +
+              ct.township +
+              ct.street +
+              ct.streetNumber,
+            poi: e.lnglat.lng + "," + e.lnglat.lat,
+          };
+          that.form.address = result.regeocode.formattedAddress;
+          // that.mapStatus = false
+          // that.addressMessage = false
+        } else {
+          that.$message.error("请重新选择地址");
+        }
+      });
+    },
     markerEvents() {
       // marker 事件添加
       let that = this;
       return {
         click: (e) => {
-          console.log(AMap)
-          let geocoder = new AMap.Geocoder();
-
-          geocoder.getAddress(e.lnglat, function (status, result) {
-            if (status === "complete" && result.regeocode) {
-              result.regeocode.lnglat = e.lnglat;
-              let ct = result.regeocode.addressComponent;
-              that.addressDetail = {
-                address:
-                  ct.province +
-                  "," +
-                  ct.city +
-                  "," +
-                  ct.district +
-                  "," +
-                  ct.township +
-                  ct.street +
-                  ct.streetNumber,
-                poi: e.lnglat.lng + "," + e.lnglat.lat,
-              };
-              that.form.address = result.regeocode.formattedAddress;
-              // that.mapStatus = false
-              // that.addressMessage = false
-            } else {
-              that.$message.error("请重新选择地址");
-            }
-          });
+          this.getpoient(e);
         },
       };
     },
-    setAddrss() {},
+    setAddrss() {
+      this.form.address = this.addressDetail.address;
+      this.form.longitudeLatitude = this.addressDetail.poi;
+      this.mapStatus = false;
+      this.addressMessage = false;
+    },
     getList() {
       let searchForm = this.searchForm;
       let params = {
@@ -722,7 +743,7 @@ export default {
 }
 .el-vue-search-box-container {
   position: absolute !important;
-  left: 10px;
+  left: 30px;
   margin-top: 10px;
   z-index: 99999 !important;
 }