123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- //
- // ChatListMoveVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/31.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ChatListMoveVC.h"
- #import "ChatMsgListCell.h"
- #import "ShowNewGroupAlert.h"
- #import "ChatMoveModel.h"
- @interface ChatListMoveVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UILabel *titleL;
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (strong,nonatomic) UIView *headerView;
- @property (weak, nonatomic) IBOutlet UIButton *addBtn;
- @property (strong,nonatomic) NSMutableArray *dataArray;
- @end
- @implementation ChatListMoveVC
- +(ChatListMoveVC *)initChatListMoveVC{
- ChatListMoveVC *controller = [StoryboardManager.shared.chatMsg instantiateViewControllerWithIdentifier:@"ChatListMoveVC"];
- return controller;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.fd_prefersNavigationBarHidden = YES;
- self.titleL.text = self.titleStr;
- [self getData];
- [self addHeaderView];
- [self.tableView setTableHeaderView:self.headerView];
- [self.tableView setSectionHeaderHeight:55.f];
- WS(weakSelf);
- [self.addBtn setAction:^{
- [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"建文件夹" placeholder:@"请输入文件夹名称" confirm:^(NSString * _Nonnull groupName) {
- NSLog(@"%@",groupName);
- NSDictionary * paraDict = @{@"FolderName":groupName,
- @"UserId":@([AppUserModel sharedAppUserModel].Id),
- @"ParentId":@(weakSelf.Id),
- @"TypeId":@(10)
- };
- [[HttpManager sharedHttpManager] PUTUrl:Host(APP_Middle_Add_Folder) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- [weakSelf getData];
- } failure:^(NSError * _Nonnull error) {
- NSLog(@"%@",error);
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- } cancle:^{
- }] show];
- }];
- }
- - (void)addHeaderView
- {
- 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]}];
- UIButton * btn = [UIButton new];
- [btn setAttributedTitle:string forState:UIControlStateNormal];
- UILabel * lineL = [UILabel new];
- lineL.backgroundColor = LINEBGCOLOR;
- [self.headerView addSubview:btn];
- [self.headerView addSubview:lineL];
- [btn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self.headerView);
- make.left.mas_offset(15);
- }];
- [lineL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(self.headerView);
- make.height.mas_offset(0.5);
- }];
- WS(weakSelf);
- [btn setAction:^{
- SHOWLOADING
- NSDictionary * dict = @{@"Ids":self.listArray,
- @"ParentId":@(0)
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dict responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- [weakSelf.navigationController popToRootViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }];
- }
- - (void)getData
- {
- [self.dataArray removeAllObjects];
- WS(weakSelf);
- SHOWLOADING
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(0) forKey:@"ParentId"];
- [dic setValue:@(10) forKey:@"TypeId"];
- NSLog(@"%@",dic);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Find) parameters:dic responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- REMOVESHOW
- if ([responseObject isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject) {
- ChatMoveModel * model = [ChatMoveModel modelWithDictionary:dict];
- [weakSelf.dataArray addObject:model];
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }
- - (UIView *)headerView
- {
- if (!_headerView) {
- _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 55.f)];
- }
- return _headerView;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- ChatMsgListCell *cell = [ChatMsgListCell configCell2:tableView indexPath:indexPath];
- ChatMoveModel * model = [self.dataArray objectAtIndex:indexPath.row];
- cell.cell2TitleLabel.text = model.Name;
- cell.cell2TimeLabel.hidden = YES;
- cell.cell2isTop.hidden = YES;
- if (model.IsFolder) {
- cell.cell2RightArrowImgView.hidden = NO;
- cell.enterBtn.hidden = NO;
- }else{
- cell.cell2RightArrowImgView.hidden = YES;
- cell.enterBtn.hidden = YES;
- }
- WS(weakSelf);
- [cell.enterBtn setAction:^{
- ChatListMoveVC * vc = [ChatListMoveVC initChatListMoveVC];
- vc.Id = model.Id;
- vc.listArray = weakSelf.listArray;
- vc.titleStr = @"移动到";
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return [ChatMsgListCell configCell2Height];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- ChatMoveModel * model = [self.dataArray objectAtIndex:indexPath.row];
- SHOWLOADING
- NSDictionary * dict = @{@"Ids":self.listArray,
- @"ParentId":@(model.Id)
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dict responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- SHOWSUCCESS(@"移动成功");
- [weakSelf.navigationController popToRootViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }
- - (void)myBack{
- for ( int i = 0 ;i< self.navigationController.viewControllers.count;i++) {
- if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"ChatMsgNoticeVC")]
- ||[self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDGroupViewController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyFavoriteVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"NoteBookVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"HomeDetailController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"NoteBookDetailVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]) {
- [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
- return;
- }
- }
- }
- - (NSMutableArray *)dataArray
- {
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- - (IBAction)backAction:(id)sender {
- [self.navigationController popViewControllerAnimated:YES];
- }
- @end
|