<!-- 搜索表单 -->
<template>
  <a-space :size="10" style="flex-wrap: wrap">
    <a-input-search
      allow-clear
      placeholder="请输入模板名称"
      v-model:value="keywords"
      style="width: 220px"
      @search="onSearch"
    />
    <a-button type="primary" class="ele-btn-icon" @click="add">
      <template #icon>
        <PlusOutlined />
      </template>
      <span>添加</span>
    </a-button>
    <a-button
      danger
      type="primary"
      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 { ShopExpressTemplateParam } from '@/api/shop/shopExpressTemplate/model';
  import type { ShopExpressTemplate } from '@/api/shop/shopExpressTemplate/model';

  const props = withDefaults(
    defineProps<{
      // 选中的表格数据
      selection?: ShopExpressTemplate[];
    }>(),
    {}
  );

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

  const keywords = ref('');

  // 搜索
  const onSearch = () => {
    emit('search', { title: keywords.value });
  };

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

  // 批量删除
  const remove = () => {
    emit('remove');
  };
</script>
