Commit e8f6a530 authored by 朱超's avatar 朱超

环比更新

parent a1c1918b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<div <div
class="contentBlock" class="contentBlock"
id="contentBlock" id="contentBlock"
v-loading="loading"
element-loading-background="rgba(122, 122, 122, 0.6)" element-loading-background="rgba(122, 122, 122, 0.6)"
> >
<el-card class="card-contianer"> <el-card class="card-contianer">
...@@ -128,7 +129,6 @@ ...@@ -128,7 +129,6 @@
<div v-show="!switchV"> <div v-show="!switchV">
<el-table <el-table
:data="tableData" :data="tableData"
v-loading="tabloading"
:height="tableHeight" :height="tableHeight"
style="width: 100%" style="width: 100%"
empty-text="暂无数据" empty-text="暂无数据"
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
<el-table-column prop="temperature" label="温度(℃)" /> <el-table-column prop="temperature" label="温度(℃)" />
<el-table-column <el-table-column
prop="record" prop="record"
label="耗气量" label="耗气量(Nm³)"
v-if="enertyInfo.energyType == '1'" v-if="enertyInfo.energyType == '1'"
/> />
<el-table-column <el-table-column
...@@ -160,8 +160,11 @@ ...@@ -160,8 +160,11 @@
</el-table> </el-table>
</div> </div>
<div v-show="switchV" id="echartsLayerBlock"> <div v-show="switchV" id="echartsLayerBlock">
<div v-show="nodata">
<div class="echartsLayer" id="echartsLayer"></div> <div class="echartsLayer" id="echartsLayer"></div>
</div> </div>
<div v-show="!nodata"><el-empty description="暂无数据" /></div>
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
...@@ -174,7 +177,7 @@ import { ElMessage } from "element-plus"; ...@@ -174,7 +177,7 @@ import { ElMessage } from "element-plus";
import { saveAs } from "file-saver"; import { saveAs } from "file-saver";
import XLSX from "xlsx-js-style"; import XLSX from "xlsx-js-style";
import { postExternalQOQ, postWithinQOQ } from "../../api/analysis"; import { postExternalQOQ, postWithinQOQ } from "../../api/analysis";
const loading = ref(false);
const tdType = ref(1); const tdType = ref(1);
const networkType = ref(2); const networkType = ref(2);
const enertyInfo = reactive({ const enertyInfo = reactive({
...@@ -192,7 +195,7 @@ const enterpriseId = ref(); ...@@ -192,7 +195,7 @@ const enterpriseId = ref();
const props = { multiple: true, emitPath: false }; const props = { multiple: true, emitPath: false };
const switchV = ref(true); const switchV = ref(true);
const echartF = ref(false); const echartF = ref(false);
const nodata = ref(false); const nodata = ref(true);
let tableData = reactive([]); let tableData = reactive([]);
const echartTitle = reactive(["耗水量趋势图"]); const echartTitle = reactive(["耗水量趋势图"]);
const echartData = reactive([]); const echartData = reactive([]);
...@@ -226,52 +229,114 @@ function getEnterprise() { ...@@ -226,52 +229,114 @@ function getEnterprise() {
} }
function transferIdChange() { function transferIdChange() {
// if (enertyInfo.transferId.length > 10) { if (enertyInfo.transferId.length > 10) {
// ElMessage.error("换热机组最多只能选择10个"); ElMessage.error("换热机组最多只能选择10个");
// } }
} }
function exportTableToExcel() { function exportTableToExcel() {
const worksheet = XLSX.utils.json_to_sheet(tableData); let exlData = [];
const workbook = XLSX.utils.book_new(); let title = [];
XLSX.utils.sheet_add_aoa( tableData.forEach((element) => {
worksheet, let tableArr = {
[["换热站机组名称", "时间", "平均温度", enertyTab.value]], rowId: element.rowId,
{ transferName: element.transferName,
origin: "A1", gatherTime: element.gatherTime.replace("T", " "),
temperature: element.temperature,
record: element.record,
};
exlData.push(tableArr);
});
switch (enertyInfo.energyType) {
case 1:
title = ["序号", "换热站机组名称", "时间", "温度(℃)", "耗气量(Nm³)"];
break;
case 2:
title = ["序号", "换热站机组名称", "时间", "温度(℃)", "耗水量(T)"];
break;
case 3:
title = ["序号", "换热站机组名称", "时间", "温度(℃)", "耗热量(GJ"];
break;
case 4:
title = ["序号", "换热站机组名称", "时间", "温度(℃)", "耗电量(A)"];
break;
} }
);
worksheet["!cols"] = [{ wch: 20 }, { wch: 20 }, { wch: 20 }, { wch: 20 }];
// worksheet["!rows"] = [{ hpx: 20 }];
worksheet["A1"].s = { const ws = XLSX.utils.json_to_sheet(exlData);
fill: { const workbook = XLSX.utils.book_new();
fgColor: { rgb: "0097d5fd" }, const border = {
top: {
style: "thin",
}, },
}; bottom: {
worksheet["B1"].s = { style: "thin",
fill: {
fgColor: { rgb: "0097d5fd" },
}, },
}; left: {
worksheet["C1"].s = { style: "thin",
fill: { },
fgColor: { rgb: "0097d5fd" }, right: {
style: "thin",
}, },
}; };
worksheet["D1"].s = { const range = XLSX.utils.decode_range(ws["!ref"]);
const cellList = Object.keys(ws).filter((item) => item.indexOf("!") < 0);
for (let row = range.s.r; row <= range.e.r; row++) {
for (let col = range.s.c; col <= range.e.c; col++) {
const cell = XLSX.utils.encode_cell({ r: row, c: col });
if (cellList.indexOf(cell) < 0) {
ws[cell] = { t: "", v: "", s: { border } };
} else {
ws[cell].s = { border };
}
}
}
XLSX.utils.sheet_add_aoa(ws, [title], {
origin: "A1",
});
ws["!cols"] = [
{ wch: 5 },
{ wch: 20 },
{ wch: 20 },
{ wch: 20 },
{ wch: 20 },
];
// ws["!rows"] = [{ hpx: 20 }];
const tagList = ["A1", "B1", "C1", "D1", "E1"];
tagList.forEach((key, index) => {
ws[key].s = {
fill: { fill: {
fgColor: { rgb: "0097d5fd" }, fgColor: { rgb: "0097d5fd" },
}, },
border: {
bottom: {
color: "#000000",
style: "thin",
},
left: {
color: "#000000",
style: "thin",
},
right: {
color: "#000000",
style: "thin",
},
top: {
color: "#000000",
style: "thin",
},
},
}; };
});
XLSX.utils.book_append_sheet(workbook, worksheet, "换热站趋势"); XLSX.utils.book_append_sheet(workbook, ws, "用量环比");
const excelBuffer = XLSX.write(workbook, { bookType: "xlsx", type: "array" }); const excelBuffer = XLSX.write(workbook, { bookType: "xlsx", type: "array" });
const dataBlob = new Blob([excelBuffer], { const dataBlob = new Blob([excelBuffer], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8", type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
}); });
const downloadUrl = URL.createObjectURL(dataBlob); const downloadUrl = URL.createObjectURL(dataBlob);
saveAs(dataBlob, "tableData.xlsx"); saveAs(dataBlob, "用量环比.xlsx");
ElMessage.success("导出成功!请稍后。。。"); ElMessage.success("导出成功!请稍后。。。");
} }
...@@ -350,7 +415,9 @@ function selTypeChange() { ...@@ -350,7 +415,9 @@ function selTypeChange() {
//换热站机组能耗数据接口(用量环比) //换热站机组能耗数据接口(用量环比)
function postExternalQOQFun() { function postExternalQOQFun() {
tabloading.value = true; loading.value = true;
echarts.dispose(document.getElementById("echartsLayer"));
tableData.length = 0;
switch (enertyInfo.energyType) { switch (enertyInfo.energyType) {
case 1: case 1:
company.value = "Nm³"; company.value = "Nm³";
...@@ -382,25 +449,29 @@ function postExternalQOQFun() { ...@@ -382,25 +449,29 @@ function postExternalQOQFun() {
postExternalQOQ(params).then((res) => { postExternalQOQ(params).then((res) => {
echarts.dispose(document.getElementById("echartsLayer")); echarts.dispose(document.getElementById("echartsLayer"));
if (res.success === true) { if (res.success === true) {
if (res.data.hourWater.length >0) { if (res.data.hourWater.length > 0) {
pageInitFun(res); pageInitFun(res);
tableData = res.data.hourWater; } else {
nodata.value = false;
} }
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.message);
} }
loading.value = false;
}); });
} else { } else {
postWithinQOQ(params).then((res) => { postWithinQOQ(params).then((res) => {
echarts.dispose(document.getElementById("echartsLayer")); echarts.dispose(document.getElementById("echartsLayer"));
if (res.success === true) { if (res.success === true) {
if (res.data.data.length >0) { if (res.data.data.length > 0) {
pageInitFun(res); pageInitFun(res);
tableData = res.data.hourWater; } else {
nodata.value = false;
} }
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.message);
} }
loading.value = false;
}); });
} }
} }
...@@ -411,26 +482,28 @@ function clearData() { ...@@ -411,26 +482,28 @@ function clearData() {
echartDataLegend.length = 0; echartDataLegend.length = 0;
echartDataTime.length = 0; echartDataTime.length = 0;
tableData.length = 0; tableData.length = 0;
tabloading.value = false;
} }
function pageInitFun(res) { function pageInitFun(res) {
tableData.length = 0; tableData.length = 0;
res.data.hourWater.forEach((element) => { // res.data.hourWater.forEach((element) => {
let tableArr = { // let tableArr = {
transferName: element.transferName, // transferName: element.transferName,
gatherTime: element.gatherTime, // gatherTime: element.gatherTime.replace("T"," "),
temperature: element.temperature, // temperature: element.temperature,
uc: parseFloat(element.uc).toFixed(2), // uc: parseFloat(element.uc).toFixed(2),
}; // };
tableData.push(tableArr); // tableData.push(tableArr);
}); // });
nodata.value = true; nodata.value = false;
tabloading.value = false; tabloading.value = false;
echartData.length = 0; echartData.length = 0;
echartSeries.length = 0; echartSeries.length = 0;
echartDataLegend.length = 0; echartDataLegend.length = 0;
echartDataTime.length = 0; echartDataTime.length = 0;
if (res.data.hourWater.length > 0) {
tableData = res.data.hourWater;
nodata.value = true;
echartData.value = dataDeal(res.data.hourWater); echartData.value = dataDeal(res.data.hourWater);
echartData.value[0].listInfo.forEach((element) => { echartData.value[0].listInfo.forEach((element) => {
if (element.gatherTime) { if (element.gatherTime) {
...@@ -488,6 +561,7 @@ function pageInitFun(res) { ...@@ -488,6 +561,7 @@ function pageInitFun(res) {
echartDataLegend.push(element.name); echartDataLegend.push(element.name);
}); });
echartInit(); echartInit();
}
} }
function setContentHeight() { function setContentHeight() {
...@@ -615,13 +689,13 @@ function echartInit() { ...@@ -615,13 +689,13 @@ function echartInit() {
} }
function changeFun() { function changeFun() {
tabloading.value = false; if (nodata.value) {
nodata.value = true;
var divWidth = document.getElementById("contentBlock").offsetWidth; var divWidth = document.getElementById("contentBlock").offsetWidth;
var divHeight = document.getElementById("contentBlock").scrollHeight; var divHeight = document.getElementById("contentBlock").scrollHeight;
computedWidth.value = divWidth + "px"; computedWidth.value = divWidth + "px";
computedHeight.value = divHeight * 0.75 + "px"; computedHeight.value = divHeight * 0.75 + "px";
echartInit(); echartInit();
}
} }
onMounted(() => { onMounted(() => {
...@@ -630,6 +704,7 @@ onMounted(() => { ...@@ -630,6 +704,7 @@ onMounted(() => {
getSupplys(); getSupplys();
postExternalQOQFun(); postExternalQOQFun();
changeFun(); changeFun();
switchV.value = true;
window.addEventListener("resize", function () { window.addEventListener("resize", function () {
location.reload(); location.reload();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment