<template>
|
<div class="device-detail-container">
|
<a-page-header
|
title="空压机预测性维护详情"
|
:sub-title="deviceInfo.deviceName"
|
@back="() => $router.go(-1)"
|
/>
|
|
<a-row :gutter="16" class="mt-4">
|
<!-- 设备基本信息 -->
|
<a-col :span="8">
|
<a-card title="设备基本信息" class="mb-4" :style="{ height: '440px' }">
|
<a-descriptions bordered :column="1">
|
<a-descriptions-item label="设备名称">{{ deviceInfo.deviceName }}</a-descriptions-item>
|
<a-descriptions-item label="设备类型">{{ deviceInfo.deviceType }}</a-descriptions-item>
|
<a-descriptions-item label="设备编号">{{ deviceInfo.deviceId }}</a-descriptions-item>
|
<a-descriptions-item label="安装日期">{{ deviceInfo.installDate }}</a-descriptions-item>
|
<a-descriptions-item label="使用年限">{{ deviceInfo.serviceLife }}年</a-descriptions-item>
|
<a-descriptions-item label="当前状态">
|
<a-tag :color="deviceInfo.statusColor">{{ deviceInfo.status }}</a-tag>
|
</a-descriptions-item>
|
</a-descriptions>
|
</a-card>
|
</a-col>
|
|
<!-- 设备健康状态与维护建议 -->
|
<a-col :span="16">
|
<a-card title="设备健康状态与维护建议" class="mb-4" :style="{ height: '440px' }">
|
<a-row :gutter="16">
|
<a-col :span="8">
|
<a-statistic
|
title="整体健康度"
|
:value="healthData.overallHealth"
|
:precision="0"
|
suffix="%"
|
:value-style="{ color: healthData.healthColor }"
|
/>
|
</a-col>
|
<a-col :span="8">
|
<a-statistic
|
title="预测剩余寿命"
|
:value="healthData.predictedLife"
|
suffix="天"
|
/>
|
</a-col>
|
<a-col :span="8">
|
<a-statistic
|
title="故障风险等级"
|
:value="healthData.riskLevel"
|
:value-style="{ color: healthData.riskColor }"
|
/>
|
</a-col>
|
</a-row>
|
<div class="mt-4">
|
<a-progress
|
:percent="healthData.overallHealth"
|
:stroke-color="healthData.healthColor"
|
:show-info="false"
|
/>
|
</div>
|
<a-divider orientation="left">预测性维护建议</a-divider>
|
<a-table
|
:columns="maintenanceColumns"
|
:data-source="maintenanceData"
|
:pagination="false"
|
size="small"
|
>
|
<template #urgency="{ text }">
|
<a-tag :color="getUrgencyColor(text)">{{ text }}</a-tag>
|
</template>
|
<template #action="{ record }">
|
<a-button type="link" size="small" @click="handleMaintenance(record)">处理</a-button>
|
</template>
|
</a-table>
|
</a-card>
|
</a-col>
|
</a-row>
|
|
<!-- 实时数据趋势图 -->
|
<a-card title="实时数据趋势图" class="mb-4">
|
<a-row :gutter="16">
|
<a-col :span="8">
|
<div id="exhaustPressureChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="exhaustTemperatureChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="hostVibrationChart" style="height: 300px;"></div>
|
</a-col>
|
</a-row>
|
<a-row :gutter="16" class="mt-4">
|
<a-col :span="8">
|
<div id="mainBearingTemperatureChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="mainMotorCurrentChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="oilTemperatureChart" style="height: 300px;"></div>
|
</a-col>
|
</a-row>
|
<a-row :gutter="16" class="mt-4">
|
<a-col :span="8">
|
<div id="oilPressureChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="oilLevelChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="inletPressureChart" style="height: 300px;"></div>
|
</a-col>
|
</a-row>
|
<a-row :gutter="16" class="mt-4">
|
<a-col :span="8">
|
<div id="inletTemperatureChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="airFlowChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="dryerDewPointChart" style="height: 300px;"></div>
|
</a-col>
|
</a-row>
|
<a-row :gutter="16" class="mt-4">
|
<a-col :span="8">
|
<div id="coolingWaterTemperatureChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="coolingWaterFlowChart" style="height: 300px;"></div>
|
</a-col>
|
<a-col :span="8">
|
<div id="ambientTemperatureHumidityChart" style="height: 300px;"></div>
|
</a-col>
|
</a-row>
|
</a-card>
|
<a-row :gutter="16">
|
<!-- 备件寿命预测 -->
|
<a-col :span="12">
|
<a-card title="备件寿命预测" class="mb-4">
|
<a-table
|
:columns="sparePartColumns"
|
:data-source="sparePartData"
|
:pagination="false"
|
size="small"
|
>
|
<template #status="{ text }">
|
<a-tag :color="getStatusColor(text)">{{ text }}</a-tag>
|
</template>
|
</a-table>
|
</a-card>
|
</a-col>
|
|
<!-- 历史维护记录 -->
|
<a-col :span="12">
|
<a-card title="历史维护记录" class="mb-4">
|
<a-timeline>
|
<a-timeline-item v-for="item in historyData" :key="item.id" :color="item.color">
|
{{ item.date }} - {{ item.type }}: {{ item.description }}
|
</a-timeline-item>
|
</a-timeline>
|
</a-card>
|
</a-col>
|
</a-row>
|
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { defineComponent, reactive, onMounted, onUnmounted } from 'vue';
|
import * as echarts from 'echarts';
|
|
export default defineComponent({
|
name: 'AirCompressorDetail',
|
setup() {
|
// 模拟数据
|
const deviceInfo = reactive({
|
deviceName: '空压机 #AC-001',
|
deviceType: '空压机',
|
deviceId: 'AC-2024-001',
|
installDate: '2023-05-10',
|
serviceLife: 10,
|
status: '运行中',
|
statusColor: '#52c41a'
|
});
|
|
const healthData = reactive({
|
overallHealth: 92,
|
healthColor: '#52c41a',
|
predictedLife: 3000,
|
riskLevel: '低风险',
|
riskColor: '#52c41a'
|
});
|
|
const maintenanceColumns = [
|
{
|
title: '维护类型',
|
dataIndex: 'type',
|
key: 'type'
|
},
|
{
|
title: '维护内容',
|
dataIndex: 'content',
|
key: 'content'
|
},
|
{
|
title: '建议时间',
|
dataIndex: 'suggestedTime',
|
key: 'suggestedTime'
|
},
|
{
|
title: '紧急程度',
|
dataIndex: 'urgency',
|
key: 'urgency',
|
slots: { customRender: 'urgency' }
|
},
|
{
|
title: '操作',
|
key: 'action',
|
slots: { customRender: 'action' }
|
}
|
];
|
|
const maintenanceData = reactive([
|
{
|
key: '1',
|
type: '例行保养',
|
content: '检查主机紧固件',
|
suggestedTime: '2024-07-01',
|
urgency: '中等'
|
},
|
{
|
key: '2',
|
type: '润滑系统维护',
|
content: '更换润滑油',
|
suggestedTime: '2024-09-01',
|
urgency: '高'
|
},
|
{
|
key: '3',
|
type: '空气系统维护',
|
content: '更换空滤芯',
|
suggestedTime: '2024-08-15',
|
urgency: '低'
|
}
|
]);
|
|
const getUrgencyColor = (urgency: string) => {
|
switch (urgency) {
|
case '高':
|
return 'red';
|
case '中等':
|
return 'orange';
|
case '低':
|
return 'green';
|
default:
|
return 'default';
|
}
|
};
|
|
const sparePartColumns = [
|
{
|
title: '备件名称',
|
dataIndex: 'name',
|
key: 'name'
|
},
|
{
|
title: '当前寿命',
|
dataIndex: 'currentLife',
|
key: 'currentLife',
|
customRender: ({ text }: { text: number }) => `${text}小时`
|
},
|
{
|
title: '预测剩余寿命',
|
dataIndex: 'remainingLife',
|
key: 'remainingLife',
|
customRender: ({ text }: { text: number }) => `${text}小时`
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
key: 'status',
|
slots: { customRender: 'status' }
|
}
|
];
|
|
const sparePartData = reactive([
|
{
|
key: '1',
|
name: '空滤芯',
|
currentLife: 1000,
|
remainingLife: 200,
|
status: '预警'
|
},
|
{
|
key: '2',
|
name: '油滤芯',
|
currentLife: 1500,
|
remainingLife: 500,
|
status: '良好'
|
},
|
{
|
key: '3',
|
name: '油气分离器',
|
currentLife: 2000,
|
remainingLife: 300,
|
status: '预警'
|
}
|
]);
|
|
const historyData = reactive([
|
{
|
id: '1',
|
date: '2024-06-10',
|
type: '例行保养',
|
description: '更换空滤芯、油滤芯',
|
color: 'green'
|
},
|
{
|
id: '2',
|
date: '2024-03-05',
|
type: '故障维修',
|
description: '主机轴承润滑脂补充',
|
color: 'red'
|
},
|
{
|
id: '3',
|
date: '2023-12-01',
|
type: '年度保养',
|
description: '全面检查设备运行状态',
|
color: 'green'
|
}
|
]);
|
|
const getStatusColor = (status: string) => {
|
switch (status) {
|
case '良好':
|
return '#52c41a';
|
case '预警':
|
return '#faad14';
|
case '危险':
|
return '#f5222d';
|
default:
|
return '#d9d9d9';
|
}
|
};
|
|
const handleMaintenance = (record: any) => {
|
console.log('处理维护建议:', record);
|
// 实际项目中这里会调用API处理维护建议
|
};
|
|
return {
|
deviceInfo,
|
healthData,
|
maintenanceColumns,
|
maintenanceData,
|
sparePartColumns,
|
sparePartData,
|
historyData,
|
getStatusColor,
|
getUrgencyColor,
|
handleMaintenance
|
};
|
},
|
|
mounted() {
|
// 初始化图表
|
const initChart = (chartId: string, title: string, chartData: any[], unit: string, baseValue: number, fluctuation: number) => {
|
const chart = echarts.init(document.getElementById(chartId));
|
|
// 预先生成60个数据点
|
for (let i = 0; i < 60; i++) {
|
const now = new Date(Date.now() - (60 - 1 - i) * 5000); // 倒推时间
|
const time = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
|
const newValue = (baseValue + (Math.random() * fluctuation * 2 - fluctuation)).toFixed(2);
|
chartData.push({
|
time,
|
value: newValue
|
});
|
}
|
|
const updateChart = () => {
|
// 生成新的数据点
|
const now = new Date();
|
const time = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
|
const newValue = (baseValue + (Math.random() * fluctuation * 2 - fluctuation)).toFixed(2);
|
|
// 添加新数据点,最多保留60个点(5分钟数据)
|
chartData.push({
|
time,
|
value: newValue
|
});
|
if (chartData.length > 60) {
|
chartData.shift();
|
}
|
|
const option = {
|
title: {
|
text: title,
|
left: 'center'
|
},
|
tooltip: {
|
trigger: 'axis',
|
formatter: (params) => {
|
return `${params[0].axisValueLabel}<br/>${params[0].marker} ${params[0].seriesName}: ${params[0].data}${unit}`;
|
}
|
},
|
grid: {
|
left: '8%', // 增加左侧边距
|
right: '5%',
|
bottom: '10%',
|
containLabel: true
|
},
|
xAxis: {
|
type: 'category',
|
data: chartData.map(item => item.time)
|
},
|
yAxis: {
|
type: 'value',
|
axisLabel: {
|
formatter: (value) => `${value}${unit}`
|
}
|
},
|
series: [
|
{
|
data: chartData.map(item => parseFloat(item.value)),
|
type: 'line',
|
smooth: true,
|
lineStyle: {
|
width: 2,
|
color: '#5470C6' // Default color
|
},
|
areaStyle: {
|
opacity: 0.8,
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
{
|
offset: 0,
|
color: 'rgba(84,112,198,0.3)'
|
},
|
{
|
offset: 1,
|
color: 'rgba(84,112,198,0)'
|
}
|
])
|
},
|
}
|
]
|
};
|
chart.setOption(option);
|
};
|
|
// 初始渲染
|
updateChart();
|
|
// 每5秒更新一次数据
|
const intervalId = setInterval(updateChart, 5000);
|
|
window.addEventListener('resize', () => {
|
chart.resize();
|
});
|
onUnmounted(() => {
|
clearInterval(intervalId);
|
});
|
|
};
|
|
|
initChart('exhaustPressureChart', '排气压力', [], 'bar', 7.5, 0.2);
|
initChart('exhaustTemperatureChart', '排气温度', [], '°C', 85, 2);
|
initChart('hostVibrationChart', '主机振动', [], 'mm/s', 3.5, 0.5);
|
initChart('mainBearingTemperatureChart', '主轴承温度', [], '°C', 70, 3);
|
initChart('mainMotorCurrentChart', '主电机电流', [], 'A', 120, 5);
|
initChart('oilTemperatureChart', '油温', [], '°C', 60, 2);
|
initChart('oilPressureChart', '油压', [], 'bar', 4.0, 0.1);
|
initChart('oilLevelChart', '油位', [], '%', 80, 5);
|
initChart('inletPressureChart', '进气压力', [], 'bar', 1.0, 0.05);
|
initChart('inletTemperatureChart', '进气温度', [], '°C', 25, 2);
|
initChart('airFlowChart', '空气流量', [], 'm³/min', 15, 1);
|
initChart('dryerDewPointChart', '干燥器露点', [], '°C', 3, 1);
|
initChart('coolingWaterTemperatureChart', '冷却水温度', [], '°C', 30, 2);
|
initChart('coolingWaterFlowChart', '冷却水流量', [], 'L/min', 10, 0.5);
|
initChart('ambientTemperatureHumidityChart', '环境温湿度', [], '°C', 28, 2);
|
}
|
|
});
|
</script>
|
|
<style scoped>
|
.device-detail-container {
|
padding: 16px;
|
background: #f0f2f5;
|
}
|
|
.mt-4 {
|
margin-top: 16px;
|
}
|
|
.mb-4 {
|
margin-bottom: 16px;
|
}
|
</style>
|
|
|
<style scoped>
|
.air-compressor-detail {
|
padding: 16px;
|
background-color: #f0f2f5;
|
}
|
.header-card {
|
margin-bottom: 16px;
|
}
|
</style>
|