<template>
  <div class="xl:w-screen-xl m-auto px-4 sm:px-0">
    <el-row :gutter="24" id="container" class="clearfix">
      <el-col :span="8" :xs="24">
        <el-card shadow="hover" :body-style="{ padding: '0px' }" class=" hover:bg-gray-50 cursor-pointer mb-5" >
          <template #header>
            <div class="text-lg font-medium flex items-center justify-between cursor-text">
              <el-space class="text-xl text-green-600 font-bold"><el-icon><Avatar /></el-icon>招生就业</el-space>
              <nuxt-link :to="`/article/4155.html`" class="font-normal text-sm text-gray-400 flex items-center cursor-pointer">查看更多<el-icon><ArrowRight /></el-icon></nuxt-link>
            </div>
          </template>
          <div class="px-5">
            <template v-for="(item,index) in zsList" :key="index">
              <nuxt-link :to="`/detail/${item.articleId}.html`" class="item">
                <div class="text-lg my-3 flex justify-between">
                  <span class="title text-gray-800 hover:text-green-700 line-clamp-2 text-sm lg:text-lg">{{ item.title }}</span>
                  <span class="text-gray-400 text-sm text-right w-[100px]">{{  dayjs(item.createTime).format('YYYY.MM.DD') }}</span>
                </div>
              </nuxt-link>
            </template>
          </div>
        </el-card>
      </el-col>
      <el-col :span="8" :xs="24">
        <el-card shadow="hover" :body-style="{ padding: '0px' }" class=" hover:bg-gray-50 cursor-pointer mb-5" >
          <template #header>
            <div class="text-lg font-medium flex items-center justify-between cursor-text">
              <el-space class="text-xl text-green-600 font-bold"><el-icon><BellFilled /></el-icon>通知公告</el-space>
              <nuxt-link :to="`/article/4152.html`" class="font-normal text-sm text-gray-400 flex items-center cursor-pointer">查看更多<el-icon><ArrowRight /></el-icon></nuxt-link>
            </div>
          </template>
          <div class="px-5">
            <template v-for="(item,index) in tzList" :key="index">
              <nuxt-link :to="`/detail/${item.articleId}.html`" class="item">
                <div class="text-lg my-3 flex justify-between">
                  <span class="title text-gray-800 hover:text-green-700 line-clamp-2  text-sm lg:text-lg">{{ item.title }}</span>
                  <span class="text-gray-400 text-sm text-right w-[100px]">{{  dayjs(item.createTime).format('YYYY.MM.DD') }}</span>
                </div>
              </nuxt-link>
            </template>
          </div>
        </el-card>
      </el-col>
      <el-col :span="8" :xs="24">
        <el-card shadow="hover" :body-style="{ padding: '0px' }" class=" hover:bg-gray-50 cursor-pointer mb-5" >
          <template #header>
            <div class="text-lg font-medium flex items-center justify-between cursor-text">
              <el-space class="text-xl text-green-600 font-bold"><el-icon><Finished /></el-icon>教学教研</el-space>
              <nuxt-link :to="`/article/4159.html`" class="font-normal text-sm text-gray-400 flex items-center cursor-pointer">查看更多<el-icon><ArrowRight /></el-icon></nuxt-link>
            </div>
          </template>
          <div class="px-5">
            <template v-for="(item,index) in jyList" :key="index">
              <nuxt-link :to="`/detail/${item.articleId}.html`" class="item">
                <div class="text-lg my-3 flex justify-between">
                  <span class="title text-gray-800 hover:text-green-700 line-clamp-2  text-sm lg:text-lg">{{ item.title }}</span>
                  <span class="text-gray-400 text-sm text-right w-[100px]">{{  dayjs(item.createTime).format('YYYY.MM.DD') }}</span>
                </div>
              </nuxt-link>
            </template>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
  <div v-if="disabled" class="px-1 text-center text-gray-500 min-h-xs">
    没有更多了
  </div>
</template>

<script lang="ts" setup>
import {navigateTo} from "#imports";
import {
  ArrowRight,
  Tickets,
  Avatar,
  BellFilled,
  Finished

} from '@element-plus/icons-vue'
import dayjs from "dayjs";
import type {CmsArticle} from "~/api/cms/cmsArticle/model";
import {listCmsArticle, pageCmsArticle} from "~/api/cms/cmsArticle";
import type {CmsArticleParam} from "~/api/cms/cmsArticle/model";
import Carousel from "~/components/Index/Carousel.vue";
import HotNewsCarousel from "~/components/Index/HotNewsCarousel.vue";

const props = withDefaults(
    defineProps<{
      param?: CmsArticleParam;
      disabled?: boolean;
      categoryId?: number;
      title?: string;
      comments?: string;
      fit?: any;
    }>(),
    {
      fit: 'cover'
    }
);

const emit = defineEmits<{
  (e: 'done'): void;
}>();

const zsList = ref<CmsArticle[]>([]);
const tzList = ref<CmsArticle[]>([]);
const jyList = ref<CmsArticle[]>([]);

// 请求数据
const reload = async () => {
  pageCmsArticle({
    limit: 8,
    recommend: 1,
    parentId: 4132
  }).then(res => {
    zsList.value = res?.list || [];
  })
  pageCmsArticle({
    limit: 8,
    recommend: 1,
    categoryId: 4152
  }).then(res => {
    tzList.value = res?.list || [];
  })
  pageCmsArticle({
    limit: 8,
    parentId: 4133
  }).then(res => {
    jyList.value = res?.list || [];
  })
}
reload();
</script>
