<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="feeNameCode">
          <PublicQuery
            title="费用名称"
            single
            baseUrl="/chg_web/chgweb"
            cfgKey="chgWmsFeeName"
            :valueField.sync="query.feeNameCode"
            @change="handleSearch"
          ></PublicQuery>
        </el-form-item>
        <el-form-item label="费用类别" prop="feeType">
          <el-select multiple v-model="feeType" @change="handleSelected">
            <el-option label="运输费用" value="TRANSPORT_CHARGE"></el-option>
            <el-option label="特殊费用" value="SPECIAL_CHARGE"></el-option>
            <el-option label="增值服务费用" value="APPENDED_CHARGE"></el-option>
            <el-option label="服务费用" value="SERVICE_CHARGE"></el-option>
            <el-option label="全部" value="ALL"></el-option>
            <el-option label="理赔费用" value="CLAIM_CHARGE"></el-option>
            <el-option label="实际报账费用" value="DRIVER_REIMBURSE"></el-option>
            <el-option label="库存费用" value="KCFY"></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,
      feeType: [],
      pickerOptions2: {
        shortcuts: [today, yesterday, week, month, twoMonths, threeMonths]
      },
      date: '',
      moreData: {}
    }
  },
  props: {
    selectIds: Array
  },
  methods: {

    // 获得生效时间
    getTime1 (val) {
      this.query.feeDateFm = val ? val[0] : ''
      this.query.feeDateTo = val ? val[1] : ''
      this.handleSearch()
    },

    handleSelected (val) {
      this.query.feeType = val.join(',')
      this.handleSearch()
    },

    handleRefresh () {
      this.feeType = []
      this.date = ''
      this.$refs.query.resetFields()
      this.$emit('getList')
    },
    // 搜索
    handleSearch () {
      const query = { ...this.query }
      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.category.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>
