浏览代码

Revert "上传图片部分界面优化"

This reverts commit 58690708177f7c5b5a91c80f4388857ec88c24a0.
XU 9 月之前
父节点
当前提交
cb6ecf472b

+ 6 - 6
src/api/technology-archives/technology-archives.js

@@ -46,11 +46,11 @@ export function selectTa1(socialNo) {
     })
 }
 
-export function setImage1(socialNo, getTime,url) {
+export function setImage1(data) {
     return request({
         url: '/technologyArchives/setImage1',
-        method: 'get',
-        params: { socialNo, getTime, url },
+        method: 'post',
+        data,
     })
 }
 
@@ -108,11 +108,11 @@ export function selectImage2(socialNo, no) {
     })
 }
 
-export function setImage2(socialNo, no,url) {
+export function setImage2(data) {
     return request({
         url: '/technologyArchives/setImage2',
-        method: 'get',
-        params: { socialNo, no, url },
+        method: 'post',
+        data,
     })
 }
 

+ 10 - 30
src/views/technology-archives/TechnologyArchivesMain.vue

@@ -365,14 +365,14 @@
                 <el-table-column prop="image" label="图片链接" min-width="180">
                   <template v-slot="scope">
                     <!-- <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.image"></el-input> -->
-                    <div v-if="scope.row.isEdit" style="display:flex;">
+                    <div v-if="scope.row.isEdit" stylr="display:flex;">
                       <el-upload
                           ref="upload"
-                          v-model:file-list="fileList2"
+                          v-model:file-list="fileList"
                           list-type="picture-card"
                           :action="apiUrl + `/technologyArchives/putProImage?socialNo=` + scope.row.socialNo + `&no=` + scope.row.no"
                           :headers="header"
-                          :on-success="uploadSuccess2"
+                          :on-success="uploadSuccess"
                           :on-preview="handlePreview"
                           :on-remove="handleRemove"
                           :before-upload="beforeUpload"
@@ -1740,7 +1740,6 @@ const cancelFirstInfo = (row, index) => {
 const apiUrl = import.meta.env.VITE_BASE_URL
 const upload = ref()
 const fileList = ref([])
-const fileList2 = ref([])
 
 const dialogImageUrl = ref('')
 const dialogVisible = ref(false) 
@@ -1786,14 +1785,15 @@ const submitUpload = (row) => {
   }
 }
 
-const url1 = ref("")
 function uploadSuccess(response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) {
-  url1.value = response.data.data.path
   const index = XEUtils.findLastIndexOf(fileList.value, (item: UploadUserFile) => {
     return item.uid === uploadFile.uid;
   })
   if (response.code === 200) {
-    fileList.value[index].url = "http://172.16.32.197:8077/upload" + url1.value
+    fileList.value[index] = {
+      ...fileList.value[index],
+      ...response.data,
+    }
     ElMessage.success("上传成功");
   } else {
     fileList.value[index].status = 'fail'
@@ -1801,22 +1801,6 @@ function uploadSuccess(response: any, uploadFile: UploadFile, uploadFiles: Uploa
   }
 }
 
-const url2 = ref("")
-function uploadSuccess2(response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) {
-  url2.value = response.data.data.path
-  console.log(url2.value)
-  const index = XEUtils.findLastIndexOf(fileList2.value, (item: UploadUserFile) => {
-    return item.uid === uploadFile.uid;
-  })
-  if (response.code === 200) {
-    fileList2.value[index].url = "http://172.16.32.197:8077/upload" + url2.value
-    ElMessage.success("上传成功");
-  } else {
-    fileList2.value[index].status = 'fail'
-    ElMessage.error("上传失败");
-  }
-}
-
 //查看图片
 const srcList = ref([])
 const url = ref("")
@@ -1904,13 +1888,11 @@ const callSaveFirstInfo = (row, oldGetTime) => {
         } else {
           queryTechnologyArchives1()
         }
-        console.log(url1.value)
-        setImage1(row.socialNo,row.getTime,url1.value)  
+        setImage1(row)  
       })
     }).catch((action) => {
       if (action === 'cancel') {
         queryTechnologyArchives1()
-        fileList.value = []
       }
     })
   }
@@ -1963,7 +1945,7 @@ const cancelSecondInfo = (row, index) => {
     }
   }
   if(!row.isUpload){
-    fileList2.value = []
+    fileList.value = []
   }
   secondKey.value = Math.random()
 }
@@ -2061,13 +2043,11 @@ const callSaveSecondInfo = (row, oldNo) => {
         } else {
           queryTechnologyArchives2()
         }
-        console.log(url2.value)
-        setImage2(row.socialNo,row.no,url2.value)  
+        setImage2(row)  
       })
     }).catch((action) => {
       if (action === 'cancel') {
         queryTechnologyArchives2()
-        fileList2.value = [];
       }
     })
   }