uploadFileRecordViewController.m 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. //
  2. // uoloadFileRecordViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/13.
  6. //
  7. #import "uploadFileRecordViewController.h"
  8. #import "uploadFileManager.h"
  9. #import "uploadFileDataModel.h"
  10. #import "uploadFileRecordheadView.h"
  11. //#import "uploadFileRecordBodyView.h"
  12. #import "uploadFileRecordEditBottomView.h"
  13. #import "uploadFileRecordBgScorllView.h"
  14. #import "uploadFileRecordTableView.h"
  15. #import "uploadFileRecordTableViewHeadView.h"
  16. #import "ComontAlretViewController.h"
  17. #import "backupsFilerecordTableView.h"
  18. #import "backupsFileManager.h"
  19. #import "photosBackupsTaskModel.h"
  20. @interface uploadFileRecordViewController ()<UIScrollViewDelegate>
  21. //选中的项
  22. @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
  23. @property (nonatomic, strong) uploadFileRecordheadView *uploadFileRecordheadV;
  24. //@property (nonatomic, strong) uploadFileRecordBodyView *uploadFileRecordBodyV;
  25. @property (nonatomic, strong) uploadFileRecordBgScorllView *uploadFileRecordBgScorllV;
  26. @property (nonatomic, strong) uploadFileRecordTableView *leftTableView;
  27. @property (nonatomic, strong) uploadFileRecordTableView *midTableView;
  28. @property (nonatomic, strong) backupsFilerecordTableView *rightTableView;
  29. @property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
  30. @property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView;
  31. //@property (nonatomic, strong) NSMutableArray *allDataArr;
  32. @property (nonatomic, strong) UIButton *leftButton;
  33. @property (nonatomic, strong) UIButton *rightButton;
  34. @property (nonatomic, strong) uploadFileRecordEditBottomView *uploadFileRecordEditBottomV;
  35. @property (nonatomic,assign) BOOL isEditType;
  36. @property(nonatomic,assign) NSInteger selectIndex;// 从1开始
  37. @end
  38. @implementation uploadFileRecordViewController
  39. - (void)viewDidLoad {
  40. [super viewDidLoad];
  41. // Do any additional setup after loading the view.
  42. //[self.view setBackgroundColor:HWF5F7FAColor];
  43. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:) name:uploadFileRefreshNotification object:nil];
  44. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileDeteleFun:) name:uploadFileDeteleNotification object:nil];
  45. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backupsFileRefreshFun:) name:backupsFileRefreshNotification object:nil];
  46. [self.view setBackgroundColor:[UIColor whiteColor]];
  47. self.titleLabel.text = NSLocalizedString(@"my_set_no_File_Transfer_List",nil) ;
  48. [self.toolBar setHidden:YES];
  49. [self.navigationBar setHidden:YES];
  50. [self.navBarBGView setHidden:NO];
  51. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  52. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  53. [self initbaseUIFun];
  54. [self getDataInDatabaseFun];
  55. [self getBackupsDatabaseFun];
  56. });
  57. }
  58. - (void)viewWillAppear:(BOOL)animated
  59. {
  60. [super viewWillAppear:animated];
  61. }
  62. #pragma mark UI
  63. - (void)initbaseUIFun
  64. {
  65. _uploadFileRecordheadV = [[uploadFileRecordheadView alloc] init];
  66. [self.view addSubview:_uploadFileRecordheadV];
  67. [_uploadFileRecordheadV mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.mas_equalTo(15);
  69. make.right.mas_equalTo(-15);
  70. make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(15.0);
  71. make.height.mas_equalTo(50);
  72. }];
  73. _selectIndex = 1;
  74. KWeakSelf
  75. #pragma mark 头部点击事件
  76. _uploadFileRecordheadV.didClickButFun = ^(NSInteger index) {
  77. [weakSelf didClickHeadFun: index];
  78. };
  79. // CGRect rrr2= self.navBarBGView.frame;
  80. // CGRect rrr= _uploadFileRecordheadV.frame;
  81. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  82. _uploadFileRecordBgScorllV= [[uploadFileRecordBgScorllView alloc] init];
  83. _uploadFileRecordBgScorllV.delegate = self;
  84. [self.view addSubview:_uploadFileRecordBgScorllV];
  85. [_uploadFileRecordBgScorllV mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.mas_equalTo(0);
  87. make.right.mas_equalTo(0);
  88. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  89. make.bottom.mas_equalTo(0);
  90. }];
  91. _leftTableView = [[uploadFileRecordTableView alloc] init];
  92. _leftTableView.tag =100;
  93. [_uploadFileRecordBgScorllV addSubview:_leftTableView];
  94. [_leftTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.mas_equalTo(SCREEN_W*0.0);
  96. make.width.mas_equalTo(SCREEN_W);
  97. make.top.mas_equalTo(0);
  98. make.height.mas_equalTo(curHeight);
  99. }];
  100. _leftTableView.didLongPressClick = ^{
  101. weakSelf.isEditType = YES;
  102. };
  103. _midTableView = [[uploadFileRecordTableView alloc] init];
  104. _midTableView.tag = 101;
  105. [_uploadFileRecordBgScorllV addSubview:_midTableView];
  106. [_midTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.mas_equalTo(SCREEN_W*1.0);
  108. make.width.mas_equalTo(SCREEN_W);
  109. make.top.mas_equalTo(0);
  110. make.height.mas_equalTo(curHeight);
  111. }];
  112. _midTableView.didLongPressClick = ^{
  113. weakSelf.isEditType = YES;
  114. };
  115. _rightTableView = [[backupsFilerecordTableView alloc] init];
  116. _rightTableView.tag = 102;
  117. [_uploadFileRecordBgScorllV addSubview:_rightTableView];
  118. [_rightTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.left.mas_equalTo(SCREEN_W*2.0);
  120. make.width.mas_equalTo(SCREEN_W);
  121. make.top.mas_equalTo(0);
  122. make.height.mas_equalTo(curHeight);
  123. }];
  124. _rightTableView.didLongPressClick = ^{
  125. // weakSelf.isEditType = YES;
  126. };
  127. _rightTableView.didClickReUploadBlock = ^(photosBackupsTaskModel* _Nonnull model) {
  128. // [weakSelf didClickReUploadFun:model];
  129. };
  130. _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*3.0, curHeight);
  131. _leftHeadView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  132. _leftTableView.tableHeaderView = _leftHeadView;
  133. _leftHeadView.didClickButFun = ^{
  134. [weakSelf didClickAllSuspendInLoadingFun];
  135. };
  136. _midHeadView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  137. _midTableView.tableHeaderView = _midHeadView;
  138. _midHeadView.didClickButFun = ^{
  139. [weakSelf didClickClearRecordInDoneFun];
  140. };
  141. _leftButton = [[UIButton alloc] init];
  142. [_leftButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  143. _leftButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  144. _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  145. [_leftButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  146. _leftButton.tag = 1;
  147. [_leftButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  148. _leftButton.hidden = YES;
  149. [self.navBarBGView addSubview:_leftButton];
  150. [_leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
  151. make.width.mas_equalTo(80);
  152. make.left.mas_equalTo(15);
  153. make.height.mas_equalTo(self.backBtn.mas_height);
  154. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  155. }];
  156. _rightButton = [[UIButton alloc] init];
  157. [_rightButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  158. _rightButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  159. _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  160. [_rightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  161. _rightButton.tag = 2;
  162. [_rightButton setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
  163. _rightButton.hidden = YES;
  164. [self.navBarBGView addSubview:_rightButton];
  165. [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  166. make.width.mas_equalTo(80);
  167. make.right.mas_equalTo(-15);
  168. make.height.mas_equalTo(self.backBtn.mas_height);
  169. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  170. }];
  171. _uploadFileRecordEditBottomV = [[uploadFileRecordEditBottomView alloc] init];
  172. _uploadFileRecordEditBottomV.hidden = YES;
  173. [self.view addSubview:_uploadFileRecordEditBottomV];
  174. [_uploadFileRecordEditBottomV mas_makeConstraints:^(MASConstraintMaker *make) {
  175. make.left.mas_equalTo(0);
  176. make.right.mas_equalTo(0);
  177. make.height.mas_equalTo(60 + safeArea);
  178. make.bottom.mas_equalTo(0);
  179. }];
  180. _uploadFileRecordEditBottomV.didClickButFun = ^{
  181. //[weakSelf.uploadFileRecordBodyV deleteModelOneByOneFun];
  182. [weakSelf didClickBottomDeleteFun];
  183. };
  184. }
  185. #pragma mark 底部删除点击
  186. -(void)didClickBottomDeleteFun
  187. {
  188. NSMutableArray *selectModelArr = nil;
  189. if(_selectIndex == 1){
  190. selectModelArr = _leftTableView.selectModelArr;
  191. }
  192. else if(_selectIndex == 2){
  193. selectModelArr = _midTableView.selectModelArr;
  194. [_midTableView deleteModelOneByOneFun];
  195. }
  196. else if(_selectIndex == 3){
  197. //selectModelArr = _rightTableView.selectModelArr;
  198. }
  199. if(!selectModelArr || selectModelArr.count== 0){
  200. [[iToast makeText:NSLocalizedString(@"File_upload_Record_delete_noFile",nil)] show];
  201. return;
  202. }
  203. NSString *delTipTip = nil;
  204. if(_selectIndex == 1){
  205. delTipTip = NSLocalizedString(@"File_upload_Record_clear_uploading_Tip_msg",nil);
  206. }
  207. else if(_selectIndex == 2){
  208. delTipTip = NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil);
  209. }
  210. else if(_selectIndex == 3){
  211. delTipTip = NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil);
  212. }
  213. /*弹窗提示二次确认*/
  214. KWeakSelf
  215. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  216. msg:delTipTip
  217. imageStr:nil
  218. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  219. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  220. didClickOk:^{
  221. [weakSelf didClickBottomDeleteFunAfterAleartFun];
  222. } didClickCancel:^{
  223. }];
  224. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  225. [self presentViewController:nextVC animated:YES completion:^{
  226. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  227. }];
  228. }
  229. -(void)didClickBottomDeleteFunAfterAleartFun
  230. {
  231. if(_selectIndex == 1){
  232. [_leftTableView deleteModelOneByOneFun];
  233. }
  234. else if(_selectIndex == 2){
  235. [_midTableView deleteModelOneByOneFun];
  236. }
  237. else if(_selectIndex == 3){
  238. //[_rightTableView deleteModelOneByOneFun];
  239. }
  240. }
  241. #pragma mark 头部点击 背景滚动
  242. - (void)didClickHeadFun:(NSInteger)index
  243. {
  244. //_uploadFileRecordBodyV.selectIndex = index;
  245. _selectIndex = index;
  246. _uploadFileRecordBgScorllV.contentOffset = CGPointMake(SCREEN_W *(index -1), 0);
  247. }
  248. - (void)didScorllBodyFun:(NSInteger)index
  249. {
  250. _uploadFileRecordheadV.selectIndex = index;
  251. _selectIndex = index;
  252. }
  253. #pragma mark 背景滚动代理
  254. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  255. {
  256. if(scrollView != _uploadFileRecordBgScorllV) return;
  257. CGFloat x = scrollView.contentOffset.x;
  258. NSInteger index = (x+1)/SCREEN_W;
  259. index += 1;//因为头部是从1开始的
  260. //HLog(@"index:%ld",index);
  261. [self didScorllBodyFun:index];
  262. }
  263. -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
  264. {
  265. [self realGotoUploadFile:indexPathsForSelectedItems];
  266. // KWeakSelf
  267. // [[uploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
  268. //
  269. // [weakSelf realGotoUploadFile:indexPathsForSelectedItems];
  270. // }];
  271. }
  272. - (void)realGotoUploadFile:(NSMutableArray *)indexPathsForSelectedItems
  273. {
  274. KWeakSelf
  275. [[uploadFileManager shareInstance] handlTZAssetModelToUploadFileDataFunBy:indexPathsForSelectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  276. //NSMutableArray *arr1 = Arr;
  277. //[weakSelf setRecordBodyDataFunBy:arr1];
  278. //weakSelf.leftTableView.curDataArr = Arr[0];
  279. weakSelf.leftTableView.outSideDataArr = Arr;
  280. [weakSelf.leftTableView reloadDataFun];
  281. //weakSelf.midTableView.curDataArr = Arr[1];
  282. [weakSelf.midTableView reloadDataFun];
  283. // weakSelf.rightTableView.curDataArr = Arr[2];
  284. // [weakSelf.rightTableView reloadDataFun];
  285. }];
  286. }
  287. #pragma mark 读取数据库数据
  288. - (void)getDataInDatabaseFun
  289. {
  290. KWeakSelf
  291. [[uploadFileManager shareInstance] getDataInDatabaseFun:_isNotUploadingType complete:^(NSMutableArray * _Nonnull Arr) {
  292. //[weakSelf setRecordBodyDataFunBy:Arr];
  293. if(!Arr ||Arr.count != 3){
  294. HLog(@"数据库出错\n\n\n");
  295. return;
  296. }
  297. NSMutableArray *curLoadIngArr = Arr[0];
  298. //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  299. if(self->_isNotUploadingType && ![uploadFileManager shareInstance].isUploadIngType){
  300. for (uploadFileDataModel * curModel in curLoadIngArr) {
  301. curModel.curUploadStateType = uploadStateSuspend;
  302. }
  303. }
  304. mainBlock(^{
  305. weakSelf.leftTableView.outSideDataArr = Arr;
  306. [weakSelf.leftTableView reloadDataFun];
  307. // weakSelf.midTableView.curDataArr = Arr[1];
  308. // [weakSelf.midTableView reloadDataFun];
  309. [weakSelf handleUploadingRightButFun];
  310. });
  311. }];
  312. // _allDataArr = [NSMutableArray new];
  313. //
  314. // KWeakSelf
  315. // [uploadFileDataModel bg_findAllAsync:upLoadFile_image_tableName complete:^(NSArray * _Nullable array) {
  316. // NSMutableArray *failArr = [NSMutableArray new];
  317. // NSMutableArray *doneArr = [NSMutableArray new];
  318. // NSMutableArray *otherArr = [NSMutableArray new];
  319. //
  320. // for (uploadFileDataModel * curModel in array) {
  321. //
  322. // //图片 和视频 还原
  323. // if(curModel.curUploadFileType == uploadFileTypeImage){
  324. // NSString*pathStr = [cachesFileManager getFilePathWithName:curModel.filename type:uploadFileTypeImage];
  325. // curModel.imageData = [NSData dataWithContentsOfFile:pathStr];
  326. // }
  327. // else if(curModel.curUploadFileType == uploadFileTypeVideo){
  328. // NSString*pathStr = [cachesFileManager getFilePathWithName:curModel.videoFirstImageName type:uploadFileTypeImage];
  329. // curModel.imageData = [NSData dataWithContentsOfFile:pathStr];
  330. //
  331. // if(curModel.curUploadStateType != uploadStateDone){
  332. // NSString*videoPathStr = [cachesFileManager getFilePathWithName:curModel.filename type:uploadFileTypeVideo];
  333. // curModel.videoData = [NSData dataWithContentsOfFile:videoPathStr];
  334. // }
  335. // }
  336. //
  337. // if(curModel.curUploadStateType == uploadStateFail){
  338. // [failArr addObject:curModel];
  339. // }
  340. // else if(curModel.curUploadStateType == uploadStateDone){
  341. // [doneArr addObject:curModel];
  342. // }
  343. // else{
  344. // //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  345. // if(self->_isNotUploadingType && ![uploadFileManager shareInstance].isUploadIngType){
  346. // curModel.curUploadStateType = uploadStateSuspend;
  347. // }
  348. //
  349. // [otherArr addObject:curModel];
  350. // }
  351. // }
  352. //
  353. // [self->_allDataArr addObject:otherArr];
  354. // [self->_allDataArr addObject:doneArr];
  355. // [self->_allDataArr addObject:failArr];
  356. //
  357. // self->_uploadFileRecordBodyV.allDataArr = self->_allDataArr;
  358. // }];
  359. }
  360. - (void)getBackupsDatabaseFun
  361. {
  362. KWeakSelf
  363. [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  364. mainBlock(^{
  365. weakSelf.rightTableView.curDataArr = array;
  366. });
  367. }];
  368. }
  369. #pragma mark 处理上传中的 全部暂停等
  370. - (void)handleUploadingRightButFun
  371. {
  372. // if(_leftTableView.curDataArr.count ==0){
  373. // //不处理
  374. // }
  375. // else{
  376. // NSMutableArray *upLoadingArr = [uploadFileManager shareInstance].fileModelDataArr;
  377. // BOOL isUploadIngType = [uploadFileManager shareInstance].isUploadIngType;
  378. //
  379. // if(!upLoadingArr ||upLoadingArr.count == 0 || !isUploadIngType){//不是上传状态
  380. // _leftHeadView.rightButton.selected = YES;
  381. // }
  382. // else if(upLoadingArr.count == _leftTableView.curDataArr.count){
  383. // _leftHeadView.rightButton.selected = NO;
  384. // }
  385. // else{
  386. // _leftHeadView.rightButton.selected = YES;
  387. // }
  388. // }
  389. }
  390. #pragma mark 给RecordBody 设置数据
  391. //- (void)setRecordBodyDataFunBy:(NSMutableArray*)arr
  392. //{
  393. // if(!arr || ![arr isKindOfClass:[NSMutableArray class]] || arr.count !=3){
  394. // return;
  395. // }
  396. // //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  397. // if(self->_isNotUploadingType && ![uploadFileManager shareInstance].isUploadIngType){
  398. // NSMutableArray *otherArr = arr[0];
  399. // for (uploadFileDataModel * curModel in otherArr) {
  400. // curModel.curUploadStateType = uploadStateSuspend;
  401. // }
  402. //
  403. // }
  404. //
  405. // //_uploadFileRecordBodyV.allDataArr = arr;
  406. //}
  407. - (void)uploadFileRefreshFun:(NSNotification*)not
  408. {
  409. uploadFileDataModel *uploadFileDataMod = [not object];
  410. //HLog(@"%@",uploadFileDataMod);
  411. uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  412. //UI和数据还没准备好
  413. // if(!_leftTableView
  414. // && (uploadFileDataMod.curUploadStateType == uploadStateFail
  415. // ||uploadFileDataMod.curUploadStateType == uploadStateDone)){
  416. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  417. // [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:uploadFileDataMod];
  418. // });
  419. //
  420. // return;
  421. // }
  422. //
  423. // if(_leftTableView && [uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
  424. //
  425. // NSMutableArray *curArr = _leftTableView.curDataArr;
  426. //
  427. // NSInteger index = 0;
  428. // for (uploadFileDataModel*mod in curArr) {
  429. // //HLog(@"%@ bg_id:%@ ?=? %@",mod.filename,mod.bg_id,uploadFileDataMod.bg_id);
  430. //
  431. // if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  432. //
  433. // if(uploadFileDataMod.curUploadStateType == uploadStateDone){
  434. // [curArr removeObject:mod];
  435. //
  436. // NSMutableArray *doneArr = _midTableView.curDataArr;
  437. // [doneArr insertObject:uploadFileDataMod atIndex:0];
  438. //
  439. // //全部上传了
  440. // if(curArr.count == 0){
  441. //
  442. // }
  443. // }
  444. // else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
  445. // [curArr removeObject:mod];
  446. //
  447. //// NSMutableArray *failArr = _rightTableView.curDataArr;
  448. //// [failArr insertObject:uploadFileDataMod atIndex:0];
  449. // }
  450. // else{
  451. // [curArr replaceObjectAtIndex:index withObject:uploadFileDataMod];
  452. // }
  453. //
  454. // break;
  455. // }
  456. //
  457. // index++;
  458. // }
  459. //
  460. // //精准刷新
  461. // if(uploadFileDataMod.curUploadStateType == uploadStateDone){
  462. // //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:_allDataArr[1] withfailArr:nil];
  463. //
  464. // [self.leftTableView reloadDataFun];
  465. //
  466. // [self.midTableView reloadDataFun];
  467. // }
  468. // else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
  469. // //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:_allDataArr[2]];
  470. //
  471. // [self.leftTableView reloadDataFun];
  472. //
  473. // [self.rightTableView reloadDataFun];
  474. // }
  475. // else{
  476. // //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
  477. //
  478. // [self.leftTableView reloadDataFun];
  479. //
  480. // }
  481. // }
  482. }
  483. - (void)uploadFileDeteleFun:(NSNotification*)not
  484. {
  485. uploadFileDataModel *uploadFileDataMod = [not object];
  486. //HLog(@"%@",uploadFileDataMod);
  487. //UI和数据还没准备好
  488. // if(!_leftTableView){
  489. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  490. // [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:uploadFileDataMod];
  491. // });
  492. //
  493. // return;
  494. // }
  495. //
  496. // if([uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
  497. //
  498. // NSMutableArray *curArr = _leftTableView.curDataArr;
  499. //
  500. // NSInteger index = 0;
  501. // for (uploadFileDataModel*mod in curArr) {
  502. // HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
  503. //
  504. // if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  505. // [curArr removeObject:mod];
  506. // break;
  507. // }
  508. //
  509. // index++;
  510. // }
  511. //
  512. // //精准刷新
  513. // //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
  514. // [self.leftTableView reloadDataFun];
  515. // }
  516. }
  517. #pragma mark 按钮点击
  518. - (void)didClickButFun:(UIButton*)but
  519. {
  520. NSInteger tag = but.tag;
  521. if(tag == 1){
  522. self.isEditType = NO;
  523. //self.uploadFileRecordBodyV.isEditType = NO;
  524. if(_selectIndex == 1){
  525. self.leftTableView.isEditType = NO;
  526. }
  527. else if(_selectIndex == 2){
  528. self.midTableView.isEditType = NO;
  529. }
  530. else if(_selectIndex == 3){
  531. //self.rightTableView.isEditType = NO;
  532. }
  533. }
  534. else{
  535. //self.uploadFileRecordBodyV.isSelectAllType = YES;
  536. if(_selectIndex == 1){
  537. self.leftTableView.isSelectAllType = YES;
  538. }
  539. else if(_selectIndex == 2){
  540. self.midTableView.isSelectAllType = YES;
  541. }
  542. else if(_selectIndex == 3){
  543. //self.rightTableView.isSelectAllType = YES;
  544. }
  545. }
  546. }
  547. -(void)setIsEditType:(BOOL)isEditType
  548. {
  549. _isEditType = isEditType;
  550. _leftButton.hidden = !isEditType;
  551. _rightButton.hidden = !isEditType;
  552. self.backBtn.hidden = isEditType;
  553. _uploadFileRecordEditBottomV.hidden = !isEditType;
  554. _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
  555. _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
  556. _leftHeadView.rightButton.userInteractionEnabled = !isEditType;
  557. if(_isEditType){
  558. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea);
  559. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  560. make.left.mas_equalTo(0);
  561. make.right.mas_equalTo(0);
  562. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  563. make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
  564. }];
  565. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  566. make.left.mas_equalTo(SCREEN_W*0.0);
  567. make.width.mas_equalTo(SCREEN_W);
  568. make.top.mas_equalTo(0);
  569. make.height.mas_equalTo(curHeight);
  570. }];
  571. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  572. make.left.mas_equalTo(SCREEN_W*1.0);
  573. make.width.mas_equalTo(SCREEN_W);
  574. make.top.mas_equalTo(0);
  575. make.height.mas_equalTo(curHeight);
  576. }];
  577. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  578. make.left.mas_equalTo(SCREEN_W*2.0);
  579. make.width.mas_equalTo(SCREEN_W);
  580. make.top.mas_equalTo(0);
  581. make.height.mas_equalTo(curHeight);
  582. }];
  583. }
  584. else{
  585. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  586. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  587. make.left.mas_equalTo(0);
  588. make.right.mas_equalTo(0);
  589. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  590. make.bottom.mas_equalTo(0);
  591. }];
  592. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  593. make.left.mas_equalTo(SCREEN_W*0.0);
  594. make.width.mas_equalTo(SCREEN_W);
  595. make.top.mas_equalTo(0);
  596. make.height.mas_equalTo(curHeight);
  597. }];
  598. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  599. make.left.mas_equalTo(SCREEN_W*1.0);
  600. make.width.mas_equalTo(SCREEN_W);
  601. make.top.mas_equalTo(0);
  602. make.height.mas_equalTo(curHeight);
  603. }];
  604. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  605. make.left.mas_equalTo(SCREEN_W*2.0);
  606. make.width.mas_equalTo(SCREEN_W);
  607. make.top.mas_equalTo(0);
  608. make.height.mas_equalTo(curHeight);
  609. }];
  610. }
  611. }
  612. #pragma mark 点击上传中的全部暂停
  613. - (void)didClickAllSuspendInLoadingFun
  614. {
  615. _leftHeadView.rightButton.selected = !_leftHeadView.rightButton.selected;
  616. // if(_leftHeadView.rightButton.selected){
  617. // [[uploadFileManager shareInstance] suspendUploadFileFun:YES];
  618. // }
  619. // else{
  620. // NSMutableArray *leftArr = _leftTableView.curDataArr;
  621. // [[uploadFileManager shareInstance] reUploadFileFunBy:leftArr];
  622. // }
  623. }
  624. #pragma mark 点击上传成功的清空记录
  625. - (void)didClickClearRecordInDoneFun
  626. {
  627. /*弹窗提示二次确认*/
  628. KWeakSelf
  629. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  630. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  631. imageStr:nil
  632. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  633. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  634. didClickOk:^{
  635. [weakSelf ClearAllRecordInDoneFun];
  636. } didClickCancel:^{
  637. }];
  638. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  639. [self presentViewController:nextVC animated:YES completion:^{
  640. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  641. }];
  642. }
  643. - (void)ClearAllRecordInDoneFun
  644. {
  645. // [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_midTableView.curDataArr withDelCache:YES complete:^(BOOL isSuccess) {
  646. // HLog(@"isSuccess:%d",isSuccess);
  647. //
  648. // if(isSuccess){
  649. // [self->_midTableView.curDataArr removeAllObjects];
  650. // [self->_midTableView reloadDataFun];
  651. // }
  652. // }];
  653. }
  654. #pragma mark 点击上传失败的清空记录
  655. - (void)didClickClearRecordInFailFun
  656. {
  657. /*弹窗提示二次确认*/
  658. KWeakSelf
  659. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  660. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  661. imageStr:nil
  662. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  663. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  664. didClickOk:^{
  665. [weakSelf ClearAllRecordInFailFun];
  666. } didClickCancel:^{
  667. }];
  668. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  669. [self presentViewController:nextVC animated:YES completion:^{
  670. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  671. }];
  672. }
  673. - (void)ClearAllRecordInFailFun
  674. {
  675. // [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_rightTableView.curDataArr withDelCache:YES complete:^(BOOL isSuccess) {
  676. // HLog(@"isSuccess:%d",isSuccess);
  677. //
  678. // if(isSuccess){
  679. // [self->_rightTableView.curDataArr removeAllObjects];
  680. // [self->_rightTableView reloadDataFun];
  681. // }
  682. // }];
  683. }
  684. #pragma mark 失败重传
  685. - (void)didClickReUploadFun:(uploadFileDataModel*)model{
  686. if(![model isKindOfClass:[uploadFileDataModel class]]){
  687. return;
  688. }
  689. // NSMutableArray *curArr = _leftTableView.curDataArr;
  690. //
  691. // BOOL isNeedToAdd = YES;
  692. //
  693. // for (uploadFileDataModel*mod in curArr) {
  694. // if(mod.bg_id.integerValue == model.bg_id.integerValue){
  695. // isNeedToAdd = NO;
  696. // break;
  697. // }
  698. // }
  699. //
  700. // if(isNeedToAdd){
  701. // [curArr addObject:model];
  702. // }
  703. //
  704. // [_leftTableView reloadDataFun];
  705. }
  706. //-(void)backBtnPressed{
  707. // [super backBtnPressed];
  708. //
  709. // _indexPathsForSelectedItems = nil;
  710. // _uploadFileRecordheadV = nil;
  711. // //_uploadFileRecordBodyV = nil;
  712. // //_allDataArr = nil;
  713. // _uploadFileRecordEditBottomV = nil;
  714. //
  715. //}
  716. - (void)backupsFileRefreshFun:(NSNotification*)not
  717. {
  718. photosBackupsTaskModel *photosBackupsTaskMod = [not object];
  719. //HLog(@"%@",uploadFileDataMod);
  720. photosBackupsTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  721. _rightTableView.photosBackupsIngTaskModel = photosBackupsTaskMod;
  722. }
  723. @end