|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <view class="self-check-container">
|
|
|
3
|
+ <view class="self-check-header">
|
|
|
4
|
+ <text class="header-title">定/自检</text>
|
|
|
5
|
+ <text class="view-all" @click="goToSelfCheckPage('all')">查看全部</text>
|
|
|
6
|
+ </view>
|
|
|
7
|
+
|
|
|
8
|
+ <view class="self-check-content">
|
|
|
9
|
+ <!-- 已过期定检提醒 -->
|
|
|
10
|
+ <view class="check-section" v-if="expiredItems.length > 0">
|
|
|
11
|
+ <view class="section-header">
|
|
|
12
|
+ <text class="section-title">已过期定检提醒</text>
|
|
|
13
|
+ <text class="view-more" @click="goToSelfCheckPage('expired')">查看更多</text>
|
|
|
14
|
+ </view>
|
|
|
15
|
+ <view class="check-item" v-for="(item, index) in expiredItems" :key="index">
|
|
|
16
|
+ <view class="item-indicator expired"></view>
|
|
|
17
|
+ <view class="item-content">
|
|
|
18
|
+ <view class="item-row">
|
|
|
19
|
+ <text class="item-label">{{ item.name }}</text>
|
|
|
20
|
+ <text class="item-label">{{ item.serialNumber }}</text>
|
|
|
21
|
+ <text class="item-date">{{ item.date }}</text>
|
|
|
22
|
+ </view>
|
|
|
23
|
+ <view class="item-row">
|
|
|
24
|
+ <text class="item-label">{{ item.location }}</text>
|
|
|
25
|
+ <text class="item-role">{{ item.role }}</text>
|
|
|
26
|
+ </view>
|
|
|
27
|
+ </view>
|
|
|
28
|
+ </view>
|
|
|
29
|
+ </view>
|
|
|
30
|
+
|
|
|
31
|
+ <!-- 两周内到期提醒 -->
|
|
|
32
|
+ <view class="check-section" v-if="twoWeeksItems.length > 0">
|
|
|
33
|
+ <view class="section-header">
|
|
|
34
|
+ <text class="section-title">两周内到期提醒</text>
|
|
|
35
|
+ <text class="view-more" @click="goToSelfCheckPage('twoWeeks')">查看更多</text>
|
|
|
36
|
+ </view>
|
|
|
37
|
+ <view class="check-item" v-for="(item, index) in twoWeeksItems" :key="index">
|
|
|
38
|
+ <view class="item-indicator urgent"></view>
|
|
|
39
|
+ <view class="item-content">
|
|
|
40
|
+ <view class="item-row">
|
|
|
41
|
+ <text class="item-label">{{ item.name }}</text>
|
|
|
42
|
+ <text class="item-label">{{ item.serialNumber }}</text>
|
|
|
43
|
+ <text class="item-date">{{ item.date }}</text>
|
|
|
44
|
+ </view>
|
|
|
45
|
+ <view class="item-row">
|
|
|
46
|
+ <text class="item-label">{{ item.location }}</text>
|
|
|
47
|
+ <text class="item-role">{{ item.role }}</text>
|
|
|
48
|
+ </view>
|
|
|
49
|
+ </view>
|
|
|
50
|
+ </view>
|
|
|
51
|
+ </view>
|
|
|
52
|
+
|
|
|
53
|
+ <!-- 一月内检到期提醒 -->
|
|
|
54
|
+ <view class="check-section" v-if="oneMonthItems.length > 0">
|
|
|
55
|
+ <view class="section-header">
|
|
|
56
|
+ <text class="section-title">一月内检到期提醒</text>
|
|
|
57
|
+ <text class="view-more" @click="goToSelfCheckPage('oneMonth')">查看更多</text>
|
|
|
58
|
+ </view>
|
|
|
59
|
+ <view class="check-item" v-for="(item, index) in oneMonthItems" :key="index">
|
|
|
60
|
+ <view class="item-indicator normal"></view>
|
|
|
61
|
+ <view class="item-content">
|
|
|
62
|
+ <view class="item-row">
|
|
|
63
|
+ <text class="item-label">{{ item.name }}</text>
|
|
|
64
|
+ <text class="item-label">{{ item.serialNumber }}</text>
|
|
|
65
|
+ <text class="item-date">{{ item.date }}</text>
|
|
|
66
|
+ </view>
|
|
|
67
|
+ <view class="item-row">
|
|
|
68
|
+ <text class="item-label">{{ item.location }}</text>
|
|
|
69
|
+ <text class="item-role">{{ item.role }}</text>
|
|
|
70
|
+ </view>
|
|
|
71
|
+ </view>
|
|
|
72
|
+ </view>
|
|
|
73
|
+ </view>
|
|
|
74
|
+ </view>
|
|
|
75
|
+ </view>
|
|
|
76
|
+</template>
|
|
|
77
|
+
|
|
|
78
|
+<script>
|
|
|
79
|
+import { getDeviceList } from "@/api/home-new/home-new";
|
|
|
80
|
+
|
|
|
81
|
+export default {
|
|
|
82
|
+ name: 'SelfCheck',
|
|
|
83
|
+ data() {
|
|
|
84
|
+ return {
|
|
|
85
|
+ // 已过期定检数据
|
|
|
86
|
+ expiredItems: [],
|
|
|
87
|
+ // 两周内到期数据
|
|
|
88
|
+ twoWeeksItems: [],
|
|
|
89
|
+ // 一月内到期数据
|
|
|
90
|
+ oneMonthItems: []
|
|
|
91
|
+ }
|
|
|
92
|
+ },
|
|
|
93
|
+ mounted() {
|
|
|
94
|
+ this.fetchDeviceList();
|
|
|
95
|
+ },
|
|
|
96
|
+ methods: {
|
|
|
97
|
+ goToSelfCheckPage(tab) {
|
|
|
98
|
+ uni.navigateTo({
|
|
|
99
|
+ url: `/pages/selfCheck/index?tab=${tab}`
|
|
|
100
|
+ });
|
|
|
101
|
+ },
|
|
|
102
|
+ fetchDeviceList() {
|
|
|
103
|
+ // 分别请求三种颜色的数据
|
|
|
104
|
+ Promise.all([
|
|
|
105
|
+ getDeviceList({ colorType: 'RED' }), // 已过期 - 红色
|
|
|
106
|
+ getDeviceList({ colorType: 'ORANGE' }), // 两周内到期 - 橙色
|
|
|
107
|
+ getDeviceList({ colorType: 'YELLOW' }) // 一月内到期 - 黄色
|
|
|
108
|
+ ]).then(results => {
|
|
|
109
|
+ // 处理红色数据(已过期)
|
|
|
110
|
+ if (results[0].code === 200) {
|
|
|
111
|
+ this.expiredItems = (results[0].data || []).slice(0, 2).map(item => this.formatDeviceItem(item));
|
|
|
112
|
+ }
|
|
|
113
|
+ // 处理橙色数据(两周内到期)
|
|
|
114
|
+ if (results[1].code === 200) {
|
|
|
115
|
+ this.twoWeeksItems = (results[1].data || []).slice(0, 2).map(item => this.formatDeviceItem(item));
|
|
|
116
|
+ }
|
|
|
117
|
+ // 处理黄色数据(一月内到期)
|
|
|
118
|
+ if (results[2].code === 200) {
|
|
|
119
|
+ this.oneMonthItems = (results[2].data || []).slice(0, 2).map(item => this.formatDeviceItem(item));
|
|
|
120
|
+ }
|
|
|
121
|
+ }).catch(err => {
|
|
|
122
|
+ console.error('获取设备列表失败', err);
|
|
|
123
|
+ });
|
|
|
124
|
+ },
|
|
|
125
|
+ formatDeviceItem(item) {
|
|
|
126
|
+ return {
|
|
|
127
|
+ name: item.equipmentName || '空',
|
|
|
128
|
+ serialNumber: item.equipmentCode || '空',
|
|
|
129
|
+ location: item.installationLocation || '空',
|
|
|
130
|
+ role:`${item.inspectionTeamLeaderName || ''}、${item.inspectionTeamMember1Name || ''}、${item.inspectionTeamMember2Name || ''}`|| '空',
|
|
|
131
|
+ date: this.formatDate(item.nextInspectionDueDate)|| '空'
|
|
|
132
|
+ };
|
|
|
133
|
+ },
|
|
|
134
|
+ formatDate(dateStr) {
|
|
|
135
|
+ if (!dateStr) return '';
|
|
|
136
|
+ const date = new Date(dateStr);
|
|
|
137
|
+ const year = date.getFullYear();
|
|
|
138
|
+ const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
139
|
+ const day = String(date.getDate()).padStart(2, '0');
|
|
|
140
|
+ return `${year}-${month}-${day}`;
|
|
|
141
|
+ }
|
|
|
142
|
+ }
|
|
|
143
|
+}
|
|
|
144
|
+</script>
|
|
|
145
|
+
|
|
|
146
|
+<style scoped>
|
|
|
147
|
+.self-check-container {
|
|
|
148
|
+ width: 100%;
|
|
|
149
|
+ padding: 12px;
|
|
|
150
|
+ background-color: #f5f7fa;
|
|
|
151
|
+}
|
|
|
152
|
+
|
|
|
153
|
+.self-check-header {
|
|
|
154
|
+ display: flex;
|
|
|
155
|
+ justify-content: space-between;
|
|
|
156
|
+ align-items: center;
|
|
|
157
|
+ margin-bottom: 12px;
|
|
|
158
|
+}
|
|
|
159
|
+
|
|
|
160
|
+.header-title {
|
|
|
161
|
+ font-size: 20px;
|
|
|
162
|
+ font-weight: bold;
|
|
|
163
|
+ color: #333;
|
|
|
164
|
+}
|
|
|
165
|
+
|
|
|
166
|
+.view-all {
|
|
|
167
|
+ font-size: 14px;
|
|
|
168
|
+ color: #409eff;
|
|
|
169
|
+}
|
|
|
170
|
+
|
|
|
171
|
+.self-check-content {
|
|
|
172
|
+ background-color: #fff;
|
|
|
173
|
+ border-radius: 12px;
|
|
|
174
|
+ padding: 12px;
|
|
|
175
|
+}
|
|
|
176
|
+
|
|
|
177
|
+.check-section {
|
|
|
178
|
+ margin-bottom: 16px;
|
|
|
179
|
+}
|
|
|
180
|
+
|
|
|
181
|
+.check-section:last-child {
|
|
|
182
|
+ margin-bottom: 0;
|
|
|
183
|
+}
|
|
|
184
|
+
|
|
|
185
|
+.section-header {
|
|
|
186
|
+ display: flex;
|
|
|
187
|
+ justify-content: space-between;
|
|
|
188
|
+ align-items: center;
|
|
|
189
|
+ margin-bottom: 10px;
|
|
|
190
|
+}
|
|
|
191
|
+
|
|
|
192
|
+.section-title {
|
|
|
193
|
+ font-size: 16px;
|
|
|
194
|
+ font-weight: bold;
|
|
|
195
|
+ color: #333;
|
|
|
196
|
+}
|
|
|
197
|
+
|
|
|
198
|
+.view-more {
|
|
|
199
|
+ font-size: 14px;
|
|
|
200
|
+ color: #409eff;
|
|
|
201
|
+}
|
|
|
202
|
+
|
|
|
203
|
+.check-item {
|
|
|
204
|
+ display: flex;
|
|
|
205
|
+ align-items: flex-start;
|
|
|
206
|
+ padding: 10px 0;
|
|
|
207
|
+ border-bottom: 1px solid #f0f0f0;
|
|
|
208
|
+}
|
|
|
209
|
+
|
|
|
210
|
+.check-item:last-child {
|
|
|
211
|
+ border-bottom: none;
|
|
|
212
|
+}
|
|
|
213
|
+
|
|
|
214
|
+.item-indicator {
|
|
|
215
|
+ width: 6px;
|
|
|
216
|
+ border-radius: 3px;
|
|
|
217
|
+ margin-right: 10px;
|
|
|
218
|
+ flex-shrink: 0;
|
|
|
219
|
+}
|
|
|
220
|
+
|
|
|
221
|
+.item-indicator.expired {
|
|
|
222
|
+ background-color: #FF0000;
|
|
|
223
|
+ height: 48px;
|
|
|
224
|
+}
|
|
|
225
|
+
|
|
|
226
|
+.item-indicator.urgent {
|
|
|
227
|
+ background-color: #FFA500;
|
|
|
228
|
+ height: 48px;
|
|
|
229
|
+}
|
|
|
230
|
+
|
|
|
231
|
+.item-indicator.normal {
|
|
|
232
|
+ background-color: #FFD700;
|
|
|
233
|
+ height: 48px;
|
|
|
234
|
+}
|
|
|
235
|
+
|
|
|
236
|
+.item-content {
|
|
|
237
|
+ flex: 1;
|
|
|
238
|
+ display: flex;
|
|
|
239
|
+ flex-direction: column;
|
|
|
240
|
+ gap: 6px;
|
|
|
241
|
+}
|
|
|
242
|
+
|
|
|
243
|
+.item-row {
|
|
|
244
|
+ display: flex;
|
|
|
245
|
+ justify-content: space-between;
|
|
|
246
|
+ align-items: center;
|
|
|
247
|
+}
|
|
|
248
|
+
|
|
|
249
|
+.item-label {
|
|
|
250
|
+ font-size: 14px;
|
|
|
251
|
+ color: #333;
|
|
|
252
|
+}
|
|
|
253
|
+
|
|
|
254
|
+.item-date {
|
|
|
255
|
+ font-size: 14px;
|
|
|
256
|
+ color: #333;
|
|
|
257
|
+}
|
|
|
258
|
+
|
|
|
259
|
+.item-role {
|
|
|
260
|
+ font-size: 14px;
|
|
|
261
|
+ color: #333;
|
|
|
262
|
+}
|
|
|
263
|
+</style>
|