From b83e8417c341636a6da3a8eb7db7c151ef3c00cd Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 04 十一月 2025 15:34:40 +0800
Subject: [PATCH] 巡查菜单权限设置

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

diff --git a/src/pages/routingInspection/detail/indexJX.vue b/src/pages/routingInspection/detail/indexJX.vue
index 715d85d..d2de1c8 100644
--- a/src/pages/routingInspection/detail/indexJX.vue
+++ b/src/pages/routingInspection/detail/indexJX.vue
@@ -1,285 +1,867 @@
 <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-info">
+        <text class="scan-device-text">褰撳墠鎵爜鏈哄彴: {{ scannedDeviceModel || "鏈壂鐮�" }}</text>
+      </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="tensionSetting">
+          {{ formatValue(recordData.fixedInfo?.tensionSetting, "N/m") }}
+        </wd-form-item>
+        <!-- 缁炲埗澶栧緞锛堝彲缂栬緫锛� -->
+        <wd-form-item label="缁炲悎澶栧緞" prop="twistedOuterDiameter" required>
+          <template v-if="isEdit">
+            <wd-input
+              v-model="formData.twistedOuterDiameter"
+              placeholder="璇疯緭鍏ョ粸鍚堝寰勶紙mm锛�"
+              type="number"
+            />
+          </template>
+          <template v-else>
+            {{ formatValue(formData.twistedOuterDiameter, "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"
+              @input="updatePitchRatio(item)"
+            />
+          </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">
+            <view style="display: flex; flex-wrap: wrap; gap: 10px">
+              <wd-checkbox
+                v-for="(opt, idx) in appearanceOptions"
+                :key="idx"
+                :value="opt.value"
+                :modelValue="formData.productAppearance.includes(opt.value)"
+                @click="handleAppearanceClick(opt.value)"
+                style="width: 100px"
+              >
+                {{ opt.label }}
+              </wd-checkbox>
+            </view>
+          </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="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>
+            {{ formatValue(formData.isFully) }}
+          </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>
+    <wd-toast />
+  </view>
 </template>
 
 <script setup lang="ts">
-	import { onLoad } from "@dcloudio/uni-app";
-	import RoutingInspectionApi from "@/api/routingInspection/routingInspection";
+import { ref, reactive, computed, onUnmounted } from "vue";
+import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
+import RoutingInspectionApi from "@/api/routingInspection/routingInspection";
+import { useToast } from "wot-design-uni";
+import AttachmentUpload from "../upload.vue";
+import { useUserStore } from "@/store/modules/user";
+import { useScanCode } from "@/composables/useScanCode";
 
-	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 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 userStore = useUserStore();
+const userInfo: any = computed(() => userStore.userInfo);
 
-	// 鑾峰彇澶栬鏂囨湰
-	const getAppearanceText = (appearance : string[]) => {
-		if (!appearance || appearance.length === 0) return "-";
-		return appearance.join("銆�");
-	};
+// 浣跨敤鎵爜绠$悊 composable锛堝叏灞�鐩戝惉鍣紝涓嶉殢椤甸潰鍒囨崲鍏抽棴锛�
+const {
+  deviceUid,
+  deviceModel: scannedDeviceModel,
+  loadFromCache,
+  enableListener,
+} = useScanCode("scanJX");
 
-	// 鏍煎紡鍖栦骇鍝佸瑙傛樉绀�
-	const formatProductAppearance = (productAppearance : string[]) => {
-		if (!productAppearance || productAppearance.length === 0) return "-";
-		return productAppearance.join("銆�");
-	};
+const formData = reactive({
+  twistedOuterDiameter: "", // 缁炲埗澶栧緞
+  structureFormula: "", // 鎴愬搧缁撴瀯
+  structureItems: [], // 缁撴瀯鏍囧噯鍊煎拰瀹炴祴
+  inspectTwist: [], // 缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗
+  productAppearance: [] as string[], // 浜у搧澶栬锛堟敼涓烘暟缁勫瓨鍌ㄩ�変腑鍊硷級
+  conclusion: "", // 缁撹锛堟敼涓烘暟缁勫瓨鍌ㄩ�変腑鍊硷級
+  isFully: "", // 鏍峰搧鏄惁榻愬叏
+});
 
-	// 鏍煎紡鍖栨暟鍊兼樉绀�
-	const formatValue = (value : any, unit ?: string) => {
-		if (value === null || value === undefined || value === "") return "-";
-		return unit ? `${value}${unit}` : value;
-	};
+const twistDirectionOptions = [
+  { 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 appearanceOptions = [
+  { label: "鏃犲瑙傞棶棰�", value: "鏃犲瑙傞棶棰�" },
+  { label: "琛ㄩ潰鍒掍激", value: "琛ㄩ潰鍒掍激" },
+  { label: "鐩村緞涓嶅潎", value: "鐩村緞涓嶅潎" },
+  { label: "鍏朵粬缂洪櫡", value: "鍏朵粬缂洪櫡" },
+];
 
-	// 鏍煎紡鍖栫粨鏋勫�兼樉绀�
-	const formatStructureValue = (value1 : any, value2 : any) => {
-		const val1 = value1 || "-";
-		const val2 = value2 ? `${value2}mm` : "-";
-		return { count: val1, diameter: val2 };
-	};
+const conclusionOptions = [
+  { label: "鍚堟牸", value: "鍚堟牸" },
+  { label: "涓嶅悎鏍�", value: "涓嶅悎鏍�" },
+];
+const sampleCompleteOptions = [
+  { label: "鏄�", value: "鏄�" },
+  { label: "鍚�", value: "鍚�" },
+];
 
-	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);
-		}
-	};
+const initFormData = () => {
+  const structureResult = recordData.value.structureInfo?.structureRecordResult || {};
+  const inspectionResult = recordData.value.inspectionResult || {};
 
-	onLoad((options : any) => {
-		paramsId.value = options.id;
-		getDetailData(options.id, options.deviceType);
-	});
+  formData.twistedOuterDiameter =
+    recordData.value.structureInfo.structureRecordResult.twistedOuterDiameter || "";
+  formData.structureFormula = structureResult.inspectStructure?.structureFormula || "";
+  formData.isFully = inspectionResult.isFully || "";
+  formData.conclusion = structureResult.conclusion || "";
 
-	const previewImage = (url : string) => {
-		previewImageUrl.value = url;
-		show.value = true;
-	};
+  // 鍒濆鍖栦骇鍝佸瑙�
+  const appearance = Array.isArray(structureResult.productAppearance)
+    ? structureResult.productAppearance
+    : structureResult.productAppearance
+      ? [structureResult.productAppearance]
+      : [];
+  formData.productAppearance = appearance;
 
-	const handleClose = () => {
-		show.value = false;
-	};
+  formData.structureItems = JSON.parse(
+    JSON.stringify(structureResult.inspectStructure?.structureItems || [])
+  );
+  formData.inspectTwist = JSON.parse(JSON.stringify(structureResult.inspectTwist || []));
+
+  formData.inspectTwist.forEach((item: any) => {
+    if (!item.direction) item.direction = "";
+  });
+};
+
+const getDetailData = async (id: string, deviceType: string) => {
+  try {
+    const response = await RoutingInspectionApi.getStrandedInspectionStructureInfoById({ id });
+    recordData.value = response.data;
+    detailData.value = response.data.structureInfo;
+
+    // 濡傛灉璁板綍浜轰负绌猴紝榛樿璁剧疆涓哄綋鍓嶇櫥褰曠敤鎴�
+    if (recordData.value.structureInfo && !recordData.value.structureInfo.createUserName) {
+      recordData.value.structureInfo.createUserName =
+        userInfo.value?.nickName || userInfo.value?.userName || "";
+    }
+
+    console.log("detailData.value", detailData.value);
+    tempFiles.value = []; // 娓呯┖涓存椂鏂囦欢
+    initFormData(); // 鏁版嵁杩斿洖鍚庡垵濮嬪寲琛ㄥ崟
+    detailDataLoaded.value = true; // 鏁版嵁鍔犺浇瀹屾垚鍚庯紝娓叉煋瀛愮粍浠�
+    console.log("鐖剁粍浠�-鏁版嵁灏辩华鍚庢墦鍗�");
+  } catch (error) {
+    console.error("鑾峰彇璇︽儏澶辫触:", error);
+    uni.showToast({ title: "鍔犺浇澶辫触", icon: "error" });
+  }
+};
+
+// 椤甸潰鍔犺浇
+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.twistedOuterDiameter)
+    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.isFully) 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("淇濆瓨鍓嶆鏌� deviceUid:", deviceUid.value);
+  if (!deviceUid.value) {
+    return uni.showToast({
+      title: "璇峰厛鎵弿璁惧浜岀淮鐮�",
+      icon: "none",
+      duration: 2000,
+    });
+  }
+  const { newFiles } = attachmentRef.value.getSubmitFiles();
+  console.log("newFiles", newFiles);
+  const allFileIds = [...newFiles];
+  try {
+    const res = await RoutingInspectionApi.strandedPatrolCheckInspection({
+      deviceUid: deviceUid.value,
+      id: paramsId.value,
+      inspectionResult: {
+        twistedOuterDiameter: formData.twistedOuterDiameter,
+        structureFormula: formData.structureFormula,
+        structureItems: formData.structureItems,
+        inspectTwist: formData.inspectTwist,
+        productAppearance: formData.productAppearance,
+        conclusion: formData.conclusion,
+        isFully: formData.isFully,
+      },
+      result: {
+        isFully: formData.isFully,
+      },
+      processInspectionAttachmentList: allFileIds,
+    });
+
+    if (res.code === 200) {
+      // 璁剧疆鍒锋柊鏍囪锛屽憡璇夊垪琛ㄩ〉闇�瑕佸埛鏂�
+      uni.setStorageSync("needRefreshInspectionList", true);
+
+      uni.showToast({
+        title: "淇濆瓨鎴愬姛",
+        icon: "success",
+        duration: 1500,
+      });
+      // 寤惰繜杩斿洖鍒楄〃椤碉紝璁╃敤鎴风湅鍒版垚鍔熸彁绀�
+      setTimeout(() => {
+        uni.navigateBack({
+          delta: 1,
+        });
+      }, 1500);
+    } 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 "primary"; // 寰呭鏍�
+    case 3:
+      return "success"; // 閫氳繃
+    default:
+      return "default";
+  }
+};
+
+// 鐘舵�佹枃鏈槧灏�
+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 calculatePitchRatio = (pitch: string, dia: string) => {
+  // 濡傛灉pitch鎴杁ia涓虹┖锛屽垯杩斿洖"-"
+  if (!pitch || !dia) return "-";
+
+  // 灏唒itch鍜宒ia杞崲涓烘诞鐐规暟
+  const pitchNum = parseFloat(pitch);
+  const diaNum = parseFloat(dia);
+
+  // 濡傛灉pitchNum鎴杁iaNum鏄疦aN锛屾垨鑰卍iaNum涓�0锛屽垯杩斿洖"-"
+  if (isNaN(pitchNum) || isNaN(diaNum) || diaNum === 0) return "-";
+
+  // 璁$畻pitchNum鍜宒iaNum鐨勬瘮鍊硷紝骞朵繚鐣欎袱浣嶅皬鏁�
+  return (pitchNum / diaNum).toFixed(2);
+};
+
+// 鏇存柊鑺傚緞姣旓紙褰撹妭璺濆彉鍖栨椂鑷姩璁$畻锛�
+const updatePitchRatio = (item: any) => {
+  // 浣跨敤缁炲悎澶栧緞浣滀负鐩村緞鏉ヨ绠楄妭寰勬瘮
+  const dia = item.dia;
+  item.pitchRatio = calculatePitchRatio(item.pitch, dia);
+};
+
+// 澶勭悊浜у搧澶栬閫夋嫨鐨勪簰鏂ラ�昏緫
+const handleAppearanceClick = (value: string) => {
+  const currentValues = [...formData.productAppearance];
+  const isCurrentlyChecked = currentValues.includes(value);
+
+  let newSelection: string[] = [];
+
+  if (value === "鏃犲瑙傞棶棰�") {
+    if (isCurrentlyChecked) {
+      // 鍙栨秷閫変腑"鏃犲瑙傞棶棰�"
+      newSelection = [];
+    } else {
+      // 閫変腑"鏃犲瑙傞棶棰�"锛屾竻绌哄叾浠栭�夐」
+      newSelection = ["鏃犲瑙傞棶棰�"];
+    }
+  } else {
+    // 鐐瑰嚮鍏朵粬閫夐」
+    if (isCurrentlyChecked) {
+      // 鍙栨秷閫変腑璇ラ�夐」
+      newSelection = currentValues.filter((v) => v !== value);
+    } else {
+      // 閫変腑璇ラ�夐」锛岀Щ闄�"鏃犲瑙傞棶棰�"
+      const filteredValues = currentValues.filter((v) => v !== "鏃犲瑙傞棶棰�");
+      newSelection = [...filteredValues, value];
+    }
+  }
+
+  formData.productAppearance = newSelection;
+};
+
+const openScan = () => {
+  console.log("indexJX - 鐐瑰嚮鎵爜鎸夐挳锛堝叏灞�鎵爜妯″紡锛屾棤闇�鎵嬪姩瑙﹀彂锛�");
+  // 鍏ㄥ眬鎵爜妯″紡涓嬶紝纭欢鎵爜浼氳嚜鍔ㄨЕ鍙戯紝鏃犻渶鎵嬪姩璋冪敤
+  uni.showToast({
+    title: "璇蜂娇鐢ㄦ壂鐮佹灙鎵弿",
+    icon: "none",
+  });
+};
+
+// 椤甸潰鏄剧ず鏃剁殑澶勭悊
+onShow(() => {
+  console.log("========== indexJX - onShow 瑙﹀彂 ==========");
+  // 閲嶆柊鍚敤鐩戝惉鍣紙纭繚鐩戝惉鍣ㄦ湁鏁堬級
+  enableListener();
+  // 鍔犺浇缂撳瓨锛堟洿鏂癠I鏄剧ず锛�
+  const cachedData = loadFromCache();
+
+  // 濡傛灉娌℃湁缂撳瓨鏁版嵁锛屾彁绀虹敤鎴烽渶瑕佹壂鐮�
+  if (!cachedData || !cachedData.uid) {
+    console.log("鈿狅笍 鏈娴嬪埌鎵爜缂撳瓨锛岀敤鎴烽渶瑕佹壂鎻忚澶囦簩缁寸爜");
+    // 鍦ㄧ紪杈戞ā寮忎笅鎵嶆彁绀�
+    if (isEdit.value) {
+      setTimeout(() => {
+        uni.showToast({
+          title: "璇锋壂鎻忚澶囦簩缁寸爜鍚庡啀淇濆瓨",
+          icon: "none",
+          duration: 2000,
+        });
+      }, 500);
+    }
+  }
+});
 </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-info {
+  display: flex;
+  align-items: center;
+  margin-right: 10px;
 
-	.attachment-section {
-		width: 100%;
-	}
+  .scan-device-text {
+    font-size: 14px;
+    color: #0d867f;
+    font-weight: 500;
+  }
+}
 
-	.attachment-grid {
-		display: flex;
-		flex-wrap: wrap;
-		/* 瓒呭嚭鑷姩鎹㈣ */
-		gap: 10px;
-		/* 鍥剧墖涔嬮棿鐨勯棿璺� */
-		padding: 10px 0;
-	}
+.scan-wrapper {
+  width: 38px;
+  height: 38px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding: 6px;
+  flex-shrink: 0;
+}
 
-	.attachment-item {
-		width: calc(25% - 10px);
-		/* 姣忚4寮狅紝闂磋窛鐢眊ap鎺у埗锛岄渶璁$畻瀹藉害 */
-		box-sizing: border-box;
-	}
+.list {
+  padding: 12px;
+  padding-top: 84px;
+  background: #f3f9f8;
+  min-height: 100vh;
+  box-sizing: border-box;
+  overflow-y: auto;
+}
 
-	/* 閫傞厤灏忓睆骞曪紝鍙皟鏁存瘡琛屾暟閲忥紙濡傛瘡琛�2寮狅級 */
-	@media (max-width: 768px) {
-		.attachment-item {
-			width: calc(25% - 10px);
-		}
-	}
-</style>
\ No newline at end of file
+.title {
+  position: relative;
+  margin-left: 10px;
+  font-size: 16px;
+  font-weight: 500;
+  color: #0d867f;
+}
+
+.title::after {
+  position: absolute;
+  content: "";
+  top: 4px;
+  left: -10px;
+  width: 4px;
+  height: 16px;
+  background: #0d867f;
+  border-radius: 2px;
+}
+
+// 浜у搧澶栬鍜岀粨璁洪�夋嫨鍣ㄦ牱寮忥紙涓�琛屼袱涓級
+.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