<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2023-12-28 16:34:51
 * @LastEditors: 纪泽龙 jizelong@qq.com
 * @LastEditTime: 2024-01-02 10:49:18
 * @FilePath: /tianhua-web/src/views/indexcomponents/index/Right/components/Bottom.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="r-bottom flex-d-b bb">
    <div class="top">
      <CharsBarT :charsArr="charsArr" />
    </div>
    <div class="bottom flex-b">
      <div v-for="item in bData" :key="item.title" class="item">
        <div class="t">{{ item.title }}</div>
        <div class="b flex-d-b bb">
          <div v-for="iten in item.list" :key="iten.l" class="i flex-b">
            <div class="l">{{ iten.l }}</div>
            <div class="r">{{ iten.r }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import CharsBarT from "@/components/CharsCom/CharsBarT.vue";
import { dangerStatistic } from "@/api/screenstatistic/statistic.js";

export default {
  name: "",
  components: {
    CharsBarT,
  },
  data() {
    return {
      charsArr: [
        {
          value: 0,
          value2: "0",
          name: "居民用户",
        },
        {
          value: 0,
          value2: "0",

          name: "餐饮用户",
        },
        {
          value: 0,
          value2: "0",
          name: "工业用户",
        },
      ],
      bData: [
        {
          title: "管道隐患",
          list: [
            {
              l: "待处理",
              r: 0,
            },
            {
              l: "待复核",
              r: 0,
            },
            {
              l: "已处理",
              r: 0,
            },
          ],
        },
        {
          title: "设备隐患",
          list: [
            {
              l: "待处理",
              r: 0,
            },
            {
              l: "待复核",
              r: 0,
            },
            {
              l: "已处理",
              r: 0,
            },
          ],
        },
        {
          title: "场站隐患",
          list: [
            {
              l: "待处理",
              r: 0,
            },
            {
              l: "待复核",
              r: 0,
            },
            {
              l: "已处理",
              r: 0,
            },
          ],
        },
      ],
    };
  },
  mounted() {
    this.dangerStatistic().then((res) => {
      console.log("yh,", res);
      if(res.data.totalNum == 0) return;
      console.log("dsfdsfdsf[[[[",this.charsArr)
      const {
        residentNum,
        busiNum,
        factoryNum,
        totalNum,

        pipeCheckNum,
        pipeDealNum,
        pipeToDoNum,
        devCheckNum,
        devDealNum,
        devToDoNum,
        stationCheckNum,
        stationDealNum,
        stationToDoNum,
      } = res.data;
      let d = residentNum + busiNum + factoryNum;
      let a, b, c;
      a = parseInt((residentNum / d) * 100);
      b = parseInt((busiNum / d) * 100);
      c = factoryNum ? 100 - (a + b) : 0;
      console.log(a, b, c);
      this.charsArr = [
        {
          value: residentNum,
          value2: a,
          name: "居民用户",
        },
        {
          value: busiNum,
          value2: b,
          name: "餐饮用户",
        },
        {
          value: factoryNum,
          value2: c + "",
          name: "工业用户",
        },
      ];

      this.bData = [
        {
          title: "管道隐患",
          list: [
            {
              l: "待处理",
              r: pipeToDoNum,
            },
            {
              l: "待复核",
              r: pipeCheckNum,
            },
            {
              l: "已处理",
              r: pipeDealNum,
            },
          ],
        },
        {
          title: "设备隐患",
          list: [
            {
              l: "待处理",
              r: devToDoNum,
            },
            {
              l: "待复核",
              r: devCheckNum,
            },
            {
              l: "已处理",
              r: devDealNum,
            },
          ],
        },
        {
          title: "场站隐患",
          list: [
            {
              l: "待处理",
              r: stationToDoNum,
            },
            {
              l: "待复核",
              r: stationCheckNum,
            },
            {
              l: "已处理",
              r: stationDealNum,
            },
          ],
        },
      ];
    });
  },
  methods: {
    dangerStatistic() {
      return dangerStatistic();
    },
  },
};
</script>
<style lang="scss" scoped>
.r-bottom {
  height: 100%;
  padding-top: 18px;

  // justify-content: space-between;
}
.top {
  width: 100%;
  height: 100px;
  margin-bottom: 10px;
}
.bottom {
  flex: 1;
  margin-left: 12px;
  .item {
    position: relative;
    .t {
      position: absolute;
      z-index: 10;
      width: 110px;
      left: 5px;
      height: 28px;
      background: url("~@/assets/indexImg/bbg.png") no-repeat center;
      text-align: center;
      color: #fff;
      line-height: 28px;
    }
    .b {
      position: relative;
      top: 14px;
      width: 120px;
      height: 112px;
      border: 1px solid #043a5c;
      border-top: none;
      color: #fff;
      padding: 25px 12px;
      padding-bottom: 10px;
      .i {
        align-items: center;
        // margin-bottom: 8px;
        .l {
          font-size: 16px;
        }
        .r {
          font-weight: 600;
        }
        &:nth-child(1) {
          .r {
            color: #2cffff;
          }
        }
        &:nth-child(2) {
          .r {
            color: #ff6464;
          }
        }
        &:nth-child(3) {
          .r {
            color: #39b1f6;
          }
        }
      }
    }
  }
}
</style>
