对接MQTT、APP样式
This commit is contained in:
481
src/pages/log/index.vue
Normal file
481
src/pages/log/index.vue
Normal file
@ -0,0 +1,481 @@
|
||||
<template>
|
||||
<view class="system-log-page">
|
||||
<!-- 固定头部 -->
|
||||
<view class="fixed-header">
|
||||
<text class="header-title">移动式检修车间</text>
|
||||
</view>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<view class="tabbar-content">
|
||||
|
||||
<!-- 筛选区域 -->
|
||||
<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 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>
|
||||
</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="statistics-section">
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">总日志数</text>
|
||||
<text class="stat-value">{{ totalLogs }}</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">错误日志</text>
|
||||
<text class="stat-value error">{{ errorLogs }}</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">警告日志</text>
|
||||
<text class="stat-value warning">{{ warningLogs }}</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">信息日志</text>
|
||||
<text class="stat-value info">{{ infoLogs }}</text>
|
||||
</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>
|
||||
|
||||
<scroll-view class="logs-list" scroll-y="true" @scrolltolower="loadMoreLogs">
|
||||
<view class="log-item" v-for="(log, index) in logs" :key="index" :class="log.level">
|
||||
<view class="log-header">
|
||||
<view class="log-level" :class="log.level">
|
||||
<text>{{ log.levelText }}</text>
|
||||
</view>
|
||||
<text class="log-time">{{ log.time }}</text>
|
||||
</view>
|
||||
<view class="log-content">
|
||||
<text class="log-message">{{ log.message }}</text>
|
||||
</view>
|
||||
<view class="log-details" v-if="log.details">
|
||||
<text class="log-details-text">{{ log.details }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="load-more" v-if="hasMore">
|
||||
<text class="load-more-text">加载更多...</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
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: 15rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.logs-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
.logs-list {
|
||||
height: 600rpx;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
padding: 30rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&.error {
|
||||
border-left: 8rpx solid #ff4444;
|
||||
}
|
||||
|
||||
&.warning {
|
||||
border-left: 8rpx solid #ff9800;
|
||||
}
|
||||
|
||||
&.info {
|
||||
border-left: 8rpx solid #2196f3;
|
||||
}
|
||||
}
|
||||
|
||||
.log-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.log-level {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
.log-time {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.log-content {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.log-message {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.log-details {
|
||||
background-color: #f8f8f8;
|
||||
padding: 15rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.log-details-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.load-more {
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.load-more-text {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user