<template>
  <div class="mrg-b">
    <div>
      <!-- <el-input class="inline" v-model="query.queryOwnerCode"  @keyup.enter.native="handleSearch" placeholder="快捷查询(货主编码)"></el-input> -->
      <!-- <el-button class="mrg-l" v-auth="50930040102" type="primary" @click="handleMoreSearch">更多</el-button> -->
      <el-row type="flex" justify="start">
        <el-col :span="23"></el-col>
        <el-col :span="1">
          <el-button v-auth="50930040101" icon="el-icon-refresh" class="query__item" type="primary" @click="handleRefresh" plain circle></el-button>
        </el-col>
      </el-row>

    </div>
    <div class="inputBox">
      <el-form inline :model="query" ref="query" label-position="left">
       <el-form-item
        label="货主"
        prop="ownerCode">
        <PublicQuery
        title="货主"
        baseUrl="/rep_web/repweb"
        cfgKey="repWmsCustomer"
        :valueField.sync="query.ownerCode"
        @change="handleSearch">
        </PublicQuery>
      </el-form-item>
      <el-form-item
        label="创建时间">
      <el-date-picker
        v-model="date1"
        type="datetimerange"
        format="yyyy-MM-dd HH:mm"
        value-format="yyyy-MM-dd HH:mm:ss"
        :default-time="['00:00:00', '23:59:59']"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        :picker-options="pickerOptions2"
        @change="getTime1">
      </el-date-picker>
    </el-form-item>
      </el-form>
    </div>
    <more-query
    :moreQueryVisible="moreQueryVisible"
    @toGetList="toGetList"
    @close="moreQueryVisible=false"></more-query>
  </div>
</template>
<script>
import { today, yesterday, week, month, twoMonths, threeMonths } from '@/config/shortcuts'
import MoreQuery from './more-query'
export default {
  components: {
    MoreQuery
  },
  data () {
    return {
      query: {},
      moreQueryVisible: false,
      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date1: ''
    }
  },
  methods: {
    handleRefresh () {
      this.date1 = ''
      this.$refs.query.resetFields()
      this.$emit('getList')
    },
    // 搜索
    handleSearch () {
      const query = { ...this.query }
      this.$emit('getList', query)
    },
    // 获得生效时间
    getTime1 (val) {
      this.query.fromTime = val ? val[0] : ''
      this.query.toTime = val ? val[1] : ''
      this.handleSearch()
    },

    // 更多搜索
    handleMoreSearch () {
      this.moreQueryVisible = true
    },

    toGetList (query) {
      this.moreQueryVisible = false
      this.$emit('getList', query)
    },

  }
}
</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;
  }
}
  .mrg-b{
        margin-bottom: 20px;
    }
    .mrg-l{
        margin-left:10px;
    }
  .inline{
    width: 15%
  }
   .query {
    &__operations {
      float: left;
    }
    &__retrieve {
      float: right;
      .el-input {
        max-width: 180px;
      }
    }
    &__item {
      margin-left: 10px;
    }
  }
</style>
