quanyawei
2024-07-04 8b29471e308be57255389b08bbc90ab33ea04584
fix: 道路尘负荷排名
1 files modified
530 ■■■■ changed files
src/views/car/index.vue 530 ●●●● patch | view | raw | blame | history
src/views/car/index.vue
@@ -39,211 +39,197 @@
              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
            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'"
            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>-->
        <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 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>
          <el-button
            type="primary"
            size="small"
            style="margin-left: 1.5rem"
            @click="insertL"
          >
            添加
          </el-button>
          <el-input
            v-model="inputnum"
            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"
            <span
              v-if="webSocketView"
              style="margin: 2px 10px 0 0"
            >
              <el-button
                slot="trigger"
                size="small"
                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>
              <div
                slot="tip"
                class="el-upload__tip"
                style="color: red"
                <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>
            </el-upload>
            <!-- <div style="display: flex">
              <span class="statspan">开始点的时间:</span
              ><el-input v-model="startL" style="width: 12rem"></el-input>
              <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>
            <div style="display: flex">
              <span class="statspan">结束点的时间:</span
              ><el-input v-model="endL" style="width: 12rem"></el-input>
            </div>
            <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> -->
            <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"
            style="float: right; margin-right: 10px"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="dateChange"
          />
          <!-- 历史/实时切换下拉框 -->
          <el-select
            v-model="dataTypeValue"
            placeholder="数据类型"
            style="
              float: right;
            <el-date-picker
              v-model="dateValue"
              size="mini"
              style=" margin-right: 10px"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              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>
          </div>
          <div
            v-if="!rankListShow & noneDustldData"
            class="rightIcon"
            @click="showRankList"
          >
            <el-option
              v-for="item in dataTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
            <i class="el-icon-s-fold" />
          </div>
          <div v-if="rankListShow">
            <!--                -->
            <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.value }}
                      </div>
                    </div>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
        <div
          v-if="noneData"
@@ -258,18 +244,6 @@
        <!-- 百度地图 -->
      </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>
    <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"
@@ -690,7 +664,9 @@
      },
      sensorDate: null,
      noneData: false,
      noneDustldData: false,
      defaultData: [],
      rankList: [],
      carMac: null,
      dialogFormVisible: false,
      sensorTableData: [
@@ -803,6 +779,7 @@
      dataTypeValue: 'history',
      historyView: true,
      webSocketView: false,
      rankListShow: false,
      isDataList: [],
      shapeLayer: null,
      carData: null,
@@ -844,25 +821,6 @@
    },
    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 () {
    // this.$watch('carMac', () => {
@@ -878,9 +836,6 @@
    this.newTime(this.timeValue)
    this.newDate()
    this.getCarData()
    // this.$watch('carMac', () => {
    //   this.getMacDate()
    // })
  },
  methods: {
    handleRemove (file, fileList) {
@@ -900,20 +855,7 @@
      // 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.Lname === '') {
        this.$message({
          message: '请输入路段名',
          type: 'warning'
@@ -932,20 +874,6 @@
      var times = this.newTime2(this.dateValue)
      const formData = new FormData()
      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])
@@ -1008,12 +936,6 @@
    },
    // 跳转设备详情页
    deviceDetail (mac, item, items, indexs) {
      // console.log('这是传输过去的值')
      // console.log(mac)
      // console.log(item)
      // console.log(items)
      // console.log(indexs)
      // this.monitorPointInfo = item
      this.$router.push({
        name: 'deviceDetail',
        // path: '/carDetail',
@@ -1150,24 +1072,6 @@
        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 () {
      // 更改时间格式
@@ -1229,6 +1133,9 @@
        }
      }
    },
    showRankList () {
      this.rankListShow = !this.rankListShow
    },
    // 走航车轨迹数据
    getStart () {
      this.noneData = false
@@ -1260,6 +1167,27 @@
        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)
        }
      })
    },
@@ -2167,12 +2095,15 @@
  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;
}
@@ -2270,4 +2201,53 @@
/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>