修改策略分析页面数据查询接口和表格显示数据变化时表格高度异常的问题

This commit is contained in:
lixiaoyuan
2026-05-08 16:57:55 +08:00
parent 27365642d9
commit 72721608e3
5 changed files with 98 additions and 44 deletions

View File

@@ -88,6 +88,7 @@ import {
const comtable = ref('')
const props = defineProps({
tableH: { Number, default: ()=> 500 },
columns: { type: Array, default: () => [] },
tableData: { type: Array, default: () => [] },
tableOption: {
@@ -164,10 +165,18 @@ onMounted(async () => {
await nextTick()
scroll.value = { y: comtable.value.offsetHeight - 56 }
})
watch(
() => props.tableH,
(n, o) => {
if (n) {
const pageH = data.newTableOpt.page ? 42 : 0
scroll.value = { y: n - pageH - 20 }
}
},
{ immediate: true }
)
watch(
() => props.tableData,
(n, o) => {

View File

@@ -122,8 +122,8 @@ export default {
smooth: true,
type: 'line',
barWidth: 10,
itemStyle: { borderRadius: 10, color: item.lineColor },
emphasis: { focus: 'series' },
itemStyle: { borderRadius: 10, color: item.lineColor},
emphasis: { focus: 'series'},
global: false,
showSymbol: false,
data: []

View File

@@ -18,8 +18,8 @@ export default {
name: '',
props: {
propKey: { type: String, default: '' },
propData: { type: Array, default: () => [] },
propOption: { type: Object, default: { series: [] } }
propData: { type: Array, default: () => [] },
propOption: { type: Object, default: { series: [] } }
},
data() {
return {

View File

@@ -58,17 +58,16 @@
</a-spin>
</div>
<div v-if="activeKey == 4" style="height:800px">
<ComTable
:columns="columns"
:table-data="tableData"
:table-option="{ page: false, select: false }">
<template #action="record">
<OperateCom :record="record" :operate-list="operateList" @operateForm="operateForm" />
</template>
</ComTable>
<div v-if="activeKey == 4" class="content-table-4" >
<ComTable
:tableH="tableH"
:columns="columns"
:table-data="tableData"
:table-option="{ page: false, select: false}">
<template #action="record">
<OperateCom :record="record" :operate-list="operateList" @operateForm="operateForm" />
</template>
</ComTable>
</div>
</div>
</template>
@@ -676,7 +675,8 @@ export default {
// {period: "尖", gridPrice: "0.8", chargePrice: "0.6", income: "0.2", elect: "35", incomeTotal: "100"},
// {period: "总计", gridPrice: "0.8", chargePrice: "0.6", income: "0.2", elect: "35", incomeTotal: "100"}
]
],
tableH: 500
}
},
watch: {
@@ -700,6 +700,10 @@ export default {
}
else {
this.$nextTick(() => {
const elementTable = document.getElementsByClassName('content-table-4')[0]
if ( elementTable) {
this.tableH = elementTable.offsetHeight - 20
}
this.getEGridPeriod()
})
}
@@ -708,6 +712,7 @@ export default {
}
},
mounted() {
window.addEventListener('resize', this.handleResize);
//this.operateList = this.$getBtns(['修改'])
console.log('mounted')
// 优先加载第一个页面(activeKey=1)所需的数据
@@ -728,6 +733,13 @@ export default {
clearInterval(this.interval) // 组件销毁时清除定时器
},
methods: {
handleResize() {
const elementTable = document.getElementsByClassName('content-table-4')[0]
if (elementTable) {
this.tableH = elementTable.offsetHeight - 20
}
},
operateForm(type, record = {}) {
if (type == 'output') {
this.loading.chart=true
@@ -935,16 +947,20 @@ export default {
async getEGridPeriod() {
const query = {
dt: this.paramsDate.end_date,
dt_start:this.paramsDate.start_date,
dt_end: this.paramsDate.end_date,
station_id: this.stationId,
}
if (!query.dt) {
if (!query.dt_end) {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0'); // 处理月份:先+1因为getMonth返回0-11再补零到2位
const day = String(today.getDate()).padStart(2, '0'); // 处理日期直接补零到2位
query.dt = `${year}-${month}-${day}`; // 拼接成指定格式
query.dt_end = `${year}-${month}-${day}`; // 拼接成指定格式
}
if (!query.dt_start) {
query.dt_start = query.dt_end;
}
try {
@@ -995,6 +1011,18 @@ export default {
color: #a6b8dd;
background-color: $bg2-color;
}
.content-table-4 {
// overflow: scroll;
width: 100%;
height: calc(100% - 52px);
min-height: 0;
//overflow: hidden;
// :deep(.ant-table-wrapper) {
// min-height: 0px;
// }
}
}
.main_content {
overflow: scroll;
@@ -1016,6 +1044,8 @@ export default {
}
}
:deep(.ant-modal-body) {
:deep(.ant-table-wrapper .ant-table-row-expand-icon) {
color: $green !important;
@@ -1041,5 +1071,12 @@ export default {
:deep(.ant-table-wrapper .ant-table-thead > tr > th) {
border-bottom: none !important;
}
:deep(.ant-table-container) {
flex: 1; /* 👈 用这个,不要用 % */
margin-top: 0px; /* 👈 这里实现“减去150px”效果 */
//height: calc(100% - 150px);;
// height: 500px;
// overflow-y: auto;
}
</style>