<template>
  <div v-loading="searchLoading" class="qualityLeft">
    <div>
      <img src="../../../assets/img/command/head-quality.png"/>
    </div>
    <div>
      <div @click="activeTypeClick(1)" :class="activeType==1?'check-type':''">单条河流分析</div>
      <div @click="activeTypeClick(2)" :class="activeType==2?'check-type':''">多条河流分析</div>
    </div>
    <div>
      <el-select v-model="searchValue" multiple placeholder="">
        <el-option
          v-for="item in driverList"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
      <div>快速对比</div>
    </div>
    <div v-show="activeType==2">
      <div @click="childTypeClick(1)" :class="childType==1?'child-type-check':''">BOD</div>
      <div @click="childTypeClick(2)" :class="childType==2?'child-type-check':''">TP</div>
      <div @click="childTypeClick(3)" :class="childType==3?'child-type-check':''">TN</div>
      <div @click="childTypeClick(4)" :class="childType==4?'child-type-check':''">TH3</div>
      <div @click="childTypeClick(5)" :class="childType==5?'child-type-check':''">COD</div>
    </div>
    <div>
      <div>
        <div>河流同比分析</div>
        <el-select :class="month?'check-select':void(0)" style="width: 1rem" v-model="month" placeholder="">
          <el-option
            v-for="item in monthList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </div>
      <div>
        <div>数量（次）</div>
        <cLine
          id="topLine"
          :width="4.19,fontSize | filterPx"
          :height="2.415,fontSize | filterPx"
        ></cLine>
      </div>
    </div>
    <div>
      <div>
        <div>河流环比分析</div>
        <el-date-picker
          :clearable="false"
          style="width: 1.8rem"
          v-model="date"
          :class="(date.length>0)?'check-select':''"
          type="monthrange"
          value-format="yyyy-MM"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </div>
      <div>
        <div>数量（mg/L）</div>
        <cLine
          id="bottomLine"
          :width="4.19,fontSize | filterPx"
          :height="2.415,fontSize | filterPx"
        ></cLine>
      </div>
    </div>
  </div>
</template>

<script>
  import {mapGetters} from "vuex";
  import cLine from './line'

  export default {
    name: "qualityLeft",
    data() {
      return {
        monthList:[
          {value:1,label:'一月'},
          {value:2,label:'二月'},
          {value:3,label:'三月'},
          {value:4,label:'四月'},
          {value:5,label:'五月'},
          {value:6,label:'六月'},
          {value:7,label:'七月'},
          {value:8,label:'八月'},
          {value:9,label:'九月'},
          {value:10,label:'十月'},
          {value:11,label:'十一月'},
          {value:12,label:'十二月'},
        ],
        date:['2020-01','2020-05'],
        driverList: [],
        searchLoading: false,
        addVisible: false,
        searchValue: '',
        month:new Date().getMonth()+1,
        activeType: 1,
        childType: 1,
        visible: false
      }
    },
    computed: {
      ...mapGetters(["fontSize"])
    },
    components: {cLine},
    watch: {
      driverId() {
        if (this.driverId) {
          this.searchValue = this.driverId
          this.search()
        }
      }
    },
    props: {
      driverId: {
        type: String,
        default() {
          return ''
        }
      }
    },
    mounted() {
      this.search()
    },
    methods: {
      activeTypeClick(activeType) {
        this.activeType = activeType
        this.search()
      },
      childTypeClick(childType){
        this.childType=childType
        this.search()
      },
      showProblemDetail(item) {
        this.$emit('showProblemDetail', {id: 1, driverId: 27})
      },
      addClick() {
        this.$emit('askClear', this.driverId)
        this.addVisible = true
      },
      successSubmit() {
        this.addVisible = false
        this.search()
      },
      search() {
        let me = this
        this.searchLoading = true
        me.$emit('qualityClear', me.driverId)
        setTimeout(function () {
          me.searchLoading = false
        }, 2000)
      }
    },
  }
</script>

<style lang="less">
  .qualityLeft {
    position: absolute;
    top: 1.25rem;
    width: 4.27rem;
    background-color: rgba(0, 0, 0, 0.6);
    height: 100%;
    padding-left: 0.26rem;
    padding-right: 0.27rem;


    > div:first-child {
      margin-top: 0.1rem;
      width: 100%;
      height: 0.47rem;
      display: flex;
      align-items: center;
      justify-content: space-between;

      > img {
        width: 1.33rem;
        height: 100%;
      }
    }

    > div:nth-child(2) {
      margin-top: 0.075rem;
      display: flex;

      > div {
        background: #2E2E2E;
        font-family: PingFangSC-Regular;
        font-size: 0.18rem;
        color: #FFFFFF;
        line-height: 0.25rem;
        border: 0.02rem solid #2E2E2E !important;
        height: 0.44rem;
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
      }

      .check-type {
        background: rgba(54, 184, 179, 0.50) !important;
        border: 0.02rem solid #36B8B3 !important;
      }

    }

    > div:nth-child(3) {
      margin-top: 0.202rem;
      display: flex;
      justify-content: space-between;

      .el-select {
        flex: 1;
      }

      .el-input__inner {
        border: none;
        background-color: #3D3D3D;
        color: #FFFFFF;
        font-family: PingFangSC-Regular;
        font-size: 0.16rem;
        height: 0.36rem;
        line-height: 0.36rem;
        opacity: 1;
      }

      > div:last-child {
        background: rgba(42, 136, 132, 0.50);
        border: 0.02rem solid #36B8B3;
        font-family: PingFangSC-Regular;
        font-size: 0.16rem;
        width: 0.84rem;
        height: 0.32rem;
        color: #FFFFFF;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 0.07rem;
      }
    }

    > div:nth-child(4) {
      margin-top: 0.22rem;
      display: flex;
      justify-content: space-between;

      > div {
        height: 0.32rem;
        width: 0.72rem;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #2E2E2E;
        font-family: PingFangSC-Regular;
        font-size: 0.16rem;
        color: #FFFFFF;
        line-height: 0.22rem;
        border: 0.02rem solid #2E2E2E !important;
        cursor: pointer;
      }

      .child-type-check {
        background: rgba(54, 184, 179, 0.30) !important;
        border: 0.02rem solid #36B8B3 !important;
      }
    }

    > div:nth-child(5),div:nth-child(6) {
      margin-top: 0.22rem;
      >div:first-child{
        display: flex;
        justify-content: space-between;
        align-items: center;
        >div:first-child{
          font-family: PingFangSC-Medium;
          font-size: 0.18rem;
          color: #FFFFFF;
          line-height: 0.25rem;
        }
        >div:last-child{
          display: flex;
          justify-content: flex-end;
        }
      }
      >div:last-child{
        margin-top: 0.1rem;
        position: relative;
        >div:first-child{
          position: absolute;
          top: 0.3rem;
          left: 0.5rem;
          opacity: 0.8;
          font-family: PingFangSC-Regular;
          font-size: 0.12rem;
          color: #FFFFFF;
        }
      }
    }

    >div:nth-child(6){
      .el-input__icon{
        display: none;
      }
      .el-input__inner{
        background: rgba(54,184,179,0.41);
        border: 0.01rem solid #36B8B3;
      }
    }
    .check-select{
      .el-input__inner {
        background: rgba(54,184,179,0.41);
        border: 0.01rem solid #36B8B3;
      }
    }

  }

</style>
