From 3c590674cb2b134c676e356d7e5ecef18b1a4399 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期四, 18 六月 2026 16:56:42 +0800
Subject: [PATCH] feat 设备巡检 调整为一次性完成

---
 src/views/equipmentManagement/inspectionManagement/components/uploadFiles.vue |  220 ++++++++++++------------------------------------------
 1 files changed, 51 insertions(+), 169 deletions(-)

diff --git a/src/views/equipmentManagement/inspectionManagement/components/uploadFiles.vue b/src/views/equipmentManagement/inspectionManagement/components/uploadFiles.vue
index 9ac7b07..7eb3e28 100644
--- a/src/views/equipmentManagement/inspectionManagement/components/uploadFiles.vue
+++ b/src/views/equipmentManagement/inspectionManagement/components/uploadFiles.vue
@@ -6,15 +6,9 @@
       width="560px"
       :before-close="closeUploadDialog"
     >
-      <el-tabs v-model="currentUploadType">
-        <el-tab-pane label="鐢熶骇鍓�" name="before" />
-        <el-tab-pane label="鐢熶骇涓�" name="after" />
-        <el-tab-pane label="鐢熶骇鍚�" name="issue" />
-      </el-tabs>
-
       <div class="exception-section">
         <div class="section-title">鏄惁瀛樺湪寮傚父锛�</div>
-        <el-radio-group v-model="currentHasException">
+        <el-radio-group v-model="hasException">
           <el-radio :value="false">姝e父</el-radio>
           <el-radio :value="true">瀛樺湪寮傚父</el-radio>
         </el-radio-group>
@@ -33,12 +27,12 @@
           :on-success="handleUploadSuccess"
           :on-error="handleUploadError"
           :on-progress="handleUploadProgress"
-          :disabled="uploading || getCurrentFiles().length >= uploadConfig.limit"
+          :disabled="uploading || fileList.length >= uploadConfig.limit"
         >
           <el-button
             type="primary"
             :loading="uploading"
-            :disabled="getCurrentFiles().length >= uploadConfig.limit"
+            :disabled="fileList.length >= uploadConfig.limit"
           >
             閫夋嫨鍥剧墖/瑙嗛
           </el-button>
@@ -51,9 +45,9 @@
         style="margin: 12px 0"
       />
 
-      <div v-if="getCurrentFiles().length" class="file-list">
+      <div v-if="fileList.length" class="file-list">
         <div
-          v-for="(file, index) in getCurrentFiles()"
+          v-for="(file, index) in fileList"
           :key="file.uid || file.id || index"
           class="file-item"
         >
@@ -86,17 +80,15 @@
 
       <el-empty
         v-else
-        :description="`璇烽�夋嫨瑕佷笂浼犵殑${getUploadTypeText()}鍥剧墖鎴栬棰慲"
+        description="璇烽�夋嫨瑕佷笂浼犵殑鍥剧墖鎴栬棰�"
       />
 
       <div class="upload-summary">
-        鐢熶骇鍓嶏細{{ beforeModelValue.length }} 涓� |
-        鐢熶骇涓細{{ afterModelValue.length }} 涓� |
-        鐢熶骇鍚庯細{{ issueModelValue.length }} 涓�
+        宸蹭笂浼� {{ fileList.length }} 涓枃浠�
       </div>
 
       <template #footer>
-				<el-button type="primary" @click="submitUpload">鎻愪氦</el-button>
+        <el-button type="primary" @click="submitUpload">鎻愪氦</el-button>
         <el-button @click="closeUploadDialog">鍙栨秷</el-button>
       </template>
     </el-dialog>
@@ -131,31 +123,14 @@
 const uploadRef = ref(null);
 const uploadFileList = ref([]);
 
-const beforeModelValue = ref([]);
-const afterModelValue = ref([]);
-const issueModelValue = ref([]);
-const currentUploadType = ref("before");
-const hasExceptionBefore = ref(null);
-const hasExceptionAfter = ref(null);
-const hasExceptionIssue = ref(null);
+const fileList = ref([]);
+const hasException = ref(null);
 const currentTask = ref(null);
 
 const showVideoDialog = ref(false);
 const currentVideoFile = ref(null);
 
-// 鏍规嵁褰撳墠 Tab 鑾峰彇/璁剧疆瀵瑰簲鐨勫紓甯哥姸鎬�
-const currentHasException = computed({
-  get: () => {
-    if (currentUploadType.value === "before") return hasExceptionBefore.value;
-    if (currentUploadType.value === "after") return hasExceptionAfter.value;
-    return hasExceptionIssue.value;
-  },
-  set: (val) => {
-    if (currentUploadType.value === "before") hasExceptionBefore.value = val;
-    else if (currentUploadType.value === "after") hasExceptionAfter.value = val;
-    else hasExceptionIssue.value = val;
-  }
-});
+const INSPECTION_TYPE = 10;
 
 const uploadConfig = {
   action: "/file/upload",
@@ -165,8 +140,7 @@
 };
 
 const uploadUrl = computed(() => {
-  const type = getTabType();
-  return `${import.meta.env.VITE_APP_BASE_API}${uploadConfig.action}?type=${type}`;
+  return `${import.meta.env.VITE_APP_BASE_API}${uploadConfig.action}?type=${INSPECTION_TYPE}`;
 });
 const uploadHeaders = {
   Authorization: `Bearer ${getToken()}`,
@@ -207,7 +181,7 @@
   return fileUrl;
 };
 
-const mapExistingFile = (file, type) => ({
+const mapExistingFile = (file) => ({
   ...file,
   id: file?.id,
   tempId: file?.tempId ?? file?.tempFileId ?? file?.id,
@@ -223,18 +197,13 @@
   size: file?.size || file?.byteSize,
   byteSize: file?.byteSize || file?.size,
   contentType: file?.contentType || "",
-  type,
-  uid: file?.uid || `${type}-${file?.id || file?.url || Math.random()}`,
+  type: INSPECTION_TYPE,
+  uid: file?.uid || `${INSPECTION_TYPE}-${file?.id || file?.url || Math.random()}`,
 });
 
 const resetDialogState = () => {
-  beforeModelValue.value = [];
-  afterModelValue.value = [];
-  issueModelValue.value = [];
-  currentUploadType.value = "before";
-  hasExceptionBefore.value = null;
-  hasExceptionAfter.value = null;
-  hasExceptionIssue.value = null;
+  fileList.value = [];
+  hasException.value = null;
   currentTask.value = null;
   uploadProgress.value = 0;
   uploading.value = false;
@@ -250,23 +219,12 @@
     storageBlobDTO: [],
   };
 
-  beforeModelValue.value = Array.isArray(rawTask.commonFileListBefore)
-    ? rawTask.commonFileListBefore.map(file => mapExistingFile(file, 10))
-    : [];
-  afterModelValue.value = Array.isArray(rawTask.commonFileListAfter)
-    ? rawTask.commonFileListAfter.map(file => mapExistingFile(file, 11))
-    : [];
-  issueModelValue.value = Array.isArray(rawTask.commonFileList)
-    ? rawTask.commonFileList.map(file => mapExistingFile(file, 12))
+  fileList.value = Array.isArray(rawTask.commonFileList)
+    ? rawTask.commonFileList.map(file => mapExistingFile(file))
     : [];
 
-  currentUploadType.value = "before";
-  hasExceptionBefore.value =
-    typeof rawTask.hasExceptionBefore === "boolean" ? rawTask.hasExceptionBefore : null;
-  hasExceptionAfter.value =
-    typeof rawTask.hasExceptionAfter === "boolean" ? rawTask.hasExceptionAfter : null;
-  hasExceptionIssue.value =
-    typeof rawTask.hasExceptionIssue === "boolean" ? rawTask.hasExceptionIssue : null;
+  hasException.value =
+    typeof rawTask.hasException === "boolean" ? rawTask.hasException : null;
   uploadFileList.value = [];
   showUploadDialog.value = true;
 };
@@ -277,26 +235,8 @@
   emit("closeDia");
 };
 
-const getCurrentFiles = () => {
-  if (currentUploadType.value === "before") return beforeModelValue.value;
-  if (currentUploadType.value === "after") return afterModelValue.value;
-  return issueModelValue.value;
-};
-
-const getUploadTypeText = () => {
-  if (currentUploadType.value === "before") return "鐢熶骇鍓�";
-  if (currentUploadType.value === "after") return "鐢熶骇涓�";
-  return "鐢熶骇鍚�";
-};
-
-const getTabType = () => {
-  if (currentUploadType.value === "before") return 10;
-  if (currentUploadType.value === "after") return 11;
-  return 12;
-};
-
 const handleBeforeUpload = file => {
-  if (getCurrentFiles().length >= uploadConfig.limit) {
+  if (fileList.value.length >= uploadConfig.limit) {
     ElMessage.warning(`鏈�澶氬彧鑳介�夋嫨${uploadConfig.limit}涓枃浠禶);
     return false;
   }
@@ -336,7 +276,6 @@
     return;
   }
 
-  const type = getTabType();
   const objectUrl = file?.raw ? URL.createObjectURL(file.raw) : "";
   const fileData = {
     id: uploadedFile.id,
@@ -354,18 +293,11 @@
     byteSize: uploadedFile.byteSize || uploadedFile.size || file.size,
     createTime: uploadedFile.createTime || Date.now(),
     contentType: uploadedFile.contentType || file.raw?.type || "",
-    type,
+    type: INSPECTION_TYPE,
     uid: `${Date.now()}-${Math.random()}`,
   };
 
-  if (currentUploadType.value === "before") {
-    beforeModelValue.value.push(fileData);
-  } else if (currentUploadType.value === "after") {
-    afterModelValue.value.push(fileData);
-  } else {
-    issueModelValue.value.push(fileData);
-  }
-
+  fileList.value.push(fileData);
   ElMessage.success("涓婁紶鎴愬姛");
 };
 
@@ -382,52 +314,9 @@
     await ElMessageBox.confirm("纭畾瑕佸垹闄よ繖涓枃浠跺悧锛�", "纭鍒犻櫎", {
       type: "warning",
     });
-
-    if (currentUploadType.value === "before") {
-      beforeModelValue.value.splice(index, 1);
-    } else if (currentUploadType.value === "after") {
-      afterModelValue.value.splice(index, 1);
-    } else {
-      issueModelValue.value.splice(index, 1);
-    }
-
+    fileList.value.splice(index, 1);
     ElMessage.success("鍒犻櫎鎴愬姛");
   } catch {}
-};
-
-const buildSubmitFiles = () => {
-  const list = [
-    ...beforeModelValue.value,
-    ...afterModelValue.value,
-    ...issueModelValue.value,
-  ];
-
-  return list.map(item => ({
-    ...item,
-    url: item?.downloadUrl || item?.url || "",
-  }));
-};
-
-const buildSubmitFileItem = item => {
-  if (!item) return null;
-
-  return {
-    id: item.id,
-    tempId: item.tempId,
-    tempFileId: item.tempFileId,
-    type: item.type,
-    url: item?.downloadUrl || item?.url || "",
-    downloadUrl: item?.downloadUrl || item?.url || "",
-    bucketFilename: item.bucketFilename,
-    originalFilename: item.originalFilename,
-    size: item.size,
-    byteSize: item.byteSize,
-    contentType: item.contentType,
-  };
-};
-
-const buildGroupedFiles = list => {
-  return (list || []).map(buildSubmitFileItem).filter(Boolean);
 };
 
 const buildSubmitPayload = () => {
@@ -442,35 +331,46 @@
     ...rest
   } = currentTask.value || {};
 
-  const files = buildSubmitFiles();
+  const files = fileList.value.map(item => ({
+    ...item,
+    url: item?.downloadUrl || item?.url || "",
+  }));
+
   const tempFileIds = files
     .map(item => item?.tempId ?? item?.tempFileId ?? item?.id)
     .filter(Boolean);
 
   return {
     ...rest,
-    hasExceptionBefore: hasExceptionBefore.value,
-    hasExceptionAfter: hasExceptionAfter.value,
-    hasExceptionIssue: hasExceptionIssue.value,
+    hasException: hasException.value,
     tempFileIds,
-    commonFileListBefore: buildGroupedFiles(beforeModelValue.value),
-    commonFileListAfter: buildGroupedFiles(afterModelValue.value),
-    commonFileList: buildGroupedFiles(issueModelValue.value),
+    commonFileList: files.map(item => {
+      if (!item) return null;
+      return {
+        id: item.id,
+        tempId: item.tempId,
+        tempFileId: item.tempFileId,
+        type: item.type,
+        url: item?.downloadUrl || item?.url || "",
+        downloadUrl: item?.downloadUrl || item?.url || "",
+        bucketFilename: item.bucketFilename,
+        originalFilename: item.originalFilename,
+        size: item.size,
+        byteSize: item.byteSize,
+        contentType: item.contentType,
+      };
+    }).filter(Boolean),
   };
 };
 
 const submitUpload = async () => {
-  // 鍙獙璇佸綋鍓� Tab 鐨勫紓甯哥姸鎬�
-  const currentException = currentHasException.value;
-  if (currentException === null) {
-    ElMessage.warning(`璇烽�夋嫨${getUploadTypeText()}鏄惁瀛樺湪寮傚父`);
+  if (hasException.value === null) {
+    ElMessage.warning("璇烽�夋嫨鏄惁瀛樺湪寮傚父");
     return;
   }
 
-  const currentFiles = getCurrentFiles();
-  // 鍙湁閫夋嫨"瀛樺湪寮傚父"鏃舵墠闇�瑕佷笂浼犳枃浠�
-  if (currentException === true && !currentFiles.length) {
-    ElMessage.warning(`${getUploadTypeText()}瀛樺湪寮傚父鏃惰涓婁紶鍥剧墖鎴栬棰慲);
+  if (hasException.value === true && !fileList.value.length) {
+    ElMessage.warning("瀛樺湪寮傚父鏃惰涓婁紶鍥剧墖鎴栬棰�");
     return;
   }
 
@@ -481,7 +381,6 @@
 
   try {
     const payload = buildSubmitPayload();
-
     const result = await uploadInspectionTask(payload);
     if (result?.code === 200 || result?.success) {
       ElMessage.success("鎻愪氦鎴愬姛");
@@ -497,23 +396,6 @@
   } finally {
     loadingInstance.close();
   }
-};
-
-const goToRepair = () => {
-  const taskInfo = {
-    taskId: currentTask.value?.taskId || currentTask.value?.id,
-    taskName: currentTask.value?.taskName,
-    inspectionLocation: currentTask.value?.inspectionLocation,
-    inspector: currentTask.value?.inspector,
-    uploadedFiles: {
-      before: beforeModelValue.value,
-      after: afterModelValue.value,
-      issue: issueModelValue.value,
-    },
-  };
-
-  sessionStorage.setItem("repairTaskInfo", JSON.stringify(taskInfo));
-  window.location.href = "/equipmentManagement/repair";
 };
 
 const previewAttachment = file => {

--
Gitblit v1.9.3