<template>
  <div>
    <div class="mrg-b">
      <el-row type="flex" justify="start">
        <el-col :span="19"></el-col>
        <el-col :span="5" >
          <el-row :span="24" type="flex" justify="end">
            <el-col :span="14" >
               <el-input v-if="tabIndex!==2"  v-model="query.quickCondition" @keyup.enter.native="handleSearch" placeholder="快捷查询(入库单号)"></el-input>
                <el-input v-else v-model="query.quickCondition" @keyup.enter.native="handleSearch" placeholder="快捷查询(出库单号)"></el-input>
            </el-col>
            <el-col :span="10">
              <el-button class="mrg-l" v-auth="50100040102" type="primary" @click="handleMoreSearch">更多</el-button>
                <el-button v-auth="50100040101" icon="el-icon-refresh" class="query__item" type="primary" @click="handleSearch" plain circle></el-button>
                <el-button
                v-if="false"
                    icon="el-icon-download"
                    type="primary"
                    @click="handleExcel"
                    plain
                    circle
                  ></el-button>
            </el-col>
          </el-row>
        </el-col>
      </el-row>

    </div>
    <MoreQuery
    :moreQueryVisible="moreQueryVisible"
    :tabIndex="tabIndex"
    @close="moreQueryVisible=false"
    @toGetList="toGetList"></MoreQuery>
  </div>
</template>
<script>
import MoreQuery from './more-query'
export default {
  components: {
    MoreQuery
  },
  data () {
    return {
      query: {},
      moreQueryVisible: false,
      moreData: {}
    }
  },
  props: {
    tabIndex: Number,
    urlKey: String,
    type: String
  },
  methods: {
    handleSearch () {
      const query = { quickCondition: `%${this.query.quickCondition || ''}%` }
      this.$emit('getList', this.urlKey, query)
    },
    handleMoreSearch () {
      this.moreQueryVisible = true
    },
    toGetList (query) {
      this.moreQueryVisible = false
      this.$emit('getList', this.urlKey, query)
    },
    handleExcel () {
      const url = this.$API.stockIn.Putaway[this.urlKey]
      const options = { ...{ queryOrderType: this.type }, ...this.moreData }
      this.$exportExcel(url, options)
    },
  }
}
</script>
<style lang="scss" scoped>
    .mrg-b{
        margin-bottom: 20px;
    }
    .mrg-l{
        margin-left:10px;
    }

</style>
