<template>
  <div id="bottomRight2">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <icon name="chart-line" class="text-icon"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">ATE良率</span>
        </div>
      </div>
      <div class="d-flex jc-center body-box">
        <dv-scroll-board class="dv-scr-board" :config="config" ref="scroll-board" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      config: {
        header: ['线别',  '良率%'],
        data: [/*
          ['组件1', 'dev-1', "<span  class='colorGrass'>↑75%</span>"],
          */
        ],
        rowNum: 8, //表格行数
        headerHeight: 35,
        headerBGC: '#0f1325', //表头
        oddRowBGC: '#0f1325', //奇数行
        evenRowBGC: '#171c33', //偶数行
        index: true,
        columnWidth: [50,130],
        align: ['center']
      }
    }
  },
  mounted() {
    this.refreshdata()
  },
  methods: {
    refreshdata() {
      this.getdata(); //获取-数据
      setInterval(() => {
        this.getdata(); //获取--数据
      }, 30000);
    },
    async getdata() {
      await this.$http.get("kanban/datalist.action?caller=ATERATE!ZZ&_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(element.linecode);
                      if(element.value<97.5) {
                        item.push("<span  class='colorRed'>" + element.value + "</span>");
                      }else{
                        item.push("<span  class='colorGrass'>" + element.value + "</span>");
                      }
                      resultList.push(item);
                    }
                    const scrollBoard = this.$refs['scroll-board'];
                    //刷新数据
                    scrollBoard.updateRows(resultList);
                },(result)=>{
                    console.error(result)
                    }
          );
    }
  }
}
</script>

<style lang="scss" scoped>
$box-height: 520px;
$box-width: 315px;
#bottomRight2 {
  padding: 16px;
  padding-top: 20px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    height: $box-height - 30px;
    border-radius: 10px;
  }
  .text {
    color: #c3cbde;
  //  font-size: 15px;
  }
  .body-box {
    border-radius: 10px;
    overflow: hidden;
    .dv-scr-board {
      width: 270px;
      height: 450px;
    }
  }
}
</style>
