//预留转入库
<template>
  <div class="steel_inbound">
    <div class="sache">
      <el-form :inline="true">
        <el-form-item>
          <span class="text">入库时间：</span>
          <el-date-picker
            v-model="startTime"
            type="datetime"
            placeholder="选择日期"
            style="width: 200px;"
          >
          </el-date-picker>
          <span class="text">至</span>
          <el-date-picker
            v-model="endTime"
            type="datetime"
            placeholder="选择日期"
            style="width: 200px;"
          >
          </el-date-picker>
        </el-form-item>
        <el-input
          placeholder="请输入内容"
          v-model="inputText"
          clearable
          style="width: 200px;"
        >
        </el-input>
        <el-button type="primary" class="btn" @click="onclick">
          <i class="el-icon-search"></i>查询
        </el-button>
        <el-button type="primary" class="btn" @click="onreserved">
          预留
        </el-button>
        <el-button type="primary" class="btn" @click="exportAllReportToExcel">
          导出
        </el-button>
      </el-form>
    </div>
    <div class="table">
      <dilTable v-bind.sync="options" @func="func">
        <!-- <el-table-column fixed="right" label="操作" width="150">
								<template slot-scope="scope">
									<el-button type="text" size="mini" @click="inboundDetails(scope)">
										详情
									</el-button>
								</template>
				</el-table-column> -->
      </dilTable>
    </div>
  </div>
</template>

<script>
import { sjTime } from '@/utils/sharedJsFile'
import { getCookie } from '@/utils/util.js'
export default {
  data() {
    return {
      tableTitle: '一棒入库转预留(已上传金蝶)',
      inputText: '',
      startTime: null,
      endTime: null,
      options: {
        // first请求数据的地址
        requestUrl:
          '/api/v1/wms/getWmsReservedResult?apiId=371&warehouseId=' + 1
        // selectionType: "select",
        // mapList: [],
      },

      totalArr: [],
      dataColumnData: []
    }
  },
  methods: {
    func(res) {
      this.dataColumnData = res.columnData
      this.totalArr = res.list
    },
    exportAllReportToExcel() {
      var title = this.tableTitle
      let tHeader = []
      let filterVal = []
      this.dataColumnData.forEach(e1 => {
        if (tHeader.indexOf(e1.label) === -1) {
          tHeader.push(e1.label)
        }
        if (filterVal.indexOf(e1.prop) === -1) {
          filterVal.push(e1.prop)
        }
      })
      //导出为excel
      this.downloadLoading = true
      require.ensure([], () => {
        const {
          export_json_to_excel
        } = require('@/assets/excel/Export2Excel.js') //这里必须使用绝对路径，使用@/+存放export2Excel的路径
        // let list = this.$refs.excelDom.dataTabel;
        let data = this.totalArr.map(v => filterVal.map(j => v[j])) //3.formatJson格式转换
        export_json_to_excel(tHeader, data, title) // (title)导出的表格名称
      })
    },
    // inboundDetails(scope){
    //   	this.$router.push("/inboundDetails/" + scope.row.inboundId)
    // },
    onclick() {
      console.log('我尽力了')
      if (this.startTime && this.endTime) {
        this.options.requestQuery = {
          startTime: sjTime(this.startTime),
          endTime: sjTime(this.endTime)
        }
      }
      this.options.requestUrl =
        '/api/v1/wms/getWmsReservedResult?apiId=371&warehouseId=' +
        1 +
        '&con=' +
        this.inputText
    },
    selectionChange(selection) {
      this.options.mapList = selection
    },
    onreserved() {
      this.$router.push({
        path: '/bar1_addSteelReserved'
      })
    }
  }
}
</script>

<style lang="scss" scode>
.steel_inbound {
  .sache {
    height: 5rem;
    display: flex;
    align-items: center;
    padding-left: 1.875rem;
  }
}
</style>
