526 lines
11 KiB
Vue
526 lines
11 KiB
Vue
<template>
|
|
<view class="system-log-page">
|
|
<!-- 固定头部 -->
|
|
<view class="fixed-header">
|
|
<text class="header-title">移动式检修车间</text>
|
|
</view>
|
|
|
|
<!-- 内容区域 -->
|
|
<view class="tabbar-content">
|
|
<!-- <view class="filter-item">
|
|
<text class="filter-label">时间范围</text>
|
|
<picker mode="date" :value="logDate" @change="onDateChange">
|
|
<view class="picker-view">
|
|
<text>{{ logDate }}</text>
|
|
<text class="picker-arrow">▼</text>
|
|
</view>
|
|
</picker>
|
|
</view> -->
|
|
<SystemLog />
|
|
|
|
<!-- 筛选区域 -->
|
|
<!-- <view class="filter-section">
|
|
<view class="filter-row">
|
|
<view class="filter-item">
|
|
<text class="filter-label">日志级别</text>
|
|
<picker :value="levelIndex" :range="levelOptions" @change="onLevelChange">
|
|
<view class="picker-view">
|
|
<text>{{ levelOptions[levelIndex] }}</text>
|
|
<text class="picker-arrow">▼</text>
|
|
</view>
|
|
</picker>
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="filter-row">
|
|
<view class="filter-item">
|
|
<text class="filter-label">关键词</text>
|
|
<input class="search-input" v-model="searchKeyword" placeholder="输入关键词搜索" />
|
|
</view>
|
|
|
|
<button class="search-button" @click="searchLogs">搜索</button>
|
|
</view>
|
|
</view> -->
|
|
|
|
<!-- 日志表格 -->
|
|
<!-- <view class="logs-container">
|
|
<view class="logs-header">
|
|
<text class="logs-title">系统日志</text>
|
|
<view class="header-actions">
|
|
<button class="action-button" @click="refreshLogs">刷新</button>
|
|
<button class="action-button" @click="exportLogs">导出</button>
|
|
<button class="action-button clear" @click="clearLogs">清空</button>
|
|
</view>
|
|
</view> -->
|
|
|
|
<!-- 表格头部 -->
|
|
<!-- <view class="table-header">
|
|
<view class="table-cell event-header">事件</view>
|
|
<view class="table-cell time-header">时间</view>
|
|
<view class="table-cell status-header">状态</view>
|
|
</view> -->
|
|
|
|
<!-- 表格内容 -->
|
|
<!-- <scroll-view class="table-content" scroll-y="true" @scrolltolower="loadMoreLogs">
|
|
<view class="table-row" v-for="(log, index) in logs" :key="index" :class="log.level">
|
|
<view class="table-cell event-cell">
|
|
<text class="event-message">{{ log.message }}</text>
|
|
<text class="event-details" v-if="log.details">{{ log.details }}</text>
|
|
</view>
|
|
<view class="table-cell time-cell">
|
|
<text class="time-text">{{ log.time }}</text>
|
|
</view>
|
|
<view class="table-cell status-cell">
|
|
<view class="status-badge" :class="log.level">
|
|
<text class="status-text">{{ log.levelText }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="load-more" v-if="hasMore">
|
|
<text class="load-more-text">加载更多...</text>
|
|
</view>
|
|
</scroll-view>
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import SystemLog from '@/components/SystemLog.vue'
|
|
export default {
|
|
components: {
|
|
SystemLog
|
|
},
|
|
data() {
|
|
return {
|
|
levelIndex: 0,
|
|
levelOptions: ['全部级别', '错误', '警告', '信息', '调试'],
|
|
logDate: '2025-09-29',
|
|
searchKeyword: '',
|
|
totalLogs: 1248,
|
|
errorLogs: 23,
|
|
warningLogs: 156,
|
|
infoLogs: 1069,
|
|
hasMore: true,
|
|
logs: [
|
|
{
|
|
level: 'error',
|
|
levelText: 'ERROR',
|
|
time: '2025-09-29 15:45:33',
|
|
message: 'MQTT连接失败',
|
|
details: 'Connection timeout after 5000ms'
|
|
},
|
|
{
|
|
level: 'warning',
|
|
levelText: 'WARN',
|
|
time: '2025-09-29 15:44:15',
|
|
message: '温度传感器读数异常',
|
|
details: 'Temperature reading: 999.9°C (超出正常范围)'
|
|
},
|
|
{
|
|
level: 'info',
|
|
levelText: 'INFO',
|
|
time: '2025-09-29 15:43:22',
|
|
message: '系统启动完成',
|
|
details: '所有服务已启动,系统运行正常'
|
|
},
|
|
{
|
|
level: 'error',
|
|
levelText: 'ERROR',
|
|
time: '2025-09-29 15:42:10',
|
|
message: '数据库连接失败',
|
|
details: 'Failed to connect to database: Connection refused'
|
|
},
|
|
{
|
|
level: 'info',
|
|
levelText: 'INFO',
|
|
time: '2025-09-29 15:41:55',
|
|
message: '用户登录成功',
|
|
details: '用户 admin 登录系统'
|
|
},
|
|
{
|
|
level: 'warning',
|
|
levelText: 'WARN',
|
|
time: '2025-09-29 15:40:33',
|
|
message: '内存使用率过高',
|
|
details: 'Memory usage: 85% (建议清理缓存)'
|
|
},
|
|
{
|
|
level: 'info',
|
|
levelText: 'INFO',
|
|
time: '2025-09-29 15:39:18',
|
|
message: '数据同步完成',
|
|
details: '同步了 156 条记录到云端'
|
|
},
|
|
{
|
|
level: 'error',
|
|
levelText: 'ERROR',
|
|
time: '2025-09-29 15:38:45',
|
|
message: '文件上传失败',
|
|
details: 'File size exceeds limit: 50MB > 10MB'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
onLoad() {
|
|
console.log('系统日志页面加载')
|
|
},
|
|
methods: {
|
|
onLevelChange(e) {
|
|
this.levelIndex = e.detail.value
|
|
},
|
|
onDateChange(e) {
|
|
this.logDate = e.detail.value
|
|
},
|
|
searchLogs() {
|
|
console.log('搜索日志', {
|
|
level: this.levelOptions[this.levelIndex],
|
|
date: this.logDate,
|
|
keyword: this.searchKeyword
|
|
})
|
|
uni.showToast({
|
|
title: '搜索中...',
|
|
icon: 'loading'
|
|
})
|
|
},
|
|
refreshLogs() {
|
|
uni.showToast({
|
|
title: '刷新日志',
|
|
icon: 'success'
|
|
})
|
|
},
|
|
exportLogs() {
|
|
uni.showToast({
|
|
title: '导出功能开发中',
|
|
icon: 'none'
|
|
})
|
|
},
|
|
clearLogs() {
|
|
uni.showModal({
|
|
title: '确认清空',
|
|
content: '确定要清空所有日志吗?此操作不可恢复。',
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
this.logs = []
|
|
this.totalLogs = 0
|
|
this.errorLogs = 0
|
|
this.warningLogs = 0
|
|
this.infoLogs = 0
|
|
uni.showToast({
|
|
title: '清空成功',
|
|
icon: 'success'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
loadMoreLogs() {
|
|
if (this.hasMore) {
|
|
uni.showToast({
|
|
title: '加载更多...',
|
|
icon: 'loading'
|
|
})
|
|
// 模拟加载更多数据
|
|
setTimeout(() => {
|
|
this.hasMore = false
|
|
uni.hideToast()
|
|
}, 1000)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.system-log-page {
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.filter-section {
|
|
background: white;
|
|
border-radius: 12rpx;
|
|
padding: 25rpx;
|
|
margin-bottom: 20rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
|
|
}
|
|
|
|
.filter-row {
|
|
display: flex;
|
|
gap: 20rpx;
|
|
margin-bottom: 20rpx;
|
|
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
|
|
.filter-item {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10rpx;
|
|
}
|
|
|
|
.filter-label {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
}
|
|
|
|
.picker-view {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 20rpx;
|
|
background-color: #f8f8f8;
|
|
border-radius: 10rpx;
|
|
border: 2rpx solid #e0e0e0;
|
|
}
|
|
|
|
.picker-arrow {
|
|
color: #999;
|
|
font-size: 24rpx;
|
|
}
|
|
|
|
.search-input {
|
|
padding: 20rpx;
|
|
background-color: #f8f8f8;
|
|
border-radius: 10rpx;
|
|
border: 2rpx solid #e0e0e0;
|
|
font-size: 28rpx;
|
|
}
|
|
|
|
.search-button {
|
|
background-color: #3f51b5;
|
|
color: white;
|
|
padding: 20rpx 30rpx;
|
|
border-radius: 10rpx;
|
|
font-size: 28rpx;
|
|
align-self: flex-end;
|
|
}
|
|
|
|
.statistics-section {
|
|
background: white;
|
|
border-radius: 12rpx;
|
|
padding: 25rpx;
|
|
margin-bottom: 20rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
|
|
display: flex;
|
|
justify-content: space-around;
|
|
}
|
|
|
|
.stat-item {
|
|
text-align: center;
|
|
}
|
|
|
|
.stat-label {
|
|
display: block;
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
margin-bottom: 10rpx;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
|
|
&.error {
|
|
color: #ff4444;
|
|
}
|
|
|
|
&.warning {
|
|
color: #ff9800;
|
|
}
|
|
|
|
&.info {
|
|
color: #2196f3;
|
|
}
|
|
}
|
|
|
|
.logs-container {
|
|
background: white;
|
|
border-radius: 12rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.logs-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 25rpx;
|
|
border-bottom: 2rpx solid #f0f0f0;
|
|
}
|
|
|
|
.logs-title {
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
}
|
|
|
|
.header-actions {
|
|
display: flex;
|
|
gap: 15rpx;
|
|
}
|
|
|
|
.action-button {
|
|
background-color: #3f51b5;
|
|
color: white;
|
|
padding: 10rpx 20rpx;
|
|
border-radius: 6rpx;
|
|
font-size: 24rpx;
|
|
|
|
&.clear {
|
|
background-color: #ff4444;
|
|
}
|
|
}
|
|
|
|
/* 表格样式 */
|
|
.table-header {
|
|
display: flex;
|
|
background-color: #f8f9fa;
|
|
border-bottom: 2rpx solid #e0e0e0;
|
|
}
|
|
|
|
.table-cell {
|
|
padding: 20rpx 15rpx;
|
|
font-size: 28rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
border-right: 1rpx solid #e0e0e0;
|
|
|
|
&:last-child {
|
|
border-right: none;
|
|
}
|
|
}
|
|
|
|
.event-header {
|
|
flex: 2;
|
|
text-align: left;
|
|
}
|
|
|
|
.time-header {
|
|
flex: 1.2;
|
|
text-align: center;
|
|
}
|
|
|
|
.status-header {
|
|
flex: 0.8;
|
|
text-align: center;
|
|
}
|
|
|
|
.table-content {
|
|
height: 600rpx;
|
|
}
|
|
|
|
.table-row {
|
|
display: flex;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
&:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
&:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
&.error {
|
|
background-color: #fff5f5;
|
|
}
|
|
|
|
&.warning {
|
|
background-color: #fffbf0;
|
|
}
|
|
|
|
&.info {
|
|
background-color: #f0f8ff;
|
|
}
|
|
}
|
|
|
|
.event-cell {
|
|
flex: 2;
|
|
padding: 20rpx 15rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8rpx;
|
|
}
|
|
|
|
.event-message {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.event-details {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
line-height: 1.3;
|
|
background-color: #f8f8f8;
|
|
padding: 8rpx 12rpx;
|
|
border-radius: 6rpx;
|
|
}
|
|
|
|
.time-cell {
|
|
flex: 1.2;
|
|
padding: 20rpx 15rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.time-text {
|
|
font-size: 24rpx;
|
|
color: #666;
|
|
text-align: center;
|
|
}
|
|
|
|
.status-cell {
|
|
flex: 0.8;
|
|
padding: 20rpx 15rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.status-badge {
|
|
padding: 8rpx 16rpx;
|
|
border-radius: 20rpx;
|
|
font-size: 22rpx;
|
|
font-weight: bold;
|
|
|
|
&.error {
|
|
background-color: #ffebee;
|
|
color: #ff4444;
|
|
}
|
|
|
|
&.warning {
|
|
background-color: #fff3e0;
|
|
color: #ff9800;
|
|
}
|
|
|
|
&.info {
|
|
background-color: #e3f2fd;
|
|
color: #2196f3;
|
|
}
|
|
}
|
|
|
|
.status-text {
|
|
font-size: 22rpx;
|
|
}
|
|
|
|
.load-more {
|
|
padding: 30rpx;
|
|
text-align: center;
|
|
}
|
|
|
|
.load-more-text {
|
|
font-size: 28rpx;
|
|
color: #666;
|
|
}
|
|
</style> |