fix:报表合计行

This commit is contained in:
shijing 2024-05-15 09:51:11 +08:00
parent 224d4e37a8
commit b73f62b4d2
3 changed files with 23 additions and 398 deletions

View File

@ -108,7 +108,9 @@
>
{{ item[2 + day] }}
</td>
<td class="numCell">{{ item[headerLength] }}</td>
<td class="numCell">
{{ item[headerLength - 1] }}
</td>
</tr>
</table>
</div>
@ -317,211 +319,21 @@ export default {
obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => {
console.log(res);
let sum = 0;
res.forEach((item) => {
let ind = item.day + 2;
that.tableDatas[index][ind] = item.val;
sum += Number(item.val);
});
sum = sum * 100;
sum = Math.round(sum);
sum = sum / 100;
let dayss = 0;
dayss = this.days + 3;
that.tableDatas[index][dayss] = sum.toFixed(2);
that.$forceUpdate();
});
},
// getData() {
// let that = this;
// function dataPush(name) {
// let index = 0;
// if (name == "") {
// index = 0;
// } else if (name == "") {
// index = 1;
// } else if (name == "") {
// index = 2;
// } else if (name == "") {
// index = 4;
// } else if (name == "") {
// index = 6;
// } else if (name == "") {
// index = 7;
// } else if (name == "") {
// index = 9;
// } else if (name == "") {
// index = 10;
// } else if (name == "") {
// index = 11;
// } else if (name == "") {
// index = 14;
// } else if (name == "") {
// index = 15;
// } else if (name == "") {
// index = 16;
// } else if (name == "") {
// index = 18;
// } else if (name == "") {
// index = 19;
// } else if (name == "1#") {
// index = 21;
// } else if (name == "2#") {
// index = 22;
// } else if (name == "3#") {
// index = 23;
// } else if (name == "4#") {
// index = 24;
// } else if (name == "") {
// index = 26;
// }
// return index;
// }
// function sumNum(a, b, c, d) {
// let sum = 0;
// if (typeof a !== "undefined" && a !== "NaN") {
// sum = sum + Number(a);
// }
// if (typeof b !== "undefined" && a !== "NaN") {
// sum = sum + Number(b);
// }
// if (typeof c !== "undefined" && a !== "NaN") {
// sum = sum + Number(c);
// }
// if (typeof d !== "undefined" && a !== "NaN") {
// sum = sum + Number(d);
// }
// return sum;
// }
// let obj = {};
// obj.type = "day_s";
// obj.year_s = that.year;
// obj.month_s = that.month;
// obj.page = 0;
// obj.mpoint__ep_monitored__power_kw__gte = 100;
// this.$API.enm.mpoint.stat
// .req(obj)
// .then((res) => {
// let wrapArr = [],
// innerArr = [];
// res.forEach((item) => {
// let day = item.day_s;
// if (wrapArr[day]) {
// wrapArr[day].push(item);
// } else {
// wrapArr[day] = [];
// wrapArr[day].push(item);
// }
// });
// wrapArr.forEach((inner, inde) => {
// inner.forEach((item) => {
// let i = dataPush(item.mpoint_name);
// let k = 0;
// if (
// i == 0 ||
// i == 4 ||
// i == 9 ||
// i == 14 ||
// i == 18 ||
// i == 21 ||
// i == 26 ||
// i == 27 ||
// i == 28
// ) {
// k = 3 + inde;
// } else {
// k = 2 + inde;
// }
// that.tableDatas[i][k] = item.val;
// });
// });
// for (let k = 0; k < that.headerLength; k++) {
// let m = k + 3;
// let n = k + 1;
// //
// that.tableDatas[3][m] = sumNum(
// that.tableDatas[0][m],
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[5][m] = sumNum();
// //
// that.tableDatas[8][m] =
// sumNum(
// that.tableDatas[4][m],
// // that.tableDatas[5][m],
// that.tableDatas[6][m],
// that.tableDatas[7][m]
// ) -
// sumNum(
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[12][m] = sumNum(
// // that.tableDatas[9][m],
// // that.tableDatas[10][m],
// // that.tableDatas[11][m]
// // );
// //
// that.tableDatas[13][m] =
// typeof that.tableDatas[12][m] !== "undefined"
// ? sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m],
// that.tableDatas[12][m]
// )
// : sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
// //
// let sum17 = sumNum(
// that.tableDatas[14][m],
// that.tableDatas[15][m],
// that.tableDatas[16][m]
// );
// that.tableDatas[17][m] =
// typeof that.tableDatas[21][m] !== "undefined"
// ? sum17 - that.tableDatas[21][m]
// : sum17;
// //
// that.tableDatas[20][m] =
// typeof that.tableDatas[19][m] !== "undefined"
// ? that.tableDatas[18][m] -
// that.tableDatas[19][m]
// : that.tableDatas[18][m];
// //
// that.tableDatas[25][m] = sumNum(
// that.tableDatas[21][m],
// that.tableDatas[22][m],
// that.tableDatas[23][m],
// that.tableDatas[24][m]
// );
// //
// that.tableDatas[27][m] = sumNum(
// that.tableDatas[3][m],
// that.tableDatas[8][m],
// that.tableDatas[13][m],
// that.tableDatas[17][m],
// that.tableDatas[18][m],
// that.tableDatas[25][m],
// that.tableDatas[26][m]
// );
// //
// // that.tableDatas[28][m] = sumNum(
// // that.tableDatas[27][m],
// // that.tableDatas[26][m]
// // );
// }
// that.tableDatas.forEach((inner, inde) => {
// let sumlast = 0;
// inner.forEach((num, ind) => {
// if (ind > 2 && ind < that.headerLength) {
// sumlast = sumlast + Number(num);
// }
// });
// inner[that.headerLength] = sumlast;
// });
// })
// .then(() => {});
// },
itemClick(item, index) {
let that = this;
let lineData = that.tableDatas[index].slice(3, that.headerLength);

View File

@ -384,212 +384,19 @@ export default {
obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => {
console.log(res);
let sum = 0;
res.forEach((item) => {
let ind = item.hour + 3;
that.tableDatas[index][ind] = item.val;
sum += Number(item.val);
});
sum = sum * 100;
sum = Math.round(sum);
sum = sum / 100;
that.tableDatas[index][27] = sum.toFixed(2);
that.$forceUpdate();
});
},
// getData(id) {
// let that = this;
// function dataPush(name) {
// let index = 0;
// if (name == "") {
// index = 0;
// } else if (name == "") {
// index = 1;
// } else if (name == "") {
// index = 2;
// } else if (name == "") {
// index = 4;
// } else if (name == "") {
// index = 6;
// } else if (name == "") {
// index = 7;
// } else if (name == "") {
// index = 9;
// } else if (name == "") {
// index = 10;
// } else if (name == "") {
// index = 11;
// } else if (name == "") {
// index = 14;
// } else if (name == "") {
// index = 15;
// } else if (name == "") {
// index = 16;
// } else if (name == "") {
// index = 18;
// } else if (name == "") {
// index = 19;
// } else if (name == "1#") {
// index = 21;
// } else if (name == "2#") {
// index = 22;
// } else if (name == "3#") {
// index = 23;
// } else if (name == "4#") {
// index = 24;
// } else if (name == "") {
// index = 26;
// }
// return index;
// }
// function sumNum(a, b, c, d) {
// let sum = 0;
// if (typeof a !== "undefined" && a !== "NaN") {
// sum = sum + Number(a);
// }
// if (typeof b !== "undefined" && a !== "NaN") {
// sum = sum + Number(b);
// }
// if (typeof c !== "undefined" && a !== "NaN") {
// sum = sum + Number(c);
// }
// if (typeof d !== "undefined" && a !== "NaN") {
// sum = sum + Number(d);
// }
// return sum;
// }
// let obj = {};
// obj.type = "hour_s";
// obj.year_s = that.year;
// obj.month_s = that.month;
// obj.day_s = that.day;
// obj.page = 0;
// obj.mpoint__ep_monitored__power_kw__gte = 100;
// this.$API.enm.mpoint.stat
// .req(obj)
// .then((res) => {
// let wrapArr = [],
// innerArr = [];
// res.forEach((item) => {
// let hour = item.hour;
// if (wrapArr[hour]) {
// wrapArr[hour].push(item);
// } else {
// wrapArr[hour] = [];
// wrapArr[hour].push(item);
// }
// });
// wrapArr.forEach((inner, inde) => {
// inner.forEach((item) => {
// let i = dataPush(item.mpoint_name);
// let k = 0;
// if (
// i == 0 ||
// i == 4 ||
// i == 9 ||
// i == 14 ||
// i == 18 ||
// i == 21 ||
// i == 26 ||
// i == 27 ||
// i == 28
// ) {
// k = 3 + inde;
// } else {
// k = 2 + inde;
// }
// that.tableDatas[i][k] = item.val;
// });
// });
// for (let k = 0; k < 24; k++) {
// let m = k + 3;
// let n = k + 1;
// //
// that.tableDatas[3][m] = sumNum(
// that.tableDatas[0][m],
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[5][m] = sumNum();
// //
// that.tableDatas[8][m] =
// sumNum(
// that.tableDatas[4][m],
// // that.tableDatas[5][m],
// that.tableDatas[6][m],
// that.tableDatas[7][m]
// ) -
// sumNum(
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[12][m] = sumNum(
// // that.tableDatas[9][m],
// // that.tableDatas[10][m],
// // that.tableDatas[11][m]
// // );
// //
// that.tableDatas[13][m] =
// typeof that.tableDatas[12][m] !== "undefined"
// ? sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m],
// that.tableDatas[12][m]
// )
// : sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
// //
// let sum17 = sumNum(
// that.tableDatas[14][m],
// that.tableDatas[15][m],
// that.tableDatas[16][m]
// );
// that.tableDatas[17][m] =
// typeof that.tableDatas[21][m] !== "undefined"
// ? sum17 - that.tableDatas[21][m]
// : sum17;
// //
// that.tableDatas[20][m] =
// typeof that.tableDatas[19][m] !== "undefined"
// ? that.tableDatas[18][m] -
// that.tableDatas[19][m]
// : that.tableDatas[18][m];
// //
// that.tableDatas[25][m] = sumNum(
// that.tableDatas[21][m],
// that.tableDatas[22][m],
// that.tableDatas[23][m],
// that.tableDatas[24][m]
// );
// //
// that.tableDatas[27][m] = sumNum(
// that.tableDatas[3][m],
// that.tableDatas[8][m],
// that.tableDatas[13][m],
// that.tableDatas[17][m],
// that.tableDatas[18][m],
// that.tableDatas[25][m],
// that.tableDatas[26][m]
// );
// //
// // that.tableDatas[28][m] = sumNum(
// // that.tableDatas[27][m],
// // that.tableDatas[26][m]
// // );
// }
// that.tableDatas.forEach((inner, inde) => {
// let sum27 = 0;
// inner.forEach((num, ind) => {
// if (ind > 2 && ind < 27) {
// sum27 = sum27 + Number(num);
// }
// });
// inner[27] = sum27;
// });
// })
// .then(() => {});
// },
getHourData() {
let that = this;
let m = 0;

View File

@ -302,10 +302,16 @@ export default {
obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => {
console.log(res);
let sum = 0;
res.forEach((item) => {
let ind = item.month + 2;
that.tableDatas[index][ind] = item.val;
sum += Number(item.val);
});
sum = sum * 100;
sum = Math.round(sum);
sum = sum / 100;
that.tableDatas[index][15] = sum.toFixed(2);
that.$forceUpdate();
});
},