241 lines
6.3 KiB
Vue
Raw Normal View History

2025-03-31 18:24:37 +08:00
<template>
2025-04-01 13:52:57 +08:00
<div class="container scrollbar">
2025-04-07 18:35:54 +08:00
<MonitoringTop :list="funcList" />
2025-04-01 18:07:18 +08:00
<el-row :gutter="20">
<el-col class="elcol" :span="16" :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
2025-04-07 18:35:54 +08:00
<DeviceHistory :api="getStatisticsContent">
2025-03-31 18:24:37 +08:00
<template #chart>
<div ref="chartRef" style="flex: 1"></div>
</template>
</DeviceHistory>
</el-col>
2025-04-01 18:07:18 +08:00
<el-col class="elcol" :span="8" :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
2025-03-31 18:24:37 +08:00
<OnLineStatistics>
<template #chart>
<div ref="chartRef1" style="flex: 1"></div>
</template>
</OnLineStatistics>
</el-col>
</el-row>
2025-04-01 18:07:18 +08:00
<el-row :gutter="20">
<el-col class="elcol" :span="16" :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
2025-04-08 18:31:37 +08:00
<EmergencyList :tableData="tableData" :page="paging" :getData="getData" :changePage="changePage"></EmergencyList>
2025-03-31 18:24:37 +08:00
</el-col>
2025-04-01 18:07:18 +08:00
<el-col class="elcol" :span="8" :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
2025-04-08 18:31:37 +08:00
<StatisticsWarning>
2025-03-31 18:24:37 +08:00
<template #chart>
<div ref="chartRef2" style="width: 100%; height: 100%"></div>
</template>
2025-04-08 18:31:37 +08:00
</StatisticsWarning>
2025-03-31 18:24:37 +08:00
</el-col>
</el-row>
</div>
</template>
<script lang="ts" setup>
import MonitoringTop from "./monitoringTop.vue";
import DeviceHistory from "./deviceHistory.vue";
import OnLineStatistics from "./onLineStatistics.vue";
2025-04-08 18:31:37 +08:00
import StatisticsWarning from "./statisticsWarning.vue";
2025-03-31 18:24:37 +08:00
import EmergencyList from "./emergencyList.vue";
import * as echarts from "echarts";
import { MapCustom } from "@/utils/mapCustom";
2025-04-08 18:31:37 +08:00
import { statisticsDevice, statisticsContent, statisticsCount, statisticsWarningapi, warnRecord } from "@/api/index";
2025-04-01 18:07:18 +08:00
import { onMounted, ref, reactive, onDeactivated } from "vue";
import { debounce } from "@/utils";
2025-04-08 18:31:37 +08:00
import { TWarnRecord } from "@/api/index.d";
2025-04-07 18:35:54 +08:00
import handcuffs from "@/assets/img/handcuffs.png";
import onLine from "@/assets/img/onLine.png";
import report from "@/assets/img/report.png";
import newly from "@/assets/img/newly.png";
2025-03-31 18:24:37 +08:00
const chartRef = ref(null);
const chartRef1 = ref(null);
const chartRef2 = ref(null);
2025-04-01 18:07:18 +08:00
let myChart = null;
let myChart1 = null;
let myChart2 = null;
2025-04-07 18:35:54 +08:00
let funcList = ref([
{ title: "手铐总数", en: "SHOUKAOZONGSHU", icon: handcuffs, num: 0, color: "##71DDF9" },
{ title: "在线数量", en: "ZAIXIANSHULIANG", icon: onLine, num: 0, color: "##71DDF9" },
{ title: "告警数量", en: "GAOJINGSHULIANG", icon: report, num: 0, color: "#8B51FD" },
{ title: "较昨日新增", en: "JIAOZUORIXINZENG", icon: newly, num: 0, color: "#FF6905" },
]);
2025-04-08 18:31:37 +08:00
const option = ref({
tooltip: {
trigger: "axis",
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
2025-03-31 18:24:37 +08:00
xAxis: {
type: "category",
2025-04-08 18:31:37 +08:00
boundaryGap: false,
data: [],
2025-03-31 18:24:37 +08:00
},
yAxis: {
type: "value",
},
2025-04-08 18:31:37 +08:00
series: [],
});
let option1 = ref({
2025-03-31 18:24:37 +08:00
tooltip: {
trigger: "item",
},
legend: {
right: "left",
},
2025-04-08 18:31:37 +08:00
series: {
type: "pie",
radius: ["20%", "50%"],
data: [
{ value: 1048, name: "常规模式" },
{ value: 735, name: "户外押送" },
{ value: 580, name: "审讯模式" },
],
},
});
let option2 = ref({
tooltip: {
trigger: "item",
},
legend: {
right: "left",
},
series: {
type: "pie",
radius: ["20%", "50%"],
data: [
{ value: 0, name: "SOS告警" },
{ value: 0, name: "围栏告警" },
{ value: 0, name: "破坏告警" },
{ value: 0, name: "低电告警" },
{ value: 0, name: "心率告警" },
{ value: 0, name: "血氧告警" },
{ value: 0, name: "体温告警" },
],
},
});
2025-03-31 18:24:37 +08:00
2025-04-08 18:31:37 +08:00
const paging = reactive({
page: 1,
2025-03-31 18:24:37 +08:00
size: 10,
2025-04-08 18:31:37 +08:00
total: 0,
deviceId: "",
2025-03-31 18:24:37 +08:00
});
2025-04-08 18:31:37 +08:00
const tableData = ref<TWarnRecord.IListRes[]>([]);
2025-03-31 18:24:37 +08:00
const getData = async () => {
2025-04-08 18:31:37 +08:00
try {
const res = await warnRecord(paging);
tableData.value = res.records;
paging.total = res.total;
} catch (error) {}
2025-03-31 18:24:37 +08:00
};
2025-04-07 18:35:54 +08:00
const getStatisticsDevice = () => {
2025-04-08 18:31:37 +08:00
statisticsDevice().then((res) => {});
};
const getStatisticsWarningApi = () => {
statisticsWarningapi().then((res) => {
option1.value.series.data = [
{ value: res?.sosCount, name: "SOS告警" },
{ value: res?.railCount, name: "围栏告警" },
{ value: res?.destroyCount, name: "破坏告警" },
{ value: res?.batteryCount, name: "低电告警" },
{ value: res?.heartRateCount, name: "心率告警" },
{ value: res?.bloodOxygenCount, name: "血氧告警" },
{ value: res?.tempCount, name: "体温告警" },
];
myChart2.setOption(option2.value);
2025-04-07 18:35:54 +08:00
});
};
const getStatisticsContent = (res) => {
2025-04-08 18:31:37 +08:00
statisticsContent(res).then((res) => {
option.value.xAxis.data = res?.times;
option.value.series = [
{
stack: "Total",
name: "SOS预警数组",
data: res?.sosArr,
type: "line",
},
{
stack: "Total",
name: "围栏预警数组",
data: res?.railArr,
type: "line",
},
{
stack: "Total",
name: "破坏预警数组",
data: res?.destroyArr,
type: "line",
},
{
stack: "Total",
name: "生理预警数组",
data: res?.healthArr,
type: "line",
},
];
});
myChart.setOption(option.value);
};
const getStatisticsCount = () => {
statisticsCount().then((res) => {
funcList.value[0].num = res?.deviceTotal || 0;
funcList.value[1].num = res?.onlineCount || 0;
funcList.value[2].num = res?.warnCount || 0;
funcList.value[3].num = res?.addCount || 0;
});
2025-04-07 18:35:54 +08:00
};
2025-03-31 18:24:37 +08:00
const changePage = (val: number) => {
2025-04-08 18:31:37 +08:00
paging.page = val;
2025-03-31 18:24:37 +08:00
getData();
};
2025-04-01 18:07:18 +08:00
const handleResize = debounce(() => {
myChart.resize();
myChart1.resize();
myChart2.resize();
}, 200);
2025-03-31 18:24:37 +08:00
onMounted(() => {
2025-04-07 18:35:54 +08:00
getData();
2025-04-08 18:31:37 +08:00
getStatisticsCount();
getStatisticsWarningApi();
2025-04-07 18:35:54 +08:00
2025-04-01 18:07:18 +08:00
new MapCustom({ dom: "mapcontainer" });
2025-03-31 18:24:37 +08:00
2025-04-01 18:07:18 +08:00
if (chartRef.value) {
myChart = echarts.init(chartRef.value);
2025-04-08 18:31:37 +08:00
myChart.setOption(option.value);
2025-03-31 18:24:37 +08:00
2025-04-01 18:07:18 +08:00
myChart1 = echarts.init(chartRef1.value);
2025-03-31 18:24:37 +08:00
myChart1.setOption(option1);
2025-04-01 18:07:18 +08:00
myChart2 = echarts.init(chartRef2.value);
2025-04-08 18:31:37 +08:00
myChart2.setOption(option2.value);
2025-04-01 18:07:18 +08:00
window.addEventListener("resize", handleResize);
2025-03-31 18:24:37 +08:00
}
});
2025-04-01 18:07:18 +08:00
onDeactivated(() => {
window.removeEventListener("resize", handleResize);
});
2025-03-31 18:24:37 +08:00
</script>
2025-04-01 18:07:18 +08:00
<style lang="less" scoped>
.elcol {
height: 380px;
margin-bottom: 20px;
}
</style>