gaoluyang
昨天 c79771f7290d595d7b8e21cac1d1e1929b09f357
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<template>
  <view class="material-inspection-detail">
    <!-- 使用通用页面头部组件 -->
    <PageHeader title="出厂检验详情"
                @back="goBack" />
    <!-- 详情内容 -->
    <view class="detail-section"
          v-if="detailData">
      <view class="detail-card">
        <view class="card-header">
          <view class="header-icon">
            <up-icon name="file-text"
                     size="20"
                     color="#ffffff"></up-icon>
          </view>
          <text class="header-title">{{ detailData.productName || '-' }}</text>
          <view class="status-tags">
            <u-tag :type="getTagType(detailData.checkResult)"
                   size="small"
                   class="status-tag">
              {{ detailData.checkResult || '-' }}
            </u-tag>
            <u-tag :type="getStateTagType(detailData.inspectState)"
                   size="small"
                   class="status-tag">
              {{ detailData.inspectState ? '已提交' : '未提交' }}
            </u-tag>
          </view>
        </view>
        <up-divider></up-divider>
        <view class="detail-content">
          <view class="detail-row">
            <text class="detail-label">检测日期</text>
            <text class="detail-value">{{ formatDateTime(detailData.checkTime) || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">生产工单号</text>
            <text class="detail-value">{{ detailData.workOrderNo || '-' }}</text>
          </view>
          <!-- <view class="detail-row">
            <text class="detail-label">工序</text>
            <text class="detail-value">{{ detailData.process || '-' }}</text>
          </view> -->
          <view class="detail-row">
            <text class="detail-label">检验员</text>
            <text class="detail-value">{{ detailData.checkName || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">产品名称</text>
            <text class="detail-value">{{ detailData.productName || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">规格型号</text>
            <text class="detail-value">{{ detailData.model || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">单位</text>
            <text class="detail-value">{{ detailData.unit || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">数量</text>
            <text class="detail-value">{{ detailData.quantity || 0 }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">检测单位</text>
            <text class="detail-value">{{ detailData.checkCompany || '-' }}</text>
          </view>
          <!-- <view class="detail-row">
            <text class="detail-label">检验标准</text>
            <text class="detail-value">{{ detailData.testStandardName || '-' }}</text>
          </view> -->
        </view>
      </view>
      <!-- 检验项目 -->
      <view class="detail-card"
            v-if="inspectionItems.length > 0">
        <view class="card-header">
          <view class="header-icon secondary">
            <up-icon name="list"
                     size="20"
                     color="#ffffff"></up-icon>
          </view>
          <text class="header-title">检验项目</text>
        </view>
        <up-divider></up-divider>
        <view class="inspection-items">
          <view v-for="(item, index) in inspectionItems"
                :key="index"
                class="inspection-item">
            <text class="item-name">{{ item.parameterItem || '检验项目' }}</text>
            <view class="item-details">
              <view class="item-detail-row">
                <text class="item-detail-label">单位:</text>
                <text class="item-detail-value">{{ item.unit || '-' }}</text>
              </view>
              <view class="item-detail-row">
                <text class="item-detail-label">标准值:</text>
                <text class="item-detail-value">{{ item.standardValue || '-' }}</text>
              </view>
              <view class="item-detail-row">
                <text class="item-detail-label">内控值:</text>
                <text class="item-detail-value">{{ item.controlValue || '-' }}</text>
              </view>
              <view class="item-detail-row">
                <text class="item-detail-label">检验值:</text>
                <text class="item-detail-value result"
                      :class="getResultClass(item.testValue, item.standardValue)">
                  {{ item.testValue || '-' }}
                </text>
              </view>
            </view>
          </view>
        </view>
      </view>
      <!-- 操作按钮 -->
      <!-- <view class="action-buttons">
        <u-button type="primary"
                  class="action-btn"
                  @click="downloadReport">
          下载报告
        </u-button>
      </view> -->
    </view>
    <view v-else
          class="no-data">
      <up-empty mode="data"
                text="暂无检验详情"></up-empty>
    </view>
  </view>
</template>
 
<script setup>
  import { ref, onMounted } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import dayjs from "dayjs";
  import { qualityInspectParamInfo } from "@/api/qualityManagement/materialInspection.js";
 
  // 显示提示信息
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
 
  // 详情数据
  const detailData = ref(null);
  // 检验项目
  const inspectionItems = ref([]);
 
  // 返回上一页
  const goBack = () => {
    uni.navigateBack();
  };
 
  // 格式化日期时间
  const formatDateTime = date => {
    if (!date) return "";
    return dayjs(date).format("YYYY-MM-DD");
  };
 
  // 获取标签类型
  const getTagType = result => {
    switch (result) {
      case "合格":
        return "success";
      case "不合格":
        return "error";
      default:
        return "info";
    }
  };
 
  // 获取状态标签类型
  const getStateTagType = state => {
    return state ? "success" : "warning";
  };
 
  // 获取结果样式
  const getResultClass = (testValue, standardValue) => {
    // 简单的结果判断逻辑,实际项目中可能需要更复杂的判断
    if (testValue === "合格") {
      return "result-passed";
    } else if (testValue === "不合格") {
      return "result-rejected";
    }
    return "";
  };
 
  // 下载报告
  const downloadReport = () => {
    uni.showToast({
      title: "报告下载中...",
      icon: "loading",
    });
 
    // 模拟下载
    setTimeout(() => {
      uni.showToast({
        title: "报告下载成功",
        icon: "success",
      });
    }, 1500);
  };
 
  // 获取页面ID
  const getPageId = () => {
    const pages = getCurrentPages();
    const currentPage = pages[pages.length - 1];
    return currentPage.options.id;
  };
 
  // 获取详情数据
  const getDetail = () => {
    const id = getPageId();
    if (!id) {
      showToast("参数错误");
      return;
    }
 
    // 从本地存储获取详情数据
    try {
      const detailDataFromStorage = uni.getStorageSync("finalInspectionEditData");
      if (detailDataFromStorage) {
        detailData.value = detailDataFromStorage;
        console.log(detailData.value, "detailData.value");
        // 使用qualityInspectParamInfo获取检验项目
        qualityInspectParamInfo(id)
          .then(res => {
            if (res.data && res.data.length > 0) {
              inspectionItems.value = res.data;
            } else if (
              detailDataFromStorage.qualityInspectParams &&
              detailDataFromStorage.qualityInspectParams.length > 0
            ) {
              // 如果接口没有返回数据,使用本地存储中的数据
              inspectionItems.value = detailDataFromStorage.qualityInspectParams;
            }
          })
          .catch(error => {
            console.error("获取检验项目失败:", error);
            // 接口调用失败时,使用本地存储中的数据或模拟数据
            if (
              detailDataFromStorage.qualityInspectParams &&
              detailDataFromStorage.qualityInspectParams.length > 0
            ) {
              inspectionItems.value = detailDataFromStorage.qualityInspectParams;
            }
          });
      }
    } catch (error) {
      console.error("加载详情数据失败:", error);
      showToast("加载详情数据失败,请重试");
    }
  };
 
  onShow(() => {
    getDetail();
  });
 
  onMounted(() => {
    getDetail();
  });
</script>
 
<style scoped lang="scss">
  .material-inspection-detail {
    min-height: 100vh;
    background: #f5f5f5;
    padding-bottom: 20px;
  }
 
  .detail-section {
    padding: 15px;
  }
 
  .detail-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }
 
  .card-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
  }
 
  .header-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
  }
 
  .header-icon.secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  }
 
  .header-icon.tertiary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  }
 
  .header-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #333;
  }
 
  .status-tag {
    margin-left: 20rpx;
  }
 
  .detail-content {
    padding-top: 8px;
  }
 
  .detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
  }
 
  .detail-row:last-child {
    border-bottom: none;
  }
 
  .detail-label {
    font-size: 14px;
    color: #666;
    min-width: 100px;
  }
 
  .detail-value {
    font-size: 14px;
    color: #333;
    text-align: right;
    flex: 1;
  }
 
  // 检验项目
  .inspection-items {
    padding-top: 8px;
  }
 
  .inspection-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
  }
 
  .inspection-item:last-child {
    margin-bottom: 0;
  }
 
  .item-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
  }
 
  .item-details {
    padding-top: 8px;
  }
 
  .item-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
  }
 
  .item-detail-row:last-child {
    margin-bottom: 0;
  }
 
  .item-detail-label {
    font-size: 12px;
    color: #666;
    min-width: 60px;
  }
 
  .item-detail-value {
    font-size: 12px;
    color: #333;
    text-align: right;
    flex: 1;
  }
 
  .item-detail-value.result {
    font-weight: 500;
  }
 
  .result-passed {
    color: #67c23a;
  }
 
  .result-rejected {
    color: #f56c6c;
  }
 
  // 空状态
  .no-data {
    padding: 60px 20px;
    text-align: center;
  }
</style>