提交 eadce0bf authored 作者: 朱政's avatar 朱政

feat:首页风险信号与后端对接口

上级 b7c44603
流水线 #535 已通过 于阶段
in 1 分 46 秒
...@@ -17,6 +17,14 @@ export function getLatestRisks() { ...@@ -17,6 +17,14 @@ export function getLatestRisks() {
}); });
} }
// 中美博弈概览V2:首页最新风险动态(10条 + 各类数量/总数)
export function getLatestRisk() {
return request({
method: "GET",
url: `/api/rivalryIndexV2/LatestRisk`
});
}
// 中美博弈概览V2:美对华制裁措施数量趋势 // 中美博弈概览V2:美对华制裁措施数量趋势
export function geDomainContainmentTrend(params) { export function geDomainContainmentTrend(params) {
return request({ return request({
......
...@@ -43,15 +43,10 @@ ...@@ -43,15 +43,10 @@
<div style="display: flex"> <div style="display: flex">
<!-- 风险信号列表 --> <!-- 风险信号列表 -->
<div class="risk-signals" ref="riskSignalsRef"> <div class="risk-signals" ref="riskSignalsRef">
<div <div class="risk-signals-item" v-for="(item, index) in warningList"
class="risk-signals-item"
v-for="(item, index) in warningList"
:key="item.signalId != null ? String(item.signalId) : 'risk-' + index" :key="item.signalId != null ? String(item.signalId) : 'risk-' + index"
@mouseenter="onMouseEnter(item, index)" @mouseenter="onMouseEnter(item, index)" @mouseleave="onMouseLeave" @click.stop
@mouseleave="onMouseLeave" :class="['risk-signals-item', { 'risk-signals-item-hightLight': riskSignalActiveIndex === index }]">
@click.stop
:class="['risk-signals-item', { 'risk-signals-item-hightLight': riskSignalActiveIndex === index }]"
>
<div class="item-left" :class="{ <div class="item-left" :class="{
'item-status-1': item.signalLevel === '特别重大', 'item-status-1': item.signalLevel === '特别重大',
'item-status-2': item.signalLevel === '重大风险', 'item-status-2': item.signalLevel === '重大风险',
...@@ -132,7 +127,8 @@ ...@@ -132,7 +127,8 @@
import { color } from "echarts"; import { color } from "echarts";
import { onMounted, ref, onUnmounted, computed } from "vue"; import { onMounted, ref, onUnmounted, computed } from "vue";
import WaveBall from "./WaveBall.vue"; import WaveBall from "./WaveBall.vue";
import { getLatestRiskUpdates, getLatestRisks } from "@/api/zmOverview/risk/index.js"; import { getLatestRisk } from "@/api/zmOverview/risk/index.js";
import { getRiskSignalInfoById } from "@/api/riskSignal/index.js";
import router from "@/router/index"; import router from "@/router/index";
import { navigateToViewRiskSignal } from "@/utils/riskSignalOverviewNavigate"; import { navigateToViewRiskSignal } from "@/utils/riskSignalOverviewNavigate";
import icon1 from "./icon/title-1.svg"; import icon1 from "./icon/title-1.svg";
...@@ -315,12 +311,14 @@ const cardShowIndex4 = ref(0); ...@@ -315,12 +311,14 @@ const cardShowIndex4 = ref(0);
// 最新风险动态统计 // 最新风险动态统计
const handleGetLatestRiskUpdates = async () => { const handleGetLatestRiskUpdates = async () => {
try { try {
const params = { const res = await getLatestRisk();
currentDate: "本周" console.log("最新风险动态", res);
};
const res = await getLatestRiskUpdates(params);
console.log("最新风险动态统计1", res);
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
const d = res.data;
const formatChange = (n) => {
const v = Number(n) || 0;
return v === 0 ? "无新增" : String(v);
};
sections.value = [ sections.value = [
{ {
// title: res.data.policiesRegulations.hotspotTitle, // title: res.data.policiesRegulations.hotspotTitle,
...@@ -328,16 +326,16 @@ const handleGetLatestRiskUpdates = async () => { ...@@ -328,16 +326,16 @@ const handleGetLatestRiskUpdates = async () => {
waveBall: [ waveBall: [
{ {
percent: 30, // 估算的百分比 percent: 30, // 估算的百分比
count: res.data.bill.total, count: d.billRiskTotal ?? 0,
change: res.data.bill.dailyIncrement, change: formatChange(d.billRiskNum),
unit: "项", unit: "项",
title: "法案(提出)", title: "法案(提出)",
type: "法案" type: "法案"
}, },
{ {
percent: 20, // 估算的百分比 percent: 20, // 估算的百分比
count: res.data.administrativeOrder.total, count: d.orderRiskTotal ?? 0,
change: res.data.administrativeOrder.dailyIncrement, change: formatChange(d.orderRiskNum),
unit: "个", unit: "个",
title: "政令", title: "政令",
type: "行政令" type: "行政令"
...@@ -350,8 +348,8 @@ const handleGetLatestRiskUpdates = async () => { ...@@ -350,8 +348,8 @@ const handleGetLatestRiskUpdates = async () => {
waveBall: [ waveBall: [
{ {
percent: 10, // 估算的百分比 percent: 10, // 估算的百分比
count: res.data.Entities.total, count: d.entityRiskTotal ?? 0,
change: res.data.Entities.dailyIncrement, change: formatChange(d.entityRiskNum),
unit: "次", unit: "次",
title: "实体清单", title: "实体清单",
...@@ -359,8 +357,8 @@ const handleGetLatestRiskUpdates = async () => { ...@@ -359,8 +357,8 @@ const handleGetLatestRiskUpdates = async () => {
}, },
{ {
percent: 20, // 估算的百分比 percent: 20, // 估算的百分比
count: res.data.CCL.total, count: d.cclRiskTotal ?? 0,
change: res.data.CCL.dailyIncrement, change: formatChange(d.cclRiskNum),
unit: "次", unit: "次",
title: "CCL", title: "CCL",
type: "CCL" type: "CCL"
...@@ -373,16 +371,16 @@ const handleGetLatestRiskUpdates = async () => { ...@@ -373,16 +371,16 @@ const handleGetLatestRiskUpdates = async () => {
waveBall: [ waveBall: [
{ {
percent: 15, // 估算的百分比 percent: 15, // 估算的百分比
count: res.data.SDN.total, count: d.sdnRiskTotal ?? 0,
change: res.data.SDN.dailyIncrement, change: formatChange(d.sdnRiskNum),
unit: "次", unit: "次",
title: "SDN", title: "SDN",
type: "SDN" type: "SDN"
}, },
{ {
percent: 5, // 估算的百分比 percent: 5, // 估算的百分比
count: res.data.militaryInvolvement.total, count: d.armyRiskTotal ?? 0,
change: res.data.militaryInvolvement.dailyIncrement, change: formatChange(d.armyRiskNum),
unit: "家", unit: "家",
title: "涉军企业", title: "涉军企业",
type: "涉军企业" type: "涉军企业"
...@@ -395,24 +393,24 @@ const handleGetLatestRiskUpdates = async () => { ...@@ -395,24 +393,24 @@ const handleGetLatestRiskUpdates = async () => {
waveBall: [ waveBall: [
{ {
percent: 3, // 估算的百分比 percent: 3, // 估算的百分比
count: res.data["337Survey"].total, count: d.m337RiskTotal ?? 0,
change: res.data["337Survey"].dailyIncrement, change: formatChange(d.m337RiskNum),
unit: "次", unit: "次",
title: "337调查", title: "337调查",
type: "337调查" type: "337调查"
}, },
{ {
percent: 3, // 估算的百分比 percent: 3, // 估算的百分比
count: res.data["232Survey"].total, count: d.m232RiskTotal ?? 0,
change: res.data["232Survey"].dailyIncrement, change: formatChange(d.m232RiskNum),
unit: "次", unit: "次",
title: "232调查", title: "232调查",
type: "232调查" type: "232调查"
}, },
{ {
percent: 3, // 估算的百分比 percent: 3, // 估算的百分比
count: res.data["301Survey"].total, count: d.m301RiskTotal ?? 0,
change: res.data["301Survey"].dailyIncrement, change: formatChange(d.m301RiskNum),
unit: "次", unit: "次",
title: "301调查", title: "301调查",
type: "301调查" type: "301调查"
...@@ -454,12 +452,60 @@ const hotNewsList = ref([ ...@@ -454,12 +452,60 @@ const hotNewsList = ref([
//最新风险信号 //最新风险信号
const handleGetLatestRisks = async () => { const handleGetLatestRisks = async () => {
try { try {
const res = await getLatestRisks(); const res = await getLatestRisk();
console.log("最新风险信号", res); console.log("最新风险动态(列表)", res);
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
warningList.value = res.data.riskVOS; const d = res.data;
hotNewsList.value = res.data.hotspotVOS; const list = Array.isArray(d.riskSignals) ? d.riskSignals : [];
riskTotal.value = res.data.riskCount; const getEventTypeFromModule = (code) => {
const c = String(code ?? "").trim();
if (c === "0100") return "法案";
if (c === "0101") return "行政令";
if (c === "0102") return "智库报告";
if (c === "0103") return "出口管制";
if (c === "0104") return "市场准入";
if (c === "0105") return "创新主体";
if (c === "0106") return "合作限制";
if (c === "0107") return "科研资助体系";
if (c === "0108") return "规则限制";
if (c === "0109") return "投融资限制";
if (c === "01031") return "实体清单";
if (c === "01032") return "CCL";
if (c === "01091") return "SDN";
if (c === "01092") return "涉军企业";
if (c === "01041") return "337调查";
if (c === "01042") return "232调查";
if (c === "01043") return "301调查";
return c;
};
warningList.value = list.map((x) => ({
signalId: x.id,
signalTitle: x.title,
signalTime: x.eventTime,
signalLevel: x.riskLevel,
signalCountryId: x.riskCountryId,
dealStatus: x.dealStatus,
eventType: getEventTypeFromModule(x.sanModuleCode)
}));
riskTotal.value = warningList.value.length;
// 右侧轮播:同样使用 LatestRisk 的 riskSignals(字段映射到现有模板使用的热点字段名)
hotNewsList.value = list.map((x) => ({
signalId: x.id,
hotspotID: x.id,
hotspotType: getEventTypeFromModule(x.sanModuleCode),
hotspotTitle: x.title,
// 轮播题目右侧标签:切换轮播时用详情接口 domains 覆盖
hotspotTag: "",
hotspotDesc: x.description || "",
hotspotDate: x.eventTime || "",
domainList: [],
eventTitle: x.issuingOrgId || ""
}));
// 首次加载:主动拉取当前轮播项详情以展示题目右侧标签
await fetchCarouselDetailForIndex(curHotNewsListIndex.value || 0);
cardList1.value = warningList.value cardList1.value = warningList.value
.filter(item => { .filter(item => {
return item.eventType === "法案" || item.eventType === "行政令"; return item.eventType === "法案" || item.eventType === "行政令";
...@@ -520,11 +566,46 @@ const handleGetLatestRisks = async () => { ...@@ -520,11 +566,46 @@ const handleGetLatestRisks = async () => {
const curNews = ref({}); const curNews = ref({});
const carouselRef = ref(null); const carouselRef = ref(null);
const curHotNewsListIndex = ref(0); const curHotNewsListIndex = ref(0);
const carouselDetailCache = ref({});
const applyHotspotTagById = (id, tagText) => {
const sid = String(id ?? "").trim();
if (!sid) return;
hotNewsList.value = (hotNewsList.value || []).map((n) => {
if (String(n.hotspotID ?? "").trim() !== sid) return n;
return { ...n, hotspotTag: tagText };
});
};
const fetchCarouselDetailForIndex = async (index) => {
const item = hotNewsList.value?.[index];
if (!item) return;
const id = String(item.hotspotID ?? "").trim();
if (!id) return;
if (carouselDetailCache.value[id]) {
applyHotspotTagById(id, carouselDetailCache.value[id]);
return;
}
try {
const res = await getRiskSignalInfoById(id);
if (res && res.code === 200 && res.data) {
const tagText = String(res.data.domains ?? "").trim();
if (tagText) {
carouselDetailCache.value = { ...carouselDetailCache.value, [id]: tagText };
applyHotspotTagById(id, tagText);
}
}
} catch (error) {
console.error("轮播风险信号详情获取失败", error);
}
};
const handleCarouselChange = index => { const handleCarouselChange = index => {
curHotNewsListIndex.value = index; curHotNewsListIndex.value = index;
if (hotNewsList.value && hotNewsList.value.length > 0) { if (hotNewsList.value && hotNewsList.value.length > 0) {
curNews.value = hotNewsList.value[index]; curNews.value = hotNewsList.value[index];
} }
fetchCarouselDetailForIndex(index);
}; };
// 查看详情 // 查看详情
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论