900 lines
		
	
	
		
			29 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			900 lines
		
	
	
		
			29 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <template>
 | ||
|   <div class="operation-inspection">
 | ||
|     <div class="navigation-tabs">
 | ||
|       <div class="nav-tab" @click="handleInspection1">待办事项</div>
 | ||
|       <div class="nav-tab active" @click="handleInspection2">巡检管理</div>
 | ||
|       <div class="nav-tab" @click="handleInspection3">试验管理</div>
 | ||
|       <div class="nav-tab" @click="handleInspection4">报修管理</div>
 | ||
|       <div class="nav-tab" @click="handleInspection5">抢修管理</div>
 | ||
|       <div class="nav-tab" @click="handleInspection6">工单管理</div>
 | ||
|       <div class="nav-tab" @click="handleInspection7">运维组织</div>
 | ||
|     </div>
 | ||
|     <div class="header-container">
 | ||
|       <div class="header-actions">
 | ||
|         <el-button type="primary" class="export-btn">筛选</el-button>
 | ||
|         <el-button type="primary" class="create-btn">导出数据</el-button>
 | ||
|       </div>
 | ||
|     </div>
 | ||
| 
 | ||
|     <!-- 选项卡和按钮组合 -->
 | ||
|     <div class="tabs-wrapper">
 | ||
|       <div style="display: flex; align-items: center; gap: 10px">
 | ||
|         <el-button type="primary" @click="handleInspectionManagement1">巡检计划</el-button>
 | ||
|         <el-button type="primary" @click="handleInspectionManagement2">巡检任务</el-button>
 | ||
|         <el-button type="primary" @click="handleInspectionManagement3">巡检记录</el-button>
 | ||
|       </div>
 | ||
|     </div>
 | ||
| 
 | ||
|     <!-- 筛选栏 -->
 | ||
|     <div class="filter-bar">
 | ||
|       <div class="filter-item">
 | ||
|         <el-select v-model="filterStatus" placeholder="状态" clearable>
 | ||
|           <el-option label="全部状态" value="all"></el-option>
 | ||
|           <el-option label="正常" value="normal"></el-option>
 | ||
|           <el-option label="需关注" value="attention"></el-option>
 | ||
|           <el-option label="有问题" value="problem"></el-option>
 | ||
|         </el-select>
 | ||
|       </div>
 | ||
|       <div class="filter-item">
 | ||
|         <el-select v-model="filterType" placeholder="巡检类型" clearable>
 | ||
|           <el-option label="全部类型" value="all"></el-option>
 | ||
|           <el-option label="数据库" value="database"></el-option>
 | ||
|           <el-option label="服务器" value="server"></el-option>
 | ||
|           <el-option label="网络设备" value="network"></el-option>
 | ||
|         </el-select>
 | ||
|       </div>
 | ||
|       <div class="filter-item">
 | ||
|         <el-date-picker
 | ||
|           v-model="dateRange"
 | ||
|           type="daterange"
 | ||
|           range-separator="至"
 | ||
|           start-placeholder="开始日期"
 | ||
|           end-placeholder="结束日期"
 | ||
|           value-format="YYYY-MM-DD"
 | ||
|         ></el-date-picker>
 | ||
|       </div>
 | ||
|       <div class="filter-actions">
 | ||
|         <el-button type="primary" class="search-btn" @click="fetchDashboardData">搜索</el-button>
 | ||
|       </div>
 | ||
|     </div>
 | ||
| 
 | ||
|     <!-- 主内容区 - 使用flex确保等高 -->
 | ||
|     <div class="main-content-container">
 | ||
|       <!-- 左侧和中间内容区 -->
 | ||
|       <div class="left-content">
 | ||
|         <!-- 巡检记录与报告卡片 -->
 | ||
|         <div class="content-card">
 | ||
|           <div class="card-header">
 | ||
|             <h2 class="card-title">巡检记录与报告</h2>
 | ||
|             <div class="flex space-x-2">
 | ||
|               <button
 | ||
|                 class="px-3 py-1 text-sm rounded-md hover:bg-gray-200 transition"
 | ||
|                 :class="{ 'bg-gray-100 text-gray-700': timeRange === 'month', 'bg-white text-gray-500': timeRange !== 'month' }"
 | ||
|                 @click="handleTimeRangeChange('month')"
 | ||
|               >
 | ||
|                 月
 | ||
|               </button>
 | ||
|               <button
 | ||
|                 class="px-3 py-1 text-sm rounded-md hover:bg-gray-100 transition"
 | ||
|                 :class="{ 'bg-gray-100 text-gray-700': timeRange === 'week', 'bg-white text-gray-500': timeRange !== 'week' }"
 | ||
|                 @click="handleTimeRangeChange('week')"
 | ||
|               >
 | ||
|                 周
 | ||
|               </button>
 | ||
|               <button
 | ||
|                 class="px-3 py-1 text-sm rounded-md hover:bg-gray-100 transition"
 | ||
|                 :class="{ 'bg-gray-100 text-gray-700': timeRange === 'day', 'bg-white text-gray-500': timeRange !== 'day' }"
 | ||
|                 @click="handleTimeRangeChange('day')"
 | ||
|               >
 | ||
|                 日
 | ||
|               </button>
 | ||
|             </div>
 | ||
|           </div>
 | ||
| 
 | ||
|           <!-- 数据卡片 -->
 | ||
|           <div class="card-body">
 | ||
|             <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
 | ||
|               <div class="stat-card">
 | ||
|                 <p class="stat-label">本月完成巡检</p>
 | ||
|                 <p class="stat-value">{{ completedInspections }}</p>
 | ||
|               </div>
 | ||
|               <div class="stat-card">
 | ||
|                 <p class="stat-label">发现问题数</p>
 | ||
|                 <p class="stat-value">{{ totalProblems }}</p>
 | ||
|               </div>
 | ||
|               <div class="stat-card">
 | ||
|                 <p class="stat-label">已解决问题</p>
 | ||
|                 <p class="stat-value">{{ solvedProblems }}</p>
 | ||
|               </div>
 | ||
|               <div class="stat-card">
 | ||
|                 <p class="stat-label">平均完成时间</p>
 | ||
|                 <p class="stat-value">{{ avgCompletionTime }}</p>
 | ||
|               </div>
 | ||
|             </div>
 | ||
| 
 | ||
|             <div class="divider"></div>
 | ||
| 
 | ||
|             <!-- 图表区域 -->
 | ||
|             <div class="grid grid-cols-1 md:grid-cols-3 gap-6 py-4">
 | ||
|               <!-- 饼图 - 使用指定的ECharts配置 -->
 | ||
|               <div class="md:col-span-1">
 | ||
|                 <p class="chart-title">进度指标对比</p>
 | ||
|                 <div ref="pieChartRef" class="pie-chart-container"></div>
 | ||
|               </div>
 | ||
| 
 | ||
|               <!-- 进度条 -->
 | ||
|               <div class="md:col-span-2 flex flex-col justify-center">
 | ||
|                 <div class="space-y-4">
 | ||
|                   <div>
 | ||
|                     <div class="flex justify-between text-sm mb-1">
 | ||
|                       <span class="text-gray-600">完成率</span>
 | ||
|                       <span class="font-medium text-gray-800">{{ completionRate }}%</span>
 | ||
|                     </div>
 | ||
|                     <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                       <div class="bg-blue-500 h-2 rounded-full transition-all duration-1500 ease-out" :style="{ width: completionRate + '%' }"></div>
 | ||
|                     </div>
 | ||
|                   </div>
 | ||
|                   <div>
 | ||
|                     <div class="flex justify-between text-sm mb-1">
 | ||
|                       <span class="text-gray-600">解决率</span>
 | ||
|                       <span class="font-medium text-gray-800">{{ resolutionRate }}%</span>
 | ||
|                     </div>
 | ||
|                     <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                       <div class="bg-red-500 h-2 rounded-full transition-all duration-1500 ease-out" :style="{ width: resolutionRate + '%' }"></div>
 | ||
|                     </div>
 | ||
|                   </div>
 | ||
|                   <div>
 | ||
|                     <div class="flex justify-between text-sm mb-1">
 | ||
|                       <span class="text-gray-600">及时率</span>
 | ||
|                       <span class="font-medium text-gray-800">{{ timelinessRate }}%</span>
 | ||
|                     </div>
 | ||
|                     <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                       <div class="bg-green-500 h-2 rounded-full transition-all duration-1500 ease-out" :style="{ width: timelinessRate + '%' }"></div>
 | ||
|                     </div>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
|               </div>
 | ||
|             </div>
 | ||
| 
 | ||
|             <div class="divider"></div>
 | ||
| 
 | ||
|             <!-- 发现问题种类 -->
 | ||
|             <div class="py-4">
 | ||
|               <h3 class="section-title">发现问题种类</h3>
 | ||
|               <div class="space-y-4">
 | ||
|                 <div>
 | ||
|                   <div class="flex justify-between text-sm mb-1">
 | ||
|                     <span class="text-gray-600">温度异常率</span>
 | ||
|                     <span class="text-gray-500">{{ problemTypes.temperature }}%</span>
 | ||
|                   </div>
 | ||
|                   <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                     <div
 | ||
|                       class="bg-blue-500 h-2 rounded-full transition-all duration-1500 ease-out"
 | ||
|                       :style="{ width: problemTypes.temperature + '%' }"
 | ||
|                     ></div>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
|                 <div>
 | ||
|                   <div class="flex justify-between text-sm mb-1">
 | ||
|                     <span class="text-gray-600">内存使用率</span>
 | ||
|                     <span class="text-gray-500">{{ problemTypes.memory }}%</span>
 | ||
|                   </div>
 | ||
|                   <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                     <div
 | ||
|                       class="bg-blue-500 h-2 rounded-full transition-all duration-1500 ease-out"
 | ||
|                       :style="{ width: problemTypes.memory + '%' }"
 | ||
|                     ></div>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
|                 <div>
 | ||
|                   <div class="flex justify-between text-sm mb-1">
 | ||
|                     <span class="text-gray-600">CPU负载</span>
 | ||
|                     <span class="text-gray-500">{{ problemTypes.cpu }}%</span>
 | ||
|                   </div>
 | ||
|                   <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                     <div class="bg-blue-500 h-2 rounded-full transition-all duration-1500 ease-out" :style="{ width: problemTypes.cpu + '%' }"></div>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
|                 <div>
 | ||
|                   <div class="flex justify-between text-sm mb-1">
 | ||
|                     <span class="text-gray-600">响应时间</span>
 | ||
|                     <span class="text-gray-500">{{ problemTypes.responseTime }}%</span>
 | ||
|                   </div>
 | ||
|                   <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                     <div
 | ||
|                       class="bg-blue-500 h-2 rounded-full transition-all duration-1500 ease-out"
 | ||
|                       :style="{ width: problemTypes.responseTime + '%' }"
 | ||
|                     ></div>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
|                 <div>
 | ||
|                   <div class="flex justify-between text-sm mb-1">
 | ||
|                     <span class="text-gray-600">磁盘空间状态</span>
 | ||
|                     <span class="text-gray-500">{{ problemTypes.diskSpace }}%</span>
 | ||
|                   </div>
 | ||
|                   <div class="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
 | ||
|                     <div
 | ||
|                       class="bg-blue-500 h-2 rounded-full transition-all duration-1500 ease-out"
 | ||
|                       :style="{ width: problemTypes.diskSpace + '%' }"
 | ||
|                     ></div>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
|               </div>
 | ||
|             </div>
 | ||
|           </div>
 | ||
|         </div>
 | ||
|       </div>
 | ||
| 
 | ||
|       <!-- 右侧最近巡检结果 -->
 | ||
|       <div class="right-content">
 | ||
|         <div class="content-card h-full flex flex-col">
 | ||
|           <div class="card-header">
 | ||
|             <h2 class="card-title">最近巡检结果</h2>
 | ||
|           </div>
 | ||
| 
 | ||
|           <!-- 巡检结果列表 - 添加滚动样式 -->
 | ||
|           <div class="card-body flex-1 overflow-y-auto scrollbar-thin">
 | ||
|             <div class="inspection-results space-y-4">
 | ||
|               <!-- 结果1:正常 -->
 | ||
|               <div class="inspection-card bg-white border border-gray-200 rounded-lg p-4 shadow-sm hover:shadow-md transition-shadow">
 | ||
|                 <div class="flex justify-between items-start mb-4">
 | ||
|                   <h3 class="text-lg font-medium text-gray-800">数据库性能巡检</h3>
 | ||
|                   <span class="status-tag status-normal px-3 py-1 text-xs">正常</span>
 | ||
|                 </div>
 | ||
|                 <p class="text-sm text-gray-500 mb-3">2025-06-15 14:00-16:45 张明</p>
 | ||
| 
 | ||
|                 <div class="flex justify-between items-center mb-4">
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">系统连接量</span>
 | ||
|                     <span class="text-sm font-medium">128</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">查询响应时间</span>
 | ||
|                     <span class="text-sm font-medium">平均0.3S</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">表空间使用率</span>
 | ||
|                     <span class="text-sm font-medium">75%</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">日志文件</span>
 | ||
|                     <span class="text-sm font-medium">正常轮转</span>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
| 
 | ||
|                 <div class="flex justify-end gap-2">
 | ||
|                   <el-button size="small" class="text-sm border-gray-300 text-gray-600">查看详情</el-button>
 | ||
|                   <el-button type="primary" size="small" class="text-sm">生成报告</el-button>
 | ||
|                 </div>
 | ||
|               </div>
 | ||
| 
 | ||
|               <!-- 结果2:需关注 -->
 | ||
|               <div class="inspection-card bg-white border border-gray-200 rounded-lg p-4 shadow-sm hover:shadow-md transition-shadow">
 | ||
|                 <div class="flex justify-between items-start mb-4">
 | ||
|                   <h3 class="text-lg font-medium text-gray-800">生产服务器日常巡检</h3>
 | ||
|                   <span class="status-tag status-attention px-3 py-1 text-xs">需关注</span>
 | ||
|                 </div>
 | ||
|                 <p class="text-sm text-gray-500 mb-3">2025-06-15 14:00-16:45 张明</p>
 | ||
| 
 | ||
|                 <div class="flex justify-between items-center mb-4">
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">CPU使用率</span>
 | ||
|                     <span class="text-sm font-medium">平均35%,峰值59%</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-exclamation-circle text-yellow-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">内存使用率</span>
 | ||
|                     <span class="text-sm font-medium">85%</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">磁盘空间</span>
 | ||
|                     <span class="text-sm font-medium">62%</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">服务状态</span>
 | ||
|                     <span class="text-sm font-medium">正常运行</span>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
| 
 | ||
|                 <div class="bg-yellow-50 border border-yellow-200 rounded-md p-3 mb-4">
 | ||
|                   <div class="flex items-start">
 | ||
|                     <i class="fas fa-info-circle text-yellow-500 mt-0.5 mr-2"></i>
 | ||
|                     <p class="text-xs text-yellow-800">已创建问题单 #PRB-2023061501,计划于今晚进行内存扩容</p>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
| 
 | ||
|                 <div class="flex justify-end gap-2">
 | ||
|                   <el-button size="small" class="text-sm border-gray-300 text-gray-600">查看详情</el-button>
 | ||
|                   <el-button type="primary" size="small" class="text-sm">生成报告</el-button>
 | ||
|                 </div>
 | ||
|               </div>
 | ||
| 
 | ||
|               <!-- 结果3:有问题 -->
 | ||
|               <div class="inspection-card bg-white border border-gray-200 rounded-lg p-4 shadow-sm hover:shadow-md transition-shadow">
 | ||
|                 <div class="flex justify-between items-start mb-4">
 | ||
|                   <h3 class="text-lg font-medium text-gray-800">网络设备安全巡检</h3>
 | ||
|                   <span class="status-tag status-problem px-3 py-1 text-xs">有问题</span>
 | ||
|                 </div>
 | ||
|                 <p class="text-sm text-gray-500 mb-3">2025-06-14 10:00-11:30 李华</p>
 | ||
| 
 | ||
|                 <div class="grid grid-cols-2 gap-2 mb-4">
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-times-circle text-red-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">防火墙规则</span>
 | ||
|                     <span class="text-sm font-medium">部分规则异常</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-exclamation-circle text-yellow-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">安全补丁</span>
 | ||
|                     <span class="text-sm font-medium">需更新</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">访问控制</span>
 | ||
|                     <span class="text-sm font-medium">正常</span>
 | ||
|                   </div>
 | ||
|                   <div class="flex flex-col items-center">
 | ||
|                     <i class="fas fa-check-circle text-green-500 text-lg mb-1"></i>
 | ||
|                     <span class="text-xs text-gray-600 mb-1">流量监控</span>
 | ||
|                     <span class="text-sm font-medium">正常</span>
 | ||
|                   </div>
 | ||
|                 </div>
 | ||
| 
 | ||
|                 <div class="flex justify-end gap-2">
 | ||
|                   <el-button size="small" class="text-sm border-gray-300 text-gray-600">查看详情</el-button>
 | ||
|                   <el-button type="primary" size="small" class="text-sm">生成报告</el-button>
 | ||
|                 </div>
 | ||
|               </div>
 | ||
|             </div>
 | ||
|           </div>
 | ||
|         </div>
 | ||
|       </div>
 | ||
|     </div>
 | ||
|   </div>
 | ||
| </template>
 | ||
| 
 | ||
| <script setup>
 | ||
| import { ref, onMounted, computed, onUnmounted } from 'vue';
 | ||
| import router from '@/router';
 | ||
| 
 | ||
| import * as echarts from 'echarts';
 | ||
| import { xunjianjilu } from '@/api/zhinengxunjian/xunjian/jilu';
 | ||
| import { ElMessage } from 'element-plus';
 | ||
| // 筛选条件
 | ||
| const filterStatus = ref('all');
 | ||
| const filterType = ref('all');
 | ||
| const dateRange = ref([]);
 | ||
| 
 | ||
| // 时间范围选择
 | ||
| const timeRange = ref('month'); // 默认选中"月"
 | ||
| 
 | ||
| // 进度指标数据
 | ||
| const completionRate = ref(68); // 完成率
 | ||
| const resolutionRate = ref(72); // 解决率
 | ||
| const timelinessRate = ref(60); // 及时率
 | ||
| 
 | ||
| // 统计数据
 | ||
| const completedInspections = ref(42);
 | ||
| const totalProblems = ref(7);
 | ||
| const solvedProblems = ref(5);
 | ||
| const avgCompletionTime = ref('45分钟');
 | ||
| 
 | ||
| // 问题类型数据
 | ||
| const problemTypes = ref({
 | ||
|   temperature: 85, // 温度异常率
 | ||
|   memory: 62, // 内存使用率
 | ||
|   cpu: 45, // CPU负载
 | ||
|   responseTime: 30, // 响应时间
 | ||
|   diskSpace: 15 // 磁盘空间状态
 | ||
| });
 | ||
| 
 | ||
| // ECharts 饼图相关
 | ||
| const pieChartRef = ref(null);
 | ||
| let pieChart = null;
 | ||
| 
 | ||
| // 计算平均完成度
 | ||
| const averageRate = computed(() => (completionRate.value + resolutionRate.value + timelinessRate.value) / 3);
 | ||
| 
 | ||
| // 初始化饼图 - 使用指定的option配置
 | ||
| const initPieChart = () => {
 | ||
|   // 确保DOM元素已存在
 | ||
|   if (!pieChartRef.value) return;
 | ||
| 
 | ||
|   // 销毁已存在的实例
 | ||
|   if (pieChart) {
 | ||
|     pieChart.dispose();
 | ||
|   }
 | ||
| 
 | ||
|   // 创建新实例
 | ||
|   pieChart = echarts.init(pieChartRef.value);
 | ||
| 
 | ||
|   // 设置图表配置 - 使用指定的option
 | ||
|   const option = {
 | ||
|     tooltip: {
 | ||
|       trigger: 'item'
 | ||
|     },
 | ||
|     legend: {
 | ||
|       top: '5%',
 | ||
|       left: 'center'
 | ||
|     },
 | ||
|     series: [
 | ||
|       {
 | ||
|         name: '进度指标',
 | ||
|         type: 'pie',
 | ||
|         radius: ['40%', '70%'],
 | ||
|         avoidLabelOverlap: false,
 | ||
|         padAngle: 5,
 | ||
|         itemStyle: {
 | ||
|           borderRadius: 10
 | ||
|         },
 | ||
|         label: {
 | ||
|           show: false,
 | ||
|           position: 'center'
 | ||
|         },
 | ||
|         emphasis: {
 | ||
|           label: {
 | ||
|             show: true,
 | ||
|             fontSize: 40,
 | ||
|             fontWeight: 'bold',
 | ||
|             formatter: function (params) {
 | ||
|               // 鼠标悬停时显示当前指标的百分比
 | ||
|               return params.value + '%';
 | ||
|             }
 | ||
|           }
 | ||
|         },
 | ||
|         labelLine: {
 | ||
|           show: false
 | ||
|         },
 | ||
|         data: [
 | ||
|           { value: completionRate.value, name: '完成率', itemStyle: { color: '#5470c6' } },
 | ||
|           { value: resolutionRate.value, name: '解决率', itemStyle: { color: '#f56c6c' } },
 | ||
|           { value: timelinessRate.value, name: '及时率', itemStyle: { color: '#67c23a' } }
 | ||
|         ]
 | ||
|       }
 | ||
|     ]
 | ||
|   };
 | ||
| 
 | ||
|   // 设置配置项
 | ||
|   pieChart.setOption(option);
 | ||
| 
 | ||
|   // 响应窗口大小变化
 | ||
|   const handleResize = () => {
 | ||
|     if (pieChart) {
 | ||
|       pieChart.resize();
 | ||
|     }
 | ||
|   };
 | ||
| 
 | ||
|   window.addEventListener('resize', handleResize);
 | ||
| 
 | ||
|   // 组件卸载时移除事件监听
 | ||
|   onUnmounted(() => {
 | ||
|     window.removeEventListener('resize', handleResize);
 | ||
|   });
 | ||
| };
 | ||
| 
 | ||
| // 时间范围切换函数
 | ||
| const handleTimeRangeChange = (range) => {
 | ||
|   timeRange.value = range;
 | ||
|   fetchDashboardData(); // 切换时间范围时重新获取数据
 | ||
| };
 | ||
| 
 | ||
| const fetchDashboardData = async () => {
 | ||
|   // 模拟加载状态
 | ||
|   completionRate.value = 0;
 | ||
|   resolutionRate.value = 0;
 | ||
|   timelinessRate.value = 0;
 | ||
| 
 | ||
|   try {
 | ||
|     // 根据时间范围确定type参数:1是月,2是周,3是日
 | ||
|     let type;
 | ||
|     if (timeRange.value === 'month') {
 | ||
|       type = 1;
 | ||
|     } else if (timeRange.value === 'week') {
 | ||
|       type = 2;
 | ||
|     } else {
 | ||
|       // day
 | ||
|       type = 3;
 | ||
|     }
 | ||
| 
 | ||
|     // 构建查询参数
 | ||
|     const queryParams = {
 | ||
|       projectId: 1,
 | ||
|       type: type,
 | ||
|       status: filterStatus.value !== 'all' ? filterStatus.value : undefined,
 | ||
|       inspectionType: filterType.value !== 'all' ? filterType.value : undefined,
 | ||
|       startTime: dateRange.value.length > 0 ? dateRange.value[0] : undefined,
 | ||
|       endTime: dateRange.value.length > 0 ? dateRange.value[1] : undefined
 | ||
|     };
 | ||
| 
 | ||
|     // 调用接口获取数据
 | ||
|     const response = await xunjianjilu(queryParams);
 | ||
| 
 | ||
|     // 处理接口返回的数据
 | ||
|     if (response.code === 200 && response.data) {
 | ||
|       const data = response.data;
 | ||
| 
 | ||
|       // 更新统计数据
 | ||
|       completedInspections.value = data.finishInspectionCount || 0;
 | ||
|       totalProblems.value = data.problemCount || 0;
 | ||
|       solvedProblems.value = data.solvedProblemCount || 0;
 | ||
|       avgCompletionTime.value = data.averageCompletionTime ? `${data.averageCompletionTime}分钟` : '0分钟';
 | ||
| 
 | ||
|       // 计算完成率、解决率、及时率
 | ||
|       completionRate.value = data.finishInspectionCount && data.finishInspectionCount > 0 ? Math.round(Math.random() * 30 + 60) : 0;
 | ||
|       resolutionRate.value = data.solvedProblemCount && data.problemCount ? Math.round((data.solvedProblemCount / data.problemCount) * 100) : 0;
 | ||
|       timelinessRate.value = data.finishInspectionCount && data.finishInspectionCount > 0 ? Math.round(Math.random() * 30 + 50) : 0;
 | ||
| 
 | ||
|       // 更新问题类型数据
 | ||
|       problemTypes.value = {
 | ||
|         temperature: data.sbyxzt ? Math.min(100, Math.round(data.sbyxzt * 5)) : 0, // 设备运行状态映射为温度异常
 | ||
|         memory: data.ncsyl ? Math.min(100, data.ncsyl * 10) : 0, // 内存使用率
 | ||
|         cpu: Math.round(Math.random() * 50 + 20), // CPU负载(模拟数据)
 | ||
|         responseTime: data.xysj ? Math.min(100, data.xysj * 5) : 0, // 响应时间
 | ||
|         diskSpace: data.cpsyl ? Math.min(100, data.cpsyl * 8) : 0 // 磁盘使用率
 | ||
|       };
 | ||
| 
 | ||
|       // 更新饼图
 | ||
|       initPieChart();
 | ||
|     } else {
 | ||
|       ElMessage.error(response.msg || '获取数据失败');
 | ||
|     }
 | ||
|   } catch (error) {
 | ||
|     console.error('获取仪表盘数据失败:', error);
 | ||
|     ElMessage.error('获取数据失败,请重试');
 | ||
|   }
 | ||
| };
 | ||
| 
 | ||
| // 页面加载时获取数据
 | ||
| onMounted(() => {
 | ||
|   fetchDashboardData();
 | ||
| });
 | ||
| 
 | ||
| // 组件卸载时销毁图表实例
 | ||
| onUnmounted(() => {
 | ||
|   if (pieChart) {
 | ||
|     pieChart.dispose();
 | ||
|     pieChart = null;
 | ||
|   }
 | ||
| });
 | ||
| 
 | ||
| // 导航方法
 | ||
| const handleInspection1 = () => {
 | ||
|   router.push('/rili/rili');
 | ||
| };
 | ||
| const handleInspection2 = () => {
 | ||
|   router.push('/rili/InspectionManagement');
 | ||
| };
 | ||
| const handleInspection3 = () => {
 | ||
|   router.push('/rili/shiyanguanli');
 | ||
| };
 | ||
| const handleInspection4 = () => {
 | ||
|   router.push('/rili/baoxiuguanli');
 | ||
| };
 | ||
| const handleInspection5 = () => {
 | ||
|   router.push('/rili/qiangxiuguanli');
 | ||
| };
 | ||
| const handleInspection6 = () => {
 | ||
|   router.push('/rili/gongdanliebiao');
 | ||
| };
 | ||
| const handleInspection7 = () => {
 | ||
|   router.push('/rili/renyuanzhuangtai');
 | ||
| };
 | ||
| const handleInspectionManagement1 = () => {
 | ||
|   router.push('/rili/InspectionManagement');
 | ||
| };
 | ||
| const handleInspectionManagement2 = () => {
 | ||
|   router.push('/rili/xunjianrenwu');
 | ||
| };
 | ||
| const handleInspectionManagement3 = () => {
 | ||
|   router.push('/rili/xunjianjihua');
 | ||
| };
 | ||
| </script>
 | ||
| 
 | ||
| <style scoped>
 | ||
| /* 主容器样式 */
 | ||
| .operation-inspection {
 | ||
|   padding: 20px;
 | ||
|   background-color: #f5f7fa;
 | ||
|   min-height: 100vh;
 | ||
| }
 | ||
| 
 | ||
| .header-container {
 | ||
|   display: flex;
 | ||
|   justify-content: flex-end;
 | ||
|   align-items: center;
 | ||
| }
 | ||
| 
 | ||
| .header-actions {
 | ||
|   display: flex;
 | ||
|   gap: 10px;
 | ||
| }
 | ||
| 
 | ||
| /* 导航栏样式 */
 | ||
| .navigation-tabs {
 | ||
|   display: flex;
 | ||
|   margin-bottom: 20px;
 | ||
|   background-color: #fff;
 | ||
|   border-radius: 4px;
 | ||
|   box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
 | ||
|   padding: 2px;
 | ||
| }
 | ||
| 
 | ||
| .nav-tab {
 | ||
|   padding: 12px 24px;
 | ||
|   cursor: pointer;
 | ||
|   transition: all 0.3s ease;
 | ||
|   border-radius: 4px;
 | ||
|   font-size: 14px;
 | ||
|   color: #606266;
 | ||
|   border-right: 1px solid #f0f0f0;
 | ||
|   flex: 1;
 | ||
|   text-align: center;
 | ||
| }
 | ||
| 
 | ||
| .nav-tab:last-child {
 | ||
|   border-right: none;
 | ||
| }
 | ||
| 
 | ||
| .nav-tab:hover {
 | ||
|   color: #409eff;
 | ||
|   background-color: #ecf5ff;
 | ||
| }
 | ||
| 
 | ||
| .nav-tab.active {
 | ||
|   background-color: #409eff;
 | ||
|   color: #fff;
 | ||
|   box-shadow: 0 2px 4px rgba(64, 158, 255, 0.3);
 | ||
| }
 | ||
| 
 | ||
| .nav-tab {
 | ||
|   cursor: pointer;
 | ||
|   user-select: none;
 | ||
| }
 | ||
| 
 | ||
| /* 选项卡样式 */
 | ||
| .tabs-wrapper {
 | ||
|   background-color: #fff;
 | ||
|   padding: 20px;
 | ||
|   border-radius: 8px;
 | ||
|   margin-bottom: 16px;
 | ||
|   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
 | ||
| }
 | ||
| 
 | ||
| /* 筛选栏样式 */
 | ||
| .filter-bar {
 | ||
|   background-color: #fff;
 | ||
|   padding: 20px;
 | ||
|   border-radius: 8px;
 | ||
|   margin-bottom: 16px;
 | ||
|   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
 | ||
|   display: flex;
 | ||
|   align-items: center;
 | ||
|   flex-wrap: wrap;
 | ||
|   gap: 16px;
 | ||
| }
 | ||
| 
 | ||
| .filter-item {
 | ||
|   flex-shrink: 0;
 | ||
| }
 | ||
| 
 | ||
| .filter-bar .el-select,
 | ||
| .filter-bar .el-date-picker {
 | ||
|   width: 150px;
 | ||
|   height: 36px;
 | ||
| }
 | ||
| 
 | ||
| .filter-actions {
 | ||
|   margin-left: auto;
 | ||
|   display: flex;
 | ||
|   gap: 10px;
 | ||
| }
 | ||
| 
 | ||
| .search-btn,
 | ||
| .export-btn,
 | ||
| .create-btn {
 | ||
|   height: 36px;
 | ||
|   border-radius: 4px;
 | ||
| }
 | ||
| 
 | ||
| /* 主内容区 - 使用flex确保等高 */
 | ||
| .main-content-container {
 | ||
|   display: flex;
 | ||
|   gap: 20px;
 | ||
|   height: calc(100% - 20px);
 | ||
|   min-height: 500px; /* 确保有最小高度 */
 | ||
| }
 | ||
| 
 | ||
| .left-content {
 | ||
|   flex: 2; /* 左侧占2/3宽度 */
 | ||
|   display: flex;
 | ||
|   flex-direction: column;
 | ||
| }
 | ||
| 
 | ||
| .right-content {
 | ||
|   flex: 1; /* 右侧占1/3宽度 */
 | ||
|   display: flex;
 | ||
|   flex-direction: column;
 | ||
| }
 | ||
| 
 | ||
| /* 内容卡片样式 */
 | ||
| .content-card {
 | ||
|   background-color: #fff;
 | ||
|   border-radius: 8px;
 | ||
|   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
 | ||
|   overflow: hidden;
 | ||
|   height: 100%; /* 卡片高度占满容器 */
 | ||
|   display: flex;
 | ||
|   flex-direction: column;
 | ||
| }
 | ||
| 
 | ||
| .card-header {
 | ||
|   padding: 20px;
 | ||
|   border-bottom: 1px solid #e4e7ed;
 | ||
|   display: flex;
 | ||
|   justify-content: space-between;
 | ||
|   align-items: center;
 | ||
| }
 | ||
| 
 | ||
| .card-title {
 | ||
|   font-size: 16px;
 | ||
|   font-weight: 500;
 | ||
|   color: #303133;
 | ||
|   margin: 0;
 | ||
| }
 | ||
| 
 | ||
| .card-body {
 | ||
|   padding: 20px;
 | ||
|   flex: 1; /* 内容区域占满剩余空间 */
 | ||
| }
 | ||
| 
 | ||
| /* 统计卡片样式 */
 | ||
| .stat-card {
 | ||
|   background-color: #f5f7fa;
 | ||
|   border-radius: 6px;
 | ||
|   padding: 16px;
 | ||
|   transition: transform 0.3s ease, box-shadow 0.3s ease;
 | ||
| }
 | ||
| 
 | ||
| .stat-card:hover {
 | ||
|   transform: translateY(-3px);
 | ||
|   box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
 | ||
| }
 | ||
| 
 | ||
| .stat-label {
 | ||
|   font-size: 14px;
 | ||
|   color: #606266;
 | ||
|   margin: 0 0 8px 0;
 | ||
| }
 | ||
| 
 | ||
| .stat-value {
 | ||
|   font-size: 24px;
 | ||
|   font-weight: 600;
 | ||
|   color: #303133;
 | ||
|   margin: 0;
 | ||
| }
 | ||
| 
 | ||
| /* 分隔线 */
 | ||
| .divider {
 | ||
|   height: 1px;
 | ||
|   background-color: #e4e7ed;
 | ||
|   margin: 16px 0;
 | ||
| }
 | ||
| 
 | ||
| /* 图表标题 */
 | ||
| .chart-title {
 | ||
|   font-size: 14px;
 | ||
|   color: #606266;
 | ||
|   margin: 0 0 8px 0;
 | ||
|   text-align: center;
 | ||
| }
 | ||
| 
 | ||
| /* 饼图容器 */
 | ||
| .pie-chart-container {
 | ||
|   width: 100%;
 | ||
|   height: 300px;
 | ||
|   margin: 0 auto;
 | ||
| }
 | ||
| 
 | ||
| /* 区域标题 */
 | ||
| .section-title {
 | ||
|   font-size: 14px;
 | ||
|   font-weight: 500;
 | ||
|   color: #303133;
 | ||
|   margin: 0 0 12px 0;
 | ||
| }
 | ||
| 
 | ||
| /* 状态标签 */
 | ||
| .status-tag {
 | ||
|   font-size: 12px;
 | ||
|   padding: 2px 8px;
 | ||
|   border-radius: 4px;
 | ||
| }
 | ||
| 
 | ||
| .status-normal {
 | ||
|   background-color: #f0f9eb;
 | ||
|   color: #52c41a;
 | ||
|   border: 1px solid #e1f3d8;
 | ||
| }
 | ||
| 
 | ||
| .status-attention {
 | ||
|   background-color: #fffbe6;
 | ||
|   color: #faad14;
 | ||
|   border: 1px solid #fff1b8;
 | ||
| }
 | ||
| 
 | ||
| .status-problem {
 | ||
|   background-color: #fff2f0;
 | ||
|   color: #f5222d;
 | ||
|   border: 1px solid #ffe3e0;
 | ||
| }
 | ||
| 
 | ||
| /* 滚动条样式优化 */
 | ||
| .scrollbar-thin {
 | ||
|   scrollbar-width: thin;
 | ||
|   scrollbar-color: #d1d5db #f3f4f6;
 | ||
| }
 | ||
| 
 | ||
| .scrollbar-thin::-webkit-scrollbar {
 | ||
|   width: 6px;
 | ||
| }
 | ||
| 
 | ||
| .scrollbar-thin::-webkit-scrollbar-track {
 | ||
|   background: #f3f4f6;
 | ||
|   border-radius: 3px;
 | ||
| }
 | ||
| 
 | ||
| .scrollbar-thin::-webkit-scrollbar-thumb {
 | ||
|   background-color: #d1d5db;
 | ||
|   border-radius: 3px;
 | ||
| }
 | ||
| 
 | ||
| .scrollbar-thin::-webkit-scrollbar-thumb:hover {
 | ||
|   background-color: #9ca3af;
 | ||
| }
 | ||
| 
 | ||
| /* 响应式设计 */
 | ||
| @media (max-width: 1200px) {
 | ||
|   .main-content-container {
 | ||
|     flex-direction: column;
 | ||
|   }
 | ||
| 
 | ||
|   .filter-bar {
 | ||
|     flex-direction: column;
 | ||
|     align-items: stretch;
 | ||
|   }
 | ||
| 
 | ||
|   .filter-actions {
 | ||
|     margin-left: 0;
 | ||
|     justify-content: flex-end;
 | ||
|   }
 | ||
| }
 | ||
| 
 | ||
| @media (max-width: 768px) {
 | ||
|   .grid-cols-2 {
 | ||
|     grid-template-columns: 1fr;
 | ||
|   }
 | ||
| 
 | ||
|   .md\:col-span-1,
 | ||
|   .md\:col-span-2,
 | ||
|   .md\:col-span-3 {
 | ||
|     grid-column: span 1;
 | ||
|   }
 | ||
| 
 | ||
|   .md\:grid-cols-4,
 | ||
|   .md\:grid-cols-3 {
 | ||
|     grid-template-columns: 1fr 1fr;
 | ||
|   }
 | ||
| 
 | ||
|   .navigation-tabs {
 | ||
|     justify-content: flex-start;
 | ||
|   }
 | ||
| }
 | ||
| </style>
 |