From 7e07d6e781f195995b27b82b4df66c3ffa391501 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期五, 17 一月 2025 09:49:25 +0800
Subject: [PATCH] 1、产品结构树页面完成文档生命周期相关功能,待后续开发至文档版本列表时继续完善与生命周期功能的关联 2、删除导出文档或NC程序功能

---
 src/views/dnc/common/ImportFileModal.vue |   45 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/src/views/dnc/common/ImportFileModal.vue b/src/views/dnc/common/ImportFileModal.vue
index 653ad41..6dd4ce0 100644
--- a/src/views/dnc/common/ImportFileModal.vue
+++ b/src/views/dnc/common/ImportFileModal.vue
@@ -37,7 +37,8 @@
         title: '',
         fileList: [],
         uploadParams: {},
-        uploading: false
+        uploading: false,
+        isUploadMultiple: true
       }
     },
     created() {
@@ -51,6 +52,7 @@
        * @param tableRowInfo 鐐瑰嚮琛ㄦ牸琛屽彸閿彍鍗曞鍏ョ▼搴忔椂浼犲叆琛屼俊鎭�
        */
       handleImport(treeNodeInfo, tableRowInfo) {
+        this.isUploadMultiple = true
         let attributionId // 鏂囨。鎵�灞炲眰绾d
         let attributionType  // 鏂囨。鎵�灞炲眰绾х被鍨�
         let docClassCode // 鏂囨。绫诲瀷
@@ -67,6 +69,17 @@
         this.visible = true
       },
 
+      handlePush(_, tableRowInfo) {
+        this.isUploadMultiple = false
+        console.log('tableRowInfo', tableRowInfo)
+        this.uploadParams = Object.assign({}, {
+          id: tableRowInfo.docId,
+          attributionId: tableRowInfo.attributionId,
+          docClassCode: tableRowInfo.param
+        })
+        this.visible = true
+      },
+
       handleRemove(file) {
         const index = this.fileList.indexOf(file)
         const newFileList = this.fileList.slice()
@@ -75,24 +88,40 @@
       },
 
       beforeUpload(file) {
-        if (!this.fileList.find(item => item.name === file.name)) this.fileList = [...this.fileList, 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)
+        }
         return false
       },
 
       handleUpload() {
-        const { fileList, $notification } = this
+        const { fileList, $notification, isUploadMultiple, uploadParams, $bus } = this
         this.uploading = true
         let uploadedFileCount = 0
         let uploadSuccessFileCount = 0
+        let apiMethod
+        let params
+
         fileList.forEach((file, index) => {
           const formData = new FormData()
           formData.append('file', file)
           file.status = 'uploading'
-          dncApi.importDocumentFromLocalApi(this.uploadParams, formData)
+          // 鐩墠鏍规嵁鏄惁涓婁紶澶氫釜鏂囦欢鍒ゆ柇涓や釜鍔熻兘锛岃嫢鍚庣画澧炲姞鍔熻兘鎴栬皟鏁撮渶姹傚垯璋冩暣鍒ゆ柇鏉′欢
+          if (isUploadMultiple) {
+            apiMethod = dncApi.importDocumentFromLocalApi
+            params = Object.assign({}, { params: uploadParams, formData })
+          } else {
+            apiMethod = dncApi.documentVersionUpdateApi
+            params = Object.assign({}, { id: uploadParams.id, formData })
+          }
+          apiMethod(params)
             .then(res => {
               if (res.success) {
                 file.status = 'done'
                 uploadSuccessFileCount++
+                console.log('uploadSuccessFileCount++', uploadSuccessFileCount)
                 $notification.success({
                   message: '娑堟伅',
                   description: res.message
@@ -111,8 +140,13 @@
             .finally(() => {
               uploadedFileCount++
               fileList.splice(index, 1, file)
+              // 褰撴枃浠跺叏閮ㄤ笂浼犲畬鎴愬悗
               if (uploadedFileCount === fileList.length) {
-                if (uploadSuccessFileCount > 0) this.$bus.$emit('importFileSuccess', this.uploadParams)
+                // 鑷冲皯鏈変竴涓枃浠朵笂浼犳垚鍔熷悗灏遍渶瑕侀噸鏂板姞杞芥枃妗e垪琛�
+                if (uploadSuccessFileCount > 0) {
+                  $bus.$emit('importFileSuccess', uploadParams)
+                  if (!isUploadMultiple) this.visible = false //鏃犳硶杩炵画鍏ュ簱澶氫釜鐗堟湰鍥犳鍏ュ簱鎴愬姛鍚庡嵆鍙��鍑虹獥鍙�
+                }
                 this.uploading = false
               }
             })
@@ -131,7 +165,6 @@
         if (this[methodName]) {
           this[methodName](treeNodeInfo, tableRowInfo)
           this.title = modalTitle
-
         }
       }
     }

--
Gitblit v1.9.3