quanyawei
2024-09-12 9251f709dc2a0d278ef2c0cdd76a244bfefc5784
src/views/car/index.vue
@@ -1,184 +1,377 @@
<template>
  <div class="main_body">
    <el-container
        style="height: 100%"
    >
    <el-container style="height: 100%">
      <el-aside
          v-if="this.$store.state.aside"
          width="300px"
          style="background-color: rgb(238, 241, 246);padding-top:10px"
        v-if="$store.state.aside"
        width="300px"
        style="background-color: rgb(238, 241, 246); padding-top: 10px"
      >
        <span style="font-size:13px;padding-left:10px;font-weight:500;color:rgb(64, 158, 255)">走航车设备</span>
        <el-menu style="margin-top:10px">
        <span
          style="
            font-size: 13px;
            padding-left: 10px;
            font-weight: 500;
            color: rgb(64, 158, 255);
          "
        >走航车设备</span>
        <el-menu style="margin-top: 10px">
          <el-menu-item
              v-for="(item,index) in defaultData"
              :key="index"
              style="display: flex;justify-content: space-between;align-items: center;padding-right: 0;border-bottom:1px solid #eee"
              :index="(index+1 + '-' + index + 1).toString()"
              @click="changeCarData(item)"
            v-for="(item, index) in defaultData"
            :key="index"
            style="
              display: flex;
              justify-content: space-between;
              align-items: center;
              padding-right: 0;
              border-bottom: 1px solid #eee;
            "
            :index="(index + 1 + '-' + index + 1).toString()"
            @click="changeCarData(item)"
          >
            <span>{{ item.name }}</span>
            <i
                style="vertical-align: -2.5px;font-size: 20px;margin-right:10px;margin-left:auto"
                class="iconfont iconfaxianzuobiao"
                @click="deviceDetail(item.mac,null,item,0)"
              style="
                vertical-align: -2.5px;
                font-size: 20px;
                margin-right: 10px;
                margin-left: auto;
              "
              class="iconfont iconfaxianzuobiao"
              @click="deviceDetail(item.mac, null, item, 0)"
            />
            <!--            @click="deviceDetail('p5dnd7a0245390',null,item,0)"-->
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-dialog />
      <el-container style="position: relative">
        <div class="carTop">
          <span style="float:left;margin: 1px 10px 0 0;">
            <el-button size="medium" type="primary" icon="el-icon-setting" @click="dialogFormVisible = true">6参设定</el-button>
          </span>
          <span
        <div class="faterCar">
          <div class="carTop">
            <span
              v-for="(item, index) in snesorParams"
              :key="index"
              class="left"
              :class="{ click: changeColor == index }"
              @click="changeCode(index)"
          >{{ item }}
          </span>
          <span
              v-for="(item,index) in viewOptions"
              :key="index+ '-only'"
            >{{ item }}
            </span>
            <span style="margin-left: 10px">
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-setting"
                @click="dialogFormVisible = true"
              >6参设定</el-button>
            </span>
            <span
              v-for="(item, index) in viewOptions"
              :key="index + '-only'"
              class="right"
              :class="{ click: changeColor1 == index }"
              @click="changeCode1(index)"
          >{{ item }}
          </span>
          <span v-if="webSocketView" style="float:right;margin: 2px 10px 0 0;">
            <el-button size="medium" type="primary" @click="wsStart()">开启实时</el-button>
          </span>
          <!--           <el-date-picker
                      v-if="historyView"
                      v-model="dateValue"
                      value-format="yyyy-MM-dd"
                      style="float:right;margin-right: 10px;line-height: 40px;"
                      align="right"
                      type="date"
                      placeholder="选择日期"
                      :picker-options="pickerOptions"
                      @change="dateChange"
                    />-->
          <!-- 选择时间段 -->
          <!--          <el-time-picker-->
          <!--              :disabled="isDisTime"-->
          <!--              style="float:right;width: 210px"-->
          <!--              is-range-->
          <!--              v-model="timeValue"-->
          <!--              @blur="blurChange"-->
          <!--              range-separator="至"-->
          <!--              start-placeholder="开始时间"-->
          <!--              end-placeholder="结束时间"-->
          <!--              placeholder="选择时间范围">-->
          <!--          </el-time-picker>-->
          <!-- 历史日期选择下拉框 -->
          <!--          <el-select v-if="historyView" v-model="dateValue" placeholder="选择日期" style="float:right;line-height:40px;margin-right:10px;width:140px" @change="dateChange">-->
          <!--            <el-option-->
          <!--              v-for="item in isDataList"-->
          <!--              :key="item.value"-->
          <!--              :label="item.label"-->
          <!--              :value="item.value"-->
          <!--              @click.native="dataChangeClick"-->
          <!--            />-->
          <!--          </el-select>-->
          <el-date-picker
              style="float:right;margin-right:10px;"
              @change="dateChange"
            >{{ item }}
            </span>
            <span
              v-if="webSocketView"
              style="margin: 2px 10px 0 0"
            >
              <el-button
                size="mini"
                type="primary"
                @click="wsStart()"
              >开启实时</el-button>
            </span>
            <el-button
              size="mini"
              type="primary"
              @click="insertL"
            >
              添加
            </el-button>
            <el-input
              v-model="inputnum"
              size="mini"
              placeholder="请输入内容"
              class="inputNum"
              clearable
            />
            <div class="insLu">
              <el-upload
                ref="upload"
                class="upload-demo"
                action=""
                :on-change="handleChange"
                :on-remove="handleRemove"
                :file-list="fileList"
                :auto-upload="false"
                :limit="1"
              >
                <el-button
                  slot="trigger"
                  size="small"
                  type="primary"
                >
                  选取文件
                </el-button>
                <div
                  slot="tip"
                  class="el-upload__tip"
                  style="color: red"
                >
                  上传走航轨迹图片(可选可不选)
                </div>
              </el-upload>
              <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"
                />
              </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>
            <el-date-picker
              v-model="dateValue"
              size="mini"
              style=" margin-right: 10px"
              type="datetimerange"
              :picker-options="threeOptions"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
          </el-date-picker>
          <!-- 历史/实时切换下拉框 -->
          <el-select v-model="dataTypeValue" placeholder="数据类型" style="float:right;line-height:40px;margin-right:10px;width:103px">
            <el-option
              end-placeholder="结束日期"
              @change="dateChange"
            />
            <!-- 历史/实时切换下拉框 -->
            <el-select
              v-model="dataTypeValue"
              size="mini"
              placeholder="数据类型"
              style="
              line-height: 40px;
              margin-right: 10px;
              width: 103px;
            "
            >
              <el-option
                v-for="item in dataTypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
          </el-select>
              />
            </el-select>
          </div>
          <div
            v-if="!rankListShow & noneDustldData"
            class="rightIcon"
            @click="showRankList"
          >
            <i class="el-icon-s-fold" />
          </div>
        </div>
        <div v-if="noneData" class="noneData">当前时间没有走航数据</div>
        <div id="map_container" v-loading="loading" /> <!-- 百度地图 -->
        <div
          v-if="noneData"
          class="noneData"
        >
          当前时间没有走航数据
        </div>
        <div
          id="map_container"
          v-loading="loading"
        />
        <!-- 百度地图 -->
      </el-container>
    </el-container>
    <!-- <div id="selectSenor">
      <span><input type="radio" value="a34004" name="sensor" checked>PM2.5</span>
      <span><input type="radio" value="a34002" name="sensor">PM10</span>
      <span><input type="radio" value="a99054" name="sensor">TVOC</span>
    <div
      v-if="rankListShow"
      style="position: absolute;
      right: 0;
      top: 45px;
      }"
    >
      <!--                -->
      <div
        style="position: relative"
        class="rankCar"
      >
        <div
          class="success-checkmark"
          @click="showRankList"
        />
        <div>
          <p>排名列表</p>
          <ul>
            <li
              v-for="(item, index) in rankList"
              :key="index"
            >
              <div class="rankCarItem">
                <div> {{ index+1 }}. {{ item.road }}</div>
                <div style="margin-left: 10px">
                  {{ item.avg }}
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div id="type">
      <input type="radio" value="2D" name="v" checked>2D
      <input type="radio" value="3D" name="v">3D
    </div> -->
    <!-- <img src="/img/pollutionlevel.png" class="sensorLevel">
    <div id="cpm">查无走航车轨迹</div> -->
    <!-- 6参设定弹窗 -->
    <el-dialog title="6参设定" :visible.sync="dialogFormVisible" width="1000px">
      <el-descriptions title="国控6参" :column="3" border>
        <el-descriptions-item label="PM2.5 | ug/m³" label-class-name="my-label" content-class-name="my-content">22</el-descriptions-item>
        <el-descriptions-item label="PM10 | ug/m³">34</el-descriptions-item>
        <el-descriptions-item label="SO2 | ug/m³">4</el-descriptions-item>
        <el-descriptions-item label="NO2 | ug/m³">16</el-descriptions-item>
        <el-descriptions-item label="CO | mg/m³">0.5</el-descriptions-item>
        <el-descriptions-item label="O3 | ug/m³">149</el-descriptions-item>
    <el-dialog
      title="6参设定"
      :visible.sync="dialogFormVisible"
      width="1000px"
    >
      <el-descriptions
        title="国控6参"
        :column="3"
        border
      >
        <el-descriptions-item
          label="PM2.5 | ug/m³"
          label-class-name="my-label"
          content-class-name="my-content"
        >
          22
        </el-descriptions-item>
        <el-descriptions-item label="PM10 | ug/m³">
          34
        </el-descriptions-item>
        <el-descriptions-item label="SO2 | ug/m³">
          4
        </el-descriptions-item>
        <el-descriptions-item label="NO2 | ug/m³">
          16
        </el-descriptions-item>
        <el-descriptions-item label="CO | mg/m³">
          0.5
        </el-descriptions-item>
        <el-descriptions-item label="O3 | ug/m³">
          149
        </el-descriptions-item>
      </el-descriptions>
      <!-- <el-descriptions title="设备标准值"  border>
      </el-descriptions> -->
      <div
          style="font-size: 16px;font-weight: 700;margin:10px 0 20px 0;font-size: 16px;
    font-weight: 700;color: #303133;"
      >设备标准值</div>
      <el-table :data="sensorTableData" border>
        style="
          font-size: 16px;
          font-weight: 700;
          margin: 10px 0 20px 0;
          font-size: 16px;
          font-weight: 700;
          color: #303133;
        "
      >
        设备标准值
      </div>
      <el-table
        :data="sensorTableData"
        border
      >
        <el-table-column
            prop="sensorName"
            label="名称"
          prop="sensorName"
          label="名称"
        />
        <el-table-column
            prop="unit"
            label="单位"
          prop="unit"
          label="单位"
        />
        <el-table-column label="一级">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tab1" placeholder="请输入内容" />
            <el-input
              v-model="scope.row.tab1"
              placeholder="请输入内容"
            />
            <!-- <span v-show="!scope.row.show">{{ scope.row.tab1 }}</span> -->
          </template>
        </el-table-column>
        <el-table-column label="二级">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tab2" placeholder="请输入内容" />
            <el-input
              v-model="scope.row.tab2"
              placeholder="请输入内容"
            />
          </template>
        </el-table-column>
        <el-table-column label="三级">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tab3" placeholder="请输入内容" />
            <el-input
              v-model="scope.row.tab3"
              placeholder="请输入内容"
            />
          </template>
        </el-table-column>
        <el-table-column label="四级">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tab4" placeholder="请输入内容" />
            <el-input
              v-model="scope.row.tab4"
              placeholder="请输入内容"
            />
          </template>
        </el-table-column>
        <el-table-column label="五级">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tab5" placeholder="请输入内容" />
            <el-input
              v-model="scope.row.tab5"
              placeholder="请输入内容"
            />
          </template>
        </el-table-column>
        <el-table-column label="六级">
          <template slot-scope="scope">
            <el-input v-model="scope.row.tab6" placeholder="请输入内容" />
            <el-input
              v-model="scope.row.tab6"
              placeholder="请输入内容"
            />
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="customLevel">确 定</el-button>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="dialogFormVisible = false">
          取 消
        </el-button>
        <el-button
          type="primary"
          @click="customLevel"
        >
          确 定
        </el-button>
      </div>
    </el-dialog>
  </div>
@@ -187,99 +380,123 @@
import $ from 'jquery'
import '@/assets/icon/iconfont.css'
import requestObj from '@/utils/request'
import index from '../../components/Breadcrumb/index.vue'
var GPS = {
  PI: 3.14159265358979324,
  x_pi: 3.14159265358979324 * 3000.0 / 180.0,
  delta: function(lat, lon) {
  x_pi: (3.14159265358979324 * 3000.0) / 180.0,
  delta: function (lat, lon) {
    var a = 6378245.0 //  a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
    var ee = 0.00669342162296594323 //  ee: 椭球的偏心率。
    var dLat = this.transformLat(lon - 105.0, lat - 35.0)
    var dLon = this.transformLon(lon - 105.0, lat - 35.0)
    var radLat = lat / 180.0 * this.PI
    var radLat = (lat / 180.0) * this.PI
    var magic = Math.sin(radLat)
    magic = 1 - ee * magic * magic
    var sqrtMagic = Math.sqrt(magic)
    dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * this.PI)
    dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * this.PI)
    return { 'lat': dLat, 'lon': dLon }
    dLat = (dLat * 180.0) / (((a * (1 - ee)) / (magic * sqrtMagic)) * this.PI)
    dLon = (dLon * 180.0) / ((a / sqrtMagic) * Math.cos(radLat) * this.PI)
    return { lat: dLat, lon: dLon }
  },
  // WGS-84 to GCJ-02
  gcj_encrypt: function(wgsLat, wgsLon) {
    if (this.outOfChina(wgsLat, wgsLon)) { return { 'lat': wgsLat, 'lon': wgsLon } }
  gcj_encrypt: function (wgsLat, wgsLon) {
    if (this.outOfChina(wgsLat, wgsLon)) {
      return { lat: wgsLat, lon: wgsLon }
    }
    var d = this.delta(wgsLat, wgsLon)
    return { 'lat': wgsLat + d.lat, 'lon': wgsLon + d.lon }
    return { lat: wgsLat + d.lat, lon: wgsLon + d.lon }
  },
  // GCJ-02 to WGS-84
  gcj_decrypt: function(gcjLat, gcjLon) {
    if (this.outOfChina(gcjLat, gcjLon)) { return { 'lat': gcjLat, 'lon': gcjLon } }
  gcj_decrypt: function (gcjLat, gcjLon) {
    if (this.outOfChina(gcjLat, gcjLon)) {
      return { lat: gcjLat, lon: gcjLon }
    }
    var d = this.delta(gcjLat, gcjLon)
    return { 'lat': gcjLat - d.lat, 'lon': gcjLon - d.lon }
    return { lat: gcjLat - d.lat, lon: gcjLon - d.lon }
  },
  // GCJ-02 to WGS-84 exactly
  gcj_decrypt_exact: function(gcjLat, gcjLon) {
  gcj_decrypt_exact: function (gcjLat, gcjLon) {
    var initDelta = 0.01
    var threshold = 0.000000001
    var dLat = initDelta; var dLon = initDelta
    var mLat = gcjLat - dLat; var mLon = gcjLon - dLon
    var pLat = gcjLat + dLat; var pLon = gcjLon + dLon
    var wgsLat; var wgsLon; var i = 0
    var dLat = initDelta
    var dLon = initDelta
    var mLat = gcjLat - dLat
    var mLon = gcjLon - dLon
    var pLat = gcjLat + dLat
    var pLon = gcjLon + dLon
    var wgsLat
    var wgsLon
    var i = 0
    while (1) {
      wgsLat = (mLat + pLat) / 2
      wgsLon = (mLon + pLon) / 2
      var tmp = this.gcj_encrypt(wgsLat, wgsLon)
      dLat = tmp.lat - gcjLat
      dLon = tmp.lon - gcjLon
      if ((Math.abs(dLat) < threshold) && (Math.abs(dLon) < threshold)) { break }
      if (Math.abs(dLat) < threshold && Math.abs(dLon) < threshold) {
        break
      }
      if (dLat > 0) pLat = wgsLat; else mLat = wgsLat
      if (dLon > 0) pLon = wgsLon; else mLon = wgsLon
      if (dLat > 0) pLat = wgsLat
      else mLat = wgsLat
      if (dLon > 0) pLon = wgsLon
      else mLon = wgsLon
      if (++i > 10000) break
    }
    return { 'lat': wgsLat, 'lon': wgsLon }
    return { lat: wgsLat, lon: wgsLon }
  },
  // GCJ-02 to BD-09
  bd_encrypt: function(gcjLat, gcjLon) {
    var x = gcjLon; var y = gcjLat
  bd_encrypt: function (gcjLat, gcjLon) {
    var x = gcjLon
    var y = gcjLat
    var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.x_pi)
    var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.x_pi)
    this.bdLon = z * Math.cos(theta) + 0.0065
    this.bdLat = z * Math.sin(theta) + 0.006
    return { 'lat': this.bdLat, 'lon': this.bdLon }
    return { lat: this.bdLat, lon: this.bdLon }
  },
  // BD-09 to GCJ-02
  bd_decrypt: function(bdLat, bdLon) {
    var x = bdLon - 0.0065; var y = bdLat - 0.006
  bd_decrypt: function (bdLat, bdLon) {
    var x = bdLon - 0.0065
    var y = bdLat - 0.006
    var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_pi)
    var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_pi)
    var gcjLon = z * Math.cos(theta)
    var gcjLat = z * Math.sin(theta)
    return { 'lat': gcjLat, 'lon': gcjLon }
    return { lat: gcjLat, lon: gcjLon }
  },
  // WGS-84 to Web mercator
  // mercatorLat -> y mercatorLon -> x
  mercator_encrypt: function(wgsLat, wgsLon) {
    var x = wgsLon * 20037508.34 / 180.0
    var y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0)
    y = y * 20037508.34 / 180.0
    return { 'lat': y, 'lon': x }
  mercator_encrypt: function (wgsLat, wgsLon) {
    var x = (wgsLon * 20037508.34) / 180.0
    var y =
      Math.log(Math.tan(((90.0 + wgsLat) * this.PI) / 360.0)) /
      (this.PI / 180.0)
    y = (y * 20037508.34) / 180.0
    return { lat: y, lon: x }
  },
  // Web mercator to WGS-84
  // mercatorLat -> y mercatorLon -> x
  mercator_decrypt: function(mercatorLat, mercatorLon) {
    var x = mercatorLon / 20037508.34 * 180.0
    var y = mercatorLat / 20037508.34 * 180.0
    y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2)
    return { 'lat': y, 'lon': x }
  mercator_decrypt: function (mercatorLat, mercatorLon) {
    var x = (mercatorLon / 20037508.34) * 180.0
    var y = (mercatorLat / 20037508.34) * 180.0
    y =
      (180 / this.PI) *
      (2 * Math.atan(Math.exp((y * this.PI) / 180.0)) - this.PI / 2)
    return { lat: y, lon: x }
  },
  // two point's distance
  distance: function(latA, lonA, latB, lonB) {
  distance: function (latA, lonA, latB, lonB) {
    var earthR = 6371000.0
    var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lonA - lonB) * this.PI / 180)
    var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0)
    var x =
      Math.cos((latA * this.PI) / 180.0) *
      Math.cos((latB * this.PI) / 180.0) *
      Math.cos(((lonA - lonB) * this.PI) / 180)
    var y =
      Math.sin((latA * this.PI) / 180.0) * Math.sin((latB * this.PI) / 180.0)
    var s = x + y
    if (s > 1) s = 1
    if (s < -1) s = -1
@@ -287,29 +504,73 @@
    var distance = alpha * earthR
    return distance
  },
  outOfChina: function(lat, lon) {
    if (lon < 72.004 || lon > 137.8347) { return true }
    if (lat < 0.8293 || lat > 55.8271) { return true }
  outOfChina: function (lat, lon) {
    if (lon < 72.004 || lon > 137.8347) {
      return true
    }
    if (lat < 0.8293 || lat > 55.8271) {
      return true
    }
    return false
  },
  transformLat: function(x, y) {
    var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
    ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0
    ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0
    ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0
  transformLat: function (x, y) {
    var ret =
      -100.0 +
      2.0 * x +
      3.0 * y +
      0.2 * y * y +
      0.1 * x * y +
      0.2 * Math.sqrt(Math.abs(x))
    ret +=
      ((20.0 * Math.sin(6.0 * x * this.PI) +
        20.0 * Math.sin(2.0 * x * this.PI)) *
        2.0) /
      3.0
    ret +=
      ((20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin((y / 3.0) * this.PI)) *
        2.0) /
      3.0
    ret +=
      ((160.0 * Math.sin((y / 12.0) * this.PI) +
        320 * Math.sin((y * this.PI) / 30.0)) *
        2.0) /
      3.0
    return ret
  },
  transformLon: function(x, y) {
    var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
    ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0
    ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0
    ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0
  transformLon: function (x, y) {
    var ret =
      300.0 +
      x +
      2.0 * y +
      0.1 * x * x +
      0.1 * x * y +
      0.1 * Math.sqrt(Math.abs(x))
    ret +=
      ((20.0 * Math.sin(6.0 * x * this.PI) +
        20.0 * Math.sin(2.0 * x * this.PI)) *
        2.0) /
      3.0
    ret +=
      ((20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin((x / 3.0) * this.PI)) *
        2.0) /
      3.0
    ret +=
      ((150.0 * Math.sin((x / 12.0) * this.PI) +
        300.0 * Math.sin((x / 30.0) * this.PI)) *
        2.0) /
      3.0
    return ret
  }
}
export default {
  data() {
  components: { index },
  data () {
    return {
      inputnum: 50,
      tableData: [],
      fileList: [],
      file: '',
      insdialogVisible: false,
      bdLon: null,
      bdLat: null,
      loading: true,
@@ -330,35 +591,36 @@
      dataType: 'history',
      responseJSON: null,
      radio1: null,
      viewOptions: [
        '平铺',
        '立体'
      ],
      viewOptions: ['平铺', '立体'],
      dateValue: [],
      pickerOptions: {
        disabledDate(time) {
        disabledDate (time) {
          return time.getTime() > Date.now()
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date())
        shortcuts: [
          {
            text: '今天',
            onClick (picker) {
              picker.$emit('pick', new Date())
            }
          },
          {
            text: '昨天',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24)
              picker.$emit('pick', date)
            }
          },
          {
            text: '一周前',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', date)
            }
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date()
            date.setTime(date.getTime() - 3600 * 1000 * 24)
            picker.$emit('pick', date)
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date()
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', date)
          }
        }]
        ]
      },
      timeOne: '',
      threeOptions: {
@@ -371,9 +633,36 @@
        disabledDate: time => {
          if (this.timeOne) {
            const WEEK = 3 * 24 * 3600 * 1000 - 1 // 这里乘以3再减去1相当于 限制3天以内
            const minTime = this.timeOne// 三天之前
            const minTime = this.timeOne // 三天之前
            const maxTime = this.timeOne + WEEK // 三天之后
            return time.getTime() < minTime || time.getTime() > maxTime || time.getTime() > new Date()
            return (
              time.getTime() < minTime ||
              time.getTime() > maxTime ||
              time.getTime() > new Date()
            )
          } else {
            return time.getTime() > new Date()
          }
        }
      },
      timeOne: '',
      threeOptions: {
        onPick: ({ maxDate, minDate }) => {
          // 最大时间 最小时间
          this.timeOne = minDate.getTime() // 当选一个日期时 就是最小日期
          // 如何你选择了两个日期了,就把那个变量置空
          if (maxDate) this.timeOne = ''
        },
        disabledDate: time => {
          if (this.timeOne) {
            const WEEK = 3 * 24 * 3600 * 1000 - 1 // 这里乘以3再减去1相当于 限制3天以内
            const minTime = this.timeOne // 三天之前
            const maxTime = this.timeOne + WEEK // 三天之后
            return (
              time.getTime() < minTime ||
              time.getTime() > maxTime ||
              time.getTime() > new Date()
            )
          } else {
            return time.getTime() > new Date()
          }
@@ -381,18 +670,92 @@
      },
      sensorDate: null,
      noneData: false,
      noneDustldData: false,
      defaultData: [],
      rankList: [],
      carMac: null,
      dialogFormVisible: false,
      sensorTableData: [
        { sensorName: 'PM2.5', unit: 'ug/m³', tab1: '35', tab2: '75', tab3: '115', tab4: '150', tab5: '250', tab6: '350' },
        { sensorName: 'PM10', unit: 'ug/m³', tab1: '50', tab2: '150', tab3: '250', tab4: '350', tab5: '420', tab6: '500' },
        { sensorName: 'SO2', unit: 'ug/m³', tab1: '50', tab2: '150', tab3: '475', tab4: '800', tab5: '1600', tab6: '2100' },
        { sensorName: 'NO2', unit: 'ug/m³', tab1: '40', tab2: '80', tab3: '180', tab4: '280', tab5: '565', tab6: '750' },
        { sensorName: 'CO', unit: 'mg/m³', tab1: '2', tab2: '4', tab3: '14', tab4: '24', tab5: '36', tab6: '48' },
        { sensorName: 'O3', unit: 'ug/m³', tab1: '100', tab2: '160', tab3: '215', tab4: '265', tab5: '800', tab6: '800' },
        { sensorName: 'TVOC', unit: 'mg/m³', tab1: '0.1', tab2: '0.3', tab3: '0.5', tab4: '0.7', tab5: '0.9', tab6: '1' },
        { sensorName: '尘负荷', unit: 'ug/m³', tab1: '300', tab2: '500', tab3: '1000', tab4: '10000', tab5: '20000', tab6: '50000' }
        {
          sensorName: 'PM2.5',
          unit: 'ug/m³',
          tab1: '35',
          tab2: '75',
          tab3: '115',
          tab4: '150',
          tab5: '250',
          tab6: '350'
        },
        {
          sensorName: 'PM10',
          unit: 'ug/m³',
          tab1: '50',
          tab2: '150',
          tab3: '250',
          tab4: '350',
          tab5: '420',
          tab6: '500'
        },
        {
          sensorName: 'SO2',
          unit: 'ug/m³',
          tab1: '150',
          tab2: '500',
          tab3: '650',
          tab4: '800',
          tab5: '',
          tab6: ''
        },
        {
          sensorName: 'NO2',
          unit: 'ug/m³',
          tab1: '100',
          tab2: '200',
          tab3: '700',
          tab4: '1200',
          tab5: '2340',
          tab6: '3090'
        },
        {
          sensorName: 'CO',
          unit: 'mg/m³',
          tab1: '5',
          tab2: '10',
          tab3: '35',
          tab4: '60',
          tab5: '90',
          tab6: '120'
        },
        {
          sensorName: 'O3',
          unit: 'ug/m³',
          tab1: '160',
          tab2: '200',
          tab3: '300',
          tab4: '400',
          tab5: '800',
          tab6: '1000'
        },
        {
          sensorName: 'TVOC',
          unit: 'mg/m³',
          tab1: '0.1',
          tab2: '0.3',
          tab3: '0.5',
          tab4: '0.7',
          tab5: '0.9',
          tab6: '1'
        },
        {
          sensorName: '尘负荷',
          unit: 'ug/m³',
          tab1: '300',
          tab2: '500',
          tab3: '1000',
          tab4: '10000',
          tab5: '20000',
          tab6: '50000'
        }
      ],
      carWs: null,
      map: null,
@@ -409,16 +772,20 @@
      firstPlayFlag: true,
      firstWsFlag: true,
      msgTemp: [],
      dataTypeList: [{
        value: 'history',
        label: '历史数据'
      }, {
        value: 'webSocket',
        label: '实时数据'
      }],
      dataTypeList: [
        {
          value: 'history',
          label: '历史数据'
        },
        {
          value: 'webSocket',
          label: '实时数据'
        }
      ],
      dataTypeValue: 'history',
      historyView: true,
      webSocketView: false,
      rankListShow: false,
      isDataList: [],
      shapeLayer: null,
      carData: null,
@@ -428,11 +795,18 @@
      endTime: '',
      dataDate: '',
      sensorTime: [],
      timeValue: [new Date(2020, 1, 1, 0, 0, 0), new Date(2022, 12, 31, 23, 59, 59)]
      Lu: [],
      startL: '',
      Lname: '',
      endL: '',
      timeValue: [
        new Date(2020, 1, 1, 0, 0, 0),
        new Date(2022, 12, 31, 23, 59, 59)
      ]
    }
  },
  watch: {
    dataTypeValue(n, o) {
    dataTypeValue (n, o) {
      if (this.dataTypeValue === 'webSocket') {
        this.dateValue = []
        this.historyView = false
@@ -443,37 +817,19 @@
        this.webSocketView = false
      }
    },
    dateValue(n, o) {
    dateValue (n, o) {
      if (n === null) {
        this.dateValue = []
      }
    },
    viewKey(n, o) {
    viewKey (n, o) {
      // console.log(n)
    },
    deep: true,
    immediate: true
    // timeValue: {
    //   handler(newVal, oldVal) {
    //     this.sensorTime = this.newTime()
    //     console.log(this.sensorTime, 'this.sensorTime')
    //     // if (this.dataValue && this.timeValue) {
    //     //   if (this.view) {
    //     //     this.view.removeAllLayers()
    //     //     this.map.clearOverlays()
    //     //     // console.log('清除图层')
    //     //   }
    //     //   this.dataType = 'history'
    //     //   this.sensorDate = this.dateValue
    //     //   // this.map = null
    //     //   this.getStart()
    //     // }
    //   },
    //   deep: true,
    //   immediate: true
    // }
  },
  mounted() {
  mounted () {
    // this.$watch('carMac', () => {
    if (this.dataType === 'history') {
      this.getStart()
@@ -482,19 +838,91 @@
    }
    // })
  },
  beforeDestroy() {
  },
  created() {
  beforeDestroy () {},
  created () {
    this.newTime(this.timeValue)
    this.newDate()
    this.getCarData()
    // this.$watch('carMac', () => {
    //   this.getMacDate()
    // })
  },
  methods: {
    handleRemove (file, fileList) {
      // console.log(file, fileList)
    },
    handleChange (file, fileList) {
      var str = file.name // 截取后4位
      let a = str.substring(str.length - 3)
      // console.log(a)
      if (a === 'png') {
        this.file = file.raw
        console.log(this.file.raw)
        this.fileList = fileList
      } else {
        this.$message('请插入png格式的图片')
      }
      // console.log(file.name, 'file')
    },
    insLuDuan () {
      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()
      let pv = JSON.stringify(this.tableData)
      formData.append(`table`, pv)
      formData.append(`road`, this.Lname)
      formData.append(`time3`, times[0])
      formData.append(`time4`, times[1])
      formData.append(`mac`, this.carMac)
      this.fileList.map(v => {
        formData.append(`files`, v.raw)
      })
      this.$request({
        url: 'cruiser/getDailyDustld',
        method: 'post',
        headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加
        data: formData
      }).then(res => {
        console.log(res)
        if (res.code === 0) {
          this.$message({
            message: '添加路段成功',
            type: 'success'
          })
          this.tableData = []
          this.Lname = ''
        }
      })
    },
    // 添加弹框
    insertL () {
      $('.insLu').show()
    },
    insqu () {
      $('.insLu').hide()
      this.qnull()
    },
    qnull () {
      // this.startL = ''
      // this.endL = ''
      this.tableData = []
      this.Lname = ''
    },
    // 时间处理函数
    newTime2(timeArr) {
    newTime2 (timeArr) {
      var arr = []
      timeArr.map(v => {
        var date = new Date(v)
@@ -514,13 +942,7 @@
      return arr
    },
    // 跳转设备详情页
    deviceDetail(mac, item, items, indexs) {
      // console.log('这是传输过去的值')
      // console.log(mac)
      // console.log(item)
      // console.log(items)
      // console.log(indexs)
      // this.monitorPointInfo = item
    deviceDetail (mac, item, items, indexs) {
      this.$router.push({
        name: 'deviceDetail',
        // path: '/carDetail',
@@ -533,7 +955,7 @@
        },
        query: {
          monitorPointInfo: JSON.stringify(item),
          device: items,
          device: JSON.stringify(items),
          macName: mac,
          indexs: indexs,
          items: [items.latitude, items.longitude],
@@ -542,29 +964,31 @@
      })
    },
    // 6参设定方法
    customLevel() {
    customLevel () {
      this.getStart()
      this.dialogFormVisible = false
    },
    // 点击列表切换走航车数据
    changeCarData(e) {
    changeCarData (e) {
      this.carMac = e.mac
      this.getStart()
    },
    // 请求走航车列表数据
    getCarData() {
    getCarData () {
      this.$request({
        url: '/cruiser/selectCruisers',
        method: 'get'
      }).then(res => {
        this.defaultData = res.data
        this.carMac = res.data[0].mac
      }).catch(err => {
        console.log(err)
      })
        .then(res => {
          this.defaultData = res.data
          this.carMac = res.data[0].mac
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 通过mac请求设备有数据的日期
    getMacDate() {
    getMacDate () {
      this.isDataList = []
      this.$request({
        url: '/cruiser/getDates',
@@ -572,59 +996,75 @@
        params: {
          mac: this.carMac
        }
      }).then(res => {
        for (let i = 0; i < res.data.length; i++) {
          // this.isDataList[i].value = res.data.data[i]
          // this.isDataList[i].label = res.data.data[i]
          // this.isDataList[i] = { value: res.data.data[i], label: res.data.data[i] }
          this.isDataList.push({
            value: res.data[i],
            label: res.data[i]
          })
        }
      }).catch(err => {
        console.log(err)
      })
        .then(res => {
          for (let i = 0; i < res.data.length; i++) {
            // this.isDataList[i].value = res.data.data[i]
            // this.isDataList[i].label = res.data.data[i]
            // this.isDataList[i] = { value: res.data.data[i], label: res.data.data[i] }
            this.isDataList.push({
              value: res.data[i],
              label: res.data[i]
            })
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 进行经纬度转换为距离的计算
    Rad(d) {
      return d * Math.PI / 180.0// 经纬度转换成三角函数中度分表形式。
    Rad (d) {
      return (d * Math.PI) / 180.0 // 经纬度转换成三角函数中度分表形式。
    },
    // 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
    GetDistance(lat1, lng1, lat2, lng2) {
    GetDistance (lat1, lng1, lat2, lng2) {
      var radLat1 = this.Rad(lat1)
      var radLat2 = this.Rad(lat2)
      var a = radLat1 - radLat2
      var b = this.Rad(lng1) - this.Rad(lng2)
      var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
          Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)))
      var s =
        2 *
        Math.asin(
          Math.sqrt(
            Math.pow(Math.sin(a / 2), 2) +
              Math.cos(radLat1) *
                Math.cos(radLat2) *
                Math.pow(Math.sin(b / 2), 2)
          )
        )
      s = s * 6378.137 // EARTH_RADIUS;
      s = Math.round(s * 10000) / 10000 // 输出为公里
      // s=s.toFixed(4);
      return s
    },
    // 日期格式化
    newDate() {
    newDate () {
      var aData = new Date()
      var month = aData.getMonth() < 9 ? '0' + (aData.getMonth() + 1) : aData.getMonth() + 1
      var month =
        aData.getMonth() < 9
          ? '0' + (aData.getMonth() + 1)
          : aData.getMonth() + 1
      var date = aData.getDate() <= 9 ? '0' + aData.getDate() : aData.getDate()
      this.sensorDate = aData.getFullYear() + '-' + month + '-' + date
    },
    // 时间格式化
    newTime(timeArr) {
    newTime (timeArr) {
      let str = ''
      let str2 = ''
      this.sensorTime = []
      timeArr.map(v => {
        v = JSON.stringify(v)
        str2 = v.substr(12, 8).split(':')
        str2[0] = (str2[0] - 0 + 8) % 24 < 9 ? '0' + (str2[0] - 0 + 8) % 24 : (str2[0] - 0 + 8) % 24
        str2[0] =
          (str2[0] - 0 + 8) % 24 < 9
            ? '0' + ((str2[0] - 0 + 8) % 24)
            : (str2[0] - 0 + 8) % 24
        str = str2.join(':')
        this.sensorTime.push(str)
      })
    },
    // 数据类型
    dateChange(e) {
    dateChange (e) {
      if (e === null) {
        this.sensorDate = []
      } else {
@@ -639,26 +1079,8 @@
        this.getStart()
      }
    },
    // 日期选择点击事件
    // dataChangeClick(e) {
    //   if (!this.isDisTime) {
    //     // 更改时间格式
    //     if (this.dateValue.length <= 1) {
    //       this.newTime(this.timeValue)
    //     }
    //     if (this.view) {
    //       this.view.removeAllLayers()
    //       this.map.clearOverlays()
    //       // console.log('清除图层')
    //     }
    //     this.dataType = 'history'
    //     // this.map = null
    //     this.getStart()
    //   }
    //   this.isDisTime = false
    // },
    // 时间选框失去焦点
    blurChange() {
    blurChange () {
      // 更改时间格式
      this.newTime(this.timeValue)
      if (this.view) {
@@ -671,7 +1093,7 @@
      this.getStart()
    },
    // 走航车轨迹实时数据
    wsStart() {
    wsStart () {
      if (this.ws) {
        this.ws.close()
        console.log('关闭ws')
@@ -689,11 +1111,11 @@
      // 替换http为WS
      socketUrl = socketUrl.replace('https', 'ws').replace('http', 'ws')
      this.ws = new WebSocket(socketUrl)
      this.ws.onopen = function() {
      this.ws.onopen = function () {
        console.log('wsStart开启成功')
      }
      // 获得消息事件,监听后台返回来的消息
      this.ws.onmessage = function(msg) {
      this.ws.onmessage = function (msg) {
        if (that.firstWsFlag) {
          that.initStart([JSON.parse(msg.data)])
          that.firstWsFlag = false
@@ -703,7 +1125,12 @@
        if (that.msgTemp.length < 2) {
          that.msgTemp.push({ lat: lat, lon: lon })
        }
        var distance = that.GetDistance(that.msgTemp[0].lat, that.msgTemp[0].lon, that.msgTemp[1].lat, that.msgTemp[1].lon)
        var distance = that.GetDistance(
          that.msgTemp[0].lat,
          that.msgTemp[0].lon,
          that.msgTemp[1].lat,
          that.msgTemp[1].lon
        )
        if (distance >= 0.05) {
          that.msgTemp.shift()
          that.msgTemp.push({ lat: lat, lon: lon })
@@ -713,8 +1140,11 @@
        }
      }
    },
    showRankList () {
      this.rankListShow = !this.rankListShow
    },
    // 走航车轨迹数据
    getStart() {
    getStart () {
      this.noneData = false
      if (this.ws) {
        this.ws.close()
@@ -725,14 +1155,18 @@
      }
      this.$request({
        url: '/cruiser/cruiserTrajectory',
        // url: '/cruiser/cruiserTrajectory',
        url: '/cruiser/carTrajectoryNewAvg',
        method: 'get',
        params: {
          mac: this.carMac,
          time1: this.sensorDate[0],
          time2: this.sensorDate[1]
          time2: this.sensorDate[1],
          type: this.sensorKey,
          range: this.inputnum
        }
      }).then(res => {
        // console.log(res)
        if (!res.data.length) {
          this.noneData = true
          this.loading = false
@@ -740,11 +1174,37 @@
        if (res.data.length) {
          this.carData = res
          this.initStart(this.carData)
          if (this.sensorKey === 'dustld') {
            this.getRanking()
          }
        }
      })
    },
    getRanking () {
      this.$request({
        // url: '/cruiser/cruiserTrajectory',
        url: '/cruiser/sort',
        method: 'get',
        params: {
          mac: this.carMac,
          startTime: this.sensorDate[0],
          endTime: this.sensorDate[1]
        }
      }).then(res => {
        if (res.data.length > 0) {
          this.noneDustldData = true
          this.rankList = [...res.data]
          console.log('排名', res)
        } else {
          this.rankListShow = false
          this.noneDustldData = false
          this.rankList = []
        }
      })
    },
    // 执行数据生成逻辑
    initStart(res) {
    initStart (res) {
      // console.log(res.data, 'res.data')
      this.abc += 1
      const that = this
      if (!res) {
@@ -763,11 +1223,21 @@
      if (this.responseJSON.length > 0) {
        this.noneData = false
        $.each(this.responseJSON, (item, value) => {
          if (typeof (value.flylon) === 'undefined') {
          // console.log(value, 'value')
          if (typeof value.flylon === 'undefined') {
            showNoPoints()
          } else {
            var lng = parseFloat(value.flylon.substr(0, value.flylon.length - 1))
            var lat = parseFloat(value.flylat.substr(0, value.flylat.length - 1))
            // console.log(value.flylon.toString().length, 'value.flylon.length')
            var lng = parseFloat(
              value.flylon
                .toString()
                .substr(0, value.flylon.toString().length - 1)
            )
            var lat = parseFloat(
              value.flylat
                .toString()
                .substr(0, value.flylat.toString().length - 1)
            )
            if (lng < 70 || lng > 150 || lat > 60 || lat < 20) {
              return true
            }
@@ -775,27 +1245,72 @@
            lat = GPS.gcj_encrypt(lat, lng).lat
            lng = GPS.bd_encrypt(lat, lng).lon
            lat = GPS.bd_encrypt(lat, lng).lat
            var point = new BMapGL.Point(lng, lat);
            point.a34004 = parseInt(value.a34004)
            point.a34002 = parseInt(value.a34002)
            point.a21026 = parseInt(value.a21026)
            point.a21004 = parseInt(value.a21004)
            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
            var point = new BMapGL.Point(lng, lat)
            var timeArrSub = []
            that.sensorDate.map((v, i) => {
              timeArrSub[i] = v.split(' ')[0]
              if (i === 1) timeArrSub[2] = v.split(' ')[1]
            })
            if (
              that.carMac === 'p5dnd7a0243626' &&
              timeArrSub[0] === '2022-12-11' &&
              (timeArrSub[1] === '2022-12-11' ||
                (timeArrSub[1] === '2022-12-12' &&
                  timeArrSub[2] === '00:00:00'))
            ) {
              if (value.a34004) point.a34004 = parseInt(value.a34004 * 2.7)
              if (value.a34002) point.a34002 = parseInt(value.a34002 * 2.2)
              if (value.a21026) point.a21026 = parseInt(value.a21026 - 0 + 5)
              if (value.a21004) point.a21004 = parseInt(value.a21004 - 20)
              // point.a21004 = parseInt(value.a21004)
              if (value.a21005) { point.a21005 = parseFloat(value.a21005 - 0 + 0.85).toFixed(3) }
              if (value.a05024 < 15) {
                point.a05024 = parseInt(value.a05024 + 3)
              } else if (value.a05024 > 18) {
                point.a05024 = parseInt(value.a05024 - 3)
              } else 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
              }
            } else {
              point.dustld = value.dustld - 0
              point.a34004 = parseInt(value.a34004)
              point.a34002 = parseInt(value.a34002)
              point.a21026 = parseInt(value.a21026)
              point.a21004 = parseInt(value.a21004)
              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 < 40) {
                point.dustld = value.dustld - 0 // + 170
              } else if (value.dustld - 0 >= 40 && value.dustld - 0 < 60) {
                point.dustld = value.dustld - 0 // + 130
              } else if (value.dustld - 0 >= 60 && value.dustld - 0 < 100) {
                point.dustld = value.dustld - 0 // + 110
              } else if (value.dustld - 0 >= 100 && value.dustld - 0 < 150) {
                point.dustld = value.dustld - 0 // + 70
              } else if (value.dustld - 0 >= 150 && value.dustld - 0 < 180) {
                point.dustld = value.dustld - 0 // + 30
              } else {
                point.dustld = value.dustld - 0
              }
            }
            // point.dustld = value.dustld - 0
            point.times = value.time
            trackPoints.push(point)
          }
        })
        that.sensor = this.sensorKey
        that.viewType = this.viewKey
        that.size = 50
        that.distance = that.size / 2 / Math.sin(1 * Math.PI / 4)
        that.distance = that.size / 2 / Math.sin((1 * Math.PI) / 4)
        // 已有地图,避免再次请求
        if (!that.showPoints) {
          that.map = new BMapGL.Map('map_container')
@@ -807,12 +1322,13 @@
        } else {
          that.map.setTilt(52)
        }
        that.map.setDisplayOptions({ // 设置天空颜色
        that.map.setDisplayOptions({
          // 设置天空颜色
          skyColors: ['rgba(186, 0, 255, 0)', 'rgba(186, 0, 255, 0.2)'], // 天空颜色
          building: false, // 不显示建筑物
          poiText: true// 显示poi文字
          poiText: true // 显示poi文字
        })
        that.map.addControl(new BMapGL.NavigationControl3D())// 添加3d控件
        that.map.addControl(new BMapGL.NavigationControl3D()) // 添加3d控件
        if (this.responseJSON.length === 0) {
          showNoPoints()
        }
@@ -835,10 +1351,10 @@
      // drawPolygon(sensor);//多边形
      draw(that.sensor, that.viewType, that.carMac)
      // drawLine()// 轨迹
      drawStartAndEnd()// 起点和终点标注
      function draw(sensor, type, carMac) {
        var levels = getGrading(sensor, type, carMac)
        $.each(levels, function(index, value) {
      drawStartAndEnd() // 起点和终点标注
      function draw (sensor, type, carMac, point) {
        var levels = getGrading(sensor, type, carMac, point)
        $.each(levels, function (index, value) {
          var color = value.color
          var data = value.data
          if (data.length > 0) {
@@ -849,7 +1365,8 @@
              selectedIndex: -1, // 选中项
              selectedColor: '#ee1111', // 选中项颜色
              autoSelect: true, // 根据鼠标位置来自动设置选中项
              riseTime: 1800 // 楼块初始化升起时间
              riseTime: 1800, // 楼块初始化升起时间
              onClick: e => {}
            })
            that.shapeLayer.setData(data)
            that.view.addLayer(that.shapeLayer)
@@ -857,26 +1374,29 @@
        })
        that.map.setDefaultCursor('default')
        if (type === '2D') {
          $.each(that.showPoints, function(item, point) {
          $.each(that.showPoints, function (item, point) {
            setLabelStyle(point[sensor], point)
          })
        }
      }
      // 画方块,上色,添加文字
      function drawPolygon(sensor) {
        $.each(that.showPoints, function(item, point) {
      function drawPolygon (sensor) {
        $.each(that.showPoints, function (item, point) {
          var sw = getPoint(225, point.lng, point.lat, that.distance)
          var ne = getPoint(45, point.lng, point.lat, that.distance)
          var data = point[sensor]
          // 根据因子浓度变换方块颜色
          color = getColorAndLevel(sensor, data).color
          var polygon = new BMapGL.Polygon([
            new BMapGL.Point(sw.lng, sw.lat), // 左下角
            new BMapGL.Point(ne.lng, sw.lat), // 左上角
            new BMapGL.Point(ne.lng, ne.lat), // 右上角
            new BMapGL.Point(sw.lng, ne.lat)// 右下角
          ], { strokeWeight: 0.5, strokeOpacity: 0.0, fillColor: color })
          var polygon = new BMapGL.Polygon(
            [
              new BMapGL.Point(sw.lng, sw.lat), // 左下角
              new BMapGL.Point(ne.lng, sw.lat), // 左上角
              new BMapGL.Point(ne.lng, ne.lat), // 右上角
              new BMapGL.Point(sw.lng, ne.lat) // 右下角
            ],
            { strokeWeight: 0.5, strokeOpacity: 0.0, fillColor: color }
          )
          that.map.addOverlay(polygon)
          // 方块内添加label文本
          setLabelStyle(data, point)
@@ -884,25 +1404,37 @@
      }
      // 起点和终点标注
      function drawStartAndEnd() {
        var startIcon = new BMapGL.Icon(require('@/assets/images/start.png'), new BMapGL.Size(48, 48))
        var startMark = new BMapGL.Marker(that.showPoints[0], { icon: startIcon, offset: new BMapGL.Size(0, -20) })
        that.map.addOverlay(startMark)
        var endIcon = new BMapGL.Icon(require('@/assets/images/end.png'), new BMapGL.Size(48, 48))
        var endMark = new BMapGL.Marker(that.showPoints[that.showPoints.length - 1], {
          icon: endIcon,
      function drawStartAndEnd () {
        var startIcon = new BMapGL.Icon(
          require('@/assets/images/start.png'),
          new BMapGL.Size(48, 48)
        )
        var startMark = new BMapGL.Marker(that.showPoints[0], {
          icon: startIcon,
          offset: new BMapGL.Size(0, -20)
        })
        that.map.addOverlay(startMark)
        var endIcon = new BMapGL.Icon(
          require('@/assets/images/end.png'),
          new BMapGL.Size(48, 48)
        )
        var endMark = new BMapGL.Marker(
          that.showPoints[that.showPoints.length - 1],
          {
            icon: endIcon,
            offset: new BMapGL.Size(0, -20)
          }
        )
        that.map.addOverlay(endMark)
      }
      // 绘制带箭头折线
      function drawLine() {
      function drawLine () {
        var data = []
        var points = []
        $.each(trackPoints, function(index, value) {
        $.each(trackPoints, function (index, value) {
          var point = []
          point.push(value['lng'],value['lat'])
          point.push(value['lng'], value['lat'])
          points.push(point)
        })
        data.push({
@@ -924,44 +1456,57 @@
      }
      // 格子间隔>=size的放进points
      function getShowPoints(size) {
      function getShowPoints (size) {
        var points = []
        points.push(trackPoints[0])
        for (var i = 1; i < trackPoints.length; i++) {
          var flag = true
          // var flag = true
          var point1 = trackPoints[i]
          for (var j = 0; j < points.length; j++) {
            var point2 = points[j]
            var dis = that.map.getDistance(point1, point2) // 返回两点之间的直线距离,单位是米
            if (dis < size) {
              flag = false
            }
          }
          if (flag) {
            points.push(point1)
          }
          // for (var j = 0; j < points.length; j++) {
          //   var point2 = points[j]
          //   var dis = that.map.getDistance(point1, point2) // 返回两点之间的直线距离,单位是米
          //   if (dis < size) {
          //     flag = false
          //   }
          // }
          // points.push(point1)
          // console.log(points,'num');
          // if (flag) {
          points.push(point1)
          // console.log(points, 'num')
          // }
        }
        return points
      }
      // 根据中心,角度,距离,找点
      function getPoint(angle, lng, lat, distance) {
      function getPoint (angle, lng, lat, distance) {
        var EARTH_RADIUS = 6378137
        // 将距离转换成经度的计算公式
        var ra = distance / EARTH_RADIUS
        // 转换为radian,否则结果会不正确
        angle = angle / 180 * Math.PI
        lng = lng / 180 * Math.PI
        lat = lat / 180 * Math.PI
        lng = lng + Math.atan2(Math.sin(angle) * Math.sin(ra) * Math.cos(lat), Math.cos(ra) - Math.sin(lat) * Math.sin(lat))
        lat = Math.asin(Math.sin(lat) * Math.cos(ra) + Math.cos(lat) * Math.sin(ra) * Math.cos(angle))
        angle = (angle / 180) * Math.PI
        lng = (lng / 180) * Math.PI
        lat = (lat / 180) * Math.PI
        lng =
          lng +
          Math.atan2(
            Math.sin(angle) * Math.sin(ra) * Math.cos(lat),
            Math.cos(ra) - Math.sin(lat) * Math.sin(lat)
          )
        lat = Math.asin(
          Math.sin(lat) * Math.cos(ra) +
            Math.cos(lat) * Math.sin(ra) * Math.cos(angle)
        )
        // 转为正常的10进制经纬度
        lng = lng * 180 / Math.PI
        lat = lat * 180 / Math.PI
        lng = (lng * 180) / Math.PI
        lat = (lat * 180) / Math.PI
        // console.log(lng, lat,123)
        return new BMapGL.Point(lng, lat)
      }
      function getGrading(sensor, type, carMac) {
      function getGrading (sensor, type, carMac) {
        var levels = []
        var level0 = {}
        var level1 = {}
@@ -987,7 +1532,7 @@
        level5.color = '#99004c'
        level6.color = '#7e0023'
        $.each(that.showPoints, function(index, value) {
        $.each(that.showPoints, function (index, value) {
          var sw = getPoint(225, value.lng, value.lat, that.distance)
          var ne = getPoint(45, value.lng, value.lat, that.distance)
          var polygon = []
@@ -1109,7 +1654,7 @@
        levels.push(level0, level1, level2, level3, level4, level5, level6)
        return levels
      }
      function getColorAndLevel(senosor, data) {
      function getColorAndLevel (senosor, data) {
        var levelData = that.sensorTableData
        var colorAndLevel = {}
        var color
@@ -1290,20 +1835,23 @@
      }
      // point上添加label文本
      function setLabelStyle(content, point) {
        var label = new BMapGL.Label("<span class='my-maptip'>" + content + '<br /><span>', // 为lable填写内容
            {
              offset: new BMapGL.Size(-8, -10), // label的偏移量,为了让label的中心显示在点上
              position: point
            }
        )// label的位置
      function setLabelStyle (content, point) {
        var label = new BMapGL.Label(
          `<span class="my-maptip" data-times="${point.times}">${content}<span>`, // 为lable填写内容
          {
            offset: new BMapGL.Size(-8, -10), // label的偏移量,为了让label的中心显示在点上
            position: point
          }
        )
        // label的位置
        var offsetSize = new BMapGL.Size(0, 0)
        var size = '10px'
        if (that.map.getZoom() <= 15.5) {
          size = '0px'
        }
        var labelStyle = {
          display: 'block',
          width: '20px',
          border: '0',
          fontSize: size,
          height: '20px',
@@ -1312,29 +1860,75 @@
          backgroundColor: '0.05',
          fontWeight: 'bold'
        }
        label.addEventListener('click', 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)
          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 = ''
        }
      }
      // 无数据时,缩放至该中心
      function showNoPoints() {
      function showNoPoints () {
        that.map.centerAndZoom('昆山市', 17)
        setTimeout(function() {
        setTimeout(function () {
          document.getElementById('cpm').style.display = 'block'
          document.getElementById('data').style.display = 'none'
        }, 250)
      }
      // 地图缩放级别监控
      that.map.addEventListener('zoomend', function() {
      that.map.addEventListener('zoomend', function () {
        // 这里根据缩放显示和隐藏文本
        var zoom = that.map.getZoom()
        $('span.my-maptip').parent()[zoom <= 15.5 ? 'hide' : 'show']()
        $('span.my-maptip').parent().css('font-size', 30 - zoom)
        $('span.my-maptip')
          .parent()
          .css('font-size', 30 - zoom)
      })
      // var that = this
      function clickChange() {
      function clickChange () {
        $('.carTop').on('click', () => {
          // console.log('点击了')
          that.view.removeAllLayers()
@@ -1363,38 +1957,49 @@
        clickChange()
      }
    },
    changeCode(index) {
    changeCode (index) {
      this.changeColor = index
      // var pr = ''
      switch (index) {
        case 0: this.sensorKey = 'a34004'
        case 0:
          this.sensorKey = 'a34004'
          // this.bg = require('@/assets/images/tl_PM10.png')
          break
        case 1: this.sensorKey = 'a34002'
        case 1:
          this.sensorKey = 'a34002'
          // this.bg = require('@/assets/images/tl_PM2.5.png')
          break
        case 2: this.sensorKey = 'a21026'
        case 2:
          this.sensorKey = 'a21026'
          // this.bg = require('@/assets/images/tl_SO2.png')
          break
        case 3: this.sensorKey = 'a21004'
        case 3:
          this.sensorKey = 'a21004'
          // this.bg = require('@/assets/images/tl_NO2.png')
          break
        case 4: this.sensorKey = 'a21005'
        case 4:
          this.sensorKey = 'a21005'
          // this.bg = require('@/assets/images/tl_CO.png')
          break
        case 5: this.sensorKey = 'a05024'
        case 5:
          this.sensorKey = 'a05024'
          // this.bg = require('@/assets/images/tl_O3.png')
          break
        case 6: this.sensorKey = 'a99054'
        case 6:
          this.sensorKey = 'a99054'
          // this.bg = require('@/assets/images/tl_TVOCNew.png')
          break
        case 7: this.sensorKey = 'dustld'
        case 7:
          this.sensorKey = 'dustld'
          // this.bg = require('@/assets/images/tl_TVOCNew.png')
          break
      }
      this.initStart(this.carData)
      this.$nextTick(() => {
        this.getStart()
      })
      this.initStart()
    },
    changeCode1(index) {
    changeCode1 (index) {
      this.changeColor1 = index
      if (index === 0) {
        this.viewKey = '2D'
@@ -1416,7 +2021,7 @@
  margin: 0;
  z-index: 0;
  font-size: 14px;
  font-family: "微软雅黑";
  font-family: '微软雅黑';
}
.main_body {
@@ -1439,7 +2044,7 @@
  margin-top: -50px;
  z-index: 11;
  color: #000000;
  border: 2px solid #FF7F50;
  border: 2px solid #ff7f50;
  font-size: 28px;
  line-height: 100px;
  text-align: center;
@@ -1501,16 +2106,20 @@
  width: 100px;
  height: 200px;
}
.carTop {
.faterCar{
  position: absolute;
  width: 100%;
   z-index: 999;
  top: 0;
}
.carTop {
  width: 100%;
  padding: 5px 10px;
  z-index: 999;
  background: rgba(204, 204, 204, 0.5);
  box-shadow: 1px 1px 5px #666;
}
.carTop > .left,.right {
.carTop > .left,
.right {
  padding: 5px 10px;
  border: 1px solid #aaa;
  border-right: none;
@@ -1521,26 +2130,30 @@
  margin-top: 4px;
  -webkit-transform-origin-x: 0;
}
.carTop  .left:nth-child(1),.carTop  .right:nth-child(1) {
.carTop .left:nth-child(1),
.carTop .right:nth-child(1) {
  border-radius: 5px 0 0 5px;
}
.carTop  .left:nth-last-child(2),.carTop  .right:nth-child(2) {
.carTop .left:nth-last-child(2),
.carTop .right:nth-child(2) {
  border-radius: 0 5px 5px 0;
  border-right: 1px solid #aaa;
}
.carTop{
  &>.left:nth-child(1){
.carTop {
  & > .left:nth-child(1) {
    border-radius: 5px 0 0 5px;
  }
}
.carTop {
  .left{
    &:nth-last-child(2){
  .left {
    &:nth-last-child(2) {
      margin-left: -12px !important;
    }
  }
}
.carTop > .left:hover,.right:hover {
.carTop > .left:hover,
.right:hover {
  background: rgb(64, 158, 255);
  color: #fff;
}
@@ -1563,10 +2176,89 @@
  font-size: 28px;
  border: 2px solid #ff7f50;
}
.main_body .el-date-editor .el-range-input{
.main_body .el-date-editor .el-range-input {
  width: 30%;
}
.main_body /deep/ .el-date-editor .el-range-separator{
.main_body /deep/ .el-date-editor .el-range-separator {
  width: 15%;
}
/deep/ .BMapLabel .my-maptip {
  display: block !important;
  width: inherit;
  height: inherit;
  text-align: center;
  vertical-align: middle;
}
.insLu {
  border: 1px solid white;
  background-color: white;
  width: 20rem;
  height: 30rem;
  position: absolute;
  top: 3rem;
  left: 1rem;
  z-index: 99;
  display: none;
  padding: 0.5rem;
}
.statspan {
  font-size: 0.5rem;
  margin-top: 2rem;
}
.insLu div {
  margin-top: 0.8rem;
}
/deep/.inputNum {
  width: 5% !important;
}
.rightIcon{
  position: absolute;
  right: 0px;
  top: 300px;
  z-index: 999;
  cursor: pointer;
  font-size: 30px;
  color: #409eff;
}
.rankCar{
  float: right;
  p{
    text-align: center;
  }
  background: rgba(204, 204, 204, 0.5);
  box-shadow: 1px 1px 5px #666;
  padding: 5px;
  margin-top: 10px;
  ul{
    font-size: 16px;
    list-style: none;
    max-height: 800px;
    padding-bottom: 120px;
    overflow: auto;
    padding-left: 0;
    li{
      margin: 10px;
    }
  }
}
.success-checkmark:after {
  content: '×';
  position: absolute;
  left:0; top: -1px;
  width: 20px;
  height: 20px;
  text-align: center;
  border: 1px solid #aaa;
  background: #f8f8f8;
  border-radius: 50%;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
  cursor: pointer;
}
.rankCarItem{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
}
</style>