zhangwencui
2026-06-29 4c8d18cc5ed8a7b0e220c91a858d16d0310896df
src/pages/qualityManagement/materialInspection/detail.vue
@@ -15,10 +15,11 @@
          </view>
          <text class="header-title">{{ detailData.productName || '-' }}</text>
          <view class="status-tags">
            <u-tag :type="getTagType(detailData.checkResult)"
            <u-tag v-if="detailData.passRate != null && detailData.passRate !== ''"
                   type="primary"
                   size="small"
                   class="status-tag">
              {{ detailData.checkResult || '-' }}
              合格率 {{ formatPassRate(detailData.passRate) }}
            </u-tag>
            <u-tag :type="getStateTagType(detailData.inspectState)"
                   size="small"
@@ -58,8 +59,20 @@
            <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 ?? 0 }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">合格数量</text>
            <text class="detail-value">{{ detailData.qualifiedQuantity ?? 0 }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">不合格数量</text>
            <text class="detail-value">{{ detailData.unqualifiedQuantity ?? 0 }}</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>
@@ -131,7 +144,7 @@
<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";
@@ -160,16 +173,13 @@
    return dayjs(date).format("YYYY-MM-DD");
  };
  // 获取标签类型
  const getTagType = result => {
    switch (result) {
      case "合格":
        return "success";
      case "不合格":
        return "error";
      default:
        return "info";
    }
  // 格式化合格率
  const formatPassRate = rate => {
    if (rate === null || rate === undefined || rate === "") return "-";
    const num = Number(rate);
    if (isNaN(num)) return rate;
    if (num <= 1) return `${(num * 100).toFixed(2)}%`;
    return `${num}%`;
  };
  // 获取状态标签类型
@@ -204,16 +214,9 @@
    }, 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;
@@ -261,6 +264,11 @@
  onMounted(() => {
    getDetail();
  });
  const optionsId = ref("");
  onLoad(options => {
    optionsId.value = options.id || "";
    getDetail();
  });
</script>
<style scoped lang="scss">