<!-- 选择下拉框 -->
<template>
  <a-space>
    <a-button type="dashed" @click="reset">全部</a-button>
    <a-button
      v-for="(item, index) in data"
      :key="index"
      type="dashed"
      v-model:value.trim="where.progress"
      @click="search(item.value)"
      >{{ item.label }}</a-button
    >
  </a-space>
</template>

<script lang="ts" setup>
  import { CustomerParam } from '@/api/oa/customer/model';
  import useSearch from '@/utils/use-search';
  import { getDictionaryOptions } from '@/utils/common';

  const emit = defineEmits<{
    (e: 'search', where?: CustomerParam): void;
  }>();

  // 字典数据
  const data = getDictionaryOptions('customerFollowStatus');

  // 表单数据
  const { where, resetFields } = useSearch<CustomerParam>({
    progress: '',
    customerType: '',
    customerSource: '',
    betweenTime: '',
    userId: ''
  });

  /* 搜索 */
  const search = (val) => {
    where.progress = val == 'all' ? null : val;
    emit('search', where);
  };

  /*  重置 */
  const reset = () => {
    resetFields();
    search('all');
  };
</script>

<style lang="less"></style>
