141 lines
3.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-03-31 18:24:37 +08:00
<MonitoringTop />
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-03-31 18:24:37 +08:00
<DeviceHistory>
<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-03-31 18:24:37 +08:00
<EmergencyList :tableData="tableData" :page="page" :getData="getData" :changePage="changePage"></EmergencyList>
</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="chartRef2" style="width: 100%; height: 100%"></div>
</template>
</OnLineStatistics>
</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";
import EmergencyList from "./emergencyList.vue";
import * as echarts from "echarts";
import { MapCustom } from "@/utils/mapCustom";
import { fetchData } from "@/api/index";
import { TableItem } from "@/types/table";
2025-04-01 18:07:18 +08:00
import { onMounted, ref, reactive, onDeactivated } from "vue";
import { debounce } from "@/utils";
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-03-31 18:24:37 +08:00
const option = {
xAxis: {
type: "category",
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
yAxis: {
type: "value",
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: "line",
smooth: true,
},
],
};
let option1 = {
tooltip: {
trigger: "item",
},
legend: {
right: "left",
},
series: [
{
name: "Access From",
type: "pie",
radius: ["20%", "50%"],
data: [
{ value: 1048, name: "常规模式" },
{ value: 735, name: "户外押送" },
{ value: 580, name: "审讯模式" },
],
},
],
};
const page = reactive({
index: 1,
size: 10,
total: 200,
});
const tableData = ref<TableItem[]>([]);
const getData = async () => {
const res = await fetchData();
tableData.value = res.data.list;
};
getData();
const changePage = (val: number) => {
page.index = val;
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-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-03-31 18:24:37 +08:00
myChart.setOption(option);
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-03-31 18:24:37 +08:00
myChart2.setOption(option1);
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>