// 采购燃料新区汽运监控
<template>
  <div class="purchasFuelNewMonitor">
    <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="totalCapacity" :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/tms/getRLFLReport?apiId=382&orderType=7&startTime=null&endTime=null&i=" +new Date(),
      },
      startTime: null,
      endTime: null,
      //合计净重
      totalNumber: 0,
      //合计车数
      totalCapacity: 0,
      tableTitle:'采购燃料新区统计报表'
    };
  },
  methods: {
    refresh(){
      this.$router.go(0);
    },
    func(res){
      console.log(res)
      var resultNetWeightTotal = 0
      res.list.forEach(e => {
        resultNetWeightTotal = resultNetWeightTotal+e.resultNetWeight
      });
      this.totalNumber = resultNetWeightTotal.toFixed(2) + " t"
      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/tms/getRLFLReport?apiId=382&orderType=7&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
        }else{
          this.startTime = null;
          this.endTime = null;
          this.$message.warning('开始时间要比结束时间早')
        }
      }else{
        this.option.requestUrl = "/api/v1/tms/getRLFLReport?apiId=382&orderType=7&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
      }
    },
  },
};
</script>

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