From 8aa85b0dfd3d0305e06b3e4637ba708bbf4a4f77 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 31 三月 2026 15:39:20 +0800
Subject: [PATCH] 酒泉app 1.巡检上传图片预览修改

---
 src/pages/inspectionUpload/index.vue |  720 ++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 389 insertions(+), 331 deletions(-)

diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index e18f93b..6ff80b6 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -3,6 +3,19 @@
     <!-- 椤甸潰澶撮儴 -->
     <PageHeader title="宸℃涓婁紶" @back="goBack" />
 
+    <!-- 鎼滅储鍖哄煙 -->
+    <view class="search-section">
+      <up-input
+        v-model="searchAll"
+        placeholder="璇疯緭鍏ヨ澶囧悕绉�"
+        prefixIcon="search"
+        border="surround"
+        :clearable="true"
+        @change="handleSearch"
+        @clear="handleClear"
+      ></up-input>
+    </view>
+
     <!-- 鏁版嵁鍒楄〃 -->
     <view class="table-section">
       <!-- 鐢熶骇宸℃鍒楄〃 -->
@@ -51,8 +64,7 @@
             <view class="detail-item">
               <text class="detail-label">宸℃鐘舵��</text>
               <view class="detail-value">
-                <uni-tag v-if="item.fileStatus==2" text="宸插畬鎴�" size="small" type="success" inverted></uni-tag>
-                <uni-tag v-else-if="item.fileStatus==1" text="宸℃涓�" size="small" type="primary" inverted></uni-tag>
+                <uni-tag v-if="item.status=='宸插贰妫�'" text="宸插贰妫�" size="small" type="success" inverted></uni-tag>
                 <uni-tag v-else="" text="鏈贰妫�" size="small" type="warning" inverted></uni-tag>
               </view>
             </view>
@@ -66,32 +78,6 @@
         <text>鏆傛棤鏁版嵁</text>
       </view>
 
-    </view>
-
-    <!-- 鎵爜鍖哄煙 - 鍏ㄥ眬寮圭獥 -->
-    <view v-if="isScanning" class="qr-scan-overlay">
-      <view class="qr-scan-container">
-        <view class="scan-header">
-          <text class="scan-title">鎵弿浜岀淮鐮�</text>
-          <u-button type="error" size="small" @click.stop="stopScan" :customStyle="{
-            borderRadius: '15px',
-            height: '30px',
-            fontSize: '12px'
-          }">
-            鍏抽棴
-          </u-button>
-        </view>
-        <camera class="qr-camera" device-position="back" flash="off" @scancode="handleScanCode"
-          @error="handleCameraError"></camera>
-        <view class="scan-frame-wrapper">
-          <view class="scan-frame"></view>
-          <view class="scan-tip">璇峰皢浜岀淮鐮佹斁鍏ユ鍐�</view>
-        </view>
-        <u-alert v-if="cameraError" :title="cameraError" type="error" :showIcon="true" :closable="true"
-          @close="cameraError = ''" :customStyle="{
-            margin: '10px 0'
-          }"></u-alert>
-      </view>
     </view>
 
     <!-- 鍥剧墖涓婁紶寮圭獥 - 鍘熺敓瀹炵幇 -->
@@ -162,10 +148,10 @@
               <view v-if="getCurrentFiles().length > 0" class="file-list">
                 <view v-for="(file, index) in getCurrentFiles()" :key="index" class="file-item">
                   <view class="file-preview-container">
-                    <image v-if="file?.path?.fileType === 'image'"
-                      :src="file?.url || file?.tempFilePath?.tempFilePath || file?.path?.tempFilePath"
+                    <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 class="video-preview">
+                    <view v-else-if="file.type === 'video'" class="video-preview">
                       <uni-icons type="videocam" name="videocam" size="18" color="#fff"
                         style="margin-right: 5px;"></uni-icons>
                       <text class="video-text">瑙嗛</text>
@@ -244,7 +230,7 @@
                 <view v-for="(file, index) in getCurrentViewAttachments()" :key="index" class="attachment-item"
                   @click="previewAttachment(file)">
                   <view class="attachment-preview-container">
-                    <image v-if="file.type === 'image' || isImageFile(file)" :src="file.url || file.downloadUrl"
+                    <image v-if="file.type === 'image' || isImageFile(file)" :src="getAttachmentImageUrl(file)"
                       class="attachment-preview" mode="aspectFill" />
                     <view v-else class="attachment-video-preview">
                       <u-icon name="video" size="24" color="#409eff"></u-icon>
@@ -294,6 +280,7 @@
 import { getLedgerById } from '@/api/equipmentManagement/ledger.js'
 import { inspectionTaskList, uploadInspectionTask } from "@/api/inspectionManagement";
 import { getToken } from "@/utils/auth";
+import config from '@/config'
 
 // 缁勪欢寮曠敤宸茬Щ闄�
 
@@ -345,9 +332,25 @@
 // 寮傚父鐘舵��
 const hasException = ref(null) // null: 鏈�夋嫨, true: 瀛樺湪寮傚父, false: 姝e父
 
+// 鎼滅储鐩稿叧
+const searchAll = ref('')
+
+const handleSearch = () => {
+  pagesPames.current = 1
+  taskTableData.value = []
+  getList()
+}
+
+const handleClear = () => {
+	searchAll.value = ''
+  pagesPames.current = 1
+  taskTableData.value = []
+  getList()
+}
+
 // 涓婁紶閰嶇疆
 const uploadConfig = {
-  action: "/common/minioUploads",
+  action: "/file/upload",
   limit: 10,
   fileSize: 50, // MB
   fileType: ['jpg', 'jpeg', 'png', 'mp4', 'mov'],
@@ -356,17 +359,7 @@
 
 // 璁$畻涓婁紶URL
 const uploadFileUrl = computed(() => {
-  let baseUrl = '';
-
-  if (process.env.VUE_APP_BASE_API) {
-    baseUrl = process.env.VUE_APP_BASE_API;
-  } else if (process.env.NODE_ENV === 'development') {
-    baseUrl = 'http://114.132.189.42:9068';
-  } else {
-    baseUrl = 'http://114.132.189.42:9068';
-  }
-
-  return baseUrl + uploadConfig.action;
+  return config.baseUrl + uploadConfig.action;
 })
 
 // 璁$畻璇锋眰澶�
@@ -377,10 +370,6 @@
 
 // 璇锋眰鍙栨秷鏍囧織锛岀敤浜庡彇娑堟鍦ㄨ繘琛岀殑璇锋眰
 let isRequestCancelled = false
-
-// 鎵爜鐩稿叧鐘舵��
-const isScanning = ref(false)
-const cameraError = ref('')
 
 const pagesPames = reactive({
   size: 10,
@@ -439,11 +428,6 @@
   // 璁剧疆鍙栨秷鏍囧織锛岄樆姝㈠悗缁殑寮傛鎿嶄綔
   isRequestCancelled = true
 
-  // 鍋滄鎵爜
-  if (isScanning.value) {
-    isScanning.value = false
-  }
-
   // 鍏抽棴涓婁紶寮圭獥
   if (showUploadDialog.value) {
     showUploadDialog.value = false
@@ -464,7 +448,14 @@
   // 璁剧疆鍙栨秷鏍囧織
   isRequestCancelled = false
   loading.value = true
-  inspectionTaskList({...pagesPames}).then(res => {
+  
+  // 鏋勫缓鏌ヨ鍙傛暟
+  const params = { ...pagesPames }
+  if (searchAll.value) {
+    params.searchAll = searchAll.value
+  }
+  
+  inspectionTaskList(params).then(res => {
     // 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪涓旇姹傛湭琚彇娑�
     if (!isRequestCancelled) {
       // 澶勭悊涓嶅悓鐨勬暟鎹粨鏋�
@@ -528,114 +519,77 @@
   }
 }
 
-// 涓烘寚瀹氫换鍔″紑濮嬫壂鐮�
+// 涓烘寚瀹氫换鍔″紑濮嬫壂鐮侊紙鐪熸満锛�
 const startScanForTask = async (task) => {
   try {
-    // 璁板綍褰撳墠鎵弿鐨勪换鍔�
     currentScanningTask.value = task
-
-    // 鏄剧ず鎵弿鐣岄潰
-    isScanning.value = true
-
-    // 浣跨敤uniapp鐨勬壂鐮丄PI
     uni.scanCode({
       success: (res) => {
         handleScanSuccess(res)
       },
       fail: (err) => {
+        console.error('鎵爜澶辫触:', err)
         uni.showToast({
           title: '鎵爜澶辫触',
           icon: 'error'
         })
-        // 鍏抽棴鎵弿鐣岄潰
-        isScanning.value = false
       }
     })
   } catch (e) {
+    console.error('鍚姩鎵爜澶辫触:', e)
     uni.showToast({
       title: '鍚姩鎵爜澶辫触',
       icon: 'error'
     })
-    isScanning.value = false
   }
 }
 
-// 鍋滄鎵爜
-const stopScan = () => {
-  isScanning.value = false
-  currentScanningTask.value = null
-}
-
-// 鎵爜鎴愬姛澶勭悊
-const handleScanSuccess = async (result) => {
+// 鎵爜鎴愬姛澶勭悊锛氭牎楠屽悗鎵撳紑涓婁紶寮圭獥
+const handleScanSuccess = (result) => {
   try {
     // 瑙f瀽浜岀淮鐮佹暟鎹紝鎻愬彇deviceId
     let deviceId = ''
 
-    // 妫�鏌ユ槸鍚︽槸URL鏍煎紡
-    if (result.result.includes('deviceId=')) {
-      // 浠嶶RL涓彁鍙杁eviceId
-      const url = result.result
-      const match = url.match(/deviceId=(\d+)/)
-      if (match && match[1]) {
-        deviceId = match[1]
-      }
-    } else {
-      // 灏濊瘯瑙f瀽JSON鏍煎紡
-      try {
-        const qrData = JSON.parse(result.result)
-        deviceId = qrData.deviceId || qrData.qrCodeId || ''
-      } catch (e) {
-        // 濡傛灉涓嶆槸JSON鏍煎紡锛岀洿鎺ヤ娇鐢ㄧ粨鏋�
-        deviceId = result.result
+    if (result?.result && typeof result.result === 'string') {
+      if (result.result.includes('deviceId=')) {
+        const match = result.result.match(/deviceId=(\d+)/)
+        if (match && match[1]) deviceId = match[1]
+      } else {
+        try {
+          const qrData = JSON.parse(result.result)
+          deviceId = qrData.deviceId || qrData.qrCodeId || ''
+        } catch (e) {
+          deviceId = result.result
+        }
       }
     }
 
     if (!deviceId) {
-      uni.showToast({
-        title: '鏈瘑鍒埌璁惧ID',
-        icon: 'error'
-      })
-      isScanning.value = false
+      uni.showToast({ title: '鏈瘑鍒埌璁惧ID', icon: 'error' })
       return
     }
 
-    // 鑾峰彇褰撳墠浠诲姟鐨則askId
     const currentTaskId = currentScanningTask.value?.taskId || currentScanningTask.value?.id
-
-    // 瀵规瘮deviceId鍜宼askId
-    if (deviceId === currentTaskId.toString()) {
-      uni.showToast({
-        title: '璇嗗埆鎴愬姛',
-        icon: 'success'
-      })
-
-      // 鍏堝叧闂壂鎻忕晫闈�
-      isScanning.value = false
-
-      // 寤惰繜鎵撳紑涓婁紶寮圭獥锛岀‘淇濇壂鎻忕晫闈㈠畬鍏ㄥ叧闂�
-      setTimeout(() => {
-        openUploadDialog(currentScanningTask.value)
-      }, 300)
-    } else {
-      uni.showToast({
-        title: '璇锋壂鎻忔纭殑璁惧',
-        icon: 'error'
-      })
-
-      // 鍏抽棴鎵弿鐣岄潰
-      isScanning.value = false
+    if (!currentTaskId) {
+      uni.showToast({ title: '浠诲姟淇℃伅缂哄け', icon: 'error' })
+      return
     }
 
+    if (deviceId === currentTaskId.toString()) {
+      uni.showToast({ title: '璇嗗埆鎴愬姛', icon: 'success' })
+      openUploadDialog(currentScanningTask.value)
+    } else {
+      uni.showToast({ title: '璇锋壂鎻忔纭殑璁惧', icon: 'error' })
+    }
   } catch (error) {
+    console.error('鎵爜缁撴灉澶勭悊澶辫触:', error)
     uni.showToast({
-      title: error.message || '鏁版嵁瑙f瀽澶辫触',
+      title: error?.message || '鏁版嵁瑙f瀽澶辫触',
       icon: 'error'
     })
-    // 鍏抽棴鎵弿鐣岄潰
-    isScanning.value = false
   }
 }
+
 
 // 鎵撳紑涓婁紶寮圭獥
 const openUploadDialog = (task) => {
@@ -753,6 +707,18 @@
 // 鎻愪氦涓婁紶
 const submitUpload = async () => {
   try {
+    // 妫�鏌ョ綉缁滆繛鎺�
+    const hasNetwork = await checkNetworkConnection();
+    if (!hasNetwork) {
+      uni.showModal({
+        title: '缃戠粶閿欒',
+        content: '缃戠粶杩炴帴涓嶅彲鐢紝璇锋鏌ョ綉缁滆缃悗閲嶈瘯',
+        showCancel: false,
+        confirmText: '鐭ラ亾浜�'
+      });
+      return;
+    }
+
     // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗紓甯哥姸鎬�
     if (hasException.value === null) {
       uni.showToast({
@@ -787,10 +753,21 @@
       arr.push(...issueModelValue.value);
     }
 
+    // 浼犵粰鍚庣鐨勪复鏃舵枃浠禝D鍒楄〃锛坱empFileIds锛�
+    // 鍏煎锛氭湁浜涙帴鍙e彲鑳借繑鍥� tempId / tempFileId / id
+    let tempFileIds = []
+    if (arr !== null && arr.length > 0) {
+      tempFileIds = arr
+        .map((item) => item?.tempId ?? item?.tempFileId ?? item?.id)
+        .filter((v) => v !== undefined && v !== null && v !== '')
+    }
+
     // 鎻愪氦鏁版嵁
     infoData.value.storageBlobDTO = arr;
     // 娣诲姞寮傚父鐘舵�佷俊鎭�
     infoData.value.hasException = hasException.value;
+    infoData.value.tempFileIds = tempFileIds;
+
     const result = await uploadInspectionTask({ ...infoData.value });
 
     // 妫�鏌ユ彁浜ょ粨鏋�
@@ -814,10 +791,13 @@
     } else {
       // 鎻愪氦澶辫触
       closeToast();
-      uni.showToast({
-        title: result?.msg || result?.message || '鎻愪氦澶辫触',
-        icon: 'error'
-      })
+      const failMsg = result?.msg || result?.message || '鏈嶅姟鍣ㄨ繑鍥為敊璇�';
+      uni.showModal({
+        title: '鎻愪氦澶辫触',
+        content: failMsg,
+        showCancel: false,
+        confirmText: '鐭ラ亾浜�'
+      });
     }
 
   } catch (error) {
@@ -833,21 +813,14 @@
       errorMessage = error;
     }
 
-    uni.showToast({
-      title: errorMessage,
-      icon: 'error'
-    })
+    // 浣跨敤寮圭獥鏄剧ず璇︾粏閿欒淇℃伅
+    uni.showModal({
+      title: '鎻愪氦澶辫触',
+      content: errorMessage,
+      showCancel: false,
+      confirmText: '鐭ラ亾浜�'
+    });
   }
-}
-
-// 鎽勫儚澶撮敊璇鐞�
-const handleCameraError = (error) => {
-  cameraError.value = '鎽勫儚澶磋闂け璐ワ紝璇锋鏌ユ潈闄愯缃�'
-}
-
-// 鎵爜浜嬩欢澶勭悊
-const handleScanCode = (result) => {
-  handleScanSuccess(result)
 }
 
 // 鏌ョ湅闄勪欢
@@ -859,32 +832,40 @@
     // 瑙f瀽鏂扮殑鏁版嵁缁撴瀯
     attachmentList.value = []
 
-    // 鐢熶骇鍓嶉檮浠� (type=0)
-    if (task.beforeProduction && Array.isArray(task.beforeProduction)) {
-      const beforeFiles = task.beforeProduction.map(file => ({
+    // 鍚庣鍙嶆樉瀛楁锛堜綘鎻愪緵鐨勬暟鎹粨鏋勶級锛�
+    // - commonFileListBefore锛氱敓浜у墠锛堥�氬父 type=10锛�
+    // - commonFileListAfter锛氱敓浜т腑锛堥�氬父 type=11锛�
+    // - commonFileList锛氬彲鑳芥槸鍏ㄩ儴/鍏滃簳锛堣嫢鍖呭惈鐢熶骇鍚庯紝涓�鑸� type=12锛�
+    const allList = Array.isArray(task?.commonFileList) ? task.commonFileList : []
+    const beforeList = Array.isArray(task?.commonFileListBefore)
+      ? task.commonFileListBefore
+      : allList.filter(f => f?.type === 10)
+    const afterList = Array.isArray(task?.commonFileListAfter)
+      ? task.commonFileListAfter
+      : allList.filter(f => f?.type === 11)
+    // 濡傛灉鍚庣鍚庣画琛ヤ簡 commonFileListIssue锛屽垯浼樺厛鐢紱鍚﹀垯浠� commonFileList 閲屾寜 type=12 鍏滃簳
+    const issueList = Array.isArray(task?.commonFileListIssue)
+      ? task.commonFileListIssue
+      : allList.filter(f => f?.type === 12)
+
+    const mapToViewFile = (file, viewType) => {
+      const u = normalizeFileUrl(file?.url || file?.downloadUrl || '')
+      return {
         ...file,
-        type: 0 // 纭繚type涓�0
-      }))
-      attachmentList.value.push(...beforeFiles)
+        // 鐢ㄤ簬涓夋爣绛鹃〉鍒嗙粍锛�0=鐢熶骇鍓� 1=鐢熶骇涓� 2=鐢熶骇鍚�
+        type: viewType,
+        name: file?.name || file?.originalFilename || file?.bucketFilename,
+        bucketFilename: file?.bucketFilename || file?.name,
+        originalFilename: file?.originalFilename || file?.name,
+        url: u,
+        downloadUrl: u,
+        size: file?.size || file?.byteSize,
+      }
     }
 
-    // 鐢熶骇涓檮浠� (type=1) 
-    if (task.afterProduction && Array.isArray(task.afterProduction)) {
-      const afterFiles = task.afterProduction.map(file => ({
-        ...file,
-        type: 1 // 纭繚type涓�1
-      }))
-      attachmentList.value.push(...afterFiles)
-    }
-
-    // 鐢熶骇鍚庨檮浠� (type=2)
-    if (task.productionIssues && Array.isArray(task.productionIssues)) {
-      const issueFiles = task.productionIssues.map(file => ({
-        ...file,
-        type: 2 // 纭繚type涓�2
-      }))
-      attachmentList.value.push(...issueFiles)
-    }
+    attachmentList.value.push(...beforeList.map(f => mapToViewFile(f, 0)))
+    attachmentList.value.push(...afterList.map(f => mapToViewFile(f, 1)))
+    attachmentList.value.push(...issueList.map(f => mapToViewFile(f, 2)))
 
     showAttachmentDialog.value = true
 
@@ -917,13 +898,13 @@
 const getTabType = () => {
   switch (currentUploadType.value) {
     case 'before':
-      return 0
+      return 10
     case 'after':
-      return 1
+      return 11
     case 'issue':
-      return 2
+      return 12
     default:
-      return 0
+      return 10
   }
 }
 // 鑾峰彇褰撳墠鏌ョ湅绫诲瀷鐨勯檮浠�
@@ -954,6 +935,46 @@
   const name = file.bucketFilename || file.originalFilename || file.name || ''
   const ext = name.split('.').pop()?.toLowerCase()
   return ['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(ext)
+}
+
+// 鑾峰彇鏌ョ湅闄勪欢鍥剧墖鐨勫畬鏁碪RL锛坖avaApi + url锛�
+const getAttachmentImageUrl = (file) => {
+  return file.url
+}
+
+// 鏂囦欢璁块棶鍩虹鍩燂紙鍚庣瑕佹眰鍓嶇紑锛�
+const filePreviewBase = config.javaApi
+
+// 灏嗗悗绔繑鍥炵殑鏂囦欢鍦板潃瑙勮寖鎴愬彲璁块棶URL
+// 鍏煎鍦烘櫙锛�
+// - 宸茬粡鏄� http/https锛氱洿鎺ヨ繑鍥�
+// - 浠� / 寮�澶达細鎷兼帴 filePreviewBase
+// - Windows 鏈湴璺緞锛堝 D:\ruoyi\prod\uploads...\xx.jpg锛夛細灏濊瘯鎴彇 prod 涔嬪悗鐨勭浉瀵硅矾寰勫苟鎷兼帴 filePreviewBase
+const normalizeFileUrl = (rawUrl) => {
+  try {
+    if (!rawUrl || typeof rawUrl !== 'string') return ''
+    const url = rawUrl.trim()
+    if (!url) return ''
+    if (/^https?:\/\//i.test(url)) return url
+    if (url.startsWith('/')) return `${filePreviewBase}${url}`
+
+    // Windows path -> web path
+    if (/^[a-zA-Z]:\\/.test(url)) {
+      const normalized = url.replace(/\\/g, '/')
+      const idx = normalized.indexOf('/prod/')
+      if (idx >= 0) {
+        const relative = normalized.slice(idx + '/prod/'.length)
+        return `${filePreviewBase}/${relative}`
+      }
+      // 鍏滃簳锛氭棤娉曟帹鏂槧灏勮鍒欐椂锛岃嚦灏戞妸鍙嶆枩鏉犲彉鎴愭鏂滄潬
+      return normalized
+    }
+
+    // 鍏朵粬鐩稿璺緞锛氱洿鎺ョ敤 baseUrl 鎷间竴涓�
+    return `${filePreviewBase}/${url.replace(/^\//, '')}`
+  } catch (e) {
+    return rawUrl || ''
+  }
 }
 
 // 棰勮闄勪欢
@@ -994,52 +1015,100 @@
   })
 }
 
-// 浣跨敤鐩告満
+// 鎷嶇収/鎷嶈棰戯紙鐪熸満浼樺厛鐢� chooseMedia锛涗笉鏀寔鍒欓檷绾э級
 const chooseMedia = (type) => {
-  let mediaPamaes = {
-    count: 1,
-    mediaType: [type || 'image'],
-    sizeType: ['compressed', 'original'],
-    sourceType: ['camera'],
+  if (getCurrentFiles().length >= uploadConfig.limit) {
+    uni.showModal({
+      title: '鏁伴噺闄愬埗',
+      content: `鏈�澶氬彧鑳戒笂浼� ${uploadConfig.limit} 涓枃浠讹紝璇峰厛鍒犻櫎閮ㄥ垎鏂囦欢鍚庡啀涓婁紶`,
+      showCancel: false,
+      confirmText: '鐭ラ亾浜�'
+    });
+    return;
   }
-  uni.chooseMedia({
-    ...mediaPamaes,
-    success: (res) => {
-      try {
-        if (!res.tempFiles || res.tempFiles.length === 0) {
-          throw new Error('鏈幏鍙栧埌鍥剧墖鏂囦欢');
+
+  const remaining = uploadConfig.limit - getCurrentFiles().length
+
+  // 浼樺厛锛歝hooseMedia锛堟敮鎸� image/video锛�
+  if (typeof uni.chooseMedia === 'function') {
+    uni.chooseMedia({
+      count: Math.min(remaining, 1),
+      mediaType: [type || 'image'],
+      sizeType: ['compressed', 'original'],
+      sourceType: ['camera'],
+      success: (res) => {
+        try {
+          const files = res?.tempFiles || []
+          if (!files.length) throw new Error('鏈幏鍙栧埌鏂囦欢')
+
+          files.forEach((tf, idx) => {
+            const filePath = tf.tempFilePath || tf.path || ''
+            const fileType = tf.fileType || type || 'image'
+            const ext = fileType === 'video' ? 'mp4' : 'jpg'
+            const file = {
+              tempFilePath: filePath,
+              path: filePath,
+              type: fileType,
+              name: `${fileType}_${Date.now()}_${idx}.${ext}`,
+              size: tf.size || 0,
+              duration: tf.duration || 0,
+              createTime: Date.now(),
+              uid: Date.now() + Math.random() + idx
+            }
+            handleBeforeUpload(file)
+          })
+        } catch (e) {
+          console.error('澶勭悊鎷嶆憚缁撴灉澶辫触:', e);
+          uni.showModal({
+            title: '澶勭悊澶辫触',
+            content: '鏂囦欢澶勭悊澶辫触锛�' + (e.message || '鏈煡閿欒'),
+            showCancel: false,
+            confirmText: '鐭ラ亾浜�'
+          });
         }
+      },
+      fail: (err) => {
+        console.error('鎷嶆憚澶辫触:', err);
+        const msg = err.errMsg || '鏈煡閿欒';
+        if (msg.includes('cancel')) {
+          // 鐢ㄦ埛鍙栨秷锛屼笉鎻愮ず
+          return;
+        }
+        uni.showModal({
+          title: '鎷嶆憚澶辫触',
+          content: '閿欒淇℃伅锛�' + msg,
+          showCancel: false,
+          confirmText: '鐭ラ亾浜�'
+        });
+      }
+    })
+    return;
+  }
 
-        const tempFilePath = res.tempFiles[0];
-        const tempFile = res.tempFiles && res.tempFiles[0] ? res.tempFiles[0] : {};
-
-        const file = {
-          tempFilePath: tempFilePath,
-          path: tempFilePath, // 淇濇寔鍏煎鎬�
+  // 闄嶇骇锛歝hooseImage / chooseVideo
+  if (type === 'video') {
+    chooseVideo()
+  } else {
+    uni.chooseImage({
+      count: 1,
+      sizeType: ['compressed', 'original'],
+      sourceType: ['camera'],
+      success: (res) => {
+        const tempFilePath = res?.tempFilePaths?.[0]
+        const tempFile = res?.tempFiles?.[0] || {}
+        if (!tempFilePath) return
+        handleBeforeUpload({
+          tempFilePath,
+          path: tempFilePath,
           type: 'image',
           name: `photo_${Date.now()}.jpg`,
           size: tempFile.size || 0,
-          createTime: new Date().getTime(),
+          createTime: Date.now(),
           uid: Date.now() + Math.random()
-        };
-
-        handleBeforeUpload(file);
-      } catch (error) {
-        console.error('澶勭悊鎷嶇収缁撴灉澶辫触:', error);
-        uni.showToast({
-          title: '澶勭悊鍥剧墖澶辫触',
-          icon: 'error'
-        });
+        })
       }
-    },
-    fail: (err) => {
-      console.error('鎷嶇収澶辫触:', err);
-      uni.showToast({
-        title: '鎷嶇収澶辫触: ' + (err.errMsg || '鏈煡閿欒'),
-        icon: 'error'
-      });
-    }
-  })
+    })
+  }
 }
 
 // 鎷嶇収
@@ -1193,36 +1262,6 @@
 
 // 涓婁紶鍓嶆牎楠�
 const handleBeforeUpload = async (file) => {
-  // 妫�鏌ョ綉缁滆繛鎺�
-  const hasNetwork = await checkNetworkConnection();
-  if (!hasNetwork) {
-    uni.showToast({
-      title: '缃戠粶杩炴帴涓嶅彲鐢紝璇锋鏌ョ綉缁滆缃�',
-      icon: 'none'
-    });
-    return false;
-  }
-
-  // 鏍¢獙鏂囦欢澶у皬
-  if (uploadConfig.fileSize && file.size) {
-    const isLt = file.size / 1024 / 1024 < uploadConfig.fileSize;
-    if (!isLt) {
-      uni.showToast({
-        title: `鏂囦欢澶у皬涓嶈兘瓒呰繃 ${uploadConfig.fileSize} MB!`,
-        icon: 'none'
-      });
-      return false;
-    }
-  }
-
-  // 鏍¢獙瑙嗛鏃堕暱
-  if (file.type === 'video' && file.duration && file.duration > uploadConfig.maxVideoDuration) {
-    uni.showToast({
-      title: `瑙嗛鏃堕暱涓嶈兘瓒呰繃 ${uploadConfig.maxVideoDuration} 绉�!`,
-      icon: 'none'
-    });
-    return false;
-  }
 
   // 鏍¢獙鏂囦欢绫诲瀷
   if (uploadConfig.fileType && Array.isArray(uploadConfig.fileType) && uploadConfig.fileType.length > 0) {
@@ -1244,9 +1283,11 @@
       );
 
       if (!isAllowed) {
-        uni.showToast({
-          title: `鏂囦欢鏍煎紡涓嶆敮鎸侊紝璇锋媿鎽� ${expectedTypes.join('/')} 鏍煎紡鐨勬枃浠禶,
-          icon: 'none'
+        uni.showModal({
+          title: '鏍煎紡涓嶆敮鎸�',
+          content: `褰撳墠鏍煎紡涓� .${fileExtension}锛岃鎷嶆憚 ${expectedTypes.join('/')} 鏍煎紡鐨勬枃浠禶,
+          showCancel: false,
+          confirmText: '鐭ラ亾浜�'
         });
         return false;
       }
@@ -1258,40 +1299,41 @@
   return true;
 }
 
-// 鏂囦欢涓婁紶澶勭悊
-const uploadFile = (file) => {
+// 鏂囦欢涓婁紶澶勭悊锛堢湡鏈鸿蛋 uni.uploadFile锛�
+const uploadFile = async (file) => {
   uploading.value = true;
   uploadProgress.value = 0;
   number.value++; // 澧炲姞涓婁紶璁℃暟
 
-  // 纭繚鏂囦欢璺緞姝g‘
-  const filePath = file.tempFilePath?.tempFilePath || file.path?.tempFilePath || '';
-  if (!filePath) {
-    handleUploadError('鏂囦欢璺緞涓嶅瓨鍦�');
-    return;
-  }
-
   // 纭繚token瀛樺湪
   const token = getToken();
   if (!token) {
-    handleUploadError('鐢ㄦ埛鏈櫥褰�');
+    handleUploadError('鐢ㄦ埛鏈櫥褰曪紝璇烽噸鏂扮櫥褰曞悗鍐嶈瘯');
     return;
   }
 
-  // 鍑嗗涓婁紶鍙傛暟
-  const uploadParams = {
+  const typeValue = getTabType(); // 鐢熶骇鍓�:10, 鐢熶骇涓�:11, 鐢熶骇鍚�:12
+
+  uploadWithUniUploadFile(file, file.tempFilePath || file.path || '', typeValue, token);
+}
+
+// 浣跨敤uni.uploadFile涓婁紶锛堥潪H5鐜鎴朒5鍥為��鏂规锛�
+const uploadWithUniUploadFile = (file, filePath, typeValue, token) => {
+  if (!filePath) {
+    handleUploadError('鏂囦欢璺緞涓嶅瓨鍦紝璇烽噸鏂版媿鎽�');
+    return;
+  }
+
+  const uploadTask = uni.uploadFile({
     url: uploadFileUrl.value,
     filePath: filePath,
-    name: 'files',
+    name: 'file',
     formData: {
-      type: getTabType() || 0
+      type: typeValue
     },
     header: {
       'Authorization': `Bearer ${token}`
-    }
-  };
-  const uploadTask = uni.uploadFile({
-    ...uploadParams,
+    },
     success: (res) => {
       try {
         if (res.statusCode === 200) {
@@ -1303,31 +1345,29 @@
               icon: 'success'
             });
           } else {
-            handleUploadError(response.msg || '鏈嶅姟鍣ㄨ繑鍥為敊璇�');
+            handleUploadError(response.msg || `鏈嶅姟鍣ㄨ繑鍥為敊璇� (code: ${response.code})`);
           }
         } else {
-          handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}`);
+          handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}锛岃绋嶅悗閲嶈瘯鎴栬仈绯荤鐞嗗憳`);
         }
       } catch (e) {
         console.error('瑙f瀽鍝嶅簲澶辫触:', e);
         console.error('鍘熷鍝嶅簲鏁版嵁:', res.data);
-        handleUploadError('鍝嶅簲鏁版嵁瑙f瀽澶辫触: ' + e.message);
+        handleUploadError('鏈嶅姟鍣ㄥ搷搴旇В鏋愬け璐ワ紝璇疯仈绯荤鐞嗗憳');
       }
     },
     fail: (err) => {
-      console.error('涓婁紶澶辫触:', err.errMsg || err);
+      console.error('涓婁紶澶辫触:', err);
       number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
 
       let errorMessage = '涓婁紶澶辫触';
       if (err.errMsg) {
-        if (err.errMsg.includes('statusCode: null')) {
-          errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃�';
+        if (err.errMsg.includes('statusCode: null') || err.errMsg.includes('fail')) {
+          errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃悗閲嶈瘯';
         } else if (err.errMsg.includes('timeout')) {
-          errorMessage = '涓婁紶瓒呮椂锛岃閲嶈瘯';
-        } else if (err.errMsg.includes('fail')) {
-          errorMessage = '涓婁紶澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�';
+          errorMessage = '涓婁紶瓒呮椂锛岃妫�鏌ョ綉缁滃悗閲嶈瘯';
         } else {
-          errorMessage = err.errMsg;
+          errorMessage = '涓婁紶澶辫触锛�' + err.errMsg;
         }
       }
 
@@ -1348,84 +1388,83 @@
 }
 
 // 涓婁紶澶辫触澶勭悊
-const handleUploadError = (message = '涓婁紶鏂囦欢澶辫触', showRetry = true) => {
-  if (showRetry) {
-    uni.showModal({
-      title: '涓婁紶澶辫触',
-      content: message + '锛屾槸鍚﹂噸璇曪紵',
-      success: (res) => {
-        if (res.confirm) {
-          // 鐢ㄦ埛閫夋嫨閲嶈瘯锛岃繖閲屽彲浠ラ噸鏂拌Е鍙戜笂浼�
-        }
-      }
-    });
-  } else {
-    uni.showToast({
-      title: message,
-      icon: 'error'
-    });
-  }
+const handleUploadError = (message = '涓婁紶鏂囦欢澶辫触') => {
+  uploading.value = false;
+  uploadProgress.value = 0;
+
+  uni.showModal({
+    title: '涓婁紶澶辫触',
+    content: message,
+    showCancel: false,
+    confirmText: '鐭ラ亾浜�'
+  });
 }
 
 // 涓婁紶鎴愬姛鍥炶皟
 const handleUploadSuccess = (res, file) => {
-  if (res.code === 200 && res.data && Array.isArray(res.data) && res.data.length > 0) {
-    const uploadedFile = res.data[0];
+  console.log('涓婁紶鎴愬姛鍝嶅簲:', res);
+  
+  // 澶勭悊涓嶅悓鐨勬暟鎹粨鏋勶細鍙兘鏄暟缁勶紝涔熷彲鑳芥槸鍗曚釜瀵硅薄
+  let uploadedFile = null;
+  uploadedFile = res.data;
 
-    // 鏍规嵁褰撳墠涓婁紶绫诲瀷璁剧疆type瀛楁
-    let typeValue = 0; // 榛樿涓虹敓浜у墠
-    switch (currentUploadType.value) {
-      case 'before':
-        typeValue = 0;
-        break;
-      case 'after':
-        typeValue = 1;
-        break;
-      case 'issue':
-        typeValue = 2;
-        break;
-    }
-
-    // 纭繚涓婁紶鐨勬枃浠舵暟鎹畬鏁达紝鍖呭惈id鍜宼ype
-    const fileData = {
-      ...file,
-      id: uploadedFile.id, // 娣诲姞鏈嶅姟鍣ㄨ繑鍥炵殑id
-      url: uploadedFile.url || uploadedFile.downloadUrl,
-      bucketFilename: uploadedFile.bucketFilename || file.name,
-      downloadUrl: uploadedFile.downloadUrl || uploadedFile.url,
-      size: uploadedFile.size || file.size,
-      createTime: uploadedFile.createTime || new Date().getTime(),
-      type: typeValue // 娣诲姞绫诲瀷瀛楁锛�0=鐢熶骇鍓�, 1=鐢熶骇涓�, 2=鐢熶骇鍚�
-    };
-
-    uploadList.value.push(fileData);
-    uploadedSuccessfully();
-  } else {
+  if (!uploadedFile) {
+    console.error('鏃犳硶瑙f瀽涓婁紶鍝嶅簲鏁版嵁:', res);
     number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
-    handleUploadError(res.msg || '涓婁紶澶辫触');
+    handleUploadError('涓婁紶鍝嶅簲鏁版嵁鏍煎紡閿欒');
+    return;
   }
+
+  // 鏍规嵁褰撳墠涓婁紶绫诲瀷璁剧疆type瀛楁
+  let typeValue = 0; // 榛樿涓虹敓浜у墠
+  switch (currentUploadType.value) {
+    case 'before':
+      typeValue = 0;
+      break;
+    case 'after':
+      typeValue = 1;
+      break;
+    case 'issue':
+      typeValue = 2;
+      break;
+  }
+
+  // 纭繚涓婁紶鐨勬枃浠舵暟鎹畬鏁达紝鍖呭惈id鍜宼ype
+  const fileData = {
+    ...file,
+    id: uploadedFile.id, // 娣诲姞鏈嶅姟鍣ㄨ繑鍥炵殑id
+    tempId: uploadedFile.tempId ?? uploadedFile.tempFileId ?? uploadedFile.id,
+    url: uploadedFile.url || uploadedFile.downloadUrl || file.tempFilePath || file.path,
+    bucketFilename: uploadedFile.bucketFilename || uploadedFile.originalFilename || file.name,
+    downloadUrl: uploadedFile.downloadUrl || uploadedFile.url,
+    size: uploadedFile.size || uploadedFile.byteSize || file.size,
+    createTime: uploadedFile.createTime || new Date().getTime(),
+    type: typeValue // 娣诲姞绫诲瀷瀛楁锛�0=鐢熶骇鍓�, 1=鐢熶骇涓�, 2=鐢熶骇鍚�
+  };
+
+  uploadList.value.push(fileData);
+  
+  // 绔嬪嵆娣诲姞鍒板搴旂殑鍒嗙被锛屼笉绛夊緟鎵�鏈夋枃浠朵笂浼犲畬鎴�
+  switch (currentUploadType.value) {
+    case 'before':
+      beforeModelValue.value.push(fileData);
+      break;
+    case 'after':
+      afterModelValue.value.push(fileData);
+      break;
+    case 'issue':
+      issueModelValue.value.push(fileData);
+      break;
+  }
+  
+  // 閲嶇疆涓婁紶鍒楄〃锛堝洜涓哄凡缁忔坊鍔犲埌瀵瑰簲鍒嗙被浜嗭級
+  uploadList.value = [];
+  number.value = 0;
 }
 
-// 涓婁紶缁撴潫澶勭悊
+// 涓婁紶缁撴潫澶勭悊锛堝凡搴熷純锛岀幇鍦ㄥ湪handleUploadSuccess涓洿鎺ュ鐞嗭級
 const uploadedSuccessfully = () => {
-  if (number.value > 0 && uploadList.value.length === number.value) {
-    // 鏍规嵁褰撳墠涓婁紶绫诲瀷锛屽皢鏂囦欢娣诲姞鍒板搴旂殑鍒嗙被
-    switch (currentUploadType.value) {
-      case 'before':
-        beforeModelValue.value = [...beforeModelValue.value, ...uploadList.value];
-        break;
-      case 'after':
-        afterModelValue.value = [...afterModelValue.value, ...uploadList.value];
-        break;
-      case 'issue':
-        issueModelValue.value = [...issueModelValue.value, ...uploadList.value];
-        break;
-    }
-
-    // 閲嶇疆鐘舵��
-    uploadList.value = [];
-    number.value = 0;
-  }
+  // 姝ゅ嚱鏁板凡涓嶅啀浣跨敤锛屾枃浠朵笂浼犳垚鍔熷悗绔嬪嵆娣诲姞鍒板搴斿垎绫�
 }
 
 // 鏍煎紡鍖栨枃浠跺ぇ灏�
@@ -2112,4 +2151,23 @@
   max-height: 60vh;
   display: block;
 }
+
+/* 鎼滅储鍖哄煙鏍峰紡 */
+.search-section {
+  padding: 15px 20px;
+  background: #fff;
+  border-bottom: 1px solid #f0f0f0;
+}
+
+:deep(.u-input) {
+  width: 100%;
+}
+
+:deep(.u-input__content) {
+  border-radius: 8px;
+}
+
+:deep(.u-input__content__field) {
+  font-size: 14px;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3