guoshipeng
2023-05-11 4174c82fa3ef8c2218cb3b7425fb4c57e681fe50
src/views/car/index.vue
@@ -136,7 +136,7 @@
                上传走航轨迹图片(可选可不选)
              </div>
            </el-upload>
            <div style="display: flex">
            <!-- <div style="display: flex">
              <span class="statspan">开始点的时间:</span
              ><el-input v-model="startL" style="width: 12rem"></el-input>
            </div>
@@ -154,6 +154,30 @@
            <div style="display: flex; margin-left: 4rem">
              <el-button type="primary" @click="insLuDuan">保存</el-button>
              <el-button @click="insqu">取消</el-button>
              <el-button @click="qnull">清空</el-button>
            </div> -->
            <el-table :data="tableData" style="width: 100%">
              <el-table-column label="开始时间" width="180">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.start }}</span>
                </template>
              </el-table-column>
              <el-table-column label="结束时间" width="180">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.end }}</span>
                </template>
              </el-table-column>
            </el-table>
            <div style="display: flex">
              <span class="statspan">路段名称:</span
              ><el-input
                v-model="Lname"
                style="width: 12rem; margin-left: 1.7rem"
              ></el-input>
            </div>
            <div style="display: flex; margin-left: 4rem">
              <el-button type="primary" @click="insLuDuan">保存</el-button>
              <el-button @click="insqu">关闭</el-button>
              <el-button @click="qnull">清空</el-button>
            </div>
          </div>
@@ -464,6 +488,7 @@
  components: { index },
  data() {
    return {
      tableData: [],
      fileList: [],
      file: '',
      insdialogVisible: false,
@@ -593,42 +618,42 @@
        {
          sensorName: 'SO2',
          unit: 'ug/m³',
          tab1: '50',
          tab2: '150',
          tab3: '475',
          tab1: '150',
          tab2: '500',
          tab3: '650',
          tab4: '800',
          tab5: '1600',
          tab6: '2100',
          tab5: '',
          tab6: '',
        },
        {
          sensorName: 'NO2',
          unit: 'ug/m³',
          tab1: '40',
          tab2: '80',
          tab3: '180',
          tab4: '280',
          tab5: '565',
          tab6: '750',
          tab1: '100',
          tab2: '200',
          tab3: '700',
          tab4: '1200',
          tab5: '2340',
          tab6: '3090',
        },
        {
          sensorName: 'CO',
          unit: 'mg/m³',
          tab1: '2',
          tab2: '4',
          tab3: '14',
          tab4: '24',
          tab5: '36',
          tab6: '48',
          tab1: '5',
          tab2: '10',
          tab3: '35',
          tab4: '60',
          tab5: '90',
          tab6: '120',
        },
        {
          sensorName: 'O3',
          unit: 'ug/m³',
          tab1: '100',
          tab2: '160',
          tab3: '215',
          tab4: '265',
          tab1: '160',
          tab2: '200',
          tab3: '300',
          tab4: '400',
          tab5: '800',
          tab6: '800',
          tab6: '1000',
        },
        {
          sensorName: 'TVOC',
@@ -688,6 +713,7 @@
      endTime: '',
      dataDate: '',
      sensorTime: [],
      Lu: [],
      startL: '',
      Lname: '',
      endL: '',
@@ -764,40 +790,64 @@
    handleChange(file, fileList) {
      var str = file.name //截取后4位
      let a = str.substring(str.length - 3)
      console.log(a)
      // console.log(a)
      if (a === 'png') {
        this.file = file
        this.file = file.raw
        console.log(this.file.raw)
        this.fileList = fileList
      }else{
      } else {
        this.$message('请插入png格式的图片')
      }
      // console.log(file.name, 'file')
    },
    insLuDuan() {
      if (this.startL == '') {
        this.$message({
          message: '请点击开始时间',
          type: 'warning',
        })
        return false
      } else if (this.endL == '') {
        this.$message({
          message: '请点击结束时间',
          type: 'warning',
        })
        return false
      } else if (this.Lname == '') {
      // if (this.startL == '') {
      //   this.$message({
      //     message: '请点击开始时间',
      //     type: 'warning',
      //   })
      //   return false
      // } else if (this.endL == '') {
      //   this.$message({
      //     message: '请点击结束时间',
      //     type: 'warning',
      //   })
      //   return false
      // } else
      if (this.Lname == '') {
        this.$message({
          message: '请输入路段名',
          type: 'warning',
        })
        return false
      }
      if (this.tableData.length === 0) {
        this.$message({
          message: '请点击时间',
          type: 'warning',
        })
        // console.log(1);
        return false
      }
      // console.log(this.tableData);
      var times = this.newTime2(this.dateValue)
      const formData = new FormData()
      formData.append(`time1`, this.startL)
      formData.append(`time2`, this.endL)
      let pv = JSON.stringify(this.tableData)
      // let big = {
      //   table: pv,
      //   road: this.Lname,
      //   time3: times[0],
      //   time4: times[1],
      //   mac: this.carMac,
      //   files: this.file,
      // }
      // console.log(big)
      // console.log(pv);
      // formData.append(`time1`, this.startL)
      // formData.append(`time2`, this.endL)
      formData.append(`table`, pv)
      formData.append(`road`, this.Lname)
      formData.append(`time3`, times[0])
      formData.append(`time4`, times[1])
@@ -817,26 +867,10 @@
            message: '添加路段成功',
            type: 'success',
          })
          this.startL = ''
          this.endL = ''
          this.tableData = []
          this.Lname = ''
        }
      })
      // this.$request({
      //   url:'',
      //   method:'post',
      //   data:{
      //     starttime:this.startL,
      //     endtime:this.endL,
      //     name:this.Lname,
      //     mac:this.carMac,
      //     sTime:times[0],
      //     eTime:times[1],
      //     img:this.file.raw
      //   }
      // }).then((res)=>{
      //   console.log(res);
      // })
    },
    //添加弹框
@@ -848,8 +882,9 @@
      this.qnull()
    },
    qnull() {
      this.startL = ''
      this.endL = ''
      // this.startL = ''
      // this.endL = ''
      this.tableData = []
      this.Lname = ''
    },
    // 时间处理函数
@@ -1206,18 +1241,34 @@
              point.a21005 = parseFloat(value.a21005).toFixed(3)
              point.a05024 = parseInt(value.a05024)
              point.a99054 = parseFloat(value.a99054).toFixed(3)
              if (
                value.dustld - 0 !== 0 &&
                value.dustld - 0 < 100 &&
                (that.carMac === 'p5dnd7a0243622' ||
                  that.carMac === 'p5dnd7a0243625')
              ) {
                point.dustld = 100
              } else {
                point.dustld = value.dustld - 0
              }
            //   if (
            //     value.dustld - 0 !== 0 &&
            //     value.dustld - 0 < 150 &&
            //     (that.carMac === 'p5dnd7a0243622' ||
            //       that.carMac === 'p5dnd7a0243625')
            //   ) {
            //     point.dustld = 200
            //   } else if (
            //     value.dustld - 0 !== 0 &&
            //     value.dustld - 0 >= 150 &&
            //     value.dustld - 0 <= 180 &&
            //     (that.carMac === 'p5dnd7a0243622' ||
            //       that.carMac === 'p5dnd7a0243625')
            //   ) {
            //     point.dustld = 220
            //   } else if (
            //     value.dustld - 0 !== 0 &&
            //     value.dustld - 0 > 180 &&
            //     value.dustld - 0 <= 200 &&
            //     (that.carMac === 'p5dnd7a0243622' ||
            //       that.carMac === 'p5dnd7a0243625')
            //   ) {
            //     point.dustld = 230
            //   } else {
            //     point.dustld = value.dustld - 0
            //   }
            }
            // point.dustld = value.dustld - 0
            point.dustld = value.dustld - 0
            point.times = value.time
            trackPoints.push(point)
          }
@@ -1384,8 +1435,11 @@
              flag = false
            }
          }
          points.push(point1)
          console.log(points,'num');
          if (flag) {
            points.push(point1)
            // console.log(points,'num');
          }
        }
@@ -1773,22 +1827,50 @@
          fontWeight: 'bold',
        }
        label.addEventListener('click', (e) => {
          console.log(e)
          // console.log(e)
          // var ps = e.target.latLng.lat
          // var ps1 = e.target.latLng.lng
          // var p1 = new BMap.Point(ps1, ps);
          // var marker = new BMap.Marker(p1);;
          // that.map.addOverlay(marker);
          var times = e.target.domElement.children[0].getAttribute('data-times')
          console.log(times)
          // console.log(times)
          if (that.startL == '') {
            that.startL = times
            // that.Lu.startLu.push(that.startL)
            // console.log(that.Lu.startLu, 'start')
          } else {
            // that.tableData=[]
            that.endL = times
            comparedate(that.startL, that.endL)
            // var endLu = []
            // that.Lu.endLu.push(that.endL)
            // console.log(that.Lu.endLu, 'end')
            // that.startL = ''
            // that.endL = ''
            // that.tableData.push(that.Lu)
            // console.log(that.tableData, 'table')
          }
        })
        label.setStyle(labelStyle)
        that.map.addOverlay(label)
      }
      //比较两个日期的大小
      function comparedate(date1, date2) {
        let oDate1 = new Date(date1)
        let oDate2 = new Date(date2)
        if (oDate1.getTime() > oDate2.getTime()) {
          that.startL = ''
          that.endL = ''
          that.$message('请重新选择,开始时间需小于结束时间')
          return false
        } else if (oDate1.getTime() < oDate2.getTime()) {
          var cardNumObj = { start: that.startL, end: that.endL }
          that.tableData.push(cardNumObj)
          console.log(that.tableData, 'that.tableData')
          that.startL = ''
          that.endL = ''
        }
      }
      // 无数据时,缩放至该中心
@@ -2072,7 +2154,7 @@
  border: 1px solid white;
  background-color: white;
  width: 20rem;
  height: 23rem;
  height: 30rem;
  position: absolute;
  top: 3rem;
  left: 1rem;
@@ -2088,4 +2170,3 @@
  margin-top: 0.8rem;
}
</style>