<!-- 搜索表单 -->
<template>
  <a-space>
    <a-input
      allow-clear
      placeholder="请输入用户id"
      v-model:value="where.userId"
      @pressEnter="search"
      @search="search"
      style="width: 240px"
    />
    <a-select ref="select" v-model:value="where.status" style="width: 120px">
      <a-select-option :value="0">查看全部</a-select-option>
      <a-select-option :value="1">只看未读</a-select-option>
    </a-select>
    <!--    <a-select ref="select" v-model:value="where.onlyFake" style="width: 120px">-->
    <!--      <a-select-option :value="false">查看全部</a-select-option>-->
    <!--      <a-select-option :value="true">只看僵尸</a-select-option>-->
    <!--    </a-select>-->
    <a-input-search
      allow-clear
      placeholder="请输入搜索关键词"
      v-model:value="where.keywords"
      @pressEnter="search"
      @search="search"
      style="width: 240px"
    />
    <a-button @click="reset">重置</a-button>
  </a-space>
</template>

<script lang="ts" setup>
  import useSearch from '@/utils/use-search';
  import { watch } from 'vue';
  import type { UserParam } from '@/api/system/user/model';
  import { ChatConversationParam } from '@/api/love/chat/model';

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

  const props = defineProps<{
    // 勾选的项目
    selection: [];
  }>();

  // 表单数据
  const { where, resetFields } = useSearch<ChatConversationParam>({
    userId: undefined,
    keywords: '',
    status: 0,
    onlyFake: false
  });

  /* 搜索 */
  const search = () => {
    emit('search', where);
  };

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

  // 监听字典id变化
  watch(
    () => props.selection,
    () => {}
  );
</script>
