After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.7 KiB |
@ -0,0 +1,691 @@
|
||||
<!-- 报表查询-用能查询-年数据 --> |
||||
<template> |
||||
<div> |
||||
<div class="findwatercharts" ref="findwater_ref"></div> |
||||
<!-- 表格 --> |
||||
<el-table |
||||
class="maintable" |
||||
header-align="center" |
||||
:data="tableData" |
||||
style="margin-right: 0.13rem" |
||||
:cell-style="tableRowStyle" |
||||
> |
||||
<el-table-column prop="itemType" label="类别" width="160" fixed="left"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day01" label="1日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day02" label="2日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day03" label="3日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day04" label="4日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day05" label="5日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day06" label="6日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day07" label="7日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day08" label="8日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day09" label="9日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day10" label="10日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day11" label="11日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day12" label="12日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day13" label="13日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day14" label="14日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day15" label="15日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day16" label="16日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day17" label="17日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day18" label="18日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day19" label="19日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day20" label="20日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day21" label="21日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day22" label="22日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day23" label="23日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day24" label="24日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day25" label="25日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day26" label="26日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day27" label="27日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day28" label="28日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day29" label="29日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day30" label="30日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="day31" label="31日" width="100"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
align="center" |
||||
prop="totalValue" |
||||
label="合计" |
||||
fixed="right" |
||||
width="130" |
||||
> |
||||
</el-table-column> |
||||
</el-table> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { getDay, getMonth, getYear } from "@/utils/datetime"; |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
props: { |
||||
chType: { |
||||
type: Number, |
||||
}, |
||||
chTime: { |
||||
type: String, |
||||
}, |
||||
jtData: { |
||||
type: String, |
||||
}, |
||||
}, |
||||
data() { |
||||
return { |
||||
chartInstance1: null, |
||||
option1: { |
||||
series: [], |
||||
}, |
||||
// 给后端日期 |
||||
endTime: "", |
||||
//表格数据 |
||||
tableData: [], |
||||
// 四条折线图 |
||||
data1: [], |
||||
data2: [], |
||||
data3: [], |
||||
data4: [], |
||||
data5: [], |
||||
// 图例 |
||||
data6: [], |
||||
// x轴数据 |
||||
data8: [], |
||||
}; |
||||
}, |
||||
watch: { |
||||
chType: { |
||||
immediate: true, |
||||
deep: true, |
||||
handler(newVal, val) { |
||||
// console.log("子组件改变的值", newVal); |
||||
this.$nextTick(function () { |
||||
this.getMothData(); |
||||
}); |
||||
}, |
||||
}, |
||||
// 对vuex里的点击的楼栋id进行监听 |
||||
jtData: { |
||||
handler(newVal, oldVal) { |
||||
// console.log("监听vuex的id", newVal, oldVal); |
||||
this.$nextTick(function () { |
||||
this.getMothData(); |
||||
}); |
||||
}, |
||||
deep: true, |
||||
immediate: true, |
||||
}, |
||||
}, |
||||
mounted() { |
||||
this.getMothData(); |
||||
this.initChart1(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
this.screenAdapter(); |
||||
}, |
||||
destroyed() { |
||||
//与mounted中的监听对应,在组件销毁的时候,需要将监听器取消掉 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
}, |
||||
methods: { |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 如果第1列,修改颜色 |
||||
if (columnIndex === 0) { |
||||
return "background-color: #31354e !important;"; |
||||
} |
||||
}, |
||||
// 查询表格数据 |
||||
getMothData() { |
||||
// 本月 本年参数 |
||||
// 选择时间的参数 父传子 |
||||
// 楼栋id 兄弟组件传值 |
||||
// select选择的值 父传子 |
||||
if (this.chTime) { |
||||
this.endTime = this.chTime; |
||||
} else { |
||||
this.endTime = getMonth(0) |
||||
} |
||||
let params = { |
||||
curDate: this.endTime, |
||||
buildingId: this.endId, |
||||
type: this.chType, |
||||
}; |
||||
console.log("月参数", params); |
||||
// this.$api.statementfind.energyMonth(params).then((res) => { |
||||
// // console.log("月表格返回", res); |
||||
// if (res.code == 200) { |
||||
// var line1 = []; |
||||
// var line2 = []; |
||||
// var line3 = []; |
||||
// var line4 = []; |
||||
// this.tableData = res.data; |
||||
// // Object.values 把数组对象 转化为 数组 |
||||
// line1 = Object.values(this.tableData[0]).slice(3, 35); |
||||
// line2 = Object.values(this.tableData[1]).slice(3, 35); |
||||
// line3 = Object.values(this.tableData[2]).slice(3, 35); |
||||
// line4 = Object.values(this.tableData[3]).slice(3, 35); |
||||
// // 四条折线图 filter里过滤掉空值 |
||||
// this.data1 = line1.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// this.data2 = line2.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// // 含百分比的数组数据还需要处理 |
||||
// var line5 = line3.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// this.data3 = []; |
||||
// this.data4 = []; |
||||
// // 遍历去除掉%,拼接后返回新数组 |
||||
// line5.forEach((item) => { |
||||
// this.data3.push(item.split("%").join("")); |
||||
// }); |
||||
// var line6 = line4.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// line6.forEach((item) => { |
||||
// this.data4.push(item.split("%").join("")); |
||||
// }); |
||||
// // 折线图x轴 数据 |
||||
// // 先拿到数组的一个对象 tableData[0] [1] [2] [3]都行,并且先过滤掉对象的空值 |
||||
// //定义一个新数组 |
||||
// let newObj = {}; |
||||
// for (let key in this.tableData[0]) { |
||||
// if (this.tableData[0][key]) { |
||||
// newObj[key] = this.tableData[0][key]; |
||||
// } |
||||
// } |
||||
// // console.log("不含空的数组对象", newObj); |
||||
// // 在返回的新的对象中,取出对象的所有key值返回新数组 |
||||
// // Object.setPrototypeOf(this.newObj); |
||||
// let data7 = Object.keys(newObj); |
||||
// // console.log("不含空的x轴数据", data7); |
||||
// // 先返回月的数组 |
||||
// let allArr = [ |
||||
// "day01", |
||||
// "day02", |
||||
// "day03", |
||||
// "day04", |
||||
// "day05", |
||||
// "day06", |
||||
// "day07", |
||||
// "day08", |
||||
// "day09", |
||||
// "day10", |
||||
// "day11", |
||||
// "day12", |
||||
// "day13", |
||||
// "day14", |
||||
// "day15", |
||||
// "day16", |
||||
// "day17", |
||||
// "day18", |
||||
// "day19", |
||||
// "day20", |
||||
// "day21", |
||||
// "day22", |
||||
// "day23", |
||||
// "day24", |
||||
// "day25", |
||||
// "day26", |
||||
// "day27", |
||||
// "day28", |
||||
// "day29", |
||||
// "day30", |
||||
// "day31", |
||||
// ]; |
||||
// // 非空数组和所有月的数组进行筛选出重复的元素 |
||||
// function compare(data7, allArr) { |
||||
// return data7.filter((v) => { |
||||
// return allArr.includes(v); |
||||
// }); |
||||
// } |
||||
// // console.log("x轴未分割日份", compare(data7, allArr)); |
||||
// // 分割data7,返回月份 xx月 |
||||
// this.data8 = []; |
||||
// compare(data7, allArr).forEach((item) => { |
||||
// if (item) { |
||||
// this.data8.push(item.split("day").join("") + "日"); |
||||
// } |
||||
// }); |
||||
// // console.log("x轴数据", this.data8); |
||||
// // 图例 |
||||
// this.data6 = []; |
||||
// this.data5 = this.tableData.forEach((item) => { |
||||
// return this.data6.push(item.itemType); |
||||
// }); |
||||
// // console.log("data1数据", this.data1); |
||||
// // console.log("data2数据", this.data2); |
||||
// // console.log("data3数据", this.data3); |
||||
// // console.log("data4数据", this.data4); |
||||
// // console.log("图例文字", this.data6); |
||||
// // 月数据 |
||||
// var Min1 = Math.floor(Math.min(...this.data1, ...this.data2)), |
||||
// Min2 = Math.floor(Math.min(...this.data3, ...this.data4) - 4), |
||||
// Max1 = Math.ceil(Math.max(...this.data1, ...this.data2) + 4), |
||||
// Max2 = Math.ceil(Math.max(...this.data3, ...this.data4) + 4); |
||||
// // console.log("Min1", Min1); |
||||
// // console.log("Min2", Min2); |
||||
// // console.log("Max1", Max1); |
||||
// // console.log("Max2", Max2); |
||||
// this.chartInstance1 = echarts.init(this.$refs.findwater_ref); |
||||
// const adapterOption = { |
||||
// legend: { |
||||
// data: this.data6, |
||||
// }, |
||||
// xAxis: { |
||||
// data: this.data8, |
||||
// }, |
||||
// yAxis: [ |
||||
// //两个y轴 |
||||
// { |
||||
// min: Min1, |
||||
// max: Max1, |
||||
// splitNumber: 10, |
||||
// interval: (Max1 - Min1) / 10, |
||||
// }, |
||||
// { |
||||
// min: Min2, |
||||
// max: Max2, |
||||
// splitNumber: 10, |
||||
// interval: (Max2 - Min2) / 10, |
||||
// }, |
||||
// ], |
||||
// series: [ |
||||
// { |
||||
// name: this.data6[0], |
||||
// data: this.data1, |
||||
// }, |
||||
// { |
||||
// name: this.data6[1], |
||||
// data: this.data2, |
||||
// }, |
||||
// { |
||||
// name: this.data6[2], |
||||
// data: this.data3, |
||||
// }, |
||||
// { |
||||
// name: this.data6[3], |
||||
// data: this.data4, |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.chartInstance1.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.chartInstance1.resize(); |
||||
// } |
||||
// }); |
||||
}, |
||||
// 导出数据 |
||||
outTable() { |
||||
// console.log("月数据啦"); |
||||
import("@/assets/excel/Export2Excel").then((excel) => { |
||||
const tHeader = [ |
||||
"类别", |
||||
"1日", |
||||
"2日", |
||||
"3日", |
||||
"4日", |
||||
"5日", |
||||
"6日", |
||||
"7日", |
||||
"8日", |
||||
"9日", |
||||
"10日", |
||||
"11日", |
||||
"12日", |
||||
"13日", |
||||
"14日", |
||||
"15日", |
||||
"16日", |
||||
"17日", |
||||
"18日", |
||||
"19日", |
||||
"20日", |
||||
"21日", |
||||
"22日", |
||||
"23日", |
||||
"24日", |
||||
"25日", |
||||
"26日", |
||||
"27日", |
||||
"28日", |
||||
"29日", |
||||
"30日", |
||||
"31日", |
||||
"合计", |
||||
]; // 导出的excel表头名信息 |
||||
const filterVal = [ |
||||
"itemType", |
||||
"day01", |
||||
"day02", |
||||
"day03", |
||||
"day04", |
||||
"day05", |
||||
"day06", |
||||
"day07", |
||||
"day08", |
||||
"day09", |
||||
"day10", |
||||
"day11", |
||||
"day12", |
||||
"day13", |
||||
"day14", |
||||
"day15", |
||||
"day16", |
||||
"day17", |
||||
"day18", |
||||
"day19", |
||||
"day20", |
||||
"day21", |
||||
"day22", |
||||
"day23", |
||||
"day24", |
||||
"day25", |
||||
"day26", |
||||
"day27", |
||||
"day28", |
||||
"day29", |
||||
"day30", |
||||
"day31", |
||||
"totalValue", |
||||
]; // 导出的excel表头字段名,需要导出表格字段名 |
||||
// const list = this.tableData; |
||||
// console.log(list) |
||||
if (this.chTime) { |
||||
this.endTime = this.chTime; |
||||
} else { |
||||
this.endTime = getMonth(0) |
||||
} |
||||
let params = { |
||||
curDate: this.endTime, |
||||
buildingId: this.endId, |
||||
type: this.chType, |
||||
}; |
||||
console.log("月参数", params); |
||||
// this.$api.statementfind.energyMonth(params).then((res) => { |
||||
// if (res.code == 200) { |
||||
// // console.log(res); |
||||
// const data = this.formatJson(filterVal, res.data); |
||||
// const autoWidth = true; |
||||
// excel.export_json_to_excel({ |
||||
// header: tHeader, //表头 |
||||
// data, //数据 |
||||
// filename: "月数据报表", //名称 |
||||
// autoWidth: true, //宽度自适应 |
||||
// }); |
||||
// } |
||||
// }); |
||||
}); |
||||
}, |
||||
//格式转换,不需要改动 |
||||
formatJson(filterVal, jsonData) { |
||||
return jsonData.map((v) => |
||||
filterVal.map((j) => { |
||||
if (j === "installDate") { |
||||
return format(v[j]); |
||||
} else { |
||||
return v[j]; |
||||
} |
||||
}) |
||||
); |
||||
}, |
||||
//初始化chartInstance1对象 |
||||
// 如果父组件点击了月 x轴数据 1号 2号 3号。。。 |
||||
// 如果父组件点击了年 x轴数据 1月 2月 3月。。。 |
||||
initChart1() { |
||||
this.$emit("initChart1"); |
||||
this.chartInstance1 = echarts.init(this.$refs.findwater_ref); |
||||
this.option1 = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
// 以下为鼠标hover时的背景颜色 |
||||
showDelay: 0, // 显示延迟,添加显示延迟可以避免频繁切换,单位ms |
||||
axisPointer: { |
||||
type: "shadow", |
||||
shadowStyle: { |
||||
color: "rgba(30, 69, 113, 0.15)", |
||||
width: "1", |
||||
}, |
||||
}, |
||||
}, |
||||
legend: { |
||||
// 折柱混合的图表,不显示icon,图例就可以根据不同的类型不同 |
||||
// icon: "cricle", |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 12, //这里改字体大小 |
||||
}, |
||||
left: "56%", |
||||
top: "5%", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
grid: { |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "3%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255,255,255,.7)", |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// 去除x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
// X 轴颜色配置 |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
//splitLine: { show: true } //x轴分割线 |
||||
}, |
||||
yAxis: [ |
||||
//两个y轴 |
||||
{ |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255,255,255,.7)", |
||||
}, |
||||
// 显示y坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
// X 轴颜色配置 |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
//y轴分割线段数 |
||||
splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
// color: "#252843", |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255,255,255,.7)", |
||||
formatter: "{value} %", |
||||
}, |
||||
// 显示y坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
// X 轴颜色配置 |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
//y轴分割线段数 |
||||
splitNumber: 5, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
// color: "#252843", |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
|
||||
series: [ |
||||
{ |
||||
type: "bar", |
||||
barWidth: 10, // 柱子宽度 |
||||
// tooltip: { |
||||
// valueFormatter: function (value) { |
||||
// return value + "吨"; |
||||
// }, |
||||
// }, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#db9215", |
||||
lineStyle: { |
||||
color: "#db9215", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "bar", |
||||
// tooltip: { |
||||
// valueFormatter: function (value) { |
||||
// return value + "吨"; |
||||
// }, |
||||
// }, |
||||
barWidth: 10, // 柱子宽度 |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#1ab395", |
||||
lineStyle: { |
||||
color: "#1ab395", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "line", |
||||
tooltip: { |
||||
valueFormatter: function (value) { |
||||
return value + "%"; |
||||
}, |
||||
}, |
||||
// stack: 'Total', |
||||
symbol: "circle", |
||||
// 拐点大小 |
||||
symbolSize: 6, |
||||
yAxisIndex: 1, |
||||
// 开始不显示拐点, 鼠标经过显示 |
||||
showSymbol: false, |
||||
// data: this.data3, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#e23131", |
||||
lineStyle: { |
||||
color: "#e23131", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "line", |
||||
tooltip: { |
||||
valueFormatter: function (value) { |
||||
return value + "%"; |
||||
}, |
||||
}, |
||||
// stack: 'Total', |
||||
symbol: "circle", |
||||
// 拐点大小 |
||||
symbolSize: 6, |
||||
//第二个y轴 |
||||
yAxisIndex: 1, |
||||
// 开始不显示拐点, 鼠标经过显示 |
||||
showSymbol: false, |
||||
// data: this.data4, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#4a98ff", |
||||
lineStyle: { |
||||
color: "#4a98ff", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.chartInstance1.setOption(this.option1, true); |
||||
}, |
||||
// 折线图自适应 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = (this.$refs.findwater_ref.offsetWidth / 100) * 1.8; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = { |
||||
//比如fontSize |
||||
textStyle: { |
||||
fontSize: titleFontSize, |
||||
}, |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.chartInstance1.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.chartInstance1.resize(); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style scoped> |
||||
.findwatercharts { |
||||
margin-bottom: 0.35rem; |
||||
width: 100%; |
||||
height: 4.5rem; |
||||
/* background-color: pink; */ |
||||
} |
||||
</style> |
@ -0,0 +1,638 @@
|
||||
<!-- 报表查询-用能查询-年数据 --> |
||||
<template> |
||||
<div> |
||||
<div class="findwatercharts" ref="findwater_ref"></div> |
||||
<!-- 表格 --> |
||||
<el-table |
||||
class="maintable" |
||||
header-align="center" |
||||
:data="tableData" |
||||
style="margin-right: 0.13rem" |
||||
:cell-style="tableRowStyle" |
||||
> |
||||
<el-table-column |
||||
align="center" |
||||
prop="itemType" |
||||
label="类别" |
||||
width="160" |
||||
fixed="left" |
||||
> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month01" label="1月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month02" label="2月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month03" label="3月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month04" label="4月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month05" label="5月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month06" label="6月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month07" label="7月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month08" label="8月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month09" label="9月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month10" label="10月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month11" label="11月"> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="month12" label="12月"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
align="center" |
||||
prop="totalValue" |
||||
label="合计" |
||||
fixed="right" |
||||
width="100" |
||||
> |
||||
</el-table-column> |
||||
</el-table> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { getYear } from "@/utils/datetime"; |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
props: { |
||||
chType: { |
||||
type: Number, |
||||
}, |
||||
chTime: { |
||||
type: String, |
||||
}, |
||||
jtData: { |
||||
type: String, |
||||
}, |
||||
}, |
||||
data() { |
||||
return { |
||||
chartInstance1: null, |
||||
option1: { |
||||
series: [], |
||||
}, |
||||
// 给后端日期 |
||||
endTime: "", |
||||
//表格数据 |
||||
tableData: [], |
||||
// 四条折线图 |
||||
data1: [], |
||||
data2: [], |
||||
data3: [], |
||||
data4: [], |
||||
data5: [], |
||||
// 图例 |
||||
data6: [], |
||||
// x轴数据 |
||||
data8: [], |
||||
}; |
||||
}, |
||||
watch: { |
||||
chType: { |
||||
immediate: true, |
||||
deep: true, |
||||
handler(newVal, val) { |
||||
// console.log("子组件改变的值", newVal); |
||||
this.$nextTick(function () { |
||||
this.getYearData(); |
||||
}); |
||||
}, |
||||
}, |
||||
// 对vuex里的点击的楼栋id进行监听 |
||||
jtData: { |
||||
handler(newVal, oldVal) { |
||||
// console.log("监听vuex的id", newVal, oldVal); |
||||
this.$nextTick(function () { |
||||
this.getYearData(); |
||||
}); |
||||
}, |
||||
deep: true, |
||||
immediate: true, |
||||
}, |
||||
}, |
||||
mounted() { |
||||
this.getYearData(); |
||||
this.initChart1(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
this.screenAdapter(); |
||||
}, |
||||
destroyed() { |
||||
//与mounted中的监听对应,在组件销毁的时候,需要将监听器取消掉 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
}, |
||||
methods: { |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 如果第1列,修改颜色 |
||||
if (columnIndex === 0) { |
||||
return "background-color: #31354e !important;"; |
||||
} |
||||
}, |
||||
// 查询表格数据 |
||||
getYearData() { |
||||
// 本月 本年参数 |
||||
// 选择时间的参数 父传子 |
||||
// 楼栋id 兄弟组件传值 |
||||
// select选择的值 父传子 |
||||
if (this.chTime) { |
||||
this.endTime = this.chTime; |
||||
} else { |
||||
this.endTime = getYear(0); |
||||
} |
||||
let params = { |
||||
curDate: this.endTime, |
||||
buildingId: this.endId, |
||||
type: this.chType, |
||||
}; |
||||
console.log("年表格参数", params); |
||||
// this.$api.statementfind.energyYear(params).then((res) => { |
||||
// // console.log("年表格返回", res); |
||||
// if (res.code == 200) { |
||||
// var line1 = []; |
||||
// var line2 = []; |
||||
// var line3 = []; |
||||
// var line4 = []; |
||||
// this.tableData = res.data; |
||||
// // Object.values 把数组对象 转化为 数组 |
||||
// line1 = Object.values(this.tableData[0]).slice(3, 15); |
||||
// line2 = Object.values(this.tableData[1]).slice(3, 15); |
||||
// line3 = Object.values(this.tableData[2]).slice(3, 15); |
||||
// line4 = Object.values(this.tableData[3]).slice(3, 15); |
||||
// // 四条折线图 filter里过滤掉空值 |
||||
// this.data1 = line1.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// this.data2 = line2.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// // 含百分比的数组数据还需要处理 |
||||
// var line5 = line3.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// this.data3 = []; |
||||
// this.data4 = []; |
||||
// // 遍历去除掉%,拼接后返回新数组 |
||||
// line5.forEach((item) => { |
||||
// this.data3.push(item.split("%").join("")); |
||||
// }); |
||||
// var line6 = line4.filter(function (s) { |
||||
// return s && s.trim(); |
||||
// }); |
||||
// line6.forEach((item) => { |
||||
// this.data4.push(item.split("%").join("")); |
||||
// }); |
||||
// // 折线图x轴 数据 |
||||
// // 先拿到数组的一个对象 tableData[0] [1] [2] [3]都行,并且先过滤掉对象的空值 |
||||
// //定义一个新数组 |
||||
// let newObj = {}; |
||||
// for (let key in this.tableData[0]) { |
||||
// if (this.tableData[0][key]) { |
||||
// newObj[key] = this.tableData[0][key]; |
||||
// } |
||||
// } |
||||
// // console.log("不含空的数组对象", newObj); |
||||
// // 在返回的新的对象中,取出对象的所有key值返回新数组 |
||||
// // Object.setPrototypeOf(this.newObj); |
||||
// let data7 = Object.keys(newObj); |
||||
// // console.log("不含空的x轴数据", data7); |
||||
// // 先返回月的数组 |
||||
// let allArr = [ |
||||
// "month01", |
||||
// "month02", |
||||
// "month03", |
||||
// "month04", |
||||
// "month05", |
||||
// "month06", |
||||
// "month07", |
||||
// "month08", |
||||
// "month09", |
||||
// "month10", |
||||
// "month11", |
||||
// "month12", |
||||
// ]; |
||||
// // 非空数组和所有月的数组进行筛选出重复的元素 |
||||
// function compare(data7, allArr) { |
||||
// return data7.filter((v) => { |
||||
// return allArr.includes(v); |
||||
// }); |
||||
// } |
||||
// // console.log("x轴未分割月份", compare(data7, allArr)); |
||||
// // 分割data7,返回月份 xx月 |
||||
// this.data8 = []; |
||||
// compare(data7, allArr).forEach((item) => { |
||||
// if (item) { |
||||
// this.data8.push(item.split("month").join("") + "月"); |
||||
// } |
||||
// }); |
||||
// // console.log("x轴数据", this.data8); |
||||
// // 图例 |
||||
// this.data6 = []; |
||||
// this.data5 = this.tableData.forEach((item) => { |
||||
// return this.data6.push(item.itemType); |
||||
// }); |
||||
// // console.log("data1数据", this.data1); |
||||
// // console.log("data2数据", this.data2); |
||||
// // console.log("data3数据", this.data3); |
||||
// // console.log("data4数据", this.data4); |
||||
// // console.log("图例文字", this.data6); |
||||
// // 月数据 |
||||
// var Min1 = Math.floor(Math.min(...this.data1, ...this.data2)), |
||||
// Min2 = Math.floor(Math.min(...this.data3, ...this.data4) - 4), |
||||
// Max1 = Math.ceil(Math.max(...this.data1, ...this.data2) + 4), |
||||
// Max2 = Math.ceil(Math.max(...this.data3, ...this.data4) + 4); |
||||
// // console.log("Min1", Min1); |
||||
// // console.log("Min2", Min2); |
||||
// // console.log("Max1", Max1); |
||||
// // console.log("Max2", Max2); |
||||
// this.chartInstance1 = echarts.init(this.$refs.findwater_ref); |
||||
// const adapterOption = { |
||||
// legend: { |
||||
// data: this.data6, |
||||
// }, |
||||
// xAxis: { |
||||
// data: this.data8, |
||||
// }, |
||||
// yAxis: [ |
||||
// //两个y轴 |
||||
// { |
||||
// min: Min1, |
||||
// max: Max1, |
||||
// splitNumber: 10, |
||||
// interval: (Max1 - Min1) / 10, |
||||
// }, |
||||
// { |
||||
// min: Min2, |
||||
// max: Max2, |
||||
// splitNumber: 10, |
||||
// interval: (Max2 - Min2) / 10, |
||||
// }, |
||||
// ], |
||||
// series: [ |
||||
// { |
||||
// name: this.data6[0], |
||||
// data: this.data1, |
||||
// }, |
||||
// { |
||||
// name: this.data6[1], |
||||
// data: this.data2, |
||||
// }, |
||||
// { |
||||
// name: this.data6[2], |
||||
// data: this.data3, |
||||
// }, |
||||
// { |
||||
// name: this.data6[3], |
||||
// data: this.data4, |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.chartInstance1.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.chartInstance1.resize(); |
||||
// } |
||||
// }); |
||||
}, |
||||
// 导出数据 |
||||
outTable() { |
||||
// console.log("年数据啦"); |
||||
import("@/assets/excel/Export2Excel").then((excel) => { |
||||
const tHeader = [ |
||||
"类别", |
||||
"1月", |
||||
"2月", |
||||
"3月", |
||||
"4月", |
||||
"5月", |
||||
"6月", |
||||
"7月", |
||||
"8月", |
||||
"9月", |
||||
"10月", |
||||
"11月", |
||||
"12月", |
||||
"合计", |
||||
]; // 导出的excel表头名信息 |
||||
const filterVal = [ |
||||
"itemType", |
||||
"month01", |
||||
"month02", |
||||
"month03", |
||||
"month04", |
||||
"month05", |
||||
"month06", |
||||
"month07", |
||||
"month08", |
||||
"month09", |
||||
"month10", |
||||
"month11", |
||||
"month12", |
||||
"totalValue", |
||||
]; // 导出的excel表头字段名,需要导出表格字段名 |
||||
// const list = this.tableData; |
||||
// console.log(list) |
||||
if (this.chTime) { |
||||
this.endTime = this.chTime; |
||||
} else { |
||||
this.endTime = getYear(0); |
||||
} |
||||
let params = { |
||||
curDate: this.endTime, |
||||
buildingId: this.endId, |
||||
type: this.chType, |
||||
}; |
||||
console.log("年表格参数", params); |
||||
// this.$api.statementfind.energyYear(params).then((res) => { |
||||
// if (res.code == 200) { |
||||
// // console.log(res); |
||||
// const data = this.formatJson(filterVal, res.data); |
||||
// const autoWidth = true; |
||||
// excel.export_json_to_excel({ |
||||
// header: tHeader, //表头 |
||||
// data, //数据 |
||||
// filename: "年数据报表", //名称 |
||||
// autoWidth: true, //宽度自适应 |
||||
// }); |
||||
// } |
||||
// }); |
||||
}); |
||||
}, |
||||
//格式转换,不需要改动 |
||||
formatJson(filterVal, jsonData) { |
||||
return jsonData.map((v) => |
||||
filterVal.map((j) => { |
||||
if (j === "installDate") { |
||||
return format(v[j]); |
||||
} else { |
||||
return v[j]; |
||||
} |
||||
}) |
||||
); |
||||
}, |
||||
//初始化chartInstance1对象 |
||||
// 如果父组件点击了月 x轴数据 1号 2号 3号。。。 |
||||
// 如果父组件点击了年 x轴数据 1月 2月 3月。。。 |
||||
initChart1() { |
||||
this.$emit("initChart1"); |
||||
this.chartInstance1 = echarts.init(this.$refs.findwater_ref); |
||||
this.option1 = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
// 以下为鼠标hover时的背景颜色 |
||||
showDelay: 0, // 显示延迟,添加显示延迟可以避免频繁切换,单位ms |
||||
axisPointer: { |
||||
type: "shadow", |
||||
shadowStyle: { |
||||
color: "rgba(30, 69, 113, 0.15)", |
||||
width: "1", |
||||
}, |
||||
}, |
||||
}, |
||||
legend: { |
||||
// 折柱混合的图表,不显示icon,图例就可以根据不同的类型不同 |
||||
// icon: "cricle", |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 12, //这里改字体大小 |
||||
}, |
||||
left: "56%", |
||||
top: "5%", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
grid: { |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "3%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255,255,255,.7)", |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// 去除x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
// X 轴颜色配置 |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
//splitLine: { show: true } //x轴分割线 |
||||
}, |
||||
yAxis: [ |
||||
//两个y轴 |
||||
{ |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255,255,255,.7)", |
||||
}, |
||||
// 显示y坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
// X 轴颜色配置 |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
//y轴分割线段数 |
||||
splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
// color: "#252843", |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255,255,255,.7)", |
||||
formatter: "{value} %", |
||||
}, |
||||
// 显示y坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
// X 轴颜色配置 |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
//y轴分割线段数 |
||||
splitNumber: 5, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
// color: "#252843", |
||||
color: "#707070", |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
|
||||
series: [ |
||||
{ |
||||
type: "bar", |
||||
barWidth: 10, // 柱子宽度 |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#db9215", |
||||
lineStyle: { |
||||
color: "#db9215", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "bar", |
||||
// tooltip: { |
||||
// valueFormatter: function (value) { |
||||
// return value + "吨"; |
||||
// }, |
||||
// }, |
||||
tooltip: { |
||||
trigger: "axis", |
||||
formatter: function (params) { |
||||
//数据单位格式化 |
||||
var relVal = params[0].name; //x轴名称 |
||||
if (params[0].seriesName == "2022年用水量") { |
||||
relVal = |
||||
params[0].name + |
||||
"<br/>" + |
||||
params[0].seriesName + |
||||
" : " + |
||||
params[0].value + |
||||
" 吨"; |
||||
} else if (params[0].seriesName == "用电量") { |
||||
relVal = |
||||
params[0].name + |
||||
"<br/>" + |
||||
params[0].seriesName + |
||||
" : " + |
||||
params[0].value + |
||||
" 度"; |
||||
} else if (params[0].seriesName == "耗能") { |
||||
relVal = |
||||
params[0].name + |
||||
"<br/>" + |
||||
params[0].seriesName + |
||||
" : " + |
||||
params[0].value + |
||||
" 度/吨"; |
||||
} else { |
||||
relVal = |
||||
params[0].name + |
||||
"<br/>" + |
||||
params[0].seriesName + |
||||
" : " + |
||||
params[0].value + |
||||
" 次"; |
||||
} |
||||
return relVal; |
||||
}, |
||||
}, |
||||
barWidth: 10, // 柱子宽度 |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#1ab395", |
||||
lineStyle: { |
||||
color: "#1ab395", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "line", |
||||
tooltip: { |
||||
valueFormatter: function (value) { |
||||
return value + "%"; |
||||
}, |
||||
}, |
||||
// stack: 'Total', |
||||
symbol: "circle", |
||||
// 拐点大小 |
||||
symbolSize: 6, |
||||
yAxisIndex: 1, |
||||
// 开始不显示拐点, 鼠标经过显示 |
||||
showSymbol: false, |
||||
// data: this.data3, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#e23131", |
||||
lineStyle: { |
||||
color: "#e23131", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
type: "line", |
||||
tooltip: { |
||||
valueFormatter: function (value) { |
||||
return value + "%"; |
||||
}, |
||||
}, |
||||
// stack: 'Total', |
||||
symbol: "circle", |
||||
// 拐点大小 |
||||
symbolSize: 6, |
||||
//第二个y轴 |
||||
yAxisIndex: 1, |
||||
// 开始不显示拐点, 鼠标经过显示 |
||||
showSymbol: false, |
||||
// data: this.data4, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#4a98ff", |
||||
lineStyle: { |
||||
color: "#4a98ff", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.chartInstance1.setOption(this.option1, true); |
||||
}, |
||||
// 折线图自适应 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = (this.$refs.findwater_ref.offsetWidth / 100) * 1.8; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = { |
||||
//比如fontSize |
||||
textStyle: { |
||||
fontSize: titleFontSize, |
||||
}, |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.chartInstance1.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.chartInstance1.resize(); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style scoped> |
||||
.findwatercharts { |
||||
margin-bottom: 0.35rem; |
||||
width: 100%; |
||||
height: 4.5rem; |
||||
/* background-color: pink; */ |
||||
} |
||||
</style> |
@ -0,0 +1,448 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<div class="left-tree"> |
||||
<!-- 为 el-tree 设置一个固定的高度和滚动条 --> |
||||
<div style="height: 7rem; overflow-y: auto"> |
||||
<el-tree |
||||
ref="tree" |
||||
:data="treeData" |
||||
node-key="id" |
||||
:default-expand-all="false" |
||||
:default-expanded-keys="expandedKeys" |
||||
:auto-expand-parent="true" |
||||
icon-class="none" |
||||
@node-expand="handleNodeExpand" |
||||
@node-collapse="handleNodeCollapse" |
||||
:highlight-current="true" |
||||
@node-click="handleNodeClick" |
||||
> |
||||
<template #default="{ node }"> |
||||
<span class="custom-tree-node"> |
||||
<!-- 根据节点状态动态设置图标类名 --> |
||||
<div class="tree-left"> |
||||
<i :class="getIconClass(node)" class="custom-tree-icon"></i> |
||||
<span class="tree-label">{{ node.label }}</span> |
||||
</div> |
||||
</span> |
||||
</template> |
||||
</el-tree> |
||||
</div> |
||||
</div> |
||||
<div class="right-monitor"> |
||||
<div class="buildingDiv"> |
||||
<div class="buildingDiv-left"> |
||||
<img |
||||
class="title-bg" |
||||
src="../../../assets/images/title-bg.png" |
||||
alt="" |
||||
/> |
||||
<div class="title-word">位置:{{ currentName }}</div> |
||||
</div> |
||||
</div> |
||||
<!-- 条件 --> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="analysisType" |
||||
placeholder="请选择" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in analysisTypes" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.value" |
||||
/> |
||||
</el-select> |
||||
<div class="choice"> |
||||
<div |
||||
class="mr20" |
||||
v-for="(item, index) in timeData2" |
||||
:key="index" |
||||
@click="handleEnter(index, $event)" |
||||
:class="{ timeStyle: currentIndex == index }" |
||||
> |
||||
{{ item.title }} |
||||
</div> |
||||
</div> |
||||
<el-date-picker |
||||
v-model="monthDate" |
||||
type="month" |
||||
v-if="currentIndex === 0" |
||||
placeholder="选择开始月份" |
||||
value-format="yyyy-MM" |
||||
> |
||||
</el-date-picker> |
||||
<el-date-picker |
||||
v-model="yearDate" |
||||
v-if="currentIndex === 1" |
||||
type="year" |
||||
placeholder="选择开始年份" |
||||
style="width: 180px" |
||||
value-format="yyyy" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<analyze-month |
||||
v-if="currentIndex === 0" |
||||
ref="monthRef" |
||||
:chType="analysisType" |
||||
:chTime="monthDate" |
||||
></analyze-month> |
||||
<analyze-year |
||||
v-if="currentIndex === 1" |
||||
ref="yearRef" |
||||
:chType="analysisType" |
||||
:chTime="yearDate" |
||||
></analyze-year> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { spaceTree } from "@/api/region"; |
||||
import { format } from "@/utils/datetime"; |
||||
import { temList, temHistory } from "@/api/temSys/temMonitor"; |
||||
import * as echarts from "echarts"; |
||||
import analyzeMonth from "./components/analyzeMonth.vue"; |
||||
import analyzeYear from "./components/analyzeYear.vue"; |
||||
export default { |
||||
components: { analyzeMonth, analyzeYear }, |
||||
data() { |
||||
return { |
||||
loading: false, |
||||
treeData: [], |
||||
analysisType: 1, |
||||
analysisTypes: [ |
||||
{ |
||||
label: "用水量", |
||||
value: 1, |
||||
}, |
||||
{ |
||||
label: "用电量", |
||||
value: 2, |
||||
}, |
||||
{ |
||||
label: "耗能", |
||||
value: 3, |
||||
}, |
||||
{ |
||||
label: "维保量", |
||||
value: 4, |
||||
}, |
||||
{ |
||||
label: "使用时间", |
||||
value: 5, |
||||
}, |
||||
], |
||||
monthDate: "", |
||||
yearDate: "", |
||||
timeData2: [{ title: "月" }, { title: "年" }], |
||||
currentIndex: 0, //月 |
||||
defaultProps: { |
||||
children: "children", |
||||
label: "label", |
||||
}, |
||||
deviceList: [], |
||||
expandedKeys: [], |
||||
currentId: "", //当前选中高亮的id |
||||
currentName: "", //当前选中的名称 |
||||
currentLevel: "", //当前节点的层级 |
||||
currentParentId: "", //当前节点的上级的id |
||||
|
||||
tableData: [], //系统状态表格数据 |
||||
chartInstance: null, |
||||
option: {}, |
||||
chartData1: [], |
||||
chartData2: [], |
||||
bottomData: [], |
||||
}; |
||||
}, |
||||
mounted() { |
||||
this.getSysBuild(); |
||||
}, |
||||
methods: { |
||||
handleEnter(index) { |
||||
this.currentIndex = index; |
||||
// this.renderingBroken(); |
||||
}, |
||||
getSysBuild() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
console.log("筛选后的新结果", newRes); |
||||
this.treeData = newRes.data; |
||||
this.$nextTick(() => { |
||||
// 默认展开节点 |
||||
this.getExpandedKeys(this.treeData, 1); |
||||
if (this.treeData.length > 0) { |
||||
// 找到最后一层的第一个子节点 |
||||
const lastLevelFirstChild = this.findLastLevelFirstChild( |
||||
this.treeData[0] |
||||
); |
||||
// this.$refs.tree.setCurrentKey( |
||||
// this.treeData[0].children[0].children[0].children[0].id |
||||
// ); |
||||
// 设置当前选中的节点,默认高亮 |
||||
this.$refs.tree.setCurrentKey(lastLevelFirstChild.id); |
||||
// 更新当前节点的信息 |
||||
this.currentId = lastLevelFirstChild.id; |
||||
this.currentLevel = lastLevelFirstChild.level; |
||||
this.currentName = lastLevelFirstChild.label; |
||||
console.log("当前选中节点ID", this.currentId); |
||||
console.log("当前选中节点层级", this.currentLevel); |
||||
console.log("当前选中节点名称", this.currentName); |
||||
// this.getTemList(); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 递归函数,找到最后一层的第一个子节点 |
||||
findLastLevelFirstChild(node, level = 1) { |
||||
if (!node.children || node.children.length === 0) { |
||||
return { |
||||
id: node.id, |
||||
level, |
||||
label: node.label, |
||||
}; |
||||
} |
||||
return this.findLastLevelFirstChild(node.children[0], level + 1); |
||||
}, |
||||
// 默认只展示一二级菜单 |
||||
getExpandedKeys(nodes, level) { |
||||
nodes.forEach((node) => { |
||||
if (level <= this.currentId + 4) { |
||||
this.expandedKeys.push(node.id); |
||||
} |
||||
if (node.children) { |
||||
this.getExpandedKeys(node.children, level + 1); |
||||
} |
||||
}); |
||||
}, |
||||
// 更换图标 |
||||
getIconClass(node) { |
||||
// console.log("当前图标的节点内容", node); |
||||
if (node.level === 4) { |
||||
// 4级菜单时的图标 |
||||
if (node.expanded) { |
||||
return "el-icon-document"; // 4级菜单展开时的图标类名 |
||||
} |
||||
return "el-icon-document"; // 4级菜单收缩时的图标类名 |
||||
} |
||||
if (node.expanded) { |
||||
return "el-icon-folder-opened"; // 4三级菜单展开时的图标类名 |
||||
} |
||||
return "el-icon-folder-add"; // 4三级菜单收缩时的图标类名 |
||||
}, |
||||
handleNodeExpand(node) { |
||||
// 节点展开时触发 |
||||
}, |
||||
handleNodeCollapse(node) { |
||||
// 节点收缩时触发 |
||||
}, |
||||
// 点击当前节点,保存节点内容 |
||||
handleNodeClick(node, data) { |
||||
console.log("点击的当前节点", node, data); |
||||
if (data.level !== 4) { |
||||
console.log("不是第4层000"); |
||||
// 设置当前选中的节点,默认高亮 |
||||
this.$refs.tree.setCurrentKey(this.currentId); |
||||
console.log("当前选中节点ID", this.currentId); |
||||
console.log("当前选中节点层级", this.currentLevel); |
||||
console.log("当前选中节点名称", this.currentName); |
||||
} else { |
||||
console.log("第5层111"); |
||||
this.currentId = node.id; |
||||
this.currentLevel = data.level; |
||||
this.currentName = node.label; |
||||
// 设置当前选中的节点,默认高亮 |
||||
this.$refs.tree.setCurrentKey(this.currentId); |
||||
console.log("当前选中节点ID", this.currentId); |
||||
console.log("当前选中节点层级", this.currentLevel); |
||||
console.log("当前选中节点名称", this.currentName); |
||||
// this.getTemList(); |
||||
} |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
if (this.currentIndex == 0) { |
||||
// 调用月的更新表格数据函数 |
||||
this.$refs.monthRef.getMothData(); |
||||
} else { |
||||
//年 |
||||
this.$refs.yearRef.getYearData(); |
||||
} |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
if (this.currentIndex == 0) { |
||||
// 月 |
||||
this.$refs.monthRef.outTable(); |
||||
} else { |
||||
//年 |
||||
this.$refs.yearRef.outTable(); |
||||
} |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
} |
||||
} |
||||
.app-container { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
flex-wrap: nowrap; |
||||
align-items: stretch; |
||||
height: 100%; |
||||
.left-tree { |
||||
width: 256px; |
||||
padding: 15px 10px 10px 10px; |
||||
border: 1px solid #004b8c; |
||||
} |
||||
.right-monitor { |
||||
width: calc(100% - 280px); |
||||
display: flex; |
||||
flex-direction: column; |
||||
justify-content: flex-start; |
||||
.buildingDiv { |
||||
padding-left: 54px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
margin-bottom: 20px; |
||||
position: relative; |
||||
.title-bg { |
||||
width: 208px; |
||||
height: 38px; |
||||
position: absolute; |
||||
left: 0; |
||||
z-index: 0; |
||||
} |
||||
.title-word { |
||||
z-index: 10; |
||||
font-family: YouSheBiaoTiHei; |
||||
font-size: 24px; |
||||
color: #ffffff; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.choice { |
||||
margin-left: 0px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.3rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 870px; |
||||
height: 300px; |
||||
} |
||||
.tree-container { |
||||
height: 330px; /* 设置固定高度 */ |
||||
overflow-y: auto; /* 启用垂直滚动条 */ |
||||
} |
||||
// 滚动条 |
||||
:-webkit-scrollbar { |
||||
width: 10px; /* 滚动条宽度 */ |
||||
} |
||||
|
||||
::-webkit-scrollbar-track { |
||||
background: transparent !important; /* 滚动条轨道背景色 */ |
||||
} |
||||
.custom-tree-node { |
||||
flex: 1; |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
font-size: 14px; |
||||
padding-right: 8px; |
||||
.tree-left { |
||||
.custom-tree-icon { |
||||
margin-right: 5px; |
||||
} |
||||
} |
||||
} |
||||
@media (min-width: 1200px) and (max-width: 1540px) { |
||||
.tem-li { |
||||
width: calc(49% - 20px) !important; |
||||
} |
||||
} |
||||
@media (max-width: 1200px) { |
||||
.tem-li { |
||||
width: calc(100% - 40px) !important; |
||||
} |
||||
} |
||||
</style> |
||||
<style scoped> |
||||
/* 自定义高亮颜色 */ |
||||
.left-tree |
||||
>>> .el-tree--highlight-current |
||||
.el-tree-node.is-current |
||||
> .el-tree-node__content { |
||||
background-color: #285b9e !important; |
||||
/* color: #f56c6c; */ |
||||
color: #25f1f8; |
||||
} |
||||
</style> |
@ -0,0 +1,958 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="data-content"> |
||||
<div class="data-li type2"> |
||||
<img class="use-icon" src="../../../../assets/images/use1.png" alt="" /> |
||||
<div class="use-text"> |
||||
<div>用水量(吨)</div> |
||||
<div class="data-text">2</div> |
||||
</div> |
||||
<div class="use-text"> |
||||
<div>与昨日相比</div> |
||||
<div class="downText"> |
||||
<i class="el-icon-bottom"></i> |
||||
<span>-10%</span> |
||||
</div> |
||||
</div> |
||||
<img |
||||
class="type-img" |
||||
src="../../../../assets/images/texture2.png" |
||||
alt="" |
||||
/> |
||||
</div> |
||||
<div class="data-li type3"> |
||||
<img class="use-icon" src="../../../../assets/images/use2.png" alt="" /> |
||||
<div class="use-text"> |
||||
<div>用电量(度)</div> |
||||
<div class="data-text">31.600</div> |
||||
</div> |
||||
<div class="use-text"> |
||||
<div>与昨日相比</div> |
||||
<div class="upText"> |
||||
<i class="el-icon-top"></i> |
||||
<span>64.41%</span> |
||||
</div> |
||||
</div> |
||||
<img |
||||
class="type-img" |
||||
src="../../../../assets/images/texture2.png" |
||||
alt="" |
||||
/> |
||||
</div> |
||||
<div class="data-li type4"> |
||||
<img class="use-icon" src="../../../../assets/images/use3.png" alt="" /> |
||||
<div class="use-text"> |
||||
<div>单耗(度/吨)</div> |
||||
<div class="data-text">2</div> |
||||
</div> |
||||
<div class="use-text"> |
||||
<div>与昨日相比</div> |
||||
<div class="upText"> |
||||
<i class="el-icon-top"></i> |
||||
<span>64.41%</span> |
||||
</div> |
||||
</div> |
||||
<img |
||||
class="type-img" |
||||
src="../../../../assets/images/texture2.png" |
||||
alt="" |
||||
/> |
||||
</div> |
||||
</div> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<div class="time-label">时间类型:</div> |
||||
<el-radio-group |
||||
v-model="dateType" |
||||
style="margin-right: 0.24rem" |
||||
@change="updateDateType" |
||||
> |
||||
<el-radio label="day">日</el-radio> |
||||
<el-radio label="month">月</el-radio> |
||||
<el-radio label="year">年</el-radio> |
||||
</el-radio-group> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="daterange" |
||||
v-if="dateType == 'day'" |
||||
:key="this.dateType" |
||||
range-separator="至" |
||||
value-format="yyyy-MM-dd" |
||||
start-placeholder="开始日期" |
||||
end-placeholder="结束日期" |
||||
@change="dateChange" |
||||
> |
||||
</el-date-picker> |
||||
<el-date-picker |
||||
v-model="monthDate" |
||||
type="monthrange" |
||||
v-if="dateType == 'month'" |
||||
:key="this.dateType" |
||||
range-separator="至" |
||||
start-placeholder="开始月份" |
||||
end-placeholder="结束月份" |
||||
value-format="yyyy-MM" |
||||
@change="dateChange" |
||||
> |
||||
</el-date-picker> |
||||
<div class="years-div" v-if="dateType == 'year'" :key="this.dateType"> |
||||
<el-date-picker |
||||
v-model="startYear" |
||||
type="year" |
||||
placeholder="选择开始年份" |
||||
style="width: 180px" |
||||
value-format="yyyy" |
||||
> |
||||
</el-date-picker> |
||||
<div class="years-word">至</div> |
||||
<el-date-picker |
||||
v-model="endYear" |
||||
type="year" |
||||
placeholder="选择结束年份" |
||||
style="width: 180px" |
||||
value-format="yyyy" |
||||
> |
||||
</el-date-picker> |
||||
</div> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="choice"> |
||||
<div |
||||
class="mr20" |
||||
v-for="(item, index) in timeData2" |
||||
:key="index" |
||||
@click="handleEnter(index, $event)" |
||||
:class="{ timeStyle: currentIndex == index }" |
||||
> |
||||
{{ item.title }} |
||||
</div> |
||||
</div> |
||||
<div class="charts" ref="chart_ref"></div> |
||||
<el-table |
||||
v-loading="loading" |
||||
:data="postList" |
||||
stripe |
||||
:cell-style="tableRowStyle" |
||||
> |
||||
<el-table-column label="日期" align="center" prop="dateAndWeek" /> |
||||
<el-table-column label="所属楼栋" align="center" prop="maxTemp" /> |
||||
<el-table-column label="用水量(吨)" align="center" prop="minTemp" /> |
||||
<el-table-column |
||||
label="用电量(度)" |
||||
align="center" |
||||
prop="weatherConditions" |
||||
/> |
||||
<el-table-column |
||||
label="单耗(度/吨)" |
||||
align="center" |
||||
prop="windDirection" |
||||
/> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
v-show="total > 0" |
||||
:total="total" |
||||
:page.sync="queryParams.pageNum" |
||||
:limit.sync="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dateType: "day", //默认选择天 |
||||
dayDate: [], //日值 |
||||
monthDate: [], //月值 |
||||
startYear: "", //开始年份 |
||||
endYear: "", //结束年份 |
||||
|
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
// 遮罩层 |
||||
loading: true, |
||||
// 总条数 |
||||
total: 0, |
||||
// 表格数据 |
||||
postList: [], |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
brokenInstanc: null, |
||||
brokenOption: {}, |
||||
timeData2: [{ title: "用水量" }, { title: "用电量" }, { title: "单耗" }], |
||||
currentIndex: 0, |
||||
brokenData1: [], |
||||
brokenData2: [], |
||||
brokenData3: [], |
||||
brokenTime: [], |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.getList(); |
||||
this.initChart(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
this.screenAdapter(); |
||||
this.getChartData(); |
||||
}, |
||||
destroyed() { |
||||
//取消监听器 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
}, |
||||
methods: { |
||||
handleEnter(index) { |
||||
this.currentIndex = index; |
||||
this.renderingBroken(); |
||||
}, |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.building = this.builds[0].id; |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
const now = new Date(); |
||||
// 获取当前月份的第一天 |
||||
const start = new Date(now.getFullYear(), now.getMonth(), 1); |
||||
// 获取当前日期(作为结束时间) |
||||
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate()); |
||||
this.dayDate = [formatDay(start), formatDay(end)]; // 更新 |
||||
}, |
||||
// 选择时间类型 |
||||
updateDateType() { |
||||
// this.dateType = this.radio; |
||||
console.log(this.dateType); |
||||
(this.dayDate = []), //日值 |
||||
(this.monthDate = []), //月值 |
||||
(this.startYear = ""), //开始年份 |
||||
(this.endYear = ""); //结束年份 |
||||
}, |
||||
// 选中日期事件 |
||||
dateChange() { |
||||
// console.log("打印时间", this.timeform.time1); |
||||
if (!this.dayDate) { |
||||
this.$nextTick(() => { |
||||
this.dayDate = []; |
||||
}); |
||||
} |
||||
if (!this.monthDate) { |
||||
this.$nextTick(() => { |
||||
this.monthDate = []; |
||||
}); |
||||
} |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
console.log("this.dateType", this.dateType); |
||||
switch (this.dateType) { |
||||
case "day": |
||||
if (this.dayDate.length === 0) { |
||||
this.showMessage("请选择时间!", "warning"); |
||||
} else { |
||||
const newLength = |
||||
new Date(this.dayDate[1]).getTime() - |
||||
new Date(this.dayDate[0]).getTime(); |
||||
const dayDiff = Math.floor(newLength / (1000 * 60 * 60 * 24)); |
||||
if (dayDiff > 31) { |
||||
this.showMessage( |
||||
"最多只能选择30天区间,请重新选择再查询!", |
||||
"warning" |
||||
); |
||||
} else { |
||||
this.getList(); |
||||
} |
||||
} |
||||
break; |
||||
case "month": |
||||
if (this.monthDate.length === 0) { |
||||
this.showMessage("请选择时间!", "warning"); |
||||
} else { |
||||
const [start, end] = this.monthDate; |
||||
const startDate = new Date(start); |
||||
const endDate = new Date(end); |
||||
const startYear = startDate.getFullYear(); |
||||
const startMonth = startDate.getMonth(); |
||||
const endYear = endDate.getFullYear(); |
||||
const endMonth = endDate.getMonth(); |
||||
const monthDiff = |
||||
(endYear - startYear) * 12 + (endMonth - startMonth); |
||||
if (monthDiff > 12) { |
||||
this.showMessage( |
||||
"最多只能选择12个月区间,请重新选择再查询!", |
||||
"warning" |
||||
); |
||||
} else { |
||||
this.getList(); |
||||
} |
||||
} |
||||
break; |
||||
case "year": |
||||
if (!this.startYear || !this.endYear) { |
||||
this.showMessage("请选择全年份区间!", "warning"); |
||||
} else if (this.startYear > this.endYear) { |
||||
this.showMessage("结束年份要大于开始年份!", "warning"); |
||||
} else { |
||||
this.getList(); |
||||
} |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}, |
||||
// 显示消息的函数 |
||||
showMessage(message, type) { |
||||
this.$message({ |
||||
message: message, |
||||
type: type, |
||||
}); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
if (this.dateType == "day") { |
||||
this.queryParams.startTime = |
||||
this.dayDate.length > 0 ? this.dayDate[0] : ""; |
||||
this.queryParams.endTime = |
||||
this.dayDate.length > 0 ? this.dayDate[1] : ""; |
||||
} else if (this.dateType == "month") { |
||||
this.queryParams.startTime = |
||||
this.monthDate.length > 0 ? this.monthDate[0] : ""; |
||||
this.queryParams.endTime = |
||||
this.monthDate.length > 0 ? this.monthDate[1] : ""; |
||||
} else if (this.dateType == "year") { |
||||
(this.queryParams.startTime = this.startYear), |
||||
(this.queryParams.endTime = this.endYear); |
||||
} |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.queryParams.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// |
||||
getChartData() { |
||||
this.queryParams.pageNum = 0; |
||||
console.log("图表参数", this.queryParams); |
||||
this.brokenData1 = [30, 40, 29]; |
||||
this.brokenData2 = [10, 23, 12]; |
||||
this.brokenData3 = [3, 4, 2]; |
||||
this.brokenTime = ["3月", "4月", "5月"]; |
||||
// weatherTempData(this.queryParams).then((response) => { |
||||
// console.log("处理值然后渲染"); |
||||
// if (response.rows.length > 0) { |
||||
// let data = response.rows; |
||||
// let timeValue = []; |
||||
// let hightValue = []; |
||||
// let lowValue = []; |
||||
// data.forEach((element) => { |
||||
// timeValue.push(element.weatherDate); |
||||
// hightValue.push(element.maxTemp); |
||||
// lowValue.push(element.minTemp); |
||||
// }); |
||||
// let adapterOption = {}; |
||||
// adapterOption = { |
||||
// xAxis: { |
||||
// data: timeValue, |
||||
// }, |
||||
// series: [ |
||||
// { |
||||
// data: hightValue, |
||||
// //折线颜色 |
||||
// itemStyle: { |
||||
// color: "rgb(18, 126, 226)", //折线的颜色 |
||||
// }, |
||||
// lineStyle: { |
||||
// color: "rgb(18, 126, 226)", //折线点的颜色 |
||||
// }, |
||||
// }, |
||||
// { |
||||
// data: lowValue, |
||||
// //折线颜色 |
||||
// itemStyle: { |
||||
// color: "rgb(250, 169, 19)", //折线的颜色 |
||||
// }, |
||||
// lineStyle: { |
||||
// color: "rgb(250, 169, 19)", //折线点的颜色 |
||||
// }, |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.brokenInstanc.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.brokenInstanc.resize(); |
||||
// } else { |
||||
// let adapterOption = {}; |
||||
// adapterOption = { |
||||
// xAxis: { |
||||
// data: [], |
||||
// }, |
||||
// series: [ |
||||
// { |
||||
// data: [], |
||||
// }, |
||||
// { |
||||
// data: [], |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.brokenInstanc.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.brokenInstanc.resize(); |
||||
// } |
||||
// }); |
||||
this.renderingBroken(); |
||||
}, |
||||
renderingBroken() { |
||||
if (this.currentIndex === 0) { |
||||
this.brokenOption.series[0].data = this.brokenData1; |
||||
this.brokenOption.series[0].itemStyle.color = "#d48e17"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(212, 142, 23, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(212, 142, 23,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
} else if (this.currentIndex === 1) { |
||||
this.brokenOption.series[0].data = this.brokenData2; |
||||
this.brokenOption.series[0].itemStyle.color = "#1ab395"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(26, 179, 149, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(26, 179, 149,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
} else if (this.currentIndex === 2) { |
||||
this.brokenOption.series[0].data = this.brokenData3; |
||||
this.brokenOption.series[0].itemStyle.color = "#1f8dee"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
} |
||||
// 保存当前索引用于闭包 |
||||
const currentIndex = this.currentIndex; |
||||
// 动态设置 tooltip 格式化函数 |
||||
this.brokenOption.tooltip = { |
||||
trigger: "axis", |
||||
formatter: function (params) { |
||||
// 获取当前数据点信息 |
||||
const data = params[0]; |
||||
const month = data.name; |
||||
const value = data.value; |
||||
|
||||
// 根据索引返回不同内容 |
||||
if (currentIndex === 0) { |
||||
return `${month}<br/>用水量: ${value} 吨`; |
||||
} else if (currentIndex === 1) { |
||||
return `${month}<br/>用电量: ${value} 度`; |
||||
} else if (currentIndex === 2) { |
||||
return `${month}<br/>单耗: ${value} 度/吨`; |
||||
} |
||||
}, |
||||
}; |
||||
this.brokenOption.xAxis.data = this.brokenTime; |
||||
this.brokenInstanc.setOption(this.brokenOption); |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("导出数据参数", data); |
||||
analyzeExport(data).then((res) => { |
||||
console.log("导出返回", res); |
||||
if (res) { |
||||
// 请求的结果就是文件 |
||||
// 创建一个blob URL,用于生成下载链接 |
||||
const url = window.URL.createObjectURL(new Blob([res])); |
||||
// 创建一个<a>元素,并设置其href和download属性 |
||||
const link = document.createElement("a"); |
||||
link.href = url; |
||||
link.setAttribute("download", "机房能耗报表.xls"); // 设置下载的文件名 |
||||
// 模拟点击下载链接 |
||||
document.body.appendChild(link); |
||||
link.click(); |
||||
document.body.removeChild(link); |
||||
// 释放blob URL资源 |
||||
window.URL.revokeObjectURL(url); |
||||
this.$message({ |
||||
type: "success", |
||||
message: "导出成功!", |
||||
}); |
||||
} else { |
||||
this.$message.error("导出失败!"); |
||||
} |
||||
}); |
||||
// .catch((err) => { |
||||
// this.$message.error('导出失败!'); |
||||
// }) |
||||
}, |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 修改颜色 |
||||
if (columnIndex === 1) { |
||||
return "color: #fd1e00;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 2) { |
||||
return "color: #3390ff;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 4) { |
||||
return "color: #75d148;!important;text-align:center"; |
||||
} |
||||
// return "text-align:center"; |
||||
}, |
||||
// 折线图自适应+ 根据按钮切换图例仅限一条且不可点击+ 折线图数据 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = this.$refs.chart_ref.offsetWidth / 130; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = {}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
}, |
||||
//初始化chartInstance对象 |
||||
initChart() { |
||||
this.brokenInstanc = echarts.init(this.$refs.chart_ref); |
||||
this.brokenOption = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
}, |
||||
legend: { |
||||
show: false, |
||||
selectedMode: false, // 是否允许图例进行点击 |
||||
icon: "cricle", //图例样式,可以自行查看样式选择 |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 16, //这里改字体大小 |
||||
}, |
||||
// left: "73%", |
||||
left: "66%", |
||||
top: "0", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
|
||||
grid: { |
||||
top: "4%", |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "5%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, //强制显示所有x轴数据 |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", |
||||
}, |
||||
}, |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#e2e6f0", |
||||
}, |
||||
}, //x轴分割线 |
||||
data: this.brokenTime, |
||||
}, |
||||
yAxis: { |
||||
min: 0, |
||||
// max:20, |
||||
// // // min:'dataMin', |
||||
// // // max:'dataMax', |
||||
// name: "kwh", // 第一个 y 轴的单位描述 |
||||
// 设置 name 的样式 |
||||
nameTextStyle: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 12, |
||||
}, |
||||
miniInterval: 5, |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
}, |
||||
// 显示y坐标轴 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", // 设置 y 轴线的颜色 |
||||
}, |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
//y轴分割线段数 |
||||
// splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#1a3d62", // 设置分割线的颜色 |
||||
type: "dashed", // 设置分割线为虚线 |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
type: "line", |
||||
// 拐点大小 |
||||
symbolSize: 8, |
||||
smooth: true, |
||||
showSymbol: false, |
||||
data: this.brokenData1, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#d48e17", //折线点的颜色 |
||||
lineStyle: { |
||||
color: "#d48e17", //折线的颜色 |
||||
}, |
||||
}, |
||||
areaStyle: { |
||||
color: { |
||||
//线性渐变 |
||||
type: "linear", |
||||
x: 0, |
||||
y: 0, |
||||
x2: 0, |
||||
y2: 1, |
||||
colorStops: [], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.brokenInstanc.setOption(this.brokenOption, true); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 300px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,779 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="date" |
||||
value-format="yyyy-MM-dd" |
||||
placeholder="选择日期" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="charts" ref="chart_ref"></div> |
||||
<el-table |
||||
:data="postList" |
||||
stripe |
||||
:cell-style="tableRowStyle" |
||||
@row-click="handlerow" |
||||
highlight-current-row |
||||
height="500" |
||||
> |
||||
<el-table-column label="楼栋名称" align="center" prop="dateAndWeek" /> |
||||
<el-table-column label="0点" align="center" prop="maxTemp" /> |
||||
<el-table-column label="2点" align="center" prop="minTemp" /> |
||||
<el-table-column label="6点" align="center" prop="minTemp" /> |
||||
<el-table-column label="8点" align="center" prop="minTemp" /> |
||||
<el-table-column label="11点" align="center" prop="minTemp" /> |
||||
<el-table-column label="13点" align="center" prop="minTemp" /> |
||||
<el-table-column label="14点" align="center" prop="minTemp" /> |
||||
<el-table-column label="15点" align="center" prop="minTemp" /> |
||||
<el-table-column label="16点" align="center" prop="minTemp" /> |
||||
<el-table-column label="17点" align="center" prop="minTemp" /> |
||||
<el-table-column label="18点" align="center" prop="minTemp" /> |
||||
<el-table-column label="19点" align="center" prop="minTemp" /> |
||||
<el-table-column label="20点" align="center" prop="minTemp" /> |
||||
<el-table-column label="21点" align="center" prop="minTemp" /> |
||||
<el-table-column label="22点" align="center" prop="minTemp" /> |
||||
<el-table-column label="23点" align="center" prop="minTemp" /> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
v-show="total > 0" |
||||
:total="total" |
||||
:page.sync="queryParams.pageNum" |
||||
:limit.sync="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dayDate: [], //日值 |
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
// 遮罩层 |
||||
loading: false, |
||||
// 总条数 |
||||
total: 0, |
||||
// 表格数据 |
||||
postList: [], |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
brokenInstanc: null, |
||||
brokenOption: {}, |
||||
brokenData1: [], |
||||
brokenTime: [], |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.getList(); |
||||
this.initChart(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
this.screenAdapter(); |
||||
this.getChartData(); |
||||
}, |
||||
destroyed() { |
||||
//取消监听器 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
}, |
||||
methods: { |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.building = this.builds[0].id; |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
this.dayDate = formatDay(new Date()); // 更新 |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
this.getList(); |
||||
}, |
||||
// 显示消息的函数 |
||||
showMessage(message, type) { |
||||
this.$message({ |
||||
message: message, |
||||
type: type, |
||||
}); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
let data = { |
||||
startTime: this.dayDate, |
||||
endTime: this.dayDate, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// |
||||
getChartData() { |
||||
this.queryParams.pageNum = 0; |
||||
console.log("图表参数", this.queryParams); |
||||
this.brokenData1 = [30, 40, 29]; |
||||
this.brokenTime = ["3月", "4月", "5月"]; |
||||
this.brokenOption.series[0].data = this.brokenData1; |
||||
this.brokenOption.series[0].itemStyle.color = "#1f8dee"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
// 动态设置 tooltip 格式化函数 |
||||
this.brokenOption.tooltip = { |
||||
trigger: "axis", |
||||
formatter: function (params) { |
||||
// 获取当前数据点信息 |
||||
const data = params[0]; |
||||
const month = data.name; |
||||
const value = data.value; |
||||
return `${month}<br/>温度: ${value} ℃`; |
||||
}, |
||||
}; |
||||
this.brokenOption.xAxis.data = this.brokenTime; |
||||
this.brokenInstanc.setOption(this.brokenOption); |
||||
// weatherTempData(this.queryParams).then((response) => { |
||||
// console.log("处理值然后渲染"); |
||||
// if (response.rows.length > 0) { |
||||
// let data = response.rows; |
||||
// let timeValue = []; |
||||
// let hightValue = []; |
||||
// let lowValue = []; |
||||
// data.forEach((element) => { |
||||
// timeValue.push(element.weatherDate); |
||||
// hightValue.push(element.maxTemp); |
||||
// lowValue.push(element.minTemp); |
||||
// }); |
||||
// let adapterOption = {}; |
||||
// adapterOption = { |
||||
// xAxis: { |
||||
// data: timeValue, |
||||
// }, |
||||
// series: [ |
||||
// { |
||||
// data: hightValue, |
||||
// //折线颜色 |
||||
// itemStyle: { |
||||
// color: "rgb(18, 126, 226)", //折线的颜色 |
||||
// }, |
||||
// lineStyle: { |
||||
// color: "rgb(18, 126, 226)", //折线点的颜色 |
||||
// }, |
||||
// }, |
||||
// { |
||||
// data: lowValue, |
||||
// //折线颜色 |
||||
// itemStyle: { |
||||
// color: "rgb(250, 169, 19)", //折线的颜色 |
||||
// }, |
||||
// lineStyle: { |
||||
// color: "rgb(250, 169, 19)", //折线点的颜色 |
||||
// }, |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.brokenInstanc.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.brokenInstanc.resize(); |
||||
// } else { |
||||
// let adapterOption = {}; |
||||
// adapterOption = { |
||||
// xAxis: { |
||||
// data: [], |
||||
// }, |
||||
// series: [ |
||||
// { |
||||
// data: [], |
||||
// }, |
||||
// { |
||||
// data: [], |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.brokenInstanc.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.brokenInstanc.resize(); |
||||
// } |
||||
// }); |
||||
}, |
||||
//查询单个热泵状态 点击表格的某一行 |
||||
handlerow(row, event, column) { |
||||
// console.log("点击的行数据----", row) |
||||
if (row) { |
||||
const obj = Object.assign({}, row); |
||||
// 先截取掉不需要的对象属性和值 |
||||
delete obj.buildingID; |
||||
delete obj.curDate; |
||||
delete obj.pumpID; |
||||
delete obj.pumpName; |
||||
delete obj.buildingName; |
||||
//定义一个新数组 |
||||
let newObj = {}; |
||||
for (let key in obj) { |
||||
if (obj[key]) { |
||||
newObj[key] = obj[key]; |
||||
} |
||||
} |
||||
// console.log("不含空的数组对象", newObj); |
||||
// 在返回的新的对象中,取出对象的所有key值返回新数组 |
||||
// Object.setPrototypeOf(this.newObj); |
||||
// let data7 = Object.keys(newObj); |
||||
// console.log("不含空的x轴数据", data7); |
||||
const keysArr = Object.keys(newObj); // 获取对象所有属性名的数组 |
||||
this.brokenTime = []; |
||||
keysArr.forEach((item) => { |
||||
if (item) { |
||||
this.brokenTime.push(item.split("temp").join("") + ":00"); |
||||
} |
||||
}); |
||||
const valuesArr = keysArr.map((key) => newObj[key]); // 将属性名对应的值提取出来存入一个新的数组中 |
||||
// console.log("值", valuesArr); |
||||
// console.log("坐标", this.brokenTime); |
||||
this.brokenData1 = valuesArr; |
||||
const adapterOption = { |
||||
xAxis: { |
||||
data: this.brokenTime, |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: "温度", |
||||
data: this.brokenData1, |
||||
itemStyle: { |
||||
color: "#1f8dee", |
||||
}, |
||||
areaStyle: { |
||||
color: { |
||||
colorStops: [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
} else { |
||||
const adapterOption = { |
||||
xAxis: { |
||||
data: [], |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: "温度", |
||||
data: [], |
||||
}, |
||||
], |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
} |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("导出数据参数", data); |
||||
analyzeExport(data).then((res) => { |
||||
console.log("导出返回", res); |
||||
if (res) { |
||||
// 请求的结果就是文件 |
||||
// 创建一个blob URL,用于生成下载链接 |
||||
const url = window.URL.createObjectURL(new Blob([res])); |
||||
// 创建一个<a>元素,并设置其href和download属性 |
||||
const link = document.createElement("a"); |
||||
link.href = url; |
||||
link.setAttribute("download", "机房能耗报表.xls"); // 设置下载的文件名 |
||||
// 模拟点击下载链接 |
||||
document.body.appendChild(link); |
||||
link.click(); |
||||
document.body.removeChild(link); |
||||
// 释放blob URL资源 |
||||
window.URL.revokeObjectURL(url); |
||||
this.$message({ |
||||
type: "success", |
||||
message: "导出成功!", |
||||
}); |
||||
} else { |
||||
this.$message.error("导出失败!"); |
||||
} |
||||
}); |
||||
// .catch((err) => { |
||||
// this.$message.error('导出失败!'); |
||||
// }) |
||||
}, |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 修改颜色 |
||||
if (columnIndex === 1) { |
||||
return "color: #fd1e00;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 2) { |
||||
return "color: #3390ff;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 4) { |
||||
return "color: #75d148;!important;text-align:center"; |
||||
} |
||||
// return "text-align:center"; |
||||
}, |
||||
// 折线图自适应+ 根据按钮切换图例仅限一条且不可点击+ 折线图数据 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = this.$refs.chart_ref.offsetWidth / 130; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = {}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
}, |
||||
//初始化chartInstance对象 |
||||
initChart() { |
||||
this.brokenInstanc = echarts.init(this.$refs.chart_ref); |
||||
this.brokenOption = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
}, |
||||
legend: { |
||||
show: false, |
||||
selectedMode: false, // 是否允许图例进行点击 |
||||
icon: "cricle", //图例样式,可以自行查看样式选择 |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 16, //这里改字体大小 |
||||
}, |
||||
// left: "73%", |
||||
left: "66%", |
||||
top: "0", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
|
||||
grid: { |
||||
top: "4%", |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "5%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, //强制显示所有x轴数据 |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", |
||||
}, |
||||
}, |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#e2e6f0", |
||||
}, |
||||
}, //x轴分割线 |
||||
data: this.brokenTime, |
||||
}, |
||||
yAxis: { |
||||
min: 0, |
||||
// max:20, |
||||
// // // min:'dataMin', |
||||
// // // max:'dataMax', |
||||
// name: "kwh", // 第一个 y 轴的单位描述 |
||||
// 设置 name 的样式 |
||||
nameTextStyle: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 12, |
||||
}, |
||||
miniInterval: 5, |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
}, |
||||
// 显示y坐标轴 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", // 设置 y 轴线的颜色 |
||||
}, |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
//y轴分割线段数 |
||||
// splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#1a3d62", // 设置分割线的颜色 |
||||
type: "dashed", // 设置分割线为虚线 |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
type: "line", |
||||
// 拐点大小 |
||||
symbolSize: 8, |
||||
smooth: true, |
||||
showSymbol: false, |
||||
data: this.brokenData1, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#d48e17", //折线点的颜色 |
||||
lineStyle: { |
||||
color: "#d48e17", //折线的颜色 |
||||
}, |
||||
}, |
||||
areaStyle: { |
||||
color: { |
||||
//线性渐变 |
||||
type: "linear", |
||||
x: 0, |
||||
y: 0, |
||||
x2: 0, |
||||
y2: 1, |
||||
colorStops: [], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.brokenInstanc.setOption(this.brokenOption, true); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 300px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,779 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="date" |
||||
value-format="yyyy-MM-dd" |
||||
placeholder="选择日期" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="charts" ref="chart_ref"></div> |
||||
<el-table |
||||
:data="postList" |
||||
stripe |
||||
:cell-style="tableRowStyle" |
||||
@row-click="handlerow" |
||||
highlight-current-row |
||||
height="500" |
||||
> |
||||
<el-table-column label="楼栋名称" align="center" prop="dateAndWeek" /> |
||||
<el-table-column label="0点" align="center" prop="maxTemp" /> |
||||
<el-table-column label="2点" align="center" prop="minTemp" /> |
||||
<el-table-column label="6点" align="center" prop="minTemp" /> |
||||
<el-table-column label="8点" align="center" prop="minTemp" /> |
||||
<el-table-column label="11点" align="center" prop="minTemp" /> |
||||
<el-table-column label="13点" align="center" prop="minTemp" /> |
||||
<el-table-column label="14点" align="center" prop="minTemp" /> |
||||
<el-table-column label="15点" align="center" prop="minTemp" /> |
||||
<el-table-column label="16点" align="center" prop="minTemp" /> |
||||
<el-table-column label="17点" align="center" prop="minTemp" /> |
||||
<el-table-column label="18点" align="center" prop="minTemp" /> |
||||
<el-table-column label="19点" align="center" prop="minTemp" /> |
||||
<el-table-column label="20点" align="center" prop="minTemp" /> |
||||
<el-table-column label="21点" align="center" prop="minTemp" /> |
||||
<el-table-column label="22点" align="center" prop="minTemp" /> |
||||
<el-table-column label="23点" align="center" prop="minTemp" /> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
v-show="total > 0" |
||||
:total="total" |
||||
:page.sync="queryParams.pageNum" |
||||
:limit.sync="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dayDate: [], //日值 |
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
// 遮罩层 |
||||
loading: false, |
||||
// 总条数 |
||||
total: 0, |
||||
// 表格数据 |
||||
postList: [], |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
brokenInstanc: null, |
||||
brokenOption: {}, |
||||
brokenData1: [], |
||||
brokenTime: [], |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.getList(); |
||||
this.initChart(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
this.screenAdapter(); |
||||
this.getChartData(); |
||||
}, |
||||
destroyed() { |
||||
//取消监听器 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
}, |
||||
methods: { |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.building = this.builds[0].id; |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
this.dayDate = formatDay(new Date()); // 更新 |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
this.getList(); |
||||
}, |
||||
// 显示消息的函数 |
||||
showMessage(message, type) { |
||||
this.$message({ |
||||
message: message, |
||||
type: type, |
||||
}); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
let data = { |
||||
startTime: this.dayDate, |
||||
endTime: this.dayDate, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// |
||||
getChartData() { |
||||
this.queryParams.pageNum = 0; |
||||
console.log("图表参数", this.queryParams); |
||||
this.brokenData1 = [30, 40, 29]; |
||||
this.brokenTime = ["3月", "4月", "5月"]; |
||||
this.brokenOption.series[0].data = this.brokenData1; |
||||
this.brokenOption.series[0].itemStyle.color = "#1f8dee"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
// 动态设置 tooltip 格式化函数 |
||||
this.brokenOption.tooltip = { |
||||
trigger: "axis", |
||||
formatter: function (params) { |
||||
// 获取当前数据点信息 |
||||
const data = params[0]; |
||||
const month = data.name; |
||||
const value = data.value; |
||||
return `${month}<br/>水位: ${value} %`; |
||||
}, |
||||
}; |
||||
this.brokenOption.xAxis.data = this.brokenTime; |
||||
this.brokenInstanc.setOption(this.brokenOption); |
||||
// weatherTempData(this.queryParams).then((response) => { |
||||
// console.log("处理值然后渲染"); |
||||
// if (response.rows.length > 0) { |
||||
// let data = response.rows; |
||||
// let timeValue = []; |
||||
// let hightValue = []; |
||||
// let lowValue = []; |
||||
// data.forEach((element) => { |
||||
// timeValue.push(element.weatherDate); |
||||
// hightValue.push(element.maxTemp); |
||||
// lowValue.push(element.minTemp); |
||||
// }); |
||||
// let adapterOption = {}; |
||||
// adapterOption = { |
||||
// xAxis: { |
||||
// data: timeValue, |
||||
// }, |
||||
// series: [ |
||||
// { |
||||
// data: hightValue, |
||||
// //折线颜色 |
||||
// itemStyle: { |
||||
// color: "rgb(18, 126, 226)", //折线的颜色 |
||||
// }, |
||||
// lineStyle: { |
||||
// color: "rgb(18, 126, 226)", //折线点的颜色 |
||||
// }, |
||||
// }, |
||||
// { |
||||
// data: lowValue, |
||||
// //折线颜色 |
||||
// itemStyle: { |
||||
// color: "rgb(250, 169, 19)", //折线的颜色 |
||||
// }, |
||||
// lineStyle: { |
||||
// color: "rgb(250, 169, 19)", //折线点的颜色 |
||||
// }, |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.brokenInstanc.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.brokenInstanc.resize(); |
||||
// } else { |
||||
// let adapterOption = {}; |
||||
// adapterOption = { |
||||
// xAxis: { |
||||
// data: [], |
||||
// }, |
||||
// series: [ |
||||
// { |
||||
// data: [], |
||||
// }, |
||||
// { |
||||
// data: [], |
||||
// }, |
||||
// ], |
||||
// }; |
||||
// //记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
// this.brokenInstanc.setOption(adapterOption); |
||||
// //手动的调用图标对象的resize才能产生效果 |
||||
// this.brokenInstanc.resize(); |
||||
// } |
||||
// }); |
||||
}, |
||||
//查询单个热泵状态 点击表格的某一行 |
||||
handlerow(row, event, column) { |
||||
// console.log("点击的行数据----", row) |
||||
if (row) { |
||||
const obj = Object.assign({}, row); |
||||
// 先截取掉不需要的对象属性和值 |
||||
delete obj.buildingID; |
||||
delete obj.curDate; |
||||
delete obj.pumpID; |
||||
delete obj.pumpName; |
||||
delete obj.buildingName; |
||||
//定义一个新数组 |
||||
let newObj = {}; |
||||
for (let key in obj) { |
||||
if (obj[key]) { |
||||
newObj[key] = obj[key]; |
||||
} |
||||
} |
||||
// console.log("不含空的数组对象", newObj); |
||||
// 在返回的新的对象中,取出对象的所有key值返回新数组 |
||||
// Object.setPrototypeOf(this.newObj); |
||||
// let data7 = Object.keys(newObj); |
||||
// console.log("不含空的x轴数据", data7); |
||||
const keysArr = Object.keys(newObj); // 获取对象所有属性名的数组 |
||||
this.brokenTime = []; |
||||
keysArr.forEach((item) => { |
||||
if (item) { |
||||
this.brokenTime.push(item.split("temp").join("") + ":00"); |
||||
} |
||||
}); |
||||
const valuesArr = keysArr.map((key) => newObj[key]); // 将属性名对应的值提取出来存入一个新的数组中 |
||||
// console.log("值", valuesArr); |
||||
// console.log("坐标", this.brokenTime); |
||||
this.brokenData1 = valuesArr; |
||||
const adapterOption = { |
||||
xAxis: { |
||||
data: this.brokenTime, |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: "温度", |
||||
data: this.brokenData1, |
||||
itemStyle: { |
||||
color: "#1f8dee", |
||||
}, |
||||
areaStyle: { |
||||
color: { |
||||
colorStops: [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
} else { |
||||
const adapterOption = { |
||||
xAxis: { |
||||
data: [], |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: "温度", |
||||
data: [], |
||||
}, |
||||
], |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
} |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("导出数据参数", data); |
||||
analyzeExport(data).then((res) => { |
||||
console.log("导出返回", res); |
||||
if (res) { |
||||
// 请求的结果就是文件 |
||||
// 创建一个blob URL,用于生成下载链接 |
||||
const url = window.URL.createObjectURL(new Blob([res])); |
||||
// 创建一个<a>元素,并设置其href和download属性 |
||||
const link = document.createElement("a"); |
||||
link.href = url; |
||||
link.setAttribute("download", "机房能耗报表.xls"); // 设置下载的文件名 |
||||
// 模拟点击下载链接 |
||||
document.body.appendChild(link); |
||||
link.click(); |
||||
document.body.removeChild(link); |
||||
// 释放blob URL资源 |
||||
window.URL.revokeObjectURL(url); |
||||
this.$message({ |
||||
type: "success", |
||||
message: "导出成功!", |
||||
}); |
||||
} else { |
||||
this.$message.error("导出失败!"); |
||||
} |
||||
}); |
||||
// .catch((err) => { |
||||
// this.$message.error('导出失败!'); |
||||
// }) |
||||
}, |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 修改颜色 |
||||
if (columnIndex === 1) { |
||||
return "color: #fd1e00;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 2) { |
||||
return "color: #3390ff;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 4) { |
||||
return "color: #75d148;!important;text-align:center"; |
||||
} |
||||
// return "text-align:center"; |
||||
}, |
||||
// 折线图自适应+ 根据按钮切换图例仅限一条且不可点击+ 折线图数据 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = this.$refs.chart_ref.offsetWidth / 130; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = {}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
}, |
||||
//初始化chartInstance对象 |
||||
initChart() { |
||||
this.brokenInstanc = echarts.init(this.$refs.chart_ref); |
||||
this.brokenOption = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
}, |
||||
legend: { |
||||
show: false, |
||||
selectedMode: false, // 是否允许图例进行点击 |
||||
icon: "cricle", //图例样式,可以自行查看样式选择 |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 16, //这里改字体大小 |
||||
}, |
||||
// left: "73%", |
||||
left: "66%", |
||||
top: "0", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
|
||||
grid: { |
||||
top: "4%", |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "5%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, //强制显示所有x轴数据 |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", |
||||
}, |
||||
}, |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#e2e6f0", |
||||
}, |
||||
}, //x轴分割线 |
||||
data: this.brokenTime, |
||||
}, |
||||
yAxis: { |
||||
min: 0, |
||||
// max:20, |
||||
// // // min:'dataMin', |
||||
// // // max:'dataMax', |
||||
// name: "kwh", // 第一个 y 轴的单位描述 |
||||
// 设置 name 的样式 |
||||
nameTextStyle: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 12, |
||||
}, |
||||
miniInterval: 5, |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
}, |
||||
// 显示y坐标轴 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", // 设置 y 轴线的颜色 |
||||
}, |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
//y轴分割线段数 |
||||
// splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#1a3d62", // 设置分割线的颜色 |
||||
type: "dashed", // 设置分割线为虚线 |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
type: "line", |
||||
// 拐点大小 |
||||
symbolSize: 8, |
||||
smooth: true, |
||||
showSymbol: false, |
||||
data: this.brokenData1, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#d48e17", //折线点的颜色 |
||||
lineStyle: { |
||||
color: "#d48e17", //折线的颜色 |
||||
}, |
||||
}, |
||||
areaStyle: { |
||||
color: { |
||||
//线性渐变 |
||||
type: "linear", |
||||
x: 0, |
||||
y: 0, |
||||
x2: 0, |
||||
y2: 1, |
||||
colorStops: [], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.brokenInstanc.setOption(this.brokenOption, true); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 300px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,94 @@
|
||||
<template> |
||||
<div class="paramsDetails"> |
||||
<div class="details-content"> |
||||
<div class="details-header"> |
||||
<el-tabs v-model="activeName" @tab-click="handleClick"> |
||||
<el-tab-pane label="能耗报表" name="first"> |
||||
<energy-report v-if="activeName === 'first'"></energy-report> |
||||
</el-tab-pane> |
||||
<el-tab-pane label="温度变化表" name="second"> |
||||
<tem-report v-if="activeName === 'second'"></tem-report> |
||||
</el-tab-pane> |
||||
<el-tab-pane label="水位变化表" name="three"> |
||||
<water-report v-if="activeName === 'three'"></water-report> |
||||
</el-tab-pane> |
||||
</el-tabs> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import EnergyReport from "./components/energyReport.vue"; |
||||
import TemReport from "./components/temReport.vue"; |
||||
import WaterReport from "./components/waterReport.vue"; |
||||
|
||||
export default { |
||||
components: { EnergyReport, TemReport, WaterReport }, |
||||
data() { |
||||
return { |
||||
activeName: "first", //能耗报表 |
||||
}; |
||||
}, |
||||
methods: { |
||||
handleClick(tab, event) { |
||||
console.log(tab, event); |
||||
}, |
||||
|
||||
//当在子页面中点击按钮时,会触发switch-tab事件, |
||||
// 然后在父组件中监听到这个事件,并将activeName设置为'second',从而让第二个tab成为当前选中的tab。 |
||||
switchToEquitesMess() { |
||||
this.activeName = "second"; |
||||
}, |
||||
switchToPatrolTem() { |
||||
// this.activeName = 'fourth'; |
||||
}, |
||||
// 记得请求冷水机组数据时,默认选中第一个冷水机组 |
||||
}, |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.paramsDetails { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: stretch; |
||||
justify-content: space-between; |
||||
|
||||
.details-content { |
||||
width: 100%; |
||||
// height: 0.42rem; |
||||
position: relative; |
||||
} |
||||
} |
||||
</style> |
||||
<style scoped> |
||||
.none-div { |
||||
padding-top: 0.31rem; |
||||
} |
||||
|
||||
.none-div >>> .el-tree { |
||||
background: transparent; |
||||
color: #789d9f; |
||||
} |
||||
|
||||
.none-div >>> .el-tree-node:focus > .el-tree-node__content { |
||||
background-color: #00be97; |
||||
color: #fff; |
||||
} |
||||
|
||||
.none-div >>> .el-tree-node__content:hover, |
||||
.none-div >>> .el-upload-list__item:hover { |
||||
background-color: #00be97; |
||||
color: #fff; |
||||
} |
||||
|
||||
.none-div >>> .el-tree-node__content { |
||||
height: 0.48rem; |
||||
justify-content: center; |
||||
} |
||||
|
||||
.none-div >>> .el-tree-node__expand-icon.is-leaf { |
||||
display: none !important; |
||||
} |
||||
</style> |
@ -0,0 +1,439 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="daterange" |
||||
range-separator="至" |
||||
value-format="yyyy-MM-dd" |
||||
start-placeholder="开始日期" |
||||
end-placeholder="结束日期" |
||||
@change="dateChange" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<el-table |
||||
:data="postList" |
||||
stripe |
||||
:cell-style="tableRowStyle" |
||||
highlight-current-row |
||||
height="500" |
||||
> |
||||
<el-table-column label="所属楼栋" align="center" prop="dateAndWeek" /> |
||||
<el-table-column label="设备编号" align="center" prop="maxTemp" /> |
||||
<el-table-column label="设备名称" align="center" prop="minTemp" /> |
||||
<el-table-column label="抄表时间" align="center" prop="minTemp" /> |
||||
<el-table-column label="采集读数" align="center" prop="minTemp" /> |
||||
<el-table-column label="用量" align="center" prop="minTemp" /> |
||||
<el-table-column label="倍率" align="center" prop="minTemp" /> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
v-show="total > 0" |
||||
:total="total" |
||||
:page.sync="queryParams.pageNum" |
||||
:limit.sync="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dayDate: [], //日值 |
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
// 遮罩层 |
||||
loading: false, |
||||
// 总条数 |
||||
total: 0, |
||||
// 表格数据 |
||||
postList: [], |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.getList(); |
||||
}, |
||||
methods: { |
||||
// 选中日期事件 |
||||
dateChange() { |
||||
// console.log("打印时间", this.timeform.time1); |
||||
if (!this.dayDate) { |
||||
this.$nextTick(() => { |
||||
this.dayDate = []; |
||||
}); |
||||
} |
||||
}, |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
this.dayDate = formatDay(new Date()); // 更新 |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
this.getList(); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
let data = { |
||||
startTime: this.dayDate, |
||||
endTime: this.dayDate, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("导出数据参数", data); |
||||
analyzeExport(data).then((res) => { |
||||
console.log("导出返回", res); |
||||
if (res) { |
||||
// 请求的结果就是文件 |
||||
// 创建一个blob URL,用于生成下载链接 |
||||
const url = window.URL.createObjectURL(new Blob([res])); |
||||
// 创建一个<a>元素,并设置其href和download属性 |
||||
const link = document.createElement("a"); |
||||
link.href = url; |
||||
link.setAttribute("download", "机房能耗报表.xls"); // 设置下载的文件名 |
||||
// 模拟点击下载链接 |
||||
document.body.appendChild(link); |
||||
link.click(); |
||||
document.body.removeChild(link); |
||||
// 释放blob URL资源 |
||||
window.URL.revokeObjectURL(url); |
||||
this.$message({ |
||||
type: "success", |
||||
message: "导出成功!", |
||||
}); |
||||
} else { |
||||
this.$message.error("导出失败!"); |
||||
} |
||||
}); |
||||
// .catch((err) => { |
||||
// this.$message.error('导出失败!'); |
||||
// }) |
||||
}, |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 修改颜色 |
||||
if (columnIndex === 1) { |
||||
return "color: #fd1e00;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 2) { |
||||
return "color: #3390ff;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 4) { |
||||
return "color: #75d148;!important;text-align:center"; |
||||
} |
||||
// return "text-align:center"; |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 300px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,583 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="date" |
||||
value-format="yyyy-MM-dd" |
||||
placeholder="选择日期" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="choice"> |
||||
<div |
||||
class="mr20" |
||||
v-for="(item, index) in timeData2" |
||||
:key="index" |
||||
@click="handleEnter(index, $event)" |
||||
:class="{ timeStyle: currentIndex == index }" |
||||
> |
||||
{{ item.title }} |
||||
</div> |
||||
</div> |
||||
<div class="charts" ref="chart_ref"></div> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dayDate: [], //日值 |
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
timeData2: [{ title: "用水量" }, { title: "用电量" }], |
||||
currentIndex: 0, |
||||
// 遮罩层 |
||||
loading: false, |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
brokenInstanc: null, |
||||
brokenOption: {}, |
||||
brokenData1: [], |
||||
brokenTime: [], |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.initChart(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
this.screenAdapter(); |
||||
this.getList(); |
||||
}, |
||||
destroyed() { |
||||
//取消监听器 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
}, |
||||
methods: { |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.building = this.builds[0].id; |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
this.dayDate = formatDay(new Date()); // 更新 |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
this.getList(); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
let data = { |
||||
startTime: this.dayDate, |
||||
endTime: this.dayDate, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
this.brokenData1 = [30, 40, 29]; |
||||
this.brokenData2 = [40, 42, 29]; |
||||
this.brokenTime = ["3月", "4月", "5月"]; |
||||
this.getChartData(); |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// |
||||
getChartData() { |
||||
this.brokenOption.series[0].data = this.brokenData1; |
||||
this.brokenOption.series[0].itemStyle.color = "#1f8dee"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
if (this.currentIndex === 0) { |
||||
this.brokenOption.series[0].data = this.brokenData1; |
||||
this.brokenOption.series[0].itemStyle.color = "#1f8dee"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(31, 141, 238, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(31, 141, 238,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
} else if (this.currentIndex === 1) { |
||||
this.brokenOption.series[0].data = this.brokenData2; |
||||
this.brokenOption.series[0].itemStyle.color = "#1ab395"; |
||||
this.brokenOption.series[0].areaStyle.color.colorStops = [ |
||||
{ |
||||
offset: 0, |
||||
color: "rgba(26, 179, 149, 0.3)", // 0% 处的颜色 |
||||
}, |
||||
{ |
||||
offset: 0.8, |
||||
color: "rgba(26, 179, 149,0)", // 100% 处的颜色 |
||||
}, |
||||
]; |
||||
} |
||||
// 保存当前索引用于闭包 |
||||
const currentIndex = this.currentIndex; |
||||
// 动态设置 tooltip 格式化函数 |
||||
this.brokenOption.tooltip = { |
||||
trigger: "axis", |
||||
formatter: function (params) { |
||||
// 获取当前数据点信息 |
||||
const data = params[0]; |
||||
const month = data.name; |
||||
const value = data.value; |
||||
|
||||
// 根据索引返回不同内容 |
||||
if (currentIndex === 0) { |
||||
return `${month}<br/>用水量: ${value} 吨`; |
||||
} else if (currentIndex === 1) { |
||||
return `${month}<br/>用电量: ${value} 度`; |
||||
} |
||||
}, |
||||
}; |
||||
this.brokenOption.xAxis.data = this.brokenTime; |
||||
this.brokenInstanc.setOption(this.brokenOption); |
||||
}, |
||||
handleEnter(index) { |
||||
this.currentIndex = index; |
||||
this.getChartData(); |
||||
}, |
||||
// 折线图自适应+ 根据按钮切换图例仅限一条且不可点击+ 折线图数据 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = this.$refs.chart_ref.offsetWidth / 130; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = {}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
}, |
||||
//初始化chartInstance对象 |
||||
initChart() { |
||||
this.brokenInstanc = echarts.init(this.$refs.chart_ref); |
||||
this.brokenOption = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
}, |
||||
legend: { |
||||
show: false, |
||||
selectedMode: false, // 是否允许图例进行点击 |
||||
icon: "cricle", //图例样式,可以自行查看样式选择 |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 16, //这里改字体大小 |
||||
}, |
||||
// left: "73%", |
||||
left: "66%", |
||||
top: "0", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
|
||||
grid: { |
||||
top: "4%", |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "5%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, //强制显示所有x轴数据 |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", |
||||
}, |
||||
}, |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#e2e6f0", |
||||
}, |
||||
}, //x轴分割线 |
||||
data: this.brokenTime, |
||||
}, |
||||
yAxis: { |
||||
min: 0, |
||||
// max:20, |
||||
// // // min:'dataMin', |
||||
// // // max:'dataMax', |
||||
// name: "kwh", // 第一个 y 轴的单位描述 |
||||
// 设置 name 的样式 |
||||
nameTextStyle: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 12, |
||||
}, |
||||
miniInterval: 5, |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
}, |
||||
// 显示y坐标轴 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", // 设置 y 轴线的颜色 |
||||
}, |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
//y轴分割线段数 |
||||
// splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#1a3d62", // 设置分割线的颜色 |
||||
type: "dashed", // 设置分割线为虚线 |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
type: "line", |
||||
// 拐点大小 |
||||
symbolSize: 8, |
||||
smooth: true, |
||||
showSymbol: false, |
||||
data: this.brokenData1, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#d48e17", //折线点的颜色 |
||||
lineStyle: { |
||||
color: "#d48e17", //折线的颜色 |
||||
}, |
||||
}, |
||||
areaStyle: { |
||||
color: { |
||||
//线性渐变 |
||||
type: "linear", |
||||
x: 0, |
||||
y: 0, |
||||
x2: 0, |
||||
y2: 1, |
||||
colorStops: [], |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.brokenInstanc.setOption(this.brokenOption, true); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 700px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,439 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="daterange" |
||||
range-separator="至" |
||||
value-format="yyyy-MM-dd" |
||||
start-placeholder="开始日期" |
||||
end-placeholder="结束日期" |
||||
@change="dateChange" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<el-table |
||||
:data="postList" |
||||
stripe |
||||
:cell-style="tableRowStyle" |
||||
highlight-current-row |
||||
height="500" |
||||
> |
||||
<el-table-column label="所属楼栋" align="center" prop="dateAndWeek" /> |
||||
<el-table-column label="设备编号" align="center" prop="maxTemp" /> |
||||
<el-table-column label="设备名称" align="center" prop="minTemp" /> |
||||
<el-table-column label="抄表时间" align="center" prop="minTemp" /> |
||||
<el-table-column label="采集读数" align="center" prop="minTemp" /> |
||||
<el-table-column label="用量" align="center" prop="minTemp" /> |
||||
<el-table-column label="倍率" align="center" prop="minTemp" /> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
v-show="total > 0" |
||||
:total="total" |
||||
:page.sync="queryParams.pageNum" |
||||
:limit.sync="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dayDate: [], //日值 |
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
// 遮罩层 |
||||
loading: false, |
||||
// 总条数 |
||||
total: 0, |
||||
// 表格数据 |
||||
postList: [], |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.getList(); |
||||
}, |
||||
methods: { |
||||
// 选中日期事件 |
||||
dateChange() { |
||||
// console.log("打印时间", this.timeform.time1); |
||||
if (!this.dayDate) { |
||||
this.$nextTick(() => { |
||||
this.dayDate = []; |
||||
}); |
||||
} |
||||
}, |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
this.dayDate = formatDay(new Date()); // 更新 |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
this.getList(); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
let data = { |
||||
startTime: this.dayDate, |
||||
endTime: this.dayDate, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("导出数据参数", data); |
||||
analyzeExport(data).then((res) => { |
||||
console.log("导出返回", res); |
||||
if (res) { |
||||
// 请求的结果就是文件 |
||||
// 创建一个blob URL,用于生成下载链接 |
||||
const url = window.URL.createObjectURL(new Blob([res])); |
||||
// 创建一个<a>元素,并设置其href和download属性 |
||||
const link = document.createElement("a"); |
||||
link.href = url; |
||||
link.setAttribute("download", "机房能耗报表.xls"); // 设置下载的文件名 |
||||
// 模拟点击下载链接 |
||||
document.body.appendChild(link); |
||||
link.click(); |
||||
document.body.removeChild(link); |
||||
// 释放blob URL资源 |
||||
window.URL.revokeObjectURL(url); |
||||
this.$message({ |
||||
type: "success", |
||||
message: "导出成功!", |
||||
}); |
||||
} else { |
||||
this.$message.error("导出失败!"); |
||||
} |
||||
}); |
||||
// .catch((err) => { |
||||
// this.$message.error('导出失败!'); |
||||
// }) |
||||
}, |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 修改颜色 |
||||
if (columnIndex === 1) { |
||||
return "color: #fd1e00;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 2) { |
||||
return "color: #3390ff;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 4) { |
||||
return "color: #75d148;!important;text-align:center"; |
||||
} |
||||
// return "text-align:center"; |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 300px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,439 @@
|
||||
<template> |
||||
<div class="big-machine" v-loading="listLoading"> |
||||
<div class="condition"> |
||||
<div class="condition-left"> |
||||
<el-select |
||||
style="margin-right: 0.1rem" |
||||
v-model="building" |
||||
placeholder="请选择楼栋" |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="(item, index) in builds" |
||||
:key="index" |
||||
:label="item.label" |
||||
:value="item.id" |
||||
/> |
||||
</el-select> |
||||
<el-date-picker |
||||
v-model="dayDate" |
||||
type="daterange" |
||||
range-separator="至" |
||||
value-format="yyyy-MM-dd" |
||||
start-placeholder="开始日期" |
||||
end-placeholder="结束日期" |
||||
@change="dateChange" |
||||
> |
||||
</el-date-picker> |
||||
<div class="success-btn" style="margin: 0 0.12rem"> |
||||
<el-button type="success" @click="findData">查询</el-button> |
||||
</div> |
||||
<div class="warning-btn"> |
||||
<el-button type="warning" @click="exportData">导出</el-button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<el-table |
||||
:data="postList" |
||||
stripe |
||||
:cell-style="tableRowStyle" |
||||
highlight-current-row |
||||
height="500" |
||||
> |
||||
<el-table-column label="所属楼栋" align="center" prop="dateAndWeek" /> |
||||
<el-table-column label="设备编号" align="center" prop="maxTemp" /> |
||||
<el-table-column label="设备名称" align="center" prop="minTemp" /> |
||||
<el-table-column label="抄表时间" align="center" prop="minTemp" /> |
||||
<el-table-column label="采集读数" align="center" prop="minTemp" /> |
||||
<el-table-column label="用量" align="center" prop="minTemp" /> |
||||
<el-table-column label="倍率" align="center" prop="minTemp" /> |
||||
</el-table> |
||||
|
||||
<pagination |
||||
v-show="total > 0" |
||||
:total="total" |
||||
:page.sync="queryParams.pageNum" |
||||
:limit.sync="queryParams.pageSize" |
||||
@pagination="getList" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { formatDay } from "@/utils/datetime"; |
||||
import { energyAnalyze, analyzeExport } from "@/api/centerairC/energyManage"; |
||||
import { spaceTree } from "@/api/region"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
listLoading: false, |
||||
dayDate: [], //日值 |
||||
dialogVisible: false, |
||||
building: "", //选中的楼栋 |
||||
builds: [], //楼栋列表 |
||||
// 遮罩层 |
||||
loading: false, |
||||
// 总条数 |
||||
total: 0, |
||||
// 表格数据 |
||||
postList: [], |
||||
// 查询参数 |
||||
queryParams: { |
||||
pageNum: 1, |
||||
pageSize: 10, |
||||
startTime: "", |
||||
endTime: "", |
||||
}, |
||||
}; |
||||
}, |
||||
created() { |
||||
// 在组件创建完成后,设置默认值 |
||||
}, |
||||
mounted() { |
||||
this.initializeTimeDate(); |
||||
this.getBuildList(); |
||||
this.getList(); |
||||
}, |
||||
methods: { |
||||
// 选中日期事件 |
||||
dateChange() { |
||||
// console.log("打印时间", this.timeform.time1); |
||||
if (!this.dayDate) { |
||||
this.$nextTick(() => { |
||||
this.dayDate = []; |
||||
}); |
||||
} |
||||
}, |
||||
/** 查询楼栋 */ |
||||
getBuildList() { |
||||
spaceTree().then((res) => { |
||||
if (res.code == 200) { |
||||
// 只需要保留热水的系统 |
||||
console.log("楼栋返回值", res); |
||||
let newRes = { ...res }; |
||||
|
||||
if (newRes.data && newRes.data[0] && newRes.data[0].children) { |
||||
newRes.data[0].children = newRes.data[0].children.filter((item) => { |
||||
// 假设子项有一个 label属性,用于检查是否包含 "热水" |
||||
return item.label && item.label.includes("热水"); |
||||
}); |
||||
} |
||||
// 指定要保留的最大层级(从 1 开始计数),这里假设指定为第 4 级 |
||||
const targetLevel = 4; |
||||
// 从 data[0] 开始处理,当前层级为 1 |
||||
if (newRes.data[0]) { |
||||
this.removeChildrenAfterLevel(newRes.data[0], 1, targetLevel); |
||||
} |
||||
this.builds = newRes.data[0].children[0].children[0].children; |
||||
// console.log("筛选后的新结果", this.builds); |
||||
this.getList(); |
||||
} |
||||
}); |
||||
}, |
||||
// 递归函数,用于去除指定层级往后的 children 数据 |
||||
removeChildrenAfterLevel(obj, currentLevel, targetLevel) { |
||||
if (currentLevel >= targetLevel) { |
||||
// 当达到指定层级时,将 children 属性置为空数组 |
||||
obj.children = []; |
||||
return; |
||||
} |
||||
if (obj.children && obj.children.length > 0) { |
||||
// 若存在 children 数组,则递归处理每个子项 |
||||
for (let i = 0; i < obj.children.length; i++) { |
||||
this.removeChildrenAfterLevel( |
||||
obj.children[i], |
||||
currentLevel + 1, |
||||
targetLevel |
||||
); |
||||
} |
||||
} |
||||
}, |
||||
// 初始化时间 |
||||
initializeTimeDate() { |
||||
this.dayDate = formatDay(new Date()); // 更新 |
||||
}, |
||||
// 查询 |
||||
findData() { |
||||
this.getList(); |
||||
}, |
||||
//请求数据 |
||||
getList() { |
||||
let data = { |
||||
startTime: this.dayDate, |
||||
endTime: this.dayDate, |
||||
building: this.building, |
||||
}; |
||||
console.log("查询数据参数", data); |
||||
this.listLoading = true; |
||||
// 请求数据 |
||||
// Just to simulate the time of the request |
||||
setTimeout(() => { |
||||
this.listLoading = false; |
||||
}, 1.0 * 1000); |
||||
}, |
||||
// 导出 |
||||
exportData() { |
||||
let data = { |
||||
timeType: this.dateType, |
||||
startTime: this.queryParams.startTime, |
||||
endTime: this.endTime, |
||||
building: this.building, |
||||
}; |
||||
console.log("导出数据参数", data); |
||||
analyzeExport(data).then((res) => { |
||||
console.log("导出返回", res); |
||||
if (res) { |
||||
// 请求的结果就是文件 |
||||
// 创建一个blob URL,用于生成下载链接 |
||||
const url = window.URL.createObjectURL(new Blob([res])); |
||||
// 创建一个<a>元素,并设置其href和download属性 |
||||
const link = document.createElement("a"); |
||||
link.href = url; |
||||
link.setAttribute("download", "机房能耗报表.xls"); // 设置下载的文件名 |
||||
// 模拟点击下载链接 |
||||
document.body.appendChild(link); |
||||
link.click(); |
||||
document.body.removeChild(link); |
||||
// 释放blob URL资源 |
||||
window.URL.revokeObjectURL(url); |
||||
this.$message({ |
||||
type: "success", |
||||
message: "导出成功!", |
||||
}); |
||||
} else { |
||||
this.$message.error("导出失败!"); |
||||
} |
||||
}); |
||||
// .catch((err) => { |
||||
// this.$message.error('导出失败!'); |
||||
// }) |
||||
}, |
||||
tableRowStyle({ row, column, rowIndex, columnIndex }) { |
||||
// 修改颜色 |
||||
if (columnIndex === 1) { |
||||
return "color: #fd1e00;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 2) { |
||||
return "color: #3390ff;!important;text-align:center"; |
||||
} |
||||
if (columnIndex === 4) { |
||||
return "color: #75d148;!important;text-align:center"; |
||||
} |
||||
// return "text-align:center"; |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.condition { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
width: 100%; |
||||
margin-bottom: 0.24rem; |
||||
|
||||
.condition-left { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.years-div { |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
|
||||
.years-word { |
||||
font-size: 14px; |
||||
margin: 0 5px; |
||||
color: #388ff3; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 16px; |
||||
line-height: 7px; |
||||
margin-right: 12px; |
||||
white-space: nowrap; |
||||
} |
||||
} |
||||
} |
||||
.data-content { |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
justify-content: space-between; |
||||
width: 100%; |
||||
margin-top: 23px; |
||||
.data-li { |
||||
background-color: transparent; |
||||
border-radius: 8px; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
padding: 0.3rem; |
||||
width: 31%; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.24rem; |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.16rem; |
||||
position: relative; |
||||
overflow: hidden; |
||||
.use-icon { |
||||
width: 0.6rem; |
||||
height: 0.6rem; |
||||
} |
||||
.use-text { |
||||
width: 33%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
color: #dbdbdb; |
||||
.data-text { |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
color: #ffffff; |
||||
} |
||||
.downText { |
||||
color: #ff4027; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
.upText { |
||||
color: #2ff016; |
||||
z-index: 11 !important; |
||||
font-family: DIN-Bold; |
||||
font-size: 0.24rem; |
||||
margin-top: 0.05rem; |
||||
.el-icon-bottom, |
||||
.el-icon-top { |
||||
margin-right: 0.08rem; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.type-img { |
||||
position: absolute; |
||||
bottom: 0; |
||||
width: 3.17rem; |
||||
height: 0.52rem; |
||||
z-index: 10; |
||||
} |
||||
.type1 { |
||||
border: 1px solid #e8aa13; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(26, 56, 65, 0.5), rgba(184, 196, 51, 0.5)); |
||||
} |
||||
.type1::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(243, 166, 23, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type2 { |
||||
border: 1px solid #27a0f2; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 43, 88, 0.5), rgba(8, 96, 179, 0.5)); |
||||
} |
||||
.type2::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(28, 128, 241, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type3 { |
||||
border: 1px solid #1ad3ef; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 50, 89, 0.5), rgba(17, 145, 151, 0.5)); |
||||
} |
||||
.type3::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(117, 242, 248, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
.type4 { |
||||
border: 1px solid #11d47b; |
||||
border-radius: 10px; |
||||
/* 设置渐变背景 */ |
||||
background: linear-gradient(rgba(2, 57, 82, 0.5), rgba(5, 91, 90, 0.5)); |
||||
} |
||||
.type4::after { |
||||
content: ""; |
||||
width: 100%; |
||||
height: 90%; |
||||
box-shadow: 0 0 30px 40px rgba(115, 245, 176, 0.3); |
||||
border-radius: 50%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
position: absolute; |
||||
bottom: -100% !important; |
||||
z-index: 1; |
||||
} |
||||
} |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.charts { |
||||
width: 100%; |
||||
height: 300px; |
||||
margin-bottom: 0.1rem; |
||||
} |
||||
// 媒体查询,适配大于2000px分辨率的大屏样式 |
||||
@media (min-width: 2000px) { |
||||
.condition { |
||||
.condition-left { |
||||
.years-div { |
||||
.years-word { |
||||
font-size: 0.14rem !important; |
||||
margin: 0 0.05rem !important; |
||||
} |
||||
} |
||||
|
||||
.time-label { |
||||
font-size: 0.16rem !important; |
||||
line-height: 0.07rem !important; |
||||
margin-right: 0.12rem !important; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,735 @@
|
||||
<template> |
||||
<div class="app-container" v-loading="loading"> |
||||
<div class="overview-top"> |
||||
<div class="overview-top-left"> |
||||
<div class="special-div"> |
||||
<div class="special-top"> |
||||
<div class="special-title">项目概况</div> |
||||
</div> |
||||
<div class="overview-data"> |
||||
<div class="overview-data-li"> |
||||
<img |
||||
class="overview-img" |
||||
src="../../../assets/images/overview1.png" |
||||
alt="" |
||||
/> |
||||
<div class="overview-num">640.4</div> |
||||
<div class="overview-title">昨日用水量(吨)</div> |
||||
</div> |
||||
<div class="overview-data-li"> |
||||
<img |
||||
class="overview-img" |
||||
src="../../../assets/images/overview2.png" |
||||
alt="" |
||||
/> |
||||
<div class="overview-num">2428.88</div> |
||||
<div class="overview-title">昨日用电量(度)</div> |
||||
</div> |
||||
<div class="overview-data-li"> |
||||
<img |
||||
class="overview-img" |
||||
src="../../../assets/images/overview3.png" |
||||
alt="" |
||||
/> |
||||
<div class="overview-num">3.79</div> |
||||
<div class="overview-title">昨日单耗(度/吨)</div> |
||||
</div> |
||||
<div class="overview-data-li"> |
||||
<img |
||||
class="overview-img" |
||||
src="../../../assets/images/overview4.png" |
||||
alt="" |
||||
/> |
||||
<div class="overview-num">186</div> |
||||
<div class="overview-title">通讯设备设备总数(台)</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="overview-top-right"> |
||||
<div class="special-div"> |
||||
<div class="special-top"> |
||||
<div class="special-title">热泵运行状态</div> |
||||
</div> |
||||
<div class="pump-charts" ref="pumpChart_ref"></div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="overview-bottom"> |
||||
<div class="overview-top-left"> |
||||
<div class="special-div"> |
||||
<div class="special-top"> |
||||
<div class="special-title">当月数据统计</div> |
||||
</div> |
||||
<div class="choice"> |
||||
<div |
||||
class="mr20" |
||||
v-for="(item, index) in timeData2" |
||||
:key="index" |
||||
@click="handleEnter(index, $event)" |
||||
:class="{ timeStyle: currentIndex == index }" |
||||
> |
||||
{{ item.title }} |
||||
</div> |
||||
</div> |
||||
<div class="brokenEcharts" ref="analyse_ref"></div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import * as echarts from "echarts"; |
||||
export default { |
||||
data() { |
||||
return { |
||||
loading: false, |
||||
chartInstance: null, |
||||
option: {}, |
||||
chartData1: "", |
||||
chartData2: "", |
||||
allData: "", |
||||
|
||||
timeData2: [{ title: "用水量" }, { title: "用电量" }, { title: "单耗" }], |
||||
currentIndex: 0, |
||||
brokenOption: "", |
||||
brokenInstanc: null, |
||||
brokenData1: [], |
||||
brokenData2: [], |
||||
brokenData3: [], |
||||
brokenTime: [], |
||||
}; |
||||
}, |
||||
mounted() { |
||||
this.initChart(); |
||||
this.initChart2(); |
||||
this.getTableData(); |
||||
window.addEventListener("resize", this.screenAdapter); |
||||
window.addEventListener("resize", this.screenAdapter2); |
||||
this.screenAdapter(); |
||||
// this.screenAdapter2(); |
||||
this.pumpEchartsData(); |
||||
}, |
||||
destroyed() { |
||||
//取消监听器 |
||||
window.removeEventListener("resize", this.screenAdapter); |
||||
window.removeEventListener("resize", this.screenAdapter2); |
||||
}, |
||||
methods: { |
||||
// 饼图自适应 |
||||
screenAdapter() { |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = this.$refs.pumpChart_ref.offsetWidth / 30; |
||||
//因为option可以多次配置的,所以这里的option只需要写 需要配置大小的相关数据 |
||||
const adapterOption = { |
||||
title: { |
||||
subtextStyle: { |
||||
fontSize: titleFontSize, |
||||
}, |
||||
}, |
||||
}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.chartInstance.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.chartInstance.resize(); |
||||
}, |
||||
// 获取热泵运行状态 |
||||
pumpEchartsData() { |
||||
let data = true; |
||||
this.chartData1 = 10; |
||||
this.chartData2 = 3; |
||||
this.allData = 13; |
||||
if (data) { |
||||
const titleFontSize = (this.$refs.pumpChart_ref.offsetWidth / 100) * 2; |
||||
const colorList = ["#ffe21e", "#08c8ff"]; // 提取颜色列表 |
||||
const adapterOption = { |
||||
tooltip: { |
||||
trigger: "item", |
||||
formatter: "{a} <br/>{b} : {c} ({d}%)", |
||||
}, |
||||
//环形图中间文字 |
||||
title: { |
||||
subtext: this.allData, |
||||
}, |
||||
legend: { |
||||
itemWidth: titleFontSize, |
||||
itemHeight: titleFontSize, |
||||
itemGap: titleFontSize * 2, |
||||
formatter: function (name) { |
||||
var arr = []; |
||||
let data = adapterOption.series[0].data; |
||||
var index = 0; |
||||
var total = 0; |
||||
for (var i = 0; i < data.length; i++) { |
||||
total += data[i].value; |
||||
if (data[i].name == name) { |
||||
index = i; |
||||
} |
||||
} |
||||
arr.push( |
||||
"{name|" + name + "}", |
||||
"{text|" + " " + ":" + " " + "}", |
||||
"{value|" + data[index].value + "}", |
||||
"{text|" + " " + "台" + "}" |
||||
); |
||||
return arr.join(""); |
||||
}, |
||||
textStyle: { |
||||
color: function (name) { |
||||
const dataSeries = adapterOption.series[1].data; // 数据圆的data |
||||
const index = dataSeries.findIndex( |
||||
(item) => item.name === name |
||||
); |
||||
const colorList = ["#2df499", "#08c8ff"]; // 数据圆的颜色列表 |
||||
return colorList[index]; |
||||
}, |
||||
rich: { |
||||
name: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
}, |
||||
text: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
}, |
||||
value: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
// color: function (params) { |
||||
// let data = adapterOption.series[1].data; |
||||
// return data.itemStyle.color({ dataIndex: params.dataIndex }); |
||||
// }, |
||||
}, |
||||
percentage: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 2, |
||||
// color: function (params) { |
||||
// let data = adapterOption.series[1].data; |
||||
// return data.itemStyle.color({ dataIndex: params.dataIndex }); |
||||
// }, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: "温度监测:", |
||||
data: [ |
||||
{ value: this.chartData1, name: "运行" }, |
||||
{ value: this.chartData2, name: "不运行" }, |
||||
], |
||||
itemStyle: { |
||||
color: function (params) { |
||||
var colorList = ["#2df499", "#08c8ff"]; |
||||
return colorList[params.dataIndex]; |
||||
}, |
||||
// borderWidth: 5, |
||||
borderColor: "#002a56", |
||||
}, |
||||
}, |
||||
{ |
||||
data: [ |
||||
{ value: this.chartData1, name: "运行" }, |
||||
{ value: this.chartData2, name: "不运行" }, |
||||
], |
||||
}, |
||||
], |
||||
}; |
||||
this.chartInstance.setOption(adapterOption); |
||||
this.chartInstance.resize(); |
||||
} else { |
||||
const titleFontSize = (this.$refs.pumpChart_ref.offsetWidth / 100) * 2; |
||||
const adapterOption = { |
||||
tooltip: { |
||||
trigger: "item", |
||||
formatter: "{a} <br/>{b} : {c} ({d}%)", |
||||
}, |
||||
//环形图中间文字 |
||||
title: { |
||||
subtext: 0, |
||||
}, |
||||
legend: { |
||||
itemWidth: titleFontSize, |
||||
itemHeight: titleFontSize, |
||||
itemGap: titleFontSize * 2, |
||||
formatter: function (name) { |
||||
var arr = []; |
||||
let data = adapterOption.series[0].data; |
||||
var index = 0; |
||||
var total = 0; |
||||
for (var i = 0; i < data.length; i++) { |
||||
total += data[i].value; |
||||
if (data[i].name == name) { |
||||
index = i; |
||||
} |
||||
} |
||||
arr.push( |
||||
"{name|" + name + "}", |
||||
"{text|" + " " + ":" + " " + "}", |
||||
"{value|" + data[index].value + "}", |
||||
"{text|" + " " + "台" + "}" |
||||
); |
||||
return arr.join(""); |
||||
}, |
||||
textStyle: { |
||||
color: function (name) { |
||||
const dataSeries = adapterOption.series[1].data; // 数据圆的data |
||||
const index = dataSeries.findIndex( |
||||
(item) => item.name === name |
||||
); |
||||
const colorList = ["#2df499", "#08c8ff"]; // 数据圆的颜色列表 |
||||
return colorList[index]; |
||||
}, |
||||
rich: { |
||||
name: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
}, |
||||
text: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
}, |
||||
value: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
// color: function (params) { |
||||
// let data = adapterOption.series[1].data; |
||||
// return data.itemStyle.color({ dataIndex: params.dataIndex }); |
||||
// }, |
||||
}, |
||||
percentage: { |
||||
align: "left", |
||||
fontSize: titleFontSize * 1.6, |
||||
// color: function (params) { |
||||
// let data = adapterOption.series[1].data; |
||||
// return data.itemStyle.color({ dataIndex: params.dataIndex }); |
||||
// }, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
name: "温度监测:", |
||||
data: [ |
||||
{ value: 0, name: "运行" }, |
||||
{ value: 0, name: "不运行" }, |
||||
], |
||||
itemStyle: { |
||||
color: function (params) { |
||||
var colorList = ["#2df499", "#08c8ff"]; |
||||
return colorList[params.dataIndex]; |
||||
}, |
||||
// borderWidth: 5, |
||||
borderColor: "#002a56", |
||||
}, |
||||
}, |
||||
{ |
||||
data: [ |
||||
{ value: 0, name: "运行" }, |
||||
{ value: 0, name: "不运行" }, |
||||
], |
||||
}, |
||||
], |
||||
}; |
||||
this.chartInstance.setOption(adapterOption); |
||||
this.chartInstance.resize(); |
||||
} |
||||
}, |
||||
//初始化chartInstance对象-饼图 |
||||
initChart() { |
||||
this.chartInstance = echarts.init(this.$refs.pumpChart_ref); |
||||
this.option = { |
||||
//环形图中间文字 |
||||
title: { |
||||
subtext: this.allData, |
||||
textStyle: { |
||||
color: "#ffffff", |
||||
fontSize: 20, |
||||
}, |
||||
subtextStyle: { |
||||
color: "#ffffff", |
||||
}, |
||||
textAlign: "center", |
||||
x: "28.5%", |
||||
y: "35%", //距离上边的距离 |
||||
}, |
||||
tooltip: { |
||||
trigger: "item", |
||||
formatter: "{a} <br/>{b} : {c} ({d}%)", |
||||
}, |
||||
//图例 |
||||
legend: { |
||||
orient: "vertical", // 垂直分布 |
||||
right: "10%", // 位于最右边 |
||||
top: "center", // 垂直居中 |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffffff", |
||||
// fontSize: 18, |
||||
}, |
||||
}, |
||||
series: [ |
||||
// 数据圆 |
||||
{ |
||||
name: "温度监测:", |
||||
type: "pie", |
||||
radius: ["50%", "62%"], |
||||
center: ["30%", "44%"], |
||||
avoidLabelOverlap: false, |
||||
label: { |
||||
show: false, |
||||
position: "center", |
||||
}, |
||||
labelLine: { |
||||
show: false, |
||||
}, |
||||
itemStyle: { |
||||
color: function (params) { |
||||
var colorList = ["#2df499", "#08c8ff"]; |
||||
return colorList[params.dataIndex]; |
||||
}, |
||||
borderWidth: 5, |
||||
borderColor: "#002a56", |
||||
}, |
||||
z: 10, //设置层级更高,否则会被阴影圆遮住 |
||||
}, |
||||
// 阴影圆 |
||||
{ |
||||
type: "pie", |
||||
radius: ["40%", "52%"], |
||||
center: ["30%", "44%"], |
||||
avoidLabelOverlap: false, |
||||
label: { |
||||
show: false, |
||||
position: "center", |
||||
}, |
||||
silent: true, |
||||
labelLine: { |
||||
show: false, |
||||
}, |
||||
//颜色 |
||||
itemStyle: { |
||||
color: function (colors) { |
||||
var colorList = ["#09596b", "#024e7d"]; |
||||
return colorList[colors.dataIndex]; |
||||
}, |
||||
}, |
||||
z: 15, |
||||
}, |
||||
// 内圈边框 |
||||
{ |
||||
// 颜色 |
||||
color: ["#305376"], |
||||
type: "pie", |
||||
silent: true, //鼠标移入不显示内容,不触发鼠标事件 |
||||
// hoverAnimation: false, //鼠标移入不放大,此属性已被废弃 |
||||
// 使用emphasis.scale 是否开启高亮后扇区的放大效果,默认true |
||||
// 这里开启silent: true, 就达到效果了 |
||||
// center与非内圈一致 |
||||
radius: ["28%", "29%"], |
||||
center: ["30%", "44%"], |
||||
label: { |
||||
show: false, |
||||
}, |
||||
data: [ |
||||
{ |
||||
value: 0, |
||||
name: "", |
||||
itemStyle: {}, |
||||
}, |
||||
], |
||||
}, |
||||
// 最里面渐变小圆 |
||||
{ |
||||
// 颜色 |
||||
type: "pie", |
||||
silent: true, //鼠标移入不显示内容,不触发鼠标事件 |
||||
// hoverAnimation: false, //鼠标移入不放大,此属性已被废弃 |
||||
// 使用emphasis.scale 是否开启高亮后扇区的放大效果,默认true |
||||
// 这里开启silent: true, 就达到效果了 |
||||
// center与非内圈一致 |
||||
radius: ["0%", "29%"], |
||||
center: ["30%", "44%"], |
||||
label: { |
||||
show: false, |
||||
}, |
||||
data: [ |
||||
{ |
||||
value: 0, |
||||
name: "", |
||||
itemStyle: {}, |
||||
}, |
||||
], |
||||
itemStyle: { |
||||
color: { |
||||
type: "linear", |
||||
x: 0, |
||||
y: 0, |
||||
x2: 1, |
||||
y2: 1, |
||||
colorStops: [ |
||||
{ offset: 0, color: "#002a55" }, // 0% 处的颜色 |
||||
{ offset: 1, color: "#0a457a" }, // 100% 处的颜色 |
||||
], |
||||
global: false, // 缺省为 false |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.chartInstance.setOption(this.option, true); |
||||
}, |
||||
handleEnter(index) { |
||||
this.currentIndex = index; |
||||
this.renderingBroken(); |
||||
}, |
||||
//初始化chartInstance2对象 折线图 |
||||
initChart2() { |
||||
this.brokenInstanc = echarts.init(this.$refs.analyse_ref); |
||||
this.brokenOption = { |
||||
tooltip: { |
||||
trigger: "axis", |
||||
}, |
||||
legend: { |
||||
show: false, |
||||
selectedMode: false, // 是否允许图例进行点击 |
||||
icon: "cricle", //图例样式,可以自行查看样式选择 |
||||
//图例文字颜色 |
||||
textStyle: { |
||||
color: "#ffff", |
||||
fontSize: 16, //这里改字体大小 |
||||
}, |
||||
// left: "73%", |
||||
left: "66%", |
||||
top: "0", |
||||
//图例距离饼图的距离 |
||||
itemGap: 5, |
||||
itemWidth: 10, |
||||
itemHeight: 5, |
||||
}, |
||||
|
||||
grid: { |
||||
top: "4%", |
||||
left: "3%", |
||||
right: "4%", |
||||
bottom: "5%", |
||||
containLabel: true, |
||||
}, |
||||
xAxis: { |
||||
type: "category", |
||||
//设置为true代表离零刻度间隔一段距离 |
||||
boundaryGap: true, |
||||
// 修饰刻度标签的颜色即x坐标数据 |
||||
axisLabel: { |
||||
// interval: 0, //强制显示所有x轴数据 |
||||
// rotate: 30, //x轴坐标字体倾斜30度 |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
axisTick: { |
||||
show: false, // 不显示坐标轴刻度线 |
||||
}, |
||||
// x坐标轴的颜色 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", |
||||
}, |
||||
}, |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#e2e6f0", |
||||
}, |
||||
}, //x轴分割线 |
||||
data: this.brokenTime, |
||||
}, |
||||
yAxis: { |
||||
min: 0, |
||||
// max:20, |
||||
// // // min:'dataMin', |
||||
// // // max:'dataMax', |
||||
// name: "kwh", // 第一个 y 轴的单位描述 |
||||
// 设置 name 的样式 |
||||
nameTextStyle: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
fontSize: 12, |
||||
}, |
||||
miniInterval: 5, |
||||
type: "value", |
||||
// 修饰刻度标签的颜色即y坐标数据 |
||||
axisLabel: { |
||||
color: "rgba(255, 255, 255, 1)", |
||||
}, |
||||
// 显示y坐标轴 |
||||
axisLine: { |
||||
show: true, |
||||
lineStyle: { |
||||
color: "#365576", // 设置 y 轴线的颜色 |
||||
}, |
||||
fontSize: 14, // 设置字体大小,可根据需要调整 |
||||
}, |
||||
//y轴分割线段数 |
||||
// splitNumber: 10, |
||||
// 修改y轴分割线的颜色 |
||||
splitLine: { |
||||
lineStyle: { |
||||
color: "#1a3d62", // 设置分割线的颜色 |
||||
type: "dashed", // 设置分割线为虚线 |
||||
}, |
||||
}, |
||||
}, |
||||
series: [ |
||||
{ |
||||
type: "line", |
||||
// 拐点大小 |
||||
symbolSize: 8, |
||||
data: this.brokenData1, |
||||
//折线颜色 |
||||
itemStyle: { |
||||
color: "#d48e17", //折线点的颜色 |
||||
lineStyle: { |
||||
color: "#d48e17", //折线的颜色 |
||||
}, |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
//把配置项给实例对象 |
||||
this.brokenInstanc.setOption(this.brokenOption, true); |
||||
}, |
||||
//折线图自适应 |
||||
screenAdapter2() { |
||||
console.log("没有数据吗", this.brokenData1); |
||||
//自己定义的比较合适的适配大小,2.6 mes_ref是图表盒子 |
||||
const titleFontSize = this.$refs.analyse_ref.offsetWidth / 130; |
||||
const adapterOption = {}; |
||||
//记得重新给配置项给实例对象。只要实例对象.chartInstance不变,option就可以多次配置不同的条件。也可以配置一个dataoption只写需要从后台请求的数据相关 |
||||
this.brokenInstanc.setOption(adapterOption); |
||||
//手动的调用图标对象的resize才能产生效果 |
||||
this.brokenInstanc.resize(); |
||||
}, |
||||
// 获取折线图数据 |
||||
getTableData() { |
||||
this.brokenData1 = [30, 40, 29]; |
||||
this.brokenData2 = [10, 23, 12]; |
||||
this.brokenData3 = [3, 4, 2]; |
||||
this.brokenTime = ["3月", "4月", "5月"]; |
||||
this.renderingBroken(); |
||||
}, |
||||
renderingBroken() { |
||||
if (this.currentIndex === 0) { |
||||
this.brokenOption.series[0].data = this.brokenData1; |
||||
this.brokenOption.series[0].itemStyle.color = "#d48e17"; |
||||
} else if (this.currentIndex === 1) { |
||||
this.brokenOption.series[0].data = this.brokenData2; |
||||
this.brokenOption.series[0].itemStyle.color = "#1ab395"; |
||||
} else if (this.currentIndex === 2) { |
||||
this.brokenOption.series[0].data = this.brokenData3; |
||||
this.brokenOption.series[0].itemStyle.color = "#1f8dee"; |
||||
} |
||||
// 保存当前索引用于闭包 |
||||
const currentIndex = this.currentIndex; |
||||
// 动态设置 tooltip 格式化函数 |
||||
this.brokenOption.tooltip = { |
||||
trigger: "axis", |
||||
formatter: function (params) { |
||||
// 获取当前数据点信息 |
||||
const data = params[0]; |
||||
const month = data.name; |
||||
const value = data.value; |
||||
|
||||
// 根据索引返回不同内容 |
||||
if (currentIndex === 0) { |
||||
return `${month}<br/>用水量: ${value} 吨`; |
||||
} else if (currentIndex === 1) { |
||||
return `${month}<br/>用电量: ${value} 度`; |
||||
} else if (currentIndex === 2) { |
||||
return `${month}<br/>单耗: ${value} 度/吨`; |
||||
} |
||||
}, |
||||
}; |
||||
this.brokenOption.xAxis.data = this.brokenTime; |
||||
this.brokenInstanc.setOption(this.brokenOption); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.overview-top { |
||||
width: 100%; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: stretch; |
||||
justify-content: space-between; |
||||
margin-bottom: 0.2rem; |
||||
.overview-top-left { |
||||
width: 65%; |
||||
.overview-data { |
||||
width: 100%; |
||||
padding: 0.5rem; |
||||
display: flex; |
||||
flex-direction: row; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
.overview-data-li { |
||||
width: 1.8rem; |
||||
height: 1.65rem; |
||||
position: relative; |
||||
.overview-img { |
||||
width: 1.8rem; |
||||
height: 1.65rem; |
||||
position: absolute; |
||||
top: 0; |
||||
} |
||||
.overview-num { |
||||
font-family: DIN-Bold; |
||||
font-size: 0.3rem; |
||||
font-weight: bold; |
||||
font-stretch: normal; |
||||
line-height: 0.5rem; |
||||
letter-spacing: 0px; |
||||
color: #ffffff; |
||||
position: absolute; |
||||
top: 0.28rem; |
||||
right: 0; |
||||
} |
||||
.overview-title { |
||||
font-family: SourceHanSansCN-Regular; |
||||
font-size: 0.18rem; |
||||
font-weight: normal; |
||||
font-stretch: normal; |
||||
line-height: 0.22rem; |
||||
letter-spacing: 0px; |
||||
color: #ffffff; |
||||
position: absolute; |
||||
top: 0.77rem; |
||||
right: 0; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.overview-top-right { |
||||
width: 33%; |
||||
.pump-charts { |
||||
width: 100%; |
||||
height: 2.65rem; |
||||
} |
||||
} |
||||
} |
||||
.overview-bottom { |
||||
.choice { |
||||
margin: 20px; |
||||
.mr20 { |
||||
padding: 0.05rem 0.2rem; |
||||
white-space: nowrap; |
||||
width: auto; |
||||
} |
||||
} |
||||
.brokenEcharts { |
||||
width: 100%; |
||||
height: 4rem; |
||||
} |
||||
} |
||||
</style> |