調整首頁用電小卡的預設顯示 | 優化歷史數據點位獲取與顯示邏輯

This commit is contained in:
koko 2025-09-25 15:21:39 +08:00
parent eeac7a10a8
commit 348bbe09cb
2 changed files with 12 additions and 5 deletions

View File

@ -33,7 +33,7 @@ const floors = ref([]);
// //
const companyOptions = ref([]); const companyOptions = ref([]);
const { searchParams } = useSearchParams(); const { changeParams, searchParams } = useSearchParams();
let intervalId = null; let intervalId = null;
const init = async () => { const init = async () => {
@ -63,7 +63,8 @@ const getDevice = async (option = 1) => {
); );
return { return {
...meter, ...meter,
device_coordinate_3d: JSON.parse(dbidItem?.device_coordinate_3d) || null, device_coordinate_3d:
JSON.parse(dbidItem?.device_coordinate_3d) || null,
}; };
}); });
meterList.value = meters; meterList.value = meters;
@ -73,6 +74,11 @@ const getDevice = async (option = 1) => {
meterList.value[0]?.main_id !== undefined meterList.value[0]?.main_id !== undefined
) { ) {
selectedMeter.value = meterList.value[0].main_id; selectedMeter.value = meterList.value[0].main_id;
changeParams({
option: 5,
camera_position: meterList.value[0].camera_position,
target_position: meterList.value[0].target_position,
});
} }
} else if (res.data?.refrigerationData) { } else if (res.data?.refrigerationData) {
heatmapDevices.value = res.data.refrigerationData; heatmapDevices.value = res.data.refrigerationData;

View File

@ -109,8 +109,9 @@ const {
const getPoint = async (Device_list, Cumulant) => { const getPoint = async (Device_list, Cumulant) => {
const res = await getHistoryPoints({ Device_list, Cumulant }); const res = await getHistoryPoints({ Device_list, Cumulant });
const data = Array.isArray(res.data) ? res.data : [];
setPoints( setPoints(
res.data.map((d, index) => ({ data.map((d, index) => ({
...d, ...d,
title: d.item_name, title: d.item_name,
key: d.points, key: d.points,
@ -146,12 +147,12 @@ watch(searchParams, (newVal, oldValue) => {
: newVal.Device_list, : newVal.Device_list,
newVal.Cumulant newVal.Cumulant
); );
setSearchTypeItems([ setSearchTypeItems([
{ {
title: "IOT數據", title: "IOT數據",
key: 1, key: 1,
active: parseInt(newVal?.Cumulant) === 1, active: parseInt(newVal?.Cumulant) === 1,
}, },
{ {
title: "累積數據", title: "累積數據",