From 9f1324fb9e73e5b53ac67542227e63cdc0b505ba Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 09 七月 2026 15:44:53 +0800
Subject: [PATCH] 手机扫码改为PDA扫码

---
 src/pages/inspectionUpload/upload.vue |  116 ++++++++++++++++++++-------------------------------------
 1 files changed, 41 insertions(+), 75 deletions(-)

diff --git a/src/pages/inspectionUpload/upload.vue b/src/pages/inspectionUpload/upload.vue
index e85cba8..785601e 100644
--- a/src/pages/inspectionUpload/upload.vue
+++ b/src/pages/inspectionUpload/upload.vue
@@ -61,77 +61,18 @@
       <view class="section-card"
             v-if="hasException === true">
         <view class="section-title">宸℃鐓х墖/瑙嗛</view>
-        <!-- 褰撳墠鍒嗙被鐨勪笂浼犲尯鍩� -->
-        <view class="upload-area">
-          <view class="upload-buttons">
-            <u-button type="primary"
-                      @click="chooseMedia('image')"
-                      :loading="uploading"
-                      :disabled="beforeModelValue.length >= uploadConfig.limit"
-                      :customStyle="{ marginRight: '10px', flex: 1 }">
-              <u-icon name="camera"
-                      size="18"
-                      color="#fff"
-                      style="margin-right: 5px"></u-icon>
-              {{ uploading ? '涓婁紶涓�...' : '鎷嶇収' }}
-            </u-button>
-            <u-button type="success"
-                      @click="chooseMedia('video')"
-                      :loading="uploading"
-                      :disabled="beforeModelValue.length >= uploadConfig.limit"
-                      :customStyle="{ flex: 1 }">
-              <uni-icons type="videocam"
-                         size="18"
-                         color="#fff"
-                         style="margin-right: 5px"></uni-icons>
-              {{ uploading ? '涓婁紶涓�...' : '鎷嶈棰�' }}
-            </u-button>
-          </view>
-          <!-- 涓婁紶杩涘害 -->
-          <view v-if="uploading"
-                class="upload-progress">
-            <u-line-progress :percentage="uploadProgress"
-                             :showText="true"
-                             activeColor="#409eff"></u-line-progress>
-          </view>
-          <!-- 褰撳墠鍒嗙被鐨勬枃浠跺垪琛� -->
-          <view v-if="beforeModelValue.length > 0"
-                class="file-list">
-            <view v-for="(file, index) in beforeModelValue"
-                  :key="index"
-                  class="file-item">
-              <view class="file-preview-container">
-                <image v-if="file.type === 'image' || (file.type !== 'video' && !file.type)"
-                       :src="file.url || file.tempFilePath || file.path || file.downloadUrl"
-                       class="file-preview"
-                       mode="aspectFill" />
-                <view v-else-if="file.type === 'video'"
-                      class="video-preview">
-                  <uni-icons type="videocam"
-                             size="18"
-                             color="#fff"
-                             style="margin-right: 5px"></uni-icons>
-                  <text class="video-text">瑙嗛</text>
-                </view>
-                <!-- 鍒犻櫎鎸夐挳 -->
-                <view class="delete-btn"
-                      @click="removeFile(index)">
-                  <u-icon name="close"
-                          size="12"
-                          color="#fff"></u-icon>
-                </view>
-              </view>
-              <view class="file-info">
-                <text class="file-name">{{ file.bucketFilename || file.name || (file.type === 'image' ? '鍥剧墖' : '瑙嗛') }}</text>
-                <text class="file-size">{{ formatFileSize(file.size) }}</text>
-              </view>
-            </view>
-          </view>
-          <view v-if="beforeModelValue.length === 0"
-                class="empty-state">
-            <text>璇烽�夋嫨瑕佷笂浼犵殑鍥剧墖鎴栬棰�</text>
-          </view>
-        </view>
+        <!-- 浣跨敤 PDA 濯掍綋涓婁紶缁勪欢 -->
+        <PdaMediaUpload v-model="beforeModelValue"
+                        :action="uploadFileUrl"
+                        :limit="uploadConfig.limit"
+                        :fileSize="uploadConfig.fileSize"
+                        :formData="{ type: 10 }"
+                        :allowCamera="true"
+                        :allowVideo="true"
+                        @update:modelValue="handleFilesUpdate"
+                        @choose-media="handleChooseMedia"
+                        @uploading="uploading = $event"
+                        @progress="uploadProgress = $event" />
         <!-- 缁熻淇℃伅 -->
         <view class="upload-summary">
           <text class="summary-text">
@@ -166,8 +107,9 @@
 
 <script setup>
   import { ref, computed, onMounted } from "vue";
-  import { onLoad } from "@dcloudio/uni-app";
+  import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
   import PageHeader from "@/components/PageHeader.vue";
+  import PdaMediaUpload from "@/components/pda-media-upload/pda-media-upload.vue";
   import { uploadInspectionTask } from "@/api/inspectionManagement";
   import { getToken } from "@/utils/auth";
   import config from "@/config";
@@ -590,10 +532,34 @@
     });
   };
 
-  // 鍒犻櫎鏂囦欢
-  const removeFile = index => {
-    beforeModelValue.value.splice(index, 1);
+  // 鐩戝惉鏂囦欢鍒楄〃鍙樺寲锛堢粍浠跺唴閮ㄥ鐞嗗垹闄わ紝鐖剁粍浠跺彧鍚屾锛�
+  const handleFilesUpdate = files => {
+    beforeModelValue.value = files;
   };
+
+  // 鐩戝惉缁勪欢鐨� choose-media 浜嬩欢锛堢敤浜庡吋瀹规棫閫昏緫锛屾垨鑰呭湪杩欓噷娣诲姞鑷畾涔夋搷浣滐級
+  const handleChooseMedia = type => {
+    // 鍙互鍦ㄨ繖閲屾坊鍔犺嚜瀹氫箟鐨勫墠缃搷浣�
+    console.log("鐢ㄦ埛閫夋嫨涓婁紶绫诲瀷:", type);
+  };
+
+  // PDA 鎵爜鐩戝惉锛堝彲閫夛細濡傛灉闇�瑕侀�氳繃鎵爜娣诲姞鏌愪釜鏍囩鎴栦俊鎭紝鍦ㄨ繖閲屽鐞嗭級
+  const handlePdaScan = data => {
+    console.log("PDA 鎵爜缁撴灉:", data);
+    uni.showToast({
+      title: `鎵爜缁撴灉: ${data.code}`,
+      icon: "none",
+    });
+  };
+
+  onShow(() => {
+    // 椤甸潰鏄剧ず鏃讹紝鐩戝惉 PDA 鎵爜锛堝鏋滄湁闇�瑕佺殑璇濓級
+    uni.$on("scan_inspection", handlePdaScan);
+  });
+
+  onHide(() => {
+    uni.$off("scan_inspection");
+  });
 </script>
 
 <style scoped>

--
Gitblit v1.9.3