<!-- 搜索表单 -->
<template>
  <a-space :size="10" style="flex-wrap: wrap">
    <a-button type="primary" class="ele-btn-icon" @click="add">
      <template #icon>
        <PlusOutlined />
      </template>
      <span>添加</span>
    </a-button>
    <DictSelect
      dict-code="cardPlanId"
      class="form-item"
      placeholder="按会员卡分组"
      style="width: 180px"
      v-model:value="where.cardCode"
      @change="handleSearch"
    />
    <!--    <a-radio-group v-model:value="where.cardCode" @change="handleSearch">-->
    <!--      <a-radio-button :value="`月/年卡`">月/年卡</a-radio-button>-->
    <!--      <a-radio-button :value="`次卡`">次卡</a-radio-button>-->
    <!--      <a-radio-button :value="`充值卡`">充值卡</a-radio-button>-->
    <!--    </a-radio-group>-->
  </a-space>
</template>

<script lang="ts" setup>
  import { PlusOutlined } from '@ant-design/icons-vue';
  import type { GradeParam } from '@/api/user/grade/model';
  import { watch } from 'vue';
  import useSearch from '@/utils/use-search';

  const props = withDefaults(
    defineProps<{
      // 选中的角色
      selection?: [];
    }>(),
    {}
  );

  const emit = defineEmits<{
    (e: 'search', where?: GradeParam): void;
    (e: 'add'): void;
    (e: 'remove'): void;
    (e: 'batchMove'): void;
  }>();

  // 新增
  const add = () => {
    emit('add');
  };

  // 表单数据
  const { where } = useSearch<any>({
    cardCode: undefined
  });

  const handleSearch = () => {
    emit('search', where);
  };

  watch(
    () => props.selection,
    () => {}
  );
</script>
