<template>
  <div class="main-data unit-dialog-area" @click.stop="preventDefault" @mouseleave="leaveFun">
    <div class="dialog-title">
      <img
        src="@/assets/images/main/cont_title_bg.png"
      />
      <div class="title">物业巡更信息</div>
    </div>
    <div class="dialog-cont">
      <div class="dialog-left">

        <div class="dialog-list">
          <div class="dialog-item wid100">
            <div class="content-title">
              <span class="title">巡更次数统计（近6月）</span>
            </div>
            <div class="charts-cont">
                  <bar-chart
                    :chart-data="electricityAreaBarData"
                    :x-axis="electricityAreaBarAxis"
                    :yAxis="electricityAreaBarYaxis"
                    y-color="#FFF"
                    l-color="#FFF"
                    width="515px"
                    height="200px"
                  />
               </div>
          </div>
        </div>

        <!-- 巡更及时率 -->
        <div class="dialog-list">
            <div class="dialog-item wid100">
              <div class="content-title">
                <span class="title">巡更及时率（近6月）</span>
              </div>
              <div class="content">
                <line-chart
                  :chart-data="lineData"
                   :x-axis="lineAxis"
                   :yAxis="lineYAxis"
                     :legend="lineLegend"
                    y-color="#FFF"
                    l-color="#FFF"
                    width="515px"
                    height="200px"
                  />
              </div>
          </div>
        </div>

               <!-- 巡更点统计-->
               <div class="dialog-list">
            <div class="dialog-item wid100">
              <div class="content-title">
                <span class="title">巡更点统计</span>
              </div>
              <div class="tank">
               <div class="ocBox">
                    <!-- 水箱 -->
                    <div class="leftTank"></div>
               </div>
               <div class="ocBox">
                <div class="table-cont">
                <div class="table-top">
                  <div class="flo">楼层</div>
                  <div class="pot">点位数</div>
                </div>
                <div class="table-bot">
                  <div class="table-list" v-for="(item,index) in floorDataList" :key="index">
                    <div class="fir">{{item.floor}}</div>
                    <div class="snd">{{item.number}}</div>
                  </div>
                </div>
              </div>
               </div>
            </div>
          </div>
        </div>



      </div>
    </div>
  </div>
</template>

<script>
import LineChart from "@/components/Echarts/LineChart";
import PieChart from "@/components/Echarts/PieChart";
import BarChart from "@/components/Echarts/BarChart.vue";
import echarts from "echarts";
import RaddarChart from "@/components/Echarts/RaddarChart.vue";
import {frequency,patrol,patrolPoint} from "@/api/screen/service";

export default {
  name: "UnitMonitorDialog",
  components: {
    RaddarChart,
    BarChart,
    PieChart,
    LineChart,
  },
  props: {
    monitorName:{
      type: String,
      default: ''
    },
    appOrg: {
      type: String,
      default: "0000",
    },
  },
  watch:{
    monitorName(newValue,oldValue){
      console.log(newValue, oldValue, "+++++")
      this.getMonitorList();
    },
    appOrg(){
      this.getMonitorList();
      this.handleUnitDataList();
    }
  },
  data() {
    return {
          //巡更次数
     electricityAreaBarData: [],
      electricityAreaBarAxis: {},
      electricityAreaBarYaxis: {
        type: "value",
        boundaryGap: [0, 0.01],
        name: '单位: 次',
        nameTextStyle: {
          color: '#fff',
          padding: [0,0,0,30]
        },
        axisLine:{
          lineStyle:{
            color:"#465A64"
          }
        },
        axisLabel: {
          color: "white", // 设置横坐标轴字体颜色为红色
        },
        splitLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        splitArea:false
      },
      lineLegend: {
          top: 0,
          orient: "horizontal",
          right: 0,
          itemWidth: 17, // 设置图例标记的宽度
          itemHeight: 10, // 设置图例标记的高度
          textStyle: {
            color: "#FFF",
          },
        },
        //巡更及时率
        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,
      },
      cityNameList: ['长治市', '交城县', '晋中市', '岚县', '吕梁市', '平遥县', '寿阳县', '营销服务中心'],
      cityCodeList: ['changzhi', 'jiaocheng', 'jinzhong', 'lanxian', 'lvliang', 'pingyao', 'shouyang', 'yingxiao'],
      raddarData: [
        {
          name: '',
          type: 'radar',
          data: [
            {
              value: [10, 20, 30, 40, 50, 60],
              areaStyle: {
                color: '#43DCDB'
              }
            }
          ]
        },
      ],
    
       //巡更点统计
       floorDataList: [],
    };
  },
  created() {
    //巡更次数统计(近6月)
    this.frequency();
    //巡更点统计
    this.patrolPoint();
    this.patrol();
  
    this.handleUnitDataList();
  },
  destroyed() {},
  beforeDestroy() {},
  mounted() {},
  methods: {
     //巡更次数统计(近6月)
     frequency() {
      frequency(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          this.electricityAreaBarAxis = {
            type: "category",
            data: res.data.xList,
            axisLabel: {
              color: "white", // 设置横坐标轴字体颜色为红色
              rotate: 0,
              interval: 0
            },
            axisLine: {
              show: true
            },
            axisTick: {
              show: false,
            },
            splitArea: false
          };
          this.electricityAreaBarData = [
            {
              data: res.data.yList,
              type: "bar",
              barWidth: 30,
              itemStyle: {
                color: {
                  type: 'linear',
                  x: 0, //右
                  y: 0, //下
                  x2: 0, //左
                  y2: 1, //上
                  colorStops: [
                    {
                      offset: 0,
                      color: '#FCE0BB' // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: '#D47F1C' // 100% 处的颜色
                    }
                  ]
                }
              },
            },
          ];
        } else {
          //构造默认数据

        }
      });
    },
     // 巡更点统计
     patrolPoint() {
      patrolPoint(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          this.floorDataList=res.data;
        }
      });
    },
    // 巡更及时率
    patrol() {
      patrol(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
      (this.lineData = [
       {
          name: "巡更及时率",
          type: "line",

          symbol: "none",
          areaStyle: {
            opacity: 0.8,
            color: new echarts.graphic.LinearGradient(0, 5, 15, 20, [
              {
                offset: 0.95,
                color: "#645727",
              },

              {
                offset: 0.98,
                color: "rgba(23, 240, 240, 0)",
              },
            ]),
          },
          lineStyle: {
            width: 2, // 设置线宽
            color: "#D67C15", // 设置线的颜色
          },

          smooth: true,

          data: res.data.patrolArray,
        },
      ]),
        (this.lineAxis = {
          type: "category",
          data: res.data.monthArray,
          axisLabel: {
            color: "white", // 设置横坐标轴字体颜色为红色
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            lineStyle: {
              color: "#465A64",
            },
          },
          boundaryGap: false,
        });
      }
      });
    },

   

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

     //鼠标移出
     leaveFun(){
      setTimeout(()=>{
        this.$emit("closeDialog")
      },200)
    },

    preventDefault() {
      console.log(11)
    },

  
   
  },
};
</script>

<style lang="scss">
.unit-dialog-area {
  overflow: hidden;
  width: 580px;
  height:920px;
  background: url("../../../assets/images/main/main_bg.png") no-repeat;
  background-size: cover;
  padding: 19px 15px 11px 15px;

  .dialog-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 10px;
    img {
      width: 284px;
      height: 32px;
    }
    .title {
      font-size: 20px;
      font-weight: 900;
      font-family: "PingFangSC";
      width: 100%;
      position: absolute;
      display: flex;
      align-items: center;
      justify-content: center;
      top: -5px;
      color: #fff;
    }
  }

  .dialog-cont {
    width:100%;
    height: 850px;
    padding: 15px;
    overflow-y: scroll;
    background: url("../../../assets/images/main/components_long_bg.png") no-repeat;
    background-size: cover;

    .dialog-left{
      width: 520px;
      float: left;
    }
    .dialog-right{
      width: 520px;
      float: right;
    }
  }

  .dialog-list{
    width: 100%;
    display: flex;
    justify-content: space-between !important;
    margin-bottom:20px;

    .dialog-item{
      width: calc(50% - 20px);
    }

    .dialog-item-cont{
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top:40px;
    }

    .wid100{
      width:100%;

      .content-title{
        width:100%;
        background: url("../../../assets/images/main/title_pro_long.png") no-repeat;
      }
    }
  }

  .content-title {
    width: 100%;
    height: 26px;
    background: url("../../../assets/images/main/title_pro.png") no-repeat;
    background-size: 100% 100%;
    font-family: "PingFangSC";
    font-size: 16px;
    font-weight: bold;
    color: #00ffff;
    padding-left: 25px;
    .title {
      display: block;
      position: relative;
      top:-5px;
    }
  }

  .content {
    margin-top: 20px;
    .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: 12px;
        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: 40px;
        font-family: 'electronicFont';
      }
      .unit {
        font-size: 12px;
      }
    }
    .data-content{
      display: flex;
      flex-direction: row;
      align-items: center;
      flex-wrap: wrap;
      .data-item{
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin-right: 24px;
        img{
          width: 89px;
          height: 82px;
        }
        .desc{
          font-size: 14px;
          color: #FFFFFF;
          margin-top: 7px;
          opacity: 0.4;
        }
        .data{
          position: absolute;
          top:20px;
          left:0;
          width: 89px;
          font-size: 30px;
          display: flex;
          align-items: center;
          justify-content: center;
          color:#19fcde;
          font-family: 'electronicFont';
        }
      }
      .data-item:nth-child(2n){
        margin-right: 0;
      }
    }
    .data-list {
      display: flex;
      flex: 1;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      .data-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        border-right: 1px solid rgba(25, 252, 222, 0.2);
        .data-detail {
          display: flex;
          flex-direction: row;
          align-items: baseline;
          color: #00ffff;
          margin-top: 11px;
          font-size: 12px;
          .data {
            font-size: 30px;
            font-family: 'electronicFont';
          }
        }
      }
      .data-item:last-child {
        border-right: none;
      }
    }
    .rate-area{
      position: relative;
      img{
        width: 198px;
        height: 114px;
      }
      .rate{
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        color: #FFF;
        .rate-data{
          display: flex;
          flex-direction: row;
          align-items: baseline;
          color: #FFBA44;
          .data{
            font-family: 'electronicFont';
            font-size: 30px;
          }
          .unit{
            font-size: 12px;
          }
        }
        .desc{
          font-size: 12px;
          width: 58px;
          text-align: center;
        }
      }
    }
  }

  .tank{
    display: flex;
    height: 245px;
    .ocBox{
      width: 50%;

  .leftTank{
    height: 260px;
    background: url("../../../assets/images/building_guarantee/xpsota.png") no-repeat;
    margin: 10px 10px 10px 10px;
  }
  .table-cont{
    width:100%;

    .table-top{
      width:100%;
      height: 50px;
      background-color: #092B2C;
      padding:0 25px 0 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size:18px;
      color:#00FFFF;
    }
    .table-bot{
      width:100%;
      height: 165px;
      overflow: scroll;

      .table-list{
        width:100%;
        height:40px;
        padding:15px 25px 15px 0px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size:16px;
        color:#FFFFFF;
        font-weight: 500;
        //border: 1px dotted #14302F;
      }
    }
    .flo{
      width:50%;
      text-align: center;
    }
    .pot{
      width:50%;
      text-align: center;
    }


    .fir{
      width:50%;
      text-align: center;
      border-left: 1px solid #40E5F2;
    }
    .snd{
      width:50%;
      text-align: center;
    }

    // .color{
    //   color:#FF8C00;
    // }
  }

    }

  }
  .other-cont{
    display: flex;

    .icon{
      display: block;
      width:70px;
      height:auto;
    }
    .other-info{
      padding-left:2px;

      .desc{
        font-size:12px;
        color:#FFFFFF;
        font-weight: bold;
      }
      .num-info{
        width:100%;
        padding-top:2px;
        display: flex;
        align-items: center;

        .num{
          font-size:30px;
          color:#19FCDE;
          font-weight: bold;
          font-family: "electronicFont";
        }
        .unit{
          font-size:12px;
          color:#00FFFF;
          font-weight: 500;
          position: relative;
          top:4px;
        }
        .mar{
          margin-left: 20px;
        }
      }
    }
  }

  .use-energy{
    width:100%;
    padding:0 15px;

    .use-energy-fir{
      width:100%;
      display: flex;
      align-items: center;
      font-size:14px;
      color:#FFFFFF;
      font-weight: 500;

      .num{
        font-weight: 900;
        color:#00FFFF;
        padding:0 8px;
      }
    }

    .use-energy-snd{
      width:100%;
      margin-top:15px;
      display: flex;
      align-items: center;

      .use-energy-snd-list{
        display: flex;
        align-items: center;

        .icon{
          display: block;
          width:34px;
          height: 34px;
        }
        .use-energy-snd-info{
          padding-left: 4px;

          .desc{
            font-size: 12px;
            color:#FFFFFF;
          }
          .num-info{
            display: flex;
            align-items: center;

            .num{
              font-size: 24px;
              color: #19FCDE;
              font-weight: bold;
              font-family: "electronicFont";
            }
            .unit{
              font-size:12px;
              color:#00FFFF;
              font-weight: 500;
              position: relative;
              top:4px;
              left:2px;
            }
          }
        }
      }
      .use-energy-snd-list:last-child{
        margin-left: 36px;
      }
    }
  }

  .circle-cont{
    width:100%;
    display: flex;
    flex-wrap: wrap;
    padding:0 15px;

    .circle-list {
      width:80px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-bottom: 10px;

      .name{
        font-size:12px;
        color:#FFFFFF;
        font-weight: 500;
        padding-top:6px;
        width:100%;
        overflow:hidden;
        text-align: center;
        white-space: nowrap;
      }
    }

    .el-progress__text{
      font-size:12px !important;
      color:#fff !important;
    }
  }
  .charts-cont{
     width:100%;
    padding-top:10px;
  }



  .data-chart {
    margin-top: 12px !important;
    margin-bottom: 10px !important;
  }

  .tab-cont {
    width: 100%;
    display: flex;
    align-items: center;
    padding-left: 15px;
    padding-bottom: 15px;

    .tab-list {
      width: 127px;
      height: 30px;
      background: url("../../../assets/images/building_guarantee/img_2.png")
      no-repeat;
      background-size: 100% 100%;
      font-family: "PingFangSC";
      font-size: 14px;
      font-weight: 500;
      color: #00ffff;
      padding-left: 15px;
      line-height: 30px;
    }
    .tab-list:last-child {
      margin-left: 20px;
    }
  }

  .camera-cont.pad{
    padding:20px 0 0 0;
  }
  .camera-cont{
    width:100%;
    padding:5px 0 25px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .camera-item{
      width: 139px;
      height: 80px;

      .camera-num{
        display: flex;
        justify-content: center;
        align-items: center;

        .num{
          font-size: 30px;
          color: #19FCDE;
          font-weight: bold;
          font-family: "electronicFont";
          padding-left:4px;
        }
        .unit{
          font-size: 12px;
          color: #00ffff;
          font-weight: 500;
          position: relative;
          top:6px;
        }
      }
    }
    .fir-bg{
      background: url("../../../assets/images/building_guarantee/img_5.png") no-repeat;
      background-size: 100% 100%;
    }
    .snd-bg{
      background: url("../../../assets/images/building_guarantee/img_6.png") no-repeat;
      background-size: 100% 100%;
    }
  }

  .monitor-cont{
    width:100%;
    display: flex;
    flex-wrap: wrap;
    padding:0 15px;

    .monitor-list{
      width:151px;
      position: relative;
      margin:0 10px 10px 0;

      .img{
        display: block;
        width:151px;
        height:104px;
      }
      .monitor-info{
        position: absolute;
        left:0;
        bottom: 0;
        width: 100%;
        height: 25px;
        opacity: 0.55;
        background: #000000;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 8px;

        .name{
          font-size: 12px;
          color: #FFFFFF;
          font-weight: 500;
        }
        .online{
          font-size: 12px;
          color: #00F6EC;
          font-weight: 500;
        }
        .offline{
          font-size: 12px;
          color: #F60000;
          font-weight: 500;
        }
      }
    }
    .monitor-list:nth-child(3n){
      margin-right: 0;
    }
  }


  ::-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>

