duy hace 2 meses
padre
commit
1c7f724acb

+ 11 - 0
src/api/modules/data-fill/wbs.js

@@ -532,4 +532,15 @@ export default {
             data: form,
         })
     },
+    //上传文件后排序接口
+    async addFileSort(form) {
+        return HcApi(
+            {
+                url: '/api/exceltab/add-bussfile-node-sort',
+                   method: 'post',
+                data: form,
+            },
+            false,
+        )
+    },
 }

+ 51 - 2
src/views/data-fill/components/HcUpload.vue

@@ -328,9 +328,10 @@ const submitUpload = async () => {
   fileListData.value.forEach((file) => {
 
     
-    formData.append('files', file.raw || file) // 确保 file.raw 是 File 对象
+    formData.append('files', file.raw ) // 确保 file.raw 是 File 对象
   })
 
+console.log( fileListData.value, ' fileListData.value')
 
 
   // 3. 发送请求
@@ -340,7 +341,7 @@ const submitUpload = async () => {
   formData.append('classify', uploadData.value.classify)
   formData.append('pkeyId', uploadData.value.pkeyId)
     formData.append('nodeId', uploadData.value.nodeId)
-
+    formData.append('type', 2)
   formData.append('contractId', uploadData.value.contractId)
     formData.append('projectId', uploadData.value.projectId)
     const { error, code, msg } = await wbsApi.addBussFile(formData) // 修改这里
@@ -348,6 +349,7 @@ const submitUpload = async () => {
      subLoading.value = false
     if (!error && code === 200) {
       window?.$message?.success('上传成功') 
+         sortFile()
       emit('change', { type: 'success' })
 
     } else {
@@ -365,6 +367,7 @@ const submitUpload = async () => {
         subLoading.value = false
     if (!error && code === 200) {
       window?.$message?.success('上传成功') 
+      sortFile()
       emit('change', { type: 'success' })
 
     } else {
@@ -376,6 +379,52 @@ const submitUpload = async () => {
  
 
  
+}
+//上传文件后排序
+const sortFile = async ()=>{
+  if (fileListData.value.length <= 0) {
+    window.$message.warning('请先上传文件')
+    return
+  }
+  let list = []
+  fileListData.value.forEach((file) => {
+    list.push({
+      name:file.name,
+  
+    })
+  })
+  let obj1 = {
+    list:list,
+   
+    nodeId:uploadData.value.nodeId,
+    contractId:uploadData.value.contractId,
+    classify:uploadData.value.classify,
+    type:uploadData.value.type,
+   
+ 
+
+  }
+    let obj2 = {
+    list:list,
+    pkeyId:uploadData.value.pkeyId,
+    nodeId:uploadData.value.nodeId,
+    contractId:uploadData.value.contractId,
+    classify:uploadData.value.classify,
+    projectId:uploadData.value.projectId,
+     type:2,
+
+  }
+          const { error, code, msg } = await (isListFile.value
+            ? wbsApi.addFileSort(obj1)
+            : wbsApi.addFileSort(obj2))
+        uploadDisabled.value = false
+        if (!error && code === 200) {
+            window?.$message?.success('排序成功')
+           
+        } else {
+            window?.$message?.error(msg || '操作失败')
+            
+        }
 }
 </script>
 

+ 1 - 1
src/views/data-fill/wbs.vue

@@ -1301,7 +1301,7 @@
             </div>
             <template #footer>
                 <el-button @click="attachmentModal = false">关闭</el-button>
-                <el-button type="primary" :loading="saveFileOrderLoad" @click="saveFileOrder">确定排序</el-button>
+                <el-button type="primary" :loading="saveFileOrderLoad" :disabled="attachmentList.length === 0" @click="saveFileOrder">确定排序</el-button>
             </template>
         </hc-new-dialog>
         <!-- 上传文件 -->