uploadFileRecordViewController.m 30 KB

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