Files
energy_storage/web/src/views/statisticalAnalysis.vue

869 lines
24 KiB
Vue
Raw Normal View History

2025-09-02 17:05:10 +08:00
<template>
<div class="statisicalAn">
<div style="display: flex; justify-content: space-between">
<div class="header">
<div
v-for="item in tabList"
:key="item.key"
class="tab-item"
2025-09-02 17:05:10 +08:00
:class="[activeKey == item.key ? 'actived' : 'uactived']"
@click="activeKey = item.key"
>
<span>{{ item.name }}</span>
</div>
2025-09-02 17:05:10 +08:00
</div>
<searchBox
class="searchBox"
ref="searchBox"
:btn-option-list="btnOptionList"
:search-options="searchOptions"
:title-option="{ title: '', info: '' }"
@onSearch="onSearch"
@operateForm="operateForm"
>
<template #stationSelect="">
<a-select
style="width: 200px"
:dropdown-match-select-width="false"
v-model:value="stationId"
allow-clear
@change="changeStation"
>
<a-select-option
:value="option.value"
v-for="option in stationList"
:key="option.value"
>
{{ option.label }}
</a-select-option>
</a-select>
<!-- <a-range-picker v-model:value="formData[item.key]" value-format="YYYY-MM-DD" @change="$emit('onSearch', formData)" /> -->
</template>
</searchBox>
2025-09-02 17:05:10 +08:00
</div>
<div class="main_content">
<a-spin :spinning="loading.chart || loading.table">
<energyEchart
:key="`${activeKey}_${renderKey}`"
:chart-options="echartsInfo[activeKey].chartOptions"
:chart-data="echartsInfo[activeKey].chartData"
:chart-datav="echartsInfo[activeKey].chartDatav"
:columns="tableList[activeKey].columns"
:page-option="tableList[activeKey].pageOption"
:table-info="tableList[activeKey].tableInfo"
:table-data="tableList[activeKey].tableData"
@pagesizeChange="pagesizeChange"
2025-09-11 19:01:01 +08:00
>
</energyEchart>
</a-spin>
</div>
2025-09-02 17:05:10 +08:00
</div>
</template>
<script>
import energyEchart from '@/components/statisticalAnalysis/energyEchart.vue'
import searchBox from '@/components/SearchBox.vue'
2025-09-04 16:04:37 +08:00
import { postReq, getReq } from '@/request/api'
import {downloadByUrl} from '@/utils/download'
2025-09-02 17:05:10 +08:00
export default {
name: 'StatisicalAnView',
components: { energyEchart, searchBox },
data() {
return {
btnOptionList: [],
2025-09-11 19:01:01 +08:00
loading: {
chart: false,
table: false
},
stationId: undefined,
renderKey: 0,
2025-09-02 17:05:10 +08:00
paramsDate: {},
searchOptions: [
{
label: '日期',
2025-09-04 16:04:37 +08:00
type: 'datePick1',
2025-09-02 17:05:10 +08:00
value: [],
key: 'time'
2025-09-11 19:01:01 +08:00
},
{
label: '场站切换',
type: 'slot',
value: [],
key: 'station',
slotName: 'stationSelect'
2025-09-02 17:05:10 +08:00
}
],
2025-09-11 19:01:01 +08:00
stationList: [],
2025-09-02 17:05:10 +08:00
echartsInfo: {
2025-09-11 19:01:01 +08:00
1: {
2025-09-02 17:05:10 +08:00
chartOptions: [
{
title: '充放电分析',
type: 'bar',
dataKey: 'sales',
infoKeys: [
2025-09-04 16:04:37 +08:00
{ key: 'storage_elect_in', label: '日充电电量', lineColor: '#2A82E4' },
{ key: 'storage_elect_out', label: '日放电电量', lineColor: '#5AABF2' }
2025-09-02 17:05:10 +08:00
]
},
{
title: '运行状态分析',
type: 'bar',
dataKey: 'users',
2025-10-10 11:01:13 +08:00
yAxisOption:[
{
name: '日故障次数(V)',
type: 'value',
nameTextStyle: {
color: '#fff'
},
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
// {
// name: '工作时长(h)',
// type: 'value',
// splitLine: {
// lineStyle: { type: 'dashed', color: '#435463' }
// },
// nameTextStyle: {
// color: '#fff'
// },
// axisLabel: {
// interval: 4,
// color: '#fff',
// fontSize:12
// },
// },
],
2025-09-02 17:05:10 +08:00
infoKeys: [
2025-09-04 16:04:37 +08:00
{ key: 'storage_num_err', label: '日故障次数', lineColor: '#0CDAF5' },
2025-10-10 11:01:13 +08:00
// { key: 'key2', label: '日充电工作时长', lineColor: '#2A82E4' }, 暂无数据
// { key: 'key3', label: '日放电工作时长', lineColor: '#5AABF2' }
2025-09-02 17:05:10 +08:00
]
},
{
2025-09-11 19:01:01 +08:00
title: '今日电压与电流分析',
2025-09-02 17:05:10 +08:00
type: 'line',
dataKey: 'stock',
2025-10-10 11:01:13 +08:00
yAxisOption:[
{
name: '电压(V)',
type: 'value',
nameTextStyle: {
color: '#fff'
},
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
{
name: '电流(A)',
type: 'value',
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
nameTextStyle: {
color: '#fff'
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
],
2025-09-02 17:05:10 +08:00
infoKeys: [
{
2025-09-11 19:01:01 +08:00
key: 'V',
2025-09-02 17:05:10 +08:00
label: '电压',
lineColor: '#3F80F2',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
},
{
2025-09-11 19:01:01 +08:00
key: 'I',
2025-09-02 17:05:10 +08:00
label: '电流',
lineColor: '#A9A6FF',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
}
]
},
{
2025-09-11 19:01:01 +08:00
title: '今日功率分析',
2025-09-02 17:05:10 +08:00
type: 'line',
dataKey: 'yearly',
infoKeys: [
{
2025-09-11 19:01:01 +08:00
key: 'P',
2025-09-02 17:05:10 +08:00
label: '功率',
lineColor: '#00FFFB',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
}
]
}
],
2025-09-11 19:01:01 +08:00
chartData: {},
2025-09-12 10:58:59 +08:00
chartDatav: {}
2025-09-04 16:04:37 +08:00
},
2025-09-11 19:01:01 +08:00
2: {
2025-09-04 16:04:37 +08:00
chartOptions: [
{
title: '充电分析',
2025-09-04 16:04:37 +08:00
type: 'bar',
dataKey: 'sales',
infoKeys: [{ key: 'storage_elect_in', label: '日充电电量', lineColor: '#2A82E4' }]
2025-09-04 16:04:37 +08:00
},
{
title: '运行状态分析',
type: 'bar',
dataKey: 'users',
infoKeys: [
{ key: 'storage_num_err', label: '日充电次数', lineColor: '#0CDAF5' },
{ key: 'key3', label: '日故障次数', lineColor: '#5AABF2' },
2025-10-10 11:01:13 +08:00
// { key: 'key3', label: '日充电时长', lineColor: '#5AABF2' }
2025-09-04 16:04:37 +08:00
]
},
{
2025-09-11 19:01:01 +08:00
title: '今日电压与电流分析',
2025-09-04 16:04:37 +08:00
type: 'line',
dataKey: 'stock',
2025-10-10 11:01:13 +08:00
yAxisOption:[
{
name: '电压(V)',
type: 'value',
nameTextStyle: {
color: '#fff'
},
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
{
name: '电流(A)',
type: 'value',
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
nameTextStyle: {
color: '#fff'
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
],
2025-09-04 16:04:37 +08:00
infoKeys: [
{
2025-09-11 19:01:01 +08:00
key: 'V',
2025-09-04 16:04:37 +08:00
label: '电压',
lineColor: '#3F80F2',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
},
{
2025-09-11 19:01:01 +08:00
key: 'I',
2025-09-04 16:04:37 +08:00
label: '电流',
lineColor: '#A9A6FF',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
}
]
},
{
2025-09-11 19:01:01 +08:00
title: '今日功率分析',
2025-09-04 16:04:37 +08:00
type: 'line',
dataKey: 'yearly',
infoKeys: [
{
2025-09-11 19:01:01 +08:00
key: 'P',
2025-09-04 16:04:37 +08:00
label: '功率',
lineColor: '#00FFFB',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
}
]
}
],
chartData: {}
},
2025-09-11 19:01:01 +08:00
3: {
2025-09-04 16:04:37 +08:00
chartOptions: [
{
title: '发电电量分析',
2025-09-04 16:04:37 +08:00
type: 'bar',
dataKey: 'sales',
infoKeys: [{ key: 'storage_elect_in', label: '日发电电量', lineColor: '#2A82E4' }]
2025-09-04 16:04:37 +08:00
},
{
title: '运行状态分析',
type: 'bar',
dataKey: 'users',
infoKeys: [
{ key: 'storage_num_err', label: '日故障次数', lineColor: '#0CDAF5' },
2025-10-10 11:01:13 +08:00
// { key: 'key3', label: '日发电时长', lineColor: '#5AABF2' }
2025-09-04 16:04:37 +08:00
]
},
{
2025-09-11 19:01:01 +08:00
title: '今日电压与电流分析',
2025-09-04 16:04:37 +08:00
type: 'line',
dataKey: 'stock',
2025-10-10 11:01:13 +08:00
yAxisOption:[
{
name: '电压(V)',
type: 'value',
nameTextStyle: {
color: '#fff'
},
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
{
name: '电流(A)',
type: 'value',
splitLine: {
lineStyle: { type: 'dashed', color: '#435463' }
},
nameTextStyle: {
color: '#fff'
},
axisLabel: {
interval: 4,
color: '#fff',
fontSize:12
},
},
],
2025-09-04 16:04:37 +08:00
infoKeys: [
{
2025-09-11 19:01:01 +08:00
key: 'V',
2025-09-04 16:04:37 +08:00
label: '电压',
lineColor: '#3F80F2',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
},
{
2025-09-11 19:01:01 +08:00
key: 'I',
2025-09-04 16:04:37 +08:00
label: '电流',
lineColor: '#A9A6FF',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
}
]
},
{
2025-09-11 19:01:01 +08:00
title: '今日功率分析',
2025-09-04 16:04:37 +08:00
type: 'line',
dataKey: 'yearly',
infoKeys: [
{
2025-09-11 19:01:01 +08:00
key: 'P',
2025-09-04 16:04:37 +08:00
label: '功率',
lineColor: '#00FFFB',
colorStart: ' rgba(10, 250, 106, 0.15)',
colorEnd: ' rgba(171, 255, 249, 0.3)'
}
]
}
],
chartData: {}
2025-09-02 17:05:10 +08:00
}
},
2025-09-11 19:01:01 +08:00
activeKey: 1,
2025-09-12 10:58:59 +08:00
interval: null,
2025-09-02 17:05:10 +08:00
tabList: [
{
2025-09-11 19:01:01 +08:00
key: 1,
2025-09-02 17:05:10 +08:00
name: '储能设备'
},
2025-09-12 10:58:59 +08:00
2025-09-02 17:05:10 +08:00
{
key: 2,
2025-09-02 17:05:10 +08:00
name: '充电设备'
2025-09-12 10:58:59 +08:00
},
{
key: 3,
2025-09-12 10:58:59 +08:00
name: '光伏设备'
2025-09-02 17:05:10 +08:00
}
],
tableList: {
2025-09-11 19:01:01 +08:00
1: {
2025-09-02 17:05:10 +08:00
columns: [
{
title: '充电电量',
dataIndex: 'storage_elect_in',
key: 'storage_elect_in',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '放电电量',
dataIndex: 'storage_elect_out',
key: 'storage_elect_out',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '充电次数',
dataIndex: 'storage_num_in',
key: 'storage_num_in',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '放电次数',
dataIndex: 'storage_num_out',
key: 'storage_num_out',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '充电时长',
dataIndex: 'storage_t_in',
key: 'storage_t_in',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '放电时长',
dataIndex: 'storage_t_out',
key: 'storage_t_out',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
2025-09-02 17:05:10 +08:00
{
title: '利用率',
dataIndex: 'storage_usage',
key: 'storage_usage',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '故障次数',
2025-09-04 16:04:37 +08:00
dataIndex: 'storage_num_err',
key: 'storage_num_err',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
},
{
title: '日期',
2025-09-04 16:04:37 +08:00
dataIndex: 'dt',
key: 'dt',
2025-09-02 17:05:10 +08:00
width: 120,
ellipsis: true
}
],
2025-09-03 15:41:12 +08:00
geturl: '',
tableData: [],
pageOption: {
2025-09-04 16:04:37 +08:00
page: 1,
2025-09-03 15:41:12 +08:00
pageSize: 10,
2025-09-04 16:04:37 +08:00
count: 1
2025-09-02 17:05:10 +08:00
}
2025-09-04 16:04:37 +08:00
},
2025-09-11 19:01:01 +08:00
2: {
2025-09-04 16:04:37 +08:00
columns: [
2025-09-03 15:41:12 +08:00
{
title: '充电电量',
dataIndex: 'charge_elect',
key: 'charge_elect',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
title: '充电次数',
dataIndex: 'charge_num',
key: 'charge_num',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
title: '充电时长',
dataIndex: 'charge_t',
key: 'charge_t',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
title: '利用率',
dataIndex: 'charge_usage',
key: 'charge_usage',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
2025-09-04 16:04:37 +08:00
title: '故障次数',
dataIndex: 'charge_num_err',
key: 'charge_num_err',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
2025-09-11 19:01:01 +08:00
2025-09-03 15:41:12 +08:00
{
2025-09-04 16:04:37 +08:00
title: '日期',
dataIndex: 'dt',
key: 'dt',
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
}
],
2025-09-04 16:04:37 +08:00
geturl: '',
tableData: [],
pageOption: {
page: 1,
pageSize: 10,
count: 1
}
},
2025-09-11 19:01:01 +08:00
3: {
2025-09-04 16:04:37 +08:00
columns: [
2025-09-03 15:41:12 +08:00
{
title: '发电电量',
dataIndex: 'solar_elect_gen',
key: 'solar_elect_gen',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
title: '入网电量',
dataIndex: 'solar_elect_grid',
key: 'solar_elect_grid',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
title: '发电时长',
dataIndex: 'solar_t',
key: 'solar_t',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
title: '利用率',
dataIndex: 'solar_usage',
key: 'solar_usage',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
{
2025-09-04 16:04:37 +08:00
title: '故障次数',
dataIndex: 'solar_num_err',
key: 'solar_num_err',
2025-09-04 16:04:37 +08:00
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
},
2025-09-03 15:41:12 +08:00
{
2025-09-04 16:04:37 +08:00
title: '日期',
dataIndex: 'dt',
key: 'dt',
width: 120,
ellipsis: true
2025-09-03 15:41:12 +08:00
}
],
2025-09-04 16:04:37 +08:00
geturl: '',
tableData: [],
pageOption: {
page: 1,
pageSize: 10,
count: 1
}
}
}
}
},
2025-09-11 19:01:01 +08:00
watch: {
activeKey: {
handler(newVal) {
2025-09-12 10:58:59 +08:00
if (!newVal) return
2025-09-11 19:01:01 +08:00
// 清除之前的数据
2025-09-12 10:58:59 +08:00
this.resetDataForInactiveKey()
2025-09-11 19:01:01 +08:00
// 并行加载新数据
Promise.all([
this.getStationList(),
this.getEchartsListForActiveKey(),
this.getTableListForActiveKey()
]).then(() => {
this.$nextTick(() => {
this.getStatCharts()
})
})
2025-09-11 19:01:01 +08:00
},
immediate: true // 添加立即执行
2025-09-04 16:04:37 +08:00
}
},
async mounted() {
2025-09-12 10:58:59 +08:00
// 优先加载第一个页面(activeKey=1)所需的数据
this.btnOptionList = this.$getBtns(['导出'])
2025-09-11 19:01:01 +08:00
await Promise.all([
this.getStationList(),
this.getEchartsListForActiveKey(),
this.getTableListForActiveKey()
2025-09-12 10:58:59 +08:00
])
2025-09-11 19:01:01 +08:00
// 初始化实时刷新
2025-09-12 10:58:59 +08:00
this.startRealtimeRefresh()
2025-09-11 19:01:01 +08:00
},
beforeUnmount() {
2025-09-12 10:58:59 +08:00
clearInterval(this.interval) // 组件销毁时清除定时器
2025-09-04 16:04:37 +08:00
},
methods: {
operateForm(type, record = {}) {
if (type == 'output') {
this.loading.chart=true
this.handleOutput()
}
},
async handleOutput() {
const { formData:{time=[]} } = this.$refs.searchBox
const params = {
station_id: this.stationId,
category: this.activeKey,
start_date: time[0] || '',
end_date: time[1] || ''
}
try {
const res = await getReq('/exportStatReport', params)
if(res.errcode==0){
window.open('/download/'+res.data,'_parent');
this.loading.chart=false
}
} catch (error) {
console.log(error)
}
},
2025-09-11 19:01:01 +08:00
forceRerender() {
2025-09-12 10:58:59 +08:00
this.renderKey += 1
2025-09-04 16:04:37 +08:00
},
2025-09-11 19:01:01 +08:00
resetDataForInactiveKey() {
// 重置非当前激活页面的数据
2025-09-11 19:01:01 +08:00
Object.keys(this.echartsInfo).forEach((key) => {
if (key != this.activeKey) {
2025-09-12 10:58:59 +08:00
this.echartsInfo[key].chartData = {}
this.echartsInfo[key].chartDatav = {}
2025-09-11 19:01:01 +08:00
}
2025-09-12 10:58:59 +08:00
})
2025-09-11 19:01:01 +08:00
Object.keys(this.tableList).forEach((key) => {
if (key != this.activeKey) {
this.tableList[key].tableData = []
this.tableList[key].pageOption = {
page: 1,
pageSize: 10,
count: 1
}
2025-09-11 19:01:01 +08:00
}
2025-09-12 10:58:59 +08:00
})
2025-09-04 16:04:37 +08:00
},
2025-09-11 19:01:01 +08:00
async getEchartsListForActiveKey() {
2025-09-12 10:58:59 +08:00
if (!this.activeKey) return
this.loading.chart = true
const currentInfo = this.echartsInfo[this.activeKey]
2025-09-04 16:04:37 +08:00
const query = {
...this.paramsDate,
2025-09-20 16:41:08 +08:00
station_id: this.stationId,
2025-09-11 19:01:01 +08:00
category: this.activeKey
2025-09-12 10:58:59 +08:00
}
2025-09-04 16:04:37 +08:00
try {
2025-09-12 10:58:59 +08:00
const res = await getReq('/queryStatDayList', query)
2025-09-04 16:04:37 +08:00
if (res.errcode === 0) {
2025-09-12 10:58:59 +08:00
this.echartsInfo[this.activeKey].chartData = res.data
this.loading.chart = false
2025-09-04 16:04:37 +08:00
} else {
2025-09-12 10:58:59 +08:00
throw res
2025-09-03 15:41:12 +08:00
}
2025-09-04 16:04:37 +08:00
} catch (error) {
2025-09-12 10:58:59 +08:00
this.loading.chart = false
this.echartsInfo[this.activeKey].chartData = {}
2025-09-03 15:41:12 +08:00
}
},
2025-09-11 19:01:01 +08:00
// 专门获取当前激活页面的表格数据
async getTableListForActiveKey() {
2025-09-12 10:58:59 +08:00
this.loading.table = true
if (!this.activeKey) return
const currentInfo = this.tableList[this.activeKey]
2025-09-03 15:41:12 +08:00
const query = {
...this.paramsDate,
2025-09-20 16:41:08 +08:00
station_id: this.stationId,
2025-09-11 19:01:01 +08:00
category: this.activeKey,
2025-09-04 16:04:37 +08:00
page_size: currentInfo.pageOption.pageSize,
page: currentInfo.pageOption.page
2025-09-12 10:58:59 +08:00
}
2025-09-11 19:01:01 +08:00
try {
const res = await getReq('/queryStatDetailList', query)
2025-09-11 19:01:01 +08:00
if (res.errcode === 0) {
2025-09-12 10:58:59 +08:00
this.tableList[this.activeKey].tableData = res.data.list || res.data
this.tableList[this.activeKey].pageOption.count = res.count || 0
this.tableList[this.activeKey].pageOption.page = res.page || 0
this.tableList[this.activeKey].pageOption.pageSize = res.page_size || 0
2025-09-12 10:58:59 +08:00
this.loading.table = false
2025-09-11 19:01:01 +08:00
} else {
2025-09-12 10:58:59 +08:00
throw res
2025-09-11 19:01:01 +08:00
}
} catch (error) {
2025-09-12 10:58:59 +08:00
this.tableList[this.activeKey].tableData = []
this.tableList[this.activeKey].pageOption.count = 0
this.tableList[this.activeKey].pageOption.page = 0
this.tableList[this.activeKey].pageOption.pageSize = 0
2025-09-12 10:58:59 +08:00
this.loading.table = false
2025-09-03 15:41:12 +08:00
}
2025-09-11 19:01:01 +08:00
},
startRealtimeRefresh() {
this.interval = setInterval(() => {
if (this.activeKey) {
2025-09-12 10:58:59 +08:00
this.getStatCharts() // 定时获取最新实时数据
2025-09-11 19:01:01 +08:00
}
}, 10000)
2025-09-11 19:01:01 +08:00
},
async getStationList() {
const params = {
page_size: 1000,
page: 1
}
2025-09-03 15:41:12 +08:00
try {
2025-09-11 19:01:01 +08:00
const res = await getReq('/queryStationList', params)
2025-09-04 16:04:37 +08:00
if (res.errcode === 0) {
2025-09-11 19:01:01 +08:00
this.stationList = res.data.map((item) => {
return {
value: item.station_id,
label: item.name
}
})
if (this.stationList.length) {
if (!this.stationId) {
this.stationId = this.stationList[0].value
}
2025-09-03 15:41:12 +08:00
}
} else {
2025-09-11 19:01:01 +08:00
const err = { tip: res.errmsg }
throw err
2025-09-03 15:41:12 +08:00
}
} catch (error) {
2025-09-11 19:01:01 +08:00
//统一处理报错提示
}
},
pagesizeChange(e) {
this.tableList[this.activeKey].pageOption.pageSize = e.pageSize
this.tableList[this.activeKey].pageOption.page = e.page
this.getTableListForActiveKey()
},
onSearch(data) {
this.paramsDate.start_date = data.time ? data.time[0] : ''
this.paramsDate.end_date = data.time ? data.time[1] : ''
this.tableList[this.activeKey].pageOption.page = 1
2025-09-12 10:58:59 +08:00
this.getStationList(), this.getEchartsListForActiveKey(), this.getTableListForActiveKey()
2025-09-11 19:01:01 +08:00
},
changeStation() {
2025-09-12 10:58:59 +08:00
this.getStatCharts()
2025-09-20 16:41:08 +08:00
this.getEchartsListForActiveKey()
this.getTableListForActiveKey()
2025-09-11 19:01:01 +08:00
},
2025-09-12 10:58:59 +08:00
2025-09-11 19:01:01 +08:00
async getStatCharts() {
const query = {
dt: this.paramsDate.end_date,
station_id: this.stationId,
category: this.activeKey
}
try {
const res = await getReq('/queryStatCharts', query)
if (res.errcode === 0) {
2025-09-12 11:43:32 +08:00
this.echartsInfo[this.activeKey].chartDatav = res.data
2025-09-11 19:01:01 +08:00
} else {
throw res
}
} catch (error) {
this.echartsInfo[this.activeKey].chartDatav = {}
2025-09-03 15:41:12 +08:00
}
2025-09-12 10:58:59 +08:00
}
2025-09-02 17:05:10 +08:00
}
}
</script>
<style scoped lang="scss">
@import url(@/style/color.scss);
.statisicalAn {
width: 100%;
height: 100%;
padding: 20px;
background: $bg1-color;
border-radius: 15px;
.header {
2025-09-02 17:05:10 +08:00
display: flex;
.tab-item {
height: 38px;
line-height: 38px;
font-size: 14px;
margin-right: 15px;
display: inline-block;
padding: 0 50px;
cursor: pointer;
border: 1px solid $tab-border;
border-radius: 4px;
2025-09-02 17:05:10 +08:00
}
}
.actived {
color: #ffffff;
background-color: $green;
}
.uactived {
color: #a6b8dd;
background-color: $bg2-color;
}
}
2025-09-03 15:41:12 +08:00
.main_content {
2025-09-02 17:05:10 +08:00
overflow: scroll;
height: calc(100% - 40px);
2025-09-03 15:41:12 +08:00
// margin-top: 10px;
2025-09-02 17:05:10 +08:00
}
</style>