即時告警假資料 | webUser顯示登入帳號的名稱 | Display Name的欄位 改成 Mac | 歷史資料:常用組合的按鈕隱藏、TiTle像是UI選項、設備名稱要改 | 能源管理介面修改

This commit is contained in:
WIN-VB61HI6M32L\Administrator 2024-10-21 17:54:30 +08:00
parent dbe0be5cf6
commit 334d0d5212
18 changed files with 82 additions and 131 deletions

View File

@ -17,7 +17,7 @@ const ackedAlarm = async (uuid) => {
<template>
<div>
<ul class="py-6 pr-4 min-h-full text-base-content">
<ul class="pr-4 min-h-full text-base-content">
<!-- Sidebar content here -->
<li class="my-3" v-for="alarm in store.alarmData" :key="alarm.uuid">
<div

View File

@ -1,7 +1,6 @@
<script setup>
import { onMounted, ref } from "vue";
import AlarmCards from "./AlarmCards.vue";
import { twMerge } from "tailwind-merge";
const showErr = ref(false);
const toggleErrIcon = () => {
@ -36,12 +35,8 @@ const toggleErrIcon = () => {
</label>
</div>
<div
:class="
twMerge(
'drawer-side translate-y-20 max-h-[90vh] overflow-x-hidden',
showErr ? 'overflow-y-scroll' : ''
)
"
v-if="showErr"
class="drawer-side translate-y-20 max-h-[90vh] overflow-x-hidden overflow-y-scroll"
>
<AlarmCards />
</div>

View File

@ -3,7 +3,7 @@ import { onMounted, ref } from "vue";
import NavbarItem from "./NavbarItem.vue";
import NavbarBuilding from "./NavbarBuilding.vue";
import Logo from "@/assets/img/logo.svg";
import useGetCookie from "@/hooks/useGetCookie";
import useUserInfoStore from "@/stores/useUserInfoStore";
import AlarmDrawer from "@/components/alarm/AlarmDrawer.vue";
import NavbarLang from "./NavbarLang.vue";
import { twMerge } from "tailwind-merge";
@ -11,8 +11,9 @@ import { twMerge } from "tailwind-merge";
const user = ref("");
const menuShow = ref(true);
const store = useUserInfoStore();
onMounted(() => {
const name = useGetCookie("niagara_userid");
const name = store.user.user_name;
if (name) {
user.value = name;
}
@ -92,11 +93,12 @@ const src = import.meta.env.MODE === "production" ? "./logo.svg" : Logo;
class="dropdown-content translate-y-2 z-[100] menu py-3 shadow rounded w-32 bg-[#4c625e] border text-center"
>
<li class="text-white">
<a
href="/logout"
<router-link
to="logout"
type="link"
class="flex flex-col justify-center items-center"
>{{ $t("sign_out") }}
</a>
</router-link>
</li>
</ul>
</div>

View File

@ -53,7 +53,7 @@
"year_elec_consumption": "今年用电度数(kWh)",
"interval_elec_consumption": "区间用电度数(kWh)",
"monthly_elec_consumption": "每月用电分析",
"monthly_carbon_emission_and_reduction": "每月碳排当量 (kgCO2e) 与减量目标",
"monthly_carbon_emission_and_reduction": "每月碳排当量 (kgCO2e)",
"monthly_bill_power": "每月计费度数 (kWh)",
"interval_bill_degree": "区间计费度数"
},

View File

@ -53,7 +53,7 @@
"year_elec_consumption": "今年用電度數(kWh)",
"interval_elec_consumption": "區間用電度數(kWh)",
"monthly_elec_consumption": "每月用電分析",
"monthly_carbon_emission_and_reduction": "每月碳排當量 (kgCO2e) 與減量目標",
"monthly_carbon_emission_and_reduction": "每月碳排當量 (kgCO2e)",
"monthly_bill_power": "每月計費度數 (kWh)",
"interval_bill_degree": "區間計費度數"
},

View File

@ -53,7 +53,7 @@
"year_elec_consumption": "This year's electricity consumption (kWh)",
"interval_elec_consumption": "Interval electricity consumption (kWh)",
"monthly_elec_consumption": "Monthly electricity consumption analysis",
"monthly_carbon_emission_and_reduction": "Monthly carbon emission equivalent (kgCO2e) and reduction target",
"monthly_carbon_emission_and_reduction": "Monthly carbon emission equivalent (kgCO2e)",
"monthly_bill_power": "Monthly billing power (kWh)",
"interval_bill_degree": "Interval billing degree"
},

View File

@ -108,6 +108,7 @@ router.beforeEach(async (to, from, next) => {
if (to.path === "/logout") {
document.cookie = "JWT-Authorization=";
auth.user.token = "";
window.location.reload();
next({ path: "/login" });
}

View File

@ -13,77 +13,40 @@ const useAlarmStore = defineStore("alarmData", () => {
};
// get data from baja
const getAlarmDataFromBaja = () => {
window.require &&
window.requirejs(["baja!"], (baja) => {
let alarms = [];
baja.Ord.make(
`local:|foxs:|alarm:|bql:select * where sourceState = 'offnormal' order by timestamp desc`
).get({
cursor: {
before: () => {
timer = null;
},
each: (record) => {
const device_number = record
.get("alarmData")
.get("sourceName")
.split("_")
.slice(0, 8)
.join("_");
// console.log("getAlarm each", {
// uuid: record.get("uuid"),
// alarmClass: record.get("alarmClass"),
// timestamp_date: getFormateDate(
// record.get("timestamp").getJsDate(),
// "YYYY/MM/DD"
// ),
// timestamp_time: getFormateDate(
// record.get("timestamp").getJsDate(),
// "HH:mm:ss"
// ),
// device_number,
// msg: record.get("alarmData").get("msgText"),
// sourceState: record.get("sourceState").getDisplayTag(),
// normalTime: getFormateDate(
// record.get("normalTime").getJsDate()
// ),
// ackState: record.get("ackState").getDisplayTag(),
// ackedTime: getFormateDate(record.get("ackTime").getJsDate()),
// });
const alarms = [];
const sampleDeviceNames = ["AA", "DeviceB", "DeviceC", "DeviceD"];
const sampleMsgs = [
"Over temperature",
"Power failure",
"Sensor malfunction",
"Connection lost",
];
alarms.push({
uuid: record.get("uuid"),
timestamp_date: getFormateDate(
record.get("timestamp").getJsDate(),
"YYYY/MM/DD "
),
timestamp_time: getFormateDate(
record.get("timestamp").getJsDate(),
"HH:mm:ss"
),
alarmClass: record.get("alarmClass"),
device_number,
full_name: allDeviceList.value.find(
(d) => device_number === d.device_number
)?.full_name,
msg: record.get("alarmData").get("msgText"),
sourceState: record.get("sourceState").getDisplayTag(),
normalTime: getFormateDate(
record.get("normalTime").getJsDate()
),
ackState: record.get("ackState").getDisplayTag(),
ackedTime: getFormateDate(record.get("ackTime").getJsDate()),
});
},
after: () => {
alarmData.value = alarms;
timer = setTimeout(() => {
getAlarmDataFromBaja();
}, 2000);
},
},
});
for (let i = 0; i < 3; i++) {
const timestamp = Date.now() - Math.floor(Math.random() * 100000000);
const device_number = `NTPC_F1_Dust_EM_U9F_NA_AD_AA${Math.floor(Math.random() * 5) + 1}`;
alarms.push({
uuid: `uuid-${i+1}`,
building_tag: "U9F",
timestamp_date: new Date(timestamp).toLocaleDateString("en-US"),
timestamp_time: new Date(timestamp).toLocaleTimeString("en-US"),
alarmClass: `Class ${Math.floor(Math.random() * 3) + 1}`,
device_number,
full_name: `AA${Math.floor(Math.random() * 5) + 1}`,
msg: sampleMsgs[Math.floor(Math.random() * sampleMsgs.length)],
sourceState: "offnormal",
normalTime: new Date(timestamp).toLocaleString("en-US"),
ackState: "Unacked",
ackedTime:
Math.random() > 0.5
? new Date(timestamp).toLocaleString("en-US")
: null,
});
}
alarmData.value = alarms;
};
const getDevice = async () => {

View File

@ -109,7 +109,7 @@ const openCompanyAddModal = () => {
></Input
>
<Input :value="formState" width="270" name="operate_text">
<template #topLeft>{{ $t("assetManagement.operate_text") }}</template>
<template #topLeft>Mac</template>
<template #bottomLeft
><span class="text-error text-base">
{{ formErrorMsg.operate_text }}

View File

@ -186,7 +186,7 @@ const onCancel = () => {
:getCoordinate="getCoordinate"
:class="
twMerge(
'absolute top-0 left-0',
'absolute top-0 left-0 bg-white',
currentFloor?.floor_map_url ? 'opacity-1' : 'opacity-0'
)
"

View File

@ -49,7 +49,7 @@ const activeTab = computed(() => {
<ButtonGroup
:items="items"
:withLine="true"
class="mt-8 mb-6"
class="my-6"
:onclick="changeComponent"
/>
<component :is="activeTab.component"></component>

View File

@ -51,7 +51,7 @@ const activeTitle = computed(() => {
<ButtonGroup
:items="items"
:withLine="true"
class="mt-8 mb-6"
class="my-6"
:onclick="changeComponent"
/>
<component :is="activeTab.component"></component>

View File

@ -13,6 +13,8 @@ import {
} from "@/apis/operation";
import { getAccountUserList } from "@/apis/account";
import useBuildingStore from "@/stores/useBuildingStore";
import useAlarmStore from "@/stores/useAlarmStore";
const storeAlarm = useAlarmStore();
const { searchParams } = useSearchParam();
const { getAlarmByBaja, alarmData } = useAlarmData();
@ -93,6 +95,10 @@ const updateDataSource = (data) => {
const search = async () => {
tableLoading.value = true;
if (Object.keys(searchParams.value).length !== 0) {
storeAlarm.getAlarmDataFromBaja();
updateDataSource(storeAlarm.alarmData);
tableLoading.value = false;
/*
await getAlarmByBaja(
searchParams.value.start_created_at,
searchParams.value.end_created_at,
@ -127,6 +133,7 @@ const search = async () => {
tableLoading.value = false;
}
);
*/
}
};

View File

@ -258,7 +258,7 @@ const closeModal = () => {
class="btn btn-outline-success"
@click.prevent="onOk"
>
{{ $t("buttton.submit") }}
{{ $t("button.submit") }}
</button>
</template>
</Modal>

View File

@ -10,7 +10,7 @@ const defaultChartOption = ref({
},
},
legend: {
data: ["Carbon Equivalent", "Reduction Target"],
data: ["Carbon Equivalent"],
textStyle: {
color: "#ffffff",
fontSize: 14,
@ -62,18 +62,7 @@ const defaultChartOption = ref({
itemStyle: {
color: "#45f4ef",
},
},
{
name: "Reduction Target",
type: "bar",
data: [
5000, 6000, 6000, 7000, 9500, 9000, 10000, 11000, 10000, 7200, 6000,
5000,
],
itemStyle: {
color: "#ffd345",
},
},
}
],
});

View File

@ -16,26 +16,27 @@ const chartOption = {
nodeWidth: 20,
nodeGap: 10,
data: [
{ name: "總電錢", value: 100 },
{ name: "空調系統", value: 40 },
{ name: "照明系統", value: 25 },
{ name: "電梯系統", value: 15 },
{ name: "插座", value: 10 },
{ name: "其他", value: 10 },
{ name: "Total", value: 100 },
{ name: "HVAC System", value: 40 },
{ name: "Lighting System", value: 25 },
{ name: "Elevator System", value: 15 },
{ name: "Outlets", value: 10 },
{ name: "Others", value: 10 },
],
links: [
{ source: "總電錢", target: "空調系統", value: 40 },
{ source: "總電錢", target: "照明系統", value: 25 },
{ source: "總電錢", target: "電梯系統", value: 15 },
{ source: "總電錢", target: "插座", value: 10 },
{ source: "總電錢", target: "其他", value: 10 },
{ source: "Total", target: "HVAC System", value: 40 },
{ source: "Total", target: "Lighting System", value: 25 },
{ source: "Total", target: "Elevator System", value: 15 },
{ source: "Total", target: "Outlets", value: 10 },
{ source: "Total", target: "Others", value: 10 },
],
emphasis: {
focus: "adjacency",
},
label: {
position: "right",
fontSize: 12,
fontSize: 14,
color: "#fff",
},
itemStyle: {
borderWidth: 0,

View File

@ -134,14 +134,9 @@ onBeforeMount(() => {
<template>
<div class="flex flex-col custom-border p-4 mb-4">
<HistoryFavoriteOption class="mb-4" />
<div class="flex mb-4">
<button
:disabled="true"
class="btn btn-outline-success disabled:text-opacity-100 mr-4 my-1"
>
{{ $t("history.device_category") }}
</button>
<!-- <HistoryFavoriteOption class="mb-4" />-->
<div class="flex items-center gap-4 mb-4">
<h2 class="text-lg font-bold ps-2">{{ $t("history.device_category") }} :</h2>
<ButtonGroup
:items="sysTagItems"
:withLine="true"
@ -152,13 +147,8 @@ onBeforeMount(() => {
"
/>
</div>
<div class="flex mb-4">
<button
:disabled="true"
class="btn btn-outline-success text-white disabled:text-opacity-100 mr-4 my-1"
>
{{ $t("history.point") }}
</button>
<div class="flex items-center gap-4 mb-4">
<h2 class="text-lg font-bold ps-2">{{ $t("history.point") }} :</h2>
<ButtonGroup
v-if="searchParams?.Device_list"
:items="points"

View File

@ -1,5 +1,5 @@
<script setup>
import { onMounted, ref, watch } from "vue";
import { onMounted, ref, watch, inject } from "vue";
import { Login } from "@/apis/login";
import Image from "@/assets/img/logo.svg";
import * as yup from "yup";
@ -8,6 +8,7 @@ import { useRouter } from "vue-router";
import useUserInfoStore from "@/stores/useUserInfoStore";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const { openToast } = inject("app_toast");
const store = useUserInfoStore();
const router = useRouter();
@ -35,6 +36,8 @@ const doLogin = async () => {
if (res.isSuccess) {
store.user = res.data;
router.replace({ path: "/dashboard" });
} else {
openToast("error", res.msg);
}
};
</script>