Explorar o código

1.对于上传中(含暂停、失败等)与上传完成的文件,可以选择删除记录及删除文件

huangxiaodong hai 11 meses
pai
achega
44ed2d0e56

+ 198 - 59
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileRecordViewController.m

@@ -22,6 +22,7 @@
 #import "downloadFileRecordTableView.h"
 #import "MySetViewController.h"
 #import "receiveView.h"
+#import "ComontAlretDeleteTypeViewController.h"
 
 @interface uploadFileRecordViewController ()<UIScrollViewDelegate,UIDocumentPickerDelegate>
 
@@ -366,42 +367,67 @@
         return;
     }
     
+    if(_selectIndex == 1){//上传相关特殊处理
+        
+        NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
+        NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
+
+        KWeakSelf
+        ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
+                                                          initWithTitle:titleStr
+                                                          msg:nil
+                                                          imageStr:nil
+                                                          cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                          okTitle:NSLocalizedString(@"other_confirm",nil)
+                                                          otherTitle:tipStr
+                                                          isOkBtnHighlight:YES
+                                                          didClickOk:^(BOOL isDeleteAll) {
+            [weakSelf didClickDeleteOkButBy:isDeleteAll];
+        } didClickCancel:^{
+            
+        }];
+                                                          
+        curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
+         
+         [self presentViewController:curAlretVC animated:YES completion:^{
+             curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
+         }];
+    }
+    else{
+        NSString *delTipTip = NSLocalizedString(@"box_receive_delete_msg",nil);
+        
+        /*弹窗提示二次确认*/
+        KWeakSelf
+        ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
+                                                                                         msg:delTipTip
+                                                                                    imageStr:nil
+                                                                                 cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                                                     okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
+                                                                                  didClickOk:^{
+            [weakSelf didClickBottomDeleteFunAfterAleartFun];
+        } didClickCancel:^{
+            
+        }];
+        nextVC.modalPresentationStyle = UIModalPresentationCustom;
+      
+        [self presentViewController:nextVC animated:YES completion:^{
+            nextVC.view.superview.backgroundColor = [UIColor clearColor];
+        }];
+    }
     
-    NSString *delTipTip = nil;
-//    if(_selectIndex == 1){
-//        delTipTip = NSLocalizedString(@"File_upload_Record_clear_uploading_Tip_msg",nil);
-//    }
-//    else if(_selectIndex == 2){
-//        delTipTip = NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil);
-//    }
-//    else if(_selectIndex == 3){
-//        delTipTip = NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil);
-//    }
-//    else if(_selectIndex == 4){
-//        delTipTip = NSLocalizedString(@"box_receive_delete_msg",nil);
-//    }
-    
-    delTipTip = NSLocalizedString(@"box_receive_delete_msg",nil);
     
-    /*弹窗提示二次确认*/
-    KWeakSelf
-    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
-                                                                                     msg:delTipTip
-                                                                                imageStr:nil
-                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
-                                                                                 okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
-                                                                              didClickOk:^{
-        [weakSelf didClickBottomDeleteFunAfterAleartFun];
-    } didClickCancel:^{
-        
-    }];
-    nextVC.modalPresentationStyle = UIModalPresentationCustom;
-  
-    [self presentViewController:nextVC animated:YES completion:^{
-        nextVC.view.superview.backgroundColor = [UIColor clearColor];
-    }];
 }
 
+#pragma mark 选中上传任务的删除的处理
+- (void)didClickDeleteOkButBy:(BOOL)isDeleteAll
+{
+    if(isDeleteAll){//删除云机上的文件
+        [self delFileListFunWithData:_leftTableView.selectModelArr];
+    }
+    
+    [self didClickBottomDeleteFunAfterAleartFun];
+    
+}
 
 -(void)didClickBottomDeleteFunAfterAleartFun
 {
@@ -870,26 +896,60 @@
 #pragma mark 点击上传成功的清空记录
 - (void)didClickClearRecordInDoneFun
 {
-    /*弹窗提示二次确认*/
+    NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
+    NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
+
     KWeakSelf
-    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
-                                                                                     msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
-                                                                                imageStr:nil
-                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
-                                                                                 okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
-                                                                              didClickOk:^{
-        [weakSelf ClearAllRecordInDoneFun];
+    ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
+                                                      initWithTitle:titleStr
+                                                      msg:nil
+                                                      imageStr:nil
+                                                      cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                      okTitle:NSLocalizedString(@"other_confirm",nil)
+                                                      otherTitle:tipStr
+                                                      isOkBtnHighlight:YES
+                                                      didClickOk:^(BOOL isDeleteAll) {
+        [weakSelf didClickClearAllRecordInUploadDoneFun:isDeleteAll];
     } didClickCancel:^{
         
     }];
-    nextVC.modalPresentationStyle = UIModalPresentationCustom;
-  
-    [self presentViewController:nextVC animated:YES completion:^{
-        nextVC.view.superview.backgroundColor = [UIColor clearColor];
-    }];
+                                                      
+    curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
+     
+     [self presentViewController:curAlretVC animated:YES completion:^{
+         curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
+     }];
+    
+//    /*弹窗提示二次确认*/
+//    KWeakSelf
+//    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
+//                                                                                     msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
+//                                                                                imageStr:nil
+//                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
+//                                                                                 okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
+//                                                                              didClickOk:^{
+//        [weakSelf ClearAllRecordInDoneFun];
+//    } didClickCancel:^{
+//        
+//    }];
+//    nextVC.modalPresentationStyle = UIModalPresentationCustom;
+//  
+//    [self presentViewController:nextVC animated:YES completion:^{
+//        nextVC.view.superview.backgroundColor = [UIColor clearColor];
+//    }];
 
 }
 
+#pragma mark 确认要删除上传完成的任务
+- (void)didClickClearAllRecordInUploadDoneFun:(BOOL)isDeleteAllType
+{
+    if(isDeleteAllType){
+        [self delFileListFunWithData:_leftTableView.uploadDoneArr];
+    }
+    
+    [self ClearAllRecordInDoneFun];
+}
+
 - (void)ClearAllRecordInDoneFun
 {
     [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadDoneArr withDelCache:YES complete:^(BOOL isSuccess) {
@@ -905,24 +965,58 @@
 #pragma mark 点击上传失败的清空记录
 - (void)didClickClearRecordInFailFun
 {
-    /*弹窗提示二次确认*/
+    NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
+    NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
+
     KWeakSelf
-    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
-                                                                                     msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
-                                                                                imageStr:nil
-                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
-                                                                                 okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
-                                                                              didClickOk:^{
-        [weakSelf ClearAllRecordInFailFun];
+    ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
+                                                      initWithTitle:titleStr
+                                                      msg:nil
+                                                      imageStr:nil
+                                                      cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                      okTitle:NSLocalizedString(@"other_confirm",nil)
+                                                      otherTitle:tipStr
+                                                      isOkBtnHighlight:YES
+                                                      didClickOk:^(BOOL isDeleteAll) {
+        [weakSelf didClickClearAllRecordInUploadFailFun:isDeleteAll];
     } didClickCancel:^{
         
     }];
-    nextVC.modalPresentationStyle = UIModalPresentationCustom;
-  
-    [self presentViewController:nextVC animated:YES completion:^{
-        nextVC.view.superview.backgroundColor = [UIColor clearColor];
-    }];
+                                                      
+    curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
+     
+     [self presentViewController:curAlretVC animated:YES completion:^{
+         curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
+     }];
+    
+//    /*弹窗提示二次确认*/
+//    KWeakSelf
+//    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
+//                                                                                     msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
+//                                                                                imageStr:nil
+//                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
+//                                                                                 okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
+//                                                                              didClickOk:^{
+//        [weakSelf ClearAllRecordInFailFun];
+//    } didClickCancel:^{
+//        
+//    }];
+//    nextVC.modalPresentationStyle = UIModalPresentationCustom;
+//  
+//    [self presentViewController:nextVC animated:YES completion:^{
+//        nextVC.view.superview.backgroundColor = [UIColor clearColor];
+//    }];
+
+}
 
+#pragma mark 确认要删除上传失败的任务
+- (void)didClickClearAllRecordInUploadFailFun:(BOOL)isDeleteAllType
+{
+    if(isDeleteAllType){
+        [self delFileListFunWithData:_leftTableView.uploadfailArr];
+    }
+    
+    [self ClearAllRecordInFailFun];
 }
 
 - (void)ClearAllRecordInFailFun
@@ -1097,7 +1191,7 @@
 }
 
 
-#pragma mark 点击上传失败的清空记录
+#pragma mark 点击下载失败的清空记录
 - (void)didClickClearRecordInDownLoadFailFun
 {
     /*弹窗提示二次确认*/
@@ -1137,4 +1231,49 @@
     });
 }
 
+#pragma mark 删除云机文件数据
+- (void)delFileListFunWithData:(NSArray*)delDataArr
+{
+    NSMutableDictionary*paraDict = [NSMutableDictionary new];
+    
+    if(delDataArr){
+        
+        NSMutableArray*pathArr = [NSMutableArray new];
+        for (uploadFileDataModel *uploadFileDataMod  in delDataArr) {
+            NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
+            
+            if(uploadDefaultPath && uploadDefaultPath.length > 0){
+                //判断最后一个是否是/
+                NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
+                if(![lastStr isEqualToString:@"/"]){
+                    uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
+                }
+                
+                NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename];
+                [pathArr addObject:savePath];
+            }
+            
+        }
+        
+        [paraDict setValue:pathArr forKey:@"path"];
+    }
+    
+    //[self showNewIndicatorWithCanBack:YES canTouch:NO];
+    
+    //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
+    KWeakSelf //@"delFile"
+    [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        //[weakSelf removeNewIndicator];
+        SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
+        if(model && model.status == 0){
+            //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
+        }
+        else{
+            
+        }
+    } failure:^(NSError * _Nonnull error) {
+        //[weakSelf removeNewIndicator];
+    }];
+}
+
 @end

+ 2 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -564,3 +564,5 @@
 "share_number_remainingNumber_tip"   = "剩余次数:";
 "share_report_tip1"   = "封禁原因:";
 "share_report_tip2"   = "投诉封禁";
+"delete_upload_task_title_msg"   = "确认删除选中的任务?";
+"delete_with_cloud_file_msg"   = "同时删除云端的文件";