<!-- 环境看板- 智能模型在线状态分析 --> <script name="DeviceOnlineTrend" lang="ts" setup> import debounce from 'lodash/throttle' import { getDeviceType } from '@/api/dataManagement/environmentBoard' const $props = defineProps({ // 实验室 lab: { type: String, default: '', }, }) const loading = ref(true) const data1 = ref<any[]>([]) const data2 = ref<any[]>([]) const xAxisData = ref<string[]>([]) // 获取数据 const fetchData = debounce(async () => { if (!$props.lab) { return } loading.value = true try { const res = await getDeviceType({ labName: $props.lab }) data1.value = res.data.map((item: any) => item.count) data2.value = res.data.map((item: any) => item.onlineCount) xAxisData.value = res.data.map((item: any) => item.deviceName) loading.value = false } catch (_) { loading.value = false } }, 1000) watch(() => $props, (newVal) => { if (newVal.lab) { fetchData() } }, { deep: true, }) </script> <template> <div class="board-item-device"> <div class="board-header"> <div class="board-title"> 智能模型在线状态分析 </div> <div class="board-select" /> </div> <div v-loading="loading" class="board-chart"> <bar-chart-double :legend-data="['智能模型总数', '智能模型在线数']" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" :x-axis-data="xAxisData" :data1="data1" :data2="data2" /> </div> </div> </template> <style lang="scss" scoped> .board-item-device { margin: 5px 0; padding: 2px 10px; // border: 2px solid #cedaf6; box-sizing: content-box; .board-header { display: flex; justify-content: space-between; .board-title { color: #0dabf1; font-weight: 700; } } .board-chart { height: 320px; } } </style>