Sfoglia il codice sorgente

站点经纬度编辑界面中可以修改入口经纬度。

zhengqiang 4 anni fa
parent
commit
062fc17be2

+ 2 - 2
.env.development

@@ -1,8 +1,8 @@
 OUT_PUT_DIR=dist/smart-bus-portal
 
-#VUE_APP_BACKEND_URL=http://127.0.0.1:8086/smart-bus-server
+VUE_APP_BACKEND_URL=http://127.0.0.1:8086/smart-bus-server
 #VUE_APP_BACKEND_URL=https://ykt-test.xiaoxinda.com/smart-bus-server
-VUE_APP_BACKEND_URL=http://121.37.187.149/smart-bus-server
+#VUE_APP_BACKEND_URL=http://121.37.187.149/smart-bus-server
 
 #手机企业版
 VUE_APP_COMPANY_HEALTH_WECHAT_QY_URL=http://wisdomhousewechat.sudaonline.net/prevention/motemwall.html 

+ 42 - 130
src/views/bus/routeInfo-detail.vue

@@ -208,65 +208,12 @@
         >
       </span>
     </el-dialog>
-    <el-dialog
+    <!--地图选点-->
+    <routeInfo-getpoint 
+      ref="getpoint"
       :visible.sync="showMapDialog"
-      title="地图选点"
-      :modal-append-to-body="true"
-      :append-to-body="true"
-      style="text-align: left"
-      width="60%"
-      top="5vh"
-      :close-on-click-modal="false"
-    >
-      <el-amap
-        ref="stationMap"
-        vid="stationMap"
-        :amap-manager="amapManager"
-        :center="pointPosition"
-        :zoom="zoom"
-        :events="events"
-        class="amap-demo"
-        :plugin="plugins"
-        style="width: 100%; height: 500px"
-      >
-        <el-amap-marker
-          vid="amapDemo"
-          :position="pointPosition"
-        ></el-amap-marker>
-
-        <!--站点入口-->
-        <el-amap-marker
-          :zIndex="1"
-          v-for="station in stationSubInfoList"
-          :key="station.id"
-          :position="station.position"
-          :title="station.title"
-          :icon="station.icon"
-        ></el-amap-marker>
-      </el-amap>
-      <span slot="footer" class="dialog-footer">
-        <div style="position: absolute; left: 20px; bottom: 20px">
-          <el-input
-            placeholder="当前经纬度"
-            v-model="selectedRow.location"
-            style="width: 400px"
-          >
-            <template slot="prepend">经纬度</template>
-            <el-button slot="append" icon="el-icon-search" @click="handleRegeo"
-              >定位</el-button
-            >
-          </el-input>          
-          <el-switch
-            v-model="ranging"
-            @change="rangingChange"
-            active-text="开启测距"
-            inactive-text="关闭测距">
-          </el-switch>
-        </div>
-        <el-button @click="showMapDialog = false">取 消</el-button>
-        <el-button type="primary" @click="handleSelectPoint()">确 定</el-button>
-      </span>
-    </el-dialog>   
+      @yes="handleChangeLocation"
+    ></routeInfo-getpoint> 
     <el-dialog
       title="导入"
       :visible.sync="batchImportVisible"
@@ -322,23 +269,16 @@
 import Constant from "@/constant";
 import routeInfoApi from "@/api/bus/routeInfo";
 import SelectTree from "@/components/SelectTree";
+import RouteInfoGetPoint from "./routeInfo-getpoint";
 import companyInfoApi from "@/api/bus/companyInfo";
 import dataDictionaryApi from "@/api/sys/dataDictionary";
 import regionInfoApi from "@/api/base/regionInfo";
-
-import greenIcon from "@/assets/icons/green.svg";
-import redIcon from "@/assets/icons/red.svg";
-
 import { getToken } from "@/utils/auth"; // get token from cookie
 
-import AMap from "vue-amap";
-let amapManager = new AMap.AMapManager();
-
 export default {
   props: ["businessKey", "title"],
   data() {
     return {
-      plugins: ["AMap.Scale", "AMap.OverView", "AMap.ToolBar", "AMap.MapType","AMap.RangingTool"],
       formModel: {
         enableChangeParent: false,
         id: "",
@@ -348,7 +288,6 @@ export default {
         stationList: [],
         removeStationList: []
       },
-      stationSubInfoList: [],
       ruleValidate: {
         companyId: [
           { required: true, message: "所属单位不能为空", trigger: "blur" },
@@ -385,27 +324,7 @@ export default {
       typeData: [],
       treeData: [],
       selectedRow: {},
-      pointPosition: [112.240222, 30.337053],
       showMapDialog: false,
-      amapManager,
-      zoom: 12,
-      mapRuler: {},
-      ranging: false,
-      events: {
-        init: (map)=>{
-          const ruler = new window.AMap.RangingTool(map);
-          this.mapRuler = ruler
-        },
-        click: (e) => {
-          if(!this.ranging){
-            var pt = e.lnglat; //点击选择新地址为中心点
-            console.log(pt);
-
-            this.pointPosition = [pt.lng, pt.lat];
-            this.selectedRow.location = pt.lng + "," + pt.lat;
-          }
-        }
-      },
       props: {
         // 配置项(必选)
         value: "id",
@@ -448,14 +367,6 @@ export default {
     });
   },
   methods: {
-    rangingChange(value) {
-      if(value){
-        this.mapRuler.turnOn();
-      }
-      else{
-        this.mapRuler.turnOff();
-      }
-    },
     closeDialog() {
       this.$emit("close", false);
     },
@@ -480,12 +391,16 @@ export default {
               self.formModel.stationList[i].sortNo = i+1;
             }
 
+            self.loading = true;
+
             if (id == null || id.length == 0) {
               return routeInfoApi.add(self.formModel);
             } else {
               return routeInfoApi.update(self.formModel);
             }
           })().then(function (response) {
+            self.loading = false;
+
             var jsonData = response.data;
 
             if (jsonData.result) {
@@ -526,29 +441,9 @@ export default {
       return isJPG && isLt2M;
     },
     handleLocation(row) {
-      this.selectedRow = row;
       this.showMapDialog = true;
-
-      if (row.location != null && row.location.length > 0) {
-        var arr = row.location.split(",");
-
-        this.pointPosition = arr;
-      }
-
-      if(row.stationSubInfoList!=null){
-        this.stationSubInfoList = [];
-
-        row.stationSubInfoList.forEach(subItem=>{
-            var startToEnd = subItem.startStationId == this.formModel.stationList[0].id;
-
-            this.stationSubInfoList.push({
-                id: subItem.id,
-                title: row.name + "入口" + (startToEnd ? "(起)" : "(终)"),
-                position: [subItem.longitude,subItem.latitude],
-                icon: startToEnd ? greenIcon : redIcon
-            });
-        });
-      }
+      this.selectedRow = row;
+      this.$refs.getpoint.showPoint(row);
     },
     handleAdd() {
       this.formModel.stationList.push({
@@ -575,19 +470,6 @@ export default {
         });
       }
     },
-    handleRegeo() {
-      var row = this.selectedRow;
-
-      if (row.location != null && row.location.length > 0) {
-        var arr = row.location.split(",");
-        this.pointPosition = arr;
-      }
-    },
-    handleSelectPoint() {
-      this.selectedRow.location =
-        this.pointPosition[0] + "," + this.pointPosition[1];
-      this.showMapDialog = false;
-    },
     handleDelete(row) {
       var stationList = this.formModel.stationList;
 
@@ -691,9 +573,39 @@ export default {
           self.$message.error(error + "");
         });
     },
+    handleChangeLocation(points) {
+      console.log(points);
+
+      if(this.selectedRow!=null){
+        points.forEach(pt=>{
+
+          if(pt.type=="station"){
+            this.selectedRow.location = pt.location;
+          }
+          else{
+            var list = this.selectedRow.stationSubInfoList;
+
+            if(list!=null){
+              for(var i=0;i<list.length;i++){
+                var subItem = list[i];
+
+                if(subItem.id == pt.id){
+                  console.log(subItem);
+
+                  subItem.longitude = pt.position[0];
+                  subItem.latitude = pt.position[1];
+                  break;
+                }
+              }
+            }
+          }
+        });
+      }
+    }
   },
   components: {
     "el-select-tree": SelectTree,
+    "routeInfo-getpoint": RouteInfoGetPoint
   },
   mounted: function () {
     var self = this;

+ 227 - 0
src/views/bus/routeInfo-getpoint.vue

@@ -0,0 +1,227 @@
+<template>
+  <el-dialog
+      :visible.sync="innerVisible"
+      title="地图选点"
+      :modal-append-to-body="true"
+      :append-to-body="true"
+      style="text-align: left"
+      width="905px"
+      top="5vh"
+      :close-on-click-modal="false"
+    >
+      <el-amap
+        ref="stationMap"
+        vid="stationMap"
+        :amap-manager="amapManager"
+        :center="pointPosition"
+        :zoom="zoom"
+        :events="events"
+        class="amap-demo"
+        :plugin="plugins"
+        style="width: 100%; height: 500px"
+      >
+        <!--站点及入口-->
+        <el-amap-marker
+          :zIndex="1"
+          v-for="point in points"
+          :key="point.id"
+          :position="point.position"
+          :title="point.title"
+          :icon="point.icon"
+          :events="markerEvents"
+          :extData="point"
+        ></el-amap-marker>
+      </el-amap>
+      <span slot="footer" class="dialog-footer">
+        <div style="position: absolute; left: 20px; bottom: 20px">
+          <el-select size="mini" v-model="selectedValue" @change="pointChange">
+              <el-option
+                v-for="point in points"
+                :key="point.id"
+                :label="point.title"
+                :value="point.id">
+            </el-option>
+          </el-select>
+          <el-input
+            placeholder="当前经纬度"
+            v-model="selectedPoint.location"
+            style="width: 320px"
+            size="mini"
+          >
+            <template slot="prepend">经纬度</template>
+            <el-button slot="append" icon="el-icon-search" @click="handleRegeo" size="mini">定位</el-button>
+          </el-input>
+          <el-switch
+            size="mini"
+            v-model="ranging"
+            @change="rangingChange"
+            active-text="开启测距"
+            inactive-text="关闭测距">
+          </el-switch>
+        </div>
+        <el-button @click="cancel()">取 消</el-button>
+        <el-button type="primary" @click="handleSelectPoint()">确 定</el-button>
+      </span>
+    </el-dialog>
+</template>
+<script>
+import Constant from "@/constant";
+import routeInfoApi from "@/api/bus/routeInfo";
+import SelectTree from "@/components/SelectTree";
+import companyInfoApi from "@/api/bus/companyInfo";
+import dataDictionaryApi from "@/api/sys/dataDictionary";
+import regionInfoApi from "@/api/base/regionInfo";
+
+import greenIcon from "@/assets/icons/green.svg";
+import redIcon from "@/assets/icons/red.svg";
+import stationIcon from "@/assets/icons/station.svg";
+
+import AMap from "vue-amap";
+let amapManager = new AMap.AMapManager();
+
+
+export default {
+    props: ["visible"],
+    computed: {
+        innerVisible: {
+            get: function() {
+                return this.visible
+            },
+            set: function(val) {
+                this.$emit('update:visible', val)
+            }
+        }
+    },
+    data() {
+        return {
+            points: [],
+            selectedValue: "",
+            selectedPoint: {},
+            station: {},
+            plugins: ["AMap.Scale", "AMap.OverView", "AMap.ToolBar", "AMap.MapType","AMap.RangingTool"],
+            pointPosition: [112.240222, 30.337053],
+            amapManager,
+            zoom: 12,
+            mapRuler: {},
+            ranging: false,
+            events: {
+                init: (map)=>{
+                const ruler = new window.AMap.RangingTool(map);
+                this.mapRuler = ruler
+                },
+                click: (e) => {
+                    console.log(e);
+
+                    if(!this.ranging){
+                        var pt = e.lnglat; //点击选择新地址为中心点
+                        console.log(pt);
+
+                        this.pointPosition = [pt.lng, pt.lat];
+
+                        if(this.selectedPoint!=null){
+                            this.selectedPoint.position = [pt.lng,pt.lat];
+                            this.selectedPoint.location = pt.lng + "," + pt.lat;
+                        }
+                    }
+                }
+            },
+            markerEvents: {
+                click: (e) => {
+                    var point = e.target.w.extData;
+                    this.selectedValue = point.id;
+
+                    this.pointChange(this.selectedValue);
+                }
+            }
+        }
+    },
+    methods: {
+        cancel() {
+            this.$emit("update:visible", false);
+        },
+        rangingChange(value) {
+            if(value){
+                this.mapRuler.turnOn();
+            }
+            else{
+                this.mapRuler.turnOff();
+            }
+        },
+        showPoint(row) {
+            this.station = row;
+
+            this.points = [];
+
+            if (row.location != null && row.location.length > 0) {
+                var arr = row.location.split(",");
+                this.pointPosition = arr;
+
+                this.points.push({
+                    id: row.id,
+                    type: "station",
+                    title: row.name,
+                    position: arr,
+                    icon: stationIcon,
+                    location: row.location
+                });
+            }
+            else{
+                this.points.push({
+                    id: row.id,
+                    type: "station",
+                    title: row.name,
+                    position: this.pointPosition,
+                    icon: stationIcon,
+                    location: this.pointPosition[0] + "," + this.pointPosition[1]
+                });
+            }
+
+            this.selectedValue = row.id;
+            this.selectedPoint = this.points[0];
+
+            if(row.stationSubInfoList!=null){
+                row.stationSubInfoList.forEach(subItem=>{
+                    var frontToEnd = subItem.direction=="1";
+
+                    this.points.push({
+                        id: subItem.id,
+                        type: "sub",
+                        title: row.name + "入口" + (frontToEnd ? "(起)" : "(终)"),
+                        position: [subItem.longitude,subItem.latitude],
+                        icon: frontToEnd ? greenIcon : redIcon,
+                        location: subItem.longitude + ',' + subItem.latitude
+                    });
+                });
+            }
+        },
+        handleRegeo() {
+            var row = this.selectedPoint;
+
+            if (row.location != null && row.location.length > 0) {
+                var arr = row.location.split(",");
+                row.position = arr;
+                
+                this.pointPosition = arr;
+            }
+        },
+        handleSelectPoint() {
+            //返回修改的站点及经纬度
+            this.$emit("yes", this.points);
+            this.$emit("update:visible", false);
+        },
+        pointChange(val) {
+            console.log(val);
+
+            for(var i=0;i<this.points.length;i++){
+                if(this.points[i].id == val){
+                    this.selectedPoint = this.points[i];
+                    break;
+                }
+            }
+        }
+    }
+}
+</script>
+<style>
+
+</style>

+ 1 - 2
src/views/bus/routeInfo-list.vue

@@ -92,7 +92,6 @@
       <el-table-column
         prop="name"
         label="路线名称"
-        width="150"
       ></el-table-column>
       <el-table-column
         prop="regionName"
@@ -114,7 +113,7 @@
         label="间隔时间(分钟)"
         width="120"
       ></el-table-column>
-      <el-table-column label="操作">
+      <el-table-column label="操作" width="400">
         <template slot-scope="{ row }">
           <el-button size="mini" type="warning" @click="handleEdit(row)"
             >编辑</el-button

+ 1 - 1
src/views/bus/shiftInfo-map.vue

@@ -155,7 +155,7 @@ export default {
 
                             if(item.stationSubInfoList!=null){
                                 item.stationSubInfoList.forEach(subItem=>{
-                                    var startToEnd = subItem.startStationId == this.stationList[0].id;
+                                    var startToEnd = subItem.direction=="1";
 
                                     this.stationList.push({
                                         id: subItem.id,

+ 2 - 4
src/views/bus/vehicleHistory-list.vue

@@ -258,13 +258,11 @@ export default {
 
                         if(item.stationSubInfoList!=null){
                             item.stationSubInfoList.forEach(subItem=>{
-                                var startToEnd = subItem.startStationId == this.stationList[0].id;
-
                                 this.stationList.push({
                                     id: subItem.id,
-                                    title: item.name + "入口" + (startToEnd ? "(起)" : "(终)"),
+                                    title: item.name + "入口" + (subItem.direction=="1" ? "(起)" : "(终)"),
                                     position: [subItem.longitude,subItem.latitude],
-                                    icon: startToEnd ? greenIcon : redIcon
+                                    icon: subItem.direction=="1" ? greenIcon : redIcon
                                 });
                             });
                         }