<template>
|
<view class="device-info-container">
|
<PageHeader title="设备信息" @back="goBack" />
|
|
<!-- 基本信息 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">基本信息</text>
|
<text
|
class="device-status"
|
:class="deviceInfo.status === 1 ? 'status-enabled' : 'status-disabled'"
|
>
|
{{ deviceInfo.status === 1 ? '启用' : '停用' }}
|
</text>
|
</view>
|
<view class="card-content">
|
<view class="info-row">
|
<text class="label">设备编号:</text>
|
<text class="value">{{ deviceInfo.uniqueCode || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">设备名称:</text>
|
<text class="value">{{ deviceInfo.deviceName || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">规格型号:</text>
|
<text class="value">{{ deviceInfo.deviceModel || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">设备品牌:</text>
|
<text class="value">{{ deviceInfo.deviceBrand || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">设备类型:</text>
|
<text class="value">{{ deviceInfo.type || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">出厂编号:</text>
|
<text class="value">{{ deviceInfo.factoryNumber || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">存放位置:</text>
|
<text class="value">{{ deviceInfo.storageLocation || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">责任人:</text>
|
<text class="value">{{ deviceInfo.responsiblePerson || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">单位:</text>
|
<text class="value">{{ deviceInfo.unit || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">建档日期:</text>
|
<text class="value">{{ formatDate(deviceInfo.filingDate) }}</text>
|
</view>
|
</view>
|
</view>
|
|
<!-- 采购信息 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">采购信息</text>
|
</view>
|
<view class="card-content">
|
<view class="info-row">
|
<text class="label">供应商:</text>
|
<text class="value">{{ deviceInfo.supplierName || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">制造厂商:</text>
|
<text class="value">{{ deviceInfo.manufacturer || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">购置日期:</text>
|
<text class="value">{{ formatDate(deviceInfo.purchaseDate) }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">资产原值:</text>
|
<text class="value">{{ deviceInfo.originalAssetValue ?? '--' }}</text>
|
</view>
|
</view>
|
</view>
|
|
<!-- 技术参数 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">技术参数</text>
|
</view>
|
<view class="card-content">
|
<view class="info-row">
|
<text class="label">主要技术参数:</text>
|
<text class="value">{{ deviceInfo.technicalParameters || '--' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">主要用途:</text>
|
<text class="value">{{ deviceInfo.mainPurpose || '--' }}</text>
|
</view>
|
</view>
|
</view>
|
|
<!-- 运行管理 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">运行管理</text>
|
</view>
|
<view class="card-content">
|
<view class="info-row">
|
<text class="label">启用日期:</text>
|
<text class="value">{{ formatDate(deviceInfo.activationDate) }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">预计运行时间:</text>
|
<text class="value">{{ formatDate(deviceInfo.planRuntimeTime) }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">启用折旧:</text>
|
<text class="value">{{ deviceInfo.isDepr === 1 ? '是' : '否' }}</text>
|
</view>
|
<view v-if="deviceInfo.isDepr === 1" class="info-row">
|
<text class="label">每年折旧金额:</text>
|
<text class="value">{{ deviceInfo.annualDepreciationAmount ?? '--' }}</text>
|
</view>
|
</view>
|
</view>
|
|
<!-- 变更记录 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">变更记录</text>
|
</view>
|
<view class="card-content">
|
<view v-if="!recordsLoading && changeRecords.length === 0" class="empty-tip">暂无变更记录</view>
|
<view v-else class="change-record" v-for="(item, index) in changeRecords" :key="index">
|
<view class="record-header">
|
<text class="record-time">{{ item.createTime }}</text>
|
<text class="record-status" :class="approvalClass(item.approvalStatus)">{{ approvalText(item.approvalStatus) }}</text>
|
</view>
|
<view class="record-line">
|
<text class="record-status-change">{{ statusText(item.originalStatus) }} → {{ statusText(item.targetStatus) }}</text>
|
<text class="record-user">申请人:{{ item.createUserName || '--' }}</text>
|
</view>
|
<view class="record-reason">变更原因:{{ item.reason || '--' }}</view>
|
<view v-if="item.approvalStatus === 'REJECTED' && item.rejectReason" class="record-reject">驳回原因:{{ item.rejectReason }}</view>
|
</view>
|
</view>
|
</view>
|
|
<!-- 报修记录 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">报修记录</text>
|
</view>
|
<view class="card-content">
|
<view v-if="repairRecords.length === 0" class="empty-tip">暂无报修记录</view>
|
<view v-else class="change-record" v-for="(item, index) in repairRecords" :key="index">
|
<view class="record-header">
|
<text class="record-time">{{ formatDate(item.repairTime) }}</text>
|
<text class="record-status" :class="item.status === 1 ? 'status-approved' : 'status-rejected'">
|
{{ item.status === 1 ? '完结' : '待维修' }}
|
</text>
|
</view>
|
<view class="record-reason">报修人:{{ item.repairName || '--' }} 维修人:{{ item.maintenanceName || '--' }}</view>
|
<view class="record-reason">维修项目:{{ item.machineryCategory || '--' }}</view>
|
<view class="record-reason">故障现象:{{ item.remark || '--' }}</view>
|
<view class="record-reason">维修结果:{{ item.maintenanceResult || '--' }}</view>
|
</view>
|
</view>
|
</view>
|
|
<!-- 保养记录 -->
|
<view class="info-card">
|
<view class="card-header">
|
<text class="card-title">保养记录</text>
|
</view>
|
<view class="card-content">
|
<view v-if="upkeepRecords.length === 0" class="empty-tip">暂无保养记录</view>
|
<view v-else class="change-record" v-for="(item, index) in upkeepRecords" :key="index">
|
<view class="record-header">
|
<text class="record-time">{{ formatDate(item.maintenancePlanTime) }}</text>
|
<text class="record-status" :class="item.status === 1 ? 'status-approved' : 'status-rejected'">
|
{{ item.status === 1 ? '完结' : '待保养' }}
|
</text>
|
</view>
|
<view class="record-reason">保养项目:{{ item.machineryCategory || '--' }}</view>
|
<view class="record-reason">保养人:{{ item.maintenancePerson || '--' }} 录入人:{{ item.createUserName || '--' }}</view>
|
<view class="record-reason">实际保养日期:{{ formatDate(item.maintenanceActuallyTime) }}</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive } from 'vue'
|
import { onLoad } from '@dcloudio/uni-app'
|
import dayjs from 'dayjs'
|
import PageHeader from '@/components/PageHeader.vue'
|
import { getDeviceInfo } from '@/api/equipmentManagement/deviceInfo'
|
import { listStatusChangeRecord } from '@/api/device/statusChangeRecord'
|
import { getRepairPage } from '@/api/equipmentManagement/repair'
|
import { getUpkeepPage } from '@/api/equipmentManagement/upkeep'
|
import { unwrapList } from '@/utils/list'
|
|
const deviceInfo = reactive({
|
uniqueCode: '',
|
deviceName: '',
|
deviceModel: '',
|
deviceBrand: '',
|
type: '',
|
factoryNumber: '',
|
storageLocation: '',
|
responsiblePerson: '',
|
filingDate: '',
|
supplierName: '',
|
manufacturer: '',
|
purchaseDate: '',
|
originalAssetValue: null,
|
unit: '',
|
technicalParameters: '',
|
mainPurpose: '',
|
status: null,
|
activationDate: '',
|
planRuntimeTime: '',
|
isDepr: 2,
|
annualDepreciationAmount: null,
|
})
|
|
const changeRecords = ref([])
|
const recordsLoading = ref(false)
|
const repairRecords = ref([])
|
const upkeepRecords = ref([])
|
|
// 后端日期多带时分秒,这里统一只显示到日
|
const formatDate = (d) => (d ? dayjs(d).format('YYYY-MM-DD') : '--')
|
|
const statusText = (s) => (s == 1 ? '启用' : '停用')
|
|
const approvalText = (s) => {
|
const map = { PENDING: '审批中', APPROVED: '已通过', REJECTED: '已驳回' }
|
return map[s] || s || '--'
|
}
|
|
const approvalClass = (s) => {
|
const map = { PENDING: 'status-pending', APPROVED: 'status-approved', REJECTED: 'status-rejected' }
|
return map[s] || ''
|
}
|
|
const fetchDeviceInfo = async (deviceId) => {
|
try {
|
const res = await getDeviceInfo(deviceId)
|
console.log('设备信息响应:', res)
|
if (res.code === 200 && res.data) {
|
Object.assign(deviceInfo, res.data)
|
}
|
} catch (error) {
|
console.error('获取设备信息失败:', error)
|
}
|
}
|
|
const fetchChangeRecords = async (deviceId) => {
|
recordsLoading.value = true
|
try {
|
const res = await listStatusChangeRecord({ deviceId, pageNum: 1, pageSize: 20 })
|
console.log('变更记录响应:', res)
|
if (res.code === 200) {
|
changeRecords.value = res.data?.records || res.data || []
|
}
|
} catch (error) {
|
console.error('获取变更记录失败:', error)
|
} finally {
|
recordsLoading.value = false
|
}
|
}
|
|
const goBack = () => {
|
uni.navigateBack()
|
}
|
|
// 报修/保养列表接口只提供 deviceName 过滤(与管理端一致,无 deviceId 维度)
|
const fetchDeviceHistory = async (deviceName) => {
|
if (!deviceName) return
|
const params = { current: -1, size: -1, deviceName }
|
const [repair, upkeep] = await Promise.all([
|
getRepairPage(params).catch(() => null),
|
getUpkeepPage(params).catch(() => null),
|
])
|
repairRecords.value = unwrapList(repair)
|
upkeepRecords.value = unwrapList(upkeep)
|
}
|
|
onLoad((options) => {
|
const deviceId = options?.deviceId || ''
|
if (!deviceId) {
|
uni.showToast({ title: '缺少设备ID', icon: 'none' })
|
return
|
}
|
fetchDeviceInfo(deviceId)
|
// 履历里的报修/保养记录要等基本信息拿到设备名称后才能查
|
.then(() => fetchDeviceHistory(deviceInfo.deviceName))
|
.catch(() => {})
|
fetchChangeRecords(deviceId)
|
})
|
</script>
|
|
<style scoped lang="scss">
|
.device-info-container {
|
min-height: 100vh;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
padding: 16px 20px 20px;
|
box-sizing: border-box;
|
}
|
|
.info-card {
|
background: rgba(255, 255, 255, 0.95);
|
border-radius: 16px;
|
margin-bottom: 16px;
|
overflow: hidden;
|
}
|
|
.card-header {
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
color: #ffffff;
|
padding: 14px 20px;
|
font-weight: 500;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.card-title {
|
font-size: 15px;
|
color: #ffffff;
|
}
|
|
.device-status {
|
padding: 4px 14px;
|
border-radius: 20px;
|
font-size: 12px;
|
color: #ffffff;
|
background: #52c41a;
|
}
|
|
.status-enabled {
|
background: #52c41a;
|
}
|
|
.status-disabled {
|
background: #bfbfbf;
|
}
|
|
.card-content {
|
padding: 16px 20px;
|
}
|
|
.info-row {
|
display: flex;
|
align-items: flex-start;
|
margin-bottom: 12px;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
}
|
|
.label {
|
/* 「主要技术参数:」比原来最长的标签更宽,改成按内容撑开,避免换行或截断 */
|
min-width: 88px;
|
flex-shrink: 0;
|
white-space: nowrap;
|
color: #666666;
|
font-size: 14px;
|
}
|
|
.value {
|
flex: 1;
|
color: #2c3e50;
|
font-weight: 500;
|
font-size: 14px;
|
word-break: break-all;
|
}
|
|
.status-normal {
|
color: #52c41a;
|
}
|
|
.empty-tip {
|
color: #999999;
|
text-align: center;
|
padding: 20px 0;
|
}
|
|
.change-record {
|
padding: 14px 0;
|
border-bottom: 1px solid #f0f0f0;
|
|
&:last-child {
|
border-bottom: none;
|
}
|
}
|
|
.record-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 8px;
|
}
|
|
.record-time {
|
color: #666666;
|
font-size: 13px;
|
}
|
|
.record-status {
|
font-size: 12px;
|
padding: 2px 10px;
|
border-radius: 12px;
|
background: #f5f5f5;
|
color: #666666;
|
}
|
|
.status-pending {
|
background: #fff7e6;
|
color: #fa8c16;
|
}
|
|
.status-approved {
|
background: #f6ffed;
|
color: #52c41a;
|
}
|
|
.status-rejected {
|
background: #fff1f0;
|
color: #f5222d;
|
}
|
|
.record-line {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 6px;
|
}
|
|
.record-status-change {
|
color: #2c3e50;
|
font-weight: 500;
|
font-size: 14px;
|
}
|
|
.record-user {
|
color: #999999;
|
font-size: 13px;
|
}
|
|
.record-reason {
|
color: #666666;
|
font-size: 13px;
|
}
|
|
.record-reject {
|
color: #f5222d;
|
font-size: 13px;
|
margin-top: 4px;
|
}
|
</style>
|