spring
6 天以前 ba01c8bd58bea9acbb98c2097765b939a81b21cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
  <div class="device-info-container">
    <div class="page-header">
      <h1>设备信息</h1>
      <div class="device-status" :class="deviceStatusClass">
        {{ deviceStatusText }}
      </div>
    </div>
 
    <div class="info-card">
      <div class="card-header">基本信息</div>
      <div class="card-content">
        <div class="info-row">
          <span class="label">设备名称:</span>
          <span class="value">{{ deviceInfo.deviceName }}</span>
        </div>
        <div class="info-row">
          <span class="label">规格型号:</span>
          <span class="value">{{ deviceInfo.deviceModel }}</span>
        </div>
        <div class="info-row">
          <span class="label">生产厂家:</span>
          <span class="value">{{ deviceInfo.supplierName }}</span>
        </div>
        <div class="info-row">
          <span class="label">单位:</span>
          <span class="value">{{ deviceInfo.unit }}</span>
        </div>
      </div>
    </div>
 
         <div class="info-card">
       <div class="card-header">维护信息</div>
       <div class="card-content">
         <div class="maintenance-info">
           <div class="maintenance-item">
             <span class="label">最后维护:</span>
             <span class="value">{{ deviceInfo.updateTime }}</span>
           </div>
           <div class="maintenance-item">
             <span class="label">下次维护:</span>
             <span class="value">{{ deviceInfo.createTime }}</span>
           </div>
           <div class="maintenance-item">
             <span class="label">维护状态:</span>
             <span class="value status-normal">{{ deviceInfo.statusText }}</span>
           </div>
         </div>
       </div>
     </div>
  </div>
</template>
 
<script setup>
import { ref, reactive, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { 
  getDeviceInfo, 
} from '@/api/equipmentManagement/deviceInfo'
 
const route = useRoute()
 
const deviceInfo = reactive({
  deviceName: '',
  deviceModel: '',
  supplierName: '',
  unit: '',
  statusText:'正常',
  updateTime:'',
  createTime:''
})
 
const deviceStatusClass = computed(() => {
  return 'status-normal'
})
 
const deviceStatusText = computed(() => {
  return '正常'
})
 
const fetchDeviceInfo = async (deviceId) => {
  try {
    // 获取设备信息
    const deviceResponse = await getDeviceInfo({id:deviceId})
    if (deviceResponse.code === 200) {
      Object.assign(deviceInfo, deviceResponse.data)
    }
    
    
  } catch (error) {
    
    ElMessage.warning('使用模拟数据,实际API调用失败')
  }
}
 
onMounted(() => {
  const deviceId = route.query.deviceId || route.params.deviceId || ''
  fetchDeviceInfo(deviceId)
})
</script>
 
<style scoped>
.device-info-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
 
.page-header {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.page-header h1 {
  margin: 0;
  color: #2c3e50;
  font-size: 24px;
}
 
.device-status {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: white;
  background: #52c41a;
}
 
.info-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  margin-bottom: 20px;
  overflow: hidden;
}
 
.card-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  font-weight: 500;
}
 
.card-content {
  padding: 20px;
}
 
.info-row, .maintenance-item {
  display: flex;
  margin-bottom: 12px;
  align-items: center;
}
 
.label {
  width: 100px;
  color: #666;
  font-size: 14px;
}
 
.value {
  flex: 1;
  color: #2c3e50;
  font-weight: 500;
}
 
.status-normal {
  color: #52c41a;
}
 
 
 
@media (max-width: 768px) {
  .device-info-container {
    padding: 16px;
  }
  
  .page-header h1 {
    font-size: 20px;
  }
  
  .label {
    width: 80px;
  }
}
</style>