quanyawei
2023-11-08 3636d6f572a8aaf43af90ba9839a8fa5370eba10
src/views/list/road.vue
@@ -2,17 +2,10 @@
  <div style="display: flex; overflow: hidden">
    <div class="left">
      <div class="left-one">
        <a-range-picker
          v-model="timevalue"
          show-time
          @ok="change1()"
          valueFormat="yyyy-MM-DD HH:MM:SS"
          style="width: 175px"
        />
        <a-select
          ref="select"
          v-model="carvalue"
          style="width: 180px; margin-left: 10px"
          style="width: 180px"
          placeholder="请选择走航车"
        >
          <a-select-option
@@ -22,6 +15,13 @@
            >{{ item.name }}</a-select-option
          >
        </a-select>
        <a-range-picker
          :show-time="{ format: 'HH:mm' }"
          @ok="change1"
          format="YYYY-MM-DD HH:mm"
          style="width: 175px; margin-left: 10px"
        />
        <a-button type="primary" style="margin-left: 10px" @click="selectCar"
          >查询</a-button
        >
@@ -167,8 +167,8 @@
import axios from "axios";
import { jsonp }  from 'vue-jsonp'
import any = jasmine.any;
import { da } from "date-fns/locale";
import {Moment} from 'moment';
@Component({
  components: {
    
@@ -176,12 +176,32 @@
})
export default class road extends Vue {
  private timevalue:any=[]
  private change1(){
    console.log(this.timevalue);
  private change1(dates: Moment[]) {
   this.timevalue=[]
   this.timevalue=[dates[0].format("YYYY-MM-DD HH:mm"),dates[1].format("YYYY-MM-DD HH:mm")]
  }
   private  mounted() {
    this.roadmap();
  }
  private dateFormat(fmt: string, date: any) {
   let o = {
      "M+": date.getMonth() + 1,                 //月份
      "d+": date.getDate(),                    //日
      "h+": date.getHours(),                   //小时
      "m+": date.getMinutes(),                 //分
      "s+": date.getSeconds(),                 //秒
      "q+": Math.floor((date.getMonth() + 3) / 3), //季度
      "S": date.getMilliseconds()             //毫秒
   }
    if (/(y+)/.test(fmt))
      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
   for (var k in o)
      if (new RegExp("(" + k + ")").test(fmt))
         fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
   return fmt
}
  private map:any
  private roadmap(){
      this.map = new BMapGL.Map('roadmap')
@@ -199,12 +219,22 @@
  private tableLoading: boolean = false;
  private columns: any[] = [
    {
      title: "序号",
      dataIndex: "key",
      key: "key",
      align: "center",
      customRender: (text,record,index) => `${index+1}`,
      width: 60,
    },
    {
      title: "路段名称",
      dataIndex: "startPoint"
      dataIndex: "startPoint",
       align: "center",
    },
    {
      title: "操作",
      customRender: this.opRender
      customRender: this.opRender,
       align: "center",
    }
  ];
  private openIn(){
@@ -272,11 +302,11 @@
    this.check=false
    this.startstate='batch'
    this.batchshow=true
    this.selectCar();
    // this.selectCar();
    this.batchid=record.coordinateId
  }
  private handlebatch(){
    this.selectCar()
    // this.selectCar()
    this.batchshow=false
    this.handlenull();
  }
@@ -295,15 +325,17 @@
      this.$message.success(res.data.message)
      this.starttime=''
      this.endtime=''
      this.selectCar()
      // this.selectCar()
    }))
  }
  private upa=''
  private recordid:any=0
  private handleEditModalVisible(record){
  private handleEditModalVisible(record) {
    console.log('dataList',this.dataList)
    this.check=false
    this.handlebatch()
    this.startstate='none'
    this.startstate = 'none'
    this.dataList=[]
    this.upa='upa'
    this.recordid=record.coordinateId
    if(this.carvalue==='请选择走航车'){
@@ -332,7 +364,6 @@
      coordinateId:this.recordid,
      data:this.dataList
    }).then((res)=>{
      console.log(res);
      this.$message.success(res.data.message)
      this.upa=''
      this.dataList=[]
@@ -342,7 +373,7 @@
  }
  private inupa(){
    this.upa=''
    this.selectCar()
    // this.selectCar()
  }
  private carvalue:any='请选择走航车'
  private carIndex:any=[]
@@ -395,6 +426,7 @@
      this.$message.warning('请选择时间')
      return
    }
    console.log("this.timevalue",this.timevalue);
    get('cruiserInfo/getCruiserInFo',{
      mac:this.carvalue,
      // time1:'2023-08-05 00:00:00',
@@ -417,8 +449,9 @@
  private carDataList:any=[]
  private starttime:any=''
  private endtime:any=''
  private InfoWindow = null
  private startstate:any='none'
  private  setMarker(res) {
  private setMarker(res) {
    const that=this
     that.carDate=[]
     that.carDataList=[]
@@ -436,17 +469,44 @@
          //创建单个point
          var myIcon = new BMapGL.Icon(require("@/assets/723cd95f31481a502d495b2d814d658.png"), new BMapGL.Size(50, 50), {
            });
          var startIcon = new BMapGL.Icon(require("@/assets/start.png"), new BMapGL.Size(50, 50), {
            });
          var endIcon = new BMapGL.Icon(require("@/assets/end.png"), new BMapGL.Size(50, 50), {
            });
          const statePoint = new BMapGL.Point(that.carDate[i].flylon,that.carDate[i].flylat);
          bPoints.push(statePoint)
          that.marker[i] = new BMapGL.Marker(statePoint,{icon:myIcon});
          that.marker[i].customData = {data: that.carDate[i].data,state: that.carDate[i].state};
          if (i === 0) {
            that.marker[i] = new BMapGL.Marker(statePoint, { icon: startIcon });
            that.marker[i].customData = { data: that.carDate[i].data, state: that.carDate[i].state };
            that.marker[i].iconPng='startIcon'
          } else if (i === that.carDate.length - 1) {
            that.marker[i] = new BMapGL.Marker(statePoint, { icon: endIcon });
            that.marker[i].customData = { data: that.carDate[i].data, state: that.carDate[i].state };
            that.marker[i].iconPng='endIcon'
          } else {
            that.marker[i] = new BMapGL.Marker(statePoint,{icon:myIcon});
            that.marker[i].customData = { data: that.carDate[i].data, state: that.carDate[i].state };
            that.marker[i].iconPng='myIcon'
          }
          var infoWindow ='';
          //that.marker[i].name = that.carDate[i].time;
          that.marker[i].on('mouseover', function (e) {
            infoWindow = new BMapGL.InfoWindow("当前时间:"+that.carDate[i].time);
             that.map.openInfoWindow(infoWindow, statePoint);
          })
         that.marker[i].on('mouseout', function (e) {
             that.map.closeInfoWindow(infoWindow, statePoint);
          })
         // that.marker.setTitle(that.carDate[i].time);
          //在地图中添加marker
          that.map.addOverlay(that.marker[i]);
          // if(that.check===false){
          that.marker[i].addEventListener("click",function(){
          console.log(that.carDate[i].data,'that.carDate[i].data');
            switch(that.carDate[i].state){
              case '1':
                console.log('that.marker',that.marker[i])
                  that.marker[i].setIcon(new BMapGL.Icon(require("@/assets/fb259ce2e368f6853a58b91d6f6b293.png"), new BMapGL.Size(50, 50)
              ));
                that.carDate[i].state='2'
@@ -486,6 +546,7 @@
        // }
      }
        for (let i = 0; i < that.carDataList.length; i++) {
          // console.log(that.carDataList[i],'that.carDataList[i]');
          //创建单个point
@@ -539,6 +600,7 @@
        }
      }
    }
    private setZoom(bPoints) {
      var view = this.map.getViewport(eval(bPoints));
      var mapZoom = view.zoom;
@@ -547,12 +609,17 @@
    }
  private selectLuName:any=null
    private selectLu(){
      var macType = null
      if(this.carvalue!=='请选择走航车'){
        macType = this.carvalue;
      }
      get('coordinate/selectCruiserRoad',{
        name:this.selectLuName
        name:this.selectLuName,
        mac:macType
      }).then((res)=>{
        this.dataSource=res.data.data
      })
    }
  }
  private created () {
    this.car()  
    this.selectLu()