<template>
  <CommonListPage 
    title="闽南民俗"
    itemType="image-large-2"
    :detailsPage="[
      '/pages/article/details',
      '/pages/inhert/intangible/details',
    ]"
    showTotal
    :dropDownNames="dropdownNames"
    :load="loadData" 
    :tabs="[
      { id: 0, name: '民俗资讯' },
      { id: 1, name: '非遗民俗' },
    ]"
    :detailsParams="{
      modelId: 4,
    }"
  />
  <!--  -->
</template>

<script setup lang="ts">
import { ref } from 'vue';
import CommonListPage, { type DropDownNames } from '@/pages/article/common/CommonListPage.vue';
import CommonContent, { GetContentListParams } from '@/api/CommonContent';
import ProjectsContent from '@/api/inheritor/ProjectsContent';

const dropdownNames = ref<DropDownNames[]>([]);

async function loadData(
  page: number, 
  pageSize: number,
  searchText: string,
  dropDownValues: number[],
  tabSelect: number,
) {
  let res;
  switch (tabSelect) {
    case 1:
      res = await ProjectsContent.getContentList(new GetContentListParams()
        .setKeywords('民俗 ' + searchText)
      , page, pageSize);
      res.list.forEach((item) => {
        item.bottomTags = [
          item.levelText, 
          item.ichTypeText, 
          item.batchText,
          item.regionText,
        ]
      })
      break;
    case 0:
    default:
      res = await CommonContent.getContentList(new GetContentListParams()
        .setKeywords(searchText)
        .setModelId(4)
        .setMainBodyColumnId([ 245,248 ])
      , page, pageSize);
      break;
  }
  return { list: res.list, total: res.total }
}
</script>