0922
This commit is contained in:
@ -10,10 +10,9 @@
|
||||
<div class="nav-tab" @click="handleInspection7">运维组织</div>
|
||||
</div>
|
||||
<div class="header-container">
|
||||
<TitleComponent title="运维巡检管理" subtitle="制定巡检计划,安排巡检任务,跟进巡检记录"></TitleComponent>
|
||||
<div class="header-actions">
|
||||
<el-button type="primary" class="export-btn">筛选</el-button>
|
||||
<el-button type="primary" class="create-btn">导入数据</el-button>
|
||||
<el-button type="primary" class="create-btn">导出数据</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -364,9 +363,10 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed, onUnmounted } from 'vue';
|
||||
import router from '@/router';
|
||||
import TitleComponent from './TitleComponent.vue';
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
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');
|
||||
@ -485,91 +485,70 @@ const handleTimeRangeChange = (range) => {
|
||||
fetchDashboardData(); // 切换时间范围时重新获取数据
|
||||
};
|
||||
|
||||
// 获取仪表盘数据(模拟)
|
||||
const fetchDashboardData = () => {
|
||||
const fetchDashboardData = async () => {
|
||||
// 模拟加载状态
|
||||
completionRate.value = 0;
|
||||
resolutionRate.value = 0;
|
||||
timelinessRate.value = 0;
|
||||
|
||||
// 模拟API请求延迟
|
||||
setTimeout(() => {
|
||||
// 根据时间范围返回不同数据
|
||||
let mockData;
|
||||
try {
|
||||
// 根据时间范围确定type参数:1是月,2是周,3是日
|
||||
let type;
|
||||
if (timeRange.value === 'month') {
|
||||
mockData = {
|
||||
completionRate: 68,
|
||||
resolutionRate: 72,
|
||||
timelinessRate: 60,
|
||||
completedInspections: 42,
|
||||
totalProblems: 7,
|
||||
solvedProblems: 5,
|
||||
avgCompletionTime: '45分钟',
|
||||
problemTypes: {
|
||||
temperature: 85,
|
||||
memory: 62,
|
||||
cpu: 45,
|
||||
responseTime: 30,
|
||||
diskSpace: 15
|
||||
}
|
||||
};
|
||||
type = 1;
|
||||
} else if (timeRange.value === 'week') {
|
||||
mockData = {
|
||||
completionRate: 75,
|
||||
resolutionRate: 80,
|
||||
timelinessRate: 65,
|
||||
completedInspections: 12,
|
||||
totalProblems: 2,
|
||||
solvedProblems: 2,
|
||||
avgCompletionTime: '35分钟',
|
||||
problemTypes: {
|
||||
temperature: 70,
|
||||
memory: 55,
|
||||
cpu: 40,
|
||||
responseTime: 25,
|
||||
diskSpace: 10
|
||||
}
|
||||
};
|
||||
type = 2;
|
||||
} else {
|
||||
// day
|
||||
mockData = {
|
||||
completionRate: 90,
|
||||
resolutionRate: 100,
|
||||
timelinessRate: 95,
|
||||
completedInspections: 2,
|
||||
totalProblems: 0,
|
||||
solvedProblems: 0,
|
||||
avgCompletionTime: '25分钟',
|
||||
problemTypes: {
|
||||
temperature: 30,
|
||||
memory: 45,
|
||||
cpu: 25,
|
||||
responseTime: 10,
|
||||
diskSpace: 5
|
||||
}
|
||||
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 || '获取数据失败');
|
||||
}
|
||||
|
||||
// 应用筛选条件(这里仅做简单演示)
|
||||
if (filterStatus.value === 'problem') {
|
||||
mockData.totalProblems = Math.round(mockData.totalProblems * 1.5);
|
||||
mockData.solvedProblems = Math.round(mockData.solvedProblems * 0.7);
|
||||
mockData.resolutionRate = Math.round(mockData.resolutionRate * 0.8);
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
completionRate.value = mockData.completionRate;
|
||||
resolutionRate.value = mockData.resolutionRate;
|
||||
timelinessRate.value = mockData.timelinessRate;
|
||||
completedInspections.value = mockData.completedInspections;
|
||||
totalProblems.value = mockData.totalProblems;
|
||||
solvedProblems.value = mockData.solvedProblems;
|
||||
avgCompletionTime.value = mockData.avgCompletionTime;
|
||||
problemTypes.value = mockData.problemTypes;
|
||||
|
||||
// 更新饼图
|
||||
initPieChart();
|
||||
}, 800); // 模拟网络延迟
|
||||
} catch (error) {
|
||||
console.error('获取仪表盘数据失败:', error);
|
||||
ElMessage.error('获取数据失败,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
// 页面加载时获取数据
|
||||
@ -626,17 +605,14 @@ const handleInspectionManagement3 = () => {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 头部容器 */
|
||||
.header-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user