149 lines
3.7 KiB
Vue

<template>
<div class="deviceStatistics card">
<div class="card-head">
<div class="title">告警列表</div>
<div class="condition">
<el-input style="width: 240px" v-model="search" placeholder="搜索设备IMEI号" :suffix-icon="Search" @input="handleInput" />
</div>
</div>
<TableCustom :columns="columns" :tableData="tableData" :paging="paging" :changePage="changePage">
<template #location="{ rows }">
<el-button type="success" link v-if="rows.warnType == 0 || rows.warnType == 1" @click="toIncidentDispose(rows.id)"> 查看 </el-button>
<div v-else>--</div>
</template>
<template #operator="{ rows }">
<el-button type="primary" v-if="!rows.status" size="small" link @click="toIncidentDispose(rows.id)"> 处理事件 </el-button>
<div v-else>--</div>
</template>
<template #warnType="{ rows }">
{{ warnTypeEnum[rows.warnType] }}
</template>
<template #status="{ rows }">
<el-tag :type="rows.status == 1 ? 'success' : 'danger'">
{{ statusEnum[rows.status] }}
</el-tag>
</template>
</TableCustom>
</div>
</template>
<script setup lang="ts">
import { Search, View } from "@element-plus/icons-vue";
import TableCustom from "@/components/table-custom.vue";
import { useRouter } from "vue-router";
import { TWarnRecord } from "@/api/index.d";
import { onMounted, ref, reactive } from "vue";
import { warnRecord } from "@/api/index";
import { debounce, format } from "@/utils";
const router = useRouter();
enum statusEnum {
"待处理",
"已处理",
}
enum warnTypeEnum {
"SOS告警",
"围栏告警",
"破坏告警",
"低电告警",
"心率告警",
"血氧告警",
"体温告警",
}
const search = ref("");
let d = new Date();
const paging = reactive({
page: 1,
size: 5,
total: 0,
deviceId: null,
startDate: `${format(d, "YYYY-MM-DD")} 00:00:00`,
endDate: `${format(d, "YYYY-MM-DD")} 23:59:59`,
});
const tableData = ref<TWarnRecord.IListRes[]>([]);
const getData = async () => {
try {
const res = await warnRecord(paging);
tableData.value = res.records;
paging.total = res.total;
} catch (error) {}
};
const changePage = (val: number) => {
paging.page = val;
getData();
};
// 表格相关
let columns = [
{ type: "index", label: "序号", width: 55, align: "center" },
{ prop: "deviceId", label: "IMEI号" },
{ prop: "warnType", label: "事件类型" },
{ prop: "createTime", label: "时间" },
{ prop: "location", label: "地理位置" },
{ prop: "status", label: "处理状态" },
{ prop: "operator", label: "操作" },
];
const handleInput = debounce((e) => {
paging.deviceId = e;
getData();
}, 500);
const toIncidentDispose = (id: string) => {
router.push({
path: "/incidentDispose",
query: { id },
});
};
onMounted(() => {
getData();
});
</script>
<style scoped lang="less">
.card {
height: 100%;
background: #ffffff;
padding: 16px 10px;
box-sizing: border-box;
overflow: hidden;
display: flex;
flex-direction: column;
border-radius: 5px;
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
margin-bottom: 20px;
.card-head {
color: #061451;
font-size: 18px;
display: flex;
align-items: center;
justify-content: space-between;
transform: translateX(-10px);
.title {
&::before {
display: inline-block;
margin-right: 10px;
content: "";
width: 2px;
height: 14px;
border-radius: 20px;
background: #061451;
}
}
.condition {
display: flex;
align-items: center;
margin-left: 20px;
.condition-time {
border: 1px solid #dcdfe6;
overflow: hidden;
margin-left: 20px;
}
}
}
}
</style>