<template>
  <div>
    <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="68px">
      <el-form-item label="司机姓名" prop="driverName">
        <el-input class="filter-input" v-model="queryParams.driverName" placeholder="请输入司机姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="手机号" prop="mobileNumber">
        <el-input class="filter-input" v-model="queryParams.mobileNumber" placeholder="请输入手机号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="驾驶证类型" prop="licenseType" label-width="90px">
        <el-select class="filter-input" v-model="queryParams.licenseType" placeholder="请选择驾驶证类型" clearable multiple>
          <el-option v-for="dict in dict.type.license_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="handleReset">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  name: 'DriverSearcher',
  dicts: ['license_type'],
  props: {
    showSearch: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      queryParams: {
        driverName: '',
        mobileNumber: '',
        licenseType: null
      },
    }
  },
  methods: {
    handleQuery() {
      this.$emit('search', { ...this.queryParams })
    },
    handleReset() {
      this.$refs.queryForm.resetFields()
      this.handleQuery()
      this.$emit('reset')
    }
  }
}
</script>
