Browse Source

fix: 编辑临时收货逻辑调整

lyc 3 weeks ago
parent
commit
d6401ae447
1 changed files with 12 additions and 3 deletions
  1. 12 3
      src/views/accountPeriod/tmpReceiveAdd.vue

+ 12 - 3
src/views/accountPeriod/tmpReceiveAdd.vue

@@ -267,7 +267,7 @@
                   <span 
                     v-show="url" 
                     class="btn-delete"
-                    @click="handlePictureCardDelete(index)"
+                    @click="handlePictureCardDelete(index, url)"
                   >
                     <el-icon><Delete /></el-icon>
                   </span>
@@ -412,6 +412,9 @@ const handleOnChangeUpload: UploadProps["onChange"] = (uploadFile) => {
     return false;
   }
   // console.log(uploadFile, ":uploadFile");
+  // if (addTmpReceiverForm.type === TmpReceiverType.EDIT) {
+  //   receiveState.imageUploadUrlList = []
+  // }
   if (uploadFile.raw) {
     const imageUrl = URL.createObjectURL(uploadFile.raw);
     receiveState.imageUploadUrlList.push(imageUrl)
@@ -434,9 +437,14 @@ const handlePictureCardPreview = (index: number) => {
   })
 };
 // 删除凭证照片
-const handlePictureCardDelete = (index: number) => {
+const handlePictureCardDelete = (index: number, url: string) => {
+  const findIndex = receiveState.imageUploadUrlList.findIndex(item => item === url)
   receiveState.imageUploadUrlList.splice(index, 1)
-  addTmpReceiverForm.files && addTmpReceiverForm.files.splice(index, 1)
+  if (addTmpReceiverForm.type === TmpReceiverType.EDIT) {
+    url.includes('blob:') && addTmpReceiverForm.files && addTmpReceiverForm.files.splice(findIndex, 1)
+  } else {
+    addTmpReceiverForm.files && addTmpReceiverForm.files.splice(index, 1)
+  }
 }
 
 // 隐藏
@@ -472,6 +480,7 @@ const show = (type: number, data: Recordable) => {
       });
       addTmpReceiverForm.type = type;
       addTmpReceiverForm.customerId = String(addTmpReceiverForm.customerId);
+      addTmpReceiverForm.files = []
       receiveState.imageUploadUrlList = data.uploadFileList || []
     }
   });