<template>
  <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="客户代码" prop="custCode">
        <el-input class="filter-input" v-model="queryParams.custCode" placeholder="请输入客户代码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户名称" prop="custName">
        <el-input class="filter-input" v-model="queryParams.custName" placeholder="请输入客户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户类型" prop="custType">
        <el-select class="filter-input" v-model="queryParams.custType" placeholder="请选择客户类型" clearable >
          <el-option v-for="dict in dict.type.customer_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>
</template>
<script>
export default {
  name: 'CustSearcher',
  dicts: ['customer_type'],
  props: {
    showSearch: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      queryParams: {
        custCode: '', // 客户编码
        custName: '', // 客户名称
        custType: null
      }
    }
  },
  methods: {
    handleQuery() {
      this.$emit('search', { ...this.queryParams })
    },
    handleReset() {
      this.$refs.queryForm.resetFields()
      this.handleQuery()
      this.$emit('reset')
    }
  }
}
</script>
