MyTDGroupViewController.m 49 KB

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