<template>
  <div class="cont">
    <div class="top_">
      <div>车辆检测数据大屏</div>
    </div>
    <!--    -->
    <div class="content_">
      <div class="c_left">
        <div class="six_box">
          <div class="s_title">
            成交金额（已收款）
          </div>
          <div class="echaets_box">
            <div id="khly" style="width: 400px; height: 267px;"></div>
          </div>
        </div>
        <div class="six_box">
          <div class="s_title">
            已收款金额(按车型)
          </div>
          <div class="dis-t">

            <div class="lan-you">
              <div class="yi" :class="{'er' : qhindex == index}" v-for="(item,index) in zilist" :key="index" @click="gbindex(index,item.unit)"> {{item.text}}</div>
            </div>
          </div>
          <div class="echaets_box">
            <div id="yskje" style="width: 400px; height: 267px;"></div>
          </div>
        </div>
        <div class="six_box">
          <div class="s_title">
            数量统计(按车型)
          </div>
          <div class="dis-t">

            <div class="lan-you">
              <div class="yi" :class="{'er' : qhindex1 == index}" v-for="(item,index) in zilist" :key="index" @click="gbindex1(index,item.unit)"> {{item.text}}</div>
            </div>
          </div>
          <div class="echaets_box">
            <div id="sltj" style="width: 400px; height: 267px;"></div>
          </div>
        </div>
      </div>
      <div class="c_cont">
        <div class="tab_">
<!--          <div @click="countOrAmount()" class="tab_buttom tab_acvit">数量</div>-->
<!--          <div @click="countOrAmount()" class="tab_buttom">金额</div>-->
        </div>


        <div class="tab_bt">
          <div class="yb_">
            <div class="yb_title">工单总金额（元）</div>
            <div class="numlist">
              <!--                <div class="num_box" v-for="(item,index) in 6" :key="index">-->
              <!--                  {{index}}-->
              <!--                </div>-->
              <div class="num_box">
<!--                {{ statistics.totalAmount }}-->
              </div>
            </div>
          </div>
          <div class="yb_">
            <div class="yb_title">今日工单金额（元）</div>
            <div class="numlist">
              <!--              <div class="num_box" v-for="(item,index) in 6" :key="index">-->
              <!--                {{index}}-->
              <!--              </div>-->
              <div class="num_box">
<!--                {{ statistics.todayAmount }}-->
              </div>
            </div>
          </div>
        </div>
        <div class="five_box">
          <div class="f_box">
            <div class="img_left">
              <img src="./imgs/1.png" style="width: 60px;height: 60px">
            </div>
            <div>
<!--              <div class="f_size">{{ statusTickets[3].name }}</div>-->
<!--              <div class="f_num">{{ statusTickets[3].value }}</div>-->
            </div>
          </div>
          <div class="f_box">
            <div class="img_left">
              <img src="./imgs/2.png" style="width: 60px;height: 60px">
            </div>
            <div>
<!--              <div class="f_size">{{ statusTickets[4].name }}</div>-->
<!--              <div class="f_num">{{ statusTickets[4].value }}</div>-->
            </div>
          </div>
          <div class="f_box">
            <div class="img_left">
              <img src="./imgs/3.png" style="width: 60px;height: 60px">
            </div>
            <div>
<!--              <div class="f_size">{{ statusTickets[0].name }}</div>-->
<!--              <div class="f_num">{{ statusTickets[0].value }}</div>-->
            </div>
          </div>
          <div class="f_box">
            <div class="img_left">
              <img src="./imgs/4.png" style="width: 60px;height: 60px">
            </div>
            <div>
<!--              <div class="f_size">{{ statusTickets[1].name }}</div>-->
<!--              <div class="f_num">{{ statusTickets[1].value }}</div>-->
            </div>
          </div>
          <div class="f_box">
            <div class="img_left">
              <img src="./imgs/5.png" style="width: 60px;height: 60px">
            </div>
            <div>
<!--              <div class="f_size">{{ statusTickets[5].name }}</div>-->
<!--              <div class="f_num">{{ statusTickets[5].value }}</div>-->
            </div>
          </div>
        </div>
        <div class="co_title">
          今日工单
        </div>
<!--        <div class="list_long">-->
<!--          <div class="long_title">-->
<!--            <div class="l_one">工单号</div>-->
<!--            <div class="l_two">服务客户</div>-->
<!--            <div class="l_three">服务顾问</div>-->
<!--            <div class="l_four">创建时间</div>-->
<!--          </div>-->
<!--          <div class="ot_vox">-->
<!--            <div class="long_box" v-for="(item,index) in todayTickets" :key="index">-->
<!--              <div class="l_one">{{ item.ticketNo }}</div>-->
<!--              <div class="l_two">{{ item.userName }}</div>-->
<!--              <div class="l_three">{{ item.adviserName }}</div>-->
<!--              <div class="l_four">{{ parseTime(item.createTime) }}</div>-->
<!--            </div>-->
<!--          </div>-->
<!--        </div>-->
      </div>
      <div class="c_right">
        <div class="six_box">
          <div class="s_title">
            检测数量
          </div>
          <div class="echaets_box">
            <div id="jcsl" style="width: 400px; height: 267px;"></div>
          </div>
        </div>
        <div class="six_box">
          <div class="s_title">
            检测合格率
          </div>
          <div class="dis-t">

            <div class="lan-you">
              <div class="yi" :class="{'er' : qhindex2 == index}" v-for="(item,index) in zilist" :key="index" @click="gbindex2(index,item.unit)"> {{item.text}}</div>
            </div>
          </div>
          <div class="echaets_box">
            <div id="jchgl" style="width: 400px; height: 267px;"></div>
          </div>
        </div>
        <div class="six_box">
          <div class="s_title">
            维修工人排行
          </div>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import * as echarts from 'echarts';
import * as jcBigScreen from '@/views/inspection/screen/api/jcBigScreen';
import {chartInfoNum, chartLineInspectionAmount} from "@/views/inspection/screen/api/jcBigScreen";

export default {
  name: 'Index',
  components: {},
  data() {
    return {
      Amount: [],
      unit: '',
      unit1: '',
      unit2: '',
      chartData1: {},
      params : {
        unit:this.unit,
      },
      qhindex:0,
      qhindex1:0,
      qhindex2:0,
      zilist:[
        {text:'日',unit:'day'},
        {text:'周',unit:'week'},
        {text:'月',unit:'month'},
        {text:'年',unit:'year'},

      ],
    }
  },
  created() {
    this.customerSource()
    this.getServerData1()
    this.chartInfoNum()
    this.chartLineInspectionNum()
    this.chartInfoRatio()

  },
  mounted() {

  },
  methods: {
    gbindex(index,unit){
      this.qhindex = index
      this.unit = unit
      this.getServerData1()
    },
    gbindex1(index,unit){
      console.log('22',unit);
      this.qhindex1 = index
      this.unit1 = unit
      this.chartInfoNum()
    },
    gbindex2(index,unit){
      console.log('33');
      this.qhindex2 = index
      this.unit2 = unit
      this.chartInfoRatio()
    },

    /**
     * 已收款金额
     * @returns {Promise<void>}
     */
    async getServerData1() {
      const params = {
        unit:this.unit,
      }
      let res = await jcBigScreen.getServerData1(params)
      console.log('已收款金额',res)
      res.data.series.forEach(item => {
        item.type = 'bar'
      })
      var chartDom = document.getElementById('yskje');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: 'category',
          data: res.data.categories
        },
        yAxis: {
          type: 'value'
        },
        series: res.data.series
      };
      option && myChart.setOption(option);
    },
    /**
     * 数量统计
     * @returns {Promise<void>}
     */
    async chartInfoNum() {
      const params = {
        unit:this.unit1,
      }
      let res = await jcBigScreen.chartInfoNum(params)
      console.log('数量统计',res)
      res.data.series.forEach(item => {
        item.type = 'bar'
      })
      var chartDom = document.getElementById('sltj');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: 'category',
          data: res.data.categories
        },
        yAxis: {
          type: 'value'
        },
        series: res.data.series
      };
      option && myChart.setOption(option);
    },
    /**
     * 检测合格率
     * @returns {Promise<void>}
     */
    async chartInfoRatio() {
      const params = {
        unit:this.unit2,
      }
      let res = await jcBigScreen.chartInfoRatio(params)
      console.log('检测合格率',res)
      res.data.series.forEach(item => {
        item.type = 'bar'
      })
      var chartDom = document.getElementById('jchgl');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: 'category',
          data: res.data.categories
        },
        yAxis: {
          type: 'value'
        },
        series: res.data.series
      };
      option && myChart.setOption(option);
    },
    /**
     * 检测数量
     * @returns {Promise<void>}
     */
    async chartLineInspectionNum() {
      const params = {
        unit:this.unit,
      }
      let res = await jcBigScreen.chartLineInspectionNum(params)
      console.log('检测数量',res)
      res.data.series.forEach(item => {
        item.type = 'bar'
      })
      const names = res.data.series.map(item => item.name)
      var chartDom = document.getElementById('jcsl');
      var myChart = echarts.init(chartDom);
      var option;
      // option = {
      //   xAxis: {
      //     type: 'category',
      //     data: res.data.categories
      //   },
      //   yAxis: {
      //     type: 'value'
      //   },
      //   series: res.data.series
      // };
      option = {
        title: {
          text: '最近七天'
        },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: names
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: res.data.categories
        },
        yAxis: {
          type: 'value'
        },
        series: res.data.series
      };
      option && myChart.setOption(option);
    },

    /**
     * 客户来源分析饼图
     */
    async customerSource() {
      const params = {
        unit:this.unit,
      }
      const res = await jcBigScreen.chartLineInspectionAmount(params);
      res.data.series.forEach(item => {
        item.type = 'line'
      })
      var chartDom = document.getElementById('khly');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: 'category',
          data: res.data.categories
        },
        yAxis: {
          type: 'value'
        },
        series: res.data.series
      };
      option && myChart.setOption(option);
    },
  }

}
</script>

<style lang="scss" scoped>
.cont {
  background: #020F32;
  //background: url("./imgs/back.png") no-repeat;
  background-size: 100% 100%;
  width: 100%;
  height: 100vh;
}

.top_ {
  width: 100%;
  height: 86px;
  background: url("./imgs/top.png") no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  color: #FFFFFF;
  font-weight: bold;
  margin-bottom: 15px;
}

.content_ {
  width: 100%;
  display: flex;
  //align-items: center;
  justify-content: space-between;
}
.dis-t{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px auto;
}
.lan-you{
  display: flex;
  align-items: center;
}

.c_left {
  width: 25%;
}

.c_cont {
  width: 50%;
}

.tab_ {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 18px;
  color: #FFFFFF;
  margin: 15px auto;
}

.yb_title {
  text-align: center;
  font-size: 18px;
  color: #FFFFFF;
  margin: 15px auto;
}

.tab_bt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-bottom: 4px solid #0174F6;
  box-sizing: border-box;
  padding-bottom: 20px;
}

.tab_buttom {
  width: 120px;
  height: 32px;

  border: 1px solid #0174F6;
  display: flex;
  align-items: center;
  justify-content: center;
}

yb_title {
  font-size: 16px;
  color: #FFFFFF;
  text-align: center;
  width: 100%;
}

.numlist {
  display: flex;
  align-items: center;
  justify-content: center;
}

.num_box {
  width: 38px;
  height: 50px;
  border-radius: 0px 0px 0px 0px;
  font-weight: 600;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url("./imgs/numbcak.png") no-repeat;
  background-size: 100% 100%;
  color: #FFFFFF;
  margin: 0px 10px;
}

.yb_ {
  width: 50%;
}

.tab_acvit {
  background: #0174F6 !important;
}

.five_box {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 30px auto;
}

.f_size {
  font-size: 14px;
  color: #FFFFFF;
}

.f_num {
  font-weight: bold;
  font-size: 24px;
  color: #FFFFFF;
}

.img_left {
  width: 60px;
  height: 60px;
  margin-right: 10px;
}

.f_box {
  display: flex;
  align-items: center;
}

.co_title {
  width: 100%;
  height: 32px;
  background: url("./imgs/c_title.png") no-repeat;
  background-size: 100% 100%;
  font-weight: 500;
  font-size: 20px;
  color: #FFFFFF;
  box-sizing: border-box;
  padding-left: 40px;
}

.s_title {
  width: 90%;
  height: 32px;
  background: url("./imgs/title.png") no-repeat;
  background-size: 100% 100%;
  font-weight: 500;
  font-size: 20px;
  color: #FFFFFF;
  box-sizing: border-box;
  padding-left: 40px;
  margin: 0px auto;
}

.echaets_box {
  width: 90%;
  height: 267px;
  margin: 0px auto;
  border-bottom: 1px solid #0174F6;
}

.list_long {
  width: 100%;
  height: 563px;

}

.l_one {
  width: 30%;
  text-align: left;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
  box-sizing: border-box;
  padding-left: 35px;
}

.l_two {
  width: 20%;
  text-align: center;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.l_three {
  width: 20%;
  text-align: center;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.l_four {
  width: 30%;
  text-align: right;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
  box-sizing: border-box;
  padding-right: 35px;
}

.long_title {
  width: 100%;
  height: 58px;
  background: rgba(1, 116, 246, 0.1);
  background: url("./imgs/c_list.png") no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px auto;
}

.ot_vox {
  width: 100%;
  height: 500px;
  overflow: auto;
  scrollbar-width: none;
}

.long_box {
  width: 100%;
  height: 58px;
  background: rgba(1, 116, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px auto;
}

.six_box {
  margin-bottom: 15px;
}

.c_right {
  width: 25%;
}

</style>
