| | |
| | | </view> |
| | | </view> |
| | | <view class="list"> |
| | | <div class="inspection-report"> |
| | | <!-- 基本信息模块 --> |
| | | <wd-row> |
| | | <view style="margin: 10rpx"> |
| | |
| | | </wd-checkbox-group> |
| | | </template> |
| | | <template v-else> |
| | | {{ |
| | | formatProductAppearance(detailData.inspectionResult?.appearance).join("、") || "-" |
| | | }} |
| | | {{ formatProductAppearance(formData.appearance) }} |
| | | </template> |
| | | </wd-form-item> |
| | | |
| | |
| | | </template> |
| | | </wd-form-item> |
| | | |
| | | <wd-form-item |
| | | label="成品模后接头情况" |
| | | prop="jointCondition" |
| | | label-width="280rpx" |
| | | required |
| | | > |
| | | <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-group v-model="formData.jointCondition" inline class="conclusion-radio-group"> |
| | | <wd-radio |
| | | v-for="(opt, idx) in jointConditionOptions" |
| | | :key="idx" |
| | |
| | | <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 :span="24"> |
| | | <AttachmentUpload |
| | | :detailData="detailData" |
| | | :isEdit="isEdit" |
| | | :deviceType="paramsType" |
| | | ref="attachmentRef" |
| | | /> |
| | | </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" |
| | | > |
| | | <view class="upload-icon">+</view> |
| | | </wd-upload> |
| | | </wd-col> |
| | | </view> |
| | | </wd-row> |
| | | </div> |
| | | <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" /> |
| | |
| | | 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(""); |
| | |
| | | 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: "", |
| | |
| | | }; |
| | | |
| | | // 格式化工具 |
| | | const formatProductAppearance = (productAppearance: string) => { |
| | | return !productAppearance ? "-" : productAppearance; |
| | | const formatProductAppearance = (productAppearance: string[]) => { |
| | | return !productAppearance.length ? "-" : productAppearance.join("、"); |
| | | }; |
| | | |
| | | const formatValue = (value: any, unit?: string) => { |
| | |
| | | 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 || ""; |
| | |
| | | // 页面加载 |
| | | onLoad((options: any) => { |
| | | paramsId.value = options.id; |
| | | paramsType.value = options.deviceType; |
| | | getDetailData(options.id, options.deviceType); |
| | | }); |
| | | |
| | |
| | | // 校验 |
| | | 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" }); |
| | |
| | | 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({ |
| | |
| | | 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" }); |
| | | } |
| | |
| | | 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 = () => { |
| | |
| | | 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; // 解析失败直接返回,避免后续错误 |
| | | } |