<template>
  <CommonListPage 
    itemType="article-common"
    :dropDownNames="dropdownNames"
    :tabs="[
      { id: 0, text: '世界走透透' },
      { id: 1, text: '海洋文化' },
    ]"
    :startTabIndex="startTab"
    :load="loadData" 
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { GetContentListParams } from '@/api/CommonContent';
import SeaContent from '@/api/introduction/SeaContent';
import NewsIndexContent from '@/api/news/NewsIndexContent';
import CommonListPage, { type DropDownNames } from '@/pages/article/common/CommonListPage.vue';
import ResultContent from '@/api/research/ResultContent';

const dropdownNames = ref<DropDownNames[]>([]);
const startTab = ref(0);
async function loadData(
  page: number, 
  pageSize: number,
  searchText: string,
  dropDownValues: number[],
  tabSelect: number,
) {
  let res;
  switch (tabSelect) {
    case 0: 
      res = (await NewsIndexContent.getContentList(new GetContentListParams()
        .setKeywords(searchText)
        .setMainBodyColumnId([260, 261, 262])
      , page, pageSize))
      break;
    default:
    case 1: 
      res = (await SeaContent.getContentList(new GetContentListParams()
        .setKeywords(searchText)
      , page, pageSize));
    break;
  }
  res.list.forEach((item) => {
    item.desc = item.from ? `来源：${item.from}` : '';
    item.bottomTags = [
      item.levelText, 
      item.mainBodyColumnName, 
      item.ichTypeText, 
      item.batchText,
    ]
  })
  return res;
}
</script>
