1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117 |
- //
- // MyTDGroupViewController.m
- // smartRhino
- //
- // Created by tederen on 2019/10/31.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyTDGroupViewController.h"
- #import "YCMenuView.h"
- #import "ShowNewGroupAlert.h"
- #import "NoticeListModel.h"
- #import "ChatNewRowVC.h"
- #import "ChatNewRowCell.h"
- #import "MoveViewController.h"
- #import "TDGroupSearchResultVC.h"
- #import "TDGroupInfoListVC.h"
- #import "MyTDGroupView.h"
- @interface MyTDGroupViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) TDTableView *tableView;
- @property (nonatomic, strong) UIView *CusNavBar;
- @property (nonatomic, strong) UIView *HeadView;
- @property (nonatomic, strong) UIView *SortView;
- @property (nonatomic, strong) UIButton *allSelectBtn;
- @property (nonatomic, strong) UILabel *selectCountL;
- @property (strong, nonatomic) MyTDGroupView *SearchView;
- @property (nonatomic, strong) UILabel *titleL;
- @property (nonatomic, strong) UIButton *addBtn;
- @property (nonatomic, strong) NSMutableArray <NoticeModel*>*dataArray;
- @property (nonatomic, copy) NSArray *addListArray;
- @property (assign,nonatomic) OperationStateEnum operationStateEnum;
- @property (strong,nonatomic) UIView *operationBottomBgView;
- @property (strong, nonatomic) UIButton *operationAllSelectButton;
- @property (nonatomic, strong) UIButton *leftCloseBtn;
- @property (nonatomic, strong) UIButton *rightMoveBtn;
- @property (nonatomic, assign) NSUInteger currentPage;
- @property (nonatomic, assign) NSUInteger totalPage;
- @property (nonatomic, assign) NSUInteger totalRecord;
- @property (nonatomic, assign) BOOL isAllSelect;
- @property (nonatomic, assign) Boolean iSViewEditor;
- @end
- @implementation MyTDGroupViewController
- - (void)viewDidDisappear:(BOOL)animated
- {
- [super viewDidDisappear:animated];
- [self changeToOperation:NO];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- [self addNavbarView];
- // [self setTableViewRefresh];
- [self initBottomBgView];
- [self changeToOperation:NO];
- self.iSViewEditor = NO;
- if (self.isPush) {
- [self pushListVC];
- }
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self getData];
- }
- - (void)addNavbarView
- {
- if (self.isSubVC) {
- self.addListArray = @[@"新建小组",@"批量编辑"];
- }else{
- self.addListArray = @[@"新建小组",@"建文件夹",@"批量编辑"];
- }
- [self.view addSubview:self.CusNavBar];
- [self.CusNavBar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.mas_equalTo(self.view);
- make.height.mas_offset(kNavigationHeight);
- }];
- // UILabel * lineL = [UILabel new];
- // lineL.backgroundColor = LINEBGCOLOR;
- // [self.CusNavBar addSubview:lineL];
- // [lineL mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.bottom.right.mas_equalTo(self.CusNavBar);
- // make.height.offset(0.5);
- // }];
- UIButton * backBtn = [UIButton new];
- [backBtn setImage:[UIImage imageNamed:@"back_black_icon"] forState:UIControlStateNormal];
- [self.CusNavBar addSubview:backBtn];
- self.operationAllSelectButton = [UIButton new];
- [self.operationAllSelectButton setImage:[UIImage imageNamed:@"menu_black_icon"] forState:UIControlStateNormal];
- [self.CusNavBar addSubview:self.operationAllSelectButton];
- self.addBtn = [UIButton new];
- if (self.isSelect) {
- [self.addBtn setImage:[UIImage imageNamed:@"add_find"] forState:UIControlStateNormal];
- }else{
- [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
- }
- [self.CusNavBar addSubview:self.addBtn];
-
- [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.CusNavBar);
- make.bottom.mas_equalTo(self.CusNavBar);
- make.width.offset(50);
- make.height.offset(44);
- }];
- [self.operationAllSelectButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(backBtn.mas_right);
- make.width.mas_greaterThanOrEqualTo(@35);
- make.height.offset(44);
- make.bottom.mas_equalTo(self.CusNavBar);
- }];
- if (self.isSelect) {
- [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.CusNavBar).offset(-15);
- make.centerY.mas_equalTo(backBtn);
- }];
- }else{
- [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.CusNavBar);
- make.bottom.mas_equalTo(self.CusNavBar);
- make.width.offset(50);
- make.height.offset(44);
- }];
- }
- [backBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.operationAllSelectButton addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside];
- WS(weakSelf);
- [self.addBtn setAction:^{
- if (weakSelf.isSelect) {
- ChatNewRowVC * vc = [ChatNewRowVC initChatNewRowVC];
- vc.GroupFolderId = weakSelf.ParentId;
- vc.upDateBlock = ^{
- [weakSelf getData];
- };
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }else{
- NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
- YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
- view.menuColor = RGB(255, 255, 255);
- view.separatorColor = RGB(234, 234, 234);
- view.textColor = RGB(102, 102, 102);
- view.textFont = [UIFont systemFontOfSize:16.0];
- view.menuCellHeight = 43.5;
- view.maxDisplayCount = 10;
- view.offset = -6;
- [view show];
- }
- }];
- [self.CusNavBar addSubview:self.titleL];
- [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.CusNavBar);
- make.centerY.mas_equalTo(backBtn);
- make.height.offset(44);
- make.width.mas_greaterThanOrEqualTo(10);
- }];
- if (self.titleStr.length == 0) {
- self.titleL.attributedText = [self stringToAttribuedString:@"小组"];
- }else{
- self.titleL.attributedText = [self stringToAttribuedString:self.titleStr];
- }
- [self.view addSubview:self.HeadView];
- [self.HeadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.height.mas_offset(46);
- make.top.mas_equalTo(self.CusNavBar.mas_bottom);
- }];
- [self.HeadView addSubview:self.SearchView];
- [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(6);
- make.left.right.mas_equalTo(self.HeadView);
- make.height.mas_offset(36);
- }];
- [self.SearchView.button setAction:^{
- TDGroupSearchResultVC *vc = [[TDGroupSearchResultVC alloc] init];
- vc.ParentId = weakSelf.ParentId;
- vc.isReturn = weakSelf.isReturn;
- vc.isSelect = weakSelf.isSelect;
- vc.sendModel = weakSelf.sendModel;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.HeadView.mas_bottom);
- make.left.right.mas_equalTo(self.view);
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
- } else {
- make.bottom.equalTo(self.view.mas_bottom);
- }
- }];
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- [self addSortV];
- }
- -(NSMutableArray *)getMenuDataSource:(NSArray *)titleArray{
- NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
- for(int i=0;i<titleArray.count;i++){
- NSString *titleStr = [titleArray objectAtIndex:i];
- WS(weakSelf);
- YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
- if([@"新建小组" isEqualToString:action.title]){
- ChatNewRowVC * vc = [ChatNewRowVC initChatNewRowVC];
- vc.GroupFolderId = self.ParentId;
- vc.upDateBlock = ^{
- [weakSelf getData];
- };
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }else if ([@"建文件夹" isEqualToString:action.title]){
- [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"建文件夹" placeholder:@"请输入文件夹名称" confirm:^(NSString * _Nonnull groupName) {
- NSLog(@"%@",groupName);
- NSDictionary * paraDict = @{@"FolderName":groupName,
- @"UserId":@([AppUserModel sharedAppUserModel].Id),
- @"ParentId":@(weakSelf.ParentId),
- @"TypeId":@(CreateGroupType)
- };
- [[HttpManager sharedHttpManager] PUTUrl:Host(APP_Middle_Add_Folder) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf headRefresh];
- });
- } failure:^(NSError * _Nonnull error) {
- NSLog(@"%@",error);
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- } cancle:^{
- }] show];
- }
- else if ([@"批量编辑" isEqualToString:action.title]){
- [weakSelf changeToOperation:YES];
- }
-
- }];
- [menuDataSourceArray addObject:actionMenu];
- }
- return menuDataSourceArray;
- }
- - (UIView *)CusNavBar
- {
- if (!_CusNavBar) {
- _CusNavBar = [UIView new];
- _CusNavBar.backgroundColor = [UIColor whiteColor];
- }
- return _CusNavBar;
- }
- - (UIView *)HeadView
- {
- if (!_HeadView) {
- _HeadView = [UIView new];
- _HeadView.backgroundColor = [UIColor whiteColor];
- }
- return _HeadView;
- }
- - (UILabel *)titleL
- {
- if (!_titleL) {
- _titleL = [UILabel new];
- _titleL.textAlignment = NSTextAlignmentCenter;
- }
- return _titleL;
- }
- - (NSAttributedString *)stringToAttribuedString:(NSString *)title;
- {
- 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]}];
- return string;
- }
- - (void)getData{
- WS(weakSelf);
- NSDictionary * paraDict = @{@"GroupFolderId":@(self.ParentId),
- @"UserId":@([AppUserModel sharedAppUserModel].Id),
- @"Key":@"",
- // @"Page":@(self.currentPage),
- // @"PerPage":@(10),
- @"Sort":@""
- };
- SHOWLOADING
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Find) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- REMOVESHOW
- [weakSelf.dataArray removeAllObjects];
- NoticeListModel *listModel = [[NoticeListModel alloc] initWithDictionary:responseObject error:nil];
- weakSelf.totalRecord = listModel.Total;
- [weakSelf.dataArray addObjectsFromArray:listModel.Items];
- dispatch_async(dispatch_get_main_queue(), ^{
- if (weakSelf.dataArray.count == 0) {
- [weakSelf changeToOperation:NO];
- }
- [weakSelf.tableView reloadData];
- });
- // [weakSelf.tableView.mj_header endRefreshing];
- // [weakSelf.tableView.mj_footer endRefreshing];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- // [weakSelf.tableView.mj_header endRefreshing];
- // [weakSelf.tableView.mj_footer endRefreshing];
- }];
- }
- #pragma mark - UItableView刷新
- - (void)setTableViewRefresh{
- WeakSelf(self)
- self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakself headRefresh];
- }];
- self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
- [weakself footerRefresh];
- }];
- }
- - (void)headRefresh{
- self.currentPage = 1;
- self.totalPage = 1;
- [self getData];
- }
- - (void)footerRefresh{
- self.currentPage += 1;
- if (self.totalRecord == self.dataArray.count) {
- self.currentPage --;
- [self.tableView.mj_footer resetNoMoreData];
- return ;
- }
- [self getData];
- }
- #pragma mark - 批量编辑
- /// 创建文件夹
- - (void)addFind:(NSString *)groupname{
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADDFind) parameters:@{@"FolderName":groupname,@"ParentId":@(self.ParentId)} success:^(id _Nonnull responseObject) {
- STRONGSELF
- REMOVESHOW
- [strongSelf getData];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 修改文件夹名称
- - (void)reNameFind:(NoticeModel*)findModel withReNameString:(NSString *)renameString{
-
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_ReName) parameters:@{@"FolderName":renameString,@"Id":@(findModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
- STRONGSELF
- REMOVESHOW
- [strongSelf getData];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 文件夹 置顶 和 取消置顶
- - (void)topFind:(NoticeModel*)findModel{
- NSLog(@"文件夹---%@%@",findModel.IsTop ? @"置顶":@"取消置顶",findModel.FolderName);
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] PUTUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_Find_Top,(long)findModel.Id] parameters:@{} success:^(id _Nonnull responseObject) {
- REMOVESHOW
- [weakSelf reCreateTable];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)reCreateTable
- {
- self.currentPage = 1;
- self.totalPage = 1;
- [self.dataArray removeAllObjects];
- WS(weakSelf);
- NSDictionary * paraDict = @{@"GroupFolderId":@(self.ParentId),
- @"UserId":@([AppUserModel sharedAppUserModel].Id),
- @"Key":@"",
- // @"Page":@(self.currentPage),
- // @"PerPage":@(20),
- @"Sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Find) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- NoticeListModel *listModel = [[NoticeListModel alloc] initWithDictionary:responseObject error:nil];
- weakSelf.totalRecord = listModel.Total;
- [weakSelf.dataArray addObjectsFromArray:listModel.Items];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView removeFromSuperview];
- weakSelf.tableView = nil;
- weakSelf.tableView.delegate = weakSelf;
- weakSelf.tableView.dataSource = weakSelf;
- [weakSelf.view addSubview:self.tableView];
- [weakSelf.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(weakSelf.HeadView.mas_bottom);
- make.left.right.mas_equalTo(weakSelf.view);
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom);
- }
- }];
- // [weakSelf.tableView.mj_header endRefreshing];
- // [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- // [weakSelf.tableView.mj_header endRefreshing];
- // [weakSelf.tableView.mj_footer endRefreshing];
- }];
- }
- /// 删除文件夹
- - (void)deleteFind:(NSMutableArray<NoticeModel *>*)findModelArray{
- NSMutableArray *MiddleIds = [NSMutableArray array];
-
- for (NoticeModel *model in findModelArray) {
- [MiddleIds addObject:@(model.Id)];
- }
- NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
- [dic setValue:MiddleIds forKey:@"MiddleIds"];
- [dic setValue:@(CreateGroupType) forKey:@"FolderType"];
-
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- STRONGSELF
- REMOVESHOW
- [strongSelf headRefresh];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 移动文件夹
- - (void)moveFind:(NSMutableArray<NoticeModel *>*)findModelArray withSuperModel:(NoticeModel *)supermodel{
- NSMutableArray *MiddleIds = [NSMutableArray array];
-
- for (NoticeModel *model in findModelArray) {
- [MiddleIds addObject:@(model.Id)];
- }
- NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
- [dic setValue:MiddleIds forKey:@"Ids"];
- [dic setValue:@(self.ParentId) forKey:@"ParentId"];
-
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- STRONGSELF
- REMOVESHOW
- [strongSelf headRefresh];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- -(void)initBottomBgView{
- // self.leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // [self.leftCloseBtn setTitle:@"删除" forState:UIControlStateNormal];
- // [self.leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal];
- // self.leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
- //
- // [self.operationBottomBgView addSubview:self.leftCloseBtn];
- // self.leftCloseBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH/2, self.operationBottomBgView.height - 10);
-
- self.self.rightMoveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [self.rightMoveBtn setTitle:@"移动" forState:UIControlStateNormal];
- // [self.rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal];
- [self.rightMoveBtn setTitleColor:UIColorHex(#BBBBBB) forState:UIControlStateNormal];
- self.rightMoveBtn.enabled = NO;
- self.rightMoveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
-
- [self.operationBottomBgView addSubview:self.rightMoveBtn];
- self.rightMoveBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH, self.operationBottomBgView.height - 10);
-
- // UIView *line = [[UIView alloc] init];
- // line.backgroundColor = RGB(240, 239, 244);
- // [self.operationBottomBgView addSubview:line];
- // line.frame = CGRectMake(SCREEN_WIDTH/2, 0, .5, self.operationBottomBgView.height);
- //
- // UIView *topLine = [[UIView alloc] init];
- // topLine.backgroundColor = RGB(240, 239, 244);
- // [self.operationBottomBgView addSubview:topLine];
- // topLine.frame = CGRectMake(0, 0, SCREEN_WIDTH, 10);
-
- WS(weakSelf);
- [self.leftCloseBtn setAction:^{
- NSMutableArray *selectIDArray = [NSMutableArray array];
- for (NoticeModel * model in weakSelf.dataArray) {
- if (model.IsSelect) {
- [selectIDArray addObject:model];
- }
- }
- if (selectIDArray.count == 0) {
- SHOWERROR(@"请选择要删除的通知");
- return ;
- }else{
- [weakSelf deleteFind:selectIDArray];
- }
- }];
- self.leftCloseBtn.hidden = YES;
- [self.rightMoveBtn setAction:^{
- NSMutableArray *selectIDArray = [NSMutableArray array];
- for (NoticeModel * model in weakSelf.dataArray) {
- if (model.IsSelect) {
- [selectIDArray addObject:@(model.Id)];
- }
- }
- if (selectIDArray.count == 0) {
- SHOWERROR(@"请选择要移动的通知或者文件夹");
- return ;
- }
- [weakSelf launchMoveVC:selectIDArray];
- }];
-
- [[UtilsTools getWindow] addSubview:self.operationBottomBgView];
- }
- - (void)launchMoveVC:(NSMutableArray<NSNumber*>*)selectIDArray{
- MoveViewController * vc = [MoveViewController initMoveViewController];
- vc.TypeId = CreateGroupType;
- vc.CollectionType = CollectModel_Group;
- vc.collectType = CollectHanderType_Move;
- vc.ParentId = 0;
- vc.titleStr = self.titleL.text;
- vc.FolderIds = selectIDArray;
- [self.navigationController pushViewController:vc animated:YES];
-
- [self changeToOperation:NO];
-
- }
- -(UIView *)operationBottomBgView{
- if(!_operationBottomBgView){
- _operationBottomBgView = [[UIView alloc] init];
- CGFloat bottomBgViewH = self.tabBarController.tabBar.height + 10;
- _operationBottomBgView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH);
- _operationBottomBgView.backgroundColor = RGB(255, 255, 255);
- _operationBottomBgView.hidden = YES;
- }
- return _operationBottomBgView;
- }
- #pragma mark 批量操作与正常操作界面切换
- -(void)changeToOperation:(BOOL)operation{
- if(operation){
- self.titleL.attributedText = [self stringToAttribuedString:@"批量编辑"];
- self.iSViewEditor = YES;
- [self.HeadView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_offset(36);
- }];
- self.SortView.hidden = NO;
- self.SearchView.hidden = YES;
- self.addBtn.hidden = YES;
- //默认操作状态为批量编辑状态
- self.operationStateEnum = OperationStateEnum1;
- // self.operationBackButton.hidden = NO;
- // self.operationAllSelectButton.hidden = NO;
- // [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
- // [self.operationAllSelectButton setTitleColor:UIColorHex(#0F88EB) forState:UIControlStateNormal];
- // [self.operationAllSelectButton setImage:nil forState:UIControlStateNormal];
-
- self.tabBarController.tabBar.hidden = YES;
-
- self.operationBottomBgView.hidden = NO;
- self.view.height -= self.tabBarController.tabBar.height;
- self.tableView.height -= self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- [self.tableView setEditing:YES];
- self.tableView.allowsSelectionDuringEditing = YES;
- }else{
- [self.tableView setEditing:NO];
- if (self.titleStr.length == 0) {
- self.titleL.attributedText = [self stringToAttribuedString:@"我的小组"];
- }else{
- self.titleL.attributedText = [self stringToAttribuedString:self.titleStr];
- }
- self.addBtn.hidden = NO;
- self.iSViewEditor = NO;
- [self.HeadView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_offset(46);
- }];
- self.SortView.hidden = YES;
- self.SearchView.hidden = NO;
- //默认操作状态为无状态
- self.operationStateEnum = OperationStateEnum0;
- // self.operationAllSelectButton.hidden = NO;
- // [self.operationAllSelectButton setImage:IMG(@"menu_black_icon") forState:UIControlStateNormal];
- // [self.operationAllSelectButton setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
- self.tabBarController.tabBar.hidden = YES;
-
- self.tableView.height += self.tabBarController.tabBar.height;
- self.view.height += self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- self.operationBottomBgView.hidden = YES;
- }
- [self.tableView reloadData];
- }
- #pragma mark 移动 isEdit:当前是否为编辑状态
- -(void)userDidMove:(BOOL)move isEdit:(BOOL)isEdit{
- //移动
- if(move){
- //默认操作状态为移动状态
- self.operationStateEnum = OperationStateEnum2;
- self.addBtn.hidden = NO;
- [self resetRightBtnAction:NO];
-
- //隐藏tabBar - 并将TableView至底端
- self.tabBarController.tabBar.hidden = YES;
- self.view.height += self.tabBarController.tabBar.height;
- self.tableView.height += self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- //隐藏operationBottomBgView
- self.operationBottomBgView.hidden = YES;
- }
- else{
- //隐藏tabBar - 并将TableView至底端有tabBar.height的高
- self.tabBarController.tabBar.hidden = YES;
- self.view.height -= self.tabBarController.tabBar.height;
- self.tableView.height -= self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- //显示operationBottomBgView
- self.operationBottomBgView.hidden = NO;
-
- if(isEdit){
- self.operationStateEnum = OperationStateEnum1;
- self.addBtn.hidden = YES;
- [self resetRightBtnAction:YES];
- }else{
- [self changeToOperation:NO];
- }
- }
- [self.tableView reloadData];
- }
- -(void)resetRightBtnAction:(BOOL)isShowMenu{
- WS(weakSelf);
- if(isShowMenu){
- [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
- [self.addBtn setAction:^{
- NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
- YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
- view.menuColor = RGB(255, 255, 255);
- view.separatorColor = RGB(234, 234, 234);
- view.textColor = RGB(102, 102, 102);
- view.textFont = [UIFont systemFontOfSize:16.0];
- view.menuCellHeight = 43.5;
- view.maxDisplayCount = 10;
- view.offset = -6;
- [view show];
- }];
- }else{
- [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_fileadd_icon"] forState:UIControlStateNormal];
- [self.addBtn setAction:^{
- [ShowtipTool showErrorWithStatus:@"未做"];
- }];
- }
- }
- - (void)backAction:(id)sender{
- if (self.iSViewEditor) {
- [self changeToOperation:NO];
- }else{
- [self.navigationController popViewControllerAnimated:true];
- }
- }
- - (void)back1
- {
- if (self.isSelect) {
- for (NSInteger i = (self.navigationController.viewControllers.count - 1); i >= 0; i --) {
- UIViewController *vc = self.navigationController.viewControllers[i];
- if ([vc isKindOfClass:NSClassFromString(@"MyTDTopicCreateVC")]) {
- [self.navigationController popToViewController:vc animated:YES];
- return;
- }
- }
- }else{
- [self.navigationController popViewControllerAnimated:YES];
- }
- }
- - (BOOL)checkChatListArray
- {
- for (NoticeModel * model in self.dataArray) {
- if (!model.IsSelect) {
- return NO;
- }
- }
- return YES;
- }
- - (NSInteger)CountSelectArray
- {
- NSInteger count = 0;
- for (NoticeModel * model in self.dataArray) {
- if (model.IsSelect) {
- count ++;
- }
- }
- return count;
- }
- - (void)menuAction:(id)sender{
- [super menuAction:sender];
- [self changeToOperation:NO];
- }
- #pragma mark - setter
- - (TDTableView *)tableView{
- if (!_tableView) {
- _tableView = [[TDTableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- }
- return _tableView;
- }
- - (NSMutableArray<NoticeModel *> *)dataArray{
- if (!_dataArray) {
- _dataArray = [NSMutableArray new];
- }
- return _dataArray;
- }
- - (MyTDGroupView *)SearchView
- {
- if (!_SearchView) {
- _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
- }
- return _SearchView;
- }
- #pragma Mark 左滑按钮 iOS8以上
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
- - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
- WS(weakSelf);
- NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
- switch (model.AttributeValue) {
- case 2:{
- UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf deleteFind:@[model].mutableCopy];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"重命名" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) {
- NSLog(@"%@",groupName);
- [weakSelf reNameFind:model withReNameString:groupName];
- } cancle:^{
- }] show];
- }];
-
- action2.backgroundColor = RGB(255, 149, 3);
- UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- [weakSelf topFind:model];
- }];
-
- action3.backgroundColor = RGB(197, 201, 204);
- UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]];
- actions.performsFirstActionWithFullSwipe = NO;
- return actions;
- }break;
- default:{
- UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"退出" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- [weakSelf deleteFind:@[model].mutableCopy];
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"移动" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy];
- }];
- action2.backgroundColor = UIColorHex(#589AF1);
- UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- [weakSelf topFind:model];
- }];
- action3.backgroundColor = RGB(197, 201, 204);
- UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]];
- actions.performsFirstActionWithFullSwipe = NO;
- return actions;
- }
- break;
- }
- }
- #else
- - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
- NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
- WEAKSELF
- switch (model.AttributeValue) {
- case 2:{
- UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf deleteFind:@[model].mutableCopy];
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"重命名" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) {
- NSLog(@"%@",groupName);
- [weakSelf reNameFind:model withReNameString:groupName];
- } cancle:^{
- }] show];
- }];
-
- action2.backgroundColor = RGB(255, 149, 3);
- // NSLog(@"")
- UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf topFind:model];
- }];
-
- action3.backgroundColor = RGB(197, 201, 204);
- return @[action1, action2, action3];
- }break;
- default:{
- UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"退出" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf deleteFind:@[model].mutableCopy];
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"移动" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy];
- }];
- action2.backgroundColor = UIColorHex(#589AF1);
- UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf topFind:model];
- }];
- action3.backgroundColor = RGB(197, 201, 204);
- return @[action1, action2, action3];
- }
- break;
- }
- }
- #endif
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return [ChatNewRowCell configCell2Height];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- switch (self.operationStateEnum) {
- case OperationStateEnum0:{
- NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
- switch (model.AttributeValue) {
- case 2:{
- ChatNewRowCell *cell = [ChatNewRowCell configCell1:tableView indexPath:indexPath];
- cell.cell1TitleLabel.text = model.FolderName;
- cell.IsTopImgV.hidden = !model.IsTop;
- cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount];
- cell.cell1TimeLabel.hidden = model.FileCount == 0 ? YES : NO;
- return cell;
- }break;
- default:{
- ChatNewRowCell *cell = [ChatNewRowCell configCell2:tableView indexPath:indexPath];
- [cell.cell2UserImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- cell.cell2TitleLabel.text = model.GroupName;
- cell.IsTopImgV.hidden = !model.IsTop;
- cell.cell2IntroLabel.text = [NSString stringWithFormat:@"共享给%ld人",(long)model.TopicSharingCount];
- cell.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.TopicAllCount];
- cell.cell2TimeLabel.hidden = model.TopicAllCount == 0 ? YES : NO;
- cell.cell2RedNumLabel.text = model.UReadTopicCount > 0 ? [NSString stringWithFormat:@"[%ld条新话题]",(long)model.UReadTopicCount] : @"";
- return cell;
- }break;
- }
-
- }break;
- default:{
- NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
- self.isAllSelect = [self checkChatListArray];
- [self isMoveCheckData];
- self.selectCountL.text = [NSString stringWithFormat:@"%ld",[self CountSelectArray]];
- if (self.isAllSelect) {
- [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
- // [self.operationAllSelectButton setTitle:@"取消全选" forState:UIControlStateNormal];
- }else{
- [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
- // [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
- }
- switch (model.AttributeValue) {
- case 2:{///文件
- ChatNewRowCell *cell = [ChatNewRowCell configCell10:tableView indexPath:indexPath];
- cell.cell1TitleLabel.text = model.FolderName;
- cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount];
- cell.cell1TimeLabel.hidden = model.FileCount == 0 ? YES : NO;
- cell.cell1SelectButton.selected = model.IsSelect;
- cell.IsTopImgV.hidden = !model.IsTop;
- cell.rightImageView.hidden = YES;
- cell.isSort = model.IsTop;
- [cell.cell1SelectButton setAction:^{
- model.IsSelect = !model.IsSelect;
- if (model.IsSelect) {
- SHOWERROR(@"文件夹不能移动");
- }
- [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }];
- return cell;
- }break;
- default:{///小组
- ChatNewRowCell *cell = [ChatNewRowCell configCell20:tableView indexPath:indexPath];
- [cell.cell2UserImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- cell.cell2TitleLabel.text = model.GroupName;
- cell.cell2IntroLabel.text = [NSString stringWithFormat:@"共享给%ld人",(long)model.TopicSharingCount];
- cell.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.TopicAllCount];
- cell.cell2TimeLabel.hidden = model.TopicAllCount == 0 ? YES : NO;
- cell.cell2RedNumLabel.text = model.UReadTopicCount > 0 ? [NSString stringWithFormat:@"[%ld条新话题]",(long)model.UReadTopicCount] : @"";
- cell.cell2SelectButton.selected = model.IsSelect;
- cell.IsTopImgV.hidden = !model.IsTop;
- [cell.cell2SelectButton setAction:^{
- model.IsSelect = !model.IsSelect;
- [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }];
- cell.isSort = model.IsTop;
- return cell;
- }break;
- }
- }break;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- switch (self.operationStateEnum) {
- case OperationStateEnum1:{
- NSLog(@"编辑状态的cell");
- NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
- model.IsSelect = !model.IsSelect;
- if (model.AttributeValue == 2 && model.IsSelect) {
- SHOWERROR(@"文件夹不能移动");
- }
- [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }break;
- default:{
- NSLog(@"正常状态的cell");
- NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row];
- if(model && model != nil)
- {
- switch (model.AttributeValue) {
- case 2:{
- MyTDGroupViewController *vc = [[MyTDGroupViewController alloc] init];
- vc.ParentId = model.Id;
- vc.isSubVC = YES;
- vc.titleStr = model.FolderName;
- vc.isReturn = self.isReturn;
- vc.isSelect = self.isSelect;
- vc.sendImage = self.sendImage;
- vc.sendModel = self.sendModel;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- default:{
- if (self.isReturn) {
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.FolderId = model.GroupId;
- vc.type = CollectModel_Toipc;
- vc.isReturn = self.isReturn;
- vc.sendImage = self.sendImage;
- vc.sendModel = self.sendModel;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- if (self.isSelect) {
- [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_SELECTCREATENOTEFOLDER object:nil userInfo:@{@"FolderId":@(model.GroupId),@"FolderName":model.GroupName}];
- [self back1];
- }else{
- TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
- vc.titleStr = model.GroupName;
- vc.GroupId = model.GroupId;
- vc.type = self.type;
- vc.isReturn = self.isReturn;
- vc.sendImage = self.sendImage;
- vc.sendModel = self.sendModel;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- }break;
- }
- }
- }break;
- }
- }
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
-
- return tableView.editing;
- }
- - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
- NoticeModel *model = [self.dataArray objectAtIndex:sourceIndexPath.row];
- NoticeModel *toModel = [self.dataArray objectAtIndex:destinationIndexPath.row];
- WS(weakSelf);
- if (model.IsTop && toModel.IsTop ) {
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Sort) parameters:@{@"MiddleIdFirst":@(model.Id),@"MiddleIdSecond":@(toModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
- [weakSelf.dataArray removeObject:model];
- [weakSelf.dataArray insertObject:model atIndex:destinationIndexPath.row];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }else{
- [weakSelf.dataArray removeObject:model];
- [weakSelf.dataArray insertObject:model atIndex:sourceIndexPath.row];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- }
- }
- - (void)pushListVC
- {
- TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
- vc.titleStr = self.pushDict[@"Name"];
- vc.GroupId = [self.pushDict[@"Id"] integerValue];
- [self.navigationController pushViewController:vc animated:NO];
- }
- - (void)isMoveCheckData
- {
- BOOL flag = NO;
- BOOL use = NO;
- for (NoticeModel * model in self.dataArray) {
- if (model.IsSelect) {
- if (model.AttributeValue == 2) {
- flag = YES;
- }else{
- use = YES;
- }
- }
- }
- if (flag) {
- [self.rightMoveBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
- self.rightMoveBtn.enabled = NO;
- }else{
- if (!use) {
- [self.rightMoveBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
- self.rightMoveBtn.enabled = NO;
- }else{
- [self.rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal];
- self.rightMoveBtn.enabled = YES;
- }
- }
- }
- - (UIButton *)allSelectBtn
- {
- if (!_allSelectBtn) {
- _allSelectBtn = [UIButton new];
- [_allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
- }
- return _allSelectBtn;
- }
- - (UILabel *)selectCountL
- {
- if (!_selectCountL) {
- _selectCountL = [UILabel new];
- _selectCountL.font = Kfont(13);
- _selectCountL.text = @"0";
- _selectCountL.textColor = UIColorHex(0x0F88EB);
- }
- return _selectCountL;
- }
- - (UIView *)SortView
- {
- if (!_SortView) {
- _SortView = [UIView new];
- _SortView.backgroundColor = UIColorHex(0xF0EFF4);
- _SortView.hidden = YES;
- }
- return _SortView;
- }
- - (void)addSortV
- {
- [self.HeadView addSubview:self.SortView];
- [self.SortView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_offset(UIEdgeInsetsZero);
- }];
- [self.SortView addSubview:self.allSelectBtn];
- [self.SortView addSubview:self.selectCountL];
- [self.allSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_offset(5);
- make.centerY.mas_equalTo(self.SortView);
- make.size.mas_offset(CGSizeMake(36, 36));
- }];
- UILabel * leftL = [UILabel new];
- leftL.text = @"已选:";
- leftL.textColor = UIColorHex(0x666666);
- leftL.font = Kfont(13);
- [self.SortView addSubview:leftL];
- [leftL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.allSelectBtn.mas_right).offset(5);
- make.centerY.mas_equalTo(self.SortView);
- }];
- [self.selectCountL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(leftL.mas_right).offset(8);
- make.centerY.mas_equalTo(self.SortView);
- }];
- UILabel * rightL = [UILabel new];
- rightL.text = @"长按右侧三横,拖动可进行排序";
- rightL.textColor = UIColorHex(0x666666);
- rightL.font = Kfont(13);
- [self.SortView addSubview:rightL];
- [rightL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.selectCountL.mas_right).offset(12);
- make.centerY.mas_equalTo(self.SortView);
- }];
- WS(weakSelf);
- [self.allSelectBtn setAction:^{
- for (NoticeModel *model in weakSelf.dataArray) {
- model.IsSelect = !weakSelf.isAllSelect;
- if (model.IsSelect && model.AttributeValue == 2) {
- SHOWERROR(@"文件夹不能移动");
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- }];
- }
- @end
|