|
|
|
|
@ -116,7 +116,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class="meta-item">
|
|
|
|
|
<i class="el-icon-time"></i>
|
|
|
|
|
<span>建立 {{ calculateRunDays(machine.createTime) }} 天</span>
|
|
|
|
|
<span>建立 {{ calculateRunDays(machine.createdTime) }} 天</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -144,9 +144,9 @@
|
|
|
|
|
<dict-tag :options="machine_status" :value="String(scope.row.deviceStatus)" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="创建时间" align="center" prop="createTime" min-width="160">
|
|
|
|
|
<el-table-column label="创建时间" align="center" prop="createdTime" min-width="160">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<span>{{ formatDate(scope.row.createTime) }}</span>
|
|
|
|
|
<span>{{ formatDate(scope.row.createdTime) }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="操作" align="center" width="320" fixed="right">
|
|
|
|
|
@ -239,7 +239,7 @@
|
|
|
|
|
<div class="overview-stats">
|
|
|
|
|
<div class="stat">
|
|
|
|
|
<span class="stat-label">建立天数</span>
|
|
|
|
|
<span class="stat-value">{{ calculateRunDays(selectedMachine.createTime) }}</span>
|
|
|
|
|
<span class="stat-value">{{ calculateRunDays(selectedMachine.createdTime) }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -307,7 +307,7 @@
|
|
|
|
|
<el-descriptions-item label="设备状态">
|
|
|
|
|
<dict-tag :options="machine_status" :value="String(selectedMachine ? (selectedMachine.deviceStatus || '') : '')" />
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
<el-descriptions-item label="创建时间">{{ selectedMachine ? formatDateTime(selectedMachine.createTime) : '' }}</el-descriptions-item>
|
|
|
|
|
<el-descriptions-item label="创建时间">{{ selectedMachine ? formatDateTime(selectedMachine.createdTime) : '' }}</el-descriptions-item>
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
@ -321,6 +321,11 @@
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { listDeviceLedger } from '@/api/base/deviceLedger';
|
|
|
|
|
import { listAllDmsBillsMaintInstance } from '@/api/dms/dmsBillsMaintInstance';
|
|
|
|
|
import { listAllDmsRecordInspect } from '@/api/dms/dmsRecordInspect';
|
|
|
|
|
import { listAllShutDown } from '@/api/dms/shutDown';
|
|
|
|
|
import { listAllDmsBillsFaultInstance } from '@/api/dms/dmsBillsFaultInstance';
|
|
|
|
|
import { listAllRepairRecord } from '@/api/dms/repairRecord';
|
|
|
|
|
import pagination from '@/components/Pagination';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
@ -616,25 +621,33 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
async loadLifecycleTypes() {
|
|
|
|
|
if (!this.selectedMachine) return;
|
|
|
|
|
const objId = this.selectedMachine.objId;
|
|
|
|
|
const deviceCode = this.selectedMachine.deviceCode;
|
|
|
|
|
try {
|
|
|
|
|
// 使用固定数量,与实际生成的假数据一致(每种最多3条)
|
|
|
|
|
// 并行获取所有类型的数据数量
|
|
|
|
|
const [maintRes, inspectRes, shutdownRes, faultRes, repairRes] = await Promise.all([
|
|
|
|
|
listAllDmsBillsMaintInstance({ deviceCode }).catch(() => ({ data: [] })),
|
|
|
|
|
listAllDmsRecordInspect({ deviceCode }).catch(() => ({ data: [] })),
|
|
|
|
|
listAllShutDown({ deviceCode }).catch(() => ({ data: [] })),
|
|
|
|
|
listAllDmsBillsFaultInstance({ deviceCode }).catch(() => ({ data: [] })),
|
|
|
|
|
listAllRepairRecord({ deviceCode }).catch(() => ({ data: [] }))
|
|
|
|
|
]);
|
|
|
|
|
// 更新各类型数量
|
|
|
|
|
this.lifecycleTypes.forEach(type => {
|
|
|
|
|
switch (type.value) {
|
|
|
|
|
case 'maintenance':
|
|
|
|
|
type.count = 3; // 保养记录:3条
|
|
|
|
|
type.count = (maintRes.data || []).length;
|
|
|
|
|
break;
|
|
|
|
|
case 'inspection':
|
|
|
|
|
type.count = 3; // 点检记录:3条
|
|
|
|
|
type.count = (inspectRes.data || []).length;
|
|
|
|
|
break;
|
|
|
|
|
case 'downtime':
|
|
|
|
|
type.count = 2; // 停机记录:2条
|
|
|
|
|
type.count = (shutdownRes.data || []).length;
|
|
|
|
|
break;
|
|
|
|
|
case 'fault':
|
|
|
|
|
type.count = 3; // 故障记录:3条
|
|
|
|
|
type.count = (faultRes.data || []).length;
|
|
|
|
|
break;
|
|
|
|
|
case 'repair':
|
|
|
|
|
type.count = 3; // 维修记录:3条
|
|
|
|
|
type.count = (repairRes.data || []).length;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
type.count = 0;
|
|
|
|
|
@ -652,104 +665,122 @@ export default {
|
|
|
|
|
const reqId = ++this.lifecycleRequestId;
|
|
|
|
|
this.lifecycleLoading = true;
|
|
|
|
|
const events = [];
|
|
|
|
|
const objId = this.selectedMachine.objId;
|
|
|
|
|
const deviceCode = this.selectedMachine.deviceCode;
|
|
|
|
|
try {
|
|
|
|
|
// 生成假数据
|
|
|
|
|
// 根据选中的类型加载对应数据
|
|
|
|
|
const promises = [];
|
|
|
|
|
this.selectedLifecycleTypes.forEach(type => {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 'maintenance':
|
|
|
|
|
// 保养记录(3条)
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
|
const maintenanceTypes = ['日常保养', '定期保养', '一级保养'];
|
|
|
|
|
const maintenancePersons = ['张三', '李四', '王五'];
|
|
|
|
|
events.push({
|
|
|
|
|
id: `maint-${i}`,
|
|
|
|
|
type: 'maintenance',
|
|
|
|
|
title: maintenanceTypes[i],
|
|
|
|
|
description: `保养单号: BY-${String(202401001 + i).padStart(9, '0')} | 保养人员: ${maintenancePersons[i]} | 状态: 已完成`,
|
|
|
|
|
time: new Date(Date.now() - (30 - i * 10) * 24 * 60 * 60 * 1000),
|
|
|
|
|
iconClass: 'el-icon-setting',
|
|
|
|
|
color: '#4facfe',
|
|
|
|
|
tags: ['保养', '已完成']
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
promises.push(
|
|
|
|
|
listAllDmsBillsMaintInstance({ deviceCode }).then(res => {
|
|
|
|
|
(res.data || []).forEach((item, i) => {
|
|
|
|
|
const statusMap = { 1: '待保养', 2: '保养中', 3: '已完成' };
|
|
|
|
|
const statusText = statusMap[item.maintStatus] || '未知';
|
|
|
|
|
events.push({
|
|
|
|
|
id: `maint-${item.maintInstanceId || i}`,
|
|
|
|
|
type: 'maintenance',
|
|
|
|
|
title: item.maintLevelName || '设备保养',
|
|
|
|
|
description: `保养单号: ${item.billsMaintCode || '-'} | 保养人员: ${item.maintSupervisor || '-'} | 状态: ${statusText}`,
|
|
|
|
|
time: item.realEndTime || item.realBeginTime || item.planBeginTime || item.createTime,
|
|
|
|
|
iconClass: 'el-icon-setting',
|
|
|
|
|
color: '#4facfe',
|
|
|
|
|
tags: ['保养', statusText]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case 'inspection':
|
|
|
|
|
// 点检记录(3条)
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
|
const inspectionStatus = ['正常', '异常', '正常'];
|
|
|
|
|
const inspectionPersons = ['张三', '李四', '王五'];
|
|
|
|
|
const statusTag = inspectionStatus[i] === '正常' ? '正常' : '异常';
|
|
|
|
|
events.push({
|
|
|
|
|
id: `inspect-${i}`,
|
|
|
|
|
type: 'inspection',
|
|
|
|
|
title: '设备点检',
|
|
|
|
|
description: `点检单号: DJ-${String(202401001 + i).padStart(9, '0')} | 点检人: ${inspectionPersons[i]} | 结果: ${inspectionStatus[i]}`,
|
|
|
|
|
time: new Date(Date.now() - (25 - i * 8) * 24 * 60 * 60 * 1000),
|
|
|
|
|
iconClass: 'el-icon-view',
|
|
|
|
|
color: inspectionStatus[i] === '正常' ? '#30cfd0' : '#ff7675',
|
|
|
|
|
tags: ['点检', statusTag]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
promises.push(
|
|
|
|
|
listAllDmsRecordInspect({ deviceCode }).then(res => {
|
|
|
|
|
(res.data || []).forEach((item, i) => {
|
|
|
|
|
const statusMap = { 1: '待巡检', 2: '巡检中', 3: '完成' };
|
|
|
|
|
const statusText = statusMap[item.inspectStatus] || '未知';
|
|
|
|
|
const inspectTypeText = item.inspectType === '1' ? '巡检' : '点检';
|
|
|
|
|
events.push({
|
|
|
|
|
id: `inspect-${item.recordInspectId || i}`,
|
|
|
|
|
type: 'inspection',
|
|
|
|
|
title: inspectTypeText,
|
|
|
|
|
description: `巡检单号: ${item.billsInspectCode || '-'} | 执行人: ${item.performer || '-'} | 状态: ${statusText}`,
|
|
|
|
|
time: item.realEndTime || item.realBeginTime || item.planBeginTime || item.createTime,
|
|
|
|
|
iconClass: 'el-icon-view',
|
|
|
|
|
color: statusText === '完成' ? '#30cfd0' : '#ff7675',
|
|
|
|
|
tags: [inspectTypeText, statusText]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case 'downtime':
|
|
|
|
|
// 停机记录(2条)
|
|
|
|
|
for (let i = 0; i < 2; i++) {
|
|
|
|
|
const downtimeReasons = ['计划停机-保养', '故障停机'];
|
|
|
|
|
const downtimeDurations = ['2小时', '4小时'];
|
|
|
|
|
events.push({
|
|
|
|
|
id: `downtime-${i}`,
|
|
|
|
|
type: 'downtime',
|
|
|
|
|
title: '设备停机',
|
|
|
|
|
description: `停机单号: TJ-${String(202401001 + i).padStart(9, '0')} | 原因: ${downtimeReasons[i]} | 时长: ${downtimeDurations[i]}`,
|
|
|
|
|
time: new Date(Date.now() - (20 - i * 8) * 24 * 60 * 60 * 1000),
|
|
|
|
|
iconClass: 'el-icon-warning-outline',
|
|
|
|
|
color: '#ffeaa7',
|
|
|
|
|
tags: ['停机', downtimeReasons[i].includes('计划') ? '计划' : '非计划']
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
promises.push(
|
|
|
|
|
listAllShutDown({ deviceCode }).then(res => {
|
|
|
|
|
(res.data || []).forEach((item, i) => {
|
|
|
|
|
const shutTimeText = item.shutTime ? `${item.shutTime}小时` : '-';
|
|
|
|
|
events.push({
|
|
|
|
|
id: `downtime-${item.recordShutDownId || i}`,
|
|
|
|
|
type: 'downtime',
|
|
|
|
|
title: '设备停机',
|
|
|
|
|
description: `原因: ${item.shutReason || '-'} | 时长: ${shutTimeText}`,
|
|
|
|
|
time: item.shutBeginTime || item.createTime,
|
|
|
|
|
iconClass: 'el-icon-warning-outline',
|
|
|
|
|
color: '#ffeaa7',
|
|
|
|
|
tags: ['停机', item.shutReason ? (item.shutReason.includes('计划') ? '计划' : '非计划') : '非计划']
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case 'fault':
|
|
|
|
|
// 故障记录(3条)
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
|
const faultTypes = ['电气故障', '机械故障', '液压故障'];
|
|
|
|
|
const faultLevels = ['一般', '严重', '一般'];
|
|
|
|
|
const faultPersons = ['张三', '李四', '王五'];
|
|
|
|
|
events.push({
|
|
|
|
|
id: `fault-${i}`,
|
|
|
|
|
type: 'fault',
|
|
|
|
|
title: faultTypes[i],
|
|
|
|
|
description: `故障单号: GZ-${String(202401001 + i).padStart(9, '0')} | 等级: ${faultLevels[i]} | 报修人: ${faultPersons[i]} | 状态: 已处理`,
|
|
|
|
|
time: new Date(Date.now() - (15 - i * 5) * 24 * 60 * 60 * 1000),
|
|
|
|
|
iconClass: 'el-icon-circle-close',
|
|
|
|
|
color: '#fa709a',
|
|
|
|
|
tags: ['故障', faultLevels[i]]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
promises.push(
|
|
|
|
|
listAllDmsBillsFaultInstance({ deviceCode }).then(res => {
|
|
|
|
|
(res.data || []).forEach((item, i) => {
|
|
|
|
|
const statusMap = { '0': '待维修', '1': '维修中', '2': '维修完成', '3': '待检修', '4': '检修中', '5': '检修完成' };
|
|
|
|
|
const statusText = statusMap[item.billsStatus] || '未知';
|
|
|
|
|
const faultLevelMap = { '1': '一般', '2': '紧急', '3': '严重' };
|
|
|
|
|
const levelText = faultLevelMap[item.faultLevel] || '一般';
|
|
|
|
|
events.push({
|
|
|
|
|
id: `fault-${item.repairInstanceId || i}`,
|
|
|
|
|
type: 'fault',
|
|
|
|
|
title: item.faultType || '设备故障',
|
|
|
|
|
description: `故障单号: ${item.billsFaultCode || '-'} | 等级: ${levelText} | 报修人: ${item.applyUser || '-'} | 状态: ${statusText}`,
|
|
|
|
|
time: item.applyTime || item.createTime,
|
|
|
|
|
iconClass: 'el-icon-circle-close',
|
|
|
|
|
color: '#fa709a',
|
|
|
|
|
tags: ['故障', levelText]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case 'repair':
|
|
|
|
|
// 维修记录(3条)
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
|
const repairTypes = ['预防性维修', '故障维修', '改进性维修'];
|
|
|
|
|
const repairStatus = ['已完成', '已完成', '进行中'];
|
|
|
|
|
const repairPersons = ['张三', '李四', '王五'];
|
|
|
|
|
events.push({
|
|
|
|
|
id: `repair-${i}`,
|
|
|
|
|
type: 'repair',
|
|
|
|
|
title: repairTypes[i],
|
|
|
|
|
description: `维修单号: WX-${String(202401001 + i).padStart(9, '0')} | 维修人: ${repairPersons[i]} | 状态: ${repairStatus[i]}`,
|
|
|
|
|
time: new Date(Date.now() - (12 - i * 4) * 24 * 60 * 60 * 1000),
|
|
|
|
|
iconClass: 'el-icon-tools',
|
|
|
|
|
color: '#667eea',
|
|
|
|
|
tags: ['维修', repairStatus[i]]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
promises.push(
|
|
|
|
|
listAllRepairRecord({ deviceCode }).then(res => {
|
|
|
|
|
(res.data || []).forEach((item, i) => {
|
|
|
|
|
const resultMap = { '1': '成功', '2': '失败', '3': '部分完成' };
|
|
|
|
|
const resultText = resultMap[item.repairResult] || '未知';
|
|
|
|
|
events.push({
|
|
|
|
|
id: `repair-${item.recordId || i}`,
|
|
|
|
|
type: 'repair',
|
|
|
|
|
title: item.faultPhenomenon || '设备维修',
|
|
|
|
|
description: `工单编号: ${item.workOrderCode || '-'} | 维修人: ${item.repairerName || '-'} | 结果: ${resultText}`,
|
|
|
|
|
time: item.endTime || item.startTime || item.createTime,
|
|
|
|
|
iconClass: 'el-icon-tools',
|
|
|
|
|
color: '#667eea',
|
|
|
|
|
tags: ['维修', resultText]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await Promise.all(promises);
|
|
|
|
|
if (reqId === this.lifecycleRequestId) {
|
|
|
|
|
this.lifecycleEvents = events.sort((a, b) => {
|
|
|
|
|
return new Date(b.time).getTime() - new Date(a.time).getTime();
|
|
|
|
|
const timeA = a.time ? new Date(a.time).getTime() : 0;
|
|
|
|
|
const timeB = b.time ? new Date(b.time).getTime() : 0;
|
|
|
|
|
return timeB - timeA;
|
|
|
|
|
});
|
|
|
|
|
this.lifecycleLoading = false;
|
|
|
|
|
}
|
|
|
|
|
|