<template>
  <div class="main-data dialog-property-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">数据概况(近三月)</span>
            </div>
            <div class="data-chart">
              <div class="data-content">
                <div class="data-item mar">
                  <div class="data">
                    <div>{{faultWarrantyNum.value}}</div>
                    <div class="unit">个</div>
                  </div>
                  <div class="name">{{ faultWarrantyNum.name }}</div>
                </div>

                <div class="data-item mar">
                  <div class="data">
                    <div>{{dispatchedNum.value}}</div>
                    <div class="unit">个</div>
                  </div>
                  <div class="name">{{ dispatchedNum.name }}</div>
                </div>
                <div class="data-item mar">
                  <div class="data">
                    <div>{{suggestedNum.value}}</div>
                    <div class="unit">个</div>
                  </div>
                  <div class="name">{{ suggestedNum.name }}</div>
                </div>
                <div class="data-item mar">
                  <div class="data">
                    <div>{{repairOrdersNum.value}}</div>
                    <div class="unit">个</div>
                  </div>
                  <div class="name">{{ repairOrdersNum.name }}</div>
                </div>
                <div class="data-item mar">
                  <div class="data">
                    <div>{{questionnairesNum.value}}</div>
                    <div class="unit">个</div>
                  </div>
                  <div class="name">{{ questionnairesNum.name }}</div>
                </div>
                <!-- <div class="data-item mar">
                  <div class="data">
                    <div>{{carlicense.value}}</div>
                    <div class="unit">个</div>
                  </div>
                  <div class="name">{{ carlicense.name }}</div>
                </div> -->

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

        <div class="dialog-list">
          <div class="dialog-item wid100">
            <div class="content-title">
              <span class="title">近一个月报修分类占比</span>
            </div>
            <div class="data-chart">
              <pie-chart
                :chart-data="pieData"
                :legend="pieLegend"
                :title="pieTitle"
                :labelShow="true"
                :labelLine="true"
                :center="pieCenter"
                width="515px"
                height="180px"
              />
            </div>
          </div>
        </div>

        <div class="dialog-list">
          <div class="dialog-item wid100">
            <div class="content-title">
              <span class="title">近六个月报修分类</span>
            </div>
            <div class="data-chart">

              <bar-chart
                :chart-data="barData"
                :x-axis="barAxis"
                :y-axis="barYaxis"
                :grid="barGrid"
                :legend="barLegend"
                y-color="#FFF"
                l-color="#FFF"
                width="500px"
                height="280px"
              />
            </div>
          </div>
        </div>

        <div class="dialog-list">
          <div class="dialog-item wid100">
            <div class="content-title">
              <span class="title">一周车流量统计</span>
            </div>
            <div class="data-chart">
              <bar-chart
                :chart-data="carFlowBarData"
                :x-axis="carFlowBarAxis"
                :y-axis="carFlowBarYaxis"
                y-color="#FFF"
                l-color="#FFF"
                width="515px"
                height="180px"
              />
            </div>
          </div>
        </div>

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

<script>
import PieChart from "@/components/Echarts/PieChart";
import BarChart from "@/components/Echarts/BarChart.vue";

import {
  getPostOverviewData,
  getPastMonthPieData,
  getPastSixMonthChartsData, getCarFlowData,
} from "@/api/screen/service";

export default {
  name: "PropertyDialog",
  components: {
    BarChart,
    PieChart,
  },
  props: {
    appOrg: {
      type: String,
      default: "0000",
    },
  },
  data() {
    return {
      //数据概况
      faultWarrantyNum: {},
      dispatchedNum: {},
      suggestedNum: {},
      repairOrdersNum: {},
      carlicense: {},
      questionnairesNum: {},

      //近一个月报修占比
      pieData: [],
      pieLegend: {
        top: 10,
        orient: "vertical",
        right: 0,
        itemWidth: 8, // 设置图例标记的宽度
        itemHeight: 8, // 设置图例标记的高度
        textStyle: {
          color: "#FFF",
        },
      },
      pieTitle: {},
      pieCenter: ["30%", "50%"],

      //近六个月报修订单分类
      barData: [],
      barAxis: {},
      barYaxis: {
        type: "value",
        boundaryGap: [0, 0.01],
        name: '单位：个',
        nameTextStyle: {
          color: '#fff',
        },
        axisLine:{
          show:false
        },
        axisLabel: {
          color: "white", // 设置横坐标轴字体颜色为红色
        },
        splitLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        splitArea:false
      },
      barGrid: {
        top: 30,
        bottom: 50,
        left: "2%",
        right: "2%",
        containLabel: true,
      },
      barLegend: {
        left: 20,
        bottom: 0,
        itemWidth: 8, // 设置图例标记的宽度
        itemHeight: 8, // 设置图例标记的高度
        textStyle: {
          color: "#FFF",
        },
      },

      //一周车流量统计
      carFlowBarData: [],
      carFlowBarAxis: {},
      carFlowBarYaxis: {
        type: "value",
        boundaryGap: [0, 0.01],
        name: '单位：辆',
        nameTextStyle: {
          color: '#fff',
        },
        axisLine:{
          show:false
        },
        axisLabel: {
          color: "white", // 设置横坐标轴字体颜色为红色
        },
        splitLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        splitArea:false
      },
    };
  },
  created() {
    //数据概况
    this.getPostOverviewData();
    //近一个月报修分类占比
    this.getPastMonthPieData();
    //近六个月报修订单分类
    this.getPastSixMonthChartsData();
    //一周车流量统计
    this.getCarFlowData();
  },
  destroyed() {},
  beforeDestroy() {},
  mounted() {},
  methods: {
    //获取数据概况
    getPostOverviewData() {
      getPostOverviewData(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          this.faultWarrantyNum = res.data.faultWarrantyNum
          this.dispatchedNum = res.data.dispatchedNum
          this.suggestedNum = res.data.suggestedNum
          this.repairOrdersNum = res.data.repairOrdersNum
          this.questionnairesNum = res.data.questionnairesNum
          this.carlicense = res.data.carlicense
        }
      });
    },

    //近一个月报修分类占比
    getPastMonthPieData() {
      getPastMonthPieData(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          this.pieData = res.data;
        }
      });
    },

    //近六个月报修订单分类
    getPastSixMonthChartsData() {
      getPastSixMonthChartsData(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          let list = [
            "seNum",
            "arNum",
            "otNum",
            "ofNum",
            "meNum",
            "laNum",
            "diNum",
            "colNum",
            "toNum",
            "elevatorNum",
          ];
          for (let index = 0; index < list.length; index++) {
            this.barData.push({
              name: res.data[list[index]].name,
              type: "bar",
              stack: "a",
              itemStyle: {
                color: res.data[list[index]].color,
              },
              barWidth: 30,
              data: res.data[list[index]].dataList,
            });
          }

          this.barAxis = {
            type: "category",
            data: res.data.xList,
            axisLabel: {
              color: "white", // 设置横坐标轴字体颜色为红色
            },
            axisTick: {
              show: false,
            },
            axisLine: {
              lineStyle: {
                color: "#0A7C80",
              },
            },
          };
        }
      });
    },

    //电子餐券
    getCarFlowData() {
      getCarFlowData(this.$props.appOrg).then((res) => {
        if (Number(res.code) === 200) {
          this.carFlowBarData = [
            {
              name: "",
              type: "bar",
              stack: "a",
              itemStyle: {
                color: res.data.yData.color,
                //barBorderRadius: [5, 5, 0, 0], // 统一设置四个角的圆角大小
              },
              barWidth: 30,
              data: res.data.yData.yList,
            },
          ];
          this.carFlowBarAxis = {
            type: "category",
            data: res.data.xList,
            axisLabel: {
              color: "white", // 设置横坐标轴字体颜色为红色
              rotate: 16,
              interval: 0
            },
            axisTick: {
              show: false,
            },
            axisLine: {
              lineStyle: {
                color: "#465A64",
              },
            },
          };
        }
      });
    },

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

    preventDefault() {
      console.log(11);
    },
  },
};
</script>

<style lang="scss">
.dialog-property-area {
  overflow: hidden;
  width: 580px;
  height:1000px;
  background: url("../../../assets/images/main/main_bg.png") no-repeat;
  background-size: 100% 100%;
  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: 920px;
    padding: 15px;
    overflow-y: scroll;
    background: url("../../../assets/images/main/components_long_bg.png") no-repeat;
    background-size: 100% 100%;

    .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;
    }
  }
  .tips{
    width: 12px;
    height: 12px;
    /* margin: 0 0 -4px 10px; */
    position: relative;
    top: -7px;
    left: 1px;
  }
  .data-chart {
    margin-top: 15px !important;
    margin-bottom: 5px !important;
  }

  .data-content{
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: visible;
    padding-top:15px;

    .mar{
      margin-bottom: 15px;
    }
    .wid{
      width: 65px;
    }
    .data-item{
      width: 65px;
      height: 65px;
      background: url("../../../assets/images/service_new/img_5.png") no-repeat;
      background-size: 100% 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      overflow: visible;

      .data{
        width: auto;
        font-size: 24px;
        color:#00FFFF;
        font-family: 'electronicFont';
        position: relative;
        top: -15px;
        display: flex;
        align-items: center;
        .unit{
          font-size:13px;
          color:#00FFFF;
          font-weight: 500;
          position: relative;
          top: 5px;
          left:2px;
        }
      }
      .name{
        font-size: 14px;
        color:#FFFFFF;
        position: relative;
        top: 16px;
        font-family: "fashionZh";
      }
    }
  }

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

