<template>
  <div class="right1-container">
    <InfoHeader name="年度维保超期率" eName="Annual overdue work"></InfoHeader>
    <InfoContent height="2.8rem">
      <div class="d-flex">
        <LineCharts
          chartId="rescue1ssss"
          :chartLineXData="chartLineXData"
          :chartSettingData="chartSettingData"
          :chartLineYData="chartLineYData"
        ></LineCharts>
      </div>
    </InfoContent>
  </div>
</template>
  
  <script>
import InfoHeader from "@/components/infoHeader";
import InfoContent from "@/components/infoContent";
import LineCharts from "@/components/lineCharts";
import { getElevatorMaintenanceTotal } from "@/api/elevator";
export default {
  components: {
    InfoHeader,
    InfoContent,
    LineCharts,
  },
  data() {
    return {
      chartSettingData: {
        lineColor: "green",
        areaColor: "green",
        seriesName: "超期率",
        height: "3rem",
      },
      chartLineXData: [
        "1月",
        "2月",
        "3月",
        "4月",
        "5月",
        "6月",
        "7月",
        "8月",
        "9月",
        "10月",
        "11月",
        "12月",
      ],
      chartLineYData:[],
      maintenanceName:'',
      chartData: [
        {
          value: 9,
          name: "停电故障",
          itemStyle: { color: "#AC2B61" },
        },
        { value: 60, name: "非平层开门", itemStyle: { color: "#FFDB4A" } },
        { value: 32, name: "非平层停梯", itemStyle: { color: "#D36D50" } },
      ],
    };
  },
  created() {
    this.$nextTick(()=>{
      this.getElevatorMaintenanceTotalApi();
      this.$EventBus.$on("maintenanceName", (maintenanceName) => {
      console.log(maintenanceName,'maintenanceName')
      this.maintenanceName = maintenanceName
      this.getElevatorMaintenanceTotalApi();
      })
    })
    
  },
  methods:{
    getElevatorMaintenanceTotalApi() {
      getElevatorMaintenanceTotal({maintenanceName:this.maintenanceName}).then((res) => {
        this.chartLineXData = res.data.overdueInfoList.map((item) => {
          return `${item.month}月`;
        });
        this.chartLineYData = res.data.overdueInfoList.map(item=>{
          return  item.overdueRatio;
        })
      });
    },
  }
};
</script>
  <style lang="scss" scoped>
.right1-container {
  position: fixed;
  top: 8.15rem;
  right: 0.22rem;
  width: 31%;
  pointer-events: all;
  .title1 {
    background-image: url("../../../assets/images/biaoti-bck.png");
    width: 1.875rem;
    height: 0.375rem;
    line-height: 0.375rem;
    margin: 0 auto;

    font-size: 0.2rem;
    color: white;
  }
  .order {
    background: url("../../../assets/images/guzhang_bck.png");
    background-repeat: no-repeat;
    background-size: 100% 35%;
    background-position: bottom;
    height: 3.25rem;
    .rate {
      font-size: 0.55rem;
      color: white;
      font-weight: bolder;
    }
    .item {
      margin: 0.375rem 0;
      .num-title {
        font-size: 0.3rem;
        color: white;
      }
      .num-value {
        font-size: 0.36rem;
        color: white;
        margin-left: 0.15rem;
      }
    }
  }
}
</style>
  