<script setup lang="ts">
import TableSearchFields, { type SearchField } from '@/components/custom/table-search-fields.vue';

defineOptions({ name: 'FeedbackSearch' });

const emit = defineEmits<{
  reset: [];
  search: [];
}>();

const model = defineModel<Api.Feedback.FeedbackSearchParams>('model', { required: true });

// 分类 / 状态筛选已迁移至左侧分面面板，搜索区只保留标题关键词
const fields: SearchField[] = [{ key: 'title', label: '标题', type: 'input', placeholder: '请输入标题关键词' }];

function reset() {
  emit('reset');
}

function search() {
  // 输入期不实时 trim（避免受控 input 吃掉词间空格）；提交前规整一次，空串归一为 undefined
  model.value.title = model.value.title?.trim() || undefined;
  emit('search');
}
</script>

<template>
  <TableSearchFields v-model="model" :fields="fields" :columns="2" @reset="reset" @search="search" />
</template>

<style scoped></style>
