实时数据表格更改

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