From 72721608e35016ae3cae3a5c4d8c79a09aa767c7 Mon Sep 17 00:00:00 2001 From: lixiaoyuan Date: Fri, 8 May 2026 16:57:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AD=96=E7=95=A5=E5=88=86?= =?UTF-8?q?=E6=9E=90=E9=A1=B5=E9=9D=A2=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=92=8C=E8=A1=A8=E6=A0=BC=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=98=E5=8C=96=E6=97=B6=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/protocol/HttpEntity.cpp | 54 ++++++++------- web/src/components/ComTable.vue | 13 +++- .../components/Home/Modal/StationCurrent.vue | 4 +- web/src/components/Home/MyChartBar.vue | 4 +- web/src/views/statisticalAnalysis.vue | 67 ++++++++++++++----- 5 files changed, 98 insertions(+), 44 deletions(-) diff --git a/src/protocol/HttpEntity.cpp b/src/protocol/HttpEntity.cpp index 6196814..aa7131e 100644 --- a/src/protocol/HttpEntity.cpp +++ b/src/protocol/HttpEntity.cpp @@ -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("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("dt"); // 谷 { njson jsonrow; float income = SetPeriodRowJson(jsonrow, "谷", item.get("E_in_G"), item.get("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("E_in_P"), item.get("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("E_in_F"), item.get("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("E_in_J"), item.get("E_out_J"), priceJ, priceC, dt); jsonrow["income"] = Utils::toStr(income); jsondata.push_back(jsonrow); - incomeTotal += income; - } - // 总计 - { - njson jsonrow; - jsonrow["dt"] = dt; - jsonrow["period"] = "总计"; - jsonrow["E_in"] = item.get("E_in"); - jsonrow["E_out"] = item.get("E_out"); - jsonrow["grid_price"] = ""; - jsonrow["charge_price"] = ""; - jsonrow["income"] = Utils::toStr(incomeTotal); - jsondata.push_back(jsonrow); + totalIncome += income; } + totalIn += item.get("E_in"); + totalOut += item.get("E_out"); } + // 总计 + { + njson jsonrow; + jsonrow["dt"] = ""; + jsonrow["period"] = "总计"; + jsonrow["E_in"] = totalIn; + jsonrow["E_out"] = totalOut; + jsonrow["grid_price"] = ""; + jsonrow["charge_price"] = ""; + jsonrow["income"] = Utils::toStr(totalIncome); + jsondata.push_back(jsonrow); + } + json["data"] = jsondata; return Errcode::OK; } \ No newline at end of file diff --git a/web/src/components/ComTable.vue b/web/src/components/ComTable.vue index 9d2e69a..a522250 100644 --- a/web/src/components/ComTable.vue +++ b/web/src/components/ComTable.vue @@ -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) => { diff --git a/web/src/components/Home/Modal/StationCurrent.vue b/web/src/components/Home/Modal/StationCurrent.vue index e29c569..13b9802 100644 --- a/web/src/components/Home/Modal/StationCurrent.vue +++ b/web/src/components/Home/Modal/StationCurrent.vue @@ -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: [] diff --git a/web/src/components/Home/MyChartBar.vue b/web/src/components/Home/MyChartBar.vue index 910c573..73df136 100644 --- a/web/src/components/Home/MyChartBar.vue +++ b/web/src/components/Home/MyChartBar.vue @@ -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 { diff --git a/web/src/views/statisticalAnalysis.vue b/web/src/views/statisticalAnalysis.vue index 4a621a6..f2fbc66 100644 --- a/web/src/views/statisticalAnalysis.vue +++ b/web/src/views/statisticalAnalysis.vue @@ -58,17 +58,16 @@ -
- - - - - +
+ + +
@@ -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; +}