mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
修改策略分析页面数据查询接口和表格显示数据变化时表格高度异常的问题
This commit is contained in:
@@ -1981,10 +1981,12 @@ static float SetPeriodRowJson(njson& jsonrow, std::string period, int eIn, int e
|
||||
Errcode HttpEntity::queryEGridPeriod(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
Fields params;
|
||||
GetRequestParams(req, {"dt", "station_id"}, params);
|
||||
GetRequestParams(req, {"dt_start", "dt_end", "station_id"}, params);
|
||||
|
||||
int stationId = params.get<int>("station_id");
|
||||
std::string dt = params.value("dt");
|
||||
std::string dtStart = params.value("dt_start");
|
||||
std::string dtEnd = params.value("dt_end");
|
||||
|
||||
//int year = 0;
|
||||
//int month = 0;
|
||||
//int day = 0;
|
||||
@@ -1993,7 +1995,7 @@ Errcode HttpEntity::queryEGridPeriod(const httplib::Request& req, njson& json, s
|
||||
//{
|
||||
// return Errcode::ERR_PARAM;
|
||||
//}
|
||||
if (stationId == 0 || dt.empty())
|
||||
if (stationId == 0 || dtStart.empty() || dtEnd.empty())
|
||||
{
|
||||
return Errcode::ERR_PARAM;
|
||||
}
|
||||
@@ -2025,25 +2027,28 @@ Errcode HttpEntity::queryEGridPeriod(const httplib::Request& req, njson& json, s
|
||||
}
|
||||
|
||||
//std::string sql = std::format("SELECT ep.*, ep2.price FROM egrid_period ep LEFT JOIN egrid_price ep2 ON ep.etype=ep2.etype WHERE ep.`month`={};", month);
|
||||
std::string sql = std::format("select * from stat_total_day WHERE dt='{}' AND station_id='{}';", dt, stationId);
|
||||
std::string sql = std::format("select * from stat_total_day WHERE dt>='{}' AND dt<='{}' AND station_id='{}';", dtStart, dtEnd, stationId);
|
||||
err = DAO::exec(NULL, sql, result);
|
||||
if (err != Errcode::OK)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
int totalIn {};
|
||||
int totalOut {};
|
||||
float totalIncome {0.0f};
|
||||
|
||||
njson jsondata = njson::array();
|
||||
if (result.size() > 0)
|
||||
for (auto& item: result)
|
||||
{
|
||||
auto& item = result[0];
|
||||
float incomeTotal = 0.0f;
|
||||
std::string dt = item.get<std::string>("dt");
|
||||
// 谷
|
||||
{
|
||||
njson jsonrow;
|
||||
float income = SetPeriodRowJson(jsonrow, "谷", item.get<int>("E_in_G"), item.get<int>("E_out_G"), priceG, priceC, dt);
|
||||
jsonrow["income"] = Utils::toStr(income);
|
||||
jsondata.push_back(jsonrow);
|
||||
incomeTotal += income;
|
||||
totalIncome += income;
|
||||
}
|
||||
// 平
|
||||
{
|
||||
@@ -2051,7 +2056,7 @@ Errcode HttpEntity::queryEGridPeriod(const httplib::Request& req, njson& json, s
|
||||
float income = SetPeriodRowJson(jsonrow, "平", item.get<int>("E_in_P"), item.get<int>("E_out_P"), priceP, priceC, dt);
|
||||
jsonrow["income"] = Utils::toStr(income);
|
||||
jsondata.push_back(jsonrow);
|
||||
incomeTotal += income;
|
||||
totalIncome += income;
|
||||
}
|
||||
// 峰
|
||||
{
|
||||
@@ -2059,7 +2064,7 @@ Errcode HttpEntity::queryEGridPeriod(const httplib::Request& req, njson& json, s
|
||||
float income = SetPeriodRowJson(jsonrow, "峰", item.get<int>("E_in_F"), item.get<int>("E_out_F"), priceF, priceC, dt);
|
||||
jsonrow["income"] = Utils::toStr(income);
|
||||
jsondata.push_back(jsonrow);
|
||||
incomeTotal += income;
|
||||
totalIncome += income;
|
||||
}
|
||||
// 尖
|
||||
{
|
||||
@@ -2067,21 +2072,24 @@ Errcode HttpEntity::queryEGridPeriod(const httplib::Request& req, njson& json, s
|
||||
float income = SetPeriodRowJson(jsonrow, "尖", item.get<int>("E_in_J"), item.get<int>("E_out_J"), priceJ, priceC, dt);
|
||||
jsonrow["income"] = Utils::toStr(income);
|
||||
jsondata.push_back(jsonrow);
|
||||
incomeTotal += income;
|
||||
totalIncome += income;
|
||||
}
|
||||
totalIn += item.get<int>("E_in");
|
||||
totalOut += item.get<int>("E_out");
|
||||
}
|
||||
// 总计
|
||||
{
|
||||
njson jsonrow;
|
||||
jsonrow["dt"] = dt;
|
||||
jsonrow["dt"] = "";
|
||||
jsonrow["period"] = "总计";
|
||||
jsonrow["E_in"] = item.get<int>("E_in");
|
||||
jsonrow["E_out"] = item.get<int>("E_out");
|
||||
jsonrow["E_in"] = totalIn;
|
||||
jsonrow["E_out"] = totalOut;
|
||||
jsonrow["grid_price"] = "";
|
||||
jsonrow["charge_price"] = "";
|
||||
jsonrow["income"] = Utils::toStr(incomeTotal);
|
||||
jsonrow["income"] = Utils::toStr(totalIncome);
|
||||
jsondata.push_back(jsonrow);
|
||||
}
|
||||
}
|
||||
|
||||
json["data"] = jsondata;
|
||||
return Errcode::OK;
|
||||
}
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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: []
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -58,17 +58,16 @@
|
||||
</a-spin>
|
||||
</div>
|
||||
|
||||
<div v-if="activeKey == 4" style="height:800px">
|
||||
|
||||
<div v-if="activeKey == 4" class="content-table-4" >
|
||||
<ComTable
|
||||
:tableH="tableH"
|
||||
:columns="columns"
|
||||
:table-data="tableData"
|
||||
:table-option="{ page: false, select: false }">
|
||||
: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>
|
||||
|
||||
Reference in New Issue
Block a user