130 lines
3.3 KiB
Vue
Raw Normal View History

2025-03-31 18:24:37 +08:00
<template>
<div class="deviceStatistics card">
<div class="card-head">
<div class="title">当前设备告警记录</div>
<div class="search">
2025-04-10 13:33:38 +08:00
<el-select class="select" placeholder="请选择事件类型" v-model="paging.warnType" style="width: 150px; margin-right: 20px" @change="handelChange">
2025-04-12 18:35:54 +08:00
<el-option label="全部" value="" />
2025-04-10 13:33:38 +08:00
<el-option v-for="(item, index) in warnTypeList" :key="index" :label="item" :value="index" />
2025-03-31 18:24:37 +08:00
</el-select>
2025-04-10 13:33:38 +08:00
<el-select class="select" placeholder="请选择处理状态" v-model="paging.status" style="width: 150px" @change="handelChange">
2025-04-12 18:35:54 +08:00
<el-option label="全部" value="" />
2025-04-10 13:33:38 +08:00
<el-option label="待处理" value="0" />
<el-option label="已处理" value="1" />
2025-03-31 18:24:37 +08:00
</el-select>
</div>
</div>
2025-04-10 13:33:38 +08:00
<TableCustom :columns="columns" :tableData="tableData" :paging="paging" :changePage="changePage">
<template #status="{ rows }">
<el-tag :type="statusColor[rows.status]">{{ warningStatusEnum[rows.status] }}</el-tag>
</template>
<template #warnType="{ rows }">
{{ warnTypeEnum[rows.warnType] }}
2025-03-31 18:24:37 +08:00
</template>
</TableCustom>
</div>
</template>
2025-04-10 13:33:38 +08:00
<script setup lang="ts">
import TableCustom from "@/components/table-custom.vue";
import { warningRecord } from "@/api/index";
import { ref, reactive, watch } from "vue";
import { TDevice } from "@/api/index.d";
const statusColor = ["danger", "success"];
enum warningStatusEnum {
"待处理",
"已处理",
}
enum warnTypeEnum {
"SOS告警",
"围栏告警",
"破坏告警",
"低电告警",
"心率告警",
"血氧告警",
"体温告警",
}
const warnTypeList = ["SOS告警", "围栏告警", "破坏告警", "低电告警", "心率告警", "血氧告警", "体温告警"];
const paging = reactive({
page: 1,
size: 4,
total: 0,
deviceId: undefined,
status: undefined,
warnType: undefined,
});
const tableData = ref<TDevice.IWarningRecordRes[]>([]);
const props = defineProps({
deviceInfo: {
2025-03-31 18:24:37 +08:00
type: Object,
2025-04-10 13:33:38 +08:00
default: undefined,
2025-03-31 18:24:37 +08:00
},
});
// 表格相关
let columns = [
{ type: "index", label: "序号", width: 55, align: "center" },
2025-04-10 13:33:38 +08:00
{ prop: "warnType", label: "事件类型" },
{ prop: "status", label: "处理状态" },
{ prop: "createTime", label: "触发时间" },
2025-03-31 18:24:37 +08:00
];
2025-04-10 13:33:38 +08:00
const getData = async () => {
const res = await warningRecord(paging);
tableData.value = res.records;
paging.total = res.total;
};
const handelChange = () => {
paging.page = 1;
getData();
};
const changePage = (val: number) => {
paging.page = val;
getData();
};
2025-04-25 18:23:20 +08:00
watch(
() => props.deviceInfo,
(newVal) => {
if (newVal) {
paging.deviceId = newVal.deviceId;
getData && getData();
}
},
{ immediate: true } // 关键选项
);
2025-03-31 18:24:37 +08:00
</script>
<style scoped lang="less">
.card {
background: #ffffff;
padding: 16px 10px;
box-sizing: border-box;
.card-head {
color: #061451;
2025-04-08 18:31:37 +08:00
font-size: 18px;
2025-03-31 18:24:37 +08:00
display: flex;
align-items: center;
justify-content: space-between;
2025-04-01 13:52:57 +08:00
transform: translateX(-10px);
2025-03-31 18:24:37 +08:00
.title {
&::before {
display: inline-block;
margin-right: 10px;
content: "";
width: 2px;
height: 14px;
border-radius: 20px;
background: #061451;
}
}
.search {
display: flex;
align-items: center;
}
}
}
</style>