<template>
  <div class="main-data data-unit-access">
    <!-- <div class="title-area">各单位的接入情况</div> -->
    <div class="content-area">
      <div class="content-title">
        <span class="title">工程现场监控接入情况</span>
      </div>
      <div class="content">
        <div class="table-cont">
          <div class="table-top">
            <div class="fir">接入单位名称</div>
            <div class="snd">已接入项目数量</div>
            <div class="thd">已接入摄像头数量</div>
          </div>
          <div class="table-bot">
            <div class="table-list" v-for="(item,index) in monitorList" :key="index" @click="choose">
              <div class="said"></div>
              <div class="fir">{{item.name}}</div>
              <div class="snd">{{item.num}}</div>
              <div class="thd color">{{item.onLineNum}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BarChart from "@/components/Echarts/BarChart";
import LineChart from "@/components/Echarts/LineChart.vue";
import echarts from "echarts";
import { getProjectCameraNumList } from '@/api/screen/service'


export default {
  name: "UnitAccessTo",
  components: {
    LineChart,
    BarChart,
  },
  props:{
    appOrg: {
      type: String,
      default: "0000",
    },
  },
  watch:{
    appOrg(newVal, oldVal){
      // this.handleDataList();
      // this.handleUnitDataList();
      // this.handleCurrentArea();
      // this.handleOnlineData();
    }
  },
  data() {
    return {
      show: true,
      barData: [],
      barAxis: {},
      barYAxis: {},
      barGrid: {
        top: 30,
        left: "3%",
        right: "6%",
        containLabel: true,
        bottom: 0,
      },
      dataList: [
        {
          name: "接入单位数量",
          num: "56",
          unit: "个",
        },
        {
          name: "应接入项目数量",
          num: "56",
          unit: "个",
        },
        {
          name: "已接入项目数量",
          num: "56",
          unit: "个",
        },
        {
          name: "已接入摄像头数量",
          num: "56",
          unit: "个",
        },
        {
          name: "已接入摄像头在线数量",
          num: "56",
          unit: "个",
        },
        {
          name: "已接入摄像头在线率",
          num: "56",
          unit: "%",
        },
      ],
      lineData: [],
      lineAxis: {},
      lineYAxis: {
        name: "历史摄像头在线率",
        nameTextStyle: {
          color: "#fff",
          padding: [0, 0, 0, 30],
        },
        axisLabel: {
          color: "#FFF",
        },
        splitLine: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        splitArea: false,
      },
      onlineData: [],
      onlineAxis: {},
      onlineYAxis: {
        name: "历史摄像头数(个)",
        nameTextStyle: {
          color: "#fff",
          fontSize: 14,
          padding: [0,0,0,35]
        },
        axisLabel: {
          color: "#FFF",
        },
        splitLine: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        splitArea: false,
      },
      monitorList: [],
      unitDataList: [],
    };
  },
  created() {
    this.handleDataList();
    this.handleUnitDataList();
    this.handleCurrentArea();
    this.handleOnlineData();
    this.getProjectCameraNumList()
  },
  destroyed() {},
  beforeDestroy() {},
  mounted() {},
  methods: {
    getProjectCameraNumList(){
      getProjectCameraNumList(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          this.monitorList = res.data;
          this.monitorList.forEach((item, index) => {
            item.name = item.unitName;
            item.num = item.projectNum;
            item.onLineNum = item.cameraNum;
          });
        }
      });
    },
    choose(){
      this.$emit('chooseUnit')
    },
    handleDataList() {
      this.dataList = [];
      setTimeout(()=>{
        this.dataList = [
          {
            name: "接入单位数量",
            num: "56",
            unit: "个",
          },
          {
            name: "应接入项目数量",
            num: "56",
            unit: "个",
          },
          {
            name: "已接入项目数量",
            num: "56",
            unit: "个",
          },
          {
            name: "已接入摄像头数量",
            num: "56",
            unit: "个",
          },
          {
            name: "已接入摄像头在线数量",
            num: "56",
            unit: "个",
          },
          {
            name: "已接入摄像头在线率",
            num: "56",
            unit: "%",
          },
        ];
      },100)
    },

    //初始化
    handleUnitDataList() {
      let unitDataList = [];
      unitDataList.push({
        name: "国网山西省电力公司",
        num: 56,
        onLineNum: 46
      });
      unitDataList.push({
        name: "国网太原供电公司",
        num: 10,
        onLineNum: 8
      });
      unitDataList.push({
        name: "国网运城供电公司",
        num: 8,
        onLineNum: 4
      });
      unitDataList.push({
        name: "国网临汾供电公司",
        num: 7,
        onLineNum: 6
      });
      unitDataList.push({
        name: "国网晋城供电公司",
        num: 6,
        onLineNum: 6
      });
      unitDataList.push({
        name: "国网吕梁供电公司",
        num: 4,
        onLineNum: 3
      });
      unitDataList.push({
        name: "国网大同供电公司",
        num: 4,
        onLineNum: 3
      });
      this.unitDataList = unitDataList;
    },

    handleCurrentArea() {
      (this.lineData = [
        {
          name: "",
          type: "line",
          areaStyle: {
            opacity: 0.8,
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
              {
                offset: 0.03,
                color: "rgba(30, 240, 215, 0.4196)",
              },
              {
                offset: 0.68,
                color: "rgba(23, 240, 240, 0)",
              },
            ]),
          },
          lineStyle: {
            width: 2, // 设置线宽
            color: "#00FFFF", // 设置线的颜色
          },

          smooth: true,
          data: [40, 60, 80, 50],
        },
      ]),
        (this.lineAxis = {
          type: "category",
          data: ["0-6", "6-12", "12-18", "18-24"],
          axisLabel: {
            color: "white", // 设置横坐标轴字体颜色为红色
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            lineStyle: {
              color: "#465A64",
            },
          },
          boundaryGap: false,
        });
    },

    handleOnlineData() {
      (this.onlineData = [
        {
          name: "",
          type: "line",
          areaStyle: {
            opacity: 0.8,
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
              {
                offset: 0.03,
                color: "rgba(30, 240, 215, 0.4196)",
              },
              {
                offset: 0.68,
                color: "rgba(23, 240, 240, 0)",
              },
            ]),
          },
          lineStyle: {
            width: 2, // 设置线宽
            color: "#00FFFF", // 设置线的颜色
          },

          smooth: true,
          data: [40, 60, 80, 50],
        },
      ]),
        (this.onlineAxis = {
          type: "category",
          data: ["0-6", "6-12", "12-18", "18-24"],
          axisLabel: {
            color: "white", // 设置横坐标轴字体颜色为红色
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            lineStyle: {
              color: "#465A64",
            },
          },
          boundaryGap: false,
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.content-title {
  width: 100%;
  height: 26px;
  background: url("../../../assets/images/main/title_pro_long.png") no-repeat;
  background-size: 100% 100%;
  font-family: "PingFangSC";
  font-size: 16px;
  font-weight: bold;
  color: #00ffff;
  padding-left: 15px;
  .title {
    display: block;
    position: relative;
    top:-5px;
  }
}
.data-unit-access {
  height: 100%;
  overflow: hidden;
  .content-area {
    display: flex;
    flex-direction: column;
    padding: 15px 20px 0 15px;
  }

  .said{
    width: 1px;
    height: 13px;
    background-color: #00FFFF;
  }


  .content {
    width: 100%;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    .title-format {
      display: flex;
      flex-direction: row;
      align-items: center;
      img {
        width: 6px;
        height: 24px;
        margin-right: 6px;
      }
      .title-info {
        display: flex;
        flex-direction: column;
        font-size: 14px;
        color: #ffffff;
        .title-en {
          font-size: 8px;
          color: #ffffff;
          opacity: 0.4;
        }
      }
    }
    .total-data {
      display: flex;
      align-items: baseline;
      color: #19fcde;
      margin-top: 4px;
      .total {
        font-size: 35px;
        font-family: "electronicFont";
      }
      .unit {
        font-size: 12px;
      }
    }
    data-detail{
      align-items: center;
    }
    .data-list {
      display: flex;
      width: 100%;
      .data-item {
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 50%;
        margin-bottom: 11px;
        .data-detail {
          display: flex;
          flex-direction: row;
          align-items: center;
          color: #00ffff;
          margin-top: 11px;
          font-size: 12px;
          .data {
            font-size: 30px;
            font-family: "electronicFont";
          }
        }
      }
      .data-item:nth-child(3n) {
        margin-right: 0;
      }
    }

    .rate-area {
      position: relative;
      margin-left: 35px;
      img {
        width: 168px;
        height: 97px;
      }
      .rate {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        position: absolute;
        top: 0;
        left: -10px;
        color: #fff;
        .rate-data {
          display: flex;
          flex-direction: row;
          align-items: baseline;
          color: #ffba44;
          .data {
            font-size: 30px;
            font-family: "electronicFont";
          }
          .unit {
            font-size: 12px;
          }
        }
        .desc {
          font-size: 12px;
          text-align: center;
        }
      }
    }
    .chart-area{
      margin-top: 50px;
    }
  }
  .iaco{
    width: 58px;
    height:56px ;
    margin-left: 45px;
    margin-right: 5px;
  }

  .table-cont{
    width:100%;

    .table-top{
      width:100%;
      height: 26px;
      background: url("../../../assets/images/building_guarantee/img_11.png") no-repeat;
      background-size: 100% 100%;
      padding:0 25px 0 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size:14px;
      color:#00FFFF;
    }
    .table-bot{
      width:100%;

      .table-list{
        width:100%;
        height:30px;
        margin-top: 3px;
        padding:5px 25px 0 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size:14px;
        color:#FFFFFF;
        font-weight: 500;
      }
      .table-list:hover{
        cursor: pointer;
      }
    }

    .fir{
      width:40%;
      text-align: left;
      margin-left: 5px;
    }
    .snd{
      width:30%;
      text-align: left;
    }
    .thd{
      width:30%;
      text-align: left;
    }
  }

  ::-webkit-scrollbar {
    display: none;
    width: 3px;
    height: 3px;
  }

  ::-webkit-scrollbar-thumb {
    //滑块部分
    // border-radius: 5px;
    background-color: #58cbbb;
  }

  ::-webkit-scrollbar-track {
    //轨道部分
    // box-shadow: inset 0 0 5px #ddd;
    background: #ddd;
    // border-radius: 5px;
  }
}
</style>

