<!-- 搜索表单 -->
<template>
  <a-space :size="10" style="flex-wrap: wrap">
    <a-input-search
      v-model:value="keywords"
      placeholder="搜索规格名称"
      allow-clear
      style="width: 200px"
      @search="search"
      @pressEnter="search"
    />
    <a-button type="primary" class="ele-btn-icon" @click="add">
      <template #icon><PlusOutlined /></template>
      <span>添加规格</span>
    </a-button>
    <a-button
      danger
      class="ele-btn-icon"
      :disabled="!selection?.length"
      @click="remove"
    >
      <template #icon><DeleteOutlined /></template>
      <span>批量删除</span>
    </a-button>
  </a-space>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
  import type { ShopSpecParam } from '@/api/shop/shopSpec/model';

  const props = withDefaults(
    defineProps<{
      selection?: any[];
    }>(),
    {}
  );

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

  const keywords = ref('');

  const search = () => {
    emit('search', { keywords: keywords.value || undefined });
  };

  const add = () => {
    emit('add');
  };

  const remove = () => {
    emit('remove');
  };
</script>
