feat:修改电量报表 按时间段查询

This commit is contained in:
zty 2024-12-13 15:29:53 +08:00
parent a56d5cbf82
commit c336a6ef1e
2 changed files with 94 additions and 23 deletions

View File

@ -1026,12 +1026,12 @@ const routes = [
component: "enm_energy/hour_base",
},
{
name: "hourBase",
name: "hourBaseTotal",
path: "/enm_energy/electric_total",
meta: {
title: "电量报表",
// icon: "el-icon-grid",
perms: ["hour_base"],
perms: ["hour_base_elec"],
},
component: "enm_energy/electric_total",
},

View File

@ -3,6 +3,19 @@
<div class="app-container" id="app-container" style="height: 100%">
<el-header id="app-header">
<div class="left-panel">
<el-select
v-model="query.type"
placeholder="查询类型"
clearable
class="headerSearch"
>
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
<el-date-picker
v-model="query.day"
type="date"
@ -10,7 +23,21 @@
format="YYYY-MM-DD"
placeholder="日"
style="margin-right: 6px"
@change="dateChange"
v-if = "query.type == 0"
@change="dateChange"
/>
<el-date-picker
v-model="daterange"
type="datetimerange"
:shortcuts="shortcuts"
range-separator="To"
start-placeholder="Start date"
end-placeholder="End date"
placeholder="时间范围"
value-format="YYYY-MM-DD hh:mm:ss"
v-if="query.type==1"
style="margin-right: 6px"
@change="changeDate"
/>
<!-- <el-button
type="primary"
@ -33,6 +60,7 @@
<div ref="print" id="myReport" class="printContainer">
<el-table
id="hourBaseTable"
v-if="query.type==0"
:data="tableDatas2"
style="width: 100%"
border
@ -58,6 +86,34 @@
<el-table-column label="年累计" prop="year" align="center" fixed>
</el-table-column>
</el-table>
<el-table
v-if="query.type==1"
id="hourBaseTable"
:data="tableDatas_range"
style="width: 100%"
border
:height="tableHeight"
@cell-click="handleCellClick_range"
>
<el-table-column
label="设备名称"
prop="mpoint__name"
fixed
align="center"
>
</el-table-column>
<el-table-column
label="对应点位"
prop="mpoint__code"
fixed
align="center"
></el-table-column><el-table-column
label="统计值(kwh)"
prop="total_val"
fixed
align="center"
></el-table-column>
</el-table>
</div>
</div>
</el-card>
@ -98,7 +154,13 @@ export default {
indexList: [],
mpointList: [],
tableDatas: [],
daterange: [],
tableDatas2: [],
tableDatas_range:[],
options: [
{id:0,name:'日统计'},
{id:1,name:'时间范围'},
],
tableHeight: 600,
itemChartTitle: "",
itemChartData: [],
@ -198,6 +260,8 @@ export default {
xAxisData: [],
xAxisData_day: [],
xAxisData_month: [],
mpointIdList: [],
result: ""
};
},
mounted() {
@ -210,6 +274,7 @@ export default {
that.headerLength = that.days + 4;
that.tableWidth = that.headerLength * 100 + "";
this.getMPoints();
let heightContainer =
document.getElementById("app-container").clientHeight;
let heightHeader = document.getElementById("app-header").clientHeight;
@ -217,28 +282,13 @@ export default {
that.tableHeight = heightTable;
},
methods: {
// objectSpanMethod({ row, column, rowIndex, columnIndex }) {
// let that = this;
// if (columnIndex == 0) {
// if (that.indexList.indexOf(rowIndex) > -1) {
// let rowspans = that.mgroupObj[row.mgroupName];
// return {
// rowspan: rowspans,
// colspan: 1,
// };
// } else {
// return {
// rowspan: 1,
// colspan: 0,
// };
// }
// }
// },
dateChange(e) {
let that = this;
that.tableDatas = [];
let arr = [];
if(e){//
let obj = {};
if (that.queryset.type == 0) {
arr = e.split('-');
that.year = Number(arr[0]);
that.month = Number(arr[1]);
@ -248,6 +298,27 @@ export default {
let nowDate = new Date();
that.timeStamp = nowDate.getTime();
},
formatArry(){
this.result = this.mpointIdList.join(","); //
},
changeDate(){
let that = this;
let obj = {};
obj.type = "hour";
obj.start_time = this.daterange[0];
obj.end_time = this.daterange[1];
this.formatArry();
obj.mpoint__in = that.result;
obj.group_by = "mpoint__code";
obj.page = 0;
this.$API.enm.mpointstat.groupValues.req(obj).then((res) => {
//res total_val
res.forEach(item => {
item.total_val = Number(item.total_val).toFixed(2);
});
this.tableDatas_range = res;
});
},
getMPoints() {
let that = this;
that.$API.enm.mpoint.list
@ -261,6 +332,8 @@ export default {
})
.then((res) => {
that.mpointList = res.filter((item) => {
// mpointIdList
that.mpointIdList.push(item.id);
return item.report_sortstr !== "";
});
that.dataLoop();
@ -271,7 +344,6 @@ export default {
that.tableDatas2 = [];
that.mpointList.forEach((item, index) => {
let obj = {};
console.log('item', item.name)
obj.name = item.name;
obj.code =
item.code != null && item.code != ""
@ -318,7 +390,6 @@ export default {
that.tableDatas2[index]['year'] = item.val;
});
});
console.log('that.tableDatas2', that.tableDatas2)
},
// handleCellClick(row, column, cell, event) {