<!-- 搜索表单 -->
<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>
<!--    <SelectCompany-->
<!--      :placeholder="`选择租户`"-->
<!--      v-model:value="where.tenantName"-->
<!--      @done="chooseTenant"-->
<!--    />-->
    <a-input-search
      allow-clear
      placeholder="请输入关键词"
      style="width: 280px"
      v-model:value="where.keywords"
      @pressEnter="search"
      @search="search"
    />
  </a-space>
</template>

<script lang="ts" setup>
import {PlusOutlined} from '@ant-design/icons-vue';
import {watch} from 'vue';
import {OaAssetsSslParam} from "@/api/oa/oaAssetsSsl/model";
import useSearch from "@/utils/use-search";
import {Company} from "@/api/system/company/model";

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

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

// 表单数据
const {where} = useSearch<OaAssetsSslParam>({
  sslId: undefined,
  name: undefined,
  tenantName: undefined,
  keywords: ''
});

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

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

const chooseTenant = (data: Company) => {
  where.tenantName = data.tenantName;
  where.tenantId = data.tenantId;
  search();
};

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