<template>
  <div class="app-container home">
    <div class="top">
      <div class="echartsbox1">
        <div class="titlename">各线体当日计划产量</div>
        <crossBarChart :chart-data="crossBarChart" ref="crossBarChart" />
        <div class="el-date-picker">
          <el-date-picker
            v-model="value1"
            type="date"
            format="yyyy-MM-dd"
            placeholder="选择日期"
            @change="changecrossBarChart"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="echartsbox1 echartsbox2">
        <div class="titlename">当日产品产量</div>
        <PieChart3 :chart-data="PieChart3Data" ref="PieChart3" />
        <div class="el-date-picker">
          <el-date-picker
            v-model="value2"
            format="yyyy-MM-dd"
            type="date"
            placeholder="选择日期"
            @change="changePieChart3Data"
          >
          </el-date-picker>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="echartsbox3">
        <div class="titlename">
          {{ titlename }}
        </div>
        <div style="">
          <LineChartshadow :chart-data="lineChartData" ref="lineChart" />
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="echartsbox4">
        <div class="titlename">各线体设备月故障数</div>
        <DeviceChartLine
          :chart-data="deviceChartLineData"
          ref="DeviceChartLine"
        />
      </div>
      <div class="echartsbox4 echartsbox5">
        <div class="titlename">各车间生产不良率</div>
        <QcChartLine :chart-data="qcChartLineData" ref="QcChartLine" />
      </div>
    </div>
    <!-- <el-row :gutter="20">
      <el-col :sm="24" :lg="24">
        <span style="font-size: 20px; margin: 40%; color: cadetblue">{{
          titlename
        }}</span>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="24">
        <div style="border: 1px solid #cfdee4">
          <line-chart :chart-data="lineChartData" ref="lineChart" />
        </div>
      </el-col>
    </el-row> -->
    <!--
     <el-row :gutter="20">
      <el-col :span="12">
        <pie-chart ref="pieChart"/>
      </el-col>
      <el-col :span="12">
        <pie-chart ref="pieChart2"/>
      </el-col>
    </el-row>-->
    <!-- <el-row :gutter="20">
      <el-col :span="12">
        <span style="font-size: 18px; padding: 1% 39%; color: cadetblue"
          >各线体设备月故障数</span
        >
      </el-col>
      <el-col :span="12">
        <span style="font-size: 18px; padding: 1% 39%; color: cadetblue"
          >各车间生产不良率</span
        >
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <DeviceChartLine
          :chart-data="deviceChartLineData"
          ref="DeviceChartLine"
        />
      </el-col>
      <el-col :span="12">
        <QcChartLine :chart-data="qcChartLineData" ref="QcChartLine" />
      </el-col>
    </el-row> -->
  </div>
</template>

<script>
import LineChart from "./dashboard/LineChart";
import LineChartshadow from "./dashboard/LineChartshadow";
import crossBarChart from "./dashboard/crossBarChart";
import PieChart from "./dashboard/PieChart";
import PieChart2 from "./dashboard/PieChart2";
import PieChart3 from "./dashboard/PieChart3";
import moment from "moment";
import {
  getGroupLineEquInfo,
  getLineChartData,
  getLineQcData,
  getLineProData,
  getMonthProData,
  getProductProData,
} from "@/api/mes/reportWork";
import DeviceChartLine from "./dashboard/DeviceChartLine";
import QcChartLine from "./dashboard/QcChartLine";
export default {
  name: "Index",
  components: {
    DeviceChartLine,
    QcChartLine,
    LineChart, //,PieChart,PieChart2
    crossBarChart,
    PieChart3,
    LineChartshadow,
  },
  data() {
    return {
      // 版本号
      version: "1.0.0",
      lineChartData: null,
      deviceChartLineData: null,
      qcChartLineData: null,
      titlename: "本月工厂产量",
      crossBarChart: null,
      PieChart3Data: null,
      value1: null,
      value2: null,
    };
  },
  created() {
    this.getLineChartData();
  },

  mounted() {
    // this.datetime = moment().subtract(2, "day").format("yyyy-MM-DD");
    this.value1 = moment().format("yyyy-MM-DD");
    this.value2 = moment().format("yyyy-MM-DD");
    this.getLineProData();
    this.getProductProData();
    this.getMonthProData();
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    getLineChartData() {
      getLineChartData().then((data) => {
        this.lineChartData = data;
      });
    },
    getLineProData() {
      getLineProData({
        productDate: this.value1,
      }).then((data) => {
        this.crossBarChart = data;
      });
    },
    getMonthProData() {
      getMonthProData().then((data) => {
        this.lineChartData = data;
      });
    },
    getProductProData() {
      getProductProData({
        productDate: this.value2,
      }).then((data) => {
        this.PieChart3Data = data;
      });
    },
    changecrossBarChart() {
      this.value1 = moment(this.value1).format("yyyy-MM-DD");
      this.getLineProData();
    },
    changePieChart3Data() {
      this.value2 = moment(this.value2).format("yyyy-MM-DD");
      this.getProductProData();
    },
    /**
    getGroupLineEquInfo(){
      getGroupLineEquInfo().then(response => {
        this.deviceChartLineData = response.data;
      });
    },
    **/
  },
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
.app-container {
  background: #d8e9fd;
  height: calc(100vh - 84px);
  overflow: hidden;
  .top {
    width: 100%;
    display: flex;
    .echartsbox1 {
      position: relative;
      width: 49.5%;
      height: 270px;
      background: #ffffff;
      border-radius: 15px;
      margin-right: 10px;
      .titlename {
        padding: 10px;
        font-size: 20px;
        color: #ffffff;
        background-color: #547bfe;
        box-sizing: border-box;
        border-radius: 15px 15px 0px 0px;
      }
    }
    .echartsbox2 {
      position: relative;
      width: 49.5%;
      background: #ffffff;
      border-radius: 15px;
      margin-right: 0px;
      padding-bottom: 10px;
      .titlename {
        background-color: #42c6f3;
      }
    }
  }
  .content {
    margin-top: 10px;
    .echartsbox3 {
      position: relative;
      width: 100%;
      height: 370px;
      background: #ffffff;
      border-radius: 15px;
      margin-right: 10px;
      .titlename {
        padding: 10px;
        font-size: 20px;
        color: #ffffff;
        background-color: #58dc91;
        box-sizing: border-box;
        border-radius: 15px 15px 0px 0px;
      }
    }
  }
  .bottom {
    margin-top: 10px;
    display: flex;
    .echartsbox4 {
      position: relative;
      width: 50%;
      height: 324px;
      background: #ffffff;
      border-radius: 15px;
      margin-right: 10px;
      .titlename {
        padding: 10px;
        font-size: 20px;
        color: #ffffff;
        background-color: #d4d52b;
        box-sizing: border-box;
        border-radius: 15px 15px 0px 0px;
      }
    }
    .echartsbox5 {
      position: relative;
      margin-right: 0px;
      .titlename {
        background-color: #ff7168;
      }
    }
  }
}
.el-date-picker {
  position: absolute;
  right: -90px;
  top: 8px;
  height: 60px;
}
::v-deep .el-input--medium .el-input__inner {
  height: 32px;
}
</style>

