yyb
5 天以前 883ab99ab021be1adc6dc5689368f899ea436e54
src/pages/routingInspection/detail/indexLS.vue
@@ -40,287 +40,254 @@
    </view>
  </view>
  <view class="list">
    <div class="inspection-report">
      <!-- 基本信息模块 -->
      <wd-row>
        <view style="margin: 10rpx">
          <text class="title">{{ "基本信息" }}</text>
        </view>
        <wd-col :span="24">
          <wd-form-item label="日期" prop="recordDate">
            {{ formatDate(detailData.fixedInfo?.recordDate) }}
          </wd-form-item>
          <wd-form-item label="机台" prop="deviceModel">
            {{ formatValue(detailData.fixedInfo?.deviceModel) }}
          </wd-form-item>
          <wd-form-item label="班次" prop="workShift">
            {{ formatValue(detailData.fixedInfo?.workShift) }}
          </wd-form-item>
          <wd-form-item label="班组" prop="teamName">
            {{ formatValue(detailData.fixedInfo?.teamName) }}
          </wd-form-item>
          <wd-form-item label="单丝规格" prop="model">
            {{ formatValue(detailData.fixedInfo?.model) }}
          </wd-form-item>
          <wd-form-item label="生产轴数" prop="outputNumber">
            {{ formatValue(detailData.fixedInfo?.outputNumber, "轴") }}
          </wd-form-item>
          <wd-form-item label="型号" prop="poleModel">
            {{ formatValue(detailData.fixedInfo?.poleModel) }}
          </wd-form-item>
          <wd-form-item label="批次" prop="poleNumber">
            {{ formatValue(detailData.fixedInfo?.poleNumber) }}
          </wd-form-item>
          <wd-form-item label="记录人" prop="createUserName">
            {{ formatValue(detailData.fixedInfo?.createUserName) }}
          </wd-form-item>
          <wd-form-item label="首检盘号" prop="firstNo">
            {{ formatValue(detailData.fixedInfo?.firstNo) }}
          </wd-form-item>
        </wd-col>
      </wd-row>
    <!-- 基本信息模块 -->
    <wd-row>
      <view style="margin: 10rpx">
        <text class="title">{{ "基本信息" }}</text>
      </view>
      <wd-col :span="24">
        <wd-form-item label="日期" prop="recordDate">
          {{ formatDate(detailData.fixedInfo?.recordDate) }}
        </wd-form-item>
        <wd-form-item label="机台" prop="deviceModel">
          {{ formatValue(detailData.fixedInfo?.deviceModel) }}
        </wd-form-item>
        <wd-form-item label="班次" prop="workShift">
          {{ formatValue(detailData.fixedInfo?.workShift) }}
        </wd-form-item>
        <wd-form-item label="班组" prop="teamName">
          {{ formatValue(detailData.fixedInfo?.teamName) }}
        </wd-form-item>
        <wd-form-item label="单丝规格" prop="model">
          {{ formatValue(detailData.fixedInfo?.model) }}
        </wd-form-item>
        <wd-form-item label="生产轴数" prop="outputNumber">
          {{ formatValue(detailData.fixedInfo?.outputNumber, "轴") }}
        </wd-form-item>
        <wd-form-item label="型号" prop="poleModel">
          {{ formatValue(detailData.fixedInfo?.poleModel) }}
        </wd-form-item>
        <wd-form-item label="批次" prop="poleNumber">
          {{ formatValue(detailData.fixedInfo?.poleNumber) }}
        </wd-form-item>
        <wd-form-item label="记录人" prop="createUserName">
          {{ formatValue(detailData.fixedInfo?.createUserName) }}
        </wd-form-item>
        <wd-form-item label="首检盘号" prop="firstNo">
          {{ formatValue(detailData.fixedInfo?.firstNo) }}
        </wd-form-item>
      </wd-col>
    </wd-row>
      <!-- 自检记录详情模块 -->
      <wd-row>
        <view style="margin: 10rpx">
          <text class="title">{{ "自检记录详情" }}</text>
        </view>
        <wd-col :span="24">
          <wd-form-item label="巡检员" prop="processInspectionUserName">
            {{ detailData.processInspectionUserName || "-" }}
          </wd-form-item>
          <wd-form-item label="状态" prop="status">
            <wd-tag custom-class="space" :type="getStatusType(detailData.status)">
              {{ getStatusText(detailData.status) }}
            </wd-tag>
          </wd-form-item>
        </wd-col>
      </wd-row>
    <!-- 自检记录详情模块 -->
    <wd-row>
      <view style="margin: 10rpx">
        <text class="title">{{ "自检记录详情" }}</text>
      </view>
      <wd-col :span="24">
        <wd-form-item label="巡检员" prop="processInspectionUserName">
          {{ detailData.processInspectionUserName || "-" }}
        </wd-form-item>
        <wd-form-item label="状态" prop="status">
          <wd-tag custom-class="space" :type="getStatusType(detailData.status)">
            {{ getStatusText(detailData.status) }}
          </wd-tag>
        </wd-form-item>
      </wd-col>
    </wd-row>
      <!-- 检验结果 -->
      <wd-row>
        <view style="margin: 10rpx">
          <text class="title">{{ "检验结果" }}</text>
        </view>
        <wd-col :span="24">
          <wd-form-item label="单丝直径" prop="dia">
            {{ formatValue(detailData.inspectionResult?.dia, "mm") || "-" }}
          </wd-form-item>
    <!-- 检验结果 -->
    <wd-row>
      <view style="margin: 10rpx">
        <text class="title">{{ "检验结果" }}</text>
      </view>
      <wd-col :span="24">
        <wd-form-item label="单丝直径" prop="dia">
          {{ formatValue(detailData.inspectionResult?.dia, "mm") || "-" }}
        </wd-form-item>
          <wd-form-item label="最大直径" prop="maxDia" required>
            <template v-if="isEdit">
              <wd-input v-model="formData.maxDia" placeholder="请输入最大直径(mm)" type="number" />
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.maxDia, "mm") || "-" }}
            </template>
          </wd-form-item>
        <wd-form-item label="最大直径" prop="maxDia" required>
          <template v-if="isEdit">
            <wd-input v-model="formData.maxDia" placeholder="请输入最大直径(mm)" type="number" />
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.maxDia, "mm") || "-" }}
          </template>
        </wd-form-item>
          <wd-form-item label="最小直径" prop="minDia" required>
            <template v-if="isEdit">
              <wd-input v-model="formData.minDia" placeholder="请输入最小直径(mm)" type="number" />
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.minDia, "mm") || "-" }}
            </template>
          </wd-form-item>
        <wd-form-item label="最小直径" prop="minDia" required>
          <template v-if="isEdit">
            <wd-input v-model="formData.minDia" placeholder="请输入最小直径(mm)" type="number" />
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.minDia, "mm") || "-" }}
          </template>
        </wd-form-item>
          <wd-form-item label="外观" prop="appearance" required>
            <template v-if="isEdit">
              <wd-checkbox-group
                v-model="formData.appearance"
                inline
                v-for="(opt, idx) in appearanceOptions"
                :key="idx"
                style="text-align: justify"
              >
                <wd-checkbox :modelValue="opt.value" style="width: 100px">
                  {{ opt.label }}
                </wd-checkbox>
              </wd-checkbox-group>
            </template>
            <template v-else>
              {{
                formatProductAppearance(detailData.inspectionResult?.appearance).join("、") || "-"
              }}
            </template>
          </wd-form-item>
          <wd-form-item label="卷绕紧密" prop="windingTightness" required>
            <template v-if="isEdit">
              <wd-radio-group
                v-model="formData.windingTightness"
                inline
                class="conclusion-radio-group"
              >
                <wd-radio
                  v-for="(opt, idx) in sampleCompleteOptions"
                  :key="idx"
                  :value="opt.value"
                  shape="dot"
                >
                  {{ opt.label }}
                </wd-radio>
              </wd-radio-group>
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.windingTightness) }}
            </template>
          </wd-form-item>
          <wd-form-item label="排列整齐" prop="arrangementNeatness" required>
            <template v-if="isEdit">
              <wd-radio-group
                v-model="formData.arrangementNeatness"
                inline
                class="conclusion-radio-group"
              >
                <wd-radio
                  v-for="(opt, idx) in sampleCompleteOptions"
                  :key="idx"
                  :value="opt.value"
                  shape="dot"
                >
                  {{ opt.label }}
                </wd-radio>
              </wd-radio-group>
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.arrangementNeatness) }}
            </template>
          </wd-form-item>
          <wd-form-item
            label="外层铝线离侧板边缘距离"
            prop="aluminumWireDistance"
            label-width="360rpx"
            required
          >
            <template v-if="isEdit">
              <wd-input
                v-model="formData.aluminumWireDistance"
                placeholder="请输入距离(mm)"
                type="number"
              />
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.aluminumWireDistance, "mm") || "-" }}
            </template>
          </wd-form-item>
          <wd-form-item
            label="成品模后接头情况"
            prop="jointCondition"
            label-width="280rpx"
            required
          >
            <template v-if="isEdit">
              <wd-radio-group
                v-model="formData.jointCondition"
                inline
                class="conclusion-radio-group"
              >
                <wd-radio
                  v-for="(opt, idx) in jointConditionOptions"
                  :key="idx"
                  :value="opt.value"
                  shape="dot"
                >
                  {{ opt.label }}
                </wd-radio>
              </wd-radio-group>
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.jointCondition) || "-" }}
            </template>
          </wd-form-item>
          <wd-form-item label="结论" prop="conclusion" required>
            <template v-if="isEdit">
              <wd-radio-group v-model="formData.conclusion" inline class="conclusion-radio-group">
                <wd-radio
                  v-for="(opt, idx) in conclusionOptions"
                  :key="idx"
                  :value="opt.value"
                  shape="dot"
                >
                  {{ opt.label }}
                </wd-radio>
              </wd-radio-group>
            </template>
            <template v-else>
              {{ formatValue(detailData.inspectionResult?.conclusion) || "-" }}
            </template>
          </wd-form-item>
        </wd-col>
      </wd-row>
      <!-- 巡检结果 -->
      <wd-row v-if="detailData.processInspectionResult?.isFully">
        <view style="margin: 10rpx">
          <text class="title">{{ "巡检结果" }}</text>
        </view>
        <wd-col :span="24">
          <wd-form-item label="铝杆前、中、尾样品是否齐全" prop="isFully" required>
            <template v-if="isEdit">
              <wd-radio-group v-model="formData.isFully" inline class="conclusion-radio-group">
                <wd-radio
                  v-for="(opt, idx) in sampleCompleteOptions"
                  :key="idx"
                  :value="opt.value"
                  shape="dot"
                >
                  {{ opt.label }}
                </wd-radio>
              </wd-radio-group>
            </template>
            <template v-else>
              <wd-tag
                custom-class="space"
                :type="detailData.processInspectionResult?.isFully ? 'success' : 'danger'"
              >
                {{ detailData.processInspectionResult?.isFully ? "是" : "否" }}
              </wd-tag>
            </template>
          </wd-form-item>
        </wd-col>
      </wd-row>
      <!-- 附件模块 -->
      <wd-row class="attachment-section" v-if="detailData.files && detailData.files.length > 0">
        <view style="margin: 10rpx">
          <text class="title">{{ "附件" }}</text>
        </view>
        <view class="attachment-grid">
          <wd-col v-for="(file, index) in detailData.files" :key="index" class="attachment-item">
            <wd-img :width="80" :height="80" :src="file.url" @click="previewImage(file.url)">
              <template #error><view class="error-wrap">加载失败</view></template>
              <template #loading>
                <view class="loading-wrap"><wd-loading /></view>
              </template>
            </wd-img>
            <!-- <wd-icon
              v-if="isEdit"
              name="close-circle"
              class="delete-icon"
              @click.stop="deleteFile(index)"
            ></wd-icon> -->
          </wd-col>
          <wd-col v-if="isEdit" class="attachment-item upload-btn">
            <wd-upload
              :multiple="true"
              :max-count="5"
              :before-upload="beforeUpload"
              @success="handleUploadSuccess"
              @fail="handleUploadFail"
              accept="all"
        <wd-form-item label="外观" prop="appearance" required>
          <template v-if="isEdit">
            <wd-checkbox-group
              v-model="formData.appearance"
              inline
              v-for="(opt, idx) in appearanceOptions"
              :key="idx"
              style="text-align: justify"
            >
              <view class="upload-icon">+</view>
            </wd-upload>
          </wd-col>
        </view>
      </wd-row>
    </div>
              <wd-checkbox :modelValue="opt.value" style="width: 100px">
                {{ opt.label }}
              </wd-checkbox>
            </wd-checkbox-group>
          </template>
          <template v-else>
            {{ formatProductAppearance(formData.appearance) }}
          </template>
        </wd-form-item>
        <wd-form-item label="卷绕紧密" prop="windingTightness" required>
          <template v-if="isEdit">
            <wd-radio-group
              v-model="formData.windingTightness"
              inline
              class="conclusion-radio-group"
            >
              <wd-radio
                v-for="(opt, idx) in sampleCompleteOptions"
                :key="idx"
                :value="opt.value"
                shape="dot"
              >
                {{ opt.label }}
              </wd-radio>
            </wd-radio-group>
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.windingTightness) }}
          </template>
        </wd-form-item>
        <wd-form-item label="排列整齐" prop="arrangementNeatness" required>
          <template v-if="isEdit">
            <wd-radio-group
              v-model="formData.arrangementNeatness"
              inline
              class="conclusion-radio-group"
            >
              <wd-radio
                v-for="(opt, idx) in sampleCompleteOptions"
                :key="idx"
                :value="opt.value"
                shape="dot"
              >
                {{ opt.label }}
              </wd-radio>
            </wd-radio-group>
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.arrangementNeatness) }}
          </template>
        </wd-form-item>
        <wd-form-item
          label="外层铝线离侧板边缘距离"
          prop="aluminumWireDistance"
          label-width="360rpx"
          required
        >
          <template v-if="isEdit">
            <wd-input
              v-model="formData.aluminumWireDistance"
              placeholder="请输入距离(mm)"
              type="number"
            />
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.aluminumWireDistance, "mm") || "-" }}
          </template>
        </wd-form-item>
        <wd-form-item label="成品模后接头情况" prop="jointCondition" label-width="280rpx" required>
          <template v-if="isEdit">
            <wd-radio-group v-model="formData.jointCondition" inline class="conclusion-radio-group">
              <wd-radio
                v-for="(opt, idx) in jointConditionOptions"
                :key="idx"
                :value="opt.value"
                shape="dot"
              >
                {{ opt.label }}
              </wd-radio>
            </wd-radio-group>
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.jointCondition) || "-" }}
          </template>
        </wd-form-item>
        <wd-form-item label="结论" prop="conclusion" required>
          <template v-if="isEdit">
            <wd-radio-group v-model="formData.conclusion" inline class="conclusion-radio-group">
              <wd-radio
                v-for="(opt, idx) in conclusionOptions"
                :key="idx"
                :value="opt.value"
                shape="dot"
              >
                {{ opt.label }}
              </wd-radio>
            </wd-radio-group>
          </template>
          <template v-else>
            {{ formatValue(detailData.inspectionResult?.conclusion) || "-" }}
          </template>
        </wd-form-item>
      </wd-col>
    </wd-row>
    <!-- 巡检结果 -->
    <wd-row v-if="detailData.processInspectionResult?.isFully">
      <view style="margin: 10rpx">
        <text class="title">{{ "巡检结果" }}</text>
      </view>
      <wd-col :span="24">
        <wd-form-item label="铝杆前、中、尾样品是否齐全" prop="isFully" required>
          <template v-if="isEdit">
            <wd-radio-group v-model="formData.isFully" inline class="conclusion-radio-group">
              <wd-radio
                v-for="(opt, idx) in sampleCompleteOptions"
                :key="idx"
                :value="opt.value"
                shape="dot"
              >
                {{ opt.label }}
              </wd-radio>
            </wd-radio-group>
          </template>
          <template v-else>
            <wd-tag
              custom-class="space"
              :type="detailData.processInspectionResult?.isFully ? 'success' : 'danger'"
            >
              {{ detailData.processInspectionResult?.isFully ? "是" : "否" }}
            </wd-tag>
          </template>
        </wd-form-item>
      </wd-col>
    </wd-row>
    <!-- 附件模块 -->
    <wd-row class="attachment-section" v-if="detailData.files && detailData.files.length > 0">
      <view style="margin: 10rpx">
        <text class="title">{{ "附件" }}</text>
      </view>
      <wd-col :span="24">
        <AttachmentUpload
          :detailData="detailData"
          :isEdit="isEdit"
          :deviceType="paramsType"
          ref="attachmentRef"
        />
      </wd-col>
    </wd-row>
    <wd-popup v-model="show" custom-style="border-radius:32rpx;" @close="handleClose">
      <div class="image-preview">
        <img :src="previewImageUrl" alt="预览图片" style="width: 100%; height: auto" />
@@ -337,8 +304,11 @@
import RoutingInspectionApi from "@/api/routingInspection/routingInspection";
import Scan from "@/components/scan/index.vue";
import { useToast } from "wot-design-uni";
import AttachmentUpload from "../upload.vue";
// 核心状态
const paramsId = ref("");
const paramsType = ref("");
const detailData = ref<any>({});
const show = ref(false);
const previewImageUrl = ref("");
@@ -347,13 +317,14 @@
const deviceUid = ref("");
const scanRef = ref();
const toast = useToast();
const attachmentRef = ref<any>(null);
// 表单数据
const formData = reactive({
  dia: "",
  maxDia: "",
  minDia: "",
  appearance: "",
  appearance: [],
  windingTightness: "",
  arrangementNeatness: "",
  aluminumWireDistance: "",
@@ -413,8 +384,8 @@
};
// 格式化工具
const formatProductAppearance = (productAppearance: string) => {
  return !productAppearance ? "-" : productAppearance;
const formatProductAppearance = (productAppearance: string[]) => {
  return !productAppearance.length ? "-" : productAppearance.join("、");
};
const formatValue = (value: any, unit?: string) => {
@@ -438,7 +409,7 @@
  formData.dia = inspectionResult.dia || "";
  formData.maxDia = inspectionResult.maxDia || "";
  formData.minDia = inspectionResult.minDia || "";
  formData.appearance = inspectionResult.appearance || "";
  formData.appearance = inspectionResult.appearance || [];
  formData.windingTightness = inspectionResult.windingTightness || "";
  formData.arrangementNeatness = inspectionResult.arrangementNeatness || "";
  formData.aluminumWireDistance = inspectionResult.aluminumWireDistance || "";
@@ -462,6 +433,7 @@
// 页面加载
onLoad((options: any) => {
  paramsId.value = options.id;
  paramsType.value = options.deviceType;
  getDetailData(options.id, options.deviceType);
});
@@ -482,7 +454,7 @@
  // 校验
  if (!formData.maxDia) return uni.showToast({ title: "最大直径为必填项", icon: "none" });
  if (!formData.minDia) return uni.showToast({ title: "最小直径为必填项", icon: "none" });
  if (!formData.appearance) return uni.showToast({ title: "外观为必填项", icon: "none" });
  if (!formData.appearance.length) return uni.showToast({ title: "外观为必填项", icon: "none" });
  if (!formData.windingTightness) return uni.showToast({ title: "卷绕紧密为必填项", icon: "none" });
  if (!formData.arrangementNeatness)
    return uni.showToast({ title: "排列整齐为必填项", icon: "none" });
@@ -493,6 +465,9 @@
  if (!formData.conclusion) return uni.showToast({ title: "结论为必填项", icon: "none" });
  if (!formData.isFully) return uni.showToast({ title: "铝杆样品是否齐全为必填项", icon: "none" });
  if (!deviceUid.value) return uni.showToast({ title: "请扫描二维码", icon: "none" });
  const { newFiles } = attachmentRef.value.getSubmitFiles();
  console.log("newFiles", newFiles);
  const allFileIds = [...newFiles];
  // 提交
  try {
    const res = await RoutingInspectionApi.drawPatrolCheckInspection({
@@ -510,12 +485,12 @@
        conclusion: formData.conclusion,
      },
      inspectionResult: { isFully: formData.isFully },
      processInspectionAttachmentList: tempFiles.value.map((f) => f.url),
      processInspectionAttachmentList: allFileIds,
    });
    if (res.code === 200) {
      uni.showToast({ title: "保存成功", icon: "success" });
      isEdit.value = false;
      getDetailData(paramsId.value, detailData.value.deviceType);
      getDetailData(paramsId.value, paramsType.value);
    } else {
      uni.showModal({ title: res.msg || "保存失败", icon: "error" });
    }
@@ -523,56 +498,6 @@
    console.error("保存失败:", e);
    uni.showModal({ title: e.message || "保存失败", icon: "error" });
  }
};
// 附件上传校验
const beforeUpload = (file: any) => {
  const maxSize = 2 * 1024 * 1024;
  if (file.size > maxSize) {
    uni.showToast({ title: "图片大小不能超过2M", icon: "none" });
    return false;
  }
  return true;
};
// 附件上传成功
const handleUploadSuccess = (res: any) => {
  if (Array.isArray(res)) {
    tempFiles.value = [
      ...tempFiles.value,
      ...res.map((file) => ({
        ...file,
        id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
      })),
    ];
  } else {
    tempFiles.value.push({
      ...res,
      id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
    });
  }
};
// 附件上传失败
const handleUploadFail = (err: any) => {
  uni.showToast({ title: "附件上传失败", icon: "error" });
};
// 删除附件
const deleteFile = (index: number) => {
  if (index >= detailData.value.files.length) {
    tempFiles.value = tempFiles.value.filter(
      (_, idx) => idx !== index - detailData.value.files.length
    );
  } else {
    detailData.value.files = detailData.value.files.filter((_, idx) => idx !== index);
  }
};
// 图片预览
const previewImage = (url: string) => {
  previewImageUrl.value = url;
  show.value = true;
};
const handleClose = () => {
@@ -583,12 +508,10 @@
  scanRef.value.triggerScan();
};
const getScanCode = (params: any) => {
  console.log("完整参数:", params);
  let codeObj = {};
  try {
    codeObj = JSON.parse(params.code);
  } catch (err) {
    console.error("JSON解析失败:", err);
    toast.error("扫码数据异常");
    return; // 解析失败直接返回,避免后续错误
  }