<!-- 搜索表单 -->
<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>
<!--    <a-radio-group v-model:value="where.version" @change="search">-->
<!--      <a-radio-button :value="10"-->
<!--      >基础版-->
<!--      </a-radio-button-->
<!--      >-->
<!--      <a-radio-button :value="20"-->
<!--      >授权版-->
<!--      </a-radio-button-->
<!--      >-->
<!--      <a-radio-button :value="30"-->
<!--      >永久授权-->
<!--      </a-radio-button-->
<!--      >-->
<!--    </a-radio-group>-->
    <a-input-search
      allow-clear
      placeholder="请输入网站名称"
      style="width: 280px"
      v-model:value="where.keywords"
      @pressEnter="search"
      @search="search"
    />
    <a-button @click="reset">重置</a-button>
  </a-space>
</template>

<script lang="ts" setup>
import {PlusOutlined} from '@ant-design/icons-vue';
import {watch} from 'vue';
import useSearch from "@/utils/use-search";
import {OaAssetsDomainParam} from "@/api/oa/oaAssetsDomain/model";
import {OaAssetsSiteParam} from "@/api/oa/oaAssetsSite/model";
import {openSpmUrl} from "@/utils/common";

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

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

// 表单数据
const {where, resetFields} = useSearch<OaAssetsSiteParam>({
  websiteId: undefined,
  version: undefined,
  websiteName: undefined,
  keywords: ''
});

// 新增
const add = () => {
  // emit('add');
  openSpmUrl(`https://site.websoft.top/register`)
};

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

/*  重置 */
const reset = () => {
  resetFields();
  search();
};

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