uploadFileRecordViewController.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  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. NSString *delTipTip = nil;
  208. if(_selectIndex == 1){
  209. delTipTip = NSLocalizedString(@"File_upload_Record_clear_uploading_Tip_msg",nil);;
  210. }
  211. else if(_selectIndex == 2){
  212. delTipTip = NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil);
  213. }
  214. else if(_selectIndex == 3){
  215. delTipTip = NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil);
  216. }
  217. /*弹窗提示二次确认*/
  218. KWeakSelf
  219. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  220. msg:delTipTip
  221. imageStr:nil
  222. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  223. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  224. didClickOk:^{
  225. [weakSelf didClickBottomDeleteFunAfterAleartFun];
  226. } didClickCancel:^{
  227. }];
  228. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  229. [self presentViewController:nextVC animated:YES completion:^{
  230. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  231. }];
  232. }
  233. -(void)didClickBottomDeleteFunAfterAleartFun
  234. {
  235. if(_selectIndex == 1){
  236. [_leftTableView deleteModelOneByOneFun];
  237. }
  238. else if(_selectIndex == 2){
  239. [_midTableView deleteModelOneByOneFun];
  240. }
  241. else if(_selectIndex == 3){
  242. [_rightTableView deleteModelOneByOneFun];
  243. }
  244. }
  245. #pragma mark 头部点击 背景滚动
  246. - (void)didClickHeadFun:(NSInteger)index
  247. {
  248. //_uploadFileRecordBodyV.selectIndex = index;
  249. _selectIndex = index;
  250. _uploadFileRecordBgScorllV.contentOffset = CGPointMake(SCREEN_W *(index -1), 0);
  251. }
  252. - (void)didScorllBodyFun:(NSInteger)index
  253. {
  254. _uploadFileRecordheadV.selectIndex = index;
  255. _selectIndex = index;
  256. }
  257. #pragma mark 背景滚动代理
  258. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  259. {
  260. if(scrollView != _uploadFileRecordBgScorllV) return;
  261. CGFloat x = scrollView.contentOffset.x;
  262. NSInteger index = (x+1)/SCREEN_W;
  263. index += 1;//因为头部是从1开始的
  264. //HLog(@"index:%ld",index);
  265. [self didScorllBodyFun:index];
  266. }
  267. -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
  268. {
  269. KWeakSelf
  270. [[uploadFileManager shareInstance] handlTZAssetModelToUploadFileDataFunBy:indexPathsForSelectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  271. NSMutableArray *arr1 = Arr;
  272. //[weakSelf setRecordBodyDataFunBy:arr1];
  273. weakSelf.leftTableView.curDataArr = Arr[0];
  274. [weakSelf.leftTableView reloadDataFun];
  275. weakSelf.midTableView.curDataArr = Arr[1];
  276. [weakSelf.midTableView reloadDataFun];
  277. weakSelf.rightTableView.curDataArr = Arr[2];
  278. [weakSelf.rightTableView reloadDataFun];
  279. }];
  280. }
  281. #pragma mark 读取数据库数据
  282. - (void)getDataInDatabaseFun
  283. {
  284. KWeakSelf
  285. [[uploadFileManager shareInstance] getDataInDatabaseFun:_isNotUploadingType complete:^(NSMutableArray * _Nonnull Arr) {
  286. //[weakSelf setRecordBodyDataFunBy:Arr];
  287. if(!Arr ||Arr.count != 3){
  288. HLog(@"数据库出错\n\n\n");
  289. return;
  290. }
  291. NSMutableArray *curLoadIngArr = Arr[0];
  292. //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  293. if(self->_isNotUploadingType && ![uploadFileManager shareInstance].isUploadIngType){
  294. for (uploadFileDataModel * curModel in curLoadIngArr) {
  295. curModel.curUploadStateType = uploadStateSuspend;
  296. }
  297. }
  298. weakSelf.leftTableView.curDataArr = curLoadIngArr;
  299. [weakSelf.leftTableView reloadDataFun];
  300. weakSelf.midTableView.curDataArr = Arr[1];
  301. [weakSelf.midTableView reloadDataFun];
  302. weakSelf.rightTableView.curDataArr = Arr[2];
  303. [weakSelf.rightTableView reloadDataFun];
  304. }];
  305. // _allDataArr = [NSMutableArray new];
  306. //
  307. // KWeakSelf
  308. // [uploadFileDataModel bg_findAllAsync:upLoadFile_image_tableName complete:^(NSArray * _Nullable array) {
  309. // NSMutableArray *failArr = [NSMutableArray new];
  310. // NSMutableArray *doneArr = [NSMutableArray new];
  311. // NSMutableArray *otherArr = [NSMutableArray new];
  312. //
  313. // for (uploadFileDataModel * curModel in array) {
  314. //
  315. // //图片 和视频 还原
  316. // if(curModel.curUploadFileType == uploadFileTypeImage){
  317. // NSString*pathStr = [cachesFileManager getFilePathWithName:curModel.filename type:uploadFileTypeImage];
  318. // curModel.imageData = [NSData dataWithContentsOfFile:pathStr];
  319. // }
  320. // else if(curModel.curUploadFileType == uploadFileTypeVideo){
  321. // NSString*pathStr = [cachesFileManager getFilePathWithName:curModel.videoFirstImageName type:uploadFileTypeImage];
  322. // curModel.imageData = [NSData dataWithContentsOfFile:pathStr];
  323. //
  324. // if(curModel.curUploadStateType != uploadStateDone){
  325. // NSString*videoPathStr = [cachesFileManager getFilePathWithName:curModel.filename type:uploadFileTypeVideo];
  326. // curModel.videoData = [NSData dataWithContentsOfFile:videoPathStr];
  327. // }
  328. // }
  329. //
  330. // if(curModel.curUploadStateType == uploadStateFail){
  331. // [failArr addObject:curModel];
  332. // }
  333. // else if(curModel.curUploadStateType == uploadStateDone){
  334. // [doneArr addObject:curModel];
  335. // }
  336. // else{
  337. // //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  338. // if(self->_isNotUploadingType && ![uploadFileManager shareInstance].isUploadIngType){
  339. // curModel.curUploadStateType = uploadStateSuspend;
  340. // }
  341. //
  342. // [otherArr addObject:curModel];
  343. // }
  344. // }
  345. //
  346. // [self->_allDataArr addObject:otherArr];
  347. // [self->_allDataArr addObject:doneArr];
  348. // [self->_allDataArr addObject:failArr];
  349. //
  350. // self->_uploadFileRecordBodyV.allDataArr = self->_allDataArr;
  351. // }];
  352. }
  353. #pragma mark 给RecordBody 设置数据
  354. //- (void)setRecordBodyDataFunBy:(NSMutableArray*)arr
  355. //{
  356. // if(!arr || ![arr isKindOfClass:[NSMutableArray class]] || arr.count !=3){
  357. // return;
  358. // }
  359. // //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  360. // if(self->_isNotUploadingType && ![uploadFileManager shareInstance].isUploadIngType){
  361. // NSMutableArray *otherArr = arr[0];
  362. // for (uploadFileDataModel * curModel in otherArr) {
  363. // curModel.curUploadStateType = uploadStateSuspend;
  364. // }
  365. //
  366. // }
  367. //
  368. // //_uploadFileRecordBodyV.allDataArr = arr;
  369. //}
  370. - (void)uploadFileRefreshFun:(NSNotification*)not
  371. {
  372. uploadFileDataModel *uploadFileDataMod = [not object];
  373. //HLog(@"%@",uploadFileDataMod);
  374. uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  375. //UI和数据还没准备好
  376. if(!_leftTableView
  377. && (uploadFileDataMod.curUploadStateType == uploadStateFail
  378. ||uploadFileDataMod.curUploadStateType == uploadStateDone)){
  379. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  380. [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:uploadFileDataMod];
  381. });
  382. return;
  383. }
  384. if(_leftTableView && [uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
  385. NSMutableArray *curArr = _leftTableView.curDataArr;
  386. NSInteger index = 0;
  387. for (uploadFileDataModel*mod in curArr) {
  388. HLog(@"%@ bg_id:%@ ?=? %@",mod.filename,mod.bg_id,uploadFileDataMod.bg_id);
  389. if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  390. if(uploadFileDataMod.curUploadStateType == uploadStateDone){
  391. [curArr removeObject:mod];
  392. NSMutableArray *doneArr = _midTableView.curDataArr;
  393. [doneArr insertObject:uploadFileDataMod atIndex:0];
  394. //全部上传了
  395. if(curArr.count == 0){
  396. }
  397. }
  398. else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
  399. [curArr removeObject:mod];
  400. NSMutableArray *failArr = _rightTableView.curDataArr;
  401. [failArr insertObject:uploadFileDataMod atIndex:0];
  402. }
  403. else{
  404. [curArr replaceObjectAtIndex:index withObject:uploadFileDataMod];
  405. }
  406. break;
  407. }
  408. index++;
  409. }
  410. //精准刷新
  411. if(uploadFileDataMod.curUploadStateType == uploadStateDone){
  412. //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:_allDataArr[1] withfailArr:nil];
  413. [self.leftTableView reloadDataFun];
  414. [self.midTableView reloadDataFun];
  415. }
  416. else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
  417. //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:_allDataArr[2]];
  418. [self.leftTableView reloadDataFun];
  419. [self.rightTableView reloadDataFun];
  420. }
  421. else{
  422. //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
  423. [self.leftTableView reloadDataFun];
  424. }
  425. }
  426. }
  427. - (void)uploadFileDeteleFun:(NSNotification*)not
  428. {
  429. uploadFileDataModel *uploadFileDataMod = [not object];
  430. //HLog(@"%@",uploadFileDataMod);
  431. //UI和数据还没准备好
  432. if(!_leftTableView){
  433. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  434. [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:uploadFileDataMod];
  435. });
  436. return;
  437. }
  438. if([uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
  439. NSMutableArray *curArr = _leftTableView.curDataArr;
  440. NSInteger index = 0;
  441. for (uploadFileDataModel*mod in curArr) {
  442. HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
  443. if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  444. [curArr removeObject:mod];
  445. break;
  446. }
  447. index++;
  448. }
  449. //精准刷新
  450. //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
  451. [self.leftTableView reloadDataFun];
  452. }
  453. }
  454. #pragma mark 按钮点击
  455. - (void)didClickButFun:(UIButton*)but
  456. {
  457. NSInteger tag = but.tag;
  458. if(tag == 1){
  459. self.isEditType = NO;
  460. //self.uploadFileRecordBodyV.isEditType = NO;
  461. if(_selectIndex == 1){
  462. self.leftTableView.isEditType = NO;
  463. }
  464. else if(_selectIndex == 2){
  465. self.midTableView.isEditType = NO;
  466. }
  467. else if(_selectIndex == 3){
  468. self.rightTableView.isEditType = NO;
  469. }
  470. }
  471. else{
  472. //self.uploadFileRecordBodyV.isSelectAllType = YES;
  473. if(_selectIndex == 1){
  474. self.leftTableView.isSelectAllType = YES;
  475. }
  476. else if(_selectIndex == 2){
  477. self.midTableView.isSelectAllType = YES;
  478. }
  479. else if(_selectIndex == 3){
  480. self.rightTableView.isSelectAllType = YES;
  481. }
  482. }
  483. }
  484. -(void)setIsEditType:(BOOL)isEditType
  485. {
  486. _isEditType = isEditType;
  487. _leftButton.hidden = !isEditType;
  488. _rightButton.hidden = !isEditType;
  489. self.backBtn.hidden = isEditType;
  490. _uploadFileRecordEditBottomV.hidden = !isEditType;
  491. _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
  492. _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
  493. _leftHeadView.rightButton.userInteractionEnabled = !isEditType;
  494. if(_isEditType){
  495. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea);
  496. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  497. make.left.mas_equalTo(0);
  498. make.right.mas_equalTo(0);
  499. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  500. make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
  501. }];
  502. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  503. make.left.mas_equalTo(SCREEN_W*0.0);
  504. make.width.mas_equalTo(SCREEN_W);
  505. make.top.mas_equalTo(0);
  506. make.height.mas_equalTo(curHeight);
  507. }];
  508. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  509. make.left.mas_equalTo(SCREEN_W*1.0);
  510. make.width.mas_equalTo(SCREEN_W);
  511. make.top.mas_equalTo(0);
  512. make.height.mas_equalTo(curHeight);
  513. }];
  514. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  515. make.left.mas_equalTo(SCREEN_W*2.0);
  516. make.width.mas_equalTo(SCREEN_W);
  517. make.top.mas_equalTo(0);
  518. make.height.mas_equalTo(curHeight);
  519. }];
  520. }
  521. else{
  522. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  523. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  524. make.left.mas_equalTo(0);
  525. make.right.mas_equalTo(0);
  526. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  527. make.bottom.mas_equalTo(0);
  528. }];
  529. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  530. make.left.mas_equalTo(SCREEN_W*0.0);
  531. make.width.mas_equalTo(SCREEN_W);
  532. make.top.mas_equalTo(0);
  533. make.height.mas_equalTo(curHeight);
  534. }];
  535. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  536. make.left.mas_equalTo(SCREEN_W*1.0);
  537. make.width.mas_equalTo(SCREEN_W);
  538. make.top.mas_equalTo(0);
  539. make.height.mas_equalTo(curHeight);
  540. }];
  541. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  542. make.left.mas_equalTo(SCREEN_W*2.0);
  543. make.width.mas_equalTo(SCREEN_W);
  544. make.top.mas_equalTo(0);
  545. make.height.mas_equalTo(curHeight);
  546. }];
  547. }
  548. }
  549. #pragma mark 点击上传中的全部暂停
  550. - (void)didClickAllSuspendInLoadingFun
  551. {
  552. _leftHeadView.rightButton.selected = !_leftHeadView.rightButton.selected;
  553. if(_leftHeadView.rightButton.selected){
  554. [[uploadFileManager shareInstance] suspendUploadFileFun:YES];
  555. }
  556. else{
  557. NSMutableArray *leftArr = _leftTableView.curDataArr;
  558. [[uploadFileManager shareInstance] reUploadFileFunBy:leftArr];
  559. }
  560. }
  561. #pragma mark 点击上传成功的清空记录
  562. - (void)didClickClearRecordInDoneFun
  563. {
  564. /*弹窗提示二次确认*/
  565. KWeakSelf
  566. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  567. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  568. imageStr:nil
  569. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  570. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  571. didClickOk:^{
  572. [weakSelf ClearAllRecordInDoneFun];
  573. } didClickCancel:^{
  574. }];
  575. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  576. [self presentViewController:nextVC animated:YES completion:^{
  577. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  578. }];
  579. }
  580. - (void)ClearAllRecordInDoneFun
  581. {
  582. [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_midTableView.curDataArr complete:^(BOOL isSuccess) {
  583. HLog(@"isSuccess:%d",isSuccess);
  584. if(isSuccess){
  585. [self->_midTableView.curDataArr removeAllObjects];
  586. [self->_midTableView reloadDataFun];
  587. }
  588. }];
  589. }
  590. #pragma mark 点击上传失败的清空记录
  591. - (void)didClickClearRecordInFailFun
  592. {
  593. /*弹窗提示二次确认*/
  594. KWeakSelf
  595. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  596. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  597. imageStr:nil
  598. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  599. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  600. didClickOk:^{
  601. [weakSelf ClearAllRecordInFailFun];
  602. } didClickCancel:^{
  603. }];
  604. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  605. [self presentViewController:nextVC animated:YES completion:^{
  606. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  607. }];
  608. }
  609. - (void)ClearAllRecordInFailFun
  610. {
  611. [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_rightTableView.curDataArr complete:^(BOOL isSuccess) {
  612. HLog(@"isSuccess:%d",isSuccess);
  613. if(isSuccess){
  614. [self->_rightTableView.curDataArr removeAllObjects];
  615. [self->_rightTableView reloadDataFun];
  616. }
  617. }];
  618. }
  619. #pragma mark 失败重传
  620. - (void)didClickReUploadFun:(uploadFileDataModel*)model{
  621. if(![model isKindOfClass:[uploadFileDataModel class]]){
  622. return;
  623. }
  624. NSMutableArray *curArr = _leftTableView.curDataArr;
  625. BOOL isNeedToAdd = YES;
  626. for (uploadFileDataModel*mod in curArr) {
  627. if(mod.bg_id.integerValue == model.bg_id.integerValue){
  628. isNeedToAdd = NO;
  629. break;
  630. }
  631. }
  632. if(isNeedToAdd){
  633. [curArr addObject:model];
  634. }
  635. [_leftTableView reloadDataFun];
  636. }
  637. //-(void)backBtnPressed{
  638. // [super backBtnPressed];
  639. //
  640. // _indexPathsForSelectedItems = nil;
  641. // _uploadFileRecordheadV = nil;
  642. // //_uploadFileRecordBodyV = nil;
  643. // //_allDataArr = nil;
  644. // _uploadFileRecordEditBottomV = nil;
  645. //
  646. //}
  647. @end