From a6d93e96d0f9585de5e15b2efa47519f18211350 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期四, 31 七月 2025 16:22:18 +0800
Subject: [PATCH] 升版导入修改为单文件导入

---
 src/views/base/modules/file/MaintenanceStandardImportModule.vue |  105 ++++++++++++++++++----------------------------------
 1 files changed, 37 insertions(+), 68 deletions(-)

diff --git a/src/views/base/modules/file/MaintenanceStandardImportModule.vue b/src/views/base/modules/file/MaintenanceStandardImportModule.vue
index c5402a5..d46498a 100644
--- a/src/views/base/modules/file/MaintenanceStandardImportModule.vue
+++ b/src/views/base/modules/file/MaintenanceStandardImportModule.vue
@@ -1,6 +1,7 @@
 <template>
   <a-modal :title="title" :visible="visible" @cancel="handleModalClose" :maskClosable="false">
-    <a-upload :multiple="true" :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload" >
+    <!-- 绉婚櫎multiple灞炴�э紝璁剧疆fileList涓哄崟涓枃浠� -->
+    <a-upload :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload" >
       <a-button type="primary" :disabled="uploading">
         <a-icon type="import"/>
         閫夊彇鏂囦欢
@@ -19,122 +20,90 @@
         纭
       </a-button>
     </template>
-
   </a-modal>
 </template>
 
 <script>
-import JUpload from '@/components/jeecg/JUpload'
-import { getAction, postAction, uploadAction } from '@/api/manage'
+import { uploadAction } from '@/api/manage'
 
 export default {
   name: 'MaintenanceStandardImportModule',
-  components: {
-    JUpload,
-  },
   data() {
     return {
       visible: false,
       title: '',
-      id:'',
-      fileList: [],
-      uploadParams: {},
+      id: '',
+      fileList: [],  // 鍒濆绌烘枃浠跺垪琛�
       uploading: false,
-      isUploadMultiple: true,
-      currentDeviceDocClassCode: 'SEND',
-      currentTitleAfterClass: '',
 
       url: {
         add: "/eam/maintenanceStandard/importUpgrade",
       },
     }
   },
-
-  created() {
-  },
   methods: {
-
-    /**
-     * 閫夋嫨濂芥枃浠剁偣鍑荤‘瀹氬悗
-     * @param file 鏂囦欢瀵硅薄
-     */
     beforeUpload(file) {
-      if (this.isUploadMultiple) {
-        if (!this.fileList.find(item => item.name === file.name)) this.fileList = [...this.fileList, file]
-      } else this.fileList.splice(0, 1, file)
+      // 鍙繚鐣欐渶鏂伴�夋嫨鐨勬枃浠�
+      this.fileList = [file]
       return false
     },
 
-    /**
-     * 鍒犻櫎鏂囦欢鍒楄〃椤规椂瑙﹀彂
-     * @param file 鏂囦欢瀵硅薄
-     */
-    handleRemove(file) {
-      const index = this.fileList.indexOf(file)
-      const newFileList = this.fileList.slice()
-      newFileList.splice(index, 1)
-      this.fileList = newFileList
+    handleRemove() {
+      // 娓呯┖鏂囦欢鍒楄〃
+      this.fileList = []
     },
 
-    // 鎺у埗鏂囦欢涓婁紶绐楀彛鍏抽棴骞舵竻绌烘枃浠跺垪琛�
     handleModalClose() {
       this.visible = false
       this.fileList = []
     },
 
-    upload(id){
-      console.log("id",id)
+    upload(id) {
       this.id = id
-      this.isUploadMultiple = true
       this.visible = true
     },
+
     handleUpload() {
-      const { fileList, $notification, handleModalClose} = this
-      this.uploading = true
-      let uploadedFileCount = 0
-      let uploadSuccessFileCount = 0
-      if (this.fileList.length === 0) {
+      const { fileList, $notification, handleModalClose } = this
+
+      // 妫�鏌ユ槸鍚︽湁鏂囦欢
+      if (fileList.length === 0) {
         this.$message.info("璇蜂笂浼犳枃浠�")
-        this.uploading = false;
+        return
       }
-      fileList.forEach((file, index) => {
-        const formData = new FormData()
-        formData.append('file', file)
-        formData.append('id',this.id)
-        uploadAction(this.url.add, formData).then(res => {
+
+      this.uploading = true
+
+      const file = fileList[0] // 鍙彇绗竴涓枃浠�
+      const formData = new FormData()
+      formData.append('file', file)
+      formData.append('id', this.id)
+
+      uploadAction(this.url.add, formData)
+        .then(res => {
           if (res.success) {
-            file.status = 'done'
-            uploadSuccessFileCount++
             $notification.success({
               message: '娑堟伅',
               description: res.message
             })
+            this.$emit('ok')
+            handleModalClose();
           } else {
-            file.status = 'error'
             $notification.error({
               message: '娑堟伅',
               description: res.message
             })
           }
         })
-          .catch(err => {
-            file.status = 'error'
+        .catch(err => {
+          $notification.error({
+            message: '閿欒',
+            description: '鏂囦欢涓婁紶澶辫触'
           })
-          .finally(() => {
-            uploadedFileCount++
-            fileList.splice(index, 1, file)
-            if (uploadedFileCount === fileList.length) {
-              if (uploadSuccessFileCount > 0) {
-                this.$emit('ok')
-              }
-              // 褰撴枃浠跺叏閮ㄤ笂浼犲畬鎴愬悗
-              if (uploadSuccessFileCount === fileList.length) {
-                handleModalClose();
-              }
-              this.uploading = false
-            }
-          })
-      })
+        })
+        .finally(() => {
+          this.uploading = false
+        })
     }
   }
 }

--
Gitblit v1.9.3