<template>
  <div id="up3">
    <div class="bg-color-black">
      <div class="d-flex pt-1 pl-2 jc-center">
        <span class="fs-xxxl text mx-2 fw-b">来料检验数据</span>
      </div>
      <div class="jc-center body-box">
        <div class="body-box d-flex">
          <div class="item d-flex jc-center flex-column">
            <div class="location">
              <div class="circle-hollow">
                <div class="info">
                  <h2 class="pb-2">{{inQty}}</h2>
                  <p class="fs-xxl pt-2">
                    已检验批次
                  </p>
                </div>
              </div>
            </div>
          </div>
          <div class="item d-flex jc-center flex-column">
            <div class="circle-hollow">
              <div class="info">
                <h2 class="pb-2">{{outQty}}</h2>
                <p class="fs-xxl pt-2">
                  待检验批次
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="d-flex pt-2 pl-2 jc-center pb-1 mb-1">
        <span class="fs-xxxl text mx-2 fw-b">来料不良批次</span>
      </div>
      <div class="d-flex jc-center body-box">
        <dv-scroll-board :config="config" ref="scroll-board" />
      </div>
    </div>
  </div>
</template>

<script>
import {mapState} from "vuex";
export default {
  computed: {
    //数组写法
    ...mapState(['user','factoryoptions','factory']),
  },
  data() {
    return {
      config: {
        header: ['供方编号','物料编号', '物料名称','批次数量','处理结果'],
        data: [],
        rowNum: 4, //表格行数
        headerHeight: 40,
        headerBGC: 'rgba(15,19,37,0.1)', //表头
        oddRowBGC: 'rgba(15,19,37,0.1)', //奇数行
        evenRowBGC: 'rgba(23,28,51,0.1)', //偶数行
        columnWidth: [130,200, 100,100,100],
        align: ['left','center','center','center','center'],

      },
      timing: null,
    }
  },
  mounted() {
    this.refreshdata();
  },
  beforeDestroy () {
    clearInterval(this.timing)
  },
  methods: {
    refreshdata() {
      this.getdata(); //获取-数据
      this.timing = setInterval(() => {
        this.getdata(); //获取--数据
      }, 10000);
    },
    async getdata() {

      this.finishQty = 0;
      this.unfinishQty = 0;
      this.inQty = 0;
      this.outQty = 0;

      //备料完成情况
      caller = 'KB!WHCHECKDATA';
      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);
            if(dataList.length>0){
              this.inQty = dataList[0].inqty;
              this.outQty = dataList[0].outqty;
            }
          }, (result) => {
            console.error(result)
          }
      );

      var caller = 'KB!WHQCRECHECK';
      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();
              if(element.qc_result=='不合格'){
                item.push("<span  class='colorRed fs-xl'>" + element.ve_code + "</span>");
                item.push("<span  class='colorRed fs-xl'>" + element.pr_code + "</span>");
                item.push("<span  class='colorRed fs-xl'>" + element.pr_detail + "</span>");
                item.push("<span  class='colorRed fs-xl'>" + element.qc_qty + "</span>");
                item.push("<span  class='colorRed fs-xl'>" + element.qc_result + "</span>");
              }
              else if(element.qc_result=='特采'){
                item.push("<span  class='colorRemind fs-xl'>" + element.ve_code + "</span>");
                item.push("<span  class='colorRemind fs-xl'>" + element.pr_code + "</span>");
                item.push("<span  class='colorRemind fs-xl'>" + element.pr_detail + "</span>");
                item.push("<span  class='colorRemind fs-xl'>" + element.qc_qty + "</span>");
                item.push("<span  class='colorRemind fs-xl'>" + element.qc_result + "</span>");
              }else {
                item.push("<span  class='colorGrass fs-xl'>" + element.ve_code + "</span>");
                item.push("<span  class='colorGrass fs-xl'>" + element.pr_code + "</span>");
                item.push("<span  class='colorGrass fs-xl'>" + element.pr_detail + "</span>");
                item.push("<span  class='colorGrass fs-xl'>" + element.qc_qty + "</span>");
                item.push("<span  class='colorGrass fs-xl'>" + element.qc_result + "</span>");
              }
              resultList.push(item);
            }
            this.config.data = resultList;
            this.config = { ...this.config };
          }, (result) => {
            console.error(result)
          }
      );
    }
  }
}
</script>

<style lang="scss" scoped>
$box-height: 475px;
$box-width: 100%;
#up3 {
  padding: 13px;
  height: $box-height;
  // font-size: 32px;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    height: $box-height - 25px;
    border-radius: 10px;
    padding: 5px;
    width: $box-width;
    .body-box {
      padding-top: 15px;
    }
  }
  .text {
    color: #c3cbde;
    //font-size: 15px;
  }
  .body-box {
    width: $box-width;

    ::v-deep .dv-scroll-board {
      height: 180px;
      padding-top: 0px; // 添加这行减少顶部间距
      .header {
        font-size: 20px !important;
        color: #c3cbde !important;
      }

      .rows {
        .row-item {
          font-size: 20px !important;
          color: #c3cbde !important;
        }
      }
    }
  }

  .item {
    width: 50%;
    align-items: center;
    /*.location{
       position: absolute;
       left: 20%;
    }*/
    .circle-hollow {
      width: 170px;
      height: 170px;
      border: 3px solid #4ecdc4; /* 边框样式 */
      border-radius: 50%;
      background-color: transparent; /* 透明背景 */
      display: flex;
      justify-content: center;
      align-items: center;
      letter-spacing:2px;
      flex-direction: column; /* 文字垂直排列 */
      box-shadow: 0 4px 8px rgba(0,0,0,0.1); /* 阴影效果 */
      .info{
        text-align: center;
        width: 140px;
        p{
          border-top: 1px solid #ddd;
        }
      }
    }
  }
}
</style>
