实时数据表格更改

This commit is contained in:
zhujiyan
2024-07-31 16:23:34 +08:00
parent f2a96f17f5
commit 06c08c416e

View File

@@ -21,39 +21,75 @@
</div>
</div>
<div class="view_bot">
<div class="view_bot_tables">
<div class="view_bot_tables" v-loading="loading">
<!-- 表格数据 -->
<div v-if="tableData.length != 0">
<!-- div设计table -->
<div class="table" v-for="(item, index) in columnsData" :key="index">
<!-- 单层表头 -->
<div class="thead">
<div class="thead_top">
{{ item[0].showName ? item[0].showName : '' }}({{ item[0].unit }})
</div>
<div class="thead_bot">
<div class="thead_bot_cell" v-for="(vv, key) in item" :key="key">
{{ vv.phase + ' ' }}
<div class="table_container">
<div class="table" v-for="(item, index) in columnsDataTop" :key="index">
<div class="table_info">
<!-- 单层表头 -->
<div class="thead">
<div class="thead_top">
{{ item[0].showName ? item[0].showName : '' }}({{ item[0].unit }})
</div>
<div class="thead_bot">
<div class="thead_bot_cell" v-for="(vv, key) in item" :key="key">
{{ vv.phase == 'M' ? '' : vv.phase + ' ' }}
</div>
</div>
</div>
<!-- 有合并表头的数据 -->
<div class="tbody">
<div class="tbody_cell" v-for="(vv, key) in item" :key="key">
{{
tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
? tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
: '/'
}}
</div>
</div>
</div>
</div>
<!-- 有合并表头的数据 -->
<div class="tbody">
<div class="tbody_cell" v-for="(vv, key) in item" :key="key">
{{
tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
? tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
: '/'
}}
</div>
<div class="table_container">
<div class="table" v-for="(item, index) in columnsDataBot" :key="index">
<div class="table_info">
<!-- 单层表头 -->
<div class="thead">
<div class="thead_top">
{{ item[0].showName ? item[0].showName : '' }}({{ item[0].unit }})
</div>
<div class="thead_bot">
<div class="thead_bot_cell" v-for="(vv, key) in item" :key="key">
{{ vv.phase == 'M' ? '' : vv.phase + ' ' }}
</div>
</div>
</div>
<!-- 有合并表头的数据 -->
<div class="tbody">
<div class="tbody_cell" v-for="(vv, key) in item" :key="key">
{{
tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
? tableData.find(item => {
return item.anotherName == vv.showName && item.phase == vv.phase
})?.statisticalData
: '/'
}}
</div>
</div>
</div>
</div>
</div>
</div>
<div v-else style="border: 1px solid #eee" v-loading="loading">
<div v-else style="border: 1px solid #eee">
<el-empty description="暂无数据" />
</div>
</div>
@@ -65,7 +101,6 @@ import { ref, onMounted } from 'vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { getRealTimeTableList } from '@/api/cs-device-boot/EquipmentDelivery'
import * as echarts from 'echarts'
import { split } from 'lodash-es'
const pieChartRef: any = ref()
const pieChart1: any = ref()
const pieChart2: any = ref()
@@ -374,7 +409,6 @@ const listA: any = ref([])
const loading = ref(false)
//定义表格所需要的数据
const tableData: any = ref([])
loading.value = true
const columnsData: any = ref([])
const getColumns = () => {
getRealTimeTableList().then(res => {
@@ -382,20 +416,34 @@ const getColumns = () => {
})
}
//处理表格数据
const columnsDataTop: any = ref([])
const columnsDataBot: any = ref([])
const getTableData = (list: any) => {
loading.value = true
tableData.value = list
columnsData.value.map((item: any) => {
columnsDataTop.value = []
columnsDataBot.value = []
columnsData.value.map((item: any, index: any) => {
item.map((vv: any) => {
vv.statisticalData = list.find((kk: any) => {
return kk.anotherName == vv.showName && kk.phase == vv.phase
})?.statisticalData
})
if (index < 4) {
columnsDataTop.value.push(item)
}
if (index >= 4) {
columnsDataBot.value.push(item)
}
loading.value = false
})
loading.value = false
}
//获取实时数据
const getRealTimeData = (val: any) => {
loading.value = true
if (val.length != 0) {
getColumns()
getTableData(val)
dataList.value = val
dataList.value.map((item: any, index: any) => {
if (item.anotherName == '相电压总有效值') {
@@ -478,8 +526,6 @@ const getRealTimeData = (val: any) => {
}
]
pieChart6.value.initChart()
getColumns()
getTableData(val)
} else {
init()
}
@@ -551,64 +597,83 @@ onMounted(() => {
.view_bot_tables {
margin-bottom: 10px;
height: auto;
min-height: 120px;
}
}
}
.view::-webkit-scrollbar {
display: none;
}
.table {
.table_container {
width: 100%;
height: 120px;
border: 1px solid #eee;
border-bottom: 2px solid #eee;
margin-bottom: 20px;
height: auto;
display: flex;
flex-direction: column;
.thead {
width: 100%;
height: auto;
background: #f4f6f9;
text-align: center;
display: flex;
flex-direction: column;
.thead_top {
align-items: center;
justify-content: center;
.table {
flex: 1;
.table_info {
width: 100%;
height: 40px;
line-height: 40px;
height: 120px;
border: 1px solid #eee;
color: #111;
font-size: 14px;
font-weight: 800;
}
.thead_bot {
width: 100%;
height: 40px;
line-height: 40px;
border-bottom: 2px solid #eee;
margin-bottom: 20px;
display: flex;
color: #111;
font-size: 14px;
font-weight: 800;
.thead_bot_cell {
flex: 1;
flex-direction: column;
}
.thead {
width: 100%;
height: auto;
background: #f4f6f9;
text-align: center;
display: flex;
flex-direction: column;
.thead_top {
width: 100%;
height: 40px;
line-height: 40px;
border: 1px solid #eee;
color: #111;
font-size: 14px;
font-weight: 800;
}
.thead_bot {
width: 100%;
height: 40px;
line-height: 40px;
display: flex;
color: #111;
font-size: 14px;
font-weight: 800;
.thead_bot_cell {
flex: 1;
border: 1px solid #eee;
}
}
}
}
.tbody {
flex: 1;
display: flex;
text-align: center;
.tbody_cell {
.tbody {
flex: 1;
display: flex;
text-align: center;
line-height: 40px;
border: 1px solid #eee;
border-bottom: 0;
.tbody_cell {
flex: 1;
text-align: center;
line-height: 40px;
border: 1px solid #eee;
border-bottom: 0;
}
}
.tbody:hover {
background: #f4f6f9;
}
}
.tbody:hover {
background: #f4f6f9;
}
}
.table_container:hover{
.table {
.tbody{
background: #f4f6f9;
}
}
}
</style>