| | |
| | | </view> |
| | | <text class="header-title">{{ detailData.productName || '-' }}</text> |
| | | <view class="status-tags"> |
| | | <u-tag :type="getTagType(detailData.checkResult)" |
| | | <u-tag :type="getPassRateTagType(detailData.passRate)" |
| | | size="small" |
| | | class="status-tag"> |
| | | {{ detailData.checkResult || '-' }} |
| | | 合格率 {{ formatPassRate(detailData.passRate) }} |
| | | </u-tag> |
| | | <u-tag :type="getStateTagType(detailData.inspectState)" |
| | | size="small" |
| | |
| | | <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> |
| | | <text class="detail-label">总数量</text> |
| | | <text class="detail-value">{{ detailData.quantity ?? '-' }}</text> |
| | | </view> |
| | | <view class="detail-row"> |
| | | <text class="detail-label">合格数量</text> |
| | | <text class="detail-value">{{ detailData.qualifiedQuantity ?? '-' }}</text> |
| | | </view> |
| | | <view class="detail-row"> |
| | | <text class="detail-label">不合格数量</text> |
| | | <text class="detail-value">{{ detailData.unqualifiedQuantity ?? '-' }}</text> |
| | | </view> |
| | | <view class="detail-row"> |
| | | <text class="detail-label">合格率</text> |
| | | <text class="detail-value">{{ formatPassRate(detailData.passRate) }}</text> |
| | | </view> |
| | | <view class="detail-row"> |
| | | <text class="detail-label">检测单位</text> |
| | |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from "vue"; |
| | | import { onShow } from "@dcloudio/uni-app"; |
| | | import { onShow, onLoad } from "@dcloudio/uni-app"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import dayjs from "dayjs"; |
| | | import { qualityInspectParamInfo } from "@/api/qualityManagement/materialInspection.js"; |
| | |
| | | return dayjs(date).format("YYYY-MM-DD"); |
| | | }; |
| | | |
| | | // 获取标签类型 |
| | | const getTagType = result => { |
| | | switch (result) { |
| | | case "合格": |
| | | return "success"; |
| | | case "不合格": |
| | | return "error"; |
| | | default: |
| | | return "info"; |
| | | } |
| | | // 格式化合格率(支持 0–1 小数或百分数) |
| | | const formatPassRate = val => { |
| | | if (val === null || val === undefined || val === "") return "-"; |
| | | const n = Number(val); |
| | | if (Number.isNaN(n)) return String(val); |
| | | if (n > 0 && n <= 1) return `${(n * 100).toFixed(1)}%`; |
| | | return `${Number.isInteger(n) ? n : Number(n.toFixed(1))}%`; |
| | | }; |
| | | |
| | | const getPassRateTagType = val => { |
| | | if (val === null || val === undefined || val === "") return "info"; |
| | | let n = Number(val); |
| | | if (Number.isNaN(n)) return "info"; |
| | | if (n > 0 && n <= 1) n *= 100; |
| | | if (n >= 100) return "success"; |
| | | if (n >= 60) return "warning"; |
| | | return "error"; |
| | | }; |
| | | |
| | | // 获取状态标签类型 |
| | |
| | | }, 1500); |
| | | }; |
| | | |
| | | // 获取页面ID |
| | | const getPageId = () => { |
| | | const pages = getCurrentPages(); |
| | | const currentPage = pages[pages.length - 1]; |
| | | return currentPage.options.id; |
| | | }; |
| | | |
| | | // 获取详情数据 |
| | | const getDetail = () => { |
| | | const id = getPageId(); |
| | | const id = optionsId.value; |
| | | if (!id) { |
| | | showToast("参数错误"); |
| | | return; |
| | |
| | | ) { |
| | | // 如果接口没有返回数据,使用本地存储中的数据 |
| | | inspectionItems.value = detailDataFromStorage.qualityInspectParams; |
| | | } else { |
| | | // 模拟检验项目 |
| | | inspectionItems.value = [ |
| | | { |
| | | parameterItem: "厚度", |
| | | unit: "mm", |
| | | standardValue: "2.0 ± 0.1", |
| | | controlValue: "2.0 ± 0.05", |
| | | testValue: "2.05", |
| | | }, |
| | | { |
| | | parameterItem: "硬度", |
| | | unit: "HB", |
| | | standardValue: "≥ 200", |
| | | controlValue: "≥ 210", |
| | | testValue: "220", |
| | | }, |
| | | { |
| | | parameterItem: "表面质量", |
| | | unit: "", |
| | | standardValue: "无划痕、无锈蚀", |
| | | controlValue: "无划痕、无锈蚀", |
| | | testValue: "合格", |
| | | }, |
| | | ]; |
| | | } |
| | | }) |
| | | .catch(error => { |
| | |
| | | inspectionItems.value = detailDataFromStorage.qualityInspectParams; |
| | | } |
| | | }); |
| | | } else { |
| | | // 模拟数据 |
| | | detailData.value = { |
| | | id: id, |
| | | checkTime: "2026-03-03", |
| | | purchaseContractNo: "PO20260303001", |
| | | supplier: "上海金属材料有限公司", |
| | | checkName: "张三", |
| | | productName: "不锈钢板材", |
| | | model: "304", |
| | | unit: "kg", |
| | | quantity: 1000, |
| | | checkCompany: "第三方检测机构", |
| | | checkResult: "合格", |
| | | inspectState: true, |
| | | }; |
| | | |
| | | // 模拟检验项目 |
| | | inspectionItems.value = [ |
| | | { |
| | | parameterItem: "厚度", |
| | | unit: "mm", |
| | | standardValue: "2.0 ± 0.1", |
| | | controlValue: "2.0 ± 0.05", |
| | | testValue: "2.05", |
| | | }, |
| | | { |
| | | parameterItem: "硬度", |
| | | unit: "HB", |
| | | standardValue: "≥ 200", |
| | | controlValue: "≥ 210", |
| | | testValue: "220", |
| | | }, |
| | | { |
| | | parameterItem: "表面质量", |
| | | unit: "", |
| | | standardValue: "无划痕、无锈蚀", |
| | | controlValue: "无划痕、无锈蚀", |
| | | testValue: "合格", |
| | | }, |
| | | ]; |
| | | } |
| | | } catch (error) { |
| | | console.error("加载详情数据失败:", error); |
| | | showToast("加载详情数据失败,请重试"); |
| | | // 加载失败时使用模拟数据 |
| | | detailData.value = { |
| | | id: id, |
| | | checkTime: "2026-03-03", |
| | | purchaseContractNo: "PO20260303001", |
| | | supplier: "上海金属材料有限公司", |
| | | checkName: "张三", |
| | | productName: "不锈钢板材", |
| | | model: "304", |
| | | unit: "kg", |
| | | quantity: 1000, |
| | | checkCompany: "第三方检测机构", |
| | | checkResult: "合格", |
| | | inspectState: true, |
| | | }; |
| | | |
| | | inspectionItems.value = [ |
| | | { |
| | | parameterItem: "厚度", |
| | | unit: "mm", |
| | | standardValue: "2.0 ± 0.1", |
| | | controlValue: "2.0 ± 0.05", |
| | | testValue: "2.05", |
| | | }, |
| | | { |
| | | parameterItem: "硬度", |
| | | unit: "HB", |
| | | standardValue: "≥ 200", |
| | | controlValue: "≥ 210", |
| | | testValue: "220", |
| | | }, |
| | | { |
| | | parameterItem: "表面质量", |
| | | unit: "", |
| | | standardValue: "无划痕、无锈蚀", |
| | | controlValue: "无划痕、无锈蚀", |
| | | testValue: "合格", |
| | | }, |
| | | ]; |
| | | } |
| | | }; |
| | | |
| | |
| | | onMounted(() => { |
| | | getDetail(); |
| | | }); |
| | | const optionsId = ref(""); |
| | | onLoad(options => { |
| | | optionsId.value = options.id || ""; |
| | | getDetail(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |