<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2025-12-20 09:31:30
 * @LastEditors: 纪泽龙 jizelong@qq.com
 * @LastEditTime: 2026-01-15 14:32:30
 * @FilePath: /test-ranqi/src/views/Ind/components/Left.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="left">
    <div class="t">
      <Title text="管线长度" text2="单位（米）" />
      <div class="gxbox">
        <div v-for="item in itemArr" :key="item.text" class="gxbox-item">
          <div class="num">{{ item.num }}</div>
          <div class="text">{{ item.text }}</div>
        </div>
      </div>
    </div>

    <div class="lb">
      <Title text="设备及场站" />
      <div class="lba lbamt">
        <div class="box-a">设备统计</div>
        <div class="box-b">
          <div class="fa">
            <div class="faa">{{ deviceTotal }}</div>
            <div class="fab">总量</div>
            <div class="fac"></div>
          </div>
          <div class="fb">
            <PressureBarChart :data="pressureData" />
          </div>
        </div>
      </div>

      <div class="lba">
        <div class="box-a">场站统计</div>
        <div class="box-b">
          <div class="fa">
            <div class="faa">{{ stationTotal }}</div>
            <div class="fab">总量</div>
            <div class="fac"></div>
          </div>
          <div class="fb">
            <PressureBarChart :data="pressureData2" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Title from "@/views/bigWindow/PubCom/title.vue";
import PressureBarChart from "@/views/bigWindow/Ind/components/PressureBarChart.vue";
import { totalNumStatisticByType } from "@/api/screenstatistic/statistic";
export default {
  name: "",
  components: {
    Title,
    PressureBarChart,
  },
  data() {
    return {
      itemArr: [
        {
          num: 0,
          text: "高压",
        },
        {
          num: 0,
          text: "次高",
        },
        {
          num: 0,
          text: "中压",
        },
        {
          num: 0,
          text: "低压",
        },
      ],
      pressureData: [],
      pressureData2: [],
      deviceTotal: 0,
      stationTotal: 0,
    };
  },
  mounted() {
    this.getTotalNumInfo();
  },
  methods: {
    getTotalNumInfo(){
      totalNumStatisticByType().then(res =>{
        if(res.code == 200){
          let data = res.data;
          //管线
          let pipeLengthInfo = data.pipeLengthInfo;
          if(pipeLengthInfo){
            pipeLengthInfo.forEach(item =>{
              let info = this.itemArr[item.type-1];
              info.num = item.totalLength;
            })
          }
          //设备
          let deviceNumInfo =  data.deviceNumInfo;
          if(deviceNumInfo) this.pressureData = deviceNumInfo;
          this.deviceTotal = this.pressureData ? this.pressureData.map(item => item.value).reduce((sum, num) => sum + num, 0) : 0;
          //场站
          let stationNumInfo = data.stationNumInfo;
          if(stationNumInfo) this.pressureData2 = stationNumInfo;
          this.stationTotal = this.pressureData2 ? this.pressureData2.map(item => item.value).reduce((sum, num) => sum + num, 0)  : 0;
        }
      })
    },
  },
};
</script>
<style lang="scss" scoped>
.left {
  overflow: hidden;
  // width: 20%;
  width: 434px;
  top: 102px;
  bottom: 50px;
  // background: url("~@/assets/bigwindowImg/index/l.png") no-repeat center;

  // background-size: 100% 100%;
  // border: 1px solid red;

  position: absolute;
  left: 10px;
  z-index: 9999;
}
.t {
  margin-bottom: 40px;
}
.gxbox {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  .gxbox-item {
    width: 90px;
    height: 106px;
    background: url("~@/assets/bigwindowImg/indImg/itemBg.png") no-repeat center;
    padding-top: 5px;
    > div {
      color: #fff;
      text-align: center;
    }
    .num {
      font-size: 24px;
      margin-bottom: 2px;
    }
    .text {
      font-size: 14px;
    }
  }
}
.lbamt {
  margin-top: 42px;
}
.lba {
  height: 152px;
  margin-bottom: 80px;
  .box-a {
    width: 172px;
    height: 36px;
    background: url("~@/assets/bigwindowImg/indImg/boxabg.png") no-repeat;
    background-size: 100% 100%;
    text-align: center;
    line-height: 36px;
    color: #fff;
    margin-bottom: 12px;
  }
  .box-b {
    width: 100%;
    height: 130px;
    display: flex;
    justify-content: space-between;

    .fa {
      width: 155px;
      height: 124px;
      color: #fff;
      text-align: center;
      padding-top: 15px;
      .faa {
        position: relative;
        font-size: 30px;
      }
      .fab {
        position: relative;
        z-index: 99;
        font-size: 20px;
      }
      .fac {
        position: relative;
        top: -55px;
        width: 100%;
        height: 100px;
        background: url("~@/assets/bigwindowImg/indImg/fabg.png") no-repeat;
      }
    }
    .fb {
      flex: 1;
    }
  }
}
</style>
