From c52a0824baaa86a719da04fba3ff65fc48a70422 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 19 三月 2026 17:37:05 +0800
Subject: [PATCH] fix: 入库数量必填

---
 src/pages/inspectionUpload/index.vue |  215 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 163 insertions(+), 52 deletions(-)

diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index 73749a7..c0293dd 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -9,7 +9,8 @@
       <view class="task-list">
         <view v-for="(item, index) in taskTableData"
               :key="index"
-              class="task-item">
+              class="task-item"
+              :class="{ 'uninspected': item.fileStatus == 1 }">
           <view class="task-header">
             <view class="task-info">
               <text class="task-name">{{ item.taskName }}</text>
@@ -18,14 +19,15 @@
             <view class="task-actions">
               <u-button type="primary"
                         size="small"
-                        @click.stop="startScanForTask(item)"
+                        v-if="item.fileStatus!=2"
+                        @click.stop="startScanForTask1(item)"
                         :customStyle="{
                 borderRadius: '15px',
                 height: '30px',
                 fontSize: '12px',
                 marginRight: '8px'
               }">
-                鎵爜涓婁紶
+                宸℃涓婁紶
               </u-button>
               <u-button type="success"
                         size="small"
@@ -42,7 +44,7 @@
           <view class="task-details">
             <view class="detail-item">
               <text class="detail-label">浠诲姟ID</text>
-              <text class="detail-value">{{ item.taskId || item.id }}</text>
+              <text class="detail-value">{{ item.id }}</text>
             </view>
             <view class="detail-item">
               <text class="detail-label">澶囨敞</text>
@@ -65,11 +67,11 @@
                          type="success"
                          inverted></uni-tag>
                 <uni-tag v-else-if="item.fileStatus==1"
-                         text="宸℃涓�"
+                         text="瓒呮湡"
                          size="small"
-                         type="primary"
+                         type="error"
                          inverted></uni-tag>
-                <uni-tag v-else=""
+                <uni-tag v-else
                          text="鏈贰妫�"
                          size="small"
                          type="warning"
@@ -98,7 +100,7 @@
           </view>
           <view class="upload-popup-body">
             <!-- 鍒嗙被鏍囩椤� -->
-            <view class="upload-tabs">
+            <!-- <view class="upload-tabs">
               <view class="tab-item"
                     :class="{ active: currentUploadType === 'before' }"
                     @click="switchUploadType('before')">
@@ -114,7 +116,7 @@
                     @click="switchUploadType('issue')">
                 鐢熶骇鍚�
               </view>
-            </view>
+            </view> -->
             <!-- 寮傚父鐘舵�侀�夋嫨 -->
             <view class="exception-section">
               <text class="section-title">鏄惁瀛樺湪寮傚父锛�</text>
@@ -151,7 +153,7 @@
                           style="margin-right: 5px;"></u-icon>
                   {{ uploading ? '涓婁紶涓�...' : '鎷嶇収' }}
                 </u-button>
-                <u-button type="success"
+                <!-- <u-button type="success"
                           @click="chooseMedia('video')"
                           :loading="uploading"
                           :disabled="getCurrentFiles().length >= uploadConfig.limit"
@@ -162,7 +164,7 @@
                              color="#fff"
                              style="margin-right: 5px;"></uni-icons>
                   {{ uploading ? '涓婁紶涓�...' : '鎷嶈棰�' }}
-                </u-button>
+                </u-button> -->
               </view>
               <!-- 涓婁紶杩涘害 -->
               <view v-if="uploading"
@@ -178,6 +180,13 @@
                       :key="index"
                       class="file-item">
                   <view class="file-preview-container">
+                    <!-- 鍒犻櫎鎸夐挳 -->
+                    <view class="delete-btn"
+                          @click="removeFile(index)">
+                      <u-icon name="close"
+                              size="12"
+                              color="#fff"></u-icon>
+                    </view>
                     <image v-if="file.type === 'image' || (file.type !== 'video' && !file.type)"
                            :src="file.url || file.tempFilePath || file.path || file.downloadUrl"
                            class="file-preview"
@@ -191,13 +200,6 @@
                                  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' ? '鍥剧墖' : '瑙嗛')
@@ -208,16 +210,16 @@
               </view>
               <view v-if="getCurrentFiles().length === 0"
                     class="empty-state">
-                <text>璇烽�夋嫨瑕佷笂浼犵殑{{ getUploadTypeText() }}鍥剧墖鎴栬棰�</text>
+                <text>璇烽�夋嫨瑕佷笂浼犵殑{{ getUploadTypeText() }}鍥剧墖</text>
               </view>
               <!-- 缁熻淇℃伅 -->
-              <view class="upload-summary">
+              <!-- <view class="upload-summary">
                 <text class="summary-text">
                   鐢熶骇鍓�: {{ beforeModelValue.length }}涓枃浠� |
                   鐢熶骇涓�: {{ afterModelValue.length }}涓枃浠� |
                   鐢熶骇鍚�: {{ issueModelValue.length }}涓枃浠�
                 </text>
-              </view>
+              </view> -->
             </view>
           </view>
           <view class="upload-popup-footer">
@@ -253,7 +255,7 @@
           </view>
           <view class="attachment-popup-body">
             <!-- 鍒嗙被鏍囩椤� -->
-            <view class="attachment-tabs">
+            <!-- <view class="attachment-tabs">
               <view class="tab-item"
                     :class="{ active: currentViewType === 'before' }"
                     @click="switchViewType('before')">
@@ -269,7 +271,7 @@
                     @click="switchViewType('issue')">
                 鐢熶骇鍚� ({{ getAttachmentsByType(2).length }})
               </view>
-            </view>
+            </view> -->
             <!-- 褰撳墠鍒嗙被鐨勯檮浠跺垪琛� -->
             <view class="attachment-content">
               <view v-if="getCurrentViewAttachments().length > 0"
@@ -279,8 +281,9 @@
                       class="attachment-item"
                       @click="previewAttachment(file)">
                   <view class="attachment-preview-container">
+                    <!-- {{formatFileUrl(file.url || file.downloadUrl)}} -->
                     <image v-if="file.type === 'image' || isImageFile(file)"
-                           :src="file.url || file.downloadUrl"
+                           :src="formatFileUrl(file.url || file.downloadUrl)"
                            class="attachment-preview"
                            mode="aspectFill" />
                     <view v-else
@@ -408,7 +411,7 @@
 
   // 璁$畻涓婁紶URL
   const uploadFileUrl = computed(() => {
-    const baseUrl = "http://114.132.189.42:9030";
+    const baseUrl = config.baseUrl;
 
     return baseUrl + uploadConfig.action;
   });
@@ -555,17 +558,71 @@
   };
 
   const getFileStatus = record => {
-    let _beforeProduction =
-      record.beforeProduction && record.beforeProduction.length;
-    let _afterProduction =
-      record.afterProduction && record.afterProduction.length;
-    let _productionIssues =
-      record.productionIssues && record.productionIssues.length;
-    if (_beforeProduction && _afterProduction && _productionIssues) {
+    // let _beforeProduction =
+    //   record.beforeProduction && record.beforeProduction.length;
+    // let _afterProduction =
+    //   record.afterProduction && record.afterProduction.length;
+    // let _productionIssues =
+    //   record.productionIssues && record.productionIssues.length;
+    // if (_beforeProduction && _afterProduction && _productionIssues) {
+    //   return 2;
+    // } else if (_beforeProduction || _afterProduction || _productionIssues) {
+    //   return 1;
+    // } else {
+    //   return 0;
+    // }
+    // let _beforeProduction =
+    //   record.beforeProduction && record.beforeProduction.length;
+    if (record.takePhone) {
+      if (record.commonFileListBefore && record.commonFileListBefore.length) {
+        return 2;
+      }
+      if (record.frequencyType == "DAILY") {
+        if (Number(record.inspectionDeadline) && record.createTime) {
+          // 璁$畻鏃堕棿宸紙灏忔椂锛�
+          const now = new Date().getTime();
+          const createTime = new Date(record.createTime).getTime();
+          const hoursDiff = (now - createTime) / (1000 * 60 * 60);
+          if (hoursDiff > Number(record.inspectionDeadline)) {
+            return 1;
+          }
+        }
+      } else {
+        if (Number(record.inspectionDeadline) && record.createTime) {
+          // 璁$畻鏃堕棿宸紙澶╋級
+          const now = new Date().getTime();
+          const createTime = new Date(record.createTime).getTime();
+          const daysDiff = (now - createTime) / (1000 * 60 * 60 * 24);
+          if (daysDiff > Number(record.inspectionDeadline)) {
+            return 1;
+          }
+        }
+      }
+      return 0;
+    } else if (record.inspectionSubmitted) {
       return 2;
-    } else if (_beforeProduction || _afterProduction || _productionIssues) {
-      return 1;
     } else {
+      if (record.frequencyType == "DAILY") {
+        if (Number(record.inspectionDeadline) && record.createTime) {
+          // 璁$畻鏃堕棿宸紙灏忔椂锛�
+          const now = new Date().getTime();
+          const createTime = new Date(record.createTime).getTime();
+          const hoursDiff = (now - createTime) / (1000 * 60 * 60);
+          if (hoursDiff > Number(record.inspectionDeadline)) {
+            return 1;
+          }
+        }
+      } else {
+        if (Number(record.inspectionDeadline) && record.createTime) {
+          // 璁$畻鏃堕棿宸紙澶╋級
+          const now = new Date().getTime();
+          const createTime = new Date(record.createTime).getTime();
+          const daysDiff = (now - createTime) / (1000 * 60 * 60 * 24);
+          if (daysDiff > Number(record.inspectionDeadline)) {
+            return 1;
+          }
+        }
+      }
       return 0;
     }
   };
@@ -620,8 +677,7 @@
         return;
       }
 
-      const currentTaskId =
-        currentScanningTask.value?.taskId || currentScanningTask.value?.id;
+      const currentTaskId = currentScanningTask.value?.id;
       if (!currentTaskId) {
         uni.showToast({ title: "浠诲姟淇℃伅缂哄け", icon: "error" });
         return;
@@ -648,7 +704,6 @@
     if (task) {
       infoData.value = {
         ...task,
-        taskId: task.taskId || task.id,
         storageBlobDTO: [], // 鍒濆鍖栨枃浠跺垪琛�
       };
     }
@@ -662,7 +717,22 @@
     // 鏄剧ず涓婁紶寮圭獥
     showUploadDialog.value = true;
   };
+  const startScanForTask1 = async task => {
+    currentScanningTask.value = task;
+    if (task) {
+      infoData.value = {
+        ...task,
+        storageBlobDTO: [], // 鍒濆鍖栨枃浠跺垪琛�
+      };
+    }
 
+    // 璁剧疆涓婁紶鐘舵�佺被鍨嬶紙鍙互鏍规嵁浠诲姟绫诲瀷璁剧疆涓嶅悓鐨勭姸鎬侊級
+    uploadStatusType.value = 0; // 榛樿鐘舵��
+
+    // 娓呯┖涔嬪墠鐨勬枃浠�
+    uploadFiles.value = [];
+    showUploadDialog.value = true;
+  };
   // 鍏抽棴涓婁紶寮圭獥
   const closeUploadDialog = () => {
     showUploadDialog.value = false;
@@ -724,7 +794,7 @@
     try {
       // 瀛樺偍褰撳墠浠诲姟淇℃伅鍒版湰鍦板瓨鍌紝渚涙姤淇〉闈娇鐢�
       const taskInfo = {
-        taskId: infoData.value?.taskId || infoData.value?.id,
+        id: infoData.value?.id,
         taskName: infoData.value?.taskName,
         inspectionLocation: infoData.value?.inspectionLocation,
         inspector: infoData.value?.inspector,
@@ -756,6 +826,11 @@
 
   // 鎻愪氦涓婁紶
   const submitUpload = async () => {
+    // console.log("鎻愪氦涓婁紶鏁版嵁:", {
+    //   before: beforeModelValue.value,
+    //   after: afterModelValue.value,
+    //   issue: issueModelValue.value,
+    // });
     try {
       // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗紓甯哥姸鎬�
       if (hasException.value === null) {
@@ -771,12 +846,14 @@
         beforeModelValue.value.length +
         afterModelValue.value.length +
         issueModelValue.value.length;
-      if (totalFiles === 0) {
-        uni.showToast({
-          title: "璇峰厛涓婁紶鏂囦欢",
-          icon: "none",
-        });
-        return;
+      if (currentScanningTask.value.takePhone) {
+        if (totalFiles === 0) {
+          uni.showToast({
+            title: "璇峰厛涓婁紶鏂囦欢",
+            icon: "none",
+          });
+          return;
+        }
       }
 
       // 鏄剧ず鎻愪氦涓殑鍔犺浇鎻愮ず
@@ -786,12 +863,15 @@
       let arr = [];
       if (beforeModelValue.value.length > 0) {
         arr.push(...beforeModelValue.value);
+        infoData.value.beforeModelValue = beforeModelValue.value;
       }
       if (afterModelValue.value.length > 0) {
         arr.push(...afterModelValue.value);
+        infoData.value.afterModelValue = afterModelValue.value;
       }
       if (issueModelValue.value.length > 0) {
         arr.push(...issueModelValue.value);
+        infoData.value.issueModelValue = issueModelValue.value;
       }
 
       // 浼犵粰鍚庣鐨勪复鏃舵枃浠禝D鍒楄〃锛坱empFileIds锛�
@@ -808,7 +888,10 @@
       // 娣诲姞寮傚父鐘舵�佷俊鎭�
       infoData.value.hasException = hasException.value;
       infoData.value.tempFileIds = tempFileIds;
-      const result = await uploadInspectionTask({ ...infoData.value });
+      const result = await uploadInspectionTask({
+        ...infoData.value,
+        inspectionSubmitted: true,
+      });
 
       // 妫�鏌ユ彁浜ょ粨鏋�
       if (result && (result.code === 200 || result.success)) {
@@ -971,7 +1054,7 @@
   };
 
   // 鏂囦欢璁块棶鍩虹鍩燂紙鍚庣瑕佹眰鍓嶇紑锛�
-  const filePreviewBase = "http://114.132.189.42:9098";
+  const filePreviewBase = config.fileUrl;
 
   // 灏嗗悗绔繑鍥炵殑鏂囦欢鍦板潃瑙勮寖鎴愬彲璁块棶URL
   // 鍏煎鍦烘櫙锛�
@@ -1061,7 +1144,9 @@
         count: Math.min(remaining, 1),
         mediaType: [type || "image"],
         sizeType: ["compressed", "original"],
-        sourceType: ["camera"],
+        sourceType: currentScanningTask.value?.takeAlbum
+          ? ["camera", "album"]
+          : ["camera"], // 鏄惁鍏佽鐩稿唽涓婁紶
         success: res => {
           try {
             const files = res?.tempFiles || [];
@@ -1081,6 +1166,8 @@
                 createTime: Date.now(),
                 uid: Date.now() + Math.random() + idx,
               };
+
+              console.log("chooseMedia 鎴愬姛鑾峰彇鏂囦欢:", file);
               handleBeforeUpload(file);
             });
           } catch (e) {
@@ -1103,7 +1190,7 @@
       uni.chooseImage({
         count: 1,
         sizeType: ["compressed", "original"],
-        sourceType: ["camera"],
+        sourceType: ["camera", "album"],
         success: res => {
           const tempFilePath = res?.tempFilePaths?.[0];
           const tempFile = res?.tempFiles?.[0] || {};
@@ -1136,7 +1223,7 @@
       count: 1,
       mediaType: ["image", "video"],
       sizeType: ["compressed", "original"],
-      sourceType: ["camera"],
+      sourceType: ["camera", "album"],
       success: res => {
         try {
           if (!res.tempFiles || res.tempFiles.length === 0) {
@@ -1480,7 +1567,7 @@
     };
 
     uploadList.value.push(fileData);
-
+    console.log("娣诲姞鍒板垎绫诲墠:", fileData);
     // 绔嬪嵆娣诲姞鍒板搴旂殑鍒嗙被锛屼笉绛夊緟鎵�鏈夋枃浠朵笂浼犲畬鎴�
     switch (currentUploadType.value) {
       case "before":
@@ -1503,7 +1590,19 @@
   const uploadedSuccessfully = () => {
     // 姝ゅ嚱鏁板凡涓嶅啀浣跨敤锛屾枃浠朵笂浼犳垚鍔熷悗绔嬪嵆娣诲姞鍒板搴斿垎绫�
   };
-
+  // 鏍煎紡鍖栨枃浠禪RL
+  const formatFileUrl = url => {
+    if (!url) return "";
+    if (url.startsWith("http://") || url.startsWith("https://")) {
+      return url;
+    }
+    // const uploadsIndex = url.indexOf("uploads");
+    // if (uploadsIndex !== -1) {
+    //   const relativePath = url.substring(uploadsIndex);
+    //   return `${config.fileUrl}/${relativePath}`;
+    // }
+    return `${config.fileUrl}/${url}`;
+  };
   // 鏍煎紡鍖栨枃浠跺ぇ灏�
   const formatFileSize = size => {
     if (!size) return "";
@@ -1535,6 +1634,17 @@
     padding: 15px;
     box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
     transition: all 0.3s ease;
+  }
+
+  .task-item.uninspected {
+    border: 1px solid #f56c6cb3;
+    background-color: #fef2f2;
+  }
+
+  .task-item.uninspected .task-name,
+  .task-item.uninspected .task-location,
+  .task-item.uninspected .detail-value {
+    color: #000000;
   }
 
   .task-header {
@@ -1694,7 +1804,7 @@
     right: 0;
     bottom: 0;
     background: rgba(0, 0, 0, 0.5);
-    z-index: 10000;
+    z-index: 100;
     display: flex;
     align-items: center;
     justify-content: center;
@@ -1833,6 +1943,7 @@
     cursor: pointer;
     box-shadow: 0 2px 4px rgba(255, 71, 87, 0.3);
     transition: all 0.3s ease;
+    z-index: 1000;
   }
 
   .delete-btn:hover {

--
Gitblit v1.9.3