diff --git a/src/components/Dashboard.vue b/src/components/Dashboard.vue index 4e87b28..e0dc8fe 100644 --- a/src/components/Dashboard.vue +++ b/src/components/Dashboard.vue @@ -22,24 +22,25 @@

科研成果

+
-

论文数量

+

论文总数

累计0
-

专利数量

-
本年0
-
-
-

高影响力论文

+

博士论文

累计0
-

科研项目数量

-
国家重点0
+

硕士论文

+
累计0
+
+
+

学士论文

+
累计0
@@ -49,7 +50,7 @@

学术产出

-
+
-

研究经费: 500万元

+

学术详情

@@ -171,6 +172,7 @@ import { import { CanvasRenderer } from 'echarts/renderers' import MarkdownIt from 'markdown-it'; const md = new MarkdownIt(); + // 向父组件发送页面切换事件 const emit = defineEmits(['navigate', 'logout']) const navigate = (page) => { @@ -183,8 +185,54 @@ const handleLogoClick = () => { } // 跳转到外部科研成果评估链接 -const redirectToResearchEvaluation = () => { - window.open('http://82.156.236.221:10004/login', '_blank'); +const redirectToResearchEvaluation = async () => { + try { + const response = await fetch(`${getApiBaseUrl()}/admin-api/pg/paper/refresh`, { + method: 'get', + credentials: 'include' // 重要:确保发送和接收cookie + }); + const result = await response.json(); + if (result.code === 0) { + // 跳转到目标网站 + await localStorage.setItem('access_token', result.data.access); + await localStorage.setItem('refresh_token', result.data.refresh); + await localStorage.setItem('user_info', JSON.stringify({ + user_id: result.data.user_id, + username: result.data.username, + permission: '2' + })); + window.location.href = 'http://82.156.236.221:10004/user/file' + } else { + console.error('代理登录失败:', result.error); + } + } catch (error) { + console.error('请求失败:', error); + } +}; +const redirectToResearchEvaluation2 = async () => { + try { + const response = await fetch(`${getApiBaseUrl()}/admin-api/pg/paper/adminLogin`, { + method: 'get', + credentials: 'include' // 重要:确保发送和接收cookie + }); + const result = await response.json(); + if (result.code === 0) { + // 跳转到目标网站 + await localStorage.setItem('access_token', result.data.access); + await localStorage.setItem('refresh_token', result.data.refresh); + await localStorage.setItem('user_info', JSON.stringify({ + user_id: result.data.user_id, + username: result.data.username, + permission: '1' + })) + return + window.location.href = 'http://82.156.236.221:10004/admin/manage' + } else { + console.error('代理登录失败:', result.error); + } + } catch (error) { + console.error('请求失败:', error); + } }; // 注册必要的 echarts 组件 @@ -214,6 +262,7 @@ const assistantPanel = ref(null) const isResizing = ref(false) const startY = ref(0) const startHeight = ref(0) + // 开始调整大小 // 保持原有的resize逻辑不变,但修改触发方式 const startResize = (e) => { @@ -266,8 +315,6 @@ const stopResize = () => { document.body.style.userSelect = '' } - - // 教研人才图表数据 const researcherData = ref({ datax: [], @@ -275,33 +322,51 @@ const researcherData = ref({ history: [], ishistory: false }) + // 学术奖项图表数据 const studyData = ref({ datax: [], datay: [] }) + // 教师服务与社会贡献项目分布图表数据 const teacherServiceData = ref({ datax: [], datay: [] }) + // 工程研究中心图表数据 const labData = ref({ - datax: [], // 存储 fieldName - series: [], // 存储 ECharts series 数组 - years: [] // 存储年份列表 + datax: [], + series: [], + years: [] }) + const labLineData = ref({ datax: [], datay: [] }) +// 学术产出图表数据 +const outputData = ref({ + months: [], + doctor: [], + master: [], + bachelor: [] +}) + +// 研究经费图表数据 +const fundingData = ref({ + doctor: 0, + master: 0, + bachelor: 0 +}) + // DeepSeek 智能助手相关变量 const chatMessagesRef = ref(null) const userInput = ref('') const isLoading = ref(false) -const chatMessages = ref([ -]) +const chatMessages = ref([]) // DeepSeek API 调用函数 const sendMessage = async () => { @@ -390,11 +455,12 @@ const scrollToBottom = () => { } }); }; + // 研究经费图例状态 const fundingLegendStatus = ref([true, true, true]) // 学术产出图例状态 -const outputLegendStatus = ref([true, true]) +const outputLegendStatus = ref([true, true, true]) // 切换研究经费图例 const toggleFundingLegend = (index) => { @@ -416,9 +482,9 @@ const updateFundingChart = () => { fundingChart.setOption({ legend: { selected: { - '政府 50%': fundingLegendStatus.value[0], - '企业 25%': fundingLegendStatus.value[1], - '其他 25%': fundingLegendStatus.value[2] + '博士': fundingLegendStatus.value[0], + '硕士': fundingLegendStatus.value[1], + '学士': fundingLegendStatus.value[2] } } }) @@ -432,8 +498,9 @@ const updateOutputChart = () => { outputChart.setOption({ legend: { selected: { - '论文总数': outputLegendStatus.value[0], - '专利总数': outputLegendStatus.value[1] + '博士': outputLegendStatus.value[0], + '硕士': outputLegendStatus.value[1], + '学士': outputLegendStatus.value[1] } } }) @@ -451,12 +518,10 @@ import { getApiBaseUrl } from '../config'; const fetchDashboardData = async () => { try { const response = await fetch(`${getApiBaseUrl()}/admin-api/pg/J-dashboard/dashboard`); - if (response.ok) { const data = await response.json(); console.log("仪表盘数据:", data); dashboardData.value = data.data; - // 更新相应的UI数据 if (data) { updateChartsWithDashboardData(); } @@ -469,14 +534,15 @@ const fetchDashboardData = async () => { loading.value = false; } }; + const fetchDashboardData2 = async () => { try { const response = await fetch(`${getApiBaseUrl()}/admin-api/pg/intelligent-assistant/get-release`); const data = await response.json(); dashboardData2.value = data.data; - if (data) { - updateChartsWithDashboardData(); - } + if (data) { + updateChartsWithDashboardData(); + } } catch (error) { console.error('获取仪表盘数据出错:', error); } finally { @@ -552,6 +618,7 @@ const updateStudyChart = () => { }); } } + const updateResearcherChart = () => { const researcherChart = echarts.getInstanceByDom(researcherChartRef.value); if (researcherChart) { @@ -659,6 +726,59 @@ const initEngineeringKeyFields = (data) => { console.log("Processed labData.value:", labData.value); }; +const fetchPaperData = async () => { + try { + const res = await fetch('http://82.156.236.221:10005/api/v1/review/show/details/'); + if (res.ok) { + const data = await res.json(); + if (data.code === 200) { + // 更新论文数量 + const paperCountEl = document.querySelector('.stat-card:nth-child(1) .stat-value'); + const paperCountEl2 = document.querySelector('.stat-card:nth-child(2) .stat-value'); + const paperCountEl3 = document.querySelector('.stat-card:nth-child(3) .stat-value'); + const paperCountEl4 = document.querySelector('.stat-card:nth-child(4) .stat-value'); + if (paperCountEl) { + paperCountEl.innerHTML = `累计${data.data.total.sum || 0}`; + paperCountEl2.innerHTML = `累计${data.data.total.doctor || 0}`; + paperCountEl3.innerHTML = `累计${data.data.total.master || 0}`; + paperCountEl4.innerHTML = `累计${data.data.total.bachelor || 0}`; + } + + // 获取当前月份前6个月的月份名称 + const currentDate = new Date(); + const monthNames = []; + for (let i = 5; i >= 0; i--) { + const date = new Date(currentDate.getFullYear(), currentDate.getMonth() - i, 1); + monthNames.push(`${date.getMonth() + 1}月`); + } + + // 更新学术产出数据 + outputData.value = { + months: monthNames, + doctor: data.data.time.map(item => item[0]).reverse(), // 添加reverse() + master: data.data.time.map(item => item[1]).reverse(), // 添加reverse() + bachelor: data.data.time.map(item => item[2]).reverse() // 添加reverse() + }; + updateOutputChart(); + + // 更新研究经费数据 + fundingData.value = { + doctor: data.data.total.doctor, + master: data.data.total.master, + bachelor: data.data.total.bachelor + }; + updateFundingChart(); + } + } else { + console.error('获取论文数据失败:', res.statusText); + } + } catch (error) { + console.error('获取论文数据出错:', error); + } finally { + loading.value = false; + } +}; + const fetchLabData = async () => { try { const res = await fetch(`${getApiBaseUrl()}/admin-api/pg/research-data-dashboard/get-release`); @@ -732,6 +852,7 @@ const updateLabBarChart = () => { }, true); } } + const updateLabLineChart = () => { const labLineChart = echarts.getInstanceByDom(labLineChartRef.value); if (labLineChart) { @@ -747,16 +868,16 @@ const updateLabLineChart = () => { }); } }; + // 使用仪表盘数据更新图表 const updateChartsWithDashboardData = () => { if (!dashboardData.value) return; if (!dashboardData2.value) return; - }; // 初始化图表 const initCharts = () => { - // 研究人员图表 - 横向堆叠柱状图(柱中心显示数字) + // 研究人员图表 const researcherChart = echarts.init(researcherChartRef.value) researcherChart.setOption({ tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, @@ -963,26 +1084,27 @@ const initCharts = () => { ] }) - // 学术产出图表 - 横向柱状图(柱末端显示数字) + // 学术产出图表 - 使用API数据 const outputChart = echarts.init(outputChartRef.value) outputChart.setOption({ tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { - data: ['论文总数', '专利总数'], + data: ['博士', '硕士', '学士'], textStyle: { color: '#fff' }, selected: { - '论文总数': outputLegendStatus.value[0], - '专利总数': outputLegendStatus.value[1] + '博士': outputLegendStatus.value[0], + '硕士': outputLegendStatus.value[1], + '学士': outputLegendStatus.value[1], } }, grid: { left: '3%', right: '12%', bottom: '3%', containLabel: true }, - yAxis: { // 交换了 xAxis 和 yAxis + yAxis: { type: 'category', - data: ['1月', '2月', '3月', '4月', '5月'], + data: outputData.value.months, axisLine: { lineStyle: { color: '#fff' } }, axisLabel: { color: '#fff' } }, - xAxis: { // 交换了 xAxis 和 yAxis + xAxis: { type: 'value', axisLine: { lineStyle: { color: '#fff' } }, axisLabel: { color: '#fff' }, @@ -996,9 +1118,9 @@ const initCharts = () => { }, series: [ { - name: '论文总数', + name: '博士', type: 'bar', - data: [140, 160, 180, 190, 210], + data: outputData.value.doctor, itemStyle: { color: '#4080ff' }, barWidth: '20%', barGap: '20%', @@ -1010,9 +1132,9 @@ const initCharts = () => { } }, { - name: '专利总数', + name: '硕士', type: 'bar', - data: [100, 110, 120, 130, 150], + data: outputData.value.master, itemStyle: { color: 'rgb(107,187,196)' }, barWidth: '20%', barGap: '20%', @@ -1022,6 +1144,20 @@ const initCharts = () => { color: '#fff', formatter: '{c}' } + }, + { + name: '学士', + type: 'bar', + data: outputData.value.bachelor, + itemStyle: { color: 'rgb(107,187,19)' }, + barWidth: '20%', + barGap: '20%', + label: { + show: true, + position: 'right', + color: '#fff', + formatter: '{c}' + } } ] }) @@ -1044,29 +1180,29 @@ const initCharts = () => { { value: studyData.value.datay, name: '奖项分布', - areaStyle: { opacity: 0 }, // 移除中间蒙版 + areaStyle: { opacity: 0 }, lineStyle: { color: '#ffd700', width: 2 }, itemStyle: { color: '#ffd700' } } ], label: { - show: true, // 显示标签 - position: 'top', // 标签位置 - color: '#fff', // 标签颜色 - fontSize: 10 // 标签字体大小 + show: true, + position: 'top', + color: '#fff', + fontSize: 10 }, emphasis: { label: { - show: true, // 鼠标悬停时也显示标签 - fontSize: 12, // 鼠标悬停时字体变大 - fontWeight: 'bold' // 鼠标悬停时字体加粗 + show: true, + fontSize: 12, + fontWeight: 'bold' } } } ] }) - // 研究经费图表 - 玫瑰饼图 + // 研究经费图表 - 使用API数据 const fundingChart = echarts.init(fundingChartRef.value) fundingChart.setOption({ tooltip: { trigger: 'item' }, @@ -1075,26 +1211,25 @@ const initCharts = () => { left: '5%', top: 'center', textStyle: { color: '#fff' }, - data: ['政府 50%', '企业 25%', '其他 25%'], + data: ['博士', '硕士', '学士'], selected: { - '政府 50%': fundingLegendStatus.value[0], - '企业 25%': fundingLegendStatus.value[1], - '其他 25%': fundingLegendStatus.value[2] + '博士': fundingLegendStatus.value[0], + '硕士': fundingLegendStatus.value[1], + '学士': fundingLegendStatus.value[2] } }, series: [ { type: 'pie', radius: ['30%', '70%'], - center: ['60%', '50%'], // 将图表向右移动为图例留出空间 + center: ['60%', '50%'], roseType: 'area', label: { show: true, - formatter: '{b}', + formatter: '{b}: {d}%', position: 'outside', color: '#fff', - alignTo: 'labelLine', - distanceToLabelLine: 5 + distanceToLabelLine: 1 }, labelLine: { show: true, @@ -1112,9 +1247,21 @@ const initCharts = () => { } }, data: [ - { value: 50, name: '政府 50%', itemStyle: { color: '#9966ff' } }, - { value: 25, name: '企业 25%', itemStyle: { color: '#ff9933' } }, - { value: 25, name: '其他 25%', itemStyle: { color: '#3399ff' } } + { + value: fundingData.value.doctor, + name: '博士', + itemStyle: { color: '#9966ff' } + }, + { + value: fundingData.value.master, + name: '硕士', + itemStyle: { color: '#ff9933' } + }, + { + value: fundingData.value.bachelor, + name: '学士', + itemStyle: { color: '#3399ff' } + } ] } ] @@ -1134,10 +1281,12 @@ const initCharts = () => { // 生命周期钩子 - 组件挂载后初始化 onMounted(async() => { + // 论文数据 + await fetchPaperData(); // 教研人才数据 await fetchTeacherbData1(); await fetchTeacherbData2(); - await fetchTeacherbData3(); // 调用新的数据获取函数 + await fetchTeacherbData3(); // 工程研究中心数据 await fetchLabData(); await fetchLabData2(); @@ -1157,63 +1306,22 @@ watch(dashboardData, () => { updateChartsWithData(); } }, { deep: true }); - // 更新图表数据 - const updateChartsWithData = () => { - if (!dashboardData.value) return; - // 更新论文数量、专利数量、高影响力论文和关键项目数量 - const paperCountEl = document.querySelector('.stat-card:nth-child(1) .stat-value'); - const patentCountEl = document.querySelector('.stat-card:nth-child(2) .stat-value'); - const highImpactPapersEl = document.querySelector('.stat-card:nth-child(3) .stat-value'); - const keyProjectsEl = document.querySelector('.stat-card:nth-child(4) .stat-value'); - - if (paperCountEl) { - paperCountEl.innerHTML = `累计${dashboardData.value.paperCount || 0}`; - } - - if (patentCountEl) { - patentCountEl.innerHTML = `本年${dashboardData.value.patentCount || 0}`; - } - - if (highImpactPapersEl) { - highImpactPapersEl.innerHTML = `累计${dashboardData.value.highImpactPapers || 0}`; - } - - if (keyProjectsEl) { - keyProjectsEl.innerHTML = `国家重点${dashboardData.value.keyProjects || 0}`; - } - - // 更新研究经费 - const fundingTitle = document.querySelector('.dashboard-panel:nth-child(3) h2'); - if (fundingTitle && dashboardData.value.fundingAmount) { - fundingTitle.textContent = `研究经费: ${dashboardData.value.fundingAmount}`; - } - }; - - // 定义newsData为ref,使其可响应 - const newsData = ref([]); - - // 新闻滚动 - let scrollInterval - const startNewsScroll = () => { - if (!newsListRef.value) return - - scrollInterval = setInterval(() => { - if (newsListRef.value.scrollTop + newsListRef.value.clientHeight >= newsListRef.value.scrollHeight) { - // 如果已经滚动到底部,重新开始滚动 - newsListRef.value.scrollTop = 0 - } else { - // 否则继续滚动 - newsListRef.value.scrollTop += 1 - } - }, 50) - } + +// 更新图表数据 +const updateChartsWithData = () => { + if (!dashboardData.value) return; + // 更新专利数量、高影响力论文和关键项目数量 + const patentCountEl = document.querySelector('.stat-card:nth-child(2) .stat-value'); + const highImpactPapersEl = document.querySelector('.stat-card:nth-child(3) .stat-value'); + const keyProjectsEl = document.querySelector('.stat-card:nth-child(4) .stat-value'); +}; + +// 定义newsData为ref,使其可响应 +const newsData = ref([]); // 组件卸载时清理定时器 onUnmounted(() => { - // 移除 resize 事件监听器 - window.removeEventListener('resize', () => { - // 这里可以添加移除所有图表实例的逻辑,或者在需要时手动销毁 - }); + window.removeEventListener('resize', () => {}); }) @@ -1358,7 +1466,7 @@ onUnmounted(() => { } .chart-container-65 { - width: 65%; + width: 100%; height: 100%; } diff --git a/src/components/LabDetail.vue b/src/components/LabDetail.vue index f387539..948d678 100644 --- a/src/components/LabDetail.vue +++ b/src/components/LabDetail.vue @@ -145,7 +145,7 @@ - + + + + @@ -514,12 +527,23 @@ const scoreComparisonTableData = computed(() => { return selectedLabs.value.map(lab => { const row = { - category: `${lab.basicInformation.name0}-${lab.basicInformation.name2}` // 纵向表头是年份-中心名称 + category: `${lab.basicInformation.name0}-${lab.basicInformation.name4}-${lab.basicInformation.name2}` }; - // 将 radarData 映射到 row 的动态属性上 - lab.result.forEach((score, index) => { - row[`score${index + 1}`] = score; - }); + + if (Array.isArray(lab.result)) { + let total = 0; + lab.result.forEach((score, index) => { + const numericScore = Number(score) || 0; + row[`score${index + 1}`] = numericScore; + total += numericScore; + }); + + // 修改这里:使用Math.round()四舍五入并转换为整数 + row.totalScore = Math.round(total); + } else { + row.totalScore = 0; // 设置为整数0 + } + return row; }); }); @@ -542,6 +566,14 @@ const columnStats = computed(() => { }; } }); + // 添加总分统计 + const totalScores = scoreComparisonTableData.value.map(row => Number(row.totalScore)); + if (totalScores.length > 0) { + stats.totalScore = { + max: Math.max(...totalScores), + min: Math.min(...totalScores) + }; + } // console.log("Calculated columnStats:", stats); // 调试输出 return stats; }); diff --git a/src/components/LabDrawerDetail.vue b/src/components/LabDrawerDetail.vue index c3a4fed..b3d7ed7 100644 --- a/src/components/LabDrawerDetail.vue +++ b/src/components/LabDrawerDetail.vue @@ -66,7 +66,8 @@
{{ item.label }}: - {{ labData.assessmentScore[item.prop] || '0' }} + {{ labData.assessmentScore[item.prop] || '0' }} / {{ labData.maximum[item.prop] || '0' }} +
diff --git a/src/config.js b/src/config.js index 49a221e..b8812db 100644 --- a/src/config.js +++ b/src/config.js @@ -3,7 +3,7 @@ const env = import.meta.env.MODE || 'development'; const config = { development: { - apiBaseUrl: 'http://192.168.18.9:48080', + apiBaseUrl: 'http://192.168.5.49:48080', }, production: { apiBaseUrl: 'http://36.103.203.89:48089',