MyTDGroupViewController.m 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. //
  2. // MyTDGroupViewController.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/31.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDGroupViewController.h"
  9. #import "YCMenuView.h"
  10. #import "ShowNewGroupAlert.h"
  11. #import "NoticeListModel.h"
  12. #import "ChatNewRowVC.h"
  13. #import "ChatNewRowCell.h"
  14. #import "MoveViewController.h"
  15. #import "TDGroupSearchResultVC.h"
  16. #import "TDGroupInfoListVC.h"
  17. #import "MyTDGroupView.h"
  18. @interface MyTDGroupViewController ()<UITableViewDelegate,UITableViewDataSource>
  19. @property (nonatomic, strong) TDTableView *tableView;
  20. @property (nonatomic, strong) UIView *CusNavBar;
  21. @property (nonatomic, strong) UIView *HeadView;
  22. @property (nonatomic, strong) UIView *SortView;
  23. @property (nonatomic, strong) UIButton *allSelectBtn;
  24. @property (nonatomic, strong) UILabel *selectCountL;
  25. @property (strong, nonatomic) MyTDGroupView *SearchView;
  26. @property (nonatomic, strong) UILabel *titleL;
  27. @property (nonatomic, strong) UIButton *addBtn;
  28. @property (nonatomic, strong) NSMutableArray <NoticeModel*>*dataArray;
  29. @property (nonatomic, copy) NSArray *addListArray;
  30. @property (assign,nonatomic) OperationStateEnum operationStateEnum;
  31. @property (strong,nonatomic) UIView *operationBottomBgView;
  32. @property (strong, nonatomic) UIButton *operationAllSelectButton;
  33. @property (nonatomic, strong) UIButton *leftCloseBtn;
  34. @property (nonatomic, strong) UIButton *rightMoveBtn;
  35. @property (nonatomic, assign) NSUInteger currentPage;
  36. @property (nonatomic, assign) NSUInteger totalPage;
  37. @property (nonatomic, assign) NSUInteger totalRecord;
  38. @property (nonatomic, assign) BOOL isFresh;
  39. @property (nonatomic, assign) BOOL isAllSelect;
  40. @property (nonatomic, assign) Boolean iSViewEditor;
  41. @end
  42. @implementation MyTDGroupViewController
  43. - (void)viewDidDisappear:(BOOL)animated
  44. {
  45. [super viewDidDisappear:animated];
  46. [self changeToOperation:NO];
  47. }
  48. - (void)viewDidLoad {
  49. [super viewDidLoad];
  50. self.fd_prefersNavigationBarHidden = YES;
  51. [self addNavbarView];
  52. [self initBottomBgView];
  53. [self changeToOperation:NO];
  54. self.iSViewEditor = NO;
  55. if (self.isPush) {
  56. [self pushListVC];
  57. }
  58. }
  59. - (void)viewWillAppear:(BOOL)animated{
  60. [super viewWillAppear:animated];
  61. [self setTableViewRefresh];
  62. [self headRefresh];
  63. }
  64. - (void)addNavbarView
  65. {
  66. if (self.isSubVC) {
  67. self.addListArray = @[@"新建小组",@"批量编辑"];
  68. }else{
  69. self.addListArray = @[@"新建小组",@"建文件夹",@"批量编辑"];
  70. }
  71. [self.view addSubview:self.CusNavBar];
  72. [self.CusNavBar mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.top.left.right.mas_equalTo(self.view);
  74. make.height.mas_offset(kNavigationHeight);
  75. }];
  76. // UILabel * lineL = [UILabel new];
  77. // lineL.backgroundColor = LINEBGCOLOR;
  78. // [self.CusNavBar addSubview:lineL];
  79. // [lineL mas_makeConstraints:^(MASConstraintMaker *make) {
  80. // make.left.bottom.right.mas_equalTo(self.CusNavBar);
  81. // make.height.offset(0.5);
  82. // }];
  83. UIButton * backBtn = [UIButton new];
  84. [backBtn setImage:[UIImage imageNamed:@"back_black_icon"] forState:UIControlStateNormal];
  85. [self.CusNavBar addSubview:backBtn];
  86. self.operationAllSelectButton = [UIButton new];
  87. [self.operationAllSelectButton setImage:[UIImage imageNamed:@"menu_black_icon"] forState:UIControlStateNormal];
  88. [self.CusNavBar addSubview:self.operationAllSelectButton];
  89. self.addBtn = [UIButton new];
  90. [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
  91. [self.CusNavBar addSubview:self.addBtn];
  92. [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.left.mas_equalTo(self.CusNavBar);
  94. make.bottom.mas_equalTo(self.CusNavBar);
  95. make.width.offset(50);
  96. make.height.offset(44);
  97. }];
  98. [self.operationAllSelectButton mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.mas_equalTo(backBtn.mas_right);
  100. make.width.mas_greaterThanOrEqualTo(@35);
  101. make.height.offset(44);
  102. make.bottom.mas_equalTo(self.CusNavBar);
  103. }];
  104. [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.right.mas_equalTo(self.CusNavBar);
  106. make.bottom.mas_equalTo(self.CusNavBar);
  107. make.width.offset(50);
  108. make.height.offset(44);
  109. }];
  110. [backBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
  111. [self.operationAllSelectButton addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside];
  112. WS(weakSelf);
  113. [self.addBtn setAction:^{
  114. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
  115. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
  116. view.menuColor = RGB(255, 255, 255);
  117. view.separatorColor = RGB(234, 234, 234);
  118. view.textColor = RGB(102, 102, 102);
  119. view.textFont = [UIFont systemFontOfSize:16.0];
  120. view.menuCellHeight = 43.5;
  121. view.maxDisplayCount = 10;
  122. view.offset = -6;
  123. [view show];
  124. }];
  125. [self.CusNavBar addSubview:self.titleL];
  126. [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.centerX.mas_equalTo(self.CusNavBar);
  128. make.centerY.mas_equalTo(backBtn);
  129. make.height.offset(44);
  130. make.width.mas_greaterThanOrEqualTo(10);
  131. }];
  132. if (self.titleStr.length == 0) {
  133. self.titleL.attributedText = [self stringToAttribuedString:@"小组"];
  134. }else{
  135. self.titleL.attributedText = [self stringToAttribuedString:self.titleStr];
  136. }
  137. [self.view addSubview:self.HeadView];
  138. [self.HeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.left.right.mas_equalTo(self.view);
  140. make.height.mas_offset(46);
  141. make.top.mas_equalTo(self.CusNavBar.mas_bottom);
  142. }];
  143. [self.HeadView addSubview:self.SearchView];
  144. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.top.mas_offset(6);
  146. make.left.right.mas_equalTo(self.HeadView);
  147. make.height.mas_offset(36);
  148. }];
  149. [self.SearchView.button setAction:^{
  150. TDGroupSearchResultVC *vc = [[TDGroupSearchResultVC alloc] init];
  151. vc.ParentId = weakSelf.ParentId;
  152. [weakSelf.navigationController pushViewController:vc animated:YES];
  153. }];
  154. [self.view addSubview:self.tableView];
  155. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  156. make.top.mas_equalTo(self.HeadView.mas_bottom);
  157. make.left.right.mas_equalTo(self.view);
  158. if (@available(iOS 11.0, *)) {
  159. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  160. } else {
  161. make.bottom.equalTo(self.view.mas_bottom);
  162. }
  163. }];
  164. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  165. [self addSortV];
  166. }
  167. -(NSMutableArray *)getMenuDataSource:(NSArray *)titleArray{
  168. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  169. for(int i=0;i<titleArray.count;i++){
  170. NSString *titleStr = [titleArray objectAtIndex:i];
  171. WS(weakSelf);
  172. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  173. if([@"新建小组" isEqualToString:action.title]){
  174. ChatNewRowVC * vc = [ChatNewRowVC initChatNewRowVC];
  175. vc.GroupFolderId = self.ParentId;
  176. vc.upDateBlock = ^{
  177. [weakSelf getData];
  178. };
  179. [weakSelf.navigationController pushViewController:vc animated:YES];
  180. }else if ([@"建文件夹" isEqualToString:action.title]){
  181. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"建文件夹" placeholder:@"请输入文件夹名称" confirm:^(NSString * _Nonnull groupName) {
  182. NSLog(@"%@",groupName);
  183. NSDictionary * paraDict = @{@"FolderName":groupName,
  184. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  185. @"ParentId":@(weakSelf.ParentId),
  186. @"TypeId":@(CreateGroupType)
  187. };
  188. [[HttpManager sharedHttpManager] PUTUrl:Host(APP_Middle_Add_Folder) parameters:paraDict success:^(id _Nonnull responseObject) {
  189. dispatch_async(dispatch_get_main_queue(), ^{
  190. [weakSelf headRefresh];
  191. });
  192. } failure:^(NSError * _Nonnull error) {
  193. NSLog(@"%@",error);
  194. SHOWERROR([ZYCTool handerResultData:error])
  195. }];
  196. } cancle:^{
  197. }] show];
  198. }
  199. else if ([@"批量编辑" isEqualToString:action.title]){
  200. [weakSelf changeToOperation:YES];
  201. }
  202. }];
  203. [menuDataSourceArray addObject:actionMenu];
  204. }
  205. return menuDataSourceArray;
  206. }
  207. - (UIView *)CusNavBar
  208. {
  209. if (!_CusNavBar) {
  210. _CusNavBar = [UIView new];
  211. _CusNavBar.backgroundColor = [UIColor whiteColor];
  212. }
  213. return _CusNavBar;
  214. }
  215. - (UIView *)HeadView
  216. {
  217. if (!_HeadView) {
  218. _HeadView = [UIView new];
  219. _HeadView.backgroundColor = [UIColor whiteColor];
  220. }
  221. return _HeadView;
  222. }
  223. - (UILabel *)titleL
  224. {
  225. if (!_titleL) {
  226. _titleL = [UILabel new];
  227. _titleL.textAlignment = NSTextAlignmentCenter;
  228. }
  229. return _titleL;
  230. }
  231. - (NSAttributedString *)stringToAttribuedString:(NSString *)title;
  232. {
  233. NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 18],NSForegroundColorAttributeName: [UIColor colorWithRed:10/255.0 green:10/255.0 blue:10/255.0 alpha:1.0]}];
  234. return string;
  235. }
  236. - (void)getData{
  237. WS(weakSelf);
  238. NSDictionary * paraDict = @{@"GroupFolderId":@(self.ParentId),
  239. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  240. @"Key":@"",
  241. @"Page":@(self.currentPage),
  242. @"PerPage":@(20),
  243. @"Sort":@""
  244. };
  245. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Find) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  246. NSLog(@"%@",responseObject);
  247. NoticeListModel *listModel = [[NoticeListModel alloc] initWithDictionary:responseObject error:nil];
  248. weakSelf.totalRecord = listModel.Total;
  249. [weakSelf.dataArray addObjectsFromArray:listModel.Items];
  250. dispatch_async(dispatch_get_main_queue(), ^{
  251. [weakSelf.tableView reloadData];
  252. });
  253. [weakSelf.tableView.mj_header endRefreshing];
  254. [weakSelf.tableView.mj_footer endRefreshing];
  255. } failure:^(NSError * _Nonnull error) {
  256. [weakSelf.tableView.mj_header endRefreshing];
  257. [weakSelf.tableView.mj_footer endRefreshing];
  258. }];
  259. }
  260. #pragma mark - UItableView刷新
  261. - (void)setTableViewRefresh{
  262. WeakSelf(self)
  263. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  264. [weakself headRefresh];
  265. }];
  266. self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  267. [weakself footerRefresh];
  268. }];
  269. }
  270. - (void)headRefresh{
  271. self.isFresh = YES;
  272. self.currentPage = 1;
  273. self.totalPage = 1;
  274. [self.dataArray removeAllObjects];
  275. [self getData];
  276. }
  277. - (void)footerRefresh{
  278. self.isFresh = NO;
  279. self.currentPage += 1;
  280. if (self.totalRecord == self.dataArray.count) {
  281. self.currentPage --;
  282. [self.tableView.mj_footer resetNoMoreData];
  283. return ;
  284. }
  285. [self getData];
  286. }
  287. #pragma mark - 批量编辑
  288. /// 创建文件夹
  289. - (void)addFind:(NSString *)groupname{
  290. SHOWLOADING
  291. WEAKSELF
  292. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADDFind) parameters:@{@"FolderName":groupname,@"ParentId":@(self.ParentId)} success:^(id _Nonnull responseObject) {
  293. STRONGSELF
  294. REMOVESHOW
  295. [strongSelf getData];
  296. } failure:^(NSError * _Nonnull error) {
  297. SHOWERROR([ZYCTool handerResultData:error]);
  298. }];
  299. }
  300. /// 修改文件夹名称
  301. - (void)reNameFind:(NoticeModel*)findModel withReNameString:(NSString *)renameString{
  302. SHOWLOADING
  303. WEAKSELF
  304. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_ReName) parameters:@{@"FolderName":renameString,@"Id":@(findModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  305. STRONGSELF
  306. REMOVESHOW
  307. [strongSelf getData];
  308. } failure:^(NSError * _Nonnull error) {
  309. SHOWERROR([ZYCTool handerResultData:error]);
  310. }];
  311. }
  312. /// 文件夹 置顶 和 取消置顶
  313. - (void)topFind:(NoticeModel*)findModel{
  314. NSLog(@"文件夹---%@%@",findModel.IsTop ? @"置顶":@"取消置顶",findModel.FolderName);
  315. SHOWLOADING
  316. WEAKSELF
  317. [[HttpManager sharedHttpManager] PUTUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_Find_Top,(long)findModel.Id] parameters:@{} success:^(id _Nonnull responseObject) {
  318. REMOVESHOW
  319. [weakSelf reCreateTable];
  320. } failure:^(NSError * _Nonnull error) {
  321. SHOWERROR([ZYCTool handerResultData:error]);
  322. }];
  323. }
  324. - (void)reCreateTable
  325. {
  326. self.currentPage = 1;
  327. self.totalPage = 1;
  328. [self.dataArray removeAllObjects];
  329. WS(weakSelf);
  330. NSDictionary * paraDict = @{@"GroupFolderId":@(self.ParentId),
  331. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  332. @"Key":@"",
  333. @"Page":@(self.currentPage),
  334. @"PerPage":@(20),
  335. @"Sort":@""
  336. };
  337. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Find) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  338. NSLog(@"%@",responseObject);
  339. NoticeListModel *listModel = [[NoticeListModel alloc] initWithDictionary:responseObject error:nil];
  340. weakSelf.totalRecord = listModel.Total;
  341. [weakSelf.dataArray addObjectsFromArray:listModel.Items];
  342. dispatch_async(dispatch_get_main_queue(), ^{
  343. [weakSelf.tableView removeFromSuperview];
  344. weakSelf.tableView = nil;
  345. weakSelf.tableView.delegate = weakSelf;
  346. weakSelf.tableView.dataSource = weakSelf;
  347. [weakSelf.view addSubview:self.tableView];
  348. [weakSelf.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  349. make.top.mas_equalTo(weakSelf.CusNavBar.mas_bottom);
  350. make.left.right.mas_equalTo(weakSelf.view);
  351. if (@available(iOS 11.0, *)) {
  352. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  353. } else {
  354. make.bottom.equalTo(weakSelf.view.mas_bottom);
  355. }
  356. }];
  357. [weakSelf.tableView.mj_header endRefreshing];
  358. [weakSelf.tableView.mj_footer endRefreshing];
  359. [weakSelf.tableView reloadData];
  360. });
  361. } failure:^(NSError * _Nonnull error) {
  362. [weakSelf.tableView.mj_header endRefreshing];
  363. [weakSelf.tableView.mj_footer endRefreshing];
  364. }];
  365. }
  366. /// 删除文件夹
  367. - (void)deleteFind:(NSMutableArray<NoticeModel *>*)findModelArray{
  368. NSMutableArray *MiddleIds = [NSMutableArray array];
  369. for (NoticeModel *model in findModelArray) {
  370. [MiddleIds addObject:@(model.Id)];
  371. }
  372. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  373. [dic setValue:MiddleIds forKey:@"MiddleIds"];
  374. [dic setValue:@(CreateGroupType) forKey:@"FolderType"];
  375. SHOWLOADING
  376. WEAKSELF
  377. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  378. STRONGSELF
  379. REMOVESHOW
  380. [strongSelf headRefresh];
  381. } failure:^(NSError * _Nonnull error) {
  382. SHOWERROR([ZYCTool handerResultData:error]);
  383. }];
  384. }
  385. /// 移动文件夹
  386. - (void)moveFind:(NSMutableArray<NoticeModel *>*)findModelArray withSuperModel:(NoticeModel *)supermodel{
  387. NSMutableArray *MiddleIds = [NSMutableArray array];
  388. for (NoticeModel *model in findModelArray) {
  389. [MiddleIds addObject:@(model.Id)];
  390. }
  391. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  392. [dic setValue:MiddleIds forKey:@"Ids"];
  393. [dic setValue:@(self.ParentId) forKey:@"ParentId"];
  394. SHOWLOADING
  395. WEAKSELF
  396. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  397. STRONGSELF
  398. REMOVESHOW
  399. [strongSelf headRefresh];
  400. } failure:^(NSError * _Nonnull error) {
  401. SHOWERROR([ZYCTool handerResultData:error]);
  402. }];
  403. }
  404. -(void)initBottomBgView{
  405. // self.leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  406. // [self.leftCloseBtn setTitle:@"删除" forState:UIControlStateNormal];
  407. // [self.leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal];
  408. // self.leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  409. //
  410. // [self.operationBottomBgView addSubview:self.leftCloseBtn];
  411. // self.leftCloseBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH/2, self.operationBottomBgView.height - 10);
  412. self.self.rightMoveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  413. [self.rightMoveBtn setTitle:@"移动" forState:UIControlStateNormal];
  414. // [self.rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal];
  415. [self.rightMoveBtn setTitleColor:UIColorHex(#BBBBBB) forState:UIControlStateNormal];
  416. self.rightMoveBtn.enabled = NO;
  417. self.rightMoveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  418. [self.operationBottomBgView addSubview:self.rightMoveBtn];
  419. self.rightMoveBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH, self.operationBottomBgView.height - 10);
  420. // UIView *line = [[UIView alloc] init];
  421. // line.backgroundColor = RGB(240, 239, 244);
  422. // [self.operationBottomBgView addSubview:line];
  423. // line.frame = CGRectMake(SCREEN_WIDTH/2, 0, .5, self.operationBottomBgView.height);
  424. //
  425. // UIView *topLine = [[UIView alloc] init];
  426. // topLine.backgroundColor = RGB(240, 239, 244);
  427. // [self.operationBottomBgView addSubview:topLine];
  428. // topLine.frame = CGRectMake(0, 0, SCREEN_WIDTH, 10);
  429. WS(weakSelf);
  430. [self.leftCloseBtn setAction:^{
  431. NSMutableArray *selectIDArray = [NSMutableArray array];
  432. for (NoticeModel * model in weakSelf.dataArray) {
  433. if (model.IsSelect) {
  434. [selectIDArray addObject:model];
  435. }
  436. }
  437. if (selectIDArray.count == 0) {
  438. SHOWERROR(@"请选择要删除的通知");
  439. return ;
  440. }else{
  441. [weakSelf deleteFind:selectIDArray];
  442. }
  443. }];
  444. self.leftCloseBtn.hidden = YES;
  445. [self.rightMoveBtn setAction:^{
  446. NSMutableArray *selectIDArray = [NSMutableArray array];
  447. for (NoticeModel * model in weakSelf.dataArray) {
  448. if (model.IsSelect) {
  449. [selectIDArray addObject:@(model.Id)];
  450. }
  451. }
  452. if (selectIDArray.count == 0) {
  453. SHOWERROR(@"请选择要移动的通知或者文件夹");
  454. return ;
  455. }
  456. [weakSelf launchMoveVC:selectIDArray];
  457. }];
  458. [[UtilsTools getWindow] addSubview:self.operationBottomBgView];
  459. }
  460. - (void)launchMoveVC:(NSMutableArray<NSNumber*>*)selectIDArray{
  461. MoveViewController * vc = [MoveViewController initMoveViewController];
  462. vc.TypeId = CreateGroupType;
  463. vc.collectType = CollectHanderType_Move;
  464. vc.ParentId = 0;
  465. vc.titleStr = self.titleL.text;
  466. vc.FolderIds = selectIDArray;
  467. [self.navigationController pushViewController:vc animated:YES];
  468. [self changeToOperation:NO];
  469. }
  470. -(UIView *)operationBottomBgView{
  471. if(!_operationBottomBgView){
  472. _operationBottomBgView = [[UIView alloc] init];
  473. CGFloat bottomBgViewH = self.tabBarController.tabBar.height + 10;
  474. _operationBottomBgView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH);
  475. _operationBottomBgView.backgroundColor = RGB(255, 255, 255);
  476. _operationBottomBgView.hidden = YES;
  477. }
  478. return _operationBottomBgView;
  479. }
  480. #pragma mark 批量操作与正常操作界面切换
  481. -(void)changeToOperation:(BOOL)operation{
  482. if(operation){
  483. self.titleL.attributedText = [self stringToAttribuedString:@"批量编辑"];
  484. self.iSViewEditor = YES;
  485. [self.HeadView mas_updateConstraints:^(MASConstraintMaker *make) {
  486. make.height.mas_offset(36);
  487. }];
  488. self.SortView.hidden = NO;
  489. self.SearchView.hidden = YES;
  490. self.addBtn.hidden = YES;
  491. //默认操作状态为批量编辑状态
  492. self.operationStateEnum = OperationStateEnum1;
  493. // self.operationBackButton.hidden = NO;
  494. // self.operationAllSelectButton.hidden = NO;
  495. // [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
  496. // [self.operationAllSelectButton setTitleColor:UIColorHex(#0F88EB) forState:UIControlStateNormal];
  497. // [self.operationAllSelectButton setImage:nil forState:UIControlStateNormal];
  498. self.tabBarController.tabBar.hidden = YES;
  499. self.operationBottomBgView.hidden = NO;
  500. self.view.height -= self.tabBarController.tabBar.height;
  501. self.tableView.height -= self.tabBarController.tabBar.height;
  502. [self.view layoutIfNeeded];
  503. [self.tableView layoutIfNeeded];
  504. [self.tableView setEditing:YES];
  505. self.tableView.allowsSelectionDuringEditing = YES;
  506. }else{
  507. [self.tableView setEditing:NO];
  508. if (self.titleStr.length == 0) {
  509. self.titleL.attributedText = [self stringToAttribuedString:@"我的小组"];
  510. }else{
  511. self.titleL.attributedText = [self stringToAttribuedString:self.titleStr];
  512. }
  513. self.addBtn.hidden = NO;
  514. self.iSViewEditor = NO;
  515. [self.HeadView mas_updateConstraints:^(MASConstraintMaker *make) {
  516. make.height.mas_offset(46);
  517. }];
  518. self.SortView.hidden = YES;
  519. self.SearchView.hidden = NO;
  520. //默认操作状态为无状态
  521. self.operationStateEnum = OperationStateEnum0;
  522. // self.operationAllSelectButton.hidden = NO;
  523. // [self.operationAllSelectButton setImage:IMG(@"menu_black_icon") forState:UIControlStateNormal];
  524. // [self.operationAllSelectButton setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
  525. self.tabBarController.tabBar.hidden = YES;
  526. self.tableView.height += self.tabBarController.tabBar.height;
  527. self.view.height += self.tabBarController.tabBar.height;
  528. [self.view layoutIfNeeded];
  529. [self.tableView layoutIfNeeded];
  530. self.operationBottomBgView.hidden = YES;
  531. }
  532. [self.tableView reloadData];
  533. }
  534. #pragma mark 移动 isEdit:当前是否为编辑状态
  535. -(void)userDidMove:(BOOL)move isEdit:(BOOL)isEdit{
  536. //移动
  537. if(move){
  538. //默认操作状态为移动状态
  539. self.operationStateEnum = OperationStateEnum2;
  540. self.addBtn.hidden = NO;
  541. [self resetRightBtnAction:NO];
  542. //隐藏tabBar - 并将TableView至底端
  543. self.tabBarController.tabBar.hidden = YES;
  544. self.view.height += self.tabBarController.tabBar.height;
  545. self.tableView.height += self.tabBarController.tabBar.height;
  546. [self.view layoutIfNeeded];
  547. [self.tableView layoutIfNeeded];
  548. //隐藏operationBottomBgView
  549. self.operationBottomBgView.hidden = YES;
  550. }
  551. else{
  552. //隐藏tabBar - 并将TableView至底端有tabBar.height的高
  553. self.tabBarController.tabBar.hidden = YES;
  554. self.view.height -= self.tabBarController.tabBar.height;
  555. self.tableView.height -= self.tabBarController.tabBar.height;
  556. [self.view layoutIfNeeded];
  557. [self.tableView layoutIfNeeded];
  558. //显示operationBottomBgView
  559. self.operationBottomBgView.hidden = NO;
  560. if(isEdit){
  561. self.operationStateEnum = OperationStateEnum1;
  562. self.addBtn.hidden = YES;
  563. [self resetRightBtnAction:YES];
  564. }else{
  565. [self changeToOperation:NO];
  566. }
  567. }
  568. [self.tableView reloadData];
  569. }
  570. -(void)resetRightBtnAction:(BOOL)isShowMenu{
  571. WS(weakSelf);
  572. if(isShowMenu){
  573. [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
  574. [self.addBtn setAction:^{
  575. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
  576. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
  577. view.menuColor = RGB(255, 255, 255);
  578. view.separatorColor = RGB(234, 234, 234);
  579. view.textColor = RGB(102, 102, 102);
  580. view.textFont = [UIFont systemFontOfSize:16.0];
  581. view.menuCellHeight = 43.5;
  582. view.maxDisplayCount = 10;
  583. view.offset = -6;
  584. [view show];
  585. }];
  586. }else{
  587. [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_fileadd_icon"] forState:UIControlStateNormal];
  588. [self.addBtn setAction:^{
  589. [ShowtipTool showErrorWithStatus:@"未做"];
  590. }];
  591. }
  592. }
  593. - (void)backAction:(id)sender{
  594. if (self.iSViewEditor) {
  595. [self changeToOperation:NO];
  596. }else{
  597. [self.navigationController popViewControllerAnimated:true];
  598. }
  599. }
  600. - (BOOL)checkChatListArray
  601. {
  602. for (NoticeModel * model in self.dataArray) {
  603. if (!model.IsSelect) {
  604. return NO;
  605. }
  606. }
  607. return YES;
  608. }
  609. - (NSInteger)CountSelectArray
  610. {
  611. NSInteger count = 0;
  612. for (NoticeModel * model in self.dataArray) {
  613. if (model.IsSelect) {
  614. count ++;
  615. }
  616. }
  617. return count;
  618. }
  619. - (void)menuAction:(id)sender{
  620. [super menuAction:sender];
  621. [self changeToOperation:NO];
  622. }
  623. #pragma mark - setter
  624. - (TDTableView *)tableView{
  625. if (!_tableView) {
  626. _tableView = [[TDTableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
  627. _tableView.delegate = self;
  628. _tableView.dataSource = self;
  629. }
  630. return _tableView;
  631. }
  632. - (NSMutableArray<NoticeModel *> *)dataArray{
  633. if (!_dataArray) {
  634. _dataArray = [NSMutableArray new];
  635. }
  636. return _dataArray;
  637. }
  638. - (MyTDGroupView *)SearchView
  639. {
  640. if (!_SearchView) {
  641. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  642. }
  643. return _SearchView;
  644. }
  645. #pragma Mark 左滑按钮 iOS8以上
  646. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  647. - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
  648. WS(weakSelf);
  649. NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
  650. switch (model.AttributeValue) {
  651. case 2:{
  652. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  653. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  654. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  655. [weakSelf deleteFind:@[model].mutableCopy];
  656. }];
  657. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  658. }];
  659. [alert addAction:sureAction];
  660. [alert addAction:cancelAction];
  661. [weakSelf presentViewController:alert animated:YES completion:^{
  662. }];
  663. }];
  664. action1.backgroundColor = RGB(255, 59, 47);
  665. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"重命名" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  666. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) {
  667. NSLog(@"%@",groupName);
  668. [weakSelf reNameFind:model withReNameString:groupName];
  669. } cancle:^{
  670. }] show];
  671. }];
  672. action2.backgroundColor = RGB(255, 149, 3);
  673. UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  674. [weakSelf topFind:model];
  675. }];
  676. action3.backgroundColor = RGB(197, 201, 204);
  677. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]];
  678. actions.performsFirstActionWithFullSwipe = NO;
  679. return actions;
  680. }break;
  681. default:{
  682. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"退出" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  683. [weakSelf deleteFind:@[model].mutableCopy];
  684. }];
  685. action1.backgroundColor = RGB(255, 59, 47);
  686. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"移动" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  687. [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy];
  688. }];
  689. action2.backgroundColor = UIColorHex(#589AF1);
  690. UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  691. [weakSelf topFind:model];
  692. }];
  693. action3.backgroundColor = RGB(197, 201, 204);
  694. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]];
  695. actions.performsFirstActionWithFullSwipe = NO;
  696. return actions;
  697. }
  698. break;
  699. }
  700. }
  701. #else
  702. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  703. NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
  704. WEAKSELF
  705. switch (model.AttributeValue) {
  706. case 2:{
  707. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  708. [weakSelf deleteFind:@[model].mutableCopy];
  709. }];
  710. action1.backgroundColor = RGB(255, 59, 47);
  711. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"重命名" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  712. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) {
  713. NSLog(@"%@",groupName);
  714. [weakSelf reNameFind:model withReNameString:groupName];
  715. } cancle:^{
  716. }] show];
  717. }];
  718. action2.backgroundColor = RGB(255, 149, 3);
  719. // NSLog(@"")
  720. UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  721. [weakSelf topFind:model];
  722. }];
  723. action3.backgroundColor = RGB(197, 201, 204);
  724. return @[action1, action2, action3];
  725. }break;
  726. default:{
  727. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"退出" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  728. [weakSelf deleteFind:@[model].mutableCopy];
  729. }];
  730. action1.backgroundColor = RGB(255, 59, 47);
  731. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"移动" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  732. [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy];
  733. }];
  734. action2.backgroundColor = UIColorHex(#589AF1);
  735. UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  736. [weakSelf topFind:model];
  737. }];
  738. action3.backgroundColor = RGB(197, 201, 204);
  739. return @[action1, action2, action3];
  740. }
  741. break;
  742. }
  743. }
  744. #endif
  745. #pragma mark - UITableViewDelegate,UITableViewDataSource
  746. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  747. return 1;
  748. }
  749. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  750. return self.dataArray.count;
  751. }
  752. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  753. return [ChatNewRowCell configCell2Height];
  754. }
  755. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  756. WS(weakSelf);
  757. switch (self.operationStateEnum) {
  758. case OperationStateEnum0:{
  759. NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
  760. switch (model.AttributeValue) {
  761. case 2:{
  762. ChatNewRowCell *cell = [ChatNewRowCell configCell1:tableView indexPath:indexPath];
  763. cell.cell1TitleLabel.text = model.FolderName;
  764. cell.IsTopImgV.hidden = !model.IsTop;
  765. cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount];
  766. cell.cell1TimeLabel.hidden = model.FileCount == 0 ? YES : NO;
  767. return cell;
  768. }break;
  769. default:{
  770. ChatNewRowCell *cell = [ChatNewRowCell configCell2:tableView indexPath:indexPath];
  771. [cell.cell2UserImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  772. cell.cell2TitleLabel.text = model.GroupName;
  773. cell.IsTopImgV.hidden = !model.IsTop;
  774. cell.cell2IntroLabel.text = [NSString stringWithFormat:@"共享给%ld人",(long)model.TopicSharingCount];
  775. cell.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.TopicAllCount];
  776. cell.cell2TimeLabel.hidden = model.TopicAllCount == 0 ? YES : NO;
  777. cell.cell2RedNumLabel.text = model.UReadTopicCount > 0 ? [NSString stringWithFormat:@"[%ld条新话题]",(long)model.UReadTopicCount] : @"";
  778. return cell;
  779. }break;
  780. }
  781. }break;
  782. default:{
  783. NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
  784. self.isAllSelect = [self checkChatListArray];
  785. [self isMoveCheckData];
  786. self.selectCountL.text = [NSString stringWithFormat:@"%ld",[self CountSelectArray]];
  787. if (self.isAllSelect) {
  788. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  789. // [self.operationAllSelectButton setTitle:@"取消全选" forState:UIControlStateNormal];
  790. }else{
  791. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  792. // [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
  793. }
  794. switch (model.AttributeValue) {
  795. case 2:{///文件
  796. ChatNewRowCell *cell = [ChatNewRowCell configCell10:tableView indexPath:indexPath];
  797. cell.cell1TitleLabel.text = model.FolderName;
  798. cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount];
  799. cell.cell1TimeLabel.hidden = model.FileCount == 0 ? YES : NO;
  800. cell.cell1SelectButton.selected = model.IsSelect;
  801. cell.IsTopImgV.hidden = !model.IsTop;
  802. cell.rightImageView.hidden = YES;
  803. cell.isSort = YES;
  804. [cell.cell1SelectButton setAction:^{
  805. model.IsSelect = !model.IsSelect;
  806. if (model.IsSelect) {
  807. SHOWERROR(@"文件夹不能移动");
  808. }
  809. [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  810. }];
  811. return cell;
  812. }break;
  813. default:{///小组
  814. ChatNewRowCell *cell = [ChatNewRowCell configCell20:tableView indexPath:indexPath];
  815. [cell.cell2UserImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  816. cell.cell2TitleLabel.text = model.GroupName;
  817. cell.cell2IntroLabel.text = [NSString stringWithFormat:@"共享给%ld人",(long)model.TopicSharingCount];
  818. cell.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.TopicAllCount];
  819. cell.cell2TimeLabel.hidden = model.TopicAllCount == 0 ? YES : NO;
  820. cell.cell2RedNumLabel.text = model.UReadTopicCount > 0 ? [NSString stringWithFormat:@"[%ld条新话题]",(long)model.UReadTopicCount] : @"";
  821. cell.cell2SelectButton.selected = model.IsSelect;
  822. cell.IsTopImgV.hidden = !model.IsTop;
  823. [cell.cell2SelectButton setAction:^{
  824. model.IsSelect = !model.IsSelect;
  825. [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  826. }];
  827. cell.isSort = YES;
  828. return cell;
  829. }break;
  830. }
  831. }break;
  832. }
  833. }
  834. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  835. {
  836. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  837. switch (self.operationStateEnum) {
  838. case OperationStateEnum1:{
  839. NSLog(@"编辑状态的cell");
  840. self.dataArray[indexPath.row].IsSelect = !self.dataArray[indexPath.row].IsSelect;
  841. if (self.dataArray[indexPath.row].IsSelect) {
  842. SHOWERROR(@"文件夹不能移动");
  843. }
  844. [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  845. }break;
  846. default:{
  847. NSLog(@"正常状态的cell");
  848. NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
  849. if(model && model != nil)
  850. {
  851. switch (model.AttributeValue) {
  852. case 2:{
  853. MyTDGroupViewController *vc = [[MyTDGroupViewController alloc] init];
  854. vc.ParentId = model.Id;
  855. vc.isSubVC = YES;
  856. vc.titleStr = model.FolderName;
  857. [self.navigationController pushViewController:vc animated:YES];
  858. }break;
  859. default:{
  860. if (self.isReturn) {
  861. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  862. vc.Id = model.GroupId;
  863. vc.type = self.type == 0 ? CollectModel_Group : self.type;
  864. vc.isReturn = self.isReturn;
  865. vc.sendModel = self.sendModel;
  866. [self.navigationController pushViewController:vc animated:YES];
  867. }else{
  868. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  869. vc.titleStr = model.GroupName;
  870. vc.GroupId = model.GroupId;
  871. vc.type = self.type;
  872. vc.sendModel = self.sendModel;
  873. [self.navigationController pushViewController:vc animated:YES];
  874. }
  875. }break;
  876. }
  877. }
  878. }break;
  879. }
  880. }
  881. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
  882. return tableView.editing;
  883. }
  884. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
  885. NoticeModel *model = [self.dataArray objectAtIndex:sourceIndexPath.row];
  886. NoticeModel *toModel = [self.dataArray objectAtIndex:destinationIndexPath.row];
  887. WS(weakSelf);
  888. if (model.IsTop && toModel.IsTop ) {
  889. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Sort) parameters:@{@"MiddleIdFirst":@(model.Id),@"MiddleIdSecond":@(toModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  890. [weakSelf.dataArray removeObject:model];
  891. [weakSelf.dataArray insertObject:model atIndex:destinationIndexPath.row];
  892. dispatch_async(dispatch_get_main_queue(), ^{
  893. [weakSelf.tableView reloadData];
  894. });
  895. } failure:^(NSError * _Nonnull error) {
  896. }];
  897. }else{
  898. [weakSelf.dataArray removeObject:model];
  899. [weakSelf.dataArray insertObject:model atIndex:sourceIndexPath.row];
  900. dispatch_async(dispatch_get_main_queue(), ^{
  901. [weakSelf.tableView reloadData];
  902. });
  903. }
  904. }
  905. - (void)pushListVC
  906. {
  907. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  908. vc.titleStr = self.pushDict[@"Name"];
  909. vc.GroupId = [self.pushDict[@"Id"] integerValue];
  910. [self.navigationController pushViewController:vc animated:NO];
  911. }
  912. - (void)isMoveCheckData
  913. {
  914. BOOL flag = NO;
  915. BOOL use = NO;
  916. for (NoticeModel * model in self.dataArray) {
  917. if (model.IsSelect) {
  918. if (model.AttributeValue == 2) {
  919. flag = YES;
  920. }else{
  921. use = YES;
  922. }
  923. }
  924. }
  925. if (flag) {
  926. [self.rightMoveBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  927. self.rightMoveBtn.enabled = NO;
  928. }else{
  929. if (!use) {
  930. [self.rightMoveBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  931. self.rightMoveBtn.enabled = NO;
  932. }else{
  933. [self.rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal];
  934. self.rightMoveBtn.enabled = YES;
  935. }
  936. }
  937. }
  938. - (UIButton *)allSelectBtn
  939. {
  940. if (!_allSelectBtn) {
  941. _allSelectBtn = [UIButton new];
  942. [_allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  943. }
  944. return _allSelectBtn;
  945. }
  946. - (UILabel *)selectCountL
  947. {
  948. if (!_selectCountL) {
  949. _selectCountL = [UILabel new];
  950. _selectCountL.font = Kfont(13);
  951. _selectCountL.text = @"0";
  952. _selectCountL.textColor = UIColorHex(0x0F88EB);
  953. }
  954. return _selectCountL;
  955. }
  956. - (UIView *)SortView
  957. {
  958. if (!_SortView) {
  959. _SortView = [UIView new];
  960. _SortView.backgroundColor = UIColorHex(0xF0EFF4);
  961. _SortView.hidden = YES;
  962. }
  963. return _SortView;
  964. }
  965. - (void)addSortV
  966. {
  967. [self.HeadView addSubview:self.SortView];
  968. [self.SortView mas_makeConstraints:^(MASConstraintMaker *make) {
  969. make.edges.mas_offset(UIEdgeInsetsZero);
  970. }];
  971. [self.SortView addSubview:self.allSelectBtn];
  972. [self.SortView addSubview:self.selectCountL];
  973. [self.allSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  974. make.left.mas_offset(5);
  975. make.centerY.mas_equalTo(self.SortView);
  976. make.size.mas_offset(CGSizeMake(36, 36));
  977. }];
  978. UILabel * leftL = [UILabel new];
  979. leftL.text = @"已选:";
  980. leftL.textColor = UIColorHex(0x666666);
  981. leftL.font = Kfont(13);
  982. [self.SortView addSubview:leftL];
  983. [leftL mas_makeConstraints:^(MASConstraintMaker *make) {
  984. make.left.mas_equalTo(self.allSelectBtn.mas_right).offset(5);
  985. make.centerY.mas_equalTo(self.SortView);
  986. }];
  987. [self.selectCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  988. make.left.mas_equalTo(leftL.mas_right).offset(8);
  989. make.centerY.mas_equalTo(self.SortView);
  990. }];
  991. UILabel * rightL = [UILabel new];
  992. rightL.text = @"长按右侧三横,拖动可进行排序";
  993. rightL.textColor = UIColorHex(0x666666);
  994. rightL.font = Kfont(13);
  995. [self.SortView addSubview:rightL];
  996. [rightL mas_makeConstraints:^(MASConstraintMaker *make) {
  997. make.left.mas_equalTo(self.selectCountL.mas_right).offset(12);
  998. make.centerY.mas_equalTo(self.SortView);
  999. }];
  1000. WS(weakSelf);
  1001. [self.allSelectBtn setAction:^{
  1002. for (NoticeModel *model in weakSelf.dataArray) {
  1003. model.IsSelect = !weakSelf.isAllSelect;
  1004. if (model.IsSelect && model.AttributeValue == 2) {
  1005. SHOWERROR(@"文件夹不能移动");
  1006. }
  1007. }
  1008. dispatch_async(dispatch_get_main_queue(), ^{
  1009. [weakSelf.tableView reloadData];
  1010. });
  1011. }];
  1012. }
  1013. @end