提交 a2f6b7d9 authored 作者: huhuiqing's avatar huhuiqing

葚图不显示的问题及词云接口对接

上级 a7a63573
...@@ -230,7 +230,7 @@ export function getThinkTankReportIndustry(params) { ...@@ -230,7 +230,7 @@ export function getThinkTankReportIndustry(params) {
export function getThinkTankReportIndustryCloud(params) { export function getThinkTankReportIndustryCloud(params) {
return request({ return request({
method: 'GET', method: 'GET',
url: `/api/thinkTankReport/industry/${params.id}/${params.industryId}`, url: `/api/thinkTankReport/keyword/${params.id}`,
}) })
} }
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
</div> </div>
</div> </div>
<div class="box2-main"> <div class="box2-main">
<div class="box2-main-tag-box"> <!-- <div class="box2-main-tag-box">
<div class="tag" :class="{ tagActive: activeArea === item }" v-for="(item, index) in areaList" :key="index" <div class="tag" :class="{ tagActive: activeArea === item }" v-for="(item, index) in areaList" :key="index"
@click="handleClickArea(item.status)"> @click="handleClickArea(item.status)">
{{ item.industryName }} {{ item.industryName }}
</div> </div>
</div> </div> -->
<div class="box2-content" id="box2Chart"></div> <div class="box2-content" id="box2Chart"></div>
</div> </div>
</div> </div>
...@@ -197,7 +197,7 @@ const handleGetThinkTankReportIndustryCloud = async () => { ...@@ -197,7 +197,7 @@ const handleGetThinkTankReportIndustryCloud = async () => {
try { try {
const params = { const params = {
id: router.currentRoute._value.params.id, id: router.currentRoute._value.params.id,
industryId: activeArea.value // industryId: activeArea.value
}; };
const res = await getThinkTankReportIndustryCloud(params); const res = await getThinkTankReportIndustryCloud(params);
console.log("科技领域词云", res); console.log("科技领域词云", res);
...@@ -372,6 +372,7 @@ const majorOpinions = ref([ ...@@ -372,6 +372,7 @@ const majorOpinions = ref([
]); ]);
// 处理页码改变事件 // 处理页码改变事件
const currentPage = ref(1); const currentPage = ref(1);
const total = ref(0)
const handleCurrentChange = page => { const handleCurrentChange = page => {
currentPage.value = page; currentPage.value = page;
handleGetThinkDynamicsReport(); handleGetThinkDynamicsReport();
...@@ -380,9 +381,10 @@ const handleCurrentChange = page => { ...@@ -380,9 +381,10 @@ const handleCurrentChange = page => {
const handleGetThinkTankReportContent = async () => { const handleGetThinkTankReportContent = async () => {
try { try {
const res = await getThinkTankReportContent(router.currentRoute._value.params.id); const res = await getThinkTankReportContent(router.currentRoute._value.params.id);
console.log("主要观点", res); console.log("主要观点", res.data.totalElements);
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
majorOpinions.value = res.data.content; majorOpinions.value = res.data.content;
total.value = res.data.totalElements
} }
} catch (error) { } catch (error) {
console.error("获取主要观点error", error); console.error("获取主要观点error", error);
...@@ -588,7 +590,7 @@ onMounted(() => { ...@@ -588,7 +590,7 @@ onMounted(() => {
.box2-content { .box2-content {
width: 430px; width: 430px;
height: 231px; height: 315px;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid rgba(234, 236, 238, 1); border: 1px solid rgba(234, 236, 238, 1);
border-radius: 4px; border-radius: 4px;
......
...@@ -977,78 +977,80 @@ const box7Data = ref({ ...@@ -977,78 +977,80 @@ const box7Data = ref({
{ source: "美国国务院", target: "兰德公司", value: 15 } { source: "美国国务院", target: "兰德公司", value: 15 }
] ]
}); });
function transformThinkTankData(data) {
// 遍历每个智库
function transformDataToSankey(inputData) {
const nodes = []; const nodes = [];
const links = []; const links = [];
const nodeSet = new Set(); // 用于去重
// 遍历每个智库 // 遍历输入数据
data.forEach(thinkTank => { inputData.forEach(item => {
const thinkTankName = thinkTank.thinkTankName; const thinkTankName = item.thinkTankName;
// 添加智库节点 // 添加智库节点(如果尚未添加)
if (!nodeSet.has(thinkTankName)) { if (!nodes.some(node => node.name === thinkTankName)) {
nodes.push({ name: thinkTankName }); nodes.push({ name: thinkTankName });
nodeSet.add(thinkTankName);
} }
// 遍历每个资金来源 // 遍历捐赠来源
thinkTank.thinkTankDonationSourceVOList.forEach(source => { item.thinkTankDonationSourceVOList.forEach(donation => {
const { amount, institution, secondInstitution } = source; const institution = donation.institution;
const secondInstitution = donation.secondInstitution;
const amount = donation.amount;
// 处理机构节点 // 添加捐赠机构节点(如果尚未添加)
if (institution && !nodeSet.has(institution)) { if (!nodes.some(node => node.name === institution)) {
nodes.push({ name: institution }); nodes.push({ name: institution });
nodeSet.add(institution);
} }
// 处理二级机构节点 // 如果存在二级机构,也添加二级机构节点(如果尚未添加)
if (secondInstitution && !nodeSet.has(secondInstitution)) { if (secondInstitution && !nodes.some(node => node.name === secondInstitution)) {
nodes.push({ name: secondInstitution }); nodes.push({ name: secondInstitution });
nodeSet.add(secondInstitution);
} }
// 构建链接 // 添加链接
if (institution && secondInstitution) { if (secondInstitution) {
// 情况1: institution → secondInstitution → thinkTankName // 如果存在二级机构,先从捐赠机构到二级机构
if (institution !== secondInstitution) { // 检查自引用
links.push({ links.push({
source: institution, source: institution,
target: secondInstitution, target: secondInstitution,
value: amount value: amount
}); });
}
// 再从二级机构到智库
if (secondInstitution !== thinkTankName) { // 检查自引用
links.push({ links.push({
source: secondInstitution, source: secondInstitution,
target: thinkTankName, target: thinkTankName,
value: amount value: amount
}); });
} else if (institution && !secondInstitution) { }
// 情况2: institution → thinkTankName } else {
// 如果没有二级机构,直接从捐赠机构到智库
if (institution !== thinkTankName) { // 检查自引用
links.push({ links.push({
source: institution, source: institution,
target: thinkTankName, target: thinkTankName,
value: amount value: amount
}); });
} else if (!institution && !secondInstitution) { }
// 情况3: 只有智库节点
links.push({
source: thinkTankName,
value: amount
});
} }
}); });
}); });
console.log(nodes, links, 'nodes, linksnodes, links')
return { nodes, links }; return { nodes, links };
} }
// 智库资金流向 // 智库资金流向
const handleGetThinkTankDonation = async () => { const handleGetThinkTankDonation = async () => {
try { try {
const res = await getThinkTankDonation(); const res = await getThinkTankDonation();
console.log("智库资金流向", res); console.log("智库资金流向", res.data, transformDataToSankey(res.data));
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
box7Data.value = transformThinkTankData(res.data); box7Data.value = transformDataToSankey(res.data);
} }
} catch (error) { } catch (error) {
console.error("获取智库资金流向error", error); console.error("获取智库资金流向error", error);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论