<!-- 搜索表单 -->
<template>
  <a-button type="primary" class="ele-btn-icon" v-if="!item" @click="add">
    <template #icon>
      <PlusOutlined />
    </template>
    <span>添加</span>
  </a-button>
  <!--  <a-space style="flex-wrap: wrap" v-else>-->
  <!--    <a-button class="ele-btn-icon" @click="openUrl(`/mp-list`)">-->
  <!--      <span>小程序概况</span>-->
  <!--    </a-button>-->
  <!--    <a-button class="ele-btn-icon" @click="openUrl(`/mp-pages`)">-->
  <!--      <span>页面管理</span>-->
  <!--    </a-button>-->
  <!--    <a-button class="ele-btn-icon" @click="openUrl(`/mp-field/${item.mpId}`)">-->
  <!--      <span>参数配置</span>-->
  <!--    </a-button>-->
  <!--    <a-button class="ele-btn-icon" @click="openUrl(`/mp-ad/${item.mpId}`)">-->
  <!--      <span>广告管理</span>-->
  <!--    </a-button>-->
  <!--    <a-button class="ele-btn-icon" @click="openUrl(`/mp-group`)">-->
  <!--      <span>卡片管理</span>-->
  <!--    </a-button>-->
  <!--    <a-button class="ele-btn-icon" @click="openUrl(`/mp-package`)">-->
  <!--      <span>分包管理</span>-->
  <!--    </a-button>-->
  <!--  </a-space>-->
</template>

<script lang="ts" setup>
  import { PlusOutlined } from '@ant-design/icons-vue';
  import { watch, ref } from 'vue';
  import { openUrl } from '@/utils/common';
  import { Mp } from '@/api/cms/mp/model';
  import { listMp } from '@/api/cms/mp';

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

  const item = ref<Mp>();

  const emit = defineEmits<{
    (e: 'add'): void;
  }>();

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

  const reload = () => {
    listMp({ type: 1 }).then((res) => {
      item.value = res[0];
    });
  };

  reload();

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