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/indexLS.vue |  756 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 389 insertions(+), 367 deletions(-)

diff --git a/src/pages/routingInspection/detail/indexLS.vue b/src/pages/routingInspection/detail/indexLS.vue
index 07bfd70..31b72e3 100644
--- a/src/pages/routingInspection/detail/indexLS.vue
+++ b/src/pages/routingInspection/detail/indexLS.vue
@@ -34,326 +34,311 @@
         淇濆瓨
       </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">
-    <div class="inspection-report">
-      <!-- 鍩烘湰淇℃伅妯″潡 -->
-      <wd-row>
-        <view style="margin: 10rpx">
-          <text class="title">{{ "鍩烘湰淇℃伅" }}</text>
-        </view>
-        <wd-col :span="24">
-          <wd-form-item label="鏃ユ湡" prop="recordDate">
-            {{ formatDate(detailData.fixedInfo?.recordDate) }}
-          </wd-form-item>
-          <wd-form-item label="鏈哄彴" prop="deviceModel">
-            {{ formatValue(detailData.fixedInfo?.deviceModel) }}
-          </wd-form-item>
-          <wd-form-item label="鐝" prop="workShift">
-            {{ formatValue(detailData.fixedInfo?.workShift) }}
-          </wd-form-item>
-          <wd-form-item label="鐝粍" prop="teamName">
-            {{ formatValue(detailData.fixedInfo?.teamName) }}
-          </wd-form-item>
-          <wd-form-item label="鍗曚笣瑙勬牸" prop="model">
-            {{ formatValue(detailData.fixedInfo?.model) }}
-          </wd-form-item>
-          <wd-form-item label="鐢熶骇杞存暟" prop="outputNumber">
-            {{ formatValue(detailData.fixedInfo?.outputNumber, "杞�") }}
-          </wd-form-item>
-          <wd-form-item label="鍨嬪彿" prop="poleModel">
-            {{ formatValue(detailData.fixedInfo?.poleModel) }}
-          </wd-form-item>
-          <wd-form-item label="鎵规" prop="poleNumber">
-            {{ formatValue(detailData.fixedInfo?.poleNumber) }}
-          </wd-form-item>
-          <wd-form-item label="璁板綍浜�" prop="createUserName">
-            {{ formatValue(detailData.fixedInfo?.createUserName) }}
-          </wd-form-item>
-          <wd-form-item label="棣栨鐩樺彿" prop="firstNo">
-            {{ formatValue(detailData.fixedInfo?.firstNo) }}
-          </wd-form-item>
-        </wd-col>
-      </wd-row>
+    <!-- 鍩烘湰淇℃伅妯″潡 -->
+    <wd-row>
+      <view style="margin: 10rpx">
+        <text class="title">{{ "鍩烘湰淇℃伅" }}</text>
+      </view>
+      <wd-col :span="24">
+        <wd-form-item label="鏃ユ湡" prop="recordDate">
+          {{ formatDate(detailData.fixedInfo?.recordDate) }}
+        </wd-form-item>
+        <wd-form-item label="鏈哄彴" prop="deviceModel">
+          {{ formatValue(detailData.fixedInfo?.deviceModel) }}
+        </wd-form-item>
+        <wd-form-item label="鐝" prop="workShift">
+          {{ formatValue(detailData.fixedInfo?.workShift) }}
+        </wd-form-item>
+        <wd-form-item label="鐝粍" prop="teamName">
+          {{ formatValue(detailData.fixedInfo?.teamName) }}
+        </wd-form-item>
+        <wd-form-item label="鍗曚笣瑙勬牸" prop="model">
+          {{ formatValue(detailData.fixedInfo?.model) }}
+        </wd-form-item>
+        <wd-form-item label="鐢熶骇杞存暟" prop="outputNumber">
+          {{ formatValue(detailData.fixedInfo?.outputNumber, "杞�") }}
+        </wd-form-item>
+        <wd-form-item label="鍨嬪彿" prop="poleModel">
+          {{ formatValue(detailData.fixedInfo?.poleModel) }}
+        </wd-form-item>
+        <wd-form-item label="鎵规" prop="poleNumber">
+          {{ formatValue(detailData.fixedInfo?.poleNumber) }}
+        </wd-form-item>
+        <wd-form-item label="璁板綍浜�" prop="createUserName">
+          {{ formatValue(detailData.fixedInfo?.createUserName) }}
+        </wd-form-item>
+        <wd-form-item label="棣栨鐩樺彿" prop="firstNo">
+          {{ formatValue(detailData.fixedInfo?.firstNo) }}
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
 
-      <!-- 鑷璁板綍璇︽儏妯″潡 -->
-      <wd-row>
-        <view style="margin: 10rpx">
-          <text class="title">{{ "鑷璁板綍璇︽儏" }}</text>
-        </view>
-        <wd-col :span="24">
-          <wd-form-item label="宸℃鍛�" prop="processInspectionUserName">
-            {{ detailData.processInspectionUserName || "-" }}
-          </wd-form-item>
-          <wd-form-item label="鐘舵��" prop="status">
-            <wd-tag custom-class="space" :type="getStatusType(detailData.status)">
-              {{ getStatusText(detailData.status) }}
-            </wd-tag>
-          </wd-form-item>
-        </wd-col>
-      </wd-row>
+    <!-- 鑷璁板綍璇︽儏妯″潡 -->
+    <wd-row>
+      <view style="margin: 10rpx">
+        <text class="title">{{ "鑷璁板綍璇︽儏" }}</text>
+      </view>
+      <wd-col :span="24">
+        <wd-form-item label="宸℃鍛�" prop="processInspectionUserName">
+          {{ detailData.processInspectionUserName || "-" }}
+        </wd-form-item>
+        <wd-form-item label="鐘舵��" prop="status">
+          <wd-tag custom-class="space" :type="getStatusType(detailData.status)">
+            {{ getStatusText(detailData.status) }}
+          </wd-tag>
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
 
-      <!-- 妫�楠岀粨鏋� -->
-      <wd-row>
-        <view style="margin: 10rpx">
-          <text class="title">{{ "妫�楠岀粨鏋�" }}</text>
-        </view>
-        <wd-col :span="24">
-          <wd-form-item label="鍗曚笣鐩村緞" prop="dia">
-            {{ formatValue(detailData.inspectionResult?.dia, "mm") || "-" }}
-          </wd-form-item>
+    <!-- 妫�楠岀粨鏋� -->
+    <wd-row>
+      <view style="margin: 10rpx">
+        <text class="title">{{ "妫�楠岀粨鏋�" }}</text>
+      </view>
+      <wd-col :span="24">
+        <wd-form-item label="鍗曚笣鐩村緞" prop="dia">
+          {{ formatValue(detailData.inspectionResult?.dia, "mm") || "-" }}
+        </wd-form-item>
 
-          <wd-form-item label="鏈�澶х洿寰�" prop="maxDia" required>
-            <template v-if="isEdit">
-              <wd-input v-model="formData.maxDia" placeholder="璇疯緭鍏ユ渶澶х洿寰�(mm)" type="number" />
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.maxDia, "mm") || "-" }}
-            </template>
-          </wd-form-item>
+        <wd-form-item label="鏈�澶х洿寰�" prop="maxDia" required>
+          <template v-if="isEdit">
+            <wd-input v-model="formData.maxDia" placeholder="璇疯緭鍏ユ渶澶х洿寰�(mm)" type="number" />
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.maxDia, "mm") || "-" }}
+          </template>
+        </wd-form-item>
 
-          <wd-form-item label="鏈�灏忕洿寰�" prop="minDia" required>
-            <template v-if="isEdit">
-              <wd-input v-model="formData.minDia" placeholder="璇疯緭鍏ユ渶灏忕洿寰�(mm)" type="number" />
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.minDia, "mm") || "-" }}
-            </template>
-          </wd-form-item>
+        <wd-form-item label="鏈�灏忕洿寰�" prop="minDia" required>
+          <template v-if="isEdit">
+            <wd-input v-model="formData.minDia" placeholder="璇疯緭鍏ユ渶灏忕洿寰�(mm)" type="number" />
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.minDia, "mm") || "-" }}
+          </template>
+        </wd-form-item>
 
-          <wd-form-item label="澶栬" prop="appearance" required>
-            <template v-if="isEdit">
-              <wd-checkbox-group
-                v-model="formData.appearance"
-                inline
+        <wd-form-item label="澶栬" prop="appearance" required>
+          <template v-if="isEdit">
+            <view style="display: flex; flex-wrap: wrap; gap: 10px">
+              <wd-checkbox
                 v-for="(opt, idx) in appearanceOptions"
                 :key="idx"
-                style="text-align: justify"
+                :value="opt.value"
+                :modelValue="formData.appearance?.includes(opt.value) || false"
+                @click="handleAppearanceClick(opt.value)"
+                style="width: 100px"
               >
-                <wd-checkbox :modelValue="opt.value" style="width: 100px">
-                  {{ opt.label }}
-                </wd-checkbox>
-              </wd-checkbox-group>
-            </template>
-            <template v-else>
-              {{
-                formatProductAppearance(detailData.inspectionResult?.appearance).join("銆�") || "-"
-              }}
-            </template>
-          </wd-form-item>
+                {{ opt.label }}
+              </wd-checkbox>
+            </view>
+          </template>
+          <template v-else>
+            {{ formatProductAppearance(formData.appearance) }}
+          </template>
+        </wd-form-item>
 
-          <wd-form-item label="鍗风粫绱у瘑" prop="windingTightness" required>
-            <template v-if="isEdit">
-              <wd-radio-group
-                v-model="formData.windingTightness"
-                inline
-                class="conclusion-radio-group"
-              >
-                <wd-radio
-                  v-for="(opt, idx) in sampleCompleteOptions"
-                  :key="idx"
-                  :value="opt.value"
-                  shape="dot"
-                >
-                  {{ opt.label }}
-                </wd-radio>
-              </wd-radio-group>
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.windingTightness) }}
-            </template>
-          </wd-form-item>
-
-          <wd-form-item label="鎺掑垪鏁撮綈" prop="arrangementNeatness" required>
-            <template v-if="isEdit">
-              <wd-radio-group
-                v-model="formData.arrangementNeatness"
-                inline
-                class="conclusion-radio-group"
-              >
-                <wd-radio
-                  v-for="(opt, idx) in sampleCompleteOptions"
-                  :key="idx"
-                  :value="opt.value"
-                  shape="dot"
-                >
-                  {{ opt.label }}
-                </wd-radio>
-              </wd-radio-group>
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.arrangementNeatness) }}
-            </template>
-          </wd-form-item>
-
-          <wd-form-item
-            label="澶栧眰閾濈嚎绂讳晶鏉胯竟缂樿窛绂�"
-            prop="aluminumWireDistance"
-            label-width="360rpx"
-            required
-          >
-            <template v-if="isEdit">
-              <wd-input
-                v-model="formData.aluminumWireDistance"
-                placeholder="璇疯緭鍏ヨ窛绂�(mm)"
-                type="number"
-              />
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.aluminumWireDistance, "mm") || "-" }}
-            </template>
-          </wd-form-item>
-
-          <wd-form-item
-            label="鎴愬搧妯″悗鎺ュご鎯呭喌"
-            prop="jointCondition"
-            label-width="280rpx"
-            required
-          >
-            <template v-if="isEdit">
-              <wd-radio-group
-                v-model="formData.jointCondition"
-                inline
-                class="conclusion-radio-group"
-              >
-                <wd-radio
-                  v-for="(opt, idx) in jointConditionOptions"
-                  :key="idx"
-                  :value="opt.value"
-                  shape="dot"
-                >
-                  {{ opt.label }}
-                </wd-radio>
-              </wd-radio-group>
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.jointCondition) || "-" }}
-            </template>
-          </wd-form-item>
-
-          <wd-form-item label="缁撹" prop="conclusion" required>
-            <template v-if="isEdit">
-              <wd-radio-group v-model="formData.conclusion" inline class="conclusion-radio-group">
-                <wd-radio
-                  v-for="(opt, idx) in conclusionOptions"
-                  :key="idx"
-                  :value="opt.value"
-                  shape="dot"
-                >
-                  {{ opt.label }}
-                </wd-radio>
-              </wd-radio-group>
-            </template>
-            <template v-else>
-              {{ formatValue(detailData.inspectionResult?.conclusion) || "-" }}
-            </template>
-          </wd-form-item>
-        </wd-col>
-      </wd-row>
-
-      <!-- 宸℃缁撴灉 -->
-      <wd-row v-if="detailData.processInspectionResult?.isFully">
-        <view style="margin: 10rpx">
-          <text class="title">{{ "宸℃缁撴灉" }}</text>
-        </view>
-        <wd-col :span="24">
-          <wd-form-item label="閾濇潌鍓嶃�佷腑銆佸熬鏍峰搧鏄惁榻愬叏" prop="isFully" required>
-            <template v-if="isEdit">
-              <wd-radio-group v-model="formData.isFully" inline class="conclusion-radio-group">
-                <wd-radio
-                  v-for="(opt, idx) in sampleCompleteOptions"
-                  :key="idx"
-                  :value="opt.value"
-                  shape="dot"
-                >
-                  {{ opt.label }}
-                </wd-radio>
-              </wd-radio-group>
-            </template>
-            <template v-else>
-              <wd-tag
-                custom-class="space"
-                :type="detailData.processInspectionResult?.isFully ? 'success' : 'danger'"
-              >
-                {{ detailData.processInspectionResult?.isFully ? "鏄�" : "鍚�" }}
-              </wd-tag>
-            </template>
-          </wd-form-item>
-        </wd-col>
-      </wd-row>
-
-      <!-- 闄勪欢妯″潡 -->
-      <wd-row class="attachment-section" v-if="detailData.files && detailData.files.length > 0">
-        <view style="margin: 10rpx">
-          <text class="title">{{ "闄勪欢" }}</text>
-        </view>
-        <view class="attachment-grid">
-          <wd-col v-for="(file, index) in detailData.files" :key="index" class="attachment-item">
-            <wd-img :width="80" :height="80" :src="file.url" @click="previewImage(file.url)">
-              <template #error><view class="error-wrap">鍔犺浇澶辫触</view></template>
-              <template #loading>
-                <view class="loading-wrap"><wd-loading /></view>
-              </template>
-            </wd-img>
-            <!-- <wd-icon
-              v-if="isEdit"
-              name="close-circle"
-              class="delete-icon"
-              @click.stop="deleteFile(index)"
-            ></wd-icon> -->
-          </wd-col>
-          <wd-col v-if="isEdit" class="attachment-item upload-btn">
-            <wd-upload
-              :multiple="true"
-              :max-count="5"
-              :before-upload="beforeUpload"
-              @success="handleUploadSuccess"
-              @fail="handleUploadFail"
-              accept="all"
+        <wd-form-item label="鍗风粫绱у瘑" prop="windingTightness" required>
+          <template v-if="isEdit">
+            <wd-radio-group
+              v-model="formData.windingTightness"
+              inline
+              class="conclusion-radio-group"
             >
-              <view class="upload-icon">+</view>
-            </wd-upload>
-          </wd-col>
-        </view>
-      </wd-row>
-    </div>
+              <wd-radio
+                v-for="(opt, idx) in sampleCompleteOptions"
+                :key="idx"
+                :value="opt.value"
+                shape="dot"
+              >
+                {{ opt.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.windingTightness) }}
+          </template>
+        </wd-form-item>
+
+        <wd-form-item label="鎺掑垪鏁撮綈" prop="arrangementNeatness" required>
+          <template v-if="isEdit">
+            <wd-radio-group
+              v-model="formData.arrangementNeatness"
+              inline
+              class="conclusion-radio-group"
+            >
+              <wd-radio
+                v-for="(opt, idx) in sampleCompleteOptions"
+                :key="idx"
+                :value="opt.value"
+                shape="dot"
+              >
+                {{ opt.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.arrangementNeatness) }}
+          </template>
+        </wd-form-item>
+
+        <wd-form-item
+          label="澶栧眰閾濈嚎绂讳晶鏉胯竟缂樿窛绂�"
+          prop="aluminumWireDistance"
+          label-width="360rpx"
+          required
+        >
+          <template v-if="isEdit">
+            <wd-input
+              v-model="formData.aluminumWireDistance"
+              placeholder="璇疯緭鍏ヨ窛绂�(mm)"
+              type="number"
+            />
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.aluminumWireDistance, "mm") || "-" }}
+          </template>
+        </wd-form-item>
+
+        <wd-form-item label="鎴愬搧妯″悗鎺ュご鎯呭喌" prop="jointCondition" label-width="280rpx" required>
+          <template v-if="isEdit">
+            <wd-radio-group v-model="formData.jointCondition" inline class="conclusion-radio-group">
+              <wd-radio
+                v-for="(opt, idx) in jointConditionOptions"
+                :key="idx"
+                :value="opt.value"
+                shape="dot"
+              >
+                {{ opt.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.jointCondition) || "-" }}
+          </template>
+        </wd-form-item>
+
+        <wd-form-item label="缁撹" prop="conclusion" required>
+          <template v-if="isEdit">
+            <wd-radio-group v-model="formData.conclusion" inline class="conclusion-radio-group">
+              <wd-radio
+                v-for="(opt, idx) in conclusionOptions"
+                :key="idx"
+                :value="opt.value"
+                shape="dot"
+              >
+                {{ opt.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </template>
+          <template v-else>
+            {{ formatValue(detailData.inspectionResult?.conclusion) || "-" }}
+          </template>
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
+
+    <!-- 宸℃缁撴灉 -->
+    <wd-row v-if="detailData.processInspectionResult?.isFully">
+      <view style="margin: 10rpx">
+        <text class="title">{{ "宸℃缁撴灉" }}</text>
+      </view>
+      <wd-col :span="24">
+        <wd-form-item label="閾濇潌鍓嶃�佷腑銆佸熬鏍峰搧鏄惁榻愬叏" prop="isFully" required>
+          <template v-if="isEdit">
+            <wd-radio-group v-model="formData.isFully" inline class="conclusion-radio-group">
+              <wd-radio
+                v-for="(opt, idx) in sampleCompleteOptions"
+                :key="idx"
+                :value="opt.value"
+                shape="dot"
+              >
+                {{ opt.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </template>
+          <template v-else>
+            <wd-tag
+              custom-class="space"
+              :type="detailData.processInspectionResult?.isFully ? 'success' : 'danger'"
+            >
+              {{ detailData.processInspectionResult?.isFully ? "鏄�" : "鍚�" }}
+            </wd-tag>
+          </template>
+        </wd-form-item>
+      </wd-col>
+    </wd-row>
+
+    <!-- 闄勪欢妯″潡 -->
+    <wd-row class="attachment-section" v-if="detailData.files && detailData.files.length > 0">
+      <view style="margin: 10rpx">
+        <text class="title">{{ "闄勪欢" }}</text>
+      </view>
+      <wd-col :span="24">
+        <AttachmentUpload
+          :detailData="detailData"
+          :isEdit="isEdit"
+          :deviceType="paramsType"
+          ref="attachmentRef"
+        />
+      </wd-col>
+    </wd-row>
     <wd-popup v-model="show" custom-style="border-radius:32rpx;" @close="handleClose">
       <div class="image-preview">
         <img :src="previewImageUrl" alt="棰勮鍥剧墖" style="width: 100%; height: auto" />
       </div>
     </wd-popup>
-    <Scan ref="scanRef" emitName="scan" />
     <wd-toast />
   </view>
 </template>
 
 <script setup lang="ts">
-import { ref, reactive } 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 paramsId = ref("");
+const paramsType = ref("");
 const detailData = ref<any>({});
 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 userStore = useUserStore();
+const userInfo: any = computed(() => userStore.userInfo);
+
+// 浣跨敤鎵爜绠$悊 composable锛堝叏灞�鐩戝惉鍣紝涓嶉殢椤甸潰鍒囨崲鍏抽棴锛�
+const {
+  deviceUid,
+  deviceModel: scannedDeviceModel,
+  loadFromCache,
+  enableListener,
+} = useScanCode("scanLS");
 
 // 琛ㄥ崟鏁版嵁
 const formData = reactive({
   dia: "",
   maxDia: "",
   minDia: "",
-  appearance: "",
+  appearance: [] as string[],
   windingTightness: "",
   arrangementNeatness: "",
   aluminumWireDistance: "",
@@ -389,11 +374,11 @@
     case 1:
       return "danger";
     case 2:
-      return "info";
+      return "primary";
     case 3:
       return "success";
     default:
-      return "info";
+      return "default";
   }
 };
 
@@ -413,8 +398,46 @@
 };
 
 // 鏍煎紡鍖栧伐鍏�
-const formatProductAppearance = (productAppearance: string) => {
-  return !productAppearance ? "-" : productAppearance;
+const formatProductAppearance = (productAppearance: string[]) => {
+  if (!productAppearance || !Array.isArray(productAppearance) || !productAppearance.length) {
+    return "-";
+  }
+  return productAppearance.join("銆�");
+};
+
+// 澶勭悊澶栬閫夋嫨鐨勪簰鏂ラ�昏緫
+const handleAppearanceClick = (value: string) => {
+  // 纭繚 appearance 鏄暟缁�
+  if (!Array.isArray(formData.appearance)) {
+    formData.appearance = [];
+  }
+
+  const currentValues = [...formData.appearance];
+  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.appearance = newSelection;
 };
 
 const formatValue = (value: any, unit?: string) => {
@@ -438,7 +461,12 @@
   formData.dia = inspectionResult.dia || "";
   formData.maxDia = inspectionResult.maxDia || "";
   formData.minDia = inspectionResult.minDia || "";
-  formData.appearance = inspectionResult.appearance || "";
+  // 纭繚 appearance 鏄暟缁�
+  formData.appearance = Array.isArray(inspectionResult.appearance)
+    ? inspectionResult.appearance
+    : inspectionResult.appearance
+      ? [inspectionResult.appearance]
+      : [];
   formData.windingTightness = inspectionResult.windingTightness || "";
   formData.arrangementNeatness = inspectionResult.arrangementNeatness || "";
   formData.aluminumWireDistance = inspectionResult.aluminumWireDistance || "";
@@ -452,6 +480,13 @@
   try {
     const response = await RoutingInspectionApi.getDrawInspectInfoById({ id });
     detailData.value = response.data;
+
+    // 濡傛灉宸℃鍛樹负绌猴紝榛樿璁剧疆涓哄綋鍓嶇櫥褰曠敤鎴�
+    if (!detailData.value.processInspectionUserName) {
+      detailData.value.processInspectionUserName =
+        userInfo.value?.nickName || userInfo.value?.userName || "";
+    }
+
     tempFiles.value = [];
     initFormData();
   } catch (error) {
@@ -462,6 +497,7 @@
 // 椤甸潰鍔犺浇
 onLoad((options: any) => {
   paramsId.value = options.id;
+  paramsType.value = options.deviceType;
   getDetailData(options.id, options.deviceType);
 });
 
@@ -482,7 +518,7 @@
   // 鏍¢獙
   if (!formData.maxDia) return uni.showToast({ title: "鏈�澶х洿寰勪负蹇呭~椤�", icon: "none" });
   if (!formData.minDia) return uni.showToast({ title: "鏈�灏忕洿寰勪负蹇呭~椤�", icon: "none" });
-  if (!formData.appearance) return uni.showToast({ title: "澶栬涓哄繀濉」", icon: "none" });
+  if (!formData.appearance.length) return uni.showToast({ title: "澶栬涓哄繀濉」", icon: "none" });
   if (!formData.windingTightness) return uni.showToast({ title: "鍗风粫绱у瘑涓哄繀濉」", icon: "none" });
   if (!formData.arrangementNeatness)
     return uni.showToast({ title: "鎺掑垪鏁撮綈涓哄繀濉」", icon: "none" });
@@ -492,7 +528,19 @@
     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" });
+
+  // 楠岃瘉鎵爜鏁版嵁锛堜粠缂撳瓨鎴栨柊鎵爜鑾峰彇锛�
+  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.drawPatrolCheckInspection({
@@ -510,12 +558,23 @@
         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);
+      // 璁剧疆鍒锋柊鏍囪锛屽憡璇夊垪琛ㄩ〉闇�瑕佸埛鏂�
+      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" });
     }
@@ -525,90 +584,41 @@
   }
 };
 
-// 闄勪欢涓婁紶鏍¢獙
-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 = () => {
   show.value = false;
 };
 
 const openScan = () => {
-  scanRef.value.triggerScan();
+  console.log("indexLS - 鐐瑰嚮鎵爜鎸夐挳锛堝叏灞�鎵爜妯″紡锛屾棤闇�鎵嬪姩瑙﹀彂锛�");
+  // 鍏ㄥ眬鎵爜妯″紡涓嬶紝纭欢鎵爜浼氳嚜鍔ㄨЕ鍙戯紝鏃犻渶鎵嬪姩璋冪敤
+  uni.showToast({
+    title: "璇蜂娇鐢ㄦ壂鐮佹灙鎵弿",
+    icon: "none",
+  });
 };
-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瀽澶辫触鐩存帴杩斿洖锛岄伩鍏嶅悗缁敊璇�
+
+// 椤甸潰鏄剧ず鏃剁殑澶勭悊
+onShow(() => {
+  console.log("========== indexLS - onShow 瑙﹀彂 ==========");
+  // 閲嶆柊鍚敤鐩戝惉鍣紙纭繚鐩戝惉鍣ㄦ湁鏁堬級
+  enableListener();
+  // 鍔犺浇缂撳瓨锛堟洿鏂癠I鏄剧ず锛�
+  const cachedData = loadFromCache();
+
+  // 濡傛灉娌℃湁缂撳瓨鏁版嵁锛屾彁绀虹敤鎴烽渶瑕佹壂鐮�
+  if (!cachedData || !cachedData.uid) {
+    console.log("鈿狅笍 鏈娴嬪埌鎵爜缂撳瓨锛岀敤鎴烽渶瑕佹壂鎻忚澶囦簩缁寸爜");
+    // 鍦ㄧ紪杈戞ā寮忎笅鎵嶆彁绀�
+    if (isEdit.value) {
+      setTimeout(() => {
+        uni.showToast({
+          title: "璇锋壂鎻忚澶囦簩缁寸爜鍚庡啀淇濆瓨",
+          icon: "none",
+          duration: 2000,
+        });
+      }, 500);
+    }
   }
-  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>
 
@@ -636,6 +646,18 @@
 
 .placeholder {
   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 {
@@ -758,4 +780,4 @@
   align-items: flex-start; // 鍨傜洿鏂瑰悜椤堕儴瀵归綈锛堜笂绉诲叧閿級
   gap: 20rpx; // 閫夐」涔嬮棿鐨勯棿璺�
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3