<template>
  <CommonListPage 
    title="闽南民俗"
    itemType="image-large-2"
    detailsPage="custom"
    showTotal
    :dropDownNames="dropdownNames"
    :load="loadData" 
    @goCustomDetails="handleDetils"
  />
  <!--  -->
</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';
import { navTo } from '@/components/utils/PageAction';

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

async function loadData(
  page: number, 
  pageSize: number,
  searchText: string,
  dropDownValues: number[],
  tabSelect: number,
) {
  const res = await CommonContent.getContentList(new GetContentListParams()
    .setKeywords(searchText)
    .setModelId(4)
    .setMainBodyColumnId([ 245, 248 ])
  , page, pageSize);
  res.list.forEach((item) => {
    item.pageType = 'news';
  });

  (await ProjectsContent.getContentList(new GetContentListParams()
    .setKeywords('民俗 ' + searchText)
  , 1, 20)).list.forEach((item) => {
    item.pageType = 'intangible';
    item.bottomTags = [
      item.levelText, 
      item.ichTypeText, 
      item.batchText,
      item.regionText,
    ]
    res.list.push(item);
  });
  return { list: res.list, total: res.total }
}

function handleDetils(item: any) {
  if (item.pageType == 'news') {
    navTo('/pages/article/details', {
      modelId: item.modelId,
      mainBodyColumnId: item.mainBodyColumnId,
      id: item.id,
    });
  } else {
    navTo('/pages/inhert/intangible/details', {
      id: item.id,
    });
  }
}
</script>