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

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

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