From c5345db4629580782122b21eb9b66ffc956937c5 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Mon, 4 Nov 2024 18:11:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E6=BA=90=E7=AE=A1=E7=90=86api?= =?UTF-8?q?=E4=B8=B2=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/energy/api.js | 2 + src/apis/energy/index.js | 24 ++ src/config/cn.json | 9 +- src/config/tw.json | 9 +- src/config/us.json | 9 +- .../energyManagement/EnergyManagement.vue | 16 ++ .../components/BillingDegreeChart.vue | 65 +++--- .../components/CarbonEmissionChart.vue | 51 ++--- .../components/IntervalBillChart.vue | 213 ++++++++++-------- .../components/MonthlyElecBillChart.vue | 87 +++---- .../components/UsageInformation.vue | 75 ++++-- 11 files changed, 354 insertions(+), 206 deletions(-) create mode 100644 src/apis/energy/api.js create mode 100644 src/apis/energy/index.js diff --git a/src/apis/energy/api.js b/src/apis/energy/api.js new file mode 100644 index 0000000..1932442 --- /dev/null +++ b/src/apis/energy/api.js @@ -0,0 +1,2 @@ +export const GET_ELECUSE_DAY_API = `/api/Energe/GetElecUseDay`; +export const GET_TAI_POWER_API = `/api/Energe/GetTaipower`; \ No newline at end of file diff --git a/src/apis/energy/index.js b/src/apis/energy/index.js new file mode 100644 index 0000000..9c30d97 --- /dev/null +++ b/src/apis/energy/index.js @@ -0,0 +1,24 @@ +import { + GET_ELECUSE_DAY_API, + GET_TAI_POWER_API, +} from "./api"; +import instance from "@/util/request"; +import apihandler from "@/util/apihandler"; + +export const getElecUseDay = async () => { + const res = await instance.post(GET_ELECUSE_DAY_API); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const getTaipower = async () => { + const res = await instance.post(GET_TAI_POWER_API); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; \ No newline at end of file diff --git a/src/config/cn.json b/src/config/cn.json index 9ed1f53..26b3711 100644 --- a/src/config/cn.json +++ b/src/config/cn.json @@ -61,7 +61,14 @@ "monthly_elec_consumption": "每月用电分析", "monthly_carbon_emission_and_reduction": "每月碳排当量 (kgCO2e)", "monthly_bill_power": "每月计费度数 (kWh)", - "interval_bill_degree": "区间计费度数" + "interval_bill_degree": "区间计费度数", + "peak": "尖峰", + "semi_peak": "半尖峰", + "off_peak": "离峰", + "var_elec_cost": "流动电费", + "fixed_elec_cost": "基本电费", + "total_elec_cost": "总电费", + "carbon_equivalent": "碳排当量" }, "alarm": { "title": "显示警告", diff --git a/src/config/tw.json b/src/config/tw.json index 81c4a60..1414899 100644 --- a/src/config/tw.json +++ b/src/config/tw.json @@ -61,7 +61,14 @@ "monthly_elec_consumption": "每月用電分析", "monthly_carbon_emission_and_reduction": "每月碳排當量 (kgCO2e)", "monthly_bill_power": "每月計費度數 (kWh)", - "interval_bill_degree": "區間計費度數" + "interval_bill_degree": "區間計費度數", + "peak": "尖峰", + "semi_peak": "半尖峰", + "off_peak": "離峰", + "var_elec_cost": "流動電費", + "fixed_elec_cost": "基本電費", + "total_elec_cost": "總電費", + "carbon_equivalent": "碳排當量" }, "alarm": { "title": "顯示警告", diff --git a/src/config/us.json b/src/config/us.json index f4e198c..566bcc6 100644 --- a/src/config/us.json +++ b/src/config/us.json @@ -61,7 +61,14 @@ "monthly_elec_consumption": "Monthly electricity consumption analysis", "monthly_carbon_emission_and_reduction": "Monthly carbon emission equivalent (kgCO2e)", "monthly_bill_power": "Monthly billing power (kWh)", - "interval_bill_degree": "Interval billing degree" + "interval_bill_degree": "Interval billing degree", + "peak": "Peak", + "semi_peak": "Semi-Peak", + "off_peak": "Off-Peak", + "var_elec_cost": "Var. Elec. Cost", + "fixed_elec_cost": "Fixed Elec. Cost", + "total_elec_cost": "Total Elec. Cost", + "carbon_equivalent": "Carbon Equivalent" }, "alarm": { "title": "Warning", diff --git a/src/views/energyManagement/EnergyManagement.vue b/src/views/energyManagement/EnergyManagement.vue index 6072a78..4e397ca 100644 --- a/src/views/energyManagement/EnergyManagement.vue +++ b/src/views/energyManagement/EnergyManagement.vue @@ -6,6 +6,22 @@ import MonthlyElecBillChart from "./components/MonthlyElecBillChart.vue"; import CarbonEmissionChart from "./components/CarbonEmissionChart.vue"; import BillingDegreeChart from "./components/BillingDegreeChart.vue"; import IntervalBillChart from "./components/IntervalBillChart.vue"; +import { getTaipower } from "@/apis/energy"; +import { ref, onMounted, provide } from "vue"; + +const taipower_data = ref([]); +const getData = async () => { + const res = await getTaipower(); + if (res.isSuccess) { + taipower_data.value = res.data; + } +}; + +onMounted(() => { + getData(); +}); + +provide("energy_data", { taipower_data });