@@ -182,20 +184,20 @@ const lastCheckTime = ref('')
const windowHeight = ref(window.innerHeight)
const windowWidth = ref(window.innerWidth)
-// 动态计算表格高度:窗口高度 - 顶部Header和工具栏预估占用的空间
+// 计算表格高度:手机端预留更多空间给折行的头部
const tableHeight = computed(() => {
- const offset = isMobile.value ? 400 : 280; // 移动端预留更多空间
- return windowHeight.value - offset;
+ const isMobile = windowWidth.value < 768
+ // 手机端头部元素堆叠,需要减去更多的高度
+ const offset = isMobile ? 380 : 250
+ return windowHeight.value - offset
})
-const isMobile = computed(() => windowWidth.value < 768)
const filters = reactive({ status: 'all', keyword: '' })
const API_BASE = import.meta.env.DEV ? 'http://127.0.0.1:5000' : ''
const dataMonitorRef = ref(null)
const maintenanceLogsRef = ref(null)
-// 统计信息
const summary = computed(() => {
const activeDevices = rawData.value.filter(r => !r.is_hidden)
const errors = activeDevices.filter(r => r.statusType === 'error').length
@@ -204,7 +206,6 @@ const summary = computed(() => {
return { errorCount: errors, warningCount: warnings, hiddenCount: hidden }
})
-// 退出登录
const handleLogout = () => {
ElMessageBox.confirm('确定退出系统吗?', '提示', { type: 'warning' }).then(() => {
localStorage.removeItem('isLoggedIn')
@@ -214,7 +215,6 @@ const handleLogout = () => {
}).catch(() => {})
}
-// 获取数据
const fetchData = async () => {
loading.value = true
try {
@@ -244,12 +244,11 @@ const fetchData = async () => {
else if (item.status === 'offline' || item.status === '已离线') sortHours = 1000000000;
else if (!validTime) sortHours = 500000000;
- let statusColor = '#67C23A', statusLabel = '正常在线', statusType = 'normal', statusLabelColor = '#fff'
+ let statusColor = '#67C23A', statusLabel = '正常', statusType = 'normal', statusLabelColor = '#fff'
if (item.is_maintaining) {
statusColor = '#409EFF'; statusLabel = '维修中'; statusType = 'maintenance';
} else if ((item.status === 'offline' || item.status === '已离线') || (!validTime || diffDays > 7)) {
- statusLabel = (item.status === 'offline' || item.status === '已离线') ? '🔴 设备离线' : '严重滞后'
- statusColor = '#F56C6C'; statusType = 'error';
+ statusLabel = '离线/滞后'; statusColor = '#F56C6C'; statusType = 'error';
} else if (diffHours > 24) {
statusColor = '#E6A23C'; statusLabel = '数据滞后'; statusType = 'warning';
} else if (!isToday) {
@@ -271,7 +270,6 @@ const fetchData = async () => {
}
}
-// 其他方法 (handleDeviceClick, openLogCenter, runManualMonitor等保持原有逻辑)...
const handleDeviceClick = (row) => { if (!row.is_hidden && dataMonitorRef.value) dataMonitorRef.value.open(row) }
const openLogCenter = (row) => { if (maintenanceLogsRef.value) maintenanceLogsRef.value.open(row ? { deviceName: row.name } : null) }
const runManualMonitor = async () => {
@@ -295,7 +293,11 @@ const filteredData = computed(() => {
const handleEditSite = (row) => {
row.tempSite = row.install_site; row.isEditingSite = true
- nextTick(() => { document.querySelector('.editing-cell input')?.focus() })
+ nextTick(() => {
+ // 兼容性查找 input
+ const inputs = document.querySelectorAll('.site-input-inner input')
+ if (inputs.length > 0) inputs[inputs.length - 1].focus()
+ })
}
const saveSite = async (row) => {
@@ -333,7 +335,6 @@ const tableRowClassName = ({ row }) => {
return ''
}
-// 监听窗口缩放,动态更新高度
const updateDimensions = () => {
windowHeight.value = window.innerHeight
windowWidth.value = window.innerWidth
@@ -347,16 +348,42 @@ onBeforeUnmount(() => window.removeEventListener('resize', updateDimensions))