<template>
  <div id="center">
    <!--  <div class="up">
        <div
          class="bg-color-black item"
          v-for="item in titleItem"
          :key="item.title"
        >
          <p class="ml-3 colorBlue fw-b fs-xl">{{ item.title }}</p>
          <div>
            <dv-digital-flop
              class="dv-dig-flop ml-1 mt-2 pl-3"
              :config="item.number"
            />
          </div>
        </div>
      </div>-->
    <div class="down">
      <div class="ranking bg-color-black">
        <span>
          <icon name="chart-pie" class="text-icon"></icon>
        </span>
        <span class="fs-xl text mx-2 mb-1 pl-3">当前时段生产明细</span>
        <dv-scroll-board class="dv-scr-board" :config="config" ref="scroll-board" />
      </div>
      <!-- <div class="percent">
         <div class="item bg-color-black">
           <span>首检合格率</span>
           <CenterChart
             :id="rate[0].id"
             :tips="rate[0].tips"
             :colorObj="rate[0].colorData"
           />
         </div>
         <div class="item bg-color-black">
           <span>巡检合格率</span>
           <CenterChart
             :id="rate[1].id"
             :tips="rate[1].tips"
             :colorObj="rate[1].colorData"
           />
         </div>
         <div class="water">
           <dv-water-level-pond class="dv-wa-le-po" :config="water" />
         </div>
       </div>-->
    </div>
  </div>
</template>

<script>
//import CenterChart from '@/components/packageechart/center/centerChartRate'

export default {
  data() {
    return {
      config: {
        header:  ['工单号','工序', '当前小时数量'],
        data: [
        ],
        rowNum: 7, //表格行数
        headerHeight: 35,
        headerBGC: '#0f1325', //表头
        oddRowBGC: '#0f1325', //奇数行
        evenRowBGC: '#171c33', //偶数行
        columnWidth: [130,120,110],
        align: ['center']
      },
      timing : null,
    }
  },
  components: {
    // CenterChart
  },
  mounted () {
    this.drawTimingFn();
  },
  beforeDestroy () {
    clearInterval(this.timing)
  },
  methods: {
    drawTimingFn () {
      this.setData();
      this.timing = setInterval(() => {
        this.setData(); //获取-数据
      }, 30000);
    },
    async setData () {
      // 首检任务数，完成数，合格数，巡检任务数，完成数，巡检合格数  name value
      /*  await this.$http.get("kanban/datalist.action?caller=CheckData&_noc=1&page=1&pageSize=100",{
        params: {
          condition: "1=1",
        }
      }).then((result)=>{
                          let dataList = JSON.parse(result.data.data);
                          let titleitems = new Array();
                          for (let index = 0; index < dataList.length; index++) {
                            const element = dataList[index];
                            titleitems.push({
                              title: element.name,
                              number: {
                                number: [element.value],
                                toFixed: 1,
                                textAlign: 'left',
                                content: '{nt}',
                                style: {
                                  fontSize: 26
                                }
                              }
                            });
                          }
                          this.titleItem = titleitems;
                        },(result)=>{
                          console.error(result)
                        }
                );*/
      // var caller = 'KeyStepRate!ZZ';
      var caller = 'CurrentHour!ZZ';
      if (sessionStorage.getItem('li_code') == '所有'){
        caller = 'ZZ!KeyStepRate!ALL';
      }
      //关键工序直通率
      await this.$http.get("kanban/datalist.action?caller="+caller+"&_noc=1&page=1&pageSize=100",{
        params: {
          condition: "1=1",
        }
      }).then((result)=>{
            let dataList = JSON.parse(result.data.data);
            let resultList = new Array();
            for (let index = 0; index < dataList.length; index++) {
              const element = dataList[index];
              let item = new Array();
              item.push("<span  class='colorGrass'>"+element.makecode+"</span>");
              item.push("<span  class='colorGrass'>"+element.stepcode+"</span>");
              item.push("<span  class='colorGrass'>"+element.value+"</span>");
              resultList.push(item);
            }
            const scrollBoard = this.$refs['scroll-board'];
            //刷新数据
            scrollBoard.updateRows(resultList);
          },(result)=>{
            console.error(result)
          }
      );
      //饼图pie，首检合格率，巡检合格率
      /* await this.$http.get("kanban/datalist.action?caller=PieCheckRate&_noc=1&page=1&pageSize=100&condition=1=1")
               .then((result)=>{
                         let dataList = JSON.parse(result.data.data);
                         this.rate[0].tips = dataList[0].firstcheckrate;
                         this.rate[0].tips = dataList[0].xcheckrate;
                       },(result)=>{
                         console.error(result)
                       }
               );*/
      //水波图，首检合格率，巡检合格率
      /* await this.$http.get("kanban/datalist.action?caller=WaterCheckRate&_noc=1&page=1&pageSize=100&condition=1=1")
               .then((result)=>{
                         let dataList = JSON.parse(result.data.data);
                         let waterdatas = new Array();
                         waterdatas.push(dataList[0].firstcheckrate);
                         waterdatas.push(dataList[0].xcheckrate);
                          this.water = { data: waterdatas }
                       },(result)=>{
                         console.error(result)
                       }
               );*/
    }
  }
}
</script>

<style lang="scss" scoped>
$box-height: 420px;
#center {
  display: flex;
  flex-direction: column;
  .up {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .item {
      border-radius: 6px;
      padding-top: 8px;
      margin-top: 8px;
      width: 32%;
      height: 70px;
      .dv-dig-flop {
        width: 150px;
        height: 30px;
      }
    }
  }
  .down {
    padding: 6px 4px;
    padding-bottom: 0;
    width: 100%;
    display: flex;
    height: $box-height;
    justify-content: space-between;
    .bg-color-black {
      border-radius: 5px;
      height: $box-height - 15px;
    }
    .ranking {
      padding: 10px;
      width: 100%;
      .dv-scr-rank-board {
        height: 370px;
      }
    }
    .percent {
      width: 40%;
      display: flex;
      flex-wrap: wrap;
      .item {
        width: 50%;
        height: 120px;
        span {
          margin-top: 8px;
          font-size: 14px;
          display: flex;
          justify-content: center;
        }
      }
      .water {
        width: 100%;
        .dv-wa-le-po {
          height: 120px;
        }
      }
    }
  }
}
</style>
