//出库统计炉号生产数量
<template>
  <div class="steel_inbound">
    <div class="sache">
      <span>出库时间：</span>
      <el-date-picker v-model="startTime" type="datetime" placeholder="选择日期">
      </el-date-picker>
      <span>至</span>
      <el-date-picker v-model="endTime" type="datetime" placeholder="选择日期">
      </el-date-picker>
           <el-input
        placeholder="请输入炉号"
        v-model="textInput"
        clearable>
      </el-input>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <!-- <el-button type="primary" @click="refresh">
        <i class="el-icon-refresh"></i>刷新
      </el-button> -->
      <span style="margin-left: 1rem;">总件数：</span>
      <el-input v-model="totalNumber" :disabled="true" style="width: 150px;"></el-input>
      <span style="margin-left: 1rem;">总重量：</span>
      <el-input v-model="totalWeight" :disabled="true" style="width: 150px;"></el-input>
    </div>
    <div class="table">
      <dilTable v-bind.sync="option" @func="func">
      </dilTable>
    </div>
  </div>
</template>

<script>
import { sjTime } from "@/utils/sharedJsFile";
export default {
  data(){
    return{
      textInput:"",
      startTime: null,
      endTime: null,
      totalNumber:0,
      totalWeight:0,
      option:{
        // first请求数据的地址
        requestUrl: "/api/v1/wms/getWmsOutboundResultStatistics?apiId=446&warehouseId="+2+"&startTime=null&endTime=null&i=" +new Date()+"&con="+this.textInput,
      },
    }
  },
  methods:{
      refresh(){
      this.$router.go(0);
    },
    func(res){
      console.log(res)
      var total1 = 0
      var total2 = 0
      res.list.forEach(e => {
        total1 = total1+e.coun
        total2 = total2+e.theoreticalWeight
      });
  
      this.totalNumber = total1
      this.totalWeight = total2
    },
   onclick() {
     console.log("textInput",this.textInput);
      let startTime = null;
      let endTime = null;
      if(this.startTime){
        startTime = sjTime(this.startTime);
      }
      if(this.endTime){
        endTime = sjTime(this.endTime);
      }
      if(startTime && endTime){
        if(startTime < endTime){
          this.option.requestUrl = "/api/v1/wms/getWmsOutboundResultStatistics?apiId=446&warehouseId="+2+"&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date()+"&con="+this.textInput;
        }else{
          this.startTime = null;
          this.endTime = null;
          this.$message.warning('开始时间要比结束时间早')
        }
      }else{
        this.option.requestUrl = "/api/v1/wms/getWmsOutboundResultStatistics?apiId=446&warehouseId="+2+"&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date()+"&con="+this.textInput;
      }
    },
    selectionChange(selection) {
      this.options.mapList = selection;
    },
  }
}
</script>

<style lang="scss" scode>
.steel_inbound{
  .sache{
    height: 5rem;
    display: flex;
    align-items: center;
    padding-left: 1.875rem;
     .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
}
</style>