From e3224d37a19f2b241286665b56b6c06bd9e859fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8F=9C?= <43331987+JiaLiBai@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ems/dzjk.js | 12 +-- src/views/ems/dzjk/tjbb/dcdqx/index.vue | 110 ++++++++++++++---------- src/views/ems/dzjk/tjbb/glqx/index.vue | 76 ++++------------ src/views/ems/dzjk/tjbb/pcsqx/index.vue | 93 ++++++++++---------- 4 files changed, 136 insertions(+), 155 deletions(-) diff --git a/src/api/ems/dzjk.js b/src/api/ems/dzjk.js index 5faf472..f14ab7a 100644 --- a/src/api/ems/dzjk.js +++ b/src/api/ems/dzjk.js @@ -116,16 +116,16 @@ export function getPcsNameList(siteId) { }) } //pcs曲线 -export function getPCSData({siteId,deviceId,startTime,endTime,dataType}) { +export function getPCSData({siteId,startTime,endTime,dataType}) { return request({ - url: `/ems/statsReport/getPCSData?siteId=${siteId}&deviceId=${deviceId}&startDate=${startTime}&endDate=${endTime}&dataType=${dataType}`, + url: `/ems/statsReport/getPCSData?siteId=${siteId}&startDate=${startTime}&endDate=${endTime}&dataType=${dataType}`, method: 'get' }) } //电池堆曲线 -export function getStackData({siteId,deviceId,startTime,endTime,dataType}) { +export function getStackData({siteId,startTime,endTime,dataType}) { return request({ - url: `/ems/statsReport/getStackData?siteId=${siteId}&deviceId=${deviceId}&startDate=${startTime}&endDate=${endTime}&dataType=${dataType}`, + url: `/ems/statsReport/getStackData?siteId=${siteId}&startDate=${startTime}&endDate=${endTime}&dataType=${dataType}`, method: 'get' }) } @@ -168,9 +168,9 @@ export function batteryAveTemp(siteId) { }) } // 功率曲线 -export function getPowerData({siteId,deviceId,startDate,endDate,dataType}) { +export function getPowerData({siteId,startDate,endDate}) { return request({ - url: `/ems/statsReport/getPowerData?siteId=${siteId}&deviceId=${deviceId}&startDate=${startDate}&endDate=${endDate}&dataType=${dataType}`, + url: `/ems/statsReport/getPowerData?siteId=${siteId}&startDate=${startDate}&endDate=${endDate}`, method: 'get' }) } diff --git a/src/views/ems/dzjk/tjbb/dcdqx/index.vue b/src/views/ems/dzjk/tjbb/dcdqx/index.vue index 8897cee..1e9f208 100644 --- a/src/views/ems/dzjk/tjbb/dcdqx/index.vue +++ b/src/views/ems/dzjk/tjbb/dcdqx/index.vue @@ -3,11 +3,11 @@
- - - - - + + + + + { - const data = JSON.parse(JSON.stringify(response?.data || [])) - this.pcsOptions = data - this.pcs = data.length>0?data[0].id:''; - }) - }, + // getPcsList(){ + // return getStackNameList(this.siteId).then(response => { + // const data = JSON.parse(JSON.stringify(response?.data || [])) + // this.pcsOptions = data + // this.pcs = data.length>0?data[0].id:''; + // }) + // }, getData(){ - const {siteId,pcs,activeBtn}=this; + const {siteId,activeBtn}=this; const [start='',end='']=(this.dateRange || []) - if(!pcs) return //接口调用完成之后 设置图表、结束loading this.loading=true; - getStackData({siteId,deviceId:pcs,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => { + getStackData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => { this.setOption(response?.data || []) }).finally(()=>{this.loading=false;}) - }, setOption(data) { + + // [{ + // "deviceId": "PCS04", + // "dataList": [ + // { + // "statisDate": "2025-09-05", + // "activePower": null, + // "reactivePower": null, + // "uCurrent": 1.30, + // "vCurrent": 0.90, + // "wCurrent": 1.00, + // "deviceId": "PCS04" + // }, + // { + // "statisDate": "2025-09-04", + // "activePower": null, + // "reactivePower": null, + // "uCurrent": 71.40, + // "vCurrent": 71.30, + // "wCurrent": 71.80, + // "deviceId": "PCS04" + // } + // ] + // }] const ele = this.btnList.find((item)=>{return item.id === this.activeBtn}) - const source = JSON.parse(JSON.stringify(ele.source)) - const length = ele.attr.length - const series = [] - data.forEach((item)=>{ - const arr = ele.attr.map(key=>item[key]) - source.push([item.statisDate,...arr]) - }) - ele.attr.forEach((item)=>{ - series.push({ - name:length>1?item:ele.name, - type:ele.type || 'scatter' + const sourceBase = JSON.parse(JSON.stringify(ele.source)) + const source=[] + const sourceTop = ['日期'] + sourceBase.forEach((outer,outerIndex)=>{ + data.forEach((item,itemIndex)=>{ + sourceTop.push(`${item.deviceId}-${outer}`) + item.dataList.forEach((inner,innerIndex)=>{ + if(itemIndex === 0 || innerIndex+1>source.length) { + source.push([inner.statisDate]) + } + source[innerIndex].push(inner[ele.attr[outerIndex]]) + }) }) }) + source.unshift(sourceTop) + console.log('========',source) this.chart.setOption({ - color:['#FFBD00','#3C81FF'], grid: { containLabel: true }, @@ -148,7 +172,11 @@ export default { type: 'value', }, dataset: {source}, - series + series:source[0].slice(1).map(item=>{ + return { + type:ele.type || 'scatter' + } + }) },true) }, initChart() { @@ -156,16 +184,10 @@ export default { }, init(){ this.loading = true - this.pcs='' - this.pcsOptions=[] + // this.pcs='' + // this.pcsOptions=[] this.initChart() - this.getPcsList().then(()=>{ - if(this.pcs){ - this.onReset() - }else{ - this.loading = false - } - }) + this.onReset() } }, mounted(){ diff --git a/src/views/ems/dzjk/tjbb/glqx/index.vue b/src/views/ems/dzjk/tjbb/glqx/index.vue index f4d8781..15270e6 100644 --- a/src/views/ems/dzjk/tjbb/glqx/index.vue +++ b/src/views/ems/dzjk/tjbb/glqx/index.vue @@ -3,16 +3,6 @@
- - - - - - - - - -
- - - - - {{item.name}} - - - -
@@ -67,26 +48,9 @@ export default { defaultDateRange:[],//默认展示的时间 dateRange:[], loading:false, - pcs:'', - pcsOptions: [], - activeBtn:'1', - btnList:[ - {name:'电网功率',id:'1',attr:'gridPower'}, - {name:'负载功率',id:'2',attr:'loadPower'}, - {name:'储能功率',id:'3',attr:'storagePower'}, - {name:'光伏功率',id:'4',attr:'pvPower'}, - ], - } }, methods: { - changeDataType(id){ - if(id !== this.activeBtn){ - console.log('点击了不同的菜单,更新数据') - this.activeBtn=id; - this.getData() - } - }, // 搜索 onSearch(){ this.getData() @@ -96,31 +60,21 @@ export default { this.dateRange=[] this.getData() }, - getPcsList(){ - return getPcsNameList(this.siteId).then(response => { - const data = response?.data || []; - this.pcsOptions = data - this.pcs = data.length>0?data[0].id:''; - }) - }, getData(){ - const {siteId,pcs,activeBtn}=this; + const {siteId}=this; const [start='',end='']=(this.dateRange || []) - if(!pcs) return //接口调用完成之后 设置图表、结束loading this.loading=true; - getPowerData({siteId,deviceId:pcs,startDate:formatDate(start),endDate:formatDate(end),dataType:activeBtn}).then(response => { + getPowerData({siteId,startDate:formatDate(start),endDate:formatDate(end)}).then(response => { this.setOption(response?.data || []) }).finally(()=>{this.loading=false;}) }, setOption(data) { - const {name,attr} =this.btnList.find(item=>item.id===this.activeBtn) - const source = [['日期',name]] - data.forEach((item,index)=>{ - source.push([item.statisDate,item[attr]]) + const source = [['日期','电网功率','负载功率','储能功率','光伏功率']] + data.forEach(item=>{ + source.push([item.statisDate,item.gridPower,item.loadPower,item.storagePower,item.pvPower]) }) this.chart.setOption({ - color:['#FFBD00','#3C81FF'], grid: { containLabel: true }, @@ -146,7 +100,15 @@ export default { dataset:{source}, series: [ { - name, + type: 'scatter', + }, + { + type: 'scatter', + }, + { + type: 'scatter', + }, + { type: 'scatter', } ] @@ -157,16 +119,8 @@ export default { }, init(){ this.loading = true - this.pcs='' - this.pcsOptions=[] this.initChart() - this.getPcsList().then(()=>{ - if(this.pcs){ - this.onReset() - }else{ - this.loading = false - } - }) + this.getData() } }, mounted(){ diff --git a/src/views/ems/dzjk/tjbb/pcsqx/index.vue b/src/views/ems/dzjk/tjbb/pcsqx/index.vue index c2ba632..62b5436 100644 --- a/src/views/ems/dzjk/tjbb/pcsqx/index.vue +++ b/src/views/ems/dzjk/tjbb/pcsqx/index.vue @@ -3,11 +3,11 @@
- - - - - + + + + + { - const data = response?.data || []; - this.pcsOptions = data - this.pcs = data.length>0?data[0].id:''; - }) - }, + // getPcsList(){ + // return getPcsNameList(this.siteId).then(response => { + // const data = response?.data || []; + // this.pcsOptions = data + // this.pcs = data.length>0?data[0].id:''; + // }) + // }, getData(){ - const {siteId,pcs,activeBtn}=this; + const {siteId,activeBtn}=this; const [start='',end='']=(this.dateRange || []) - if(!pcs) return this.loading=true; //接口调用完成之后 设置图表、结束loading - getPCSData({siteId,deviceId:pcs,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => { + getPCSData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => { this.setOption(response?.data || []) }).finally(()=>{this.loading=false;}) }, setOption(data) { const ele = this.btnList.find((item)=>{return item.id === this.activeBtn}) - const source = JSON.parse(JSON.stringify(ele.source)) - const length = ele.attr.length - const series = [] - data.forEach((item)=>{ - const arr = ele.attr.map(key=>item[key]) - source.push([item.statisDate,...arr]) - }) - ele.attr.forEach((item)=>{ - series.push({ - name:length>1?item:ele.name, - type:ele.type || 'scatter' + const sourceBase = JSON.parse(JSON.stringify(ele.source)) + const source=[] + const sourceTop = ['日期'] + sourceBase.forEach((outer,outerIndex)=>{ + data.forEach((item,itemIndex)=>{ + sourceTop.push(`${item.deviceId}-${outer}`) + item.dataList.forEach((inner,innerIndex)=>{ + if(itemIndex === 0 || innerIndex+1>source.length) { + source.push([inner.statisDate]) + } + source[innerIndex].push(inner[ele.attr[outerIndex]]) + }) }) }) + source.unshift(sourceTop) + console.log('========',source) this.chart.setOption({ - color:['#FFBD00','#3C81FF','#91cc74'], grid: { containLabel: true }, @@ -151,7 +152,11 @@ export default { type: 'value', }, dataset: {source}, - series + series:source[0].slice(1).map(item=>{ + return { + type:ele.type || 'scatter' + } + }) },true) }, @@ -160,18 +165,18 @@ export default { }, init(){ this.loading = true - this.pcs='' - this.pcsOptions=[] - this.dateRange =[] + // this.pcs='' + // this.pcsOptions=[] this.initChart() - this.getPcsList().then(()=>{ - if(this.pcs){ - this.onReset() - }else{ - this.loading=false; - } - - }) + this.onReset() + // this.getPcsList().then(()=>{ + // if(this.pcs){ + // this.onReset() + // }else{ + // this.loading=false; + // } + // + // }) } }, mounted(){