MyTDGroupViewController.m 47 KB

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