From 9ab7e759dd16e01559d3fdb97a9f059ca5851343 Mon Sep 17 00:00:00 2001 From: shijing Date: Wed, 7 Aug 2024 09:04:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=B0=8F=E6=97=B6=E6=95=B0hour=5Fs?= =?UTF-8?q?=E4=BC=A0=E5=8F=82=E6=8D=A2=E6=88=90=E5=AE=9E=E9=99=85=E6=97=B6?= =?UTF-8?q?=E9=97=B4year=E3=80=81month=E3=80=81day=E3=80=81hour;=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E6=95=B0=E6=8D=AE=E9=80=9A=E8=BF=87=E6=B5=8B=E7=82=B9?= =?UTF-8?q?=E7=9A=84mpoint=5Fname=E8=BF=9B=E8=A1=8C=E6=95=B4=E5=90=88?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/enm_coal/power.vue | 59 ++++++++++++++++-------------------- src/views/enm_kiln/power.vue | 57 ++++++++++++++++------------------ src/views/enm_mill/power.vue | 59 ++++++++++++++++-------------------- src/views/enm_rm/power.vue | 57 ++++++++++++++++------------------ src/views/enm_slag/power.vue | 55 ++++++++++++++------------------- 5 files changed, 126 insertions(+), 161 deletions(-) diff --git a/src/views/enm_coal/power.vue b/src/views/enm_coal/power.vue index 7cf412a7..2cfa1b47 100644 --- a/src/views/enm_coal/power.vue +++ b/src/views/enm_coal/power.vue @@ -377,7 +377,7 @@ export default { console.log("mpoints", res); let arr = []; res.forEach((item) => { - arr.push(item.nickname); + arr.push(item.name); }); console.log("arr", arr); that.mpoints = arr; @@ -406,6 +406,7 @@ export default { getTableHourData() { let that = this; that.tableDatas = []; + let nowDate = new Date(); let timeDate = new Date().getTime(); let hourTime = timeDate - 3600000; let hourDate = new Date(hourTime); @@ -413,15 +414,6 @@ export default { let month_h = hourDate.getMonth() + 1; let days_h = hourDate.getDate(); let hours_h = hourDate.getHours(); - let minutes = hourDate.getMinutes(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; - if (hours_h > 5) { - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } else { - hours_h = hours_h - 1; - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } let obj = {}; obj.type = "hour_s"; obj.year = year_h; @@ -436,11 +428,10 @@ export default { .req(obj) .then((res) => { that.tableData = res; - console.log("getTableHourData", res); res.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); + let index = that.mpoints.indexOf(item.mpoint_name); let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[3] = item.elec_consume_unit; @@ -449,18 +440,21 @@ export default { obj[6] = item.mpoint; that.tableDatas[index] = obj; }); - let yetTime = timeDate - 3600000 * 24; - let ystDate = new Date(yetTime); - let year_h = ystDate.getFullYear(); - let month_h = ystDate.getMonth() + 1; - let days_h = ystDate.getDate(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; + let ystDate = null; + if(hours_h>21){//传入今天的日期 + ystDate = nowDate; + }else{//传入昨天的日期 + let yetTime = timeDate - 3600000 * 24; + ystDate = new Date(yetTime); + } + let year_d = ystDate.getFullYear(); + let month_d = ystDate.getMonth() + 1; + let days_d = ystDate.getDate(); let obj_d = {}; obj_d.type = "day_s"; - obj_d.year_s = year_h; - obj_d.month_s = month_h; - obj_d.day_s = days_h; + obj_d.year_s = year_d; + obj_d.month_s = month_d; + obj_d.day_s = days_d; obj_d.mgroup__name = "煤磨"; obj_d.mpoint__material__code__in = "elec,elec_0"; obj_d.mpoint__need_display = 1; @@ -469,14 +463,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_d = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_d]) { - that.tableDatas[index_d][3] = + that.tableDatas[index_d][4] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[4] = item.elec_consume_unit; @@ -496,14 +490,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_m = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_m]) { - that.tableDatas[index_m][4] = + that.tableDatas[index_m][5] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[5] = item.elec_consume_unit; @@ -514,7 +508,6 @@ export default { }); }); }) - .then(() => {}); }, //获取小时数据 getHourData(year, month, days) { @@ -536,7 +529,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.hour; //xAxis seriesData[index][ind] = item.elec_consume_unit; }); @@ -577,7 +570,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.day_s - 1; seriesData[index][ind] = item.elec_consume_unit; }); @@ -619,7 +612,7 @@ export default { let data = response; data.forEach((item) => { let ind = item.month_s - 1; - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint seriesData[index][ind] = item.elec_consume_unit; }); let options = { ...that.option3 }; diff --git a/src/views/enm_kiln/power.vue b/src/views/enm_kiln/power.vue index d0345584..da6ada11 100644 --- a/src/views/enm_kiln/power.vue +++ b/src/views/enm_kiln/power.vue @@ -492,7 +492,7 @@ export default { console.log("mpoints", res); let arr = []; res.forEach((item) => { - arr.push(item.nickname); + arr.push(item.name); }); console.log("arr", arr); that.mpoints = arr; @@ -521,6 +521,7 @@ export default { getTableHourData() { let that = this; that.tableDatas = []; + let nowDate = new Date(); let timeDate = new Date().getTime(); let hourTime = timeDate - 3600000; let hourDate = new Date(hourTime); @@ -528,15 +529,6 @@ export default { let month_h = hourDate.getMonth() + 1; let days_h = hourDate.getDate(); let hours_h = hourDate.getHours(); - let minutes = hourDate.getMinutes(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; - if (hours_h > 5) { - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } else { - hours_h = hours_h - 1; - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } let obj = {}; obj.type = "hour_s"; obj.year = year_h; @@ -553,9 +545,9 @@ export default { that.tableData = res; console.log("getTableHourData", res); res.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); + let index = that.mpoints.indexOf(item.mpoint_name); let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[3] = item.elec_consume_unit; @@ -564,18 +556,21 @@ export default { obj[6] = item.mpoint; that.tableDatas[index] = obj; }); - let yetTime = timeDate - 3600000 * 24; - let ystDate = new Date(yetTime); - let year_h = ystDate.getFullYear(); - let month_h = ystDate.getMonth() + 1; - let days_h = ystDate.getDate(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; + let ystDate = null; + if(hours_h>21){//传入今天的日期 + ystDate = nowDate; + }else{//传入昨天的日期 + let yetTime = timeDate - 3600000 * 24; + ystDate = new Date(yetTime); + } + let year_d = ystDate.getFullYear(); + let month_d = ystDate.getMonth() + 1; + let days_d = ystDate.getDate(); let obj_d = {}; obj_d.type = "day_s"; - obj_d.year_s = year_h; - obj_d.month_s = month_h; - obj_d.day_s = days_h; + obj_d.year_s = year_d; + obj_d.month_s = month_d; + obj_d.day_s = days_d; obj_d.mgroup__name = "回转窑"; obj_d.mpoint__material__code__in = "elec,elec_0"; obj_d.mpoint__need_display = 1; @@ -584,14 +579,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_d = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_d]) { - that.tableDatas[index_d][3] = + that.tableDatas[index_d][4] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[4] = item.elec_consume_unit; @@ -611,14 +606,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_m = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_m]) { - that.tableDatas[index_m][4] = + that.tableDatas[index_m][5] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[5] = item.elec_consume_unit; @@ -651,7 +646,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.hour; //xAxis seriesData[index][ind] = item.elec_consume_unit; }); @@ -692,7 +687,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.day_s - 1; seriesData[index][ind] = item.elec_consume_unit; }); @@ -734,7 +729,7 @@ export default { let data = response; data.forEach((item) => { let ind = item.month_s - 1; - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint seriesData[index][ind] = item.elec_consume_unit; }); let options = { ...that.option3 }; diff --git a/src/views/enm_mill/power.vue b/src/views/enm_mill/power.vue index 3e7ac7e0..0e8299dc 100644 --- a/src/views/enm_mill/power.vue +++ b/src/views/enm_mill/power.vue @@ -449,7 +449,7 @@ export default { console.log("mpoints", res); let arr = []; res.forEach((item) => { - arr.push(item.nickname); + arr.push(item.name); }); console.log("arr", arr); that.mpoints = arr; @@ -478,6 +478,7 @@ export default { getTableHourData() { let that = this; that.tableDatas = []; + let nowDate = new Date(); let timeDate = new Date().getTime(); let hourTime = timeDate - 3600000; let hourDate = new Date(hourTime); @@ -485,15 +486,6 @@ export default { let month_h = hourDate.getMonth() + 1; let days_h = hourDate.getDate(); let hours_h = hourDate.getHours(); - let minutes = hourDate.getMinutes(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; - if (hours_h > 5) { - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } else { - hours_h = hours_h - 1; - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } let obj = {}; obj.type = "hour_s"; obj.year = year_h; @@ -510,29 +502,30 @@ export default { that.tableData = res; console.log("getTableHourData", res); res.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); + let index = that.mpoints.indexOf(item.mpoint_name); let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[3] = item.elec_consume_unit; - obj[4] = 0; - obj[5] = 0; obj[6] = item.mpoint; that.tableDatas[index] = obj; }); - let yetTime = timeDate - 3600000 * 24; - let ystDate = new Date(yetTime); - let year_h = ystDate.getFullYear(); - let month_h = ystDate.getMonth() + 1; - let days_h = ystDate.getDate(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; + let ystDate = null; + if(hours_h>21){//传入今天的日期 + ystDate = nowDate; + }else{//传入昨天的日期 + let yetTime = timeDate - 3600000 * 24; + ystDate = new Date(yetTime); + } + let year_d = ystDate.getFullYear(); + let month_d = ystDate.getMonth() + 1; + let days_d = ystDate.getDate(); let obj_d = {}; obj_d.type = "day_s"; - obj_d.year_s = year_h; - obj_d.month_s = month_h; - obj_d.day_s = days_h; + obj_d.year_s = year_d; + obj_d.month_s = month_d; + obj_d.day_s = days_d; obj_d.mgroup__name = "水泥磨"; obj_d.mpoint__material__code__in = "elec,elec_0"; obj_d.mpoint__need_display = 1; @@ -541,14 +534,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_d = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_d]) { - that.tableDatas[index_d][3] = + that.tableDatas[index_d][4] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[4] = item.elec_consume_unit; @@ -568,14 +561,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_m = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_m]) { - that.tableDatas[index_m][4] = + that.tableDatas[index_m][5] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[5] = item.elec_consume_unit; @@ -608,7 +601,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.hour; //xAxis seriesData[index][ind] = item.elec_consume_unit; }); @@ -649,7 +642,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.day_s - 1; seriesData[index][ind] = item.elec_consume_unit; }); @@ -691,7 +684,7 @@ export default { let data = response; data.forEach((item) => { let ind = item.month_s - 1; - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint seriesData[index][ind] = item.elec_consume_unit; }); let options = { ...that.option3 }; diff --git a/src/views/enm_rm/power.vue b/src/views/enm_rm/power.vue index 59535506..5d480fff 100644 --- a/src/views/enm_rm/power.vue +++ b/src/views/enm_rm/power.vue @@ -426,7 +426,7 @@ export default { console.log("mpoints", res); let arr = []; res.forEach((item) => { - arr.push(item.nickname); + arr.push(item.name); }); console.log("arr", arr); that.mpoints = arr; @@ -455,6 +455,7 @@ export default { getTableHourData() { let that = this; that.tableDatas = []; + let nowDate = new Date(); let timeDate = new Date().getTime(); let hourTime = timeDate - 3600000; let hourDate = new Date(hourTime); @@ -462,15 +463,6 @@ export default { let month_h = hourDate.getMonth() + 1; let days_h = hourDate.getDate(); let hours_h = hourDate.getHours(); - let minutes = hourDate.getMinutes(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; - if (hours_h > 5) { - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } else { - hours_h = hours_h - 1; - hours_h = hours_h > 9 ? hours_h : "0" + hours_h; - } let obj = {}; obj.type = "hour_s"; obj.year = year_h; @@ -487,9 +479,9 @@ export default { that.tableData = res; console.log("getTableHourData", res); res.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); + let index = that.mpoints.indexOf(item.mpoint_name); let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[3] = item.elec_consume_unit; @@ -498,18 +490,21 @@ export default { obj[6] = item.mpoint; that.tableDatas[index] = obj; }); - let yetTime = timeDate - 3600000 * 24; - let ystDate = new Date(yetTime); - let year_h = ystDate.getFullYear(); - let month_h = ystDate.getMonth() + 1; - let days_h = ystDate.getDate(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; + let ystDate = null; + if(hours_h>21){//传入今天的日期 + ystDate = nowDate; + }else{//传入昨天的日期 + let yetTime = timeDate - 3600000 * 24; + ystDate = new Date(yetTime); + } + let year_d = ystDate.getFullYear(); + let month_d = ystDate.getMonth() + 1; + let days_d = ystDate.getDate(); let obj_d = {}; obj_d.type = "day_s"; - obj_d.year_s = year_h; - obj_d.month_s = month_h; - obj_d.day_s = days_h; + obj_d.year_s = year_d; + obj_d.month_s = month_d; + obj_d.day_s = days_d; obj_d.mgroup__name = "原料磨"; obj_d.mpoint__material__code__in = "elec,elec_0"; obj_d.mpoint__need_display = 1; @@ -518,14 +513,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_d = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_d]) { - that.tableDatas[index_d][3] = + that.tableDatas[index_d][4] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[4] = item.elec_consume_unit; @@ -545,14 +540,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_m = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_m]) { - that.tableDatas[index_m][4] = + that.tableDatas[index_m][5] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[5] = item.elec_consume_unit; @@ -585,7 +580,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.hour; //xAxis seriesData[index][ind] = item.elec_consume_unit; }); @@ -626,7 +621,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.day_s - 1; seriesData[index][ind] = item.elec_consume_unit; }); @@ -668,7 +663,7 @@ export default { let data = response; data.forEach((item) => { let ind = item.month_s - 1; - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint seriesData[index][ind] = item.elec_consume_unit; }); let options = { ...that.option3 }; diff --git a/src/views/enm_slag/power.vue b/src/views/enm_slag/power.vue index 89be1dd6..9512be7e 100644 --- a/src/views/enm_slag/power.vue +++ b/src/views/enm_slag/power.vue @@ -280,22 +280,6 @@ export default { that.getTableHourData(); that.getDayData(that.year, that.month); that.getMonthData(that.year); - let obj = {}; - obj.mgroup__name = "电石渣"; - obj.page = 0; - obj.enabled = 1; - obj.need_display = 1; - obj.ordering = "report_sortstr"; - obj.material__code__in = "elec,elec_0"; - this.$API.enm.mpoint.list.req(obj).then((res) => { - console.log("mpoints", res); - let arr = []; - res.forEach((item) => { - arr.push(item.nickname); - }); - console.log("arr", arr); - that.mpoints = arr; - }); }, methods: { getMpoints() { @@ -311,7 +295,7 @@ export default { console.log("mpoints", res); let arr = []; res.forEach((item) => { - arr.push(item.nickname); + arr.push(item.name); }); console.log("arr", arr); that.mpoints = arr; @@ -336,19 +320,24 @@ export default { getTableHourData() { let that = this; that.tableDatas = []; + let nowDate = new Date(); let timeDate = new Date().getTime(); - let yetTime = timeDate - 3600000 * 24; - let ystDate = new Date(yetTime); - let year_h = ystDate.getFullYear(); - let month_h = ystDate.getMonth() + 1; - let days_h = ystDate.getDate(); - month_h = month_h > 9 ? month_h : "0" + month_h; - days_h = days_h > 9 ? days_h : "0" + days_h; + let hours_h = nowDate.getHours(); + let ystDate = null; + if(hours_h>21){//传入今天的日期 + ystDate = nowDate; + }else{//传入昨天的日期 + let yetTime = timeDate - 3600000 * 24; + ystDate = new Date(yetTime); + } + let year_d = ystDate.getFullYear(); + let month_d = ystDate.getMonth() + 1; + let days_d = ystDate.getDate(); let obj_d = {}; obj_d.type = "day_s"; - obj_d.year_s = year_h; - obj_d.month_s = month_h; - obj_d.day_s = days_h; + obj_d.year_s = year_d; + obj_d.month_s = month_d; + obj_d.day_s = days_d; obj_d.mgroup__name = "电石渣"; obj_d.mpoint__material__code__in = "elec,elec_0"; obj_d.mpoint__need_display = 1; @@ -356,12 +345,12 @@ export default { this.$API.enm.mpoint.stat.req(obj_d).then((res) => { console.log("getTableHourData", res); res.forEach((item, index) => { - let index_d = that.mpoints.indexOf(item.mpoint_nickname); + let index_d = that.mpoints.indexOf(item.mpoint_name); if (that.tableDatas[index_d]) { that.tableDatas[index_d][3] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[3] = item.elec_consume_unit; @@ -381,14 +370,14 @@ export default { console.log("getTableHourData", res); res.forEach((item, index) => { let index_m = that.mpoints.indexOf( - item.mpoint_nickname + item.mpoint_name ); if (that.tableDatas[index_m]) { that.tableDatas[index_m][4] = item.elec_consume_unit; } else { let obj = []; - obj[0] = item.mpoint_nickname; + obj[0] = item.mpoint_nickname?item.mpoint_nickname:item.mpoint_name;; obj[1] = item.ep_monitored_number; obj[2] = "KW·h/t"; obj[4] = item.elec_consume_unit; @@ -418,7 +407,7 @@ export default { } let data = response; data.forEach((item) => { - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint let ind = item.day_s - 1; seriesData[index][ind] = item.elec_consume_unit; }); @@ -460,7 +449,7 @@ export default { let data = response; data.forEach((item) => { let ind = item.month_s - 1; - let index = that.mpoints.indexOf(item.mpoint_nickname); //第几个mpoint + let index = that.mpoints.indexOf(item.mpoint_name); //第几个mpoint seriesData[index][ind] = item.elec_consume_unit; }); let options = { ...that.option3 };