ChatListMoveVC.m 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. //
  2. // ChatListMoveVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/31.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "ChatListMoveVC.h"
  9. #import "ChatMsgListCell.h"
  10. #import "ShowNewGroupAlert.h"
  11. #import "ChatMoveModel.h"
  12. @interface ChatListMoveVC ()<UITableViewDelegate,UITableViewDataSource>
  13. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  14. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  15. @property (strong,nonatomic) UIView *headerView;
  16. @property (weak, nonatomic) IBOutlet UIButton *addBtn;
  17. @property (strong,nonatomic) NSMutableArray *dataArray;
  18. @end
  19. @implementation ChatListMoveVC
  20. +(ChatListMoveVC *)initChatListMoveVC{
  21. ChatListMoveVC *controller = [StoryboardManager.shared.chatMsg instantiateViewControllerWithIdentifier:@"ChatListMoveVC"];
  22. return controller;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. self.tableView.delegate = self;
  27. self.tableView.dataSource = self;
  28. self.fd_prefersNavigationBarHidden = YES;
  29. self.titleL.text = self.titleStr;
  30. [self getData];
  31. [self addHeaderView];
  32. [self.tableView setTableHeaderView:self.headerView];
  33. [self.tableView setSectionHeaderHeight:55.f];
  34. WS(weakSelf);
  35. [self.addBtn setAction:^{
  36. [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"建文件夹" placeholder:@"请输入文件夹名称" confirm:^(NSString * _Nonnull groupName) {
  37. NSLog(@"%@",groupName);
  38. NSDictionary * paraDict = @{@"FolderName":groupName,
  39. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  40. @"ParentId":@(weakSelf.Id),
  41. @"TypeId":@(10)
  42. };
  43. [[HttpManager sharedHttpManager] PUTUrl:Host(APP_Middle_Add_Folder) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  44. [weakSelf getData];
  45. } failure:^(NSError * _Nonnull error) {
  46. NSLog(@"%@",error);
  47. SHOWERROR([ZYCTool handerResultData:error])
  48. }];
  49. } cancle:^{
  50. }] show];
  51. }];
  52. }
  53. - (void)addHeaderView
  54. {
  55. NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"根目录" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 17],NSForegroundColorAttributeName: [UIColor colorWithRed:10/255.0 green:10/255.0 blue:10/255.0 alpha:1.0]}];
  56. UIButton * btn = [UIButton new];
  57. [btn setAttributedTitle:string forState:UIControlStateNormal];
  58. UILabel * lineL = [UILabel new];
  59. lineL.backgroundColor = LINEBGCOLOR;
  60. [self.headerView addSubview:btn];
  61. [self.headerView addSubview:lineL];
  62. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.centerY.mas_equalTo(self.headerView);
  64. make.left.mas_offset(15);
  65. }];
  66. [lineL mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.right.bottom.mas_equalTo(self.headerView);
  68. make.height.mas_offset(0.5);
  69. }];
  70. WS(weakSelf);
  71. [btn setAction:^{
  72. SHOWLOADING
  73. NSDictionary * dict = @{@"Ids":self.listArray,
  74. @"ParentId":@(0)
  75. };
  76. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dict responseStyle:DATA success:^(id _Nonnull responseObject) {
  77. REMOVESHOW
  78. [weakSelf.navigationController popToRootViewControllerAnimated:YES];
  79. } failure:^(NSError * _Nonnull error) {
  80. REMOVESHOW
  81. SHOWERROR([ZYCTool handerResultData:error])
  82. }];
  83. }];
  84. }
  85. - (void)getData
  86. {
  87. [self.dataArray removeAllObjects];
  88. WS(weakSelf);
  89. SHOWLOADING
  90. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  91. [dic setValue:@(0) forKey:@"ParentId"];
  92. [dic setValue:@(10) forKey:@"TypeId"];
  93. NSLog(@"%@",dic);
  94. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Find) parameters:dic responseStyle:JOSN success:^(id _Nonnull responseObject) {
  95. NSLog(@"%@",responseObject);
  96. REMOVESHOW
  97. if ([responseObject isKindOfClass:[NSArray class]]) {
  98. for (NSDictionary * dict in responseObject) {
  99. ChatMoveModel * model = [ChatMoveModel modelWithDictionary:dict];
  100. [weakSelf.dataArray addObject:model];
  101. }
  102. }
  103. dispatch_async(dispatch_get_main_queue(), ^{
  104. [weakSelf.tableView reloadData];
  105. });
  106. } failure:^(NSError * _Nonnull error) {
  107. REMOVESHOW
  108. SHOWERROR([ZYCTool handerResultData:error])
  109. }];
  110. }
  111. - (UIView *)headerView
  112. {
  113. if (!_headerView) {
  114. _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 55.f)];
  115. }
  116. return _headerView;
  117. }
  118. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  119. return 1;
  120. }
  121. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  122. return self.dataArray.count;
  123. }
  124. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  125. ChatMsgListCell *cell = [ChatMsgListCell configCell2:tableView indexPath:indexPath];
  126. ChatMoveModel * model = [self.dataArray objectAtIndex:indexPath.row];
  127. cell.cell2TitleLabel.text = model.Name;
  128. cell.cell2TimeLabel.hidden = YES;
  129. cell.cell2isTop.hidden = YES;
  130. if (model.IsFolder) {
  131. cell.cell2RightArrowImgView.hidden = NO;
  132. cell.enterBtn.hidden = NO;
  133. }else{
  134. cell.cell2RightArrowImgView.hidden = YES;
  135. cell.enterBtn.hidden = YES;
  136. }
  137. WS(weakSelf);
  138. [cell.enterBtn setAction:^{
  139. ChatListMoveVC * vc = [ChatListMoveVC initChatListMoveVC];
  140. vc.Id = model.Id;
  141. vc.listArray = weakSelf.listArray;
  142. vc.titleStr = @"移动到";
  143. [weakSelf.navigationController pushViewController:vc animated:YES];
  144. }];
  145. return cell;
  146. }
  147. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  148. return [ChatMsgListCell configCell2Height];
  149. }
  150. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  151. WS(weakSelf);
  152. ChatMoveModel * model = [self.dataArray objectAtIndex:indexPath.row];
  153. SHOWLOADING
  154. NSDictionary * dict = @{@"Ids":self.listArray,
  155. @"ParentId":@(model.Id)
  156. };
  157. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dict responseStyle:DATA success:^(id _Nonnull responseObject) {
  158. REMOVESHOW
  159. SHOWSUCCESS(@"移动成功");
  160. [weakSelf.navigationController popToRootViewControllerAnimated:YES];
  161. } failure:^(NSError * _Nonnull error) {
  162. REMOVESHOW
  163. SHOWERROR([ZYCTool handerResultData:error])
  164. }];
  165. }
  166. - (void)myBack{
  167. for ( int i = 0 ;i< self.navigationController.viewControllers.count;i++) {
  168. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"ChatMsgNoticeVC")]
  169. ||[self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDGroupViewController")]
  170. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyFavoriteVC")]
  171. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"NoteBookVC")]
  172. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"HomeDetailController")]
  173. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"NoteBookDetailVC")]
  174. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]) {
  175. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  176. return;
  177. }
  178. }
  179. }
  180. - (NSMutableArray *)dataArray
  181. {
  182. if (!_dataArray) {
  183. _dataArray = [NSMutableArray array];
  184. }
  185. return _dataArray;
  186. }
  187. - (IBAction)backAction:(id)sender {
  188. [self.navigationController popViewControllerAnimated:YES];
  189. }
  190. @end