yak_handcuffs/src/views/statisticalCenter/onLineStatistics.vue

100 lines
2.1 KiB
Vue
Raw Normal View History

2025-03-31 18:24:37 +08:00
<template>
<div class="deviceStatistics card">
<div class="card-head">
2025-04-15 15:01:40 +08:00
<div class="title">使用设备统计</div>
2025-03-31 18:24:37 +08:00
</div>
2025-04-25 18:23:20 +08:00
<div class="card-chart">
2025-05-06 14:19:39 +08:00
<div ref="chartRef1" style="width: 100%; height: 100%"></div>
2025-04-25 18:23:20 +08:00
</div>
2025-03-31 18:24:37 +08:00
</div>
</template>
2025-05-06 14:19:39 +08:00
<script setup>
import { statisticsUseCount } from "@/api/index";
import { onMounted, ref } from "vue";
import * as echarts from "echarts";
import { useResize } from "@/utils/hooks";
const chartRef1 = ref(null);
let myChart = null;
let option = ref({
tooltip: {
trigger: "item",
},
legend: {
right: "left",
},
series: {
type: "pie",
radius: ["20%", "50%"],
data: [
{ value: 0, name: "常规模式" },
{ value: 0, name: "户外押送" },
{ value: 0, name: "审讯模式" },
],
},
});
const getStatisticsUseCount = () => {
statisticsUseCount().then((res) => {
option.value.series.data = [
2025-05-21 17:43:01 +08:00
{ value: res.defaultCount || 0, name: "常规模式" },
{ value: res.outsideCount || 0, name: "户外押送" },
{ value: res.monitorCount || 0, name: "审讯模式" },
2025-05-06 14:19:39 +08:00
];
myChart.setOption(option.value);
});
};
useResize(() => {
myChart.resize();
});
onMounted(() => {
myChart = echarts.init(chartRef1.value);
myChart.setOption(option);
getStatisticsUseCount();
});
</script>
2025-03-31 18:24:37 +08:00
<style scoped lang="less">
.card {
height: 100%;
background: #ffffff;
padding: 16px 10px;
box-sizing: border-box;
position: relative;
display: flex;
2025-04-01 13:52:57 +08:00
border-radius: 5px;
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
2025-04-01 18:07:18 +08:00
margin-bottom: 20px;
2025-04-25 18:23:20 +08:00
.card-chart {
height: 90%;
width: 100%;
margin-top: 30px;
}
2025-03-31 18:24:37 +08:00
.card-head {
position: absolute;
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-04-01 18:07:18 +08:00
margin-bottom: 20px;
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>