//收发存报表
<template>
  <div class="sendReceive">
    <div class="frameCalculation">
      <span>库存时间：</span>
      <el-date-picker
        v-model="startTime"
        type="date"
        placeholder="选择日期"
      >
      </el-date-picker>
      <!-- <span>至</span>
      <el-date-picker
        v-model="endTime"
        type="date"
        placeholder="选择日期"
      >
      </el-date-picker> -->
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <el-button type="primary" @click="exportData()"><i class="el-icon-download"></i>导出(Excel)</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="totalNumber" :disabled="true" style="width: 150px;"></el-input>
    </div>
    <div class="table">
      <dilTable ref="excelDom" v-bind.sync="option" @func="func"></dilTable>
    </div>
  </div>
</template>

<script>
import { sjTime } from '@/utils/sharedJsFile'
export default {
  data() {
    return {
      option: {
        requestUrl: "/api/v1/wms/getSendReceive?apiId=97&startTime=null&endTime=null&i=" +new Date(),
      },
      startTime: null,
      endTime: null,
      //合计今日库存
      totalNumber: 0,
      tableTitle:'收发存报表'
    };
  },
  methods: {
    refresh(){
      this.$router.go(0);
    },
    func(res){
      console.log(res)
      var lastDayTotal = 0
      res.list.forEach(e => {
        lastDayTotal = lastDayTotal+e.send_receive_thisday_inventory
      });
      this.totalNumber = lastDayTotal
      //this.totalCapacity = res.total;
      //获取总记录条数作为合计车数
      // this.totalCapacity = res.total;
      this.isKuang = false;
    },
    onclick() {
      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/getSendReceive?apiId=97&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
        }else{
          this.startTime = null;
          this.endTime = null;
          this.$message.warning('开始时间要比结束时间早')
        }
      }else{
        this.option.requestUrl = "/api/v1/wms/getSendReceive?apiId=97&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
      }
    },
  },
};
</script>

<style lang="scss">
.sendReceive {
  .frameCalculation {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    padding-left: 50px;
    .el-date-editor{
      margin: 20px;
    }
  }
}
</style>