<template>
  <div>
    <div class="mrg-b">
      <el-row type="flex" justify="start">
        <el-col :span="23"></el-col>
        <el-col :span="1">
          <!-- <el-button v-auth="50400030102" type="primary" @click="handleMoreSearch">更多</el-button> -->
          <el-row type="flex" justify="end">
              <el-button
                v-auth="50100030101"
                icon="el-icon-refresh"
                class="query__item"
                type="primary"
                @click="handleRefresh"
                plain
                circle
              ></el-button>
              <el-button
              v-if="false"
              icon="el-icon-download"
              type="primary"
              @click="handleExcel"
              plain
              circle
            ></el-button>
          </el-row>
        </el-col>
      </el-row>
    </div>
    <div class="inputBox">
      <el-form inline :model="query" ref="query" label-position="left">
        <el-form-item label="单据号" prop="orderNo">
          <el-input
            v-model="query.orderNo"
            @keyup.enter.native="handleSearch"
            placeholder="快捷查询(单据号)"
          ></el-input>
        </el-form-item>
        <el-form-item label="单据类型" prop="orderType">
          <el-select multiple v-model="orderType" @change="handleSelected">
            <el-option label="入库单" value="ASN"></el-option>
            <el-option label="出库单" value="SO"></el-option>
            <el-option label="装车单" value="LD"></el-option>
            <el-option label="调整单" value="AD"></el-option>
            <el-option label="转移单" value="TF"></el-option>
            <el-option label="质检单" value="QC"></el-option>
            <el-option label="加工单" value="KIT"></el-option>
            <el-option label="补货单" value="RP"></el-option>
            <el-option label="移动单" value="MV"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="费用时间">
          <el-date-picker
            v-model="date"
            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"
      @close="moreQueryVisible=false"
      @toGetList="getQueryList"
    ></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,
      orderType: [],
      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date: '',
      moreData: {}
    }
  },
  props: {
    selectIds: Array
  },
  methods: {
    // 获得生效时间
    getTime1 (val) {
      this.query.feeDateFm = val[0]
      this.query.feeDateTo = val[1]
      this.handleSearch()
    },
    handleSelected (val) {
      this.query.orderType = val.join(',')
      this.handleSearch()
    },

    handleRefresh () {
      this.orderType = []
      this.date = ''
      this.$refs.query.resetFields()
      this.$emit('getList')
    },
    // 搜索
    handleSearch () {
      const query = { ...this.query, orderNo: `%${this.query.orderNo || ''}%` }
      this.moreData = query
      this.$emit('getList', query)
    },

    // 更多查询数据
    getQueryList (query) {
      this.moreQueryVisible = false
      this.moreData = query
      this.$emit('getList', query)
    },

    // 更多搜索查询
    handleMoreSearch () {
      this.moreQueryVisible = true
    },
    handleExcel () {
      const url = this.$API.charging.order.getList
      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;
  }
}
.mrg-b {
  margin-bottom: 20px;
}
.mrg-l {
  margin-left: 10px;
}
.query {
  &__operations {
    float: left;
  }
  &__retrieve {
    float: right;
    .el-input {
      max-width: 180px;
    }
  }
  &__item {
    margin-left: 10px;
  }
}
</style>
