uploadFileRecordViewController.m 31 KB

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