<!-- Description: 综合大屏 - 数据展示- 监测设备统计 Author: 李亚光 Date: 2024-09-18 --> <script lang="ts" setup name="FullScreenMonitorDeviceCount"> import layout from './layout.vue' import { deviceTypeStatistics } from '@/api/home/dashboard/fullScreen' import PieChart3D from '@/components/Echart/PieChart3D.vue' const $props = defineProps({ type: { type: String, required: true, }, }) // 宽高 const height = ref((window.innerHeight - 100 - 50) / 3 + 20) const width = ref((window.innerWidth - (window.innerWidth * 0.6) - 30) / 2) window.addEventListener('resize', () => { height.value = (window.innerHeight - 100 - 50 + 20) / 3 width.value = (window.innerWidth - (window.innerWidth * 0.6) - 30) / 2 }) onBeforeUnmount(() => { window.addEventListener('resize', () => { }) }) const data = ref<any[]>([]) onMounted(() => { // setTimeout(() => { // data.value = [ // { // name: '管网哨兵', // value: '12', // }, // { // name: '燃气智能监测终端', // value: '18', // }, // { // name: '场站监测云台', // value: '6', // }, // { // name: '井盖状态监测仪', // value: '10', // }, // { // name: '智能警示桩', // value: '14', // }, // ] // }, 100) }) // 获取数据 const loading = ref(true) const fetchData = () => { loading.value = true deviceTypeStatistics({ type: $props.type }).then((res) => { // console.log(res.data, '监测设备统计') data.value = res.data loading.value = false }).catch(() => { loading.value = false }) } watch(() => $props.type, (newVal) => { if (newVal) { fetchData() } else { loading.value = false } }, { deep: true, immediate: true, }) </script> <template> <layout v-loading="loading" class="layout" :height="height" :width="width" title="监测设备统计" subtitle="Monitoring Equipment Statistics"> <template #content> <pie-chart3-d :data="data" :style="{ width: '100%', height: `${height - 30}px` }" /> </template> </layout> </template> <style lang="scss" scoped> // .layout { // ::v-deep(.title) { // padding-left: 8px !important; // color: #fff; // font-weight: 700; // // padding-left: 20px; // box-sizing: border-box; // } // } ::v-deep(.el-loading-mask) { background-color: rgba($color: #0b0b0f, $alpha: 95%); } </style>