<template>
<div>
<el-row class="query">
  <div class="query__retrieve">
    <!-- <el-input
      v-model="query.quickCondition"
      placeholder="快捷查询（入库单号）"
      @keyup.enter.native="e => toGetList(query)"
    ></el-input> -->
    <el-button v-auth="50940030102" class="query__item" type="primary" @click="moreQuery">更多</el-button>
    <el-button v-auth="50940030101" icon="el-icon-refresh" class="query__item" type="primary" @click="e => handelGetList(query)" plain circle></el-button>
    <el-button
    v-if="false"
      icon="el-icon-download"
      type="primary"
      @click="handleExcel"
      plain
      circle
    ></el-button>
    <MoreQuery
      :showMore="showMore"
      @close="showMore = false"
      @toGetList="toGetList"
    ></MoreQuery>
  </div>
</el-row>
  <div class="inputBox">
      <el-form inline :model="formData" ref="formData" label-position="left">
        <el-form-item
          label="仓库"
          prop="projectIds">
          <PublicQuery
          title="仓库"
          baseUrl="/enp_web/enpweb"
          cfgKey="enpWmsShareWareHouse"
          :valueField.sync="formData.projectIds"
          @change="handelKitType">
          </PublicQuery>
        </el-form-item>
        <el-form-item
          label="商品"
          prop="skuCode">
          <PublicQuery
          title="商品"
          baseUrl="/enp_web/enpweb"
          cfgKey="enpWmsSkuCode"
          :valueField.sync="formData.skuCode"
          @change="handelKitType">
          </PublicQuery>
        </el-form-item>
        <el-form-item
            label="货主编码"
            prop="ownerCode">
            <PublicQuery
            title="货主编码"
            baseUrl="/enp_web/enpweb"
            cfgKey="enpWmsCustomer"
            :valueField.sync="formData.ownerCode"
            @change="handelKitType">
            </PublicQuery>
      </el-form-item>
      <el-form-item label="订单时间">
        <el-date-picker
          v-model="dateTime"
          type="datetimerange"
          :picker-options="pickerOptions"
          :default-time="['00:00:00', '23:59:59']"
          format="yyyy-MM-dd HH:mm"
          value-format="yyyy-MM-dd HH:mm:ss"
          @change="dateTimeChange"
        ></el-date-picker>
        </el-form-item>
    </el-form>
  </div>
</div>
</template>

<script>
import MoreQuery from './MoreQuery'
import * as shortcuts from '@/config/shortcuts'
export default {
  components: { MoreQuery },
  created () {
  },
  mounted () {
  },

  data () {
    return {
      dateTime: '',
      query: {}, // 查询条件
      showMore: false, // 显示更多查询
      formData: {},
      pickerOptions: {
        shortcuts: { ...shortcuts }
      },
      moreData: {}
    }
  },
  methods: {
    handelKitType () {
      this.$emit('getList', this.formData)
    },
    // 查询
    toGetList (query = {}) {
      this.moreData = query
      this.$emit('getList', query)
    },
    handelGetList () {
      this.dateTime = ''
      this.$refs.formData.resetFields()
      this.$emit('getList')
    },
    // 点击更多查询
    moreQuery () {
      this.showMore = true
    },
    // 时间变化
    dateTimeChange (val) {
      this.formData.orderTimeForm = val ? val[0] : ''
      this.formData.orderTimeTo = val ? val[1] : ''
      this.$emit('getList', this.formData)
    },
    handleExcel () {
      const url = this.$API.enterprise.warehousesStockInList
      const options = this.moreData
      this.$exportExcel(url, options)
    },
  },
}
</script>

<style lang="scss" scoped>
 .inputBox {
    width: 100%;
    border: 1px solid #d1d5db;
    margin-top: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    .el-form-item {
      margin-bottom: 0px;
      margin-top: 10px;
    }
  }
  .query {
    &__retrieve {
      float: right;
      .el-input {
        max-width: 180px;
      }
    }
    &__item {
      margin-left: 10px;
    }
  }
</style>
