From 6e763136fdf4469143ebbae0b717eb8e9b0ca954 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 03 十一月 2025 17:32:35 +0800
Subject: [PATCH] fix: 完成巡查

---
 src/pages/routingInspection/detail/indexJX.vue |  382 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 211 insertions(+), 171 deletions(-)

diff --git a/src/pages/routingInspection/detail/indexJX.vue b/src/pages/routingInspection/detail/indexJX.vue
index 46fdd5f..27572e5 100644
--- a/src/pages/routingInspection/detail/indexJX.vue
+++ b/src/pages/routingInspection/detail/indexJX.vue
@@ -34,6 +34,9 @@
         淇濆瓨
       </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>
@@ -70,20 +73,20 @@
         <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 label="寮犲姏璁剧疆" prop="tensionSetting">
+          {{ formatValue(recordData.fixedInfo?.tensionSetting, "N/m") }}
         </wd-form-item>
         <!-- 缁炲埗澶栧緞锛堝彲缂栬緫锛� -->
-        <wd-form-item label="缁炲埗澶栧緞" prop="twistDiameter" required>
+        <wd-form-item label="缁炲悎澶栧緞" prop="twistedOuterDiameter" required>
           <template v-if="isEdit">
             <wd-input
-              v-model="formData.twistDiameter"
-              placeholder="璇疯緭鍏ョ粸鍒跺寰勶紙mm锛�"
+              v-model="formData.twistedOuterDiameter"
+              placeholder="璇疯緭鍏ョ粸鍚堝寰勶紙mm锛�"
               type="number"
             />
           </template>
           <template v-else>
-            {{ formatValue(formData.twistDiameter, "mm") }}
+            {{ formatValue(formData.twistedOuterDiameter, "mm") }}
           </template>
         </wd-form-item>
       </wd-col>
@@ -138,6 +141,7 @@
         style="padding-bottom: 10px"
       >
         <wd-form-item
+          prop="structureItemsGroup"
           :label="formatValue(item.structureName)"
           label-width="400rpx"
           style="color: red"
@@ -184,6 +188,7 @@
           :label="formatValue(item.twistName)"
           label-width="400rpx"
           style="color: red"
+          prop="inspectTwistGroup"
           required
         ></wd-form-item>
         <wd-form-item label="缁炲悜" prop="direction" required>
@@ -203,7 +208,12 @@
         </wd-form-item>
         <wd-form-item label="鑺傝窛" prop="pitch" required>
           <template v-if="isEdit">
-            <wd-input v-model="item.pitch" placeholder="璇疯緭鍏ヨ妭璺濓紙mm锛�" type="number" />
+            <wd-input
+              v-model="item.pitch"
+              placeholder="璇疯緭鍏ヨ妭璺濓紙mm锛�"
+              type="number"
+              @input="updatePitchRatio(item)"
+            />
           </template>
           <template v-else>
             {{ formatValue(item.pitch, "mm") }}
@@ -223,17 +233,18 @@
       <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">
+            <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>
-            </wd-checkbox-group>
+            </view>
           </template>
           <template v-else>
             {{ formatProductAppearance(formData.productAppearance) }}
@@ -290,40 +301,15 @@
       <view style="margin: 10rpx">
         <text class="title">{{ "闄勪欢" }}</text>
       </view>
-      <view class="attachment-grid">
-        <!-- 宸蹭笂浼犻檮浠讹紙鍖呭惈鏂颁笂浼犵殑锛� -->
-        <wd-col v-for="(file, index) in allFiles" :key="file.id || 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(file.id || 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"
-          >
-            <view class="upload-icon">+</view>
-          </wd-upload>
-        </wd-col>
-      </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">
@@ -331,32 +317,45 @@
         <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 { ref, reactive, computed } from "vue";
-import { onLoad } from "@dcloudio/uni-app";
+import { ref, reactive, computed, onUnmounted } from "vue";
+import { onLoad, onShow, onHide } 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";
+import { useUserStore } from "@/store/modules/user";
+import { useScanCode } from "@/composables/useScanCode";
 
-// 鏍稿績鐘舵��
+const paramsType = ref("");
 const paramsId = ref("");
 const recordData = ref<any>({ structureInfo: { files: [], structureRecordResult: {} } });
 const show = ref(false);
 const previewImageUrl = ref("");
 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 userStore = useUserStore();
+const userInfo: any = computed(() => userStore.userInfo);
+
+// 浣跨敤鎵爜绠$悊 composable锛堝叏灞�鐩戝惉鍣紝涓嶉殢椤甸潰鍒囨崲鍏抽棴锛�
+const {
+  deviceUid,
+  deviceModel: scannedDeviceModel,
+  loadFromCache,
+  enableListener,
+} = useScanCode("scanJX");
+
 const formData = reactive({
-  twistDiameter: "", // 缁炲埗澶栧緞
+  twistedOuterDiameter: "", // 缁炲埗澶栧緞
   structureFormula: "", // 鎴愬搧缁撴瀯
   structureItems: [], // 缁撴瀯鏍囧噯鍊煎拰瀹炴祴
   inspectTwist: [], // 缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗
@@ -365,7 +364,6 @@
   sampleComplete: "", // 鏍峰搧鏄惁榻愬叏
 });
 
-// 閫夐」鏁版嵁
 const twistDirectionOptions = [
   { label: "宸﹀悜", value: "宸﹀悜" },
   { label: "鍙冲悜", value: "鍙冲悜" },
@@ -387,47 +385,51 @@
   { label: "鍚�", value: "鍚�" },
 ];
 
-// 鍚堝苟鍘熸湁闄勪欢鍜屾柊涓婁紶闄勪欢
-const allFiles = computed(() => {
-  return [...(recordData.value.structureInfo?.files || []), ...tempFiles.value];
-});
-
-// 鍒濆鍖栬〃鍗曟暟鎹紙鎺ュ彛鏁版嵁鍚屾鍒拌〃鍗曪級
 const initFormData = () => {
   const structureResult = recordData.value.structureInfo?.structureRecordResult || {};
   const inspectionResult = recordData.value.inspectionResult || {};
 
-  // 鍩虹鍙紪杈戝瓧娈�
-  formData.twistDiameter = inspectionResult.twistDiameter || "";
+  formData.twistedOuterDiameter =
+    recordData.value.structureInfo.structureRecordResult.twistedOuterDiameter || "";
   formData.structureFormula = structureResult.inspectStructure?.structureFormula || "";
   formData.sampleComplete = inspectionResult.sampleComplete || "";
   formData.conclusion = structureResult.conclusion || "";
-  // 淇浜у搧澶栬鍜岀粨璁虹殑鏁版嵁鏍煎紡
-  formData.productAppearance = Array.isArray(structureResult.productAppearance)
+
+  // 鍒濆鍖栦骇鍝佸瑙�
+  const appearance = Array.isArray(structureResult.productAppearance)
     ? structureResult.productAppearance
     : structureResult.productAppearance
-    ? [structureResult.productAppearance]
-    : [];
+      ? [structureResult.productAppearance]
+      : [];
+  formData.productAppearance = appearance;
 
-  // 寰幆绫诲瓧娈碉紙娣辨嫹璐濋伩鍏嶅師鏁版嵁姹℃煋锛�
   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" });
@@ -436,8 +438,14 @@
 
 // 椤甸潰鍔犺浇
 onLoad((options: any) => {
-  paramsId.value = options.id;
-  getDetailData(options.id, options.deviceType);
+  try {
+    paramsId.value = options.id;
+    paramsType.value = options.deviceType;
+    getDetailData(options.id, options.deviceType);
+  } catch (error) {
+    console.error("鑾峰彇璇︽儏澶辫触:", error);
+    uni.showToast({ title: "鍔犺浇澶辫触", icon: "error" });
+  }
 });
 
 // 缂栬緫妯″紡鍒囨崲
@@ -448,15 +456,16 @@
 // 鍙栨秷缂栬緫锛堥噸缃〃鍗曪級
 const close = () => {
   isEdit.value = false;
-  tempFiles.value = []; // 鍙栨秷鏃舵竻绌轰复鏃朵笂浼犵殑鏂囦欢
-  initFormData(); // 鎭㈠鍘熷鏁版嵁
+  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.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" });
@@ -480,15 +489,24 @@
     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" });
-  // 4. 鎻愪氦鏁版嵁鍒版帴鍙�
+  // 楠岃瘉鎵爜鏁版嵁锛堜粠缂撳瓨鎴栨柊鎵爜鑾峰彇锛�
+  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,
       result: {
-        twistDiameter: formData.twistDiameter,
+        twistedOuterDiameter: formData.twistedOuterDiameter,
         structureFormula: formData.structureFormula,
         structureItems: formData.structureItems,
         inspectTwist: formData.inspectTwist,
@@ -499,13 +517,24 @@
       inspectionResult: {
         sampleComplete: formData.sampleComplete,
       },
-      processInspectionAttachmentList: tempFiles.value.map((f) => f.url), // 鏂颁笂浼犵殑闄勪欢
+      processInspectionAttachmentList: allFileIds,
     });
 
     if (res.code === 200) {
-      uni.showToast({ title: "淇濆瓨鎴愬姛", icon: "success" });
-      isEdit.value = false;
-      getDetailData(paramsId.value, recordData.value.deviceType); // 鍒锋柊鏁版嵁
+      // 璁剧疆鍒锋柊鏍囪锛屽憡璇夊垪琛ㄩ〉闇�瑕佸埛鏂�
+      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" });
     }
@@ -513,61 +542,6 @@
     console.error("淇濆瓨澶辫触:", e);
     uni.showModal({ title: e.message || "淇濆瓨澶辫触", icon: "error" });
   }
-};
-
-// 闄勪欢涓婁紶鍓嶇疆鏍¢獙
-const beforeUpload = (file: any) => {
-  // 闄愬埗鍥剧墖澶у皬涓嶈秴杩�2M
-  const maxSize = 2 * 1024 * 1024;
-  if (file.size > maxSize) {
-    uni.showToast({ title: "鍥剧墖澶у皬涓嶈兘瓒呰繃2M", icon: "none" });
-    return false;
-  }
-  return true;
-};
-
-// 闄勪欢涓婁紶鎴愬姛鍥炶皟
-const handleUploadSuccess = (res: any) => {
-  // 鍋囪鎺ュ彛杩斿洖鏍煎紡: { url: 'xxx', id: 'xxx' }
-  if (Array.isArray(res)) {
-    tempFiles.value = [
-      ...tempFiles.value,
-      ...res.map((file) => ({
-        ...file,
-        id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, // 鐢熸垚涓存椂ID
-      })),
-    ];
-  } 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 = (id: string | number) => {
-  // 鍒犻櫎涓存椂鏂囦欢
-  tempFiles.value = tempFiles.value.filter((file) => file.id !== id);
-
-  // 濡傛灉鏄師鏈夋枃浠讹紝闇�瑕佹爣璁板垹闄わ紙瀹為檯椤圭洰涓彲鑳介渶瑕佹帴鍙d氦浜掞級
-  if (typeof id !== "string" || !id.startsWith("temp-")) {
-    // 杩欓噷鍙互瀹炵幇鍒犻櫎鍘熸湁鏂囦欢鐨勯�昏緫
-    recordData.value.structureInfo.files = recordData.value.structureInfo.files.filter(
-      (file: any, index: number) => index !== id
-    );
-  }
-};
-
-// 鍥剧墖棰勮
-const previewImage = (url: string) => {
-  previewImageUrl.value = url;
-  show.value = true;
 };
 
 const handleClose = () => {
@@ -582,11 +556,11 @@
     case 1:
       return "danger"; // 宸查┏鍥�
     case 2:
-      return "info"; // 寰呭鏍�
+      return "primary"; // 寰呭鏍�
     case 3:
       return "success"; // 閫氳繃
     default:
-      return "info";
+      return "default";
   }
 };
 
@@ -628,36 +602,90 @@
   });
 };
 
-const openScan = () => {
-  scanRef.value.triggerScan();
+// 璁$畻鑺傚緞姣�
+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 getScanCode = (params: any) => {
-  console.log("瀹屾暣鍙傛暟锛�", params);
-  let codeObj = {};
-  try {
-    codeObj = JSON.parse(params.code);
-  } catch (err) {
-    console.error("JSON瑙f瀽澶辫触锛�", err);
-    toast.error("鎵爜鏁版嵁寮傚父");
-    return; // 瑙f瀽澶辫触鐩存帴杩斿洖锛岄伩鍏嶅悗缁敊璇�
+
+// 鏇存柊鑺傚緞姣旓紙褰撹妭璺濆彉鍖栨椂鑷姩璁$畻锛�
+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];
+    }
   }
-  deviceUid.value = codeObj?.uid;
-  toast.success("鎵爜鎴愬姛");
+
+  formData.productAppearance = newSelection;
 };
-// 纭繚鍏堢Щ闄ゅ啀娣诲姞鐩戝惉
-const setupScanListener = () => {
-  uni.$off("scan", getScanCode); // 鍏堢Щ闄ゆ棫鐨�
-  uni.$on("scan", getScanCode); // 鍐嶆坊鍔犳柊鐨�
+
+const openScan = () => {
+  console.log("indexJX - 鐐瑰嚮鎵爜鎸夐挳锛堝叏灞�鎵爜妯″紡锛屾棤闇�鎵嬪姩瑙﹀彂锛�");
+  // 鍏ㄥ眬鎵爜妯″紡涓嬶紝纭欢鎵爜浼氳嚜鍔ㄨЕ鍙戯紝鏃犻渶鎵嬪姩璋冪敤
+  uni.showToast({
+    title: "璇蜂娇鐢ㄦ壂鐮佹灙鎵弿",
+    icon: "none",
+  });
 };
-onUnmounted(() => {
-  // 寮�鍚箍鎾洃鍚簨浠�
-  uni.$off("scan", getScanCode);
-  console.log("绂诲紑1");
-});
-onMounted(() => {
-  // 寮�鍚箍鎾洃鍚簨浠�
-  setupScanListener();
-  console.log("鏄剧ず1");
+
+// 椤甸潰鏄剧ず鏃剁殑澶勭悊
+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>
 
@@ -687,6 +715,18 @@
   flex: 1;
 }
 
+.scan-info {
+  display: flex;
+  align-items: center;
+  margin-right: 10px;
+
+  .scan-device-text {
+    font-size: 14px;
+    color: #0d867f;
+    font-weight: 500;
+  }
+}
+
 .scan-wrapper {
   width: 38px;
   height: 38px;

--
Gitblit v1.9.3