<script setup lang="ts">

import { formatTime } from '@/utils/formatTime'
import { ref } from 'vue'
import { getNews, type NewsData } from '@/api/home'
import { queryFieldMethod } from '@/utils/queryFieldMethod'
import { useRouter } from 'vue-router'

const router = useRouter();

const financialData = ref<NewsData[]>([])
const knowMore = (dickMapKey:string|undefined,dickMapValue:string|undefined)=>{
  router.push({
    path:'/creditDynamicsDetail',
    query:{
      dickMapKey,
      dickMapValue
    }
  });
}
const toDetail = (id:number|undefined)=>{
  if(!id){
    return
  }
  router.push({
    path:'/newsDetail',
    query:{
      id
    }
  })
}
const toLink = (index:number)=>{
  if(index == 1){
    window.open("http://hntzxm.fgw.hunan.gov.cn/home")
  }else if(index == 2){
    window.open("http://220.168.30.70:28889/portal_v2.jsp")
  }else if(index == 3){
    window.open("https://222.244.103.250:8181/pmp/a/login;jsessionid=fa168d5f90a3ed7b76a9bd5f2442#")
  }else if(index == 4){
    window.open("http://kjgl.kjt.hunan.gov.cn/egrantweb/")
  }else if(index == 5){
    window.open("https://zwfw-new.hunan.gov.cn/hnzwfw/1/186/187/index.htm")
  }
}
const init =async ()=>{
  const res1 = await getNews(queryFieldMethod('special_column','financial_need'))
  if(res1.code == 200){
    financialData.value = res1.data.slice(0,5);
  }
}
init()
</script>

<template>
  <div>
    <div class="w-912px bg-white ml-a mr-a text-16px pt-12px mb-10px line-height-44px border-dashed border-#e5e5e5 border-b-5px">
      <div class="w-240px border-solid border-#00306e border-b-5px relative">
        <img class="w-21px h-21px m-3px " src="/src/assets/img/信用小图标.png" />
        <span class="color-#003aac text-16px">政府项目资金需求发布及链接</span>
        <span class="absolute right--650px top-10px cursor-pointer text-#959595" @click="knowMore('financial_need','政府项目资金需求')">查看更多 ></span>
      </div>
      <div v-for="(item,index) in financialData" :key="index">
        <div class="flex justify-between">
          <div class="ml-20px cursor-pointer" @click="toDetail(item.id)">{{item.title}}</div>
          <div class="color-gray mr-20px text-14px">
            <span>数据来源:{{item.dataSource}}</span>
            <span>|</span>
            <span>{{formatTime(item.date)}}</span>
          </div>
        </div>
        <div class="h-1px bg-gray"></div>
      </div>
    </div>
    <div>
      <div class="w-912px ml-auto mr-auto flex flex-wrap justify-between bg-white">
        <div class="w-174px h-116px mr-10px relative cursor-pointer" @click="toLink(1)">
          <img class="w-100% h-100%" src="/static/bg8.jpg" />
          <div class="absolute bottom-0 text-center w-100% h-22px text-white text-14px pt-4px pb-4px bg-#00306e bg-opacity-72">湖南省发改委项目审批</div>
        </div>
        <div class="w-174px h-116px mr-10px relative cursor-pointer" @click="toLink(2)">
          <img class="w-100% h-100%" src="/static/bg9.jpg" />
          <div class="absolute bottom-0 text-center w-100% h-22px text-white text-14px pt-4px pb-4px bg-#00306e bg-opacity-72">湖南省财政厅项目资金管理</div>
        </div>
        <div class="w-174px h-116px mr-10px relative cursor-pointer" @click="toLink(3)">
          <img class="w-100% h-100%" src="/static/bg10.jpg" />
          <div class="absolute bottom-0 text-center w-100% h-22px text-white text-14px pt-4px pb-4px bg-#00306e bg-opacity-72">湖南省工信厅项目管理</div>
        </div>
        <div class="w-174px h-116px mr-10px relative cursor-pointer" @click="toLink(4)">
          <img class="w-100% h-100%" src="/static/bg11.jpg" />
          <div class="absolute bottom-0 text-center w-100% h-22px text-white text-14px pt-4px pb-4px bg-#00306e bg-opacity-72">科技厅</div>
        </div>
        <div class="w-174px h-116px relative cursor-pointer" @click="toLink(5)">
          <img class="w-100% h-100%" src="/static/bg12.jpg" />
          <div class="absolute bottom-0 text-center w-100% h-22px text-white text-14px pt-4px pb-4px bg-#00306e bg-opacity-72">人社厅</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>

</style>