| | |
| | | import EmptyState from './EmptyState.vue' |
| | | |
| | | const equipmentWarningData = ref([]) |
| | | const loading = ref(true) |
| | | const minLoadingMs = 400 |
| | | const loading = ref(false) |
| | | const loadingTimer = ref(null) |
| | | |
| | | const statusMap = { |
| | | 0: { text: '在线', statusType: 'online' }, |
| | |
| | | } |
| | | |
| | | const fetchDeviceWarning = async () => { |
| | | const startAt = Date.now() |
| | | loading.value = true |
| | | // 只有超过200ms才显示loading,避免闪烁 |
| | | loadingTimer.value = setTimeout(() => { |
| | | loading.value = true |
| | | }, 200) |
| | | |
| | | try { |
| | | const params = { current: 1, size: 20, deviceStatusList: '1,2,3' } |
| | | const res = await deviceSearchApi(params) |
| | | const records = res?.data?.data?.records ?? [] |
| | | equipmentWarningData.value = records.map(formatDeviceItem) |
| | | } finally { |
| | | const elapsed = Date.now() - startAt |
| | | if (elapsed < minLoadingMs) { |
| | | await new Promise((resolve) => setTimeout(resolve, minLoadingMs - elapsed)) |
| | | } |
| | | if (loadingTimer.value) clearTimeout(loadingTimer.value) |
| | | loading.value = false |
| | | } |
| | | } |