From 1e71cfb6ec97cff6531dec65a3fb5cb24b2c18ac Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 03 十一月 2025 09:57:48 +0800
Subject: [PATCH] fix: 附件完善

---
 src/pages/routingInspection/detail/indexJX.vue |  988 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 728 insertions(+), 260 deletions(-)

diff --git a/src/pages/routingInspection/detail/indexJX.vue b/src/pages/routingInspection/detail/indexJX.vue
index 715d85d..f82336a 100644
--- a/src/pages/routingInspection/detail/indexJX.vue
+++ b/src/pages/routingInspection/detail/indexJX.vue
@@ -1,285 +1,753 @@
 <template>
-	<view class="list">
-		<div class="inspection-report">
-			<!-- 鍩烘湰淇℃伅妯″潡 -->
-			<wd-row>
-				<text class="title">{{ "鍩烘湰淇℃伅" }}</text>
-				<wd-col :span="24">
-					<wd-form-item label="鏃ユ湡"
-						prop="recordDate">{{ formatDate(recordData.fixedInfo?.recordDate)}}</wd-form-item>
-					<wd-form-item label="鐝"
-						prop="workShift">{{formatValue(recordData.fixedInfo?.workShift)}}</wd-form-item>
-					<wd-form-item label="鍨嬪彿瑙勬牸" prop="model">{{ formatValue(recordData.fixedInfo?.model)}}</wd-form-item>
-					<wd-form-item label="鎴愬搧绾跨洏鍙�"
-						prop="systemNo">{{ formatValue(recordData.fixedInfo?.systemNo)}}</wd-form-item>
-					<wd-form-item label="璁板綍浜�"
-						prop="createUserName">{{ formatValue(recordData.fixedInfo?.createUserName) }}</wd-form-item>
-					<wd-form-item label="鏈哄彴"
-						prop="deviceModel">{{ formatValue(recordData.fixedInfo?.deviceModel)}}</wd-form-item>
-					<wd-form-item label="浜у搧绫诲埆"
-						prop="productType">{{ formatValue(recordData.fixedInfo?.productType)}}</wd-form-item>
-					<wd-form-item label="鐢熶骇闀垮害"
-						prop="actuallyLength">{{ formatValue(recordData.fixedInfo?.actuallyLength, "m")}}</wd-form-item>
-					<wd-form-item label="寮犲姏璁剧疆"
-						prop="twistTension">{{ formatValue(recordData.fixedInfo?.twistTension, "N/m") }}</wd-form-item>
-					<wd-form-item label="缁炲埗澶栧緞"
-						prop="twistDiameter">{{ formatValue(recordData.inspectionResult?.twistDiameter, "mm") }}</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<!-- 鑷璁板綍璇︽儏妯″潡 -->
-			<wd-row>
-				<text class="title">{{ "鑷璁板綍璇︽儏" }}</text>
-				<wd-col :span="24">
-					<wd-form-item label="璁板綍浣嶇疆"
-						prop="recordPosition">{{ recordData.structureInfo?.recordPosition || "-" }}</wd-form-item>
-					<wd-form-item label="璁板綍浜�"
-						prop="createUserName">{{ recordData.structureInfo?.createUserName || "-"}}</wd-form-item>
-					<wd-form-item label="鐘舵��" prop="status">
-						<wd-tag custom-class="space"
-							:type="getStatusType(recordData.structureInfo?.status)">{{ getStatusText(recordData.structureInfo?.status) }}</wd-tag>
-					</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<!-- 缁撴瀯妫�鏌ユā鍧� -->
-			<wd-row>
-				<text class="title">{{ "缁撴瀯妫�鏌�" }}</text>
-				<wd-col :span="24">
-					<wd-form-item label="鎴愬搧缁撴瀯"
-						prop="inspectStructure">{{recordData.structureInfo.structureRecordResult.inspectStructure.structureFormula || "-"}}</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<wd-row v-if="recordData.structureInfo.structureRecordResult.inspectStructure.structureItems">
-				<text class="title">{{ "缁撴瀯鏍囧噯鍊煎拰瀹炴祴" }}</text>
-				<wd-col :span="24"
-					v-for="(item, index) in recordData.structureInfo.structureRecordResult.inspectStructure.structureItems"
-					:key="index" style="padding-bottom: 10px;">
-					<wd-form-item :label="formatValue(item.structureName)" label-width="400rpx"
-						style="color: red;"></wd-form-item>
-					<wd-form-item label="鏍囧噯鍊�" prop="structureValue">{{formatValue(item.structureValue)}}</wd-form-item>
-					<wd-form-item label="瀹炴祴鏍规暟"
-						prop="actualValue1">{{formatValue(item.actualValue1, "鏍�")}}</wd-form-item>
-					<wd-form-item label="瀹炴祴鐩村緞"
-						prop="actualValue2">{{formatValue(item.actualValue2, "mm")}}</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<!-- 缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗妯″潡 -->
-			<wd-row v-if="recordData.structureInfo?.structureRecordResult?.inspectTwist">
-				<text class="title">{{ "缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗" }}</text>
-				<wd-col :span="24" v-for="(item, index) in recordData.structureInfo.structureRecordResult.inspectTwist"
-					:key="index" style="padding-bottom: 10px;">
-					<wd-form-item :label="formatValue(item.twistName)" label-width="400rpx"
-						style="color: red;"></wd-form-item>
-					<wd-form-item label="缁炲悜" prop="direction">{{ formatValue(item.direction) }}</wd-form-item>
-					<wd-form-item label="鑺傝窛" prop="pitch">{{ formatValue(item.pitch, "mm") }}</wd-form-item>
-					<wd-form-item label="鑺傚緞姣�" prop="pitchRatio">{{ formatValue(item.pitchRatio) }}</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<!-- 澶栬鍜岀粨璁烘ā鍧� -->
-			<wd-row>
-				<text class="title">{{ "澶栬鍜岀粨璁�" }}</text>
-				<wd-col :span="24">
-					<wd-form-item label="缁撹"
-						prop="conclusion">{{formatValue(recordData.structureInfo.structureRecordResult.conclusion)}}</wd-form-item>
-					<wd-form-item label="浜у搧澶栬"
-						prop="productAppearance">{{formatProductAppearance(recordData.structureInfo.structureRecordResult.productAppearance)}}</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<!-- 宸℃缁撴灉妯″潡 -->
-			<wd-row>
-				<text class="title">{{ "宸℃缁撴灉" }}</text>
-				<wd-col :span="24">
-					<wd-form-item label="鏍峰搧鏄惁榻愬叏"
-						prop="sampleComplete">{{formatValue(recordData.inspectionResult?.sampleComplete)}}</wd-form-item>
-				</wd-col>
-			</wd-row>
-			<!-- 闄勪欢妯″潡 -->
-			<wd-row class="attachment-section">
-				<text class="title">{{ "闄勪欢" }}</text>
-				<!-- 鐢� flex 瀹瑰櫒鍖呰9鍥剧墖鍒楋紝瀹炵幇鑷姩鎹㈣ -->
-				<view class="attachment-grid">
-					<wd-col v-for="(file, index) in recordData.structureInfo.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-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" />
-			</div>
-		</wd-popup>
-	</view>
+  <view class="fixed-header">
+    <view class="header-container">
+      <wd-button
+        icon="file-add"
+        :round="false"
+        size="small"
+        custom-class="add_btn"
+        @click="editList"
+        v-if="!isEdit"
+      >
+        缂栬緫
+      </wd-button>
+      <wd-button
+        icon="close"
+        type="info"
+        :round="false"
+        size="small"
+        custom-class="add_btn"
+        @click="close"
+        v-if="isEdit"
+      >
+        鍙栨秷
+      </wd-button>
+      <wd-button
+        icon="check"
+        type="success"
+        :round="false"
+        size="small"
+        custom-class="add_btn"
+        @click="saveList"
+        v-if="isEdit"
+      >
+        淇濆瓨
+      </wd-button>
+      <view class="placeholder"></view>
+      <view class="scan-wrapper" @click="openScan">
+        <wd-icon name="scan" size="24px" color="#0D867F"></wd-icon>
+      </view>
+    </view>
+  </view>
+  <view class="list">
+    <!-- 鍩烘湰淇℃伅妯″潡 -->
+    <wd-row>
+      <view style="margin: 10rpx">
+        <text class="title">{{ "鍩烘湰淇℃伅" }}</text>
+      </view>
+      <wd-col :span="24">
+        <wd-form-item label="鏃ユ湡" prop="recordDate">
+          {{ formatDate(recordData.fixedInfo?.recordDate) }}
+        </wd-form-item>
+        <wd-form-item label="鐝" prop="workShift">
+          {{ formatValue(recordData.fixedInfo?.workShift) }}
+        </wd-form-item>
+        <wd-form-item label="鍨嬪彿瑙勬牸" prop="model">
+          {{ formatValue(recordData.fixedInfo?.model) }}
+        </wd-form-item>
+        <wd-form-item label="鎴愬搧绾跨洏鍙�" prop="systemNo">
+          {{ formatValue(recordData.fixedInfo?.systemNo) }}
+        </wd-form-item>
+        <wd-form-item label="璁板綍浜�" prop="createUserName">
+          {{ formatValue(recordData.fixedInfo?.createUserName) }}
+        </wd-form-item>
+        <wd-form-item label="鏈哄彴" prop="deviceModel">
+          {{ formatValue(recordData.fixedInfo?.deviceModel) }}
+        </wd-form-item>
+        <wd-form-item label="浜у搧绫诲埆" prop="productType">
+          {{ formatValue(recordData.fixedInfo?.productType) }}
+        </wd-form-item>
+        <wd-form-item label="鐢熶骇闀垮害" prop="actuallyLength">
+          {{ formatValue(recordData.fixedInfo?.actuallyLength, "m") }}
+        </wd-form-item>
+        <wd-form-item label="寮犲姏璁剧疆" prop="twistTension">
+          {{ formatValue(recordData.fixedInfo?.twistTension, "N/m") }}
+        </wd-form-item>
+        <!-- 缁炲埗澶栧緞锛堝彲缂栬緫锛� -->
+        <wd-form-item label="缁炲埗澶栧緞" prop="twistDiameter" required>
+          <template v-if="isEdit">
+            <wd-input
+              v-model="formData.twistDiameter"
+              placeholder="璇疯緭鍏ョ粸鍒跺寰勶紙mm锛�"
+              type="number"
+            />
+          </template>
+          <template v-else>
+            {{ formatValue(formData.twistDiameter, "mm") }}
+          </template>
+        </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="recordPosition">
+          {{ recordData.structureInfo?.recordPosition || "-" }}
+        </wd-form-item>
+        <wd-form-item label="璁板綍浜�" prop="createUserName">
+          {{ recordData.structureInfo?.createUserName || "-" }}
+        </wd-form-item>
+        <wd-form-item label="鐘舵��" prop="status">
+          <wd-tag custom-class="space" :type="getStatusType(recordData.structureInfo?.status)">
+            {{ getStatusText(recordData.structureInfo?.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="structureFormula" required>
+          <template v-if="isEdit">
+            <wd-input v-model="formData.structureFormula" placeholder="璇疯緭鍏ユ垚鍝佺粨鏋�" />
+          </template>
+          <template v-else>
+            {{ formData.structureFormula || "-" }}
+          </template>
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
+
+    <!-- 缁撴瀯鏍囧噯鍊煎拰瀹炴祴锛堝彲缂栬緫锛� -->
+    <wd-row v-if="formData.structureItems.length">
+      <view style="margin: 10rpx">
+        <text class="title">{{ "缁撴瀯鏍囧噯鍊煎拰瀹炴祴" }}</text>
+      </view>
+      <wd-col
+        :span="24"
+        v-for="(item, index) in formData.structureItems"
+        :key="index"
+        style="padding-bottom: 10px"
+      >
+        <wd-form-item
+          prop="structureItemsGroup"
+          :label="formatValue(item.structureName)"
+          label-width="400rpx"
+          style="color: red"
+          required
+        ></wd-form-item>
+        <wd-form-item label="鏍囧噯鍊�" prop="structureValue" required>
+          {{ formatValue(item.structureValue) }}
+        </wd-form-item>
+        <wd-form-item label="瀹炴祴鏍规暟" prop="actualValue1" required>
+          <template v-if="isEdit">
+            <wd-input v-model="item.actualValue1" placeholder="璇疯緭鍏ュ疄娴嬫牴鏁�" type="number" />
+          </template>
+          <template v-else>
+            {{ formatValue(item.actualValue1, "鏍�") }}
+          </template>
+        </wd-form-item>
+        <wd-form-item label="瀹炴祴鐩村緞" prop="actualValue2" required>
+          <template v-if="isEdit">
+            <wd-input
+              v-model="item.actualValue2"
+              placeholder="璇疯緭鍏ュ疄娴嬬洿寰勶紙mm锛�"
+              type="number"
+            />
+          </template>
+          <template v-else>
+            {{ formatValue(item.actualValue2, "mm") }}
+          </template>
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
+
+    <!-- 缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗锛堝彲缂栬緫锛� -->
+    <wd-row v-if="formData.inspectTwist.length">
+      <view style="margin: 10rpx">
+        <text class="title">{{ "缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗" }}</text>
+      </view>
+      <wd-col
+        :span="24"
+        v-for="(item, index) in formData.inspectTwist"
+        :key="index"
+        style="padding-bottom: 10px"
+      >
+        <wd-form-item
+          :label="formatValue(item.twistName)"
+          label-width="400rpx"
+          style="color: red"
+          prop="inspectTwistGroup"
+          required
+        ></wd-form-item>
+        <wd-form-item label="缁炲悜" prop="direction" required>
+          <template v-if="isEdit">
+            <wd-select-picker
+              label=""
+              v-model="item.direction"
+              :columns="twistDirectionOptions"
+              type="radio"
+              placeholder="璇烽�夋嫨缁炲悜"
+              :clearable="false"
+            ></wd-select-picker>
+          </template>
+          <template v-else>
+            {{ formatValue(item.direction) }}
+          </template>
+        </wd-form-item>
+        <wd-form-item label="鑺傝窛" prop="pitch" required>
+          <template v-if="isEdit">
+            <wd-input v-model="item.pitch" placeholder="璇疯緭鍏ヨ妭璺濓紙mm锛�" type="number" />
+          </template>
+          <template v-else>
+            {{ formatValue(item.pitch, "mm") }}
+          </template>
+        </wd-form-item>
+        <wd-form-item label="鑺傚緞姣�" prop="pitchRatio" required>
+          {{ formatValue(item.pitchRatio) }}
+        </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="productAppearance" required>
+          <template v-if="isEdit">
+            <wd-checkbox-group
+              v-model="formData.productAppearance"
+              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(formData.productAppearance) }}
+          </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(formData.conclusion) }}
+          </template>
+        </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="sampleComplete" required>
+          <template v-if="isEdit">
+            <wd-radio-group v-model="formData.sampleComplete" 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(formData.sampleComplete) }}
+          </template>
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
+
+    <!-- 闄勪欢妯″潡锛堝惈涓婁紶鍔熻兘锛� -->
+    <wd-row class="attachment-section">
+      <view style="margin: 10rpx">
+        <text class="title">{{ "闄勪欢" }}</text>
+      </view>
+      <wd-col :span="24">
+        <AttachmentUpload
+          :detailData="detailData"
+          :isEdit="isEdit"
+          :deviceType="paramsType"
+          ref="attachmentRef"
+          v-if="detailDataLoaded"
+        />
+      </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" />
+      </div>
+    </wd-popup>
+    <Scan ref="scanRef" emitName="scan" />
+    <wd-toast />
+  </view>
 </template>
 
 <script setup lang="ts">
-	import { onLoad } from "@dcloudio/uni-app";
-	import RoutingInspectionApi from "@/api/routingInspection/routingInspection";
+import { ref, reactive, computed } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+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 recordData = ref<any>({});
-	const show = ref(false);
+const paramsType = ref("");
+const paramsId = ref("");
+const recordData = ref<any>({ structureInfo: { files: [], structureRecordResult: {} } });
+const show = ref(false);
 const previewImageUrl = ref("");
-  
-	// 鐘舵�佺被鍨嬫槧灏�
-	const getStatusType = (status : number) => {
-		switch (status) {
-			case 0:
-				return "warning"; // 寰呭贰妫�
-			case 1:
-				return "danger"; // 宸查┏鍥�
-			case 2:
-				return "info"; // 寰呭鏍�
-			case 3:
-				return "success"; // 閫氳繃
-			default:
-				return "info";
-		}
-	};
+const isEdit = ref(false);
+const tempFiles = ref<any[]>([]); // 涓存椂瀛樺偍鏂颁笂浼犵殑闄勪欢
+const deviceUid = ref("");
+const scanRef = ref();
+const toast = useToast();
+const attachmentRef = ref<any>(null);
+const detailData = reactive<any>({});
+const detailDataLoaded = ref(false);
 
-	// 鐘舵�佹枃鏈槧灏�
-	const getStatusText = (status : number) => {
-		switch (status) {
-			case 0:
-				return "寰呭贰妫�";
-			case 1:
-				return "宸查┏鍥�";
-			case 2:
-				return "寰呭鏍�";
-			case 3:
-				return "閫氳繃";
-			default:
-				return "鏈煡";
-		}
-	};
+const formData = reactive({
+  twistDiameter: "", // 缁炲埗澶栧緞
+  structureFormula: "", // 鎴愬搧缁撴瀯
+  structureItems: [], // 缁撴瀯鏍囧噯鍊煎拰瀹炴祴
+  inspectTwist: [], // 缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗
+  productAppearance: [] as string[], // 浜у搧澶栬锛堟敼涓烘暟缁勫瓨鍌ㄩ�変腑鍊硷級
+  conclusion: "", // 缁撹锛堟敼涓烘暟缁勫瓨鍌ㄩ�変腑鍊硷級
+  sampleComplete: "", // 鏍峰搧鏄惁榻愬叏
+});
 
-	// 鑾峰彇澶栬鏂囨湰
-	const getAppearanceText = (appearance : string[]) => {
-		if (!appearance || appearance.length === 0) return "-";
-		return appearance.join("銆�");
-	};
+const twistDirectionOptions = [
+  { label: "宸﹀悜", value: "宸﹀悜" },
+  { label: "鍙冲悜", value: "鍙冲悜" },
+];
 
-	// 鏍煎紡鍖栦骇鍝佸瑙傛樉绀�
-	const formatProductAppearance = (productAppearance : string[]) => {
-		if (!productAppearance || productAppearance.length === 0) return "-";
-		return productAppearance.join("銆�");
-	};
+const appearanceOptions = [
+  { label: "鏃犲瑙傞棶棰�", value: "鏃犲瑙傞棶棰�" },
+  { label: "琛ㄩ潰鍒掍激", value: "琛ㄩ潰鍒掍激" },
+  { label: "鐩村緞涓嶅潎", value: "鐩村緞涓嶅潎" },
+  { label: "鍏朵粬缂洪櫡", value: "鍏朵粬缂洪櫡" },
+];
 
-	// 鏍煎紡鍖栨暟鍊兼樉绀�
-	const formatValue = (value : any, unit ?: string) => {
-		if (value === null || value === undefined || value === "") return "-";
-		return unit ? `${value}${unit}` : value;
-	};
+const conclusionOptions = [
+  { label: "鍚堟牸", value: "鍚堟牸" },
+  { label: "涓嶅悎鏍�", value: "涓嶅悎鏍�" },
+];
+const sampleCompleteOptions = [
+  { label: "鏄�", value: "鏄�" },
+  { label: "鍚�", value: "鍚�" },
+];
 
-	// 鏍煎紡鍖栨棩鏈熸樉绀�
-	const formatDate = (date : string) => {
-		if (!date) return "-";
-		return new Date(date).toLocaleDateString("zh-CN", {
-			year: "numeric",
-			month: "2-digit",
-			day: "2-digit"
-		});
-	};
+const initFormData = () => {
+  const structureResult = recordData.value.structureInfo?.structureRecordResult || {};
+  const inspectionResult = recordData.value.inspectionResult || {};
 
-	// 鏍煎紡鍖栫粨鏋勫�兼樉绀�
-	const formatStructureValue = (value1 : any, value2 : any) => {
-		const val1 = value1 || "-";
-		const val2 = value2 ? `${value2}mm` : "-";
-		return { count: val1, diameter: val2 };
-	};
+  formData.twistDiameter = inspectionResult.twistDiameter || "";
+  formData.structureFormula = structureResult.inspectStructure?.structureFormula || "";
+  formData.sampleComplete = inspectionResult.sampleComplete || "";
+  formData.conclusion = structureResult.conclusion || "";
+  formData.productAppearance = Array.isArray(structureResult.productAppearance)
+    ? structureResult.productAppearance
+    : structureResult.productAppearance
+    ? [structureResult.productAppearance]
+    : [];
 
-	const getDetailData = async (id : string, deviceType : string) => {
-		try {
-			let response;
-				// 鑾峰彇缁炵嚎鍗曚釜缁撴瀯
-				response = await RoutingInspectionApi.getStrandedInspectionStructureInfoById({
-					id: id,
-				});
-				recordData.value = response.data;
-				console.log(recordData.value);
-		} catch (error) {
-			console.error("鑾峰彇璇︽儏澶辫触:", error);
-		}
-	};
+  formData.structureItems = JSON.parse(
+    JSON.stringify(structureResult.inspectStructure?.structureItems || [])
+  );
+  formData.inspectTwist = JSON.parse(JSON.stringify(structureResult.inspectTwist || []));
 
-	onLoad((options : any) => {
-		paramsId.value = options.id;
-		getDetailData(options.id, options.deviceType);
-	});
+  formData.inspectTwist.forEach((item: any) => {
+    if (!item.direction) item.direction = "";
+  });
+};
 
-	const previewImage = (url : string) => {
-		previewImageUrl.value = url;
-		show.value = true;
-	};
+const getDetailData = async (id: string, deviceType: string) => {
+  try {
+    const response = await RoutingInspectionApi.getStrandedInspectionStructureInfoById({ id });
+    recordData.value = response.data;
+    detailData.value = response.data.structureInfo;
+    console.log("detailData.value", detailData.value);
+    tempFiles.value = []; // 娓呯┖涓存椂鏂囦欢
+    initFormData(); // 鏁版嵁杩斿洖鍚庡垵濮嬪寲琛ㄥ崟
+    detailDataLoaded.value = true; // 鏁版嵁鍔犺浇瀹屾垚鍚庯紝娓叉煋瀛愮粍浠�
+    console.log("鐖剁粍浠�-鏁版嵁灏辩华鍚庢墦鍗�");
+  } catch (error) {
+    console.error("鑾峰彇璇︽儏澶辫触:", error);
+    uni.showToast({ title: "鍔犺浇澶辫触", icon: "error" });
+  }
+};
 
-	const handleClose = () => {
-		show.value = false;
-	};
+// 椤甸潰鍔犺浇
+onLoad((options: any) => {
+  try {
+    paramsId.value = options.id;
+    paramsType.value = options.deviceType;
+    getDetailData(options.id, options.deviceType);
+  } catch (error) {
+    console.error("鑾峰彇璇︽儏澶辫触:", error);
+    uni.showToast({ title: "鍔犺浇澶辫触", icon: "error" });
+  }
+});
+
+// 缂栬緫妯″紡鍒囨崲
+const editList = () => {
+  isEdit.value = true;
+};
+
+// 鍙栨秷缂栬緫锛堥噸缃〃鍗曪級
+const close = () => {
+  isEdit.value = false;
+  tempFiles.value = [];
+  initFormData();
+};
+
+// 淇濆瓨缂栬緫锛堝惈蹇呭~椤规牎楠岋級
+const saveList = async () => {
+  // 1. 鍩虹瀛楁鏍¢獙
+  if (!formData.structureFormula) return uni.showToast({ title: "鎴愬搧缁撴瀯涓哄繀濉」", icon: "none" });
+  if (!formData.twistDiameter) return uni.showToast({ title: "缁炲埗澶栧緞涓哄繀濉」", icon: "none" });
+  if (!formData.productAppearance.length)
+    return uni.showToast({ title: "浜у搧澶栬涓哄繀濉」", icon: "none" });
+  if (!formData.conclusion) return uni.showToast({ title: "缁撹涓哄繀濉」", icon: "none" });
+  if (!formData.sampleComplete)
+    return uni.showToast({ title: "鏍峰搧鏄惁榻愬叏涓哄繀濉」", icon: "none" });
+  // 2. 缁撴瀯椤瑰惊鐜牎楠�
+  for (const item of formData.structureItems) {
+    if (!item.structureValue)
+      return uni.showToast({ title: `${item.structureName}鏍囧噯鍊间负蹇呭~椤筦, icon: "none" });
+    if (!item.actualValue1)
+      return uni.showToast({ title: `${item.structureName}瀹炴祴鏍规暟涓哄繀濉」`, icon: "none" });
+    if (!item.actualValue2)
+      return uni.showToast({ title: `${item.structureName}瀹炴祴鐩村緞涓哄繀濉」`, icon: "none" });
+  }
+
+  // 3. 缁炵嚎宸ヨ壓椤瑰惊鐜牎楠�
+  for (const item of formData.inspectTwist) {
+    if (!item.direction)
+      return uni.showToast({ title: `${item.twistName}缁炲悜涓哄繀濉」`, icon: "none" });
+    if (!item.pitch) return uni.showToast({ title: `${item.twistName}鑺傝窛涓哄繀濉」`, icon: "none" });
+    if (!item.pitchRatio)
+      return uni.showToast({ title: `${item.twistName}鑺傚緞姣斾负蹇呭~椤筦, icon: "none" });
+  }
+  console.log("1111", deviceUid.value);
+  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.strandedPatrolCheckInspection({
+      deviceUid: deviceUid.value,
+      id: paramsId.value,
+      result: {
+        twistDiameter: formData.twistDiameter,
+        structureFormula: formData.structureFormula,
+        structureItems: formData.structureItems,
+        inspectTwist: formData.inspectTwist,
+        productAppearance: formData.productAppearance,
+        conclusion: formData.conclusion,
+        sampleComplete: formData.sampleComplete,
+      },
+      inspectionResult: {
+        sampleComplete: formData.sampleComplete,
+      },
+      processInspectionAttachmentList: allFileIds,
+    });
+
+    if (res.code === 200) {
+      uni.showToast({ title: "淇濆瓨鎴愬姛", icon: "success" });
+      isEdit.value = false;
+      getDetailData(paramsId.value, paramsType.value);
+    } else {
+      uni.showModal({ title: res.msg || "淇濆瓨澶辫触", icon: "error" });
+    }
+  } catch (e) {
+    console.error("淇濆瓨澶辫触:", e);
+    uni.showModal({ title: e.message || "淇濆瓨澶辫触", icon: "error" });
+  }
+};
+
+const handleClose = () => {
+  show.value = false;
+};
+
+// 鐘舵�佺被鍨嬫槧灏�
+const getStatusType = (status: number) => {
+  switch (status) {
+    case 0:
+      return "warning"; // 寰呭贰妫�
+    case 1:
+      return "danger"; // 宸查┏鍥�
+    case 2:
+      return "info"; // 寰呭鏍�
+    case 3:
+      return "success"; // 閫氳繃
+    default:
+      return "info";
+  }
+};
+
+// 鐘舵�佹枃鏈槧灏�
+const getStatusText = (status: number) => {
+  switch (status) {
+    case 0:
+      return "寰呭贰妫�";
+    case 1:
+      return "宸查┏鍥�";
+    case 2:
+      return "寰呭鏍�";
+    case 3:
+      return "閫氳繃";
+    default:
+      return "鏈煡";
+  }
+};
+
+// 鏍煎紡鍖栦骇鍝佸瑙傛樉绀�
+const formatProductAppearance = (productAppearance: string[]) => {
+  if (!productAppearance || productAppearance.length === 0) return "-";
+  return productAppearance.join("銆�");
+};
+
+// 鏍煎紡鍖栨暟鍊兼樉绀�
+const formatValue = (value: any, unit?: string) => {
+  if (value === null || value === undefined || value === "") return "-";
+  return unit ? `${value}${unit}` : value;
+};
+
+// 鏍煎紡鍖栨棩鏈熸樉绀�
+const formatDate = (date: string) => {
+  if (!date) return "-";
+  return new Date(date).toLocaleDateString("zh-CN", {
+    year: "numeric",
+    month: "2-digit",
+    day: "2-digit",
+  });
+};
+
+const openScan = () => {
+  scanRef.value.triggerScan();
+};
+const getScanCode = (params: any) => {
+  console.log("瀹屾暣鍙傛暟锛�", params);
+  let codeObj = {};
+  try {
+    codeObj = JSON.parse(params.code);
+  } catch (err) {
+    console.error("JSON瑙f瀽澶辫触锛�", err);
+    toast.error("鎵爜鏁版嵁寮傚父");
+    return;
+  }
+  deviceUid.value = codeObj?.uid;
+  toast.success("鎵爜鎴愬姛");
+};
+// 纭繚鍏堢Щ闄ゅ啀娣诲姞鐩戝惉
+const setupScanListener = () => {
+  uni.$off("scan", getScanCode); // 鍏堢Щ闄ゆ棫鐨�
+  uni.$on("scan", getScanCode); // 鍐嶆坊鍔犳柊鐨�
+};
+onUnmounted(() => {
+  // 寮�鍚箍鎾洃鍚簨浠�
+  uni.$off("scan", getScanCode);
+  console.log("绂诲紑1");
+});
+onMounted(() => {
+  // 寮�鍚箍鎾洃鍚簨浠�
+  setupScanListener();
+  console.log("鏄剧ず1");
+});
 </script>
+
 <style lang="scss" scoped>
-	.list {
-		height: calc(100vh - 80px);
-		padding: 12px;
-		background: #f3f9f8;
+.fixed-header {
+  position: fixed;
+  top: 44;
+  left: 0;
+  right: 0;
+  background: #f3f9f8;
+  z-index: 999;
+  padding: 12px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+  min-height: 60px;
+  box-sizing: border-box;
+  overflow: visible;
+}
 
-		:deep() {
-			.round {
-				border-radius: 4px;
-			}
-		}
-	}
+.header-container {
+  display: flex;
+  align-items: center;
+  width: 100%;
+  gap: 10px;
+}
 
-	.title {
-		position: relative;
-		margin-left: 10px;
-		font-size: 16px;
-		font-weight: 500;
-		color: #0d867f;
-	}
+.placeholder {
+  flex: 1;
+}
 
-	.title::after {
-		position: absolute;
-		content: "";
-		top: 4px;
-		left: -10px;
-		width: 4px;
-		height: 16px;
-		background: #0d867f;
-		border-radius: 2px;
-	}
+.scan-wrapper {
+  width: 38px;
+  height: 38px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding: 6px;
+  flex-shrink: 0;
+}
 
-	.attachment-section {
-		width: 100%;
-	}
+.list {
+  padding: 12px;
+  padding-top: 84px;
+  background: #f3f9f8;
+  min-height: 100vh;
+  box-sizing: border-box;
+  overflow-y: auto;
+}
 
-	.attachment-grid {
-		display: flex;
-		flex-wrap: wrap;
-		/* 瓒呭嚭鑷姩鎹㈣ */
-		gap: 10px;
-		/* 鍥剧墖涔嬮棿鐨勯棿璺� */
-		padding: 10px 0;
-	}
+.title {
+  position: relative;
+  margin-left: 10px;
+  font-size: 16px;
+  font-weight: 500;
+  color: #0d867f;
+}
 
-	.attachment-item {
-		width: calc(25% - 10px);
-		/* 姣忚4寮狅紝闂磋窛鐢眊ap鎺у埗锛岄渶璁$畻瀹藉害 */
-		box-sizing: border-box;
-	}
+.title::after {
+  position: absolute;
+  content: "";
+  top: 4px;
+  left: -10px;
+  width: 4px;
+  height: 16px;
+  background: #0d867f;
+  border-radius: 2px;
+}
 
-	/* 閫傞厤灏忓睆骞曪紝鍙皟鏁存瘡琛屾暟閲忥紙濡傛瘡琛�2寮狅級 */
-	@media (max-width: 768px) {
-		.attachment-item {
-			width: calc(25% - 10px);
-		}
-	}
-</style>
\ No newline at end of file
+// 浜у搧澶栬鍜岀粨璁洪�夋嫨鍣ㄦ牱寮忥紙涓�琛屼袱涓級
+.checkbox-group {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 16rpx;
+  padding: 8rpx 0;
+}
+
+.checkbox-item {
+  width: calc(50% - 8rpx);
+  margin-bottom: 8rpx;
+}
+
+// 闄勪欢鐩稿叧鏍峰紡
+.attachment-section {
+  width: 100%;
+}
+
+.attachment-grid {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 10px;
+  padding: 10px 0;
+}
+
+.attachment-item {
+  width: calc(25% - 10px);
+  box-sizing: border-box;
+  position: relative;
+}
+
+.upload-btn {
+  width: 80px;
+  height: 80px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: 1px dashed #ccc;
+  border-radius: 4px;
+  box-sizing: border-box;
+}
+
+.upload-icon {
+  font-size: 32px;
+  color: #0d867f;
+}
+
+// 闄勪欢鍒犻櫎鍥炬爣
+.delete-icon {
+  position: absolute;
+  top: -8px;
+  right: -8px;
+  width: 24px;
+  height: 24px;
+  background-color: rgba(255, 0, 0, 0.8);
+  color: white;
+  border-radius: 50%;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 10;
+}
+
+@media (max-width: 768px) {
+  .attachment-item {
+    width: calc(25% - 10px);
+  }
+}
+
+// 缂栬緫妯″紡涓嬭〃鍗曠粍浠舵牱寮忎紭鍖�
+:deep(.wd-form-item) {
+  margin-bottom: 8rpx;
+}
+
+:deep(.wd-input, .wd-select, .wd-radio-group, .wd-checkbox-group) {
+  width: 100%;
+  box-sizing: border-box;
+}
+
+:deep(.wd-form-item__label) {
+  &::after {
+    content: "*";
+    color: red;
+    margin-left: 4rpx;
+  }
+}
+
+// 淇閫夋嫨鍣ㄦ牱寮�
+:deep(.wd-select) {
+  width: 100%;
+}
+
+:deep(.wd-checkbox) {
+  margin-right: 0;
+}
+.conclusion-radio-group {
+  display: flex;
+  align-items: flex-start; // 鍨傜洿鏂瑰悜椤堕儴瀵归綈锛堜笂绉诲叧閿級
+  gap: 20rpx; // 閫夐」涔嬮棿鐨勯棿璺�
+}
+</style>

--
Gitblit v1.9.3