Browse Source

删除文件修改

duy 3 weeks ago
parent
commit
cc2776c75c
1 changed files with 17 additions and 5 deletions
  1. 17 5
      src/views/other-file/image-form.vue

+ 17 - 5
src/views/other-file/image-form.vue

@@ -407,11 +407,17 @@ const previewModalClose = () => {
 }
 
 //删除上传的文件
-const uploadsDel = async ({ link }) => {
-    const arrUrl = link.split('.com//')
-    if (arrUrl.length > 0) {
-        await ossApi.removeFile({ fileName: arrUrl[1] }, false)
-    }
+const uploadsDel = async (data) => {
+    
+    
+    // const arrUrl = link.split('.com//')
+    // if (arrUrl.length > 0) {
+    //     await ossApi.removeFile({ fileName: arrUrl[1] }, false)
+    // }
+    const { link } = data
+    await ossApi.removeFile({ fileName:link }, false)
+     uploadFileList.value = uploadFileList.value.filter((item) => item.url !== data.link)
+
 }
 
 //上传记录表格
@@ -444,11 +450,17 @@ const verifyFormData = async (log) => {
     formData.contractId = contractId
     formData.type = fileType.value || '2'
     const fileList = uploadFileList.value
+
+    
+    
     //处理文件
     let imageUrl = '', pdfUrl = ''
     if (fileList.length > 0) {
         imageUrl = arrToKey(fileList, 'url', ',')
         pdfUrl = arrToKey(fileList, 'pdfUrl', ',')
+    } else {
+        window.$message?.warning('请先上传文件')
+        return
     }
     //设置数据
     formData.imageUrl = imageUrl