Browse Source

上传图片部分界面优化

XU 9 months ago
parent
commit
5869070817

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

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

+ 30 - 10
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" stylr="display:flex;">
+                    <div v-if="scope.row.isEdit" style="display:flex;">
                       <el-upload
                           ref="upload"
-                          v-model:file-list="fileList"
+                          v-model:file-list="fileList2"
                           list-type="picture-card"
                           :action="apiUrl + `/technologyArchives/putProImage?socialNo=` + scope.row.socialNo + `&no=` + scope.row.no"
                           :headers="header"
-                          :on-success="uploadSuccess"
+                          :on-success="uploadSuccess2"
                           :on-preview="handlePreview"
                           :on-remove="handleRemove"
                           :before-upload="beforeUpload"
@@ -1740,6 +1740,7 @@ 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) 
@@ -1785,15 +1786,14 @@ 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] = {
-      ...fileList.value[index],
-      ...response.data,
-    }
+    fileList.value[index].url = "http://172.16.32.197:8077/upload" + url1.value
     ElMessage.success("上传成功");
   } else {
     fileList.value[index].status = 'fail'
@@ -1801,6 +1801,22 @@ 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("")
@@ -1888,11 +1904,13 @@ const callSaveFirstInfo = (row, oldGetTime) => {
         } else {
           queryTechnologyArchives1()
         }
-        setImage1(row)  
+        console.log(url1.value)
+        setImage1(row.socialNo,row.getTime,url1.value)  
       })
     }).catch((action) => {
       if (action === 'cancel') {
         queryTechnologyArchives1()
+        fileList.value = []
       }
     })
   }
@@ -1945,7 +1963,7 @@ const cancelSecondInfo = (row, index) => {
     }
   }
   if(!row.isUpload){
-    fileList.value = []
+    fileList2.value = []
   }
   secondKey.value = Math.random()
 }
@@ -2043,11 +2061,13 @@ const callSaveSecondInfo = (row, oldNo) => {
         } else {
           queryTechnologyArchives2()
         }
-        setImage2(row)  
+        console.log(url2.value)
+        setImage2(row.socialNo,row.no,url2.value)  
       })
     }).catch((action) => {
       if (action === 'cancel') {
         queryTechnologyArchives2()
+        fileList2.value = [];
       }
     })
   }