<template>
  <div class="date-right">
    <div>
      <div class="box-header-title">
        <div>巡检问题类型统计</div>
      </div>
      <div>
        <div :key="index" v-for="(item,index) in inspectQuestionCategoryList">
          <div :title="item.questionContent">{{item.questionContent}}</div>
          <el-progress :show-text="false" :stroke-width="0.15,fontSize | filterPx" color="#17B4AC"
                       :percentage="(item.questionNum/count)*100"></el-progress>
          <div>{{item.questionNum}}</div>
        </div>
      </div>
    </div>
    <div>
      <div class="box-header-title">
        <div>河湖水质问题分类统计</div>
      </div>
      <div>
        <cake v-if="waterAlarmCategoryList.length>0" :dataList="waterAlarmCategoryList" id="rightPre"
              :width="3.89,fontSize | filterPx" :height="2.254,fontSize | filterPx"></cake>
      </div>
    </div>
    <div>
      <div class="box-header-title">
        <div>水质污染程度统计</div>
        <div class="header-right">
          <div @click="activeClick('1')" :class="active==1?'header-right-div-active':void(0)" class="header-right-div">
            <span>当月</span></div>
          <div @click="activeClick('2')" :class="active==2?'header-right-div-active':void(0)" class="header-right-div">
            <span>三个月</span></div>
          <div @click="activeClick('3')" :class="active==3?'header-right-div-active':void(0)" class="header-right-div">
            <span>半年</span></div>
        </div>
      </div>
      <div>
        <div :style="{background:(index==1||index==3||index==5)?'#262a29':void(0)}" :key="index"
             v-for="(item,index) in tableData">
          <div>{{index+1}}</div>
          <div>
            <div :class="item.measuredStandard==5?'levelFour':'levelThree'">
              {{item.measuredStandard}}级
            </div>
          </div>
          <div :title="item.driverName">{{item.driverName}}</div>
          <div>{{item.driverAreaName}}</div>
          <div>{{item.measuredName}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {mapGetters} from "vuex";
  import cake from './cake'
  import api from '@/api/command/index'

  export default {
    name: "date-left",
    computed: {
      ...mapGetters(["fontSize"])
    },
    data() {
      return {
        count: 0,
        inspectQuestionCategoryList: [],
        waterAlarmCategoryList: [],
        tableData: [],
        active: '1',
        data: {
          a: 2673,
          b: 733,
          c: 573,
          d: 273,
          e: 673
        },
      }
    },
    components: {cake},
    props: {
      dataChild: {
        type: Object,
        default() {
          return
        }
      }
    },
    mounted() {
      this.getWaterAlarmInfoList()
    },
    watch: {
      dataChild: {
        deep: true,
        handler: function (newVal, oldVal) {
          const {waterAlarmCategoryList, inspectQuestionCategoryList} = newVal
          this.waterAlarmCategoryList = waterAlarmCategoryList ? waterAlarmCategoryList : []
          this.inspectQuestionCategoryList = inspectQuestionCategoryList ? inspectQuestionCategoryList : []
          let count = 0
          inspectQuestionCategoryList.map(item => {
            count += item.questionNum
          })
          this.count = count
          console.log(inspectQuestionCategoryList)
        }
      }
    },
    methods: {
      activeClick(active) {
        this.active = active
        this.tableData=[]
        this.getWaterAlarmInfoList()
      },
      getWaterAlarmInfoList() {
        api.getWaterAlarmInfoList(this.active).then(res => {
          this.tableData = res.data ? res.data : []
        }).catch(e => {
          this.tableData = []
        });
      }
    },
  }
</script>

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

    .header-right {
      display: flex;
      align-items: center;
      padding-right: 0.1rem;

      .header-right-div {
        width: 0.65rem;
        height: 0.24rem;
        line-height: 0.24rem;
        cursor: pointer;
        font-size: 0.12rem;
        color: #ffffff;
        margin-left: 0.05rem;
        background-color: #3A4040;
        border: 0.01rem solid #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.2rem;
      }

      .header-right-div-active {
        background-color: #2c6b6d;
        border-color: #0CD1D6;
      }
    }

    > div:first-child {
      margin-top: 0.15rem;
      padding-bottom: 0.05rem;

      > div:last-child {
        position: relative;
        height: 1.65rem;

        > div {
          margin-top: 0.16rem;
          display: flex;
          align-items: center;

          > div:first-child {
            width: 0.87rem;
            font-family: PingFangSC-Regular;
            font-size: 0.14rem;
            color: #FFFFFF;
            text-align: right;
            overflow: hidden;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
            white-space: nowrap;
          }

          > div:nth-child(2) {
            flex: 1;
            display: flex;
            align-items: center;
            margin-left: 0.086rem;

            .el-progress-bar {
              padding-right: 0rem;
              width: 100%;
              margin-right: -0rem;
            }

            .el-progress-bar__outer {
              background: #0B2221;
              border-radius: 0.085rem
            }
          }

          > div:last-child {
            width: 0.6rem;
            text-align: center;
            font-family: PingFangSC-Medium;
            font-size: 0.14rem !important;
            color: #17B4AC;
            line-height: 0.2rem;
          }
        }
      }
    }

    > div:nth-child(2) {
      margin-top: 0.2rem;

      > div:last-child {
        position: relative;
        padding: 0 0.2rem;
        height: 2.254rem;
      }
    }

    > div:last-child {

      > div:last-child {
        position: relative;
        padding: 0 0.1rem;

        > div {
          display: flex;
          font-family: PingFangSC-Regular;
          font-size: 0.14rem;
          color: #FFFFFF;
          line-height: 0.3rem;
          height: 0.3rem;

          > div {
            flex: 1;
            text-align: center;
          }

          > div:first-child {
            width: 0.36rem;
            text-align: left;
            flex: 0;
          }

          > div:nth-child(2) {
            > div {
              background-color: red;
              padding: 0.02rem 0.048rem;
              font-size: 0.12rem;
              display: inline;
            }

            .levelFour {
              background-color: #F70F30;
            }

            .levelThree {
              background-color: #F5A623;
            }

            .levelTwo {
              background-color: #F5D823;
            }
          }
          >div:nth-child(3),>div:nth-child(4){
            overflow: hidden;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
            white-space: nowrap;
          }
        }


        > div:nth-child(odd) {
          height: 0.487rem;
          line-height: 0.487rem;
        }
      }
    }
  }

</style>
