Browse Source

修改收益分析图表的数据

dev
selia-zx 5 days ago
parent
commit
b310e616eb
  1. 65
      src/views/hotWater/profitAnalysis/index.vue

65
src/views/hotWater/profitAnalysis/index.vue

@ -80,7 +80,7 @@
<div class="charts-container"> <div class="charts-container">
<!-- 左侧成本与收益对比图 --> <!-- 左侧成本与收益对比图 -->
<div class="chart-section"> <div class="chart-section">
<div class="section-title">成本与收益对比图</div> <div class="section-title">成本与单耗对比图</div>
<div class="chart-box" ref="costChart_ref"></div> <div class="chart-box" ref="costChart_ref"></div>
</div> </div>
@ -174,7 +174,9 @@ export default {
// //
tableData: [ tableData: [
] ],
//
chartData: []
}; };
}, },
mounted() { mounted() {
@ -186,7 +188,9 @@ export default {
this.handleResize(); this.handleResize();
// //
this.fetchCardData(); this.fetchCardData();
this.getList(); this.getList().then(() => {
this.fetchChartData();
});
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("resize", this.handleResize); window.removeEventListener("resize", this.handleResize);
@ -204,11 +208,11 @@ export default {
// //
initCostChart() { initCostChart() {
const dates = this.tableData.map(item => item.curDate).reverse(); const dates = this.chartData.map(item => item.curDate).reverse();
const waterAmountData = this.tableData.map(item => item.totalUseWater).reverse(); const waterAmountData = this.chartData.map(item => item.totalUseWater).reverse();
const electricAmountData = this.tableData.map(item => item.totalUseEle).reverse(); const electricAmountData = this.chartData.map(item => item.totalUseEle).reverse();
const unitConsumptionData = this.tableData.map(item => item.unitConsumption).reverse(); const unitConsumptionData = this.chartData.map(item => item.unitConsumption).reverse();
console.log(" electricAmountData", electricAmountData) console.log(" electricAmountData", electricAmountData)
@ -483,9 +487,9 @@ export default {
// ,y // ,y
handleLegendChanged(params) { handleLegendChanged(params) {
const waterAmountData = this.tableData.map(item => item.totalUseWater).reverse(); const waterAmountData = this.chartData.map(item => item.totalUseWater).reverse();
const electricAmountData = this.tableData.map(item => item.totalUseEle).reverse(); const electricAmountData = this.chartData.map(item => item.totalUseEle).reverse();
const unitConsumptionData = this.tableData.map(item => item.unitConsumption).reverse(); const unitConsumptionData = this.chartData.map(item => item.unitConsumption).reverse();
// //
const selected = params.selected; const selected = params.selected;
@ -699,8 +703,8 @@ export default {
initTrendChart() { initTrendChart() {
this.trendChart = echarts.init(this.$refs.trendChart_ref); this.trendChart = echarts.init(this.$refs.trendChart_ref);
const dates = this.tableData.map(item => item.curDate).reverse(); const dates = this.chartData.map(item => item.curDate).reverse();
const incomeData = this.tableData.map(item => item.totalIncome).reverse(); const incomeData = this.chartData.map(item => item.totalIncome).reverse();
const option = { const option = {
tooltip: { tooltip: {
@ -714,7 +718,7 @@ export default {
}, },
grid: { grid: {
left: "3%", left: "3%",
right: "4%", right: "5%",
bottom: "3%", bottom: "3%",
containLabel: true containLabel: true
}, },
@ -819,7 +823,9 @@ export default {
this.dateType = type; this.dateType = type;
this.fetchCardData(); this.fetchCardData();
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getList(); this.getList().then(() => {
this.fetchChartData();
});
}, },
// //
@ -849,7 +855,10 @@ export default {
console.log("查询数据"); console.log("查询数据");
this.fetchCardData(); this.fetchCardData();
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getList(); // total
this.getList().then(() => {
this.fetchChartData();
});
}, },
// //
@ -1004,7 +1013,7 @@ export default {
this.endYear = String(currentYear); this.endYear = String(currentYear);
}, },
// //
async getList() { async getList() {
try { try {
// //
@ -1021,16 +1030,36 @@ export default {
if (res.code === 200 && res.rows) { if (res.code === 200 && res.rows) {
// //
this.tableData = res.rows; this.tableData = res.rows;
this.total = res.total || 0; this.total = res.total || 0;
}
} catch (error) {
console.error('获取列表数据失败:', error);
}
},
//
async fetchChartData() {
try {
// 使 total pageSize
const params = {
startDate: this.getDateRange().start,
endDate: this.getDateRange().end,
type: this.getTypeValue(),
buildingId: '所有',
pageNum: 1,
pageSize: this.total || 1000
};
const res = await waterRevenueQuery(params);
if (res.code === 200 && res.rows) {
this.chartData = res.rows;
// //
this.$nextTick(() => { this.$nextTick(() => {
this.updateCharts(); this.updateCharts();
}); });
} }
} catch (error) { } catch (error) {
console.error('获取列表数据失败:', error); console.error('获取表数据失败:', error);
} }
}, },

Loading…
Cancel
Save