MyTDGroupViewController.m 47 KB

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