AJNB 1 月之前
父節點
當前提交
827b33f361
共有 2 個文件被更改,包括 50 次插入55 次删除
  1. 48 54
      src/views/enterprise/mapContainer.vue
  2. 2 1
      vue.config.js

+ 48 - 54
src/views/enterprise/mapContainer.vue

@@ -30,7 +30,7 @@
         <el-button @click="selectRectsBeginPoint">生成小区群</el-button>
         <el-button @click="changeNeighborAngle">小区群改变角度</el-button>
         <el-button
-          @click="(new_farm.ridge_distance === 0 ? $message.error('请先创建农场') : (neighborhoodDialogVisible = true, neighborhood.push(neighborhood[neighborhood.length - 1])))">创建小区</el-button>
+          @click="(new_farm.ridge_distance === 0 ? $message.error('请先创建农场') : (neighborhoodDialogVisible = true, neighborhood.push(neighborhood[neighborhood.length - 1]),selectNeighborIndex=neighborhood.length - 1))">创建小区</el-button>
         <el-button
           @click="(polygon === null ? $message.error('请先创建农场') : loadWidthDialogVisible = true)">输入作业路宽</el-button>
       </div>
@@ -152,7 +152,7 @@ import Stick from "./components/stick.vue"
 import draggable from "vuedraggable";
 import bus from './bus.js'
 import { listFarm } from '@/api/farm/farm.js'
-import { addFarmReturnId, delFarmAndMap } from '@/api/map/map.js'
+import { addFarmReturnId, delFarmAndMap, listFarmAndMapById } from '@/api/map/map.js'
 // @ts-ignore
 window._AMapSecurityConfig = {
   // 安全密钥
@@ -240,48 +240,28 @@ export default {
       },
       //农村数据
       farm: [
-        {
-          id: '',
-          farm_name: '',
-          enterpirse_id: '',
-          size_m: '',
-          size_p: '',
-          size_round: '',
-          ridge_distance: '',
-          area_num: '',
-          project_num: '',
-          create_time: '',
-          address: '',
-          s_picture: '',
-          scale: '',
-          polygon: [
-            [116.403322, 39.920255],
-            [116.410703, 39.897555],
-            [116.402292, 39.892353],
-            [116.389846, 39.891365],
-          ],
-        },
-        {
-          id: '',
-          farm_name: '',
-          enterpirse_id: '',
-          size_m: '30',
-          size_p: '30',
-          size_round: '',
-          ridge_distance: '1',
-          area_num: '',
-          project_num: '',
-          create_time: '',
-          address: '',
-          s_picture: '',
-          scale: '',
-          polygon: [
-            [116.503322, 39.950255],
-            [116.510703, 39.997555],
-            [116.502292, 39.992353],
-            [116.589846, 39.991365],
-          ],
-        },
+        // {
+        //   id: '',
+        //   farm_name: '',
+        //   enterpirse_id: '',
+        //   size_m: '',
+        //   size_p: '',
+        //   size_round: '',
+        //   ridge_distance: '',
+        //   area_num: '',
+        //   project_num: '',
+        //   create_time: '',
+        //   address: '',
+        //   s_picture: '',
+        //   scale: '',
+        //   polygon: [
+        //     [116.403322, 39.920255],
+        //     [116.410703, 39.897555],
+        //     [116.402292, 39.892353],
+        //     [116.389846, 39.891365],
+        //   ],
+        // },
+
       ],
       //创建小区弹窗
       neighborhoodDialogVisible: false,
@@ -410,8 +390,9 @@ export default {
             this.clearNeighbor();
             this.neighborContextMenu.close()
           })
-
-          this.initPolygon();
+          //初始农场信息,并加载农场
+          this.initFarmInfo();
+          
 
           // 添加卫星图层
           let weixing = new AMap.TileLayer.Satellite({
@@ -825,7 +806,7 @@ export default {
       let angle;
       if (this.neighborhood[this.neighborhood.length - 1].islock_ridge) {
         angle = this.currentNeighborAngle; // 旋转角度,单位为度
-      }else{
+      } else {
         angle = 0;
       }
 
@@ -1128,8 +1109,19 @@ export default {
       this.polyEditor.close();
       this.polyEditor = null;
     },
-
-    //初始化多边形
+    //初始化农场信息
+    initFarmInfo() {
+      listFarmAndMapById({}).then(info => {
+        // console.log("info", info);
+        for (let i = 0; i < info.data.length; i++) {
+          let t = info.data[i]
+          this.farm.push({...t, polygon: t.polygonMap.map(item => [Number(item.lng), Number(item.lat)])})
+        }
+        console.log("this.farm", this.farm);
+        this.initPolygon();
+      })
+    },
+    //初始化农场多边形
     initPolygon() {
       this.map.clearMap()
       for (let index = 0; index < this.farm.length; index++) {
@@ -1153,7 +1145,7 @@ export default {
       this.new_farm.size_p = this.area;
       this.new_farm.size_round = this.perimeter;
       this.new_farm.polygon = this.polygon.getPath()
-      // console.log("new_farm.polygon", new_farm.polygon);
+      console.log("new_farm.polygon", this.new_farm.polygon);
     },
     //根据坐标解析地址
     addressResolutionByCoordinates(obj) {
@@ -1181,7 +1173,7 @@ export default {
       // this.farm.push(this.new_farm);
       Message.success("创建成功");
       this.farmDialogVisible = false;
-      // console.log("this.new_farm", this.new_farm);
+      console.log("this.new_farm", this.new_farm);
       addFarmReturnId(this.new_farm).then(info => {
         // console.log("info", info);
         this.new_farm.id = info.msg
@@ -1252,10 +1244,12 @@ export default {
       console.log("changeAngle", changeAngle);
       this.changeNeighborAngle(-changeAngle);
     })
-    listFarm({}).then(info => {
-      console.log("info", info);
+    // listFarm({}).then(info => {
+    //   console.log("info", info);
+
+    // })
+
 
-    })
     // delFarmAndMap({id:'5c1a7a58-3f51-4e77-9dfc-ede01c29fa45'}).then(info => {
     //   console.log("info", info);
     // })

+ 2 - 1
vue.config.js

@@ -35,7 +35,8 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://192.168.0.153:8080`,
+        target: `http://localhost:8080`,
+        // target: `http://192.168.0.153:8080`,
         // target: `http://8.130.113.97:8080`,
         changeOrigin: true,
         pathRewrite: {