diff --git a/src/apis/dashboard/index.js b/src/apis/dashboard/index.js index 4d60e1d..b6bc297 100644 --- a/src/apis/dashboard/index.js +++ b/src/apis/dashboard/index.js @@ -70,11 +70,13 @@ export const getDashboardTemp = async ({ timeInterval, tempOption, building_guid, + option }) => { const res = await instance.post(GET_DASHBOARD_TEMP_API, { timeInterval, tempOption, building_guid, + option }); return apihandler(res.code, res.data, { diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index 9548b61..ae2313e 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -56,7 +56,7 @@ const getData = async () => { const y = coordinates[1]; // 決定設備狀態和顏色 - let state = "online"; + let state = "Online"; let bgColor = device.device_normal_color; if (device.device_status === "Offline" || device.device_status === null) { diff --git a/src/views/dashboard/components/DashboardHumidity.vue b/src/views/dashboard/components/DashboardHumidity.vue index 11ba8c1..5080e0a 100644 --- a/src/views/dashboard/components/DashboardHumidity.vue +++ b/src/views/dashboard/components/DashboardHumidity.vue @@ -63,13 +63,14 @@ const getData = async (tempOption) => { building_guid: buildingStore.selectedBuilding.building_guid, tempOption, // 1:室溫 2:冷藏 timeInterval: 1, // 時間間隔=>1.4.8 + option: 2, // 2:濕度 }); if (res.isSuccess) { if (tempOption === 1) { - console.log("室內溫度資料:", res.data["室溫"]); + console.log("室內溼度資料:", res.data["室溫"]); data.value = res.data["室溫"] || []; } else { - console.log("冷藏溫度資料:", res.data["冷藏溫度"]); + console.log("冷藏溼度資料:", res.data["冷藏溫度"]); data.value = res.data["冷藏溫度"] || []; } } @@ -81,29 +82,15 @@ watch( (newValue) => { if (newValue) { // 根據 sysConfig 設定動態生成按鈕 - const itemsArr = []; - if (buildingStore.sysConfig?.show_room) { - itemsArr.push({ - title: "室內溫度", - key: 1, - active: false, - }); - } - if (buildingStore.sysConfig?.show_refrigeration) { - itemsArr.push({ - title: "冷藏溫度", - key: 2, - active: false, - }); - } - if (itemsArr.length > 0) { - itemsArr[0].active = true; - - // getData(itemsArr[0].key); - // timeoutTimer.value = setInterval(() => { - // getData(itemsArr[0].key); - // }, 60 * 1000); - } + const itemsArr = buildingStore.sysConfig?.humiture_options + ? Object.entries(buildingStore.sysConfig.humiture_options).map( + ([key, title], index) => ({ + key: Number(key), + title, + active: index === 0, + }) + ) + : []; setItems(itemsArr); } else { // 清除定時器 diff --git a/src/views/dashboard/components/DashboardSysCard.vue b/src/views/dashboard/components/DashboardSysCard.vue index 4f6a35b..81d8a04 100644 --- a/src/views/dashboard/components/DashboardSysCard.vue +++ b/src/views/dashboard/components/DashboardSysCard.vue @@ -23,12 +23,19 @@ const currentData = computed(() => {
- + class="border-2 rounded-lg shadow-sm shadow-slate-100 p-2 me-2" + :style="{ + backgroundColor: device[2]?.bgColor, + }" + > + +
{{ device[2]?.full_name }}
@@ -37,8 +44,7 @@ const currentData = computed(() => { {{ $t("system.status") }}: @@ -107,7 +113,7 @@ const currentData = computed(() => { display: flex; align-items: center; position: relative; - margin-bottom: 15px; + margin-bottom: 10px; } .item .sec02::after { @@ -123,7 +129,7 @@ const currentData = computed(() => { } .item .sec02 img { - margin-right: 10px; + /* margin-right: 10px; */ width: 1.5rem !important; height: 1.5rem; } diff --git a/src/views/dashboard/components/DashboardTemp.vue b/src/views/dashboard/components/DashboardTemp.vue index 22df43d..efa0094 100644 --- a/src/views/dashboard/components/DashboardTemp.vue +++ b/src/views/dashboard/components/DashboardTemp.vue @@ -63,6 +63,7 @@ const getData = async (tempOption) => { building_guid: buildingStore.selectedBuilding.building_guid, tempOption, // 1:室溫 2:冷藏 timeInterval: 1, // 時間間隔=>1.4.8 + option: 1, // 1:即時溫度 }); if (res.isSuccess) { if (tempOption === 1) { @@ -81,29 +82,15 @@ watch( (newValue) => { if (newValue) { // 根據 sysConfig 設定動態生成按鈕 - const itemsArr = []; - if (buildingStore.sysConfig?.show_room) { - itemsArr.push({ - title: "室內溫度", - key: 1, - active: false, - }); - } - if (buildingStore.sysConfig?.show_refrigeration) { - itemsArr.push({ - title: "冷藏溫度", - key: 2, - active: false, - }); - } - if (itemsArr.length > 0) { - itemsArr[0].active = true; - - // getData(itemsArr[0].key); - // timeoutTimer.value = setInterval(() => { - // getData(itemsArr[0].key); - // }, 60 * 1000); - } + const itemsArr = buildingStore.sysConfig?.humiture_options + ? Object.entries(buildingStore.sysConfig.humiture_options).map( + ([key, title], index) => ({ + key: Number(key), + title, + active: index === 0, + }) + ) + : []; setItems(itemsArr); } else { // 清除定時器 @@ -157,7 +144,9 @@ watch( data: newValue.map(({ full_name }) => full_name), }, xAxis: { - data: firstItem.data.map(({ time }) => dayjs(time).format("HH:mm:ss")), + data: firstItem.data.map(({ time }) => + dayjs(time).format("HH:mm:ss") + ), }, yAxis: { min: Math.floor(minValue), diff --git a/src/views/history/components/HistoryDataCahrt.vue b/src/views/history/components/HistoryDataCahrt.vue index 0ce68ea..2517f94 100644 --- a/src/views/history/components/HistoryDataCahrt.vue +++ b/src/views/history/components/HistoryDataCahrt.vue @@ -61,7 +61,7 @@ const defaultChartOption = { axisLabel: { color: "#ffffff" }, // interval: 100, //Y 軸的刻度間隔 min: "dataMin", - max: "dataMax", + max: "dataMax", // splitArea: { show: false }, }, series: [],