Files
jinshen-website/app/components/pages/search/SearchTabs.vue
R2m1liA f1398a5545 feat: 为搜索条目添加细分类型
- 类型细分:有原先的四大分类添加细分类型,例如产品(原纸分切机)
- 接口调整:原先的type分类改为sectionType并将type作为细分类型使用
2025-12-05 16:49:09 +08:00

50 lines
1.3 KiB
Vue

<template>
<el-tabs v-model="activeTab">
<el-tab-pane
v-for="tab in tabs"
:key="tab.name"
:label="`${tab.label}(${resultCount[tab.name] || 0})`"
:name="tab.name"
>
<SearchResults
v-model:current-page="currentPage"
:search-items="searchItems"
:category="tab.name === 'all' ? undefined : tab.name"
/>
</el-tab-pane>
</el-tabs>
</template>
<script setup lang="ts">
const props = defineProps<{
// resultCount: Record<string, number>;
searchItems: SearchItemView[];
}>();
const tabs = [
{ name: 'all', label: $t('all') },
{ name: 'product', label: $t('search.sections.product') },
{ name: 'solution', label: $t('search.sections.solution') },
{ name: 'question', label: $t('search.sections.faq') },
{ name: 'document', label: $t('search.sections.document') },
];
const resultCount = computed(() => {
const map: Record<string, number> = { all: props.searchItems.length };
for (const item of props.searchItems) {
map[item.sectionType] = (map[item.sectionType] ?? 0) + 1;
}
return map;
});
// 分类控制
const activeTab = ref('all');
// 分页控制
const currentPage = ref(1);
watch(activeTab, () => {
currentPage.value = 1; // 重置页码
});
</script>