Files
td_official/src/views/projectLarge/ProjectScreen/components/rightPage.vue

222 lines
5.1 KiB
Vue
Raw Normal View History

2025-08-21 20:38:44 +08:00
<template>
<div class="leftPage">
<div class="topPage">
<Title title="项目概况" />
2025-08-22 22:17:57 +08:00
<div class="content" v-html="generalize"></div>
2025-08-21 20:38:44 +08:00
</div>
2025-09-12 18:54:44 +08:00
<div class="midPage">
2025-08-21 20:38:44 +08:00
<Title title="形象进度" />
2025-09-12 18:54:44 +08:00
<div ref="pieChartRef" class="echart" />
</div>
<div class="endPage">
<Title title="土地流转情况" />
<div ref="lineChartRef" class="echart" />
2025-08-21 20:38:44 +08:00
</div>
</div>
</template>
<script setup lang="ts">
2025-09-12 22:01:26 +08:00
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
import Title from './title.vue';
2025-08-21 20:38:44 +08:00
import * as echarts from 'echarts';
2025-08-22 17:47:58 +08:00
import { pieOption, barOption } from './optionList';
2025-08-22 22:17:57 +08:00
import { getScreenLand, getScreenImgProcess, getScreenGeneralize } from '@/api/projectScreen';
2025-09-12 22:01:26 +08:00
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
2025-08-22 17:47:58 +08:00
const props = defineProps({
projectId: {
type: String,
default: 0
}
2025-09-12 22:01:26 +08:00
});
2025-08-21 20:38:44 +08:00
2025-09-12 22:01:26 +08:00
const generalize = ref();
2025-08-21 20:38:44 +08:00
// 饼图相关
const pieChartRef = ref<HTMLDivElement | null>(null);
let pieChart: any = null;
2025-09-12 22:01:26 +08:00
const totalPercent = ref(0);
2025-08-21 20:38:44 +08:00
// 折线图相关
const lineChartRef = ref<HTMLDivElement | null>(null);
let lineChart: any = null;
2025-08-22 17:47:58 +08:00
// 土地数据 折线图
2025-09-12 22:01:26 +08:00
const designAreaData = ref([]);
const transferAreaData = ref([]);
2025-09-16 19:41:38 +08:00
const barNames = ref([]);
2025-08-21 20:38:44 +08:00
// 饼图数据
2025-09-12 20:43:56 +08:00
let pieData = [
{ label: 'areaPercentage', name: '场区', value: 0 },
2025-08-22 22:17:57 +08:00
{ label: 'roadPercentage', name: '道路', value: 0 },
{ label: 'collectorLinePercentage', name: '集电线路', value: 0 },
{ label: 'exportLinePercentage', name: '送出线路', value: 0 },
{ label: 'substationPercentage', name: '升压站', value: 0 },
2025-09-12 22:01:26 +08:00
{ label: 'boxTransformerPercentage', name: '箱变', value: 0 }
];
2025-08-21 20:38:44 +08:00
// 初始化饼图
const initPieChart = () => {
if (!pieChartRef.value) {
console.error('未找到饼图容器元素');
return;
}
2025-09-12 22:01:26 +08:00
pieOption.series.data = pieData;
pieOption.graphic[0].style.text = totalPercent.value + '%';
2025-08-21 20:38:44 +08:00
pieChart = echarts.init(pieChartRef.value, null, {
renderer: 'canvas',
useDirtyRect: false
});
pieChart.setOption(pieOption);
2025-09-12 22:01:26 +08:00
};
2025-08-21 20:38:44 +08:00
2025-09-16 19:41:38 +08:00
// 初始柱状图线图
2025-08-21 20:38:44 +08:00
const initLineChart = () => {
if (!lineChartRef.value) {
console.error('未找到折线图容器元素');
return;
}
2025-09-16 19:41:38 +08:00
barOption.xAxis.data = barNames.value;
2025-09-12 22:01:26 +08:00
barOption.series[0].data = designAreaData.value;
barOption.series[1].data = transferAreaData.value;
2025-08-21 20:38:44 +08:00
lineChart = echarts.init(lineChartRef.value, null, {
renderer: 'canvas',
useDirtyRect: false
});
lineChart.setOption(barOption);
2025-09-12 22:01:26 +08:00
};
2025-08-21 20:38:44 +08:00
2025-08-22 17:47:58 +08:00
/**
* 获取项目土地统计数据
*/
const getScreenLandData = async () => {
2025-09-12 22:01:26 +08:00
const res = await getScreenLand(projectIdTwo);
const { data, code } = res;
2025-08-22 17:47:58 +08:00
if (code === 200) {
2025-09-16 19:41:38 +08:00
console.log(data);
barNames.value = res.data.map((item: any) => item.landName);
2025-09-12 22:01:26 +08:00
designAreaData.value = data.map((item: any) => Number(item.designArea));
transferAreaData.value = data.map((item: any) => Number(item.transferArea));
2025-08-22 17:47:58 +08:00
initLineChart();
}
2025-09-12 22:01:26 +08:00
};
2025-08-22 17:47:58 +08:00
2025-08-22 22:17:57 +08:00
/**
* 获取项目形象进度数据
*/
const getScreenImgProcessData = async () => {
2025-09-12 22:01:26 +08:00
const res = await getScreenImgProcess(projectIdTwo);
const { data, code } = res;
2025-08-22 22:17:57 +08:00
if (code === 200) {
2025-09-12 22:01:26 +08:00
totalPercent.value = data.totalPercentage;
2025-08-22 22:17:57 +08:00
pieData.forEach((item: any) => {
2025-09-12 22:01:26 +08:00
item.value = data[item.label];
});
pieData = pieData.filter((item: any) => item.value != '0.0');
console.log(pieData);
initPieChart();
2025-08-22 22:17:57 +08:00
}
2025-09-12 22:01:26 +08:00
};
2025-08-22 22:17:57 +08:00
/**
* 获取项目概况数据
*/
const getScreenGeneralizeData = async () => {
2025-09-12 22:01:26 +08:00
const res = await getScreenGeneralize(projectIdTwo);
const { data, code, msg } = res;
2025-08-22 22:17:57 +08:00
if (code === 200) {
2025-09-12 22:01:26 +08:00
generalize.value = msg;
2025-08-22 22:17:57 +08:00
}
2025-09-12 22:01:26 +08:00
};
2025-08-22 22:17:57 +08:00
2025-09-12 18:54:44 +08:00
// 响应窗口大小变化
const handleResize = () => {
if (pieChart) pieChart.resize();
if (lineChart) lineChart.resize();
};
2025-08-21 20:38:44 +08:00
// 组件挂载时初始化图表
onMounted(() => {
2025-09-12 22:01:26 +08:00
getScreenLandData();
getScreenImgProcessData();
getScreenGeneralizeData();
2025-08-21 20:38:44 +08:00
nextTick(() => {
initPieChart();
window.addEventListener('resize', handleResize);
});
});
// 组件卸载时清理
onUnmounted(() => {
if (pieChart) {
pieChart.dispose();
pieChart = null;
}
if (lineChart) {
lineChart.dispose();
lineChart = null;
}
});
</script>
<style scoped lang="scss">
.leftPage {
display: flex;
flex-direction: column;
height: 100%;
.topPage,
2025-09-12 18:54:44 +08:00
.midPage,
2025-08-21 20:38:44 +08:00
.endPage {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
padding: 15px 0;
border: 1px solid rgba(29, 214, 255, 0.1);
box-sizing: border-box;
}
2025-09-12 18:54:44 +08:00
.endPage,
.midPage {
2025-08-21 20:38:44 +08:00
flex: 1;
margin-top: 23px;
2025-08-22 17:47:58 +08:00
.echart {
2025-09-12 18:54:44 +08:00
height: 100%;
2025-08-22 17:47:58 +08:00
width: 100%;
}
2025-08-21 20:38:44 +08:00
}
}
.content {
2025-09-04 17:36:13 +08:00
height: 100px;
2025-08-22 17:47:58 +08:00
margin: 0 15px;
padding: 0 10px;
box-sizing: border-box;
overflow-y: auto;
&::-webkit-scrollbar-track {
background: rgba(204, 204, 204, 0.1);
border-radius: 10px;
}
&::-webkit-scrollbar-thumb {
background: rgba(29, 214, 255, 0.78);
border-radius: 10px;
}
2025-08-21 20:38:44 +08:00
.content_item {
font-size: 14px;
font-weight: 400;
color: rgba(230, 247, 255, 1);
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
}
}
.subfont {
color: rgba(138, 149, 165, 1);
}
</style>