|
@@ -25,6 +25,7 @@
|
|
|
@property (nonatomic, strong) NSMutableArray <Department *>*selectDepartArray;
|
|
|
@property (nonatomic, strong) NSMutableArray <SelectModel*>*usersSourceDataArray;
|
|
|
@property (nonatomic, strong) NSMutableArray *dataSourceArray;
|
|
|
+@property (nonatomic, strong) NSMutableArray *OtherArray;
|
|
|
@property (nonatomic, strong) UIView *SortView;
|
|
|
@property (nonatomic, strong) UIButton *allSelectBtn;
|
|
|
@property (nonatomic, strong) UILabel *selectCountL;
|
|
@@ -72,7 +73,7 @@
|
|
|
[self.myNavigationBar.rightButton setTitle:@"确定" forState:UIControlStateNormal];
|
|
|
[[self.myNavigationBar.rightButton titleLabel] setFont:[UIFont systemFontOfSize:15.f]];
|
|
|
self.myNavigationBar.rightButton.hidden = NO;
|
|
|
- [self.myNavigationBar.rightButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [self.myNavigationBar.rightButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerY.equalTo(self.myNavigationBar.backButton);
|
|
|
make.height.mas_offset(@44);
|
|
|
make.right.mas_equalTo(self.myNavigationBar.mas_right).offset(-15);
|
|
@@ -120,6 +121,7 @@
|
|
|
if (depart.hadSelected) {
|
|
|
count ++;
|
|
|
}
|
|
|
+ [self countMailArray:@[depart]];
|
|
|
}
|
|
|
}
|
|
|
if (i == 1) {
|
|
@@ -128,6 +130,7 @@
|
|
|
if (model.hadSelected) {
|
|
|
count ++;
|
|
|
}
|
|
|
+ [self countMailArray:@[model]];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -135,10 +138,22 @@
|
|
|
}else{
|
|
|
NSInteger count = 0;
|
|
|
for (NSArray * array in self.dataSourceArray) {
|
|
|
- for (MailModel * model in array) {
|
|
|
- model.IsSelect = self.isAllSelected;
|
|
|
- if (model.IsSelect) {
|
|
|
- count ++;
|
|
|
+ for (id sub in array) {
|
|
|
+ if ([sub isKindOfClass:[MailModel class]]) {
|
|
|
+ MailModel * model = (MailModel *)sub;
|
|
|
+ model.IsSelect = self.isAllSelected;
|
|
|
+ if (model.IsSelect) {
|
|
|
+ count ++;
|
|
|
+ }
|
|
|
+ [self countMailArray:@[model]];
|
|
|
+ }
|
|
|
+ if ([sub isKindOfClass:[SelectModel class]]) {
|
|
|
+ SelectModel * model = (SelectModel *)sub;
|
|
|
+ model.hadSelected = self.isAllSelected;
|
|
|
+ if (model.hadSelected) {
|
|
|
+ count ++;
|
|
|
+ }
|
|
|
+ [self countMailArray:@[model]];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -158,6 +173,76 @@
|
|
|
}
|
|
|
|
|
|
- (void)confirmAction:(UIButton*)btn{
|
|
|
+ if (self.isAllSelected) {
|
|
|
+ NSMutableArray * mailArray = [NSMutableArray arrayWithArray:USERDEFAULTSGET(MAILSELECT)];
|
|
|
+ NSMutableArray * addArray = [NSMutableArray array];
|
|
|
+ for (id mail in mailArray) {
|
|
|
+ NSData * data = (NSData *)mail;
|
|
|
+ SelectModel * sModel = (SelectModel*) [NSKeyedUnarchiver unarchiveObjectWithData:data];
|
|
|
+ [addArray addObject:sModel];
|
|
|
+ }
|
|
|
+ if (addArray.count > 0) {
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":addArray}];
|
|
|
+ [self back1];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
|
|
|
+ if (self.dataSourceArray.count > 0) {
|
|
|
+ NSMutableArray * mArray = [NSMutableArray array];
|
|
|
+ for (NSArray * array in self.dataSourceArray) {
|
|
|
+ for (id sub in array) {
|
|
|
+ if ([sub isKindOfClass:[MailModel class]]) {
|
|
|
+ MailModel * model = (MailModel *)sub;
|
|
|
+ if (model.IsSelect) {
|
|
|
+ [mArray addObject:@{@"SourceType":@(model.TypeId),@"SourceId":@(0)}];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ([sub isKindOfClass:[SelectModel class]]) {
|
|
|
+ SelectModel * model = (SelectModel *)sub;
|
|
|
+ if (model.hadSelected) {
|
|
|
+ [mArray addObject:@{@"SourceType":@(0),@"SourceId":@(model.UserId)}];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mArray.count > 0) {
|
|
|
+ [paraDict setValue:mArray forKey:@"Item"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (self.departSourceDataArray.count > 0) {
|
|
|
+ NSMutableArray * mArray = [NSMutableArray array];
|
|
|
+ for (Department *model in self.departSourceDataArray) {
|
|
|
+ if (model.hadSelected) {
|
|
|
+ [mArray addObject:@{@"SourceType":@(1),@"SourceId":@(model.Id)}];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mArray.count > 0) {
|
|
|
+ [paraDict setValue:mArray forKey:@"Item"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [self.selectArray removeAllObjects];
|
|
|
+ SHOWLOADING
|
|
|
+ WS(weakSelf);
|
|
|
+ [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_User_Middle) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
|
|
|
+ REMOVESHOW
|
|
|
+ for (NSDictionary *dict in responseObject) {
|
|
|
+ SelectModel * model = [SelectModel modelWithDictionary:dict];
|
|
|
+ model.UserId = model.Id;
|
|
|
+ model.UserName = model.Name;
|
|
|
+ model.SourceType = weakSelf.SourceType;
|
|
|
+ model.SourceId = model.UserId;
|
|
|
+ model.SourceName = model.UserName;
|
|
|
+ [weakSelf.selectArray addObject:model];
|
|
|
+ }
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":weakSelf.selectArray}];
|
|
|
+ [weakSelf back1];
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ SHOWERROR([ZYCTool handerResultData:error]);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// if (self.isAllSelected) {
|
|
|
// //获取所有被选中的分组
|
|
|
// NSMutableArray *groupIDArray = [NSMutableArray array];
|
|
@@ -243,8 +328,6 @@
|
|
|
// }
|
|
|
// }
|
|
|
// NSLog(@"请求参数1%@",dic);
|
|
|
- SHOWLOADING
|
|
|
- WS(weakSelf);
|
|
|
// [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddChaoSongRen_Post] parameters:dic responseStyle:JOSN success:^(id _Nonnull responseObject) {
|
|
|
// REMOVESHOW
|
|
|
// for (NSDictionary *dict in responseObject) {
|
|
@@ -261,45 +344,12 @@
|
|
|
// } failure:^(NSError * _Nonnull error) {
|
|
|
// SHOWERROR([ZYCTool handerResultData:error]);
|
|
|
// }];
|
|
|
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
|
|
|
- if (self.dataSourceArray.count > 0) {
|
|
|
- NSMutableArray * mArray = [NSMutableArray array];
|
|
|
- for (NSArray * array in self.dataSourceArray) {
|
|
|
- for (MailModel * model in array) {
|
|
|
- [mArray addObject:@{@"SourceType":@(model.TypeId),@"SourceId":@(0)}];
|
|
|
- }
|
|
|
- }
|
|
|
- [paraDict setValue:mArray forKey:@"Item"];
|
|
|
- }
|
|
|
- if (self.departSourceDataArray.count > 0) {
|
|
|
- NSMutableArray * mArray = [NSMutableArray array];
|
|
|
- for (Department *model in self.departSourceDataArray) {
|
|
|
- [mArray addObject:@{@"SourceType":@(1),@"SourceId":@(model.Id)}];
|
|
|
- }
|
|
|
- [paraDict setValue:mArray forKey:@"Item"];
|
|
|
- }
|
|
|
- [self.selectArray removeAllObjects];
|
|
|
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_User_Middle) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
|
|
|
- REMOVESHOW
|
|
|
- for (NSDictionary *dict in responseObject) {
|
|
|
- SelectModel * model = [SelectModel modelWithDictionary:dict];
|
|
|
- model.UserId = model.Id;
|
|
|
- model.UserName = model.Name;
|
|
|
- model.SourceType = weakSelf.SourceType;
|
|
|
- model.SourceId = model.UserId;
|
|
|
- model.SourceName = model.UserName;
|
|
|
- [weakSelf.selectArray addObject:model];
|
|
|
- }
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":weakSelf.selectArray}];
|
|
|
- [weakSelf back1];
|
|
|
- } failure:^(NSError * _Nonnull error) {
|
|
|
- SHOWERROR([ZYCTool handerResultData:error]);
|
|
|
- }];
|
|
|
+
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
-- (void)setRIghtButtonTitle:(NSInteger)indeflag{
|
|
|
- [self.myNavigationBar.rightButton setTitle:[NSString stringWithFormat:@"确定(%ld)",(long)indeflag] forState:UIControlStateNormal];
|
|
|
+//- (void)setRIghtButtonTitle:(NSInteger)indeflag{
|
|
|
+// [self.myNavigationBar.rightButton setTitle:[NSString stringWithFormat:@"确定(%ld)",(long)indeflag] forState:UIControlStateNormal];
|
|
|
// if (self.isDefalutPage == 1){
|
|
|
// if (indeflag == 2) {
|
|
|
// [self.myNavigationBar.backButton2 setTitle:@"取消全选" forState:UIControlStateNormal];
|
|
@@ -309,8 +359,7 @@
|
|
|
// }else{
|
|
|
// [self.myNavigationBar.backButton2 setTitle:@"全选" forState:UIControlStateNormal];
|
|
|
// }
|
|
|
-
|
|
|
-}
|
|
|
+//}
|
|
|
#pragma mark - setter
|
|
|
- (TDTableView *)myTableView{
|
|
|
if (!_myTableView) {
|
|
@@ -375,12 +424,7 @@
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
WS(weakSelf);
|
|
|
- NSInteger count = [self countOfSelectArray];
|
|
|
- if (count > 0) {
|
|
|
- [self.myNavigationBar.rightButton setTitle:[NSString stringWithFormat:@"确定(%ld)",(long)count] forState:UIControlStateNormal];
|
|
|
- }else{
|
|
|
- [self.myNavigationBar.rightButton setTitle:@"确定" forState:UIControlStateNormal];
|
|
|
- }
|
|
|
+
|
|
|
if (!self.IsSubVC) {
|
|
|
if ([self checkAllSelect:2]) {
|
|
|
[self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
|
|
@@ -390,55 +434,72 @@
|
|
|
NSString *cellIdentifier2 = @"SendGroupBCell";
|
|
|
SendGroupBCell * cell = (SendGroupBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
|
|
|
NSArray * array = self.dataSourceArray[indexPath.section];
|
|
|
- if (array.count > 0) {
|
|
|
- MailModel * model = array[indexPath.row];
|
|
|
- [cell setDataModel:model];
|
|
|
- [cell.selectbuton setAction:^{
|
|
|
- model.IsSelect = !model.IsSelect;
|
|
|
- [weakSelf checkSelectCount:2];
|
|
|
- [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
- }];
|
|
|
+ switch (indexPath.section) {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ if (array.count > 0) {
|
|
|
+ MailModel * model = array[indexPath.row];
|
|
|
+ [cell setDataModel:model];
|
|
|
+ [cell.selectbuton setAction:^{
|
|
|
+ model.IsSelect = !model.IsSelect;
|
|
|
+ [weakSelf checkSelectCount:model];
|
|
|
+ [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:{
|
|
|
+ NSString *cellIdentifier = @"SendInfoGroupCell";
|
|
|
+ SendInfoGroupCell * detailCommentCell = (SendInfoGroupCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
|
|
+ SelectModel *model = array[indexPath.row];
|
|
|
+ [detailCommentCell loadDataDepartUserModel:model indexWith:indexPath];
|
|
|
+ [detailCommentCell.selectbuton setAction:^{
|
|
|
+ model.hadSelected = !model.hadSelected;
|
|
|
+ [weakSelf checkSelectCount:model];
|
|
|
+ [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
+ }];
|
|
|
+ detailCommentCell.rightImgeView.hidden = YES;
|
|
|
+ return detailCommentCell;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
return cell;
|
|
|
- }
|
|
|
- if (indexPath.section == 1) {
|
|
|
- if ([self checkAllSelect:0]) {
|
|
|
- [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
|
|
|
- }else{
|
|
|
- [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
- }
|
|
|
- NSString *cellIdentifier = @"SendInfoGroupCell";
|
|
|
- SendInfoGroupCell * detailCommentCell = (SendInfoGroupCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
|
|
- SelectModel *model = self.usersSourceDataArray[indexPath.row];
|
|
|
- if (model.IsDisable) {
|
|
|
- [detailCommentCell.selectbuton setEnabled:NO];
|
|
|
- [detailCommentCell.contentView setBackgroundColor:[UIColor grayColor]];
|
|
|
- }
|
|
|
- [detailCommentCell loadDataDepartUserModel:model indexWith:indexPath];
|
|
|
- [detailCommentCell.selectbuton setAction:^{
|
|
|
- model.hadSelected = !model.hadSelected;
|
|
|
- [weakSelf checkSelectCount:0];
|
|
|
- [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
- }];
|
|
|
- detailCommentCell.rightImgeView.hidden = YES;
|
|
|
- return detailCommentCell;
|
|
|
}else{
|
|
|
- if ([self checkAllSelect:1]) {
|
|
|
- [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
|
|
|
+ if (indexPath.section == 1) {
|
|
|
+ if ([self checkAllSelect:0]) {
|
|
|
+ [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
|
|
|
+ }else{
|
|
|
+ [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ NSString *cellIdentifier = @"SendInfoGroupCell";
|
|
|
+ SendInfoGroupCell * detailCommentCell = (SendInfoGroupCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
|
|
+ SelectModel *model = self.usersSourceDataArray[indexPath.row];
|
|
|
+ [detailCommentCell loadDataDepartUserModel:model indexWith:indexPath];
|
|
|
+ [detailCommentCell.selectbuton setAction:^{
|
|
|
+ model.hadSelected = !model.hadSelected;
|
|
|
+ [weakSelf checkSelectCount:model];
|
|
|
+ [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
+ }];
|
|
|
+ detailCommentCell.rightImgeView.hidden = YES;
|
|
|
+ return detailCommentCell;
|
|
|
}else{
|
|
|
- [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
+ if ([self checkAllSelect:1]) {
|
|
|
+ [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
|
|
|
+ }else{
|
|
|
+ [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ NSString *cellIdentifier2 = @"SendGroupBCell";
|
|
|
+ SendGroupBCell * sendB = (SendGroupBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
|
|
|
+ Department *model = self.departSourceDataArray[indexPath.row];
|
|
|
+ [sendB loadDataModelDepartment: model WithIndex:indexPath];
|
|
|
+ [sendB.selectbuton setAction:^{
|
|
|
+ model.hadSelected = !model.hadSelected;
|
|
|
+ [weakSelf checkSelectCount:model];
|
|
|
+ [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
+ }];
|
|
|
+ sendB.rightImgeView.hidden = NO;
|
|
|
+ return sendB;
|
|
|
}
|
|
|
- NSString *cellIdentifier2 = @"SendGroupBCell";
|
|
|
- SendGroupBCell * sendB = (SendGroupBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
|
|
|
- Department *model = self.departSourceDataArray[indexPath.row];
|
|
|
- [sendB loadDataModelDepartment: model WithIndex:indexPath];
|
|
|
- [sendB.selectbuton setAction:^{
|
|
|
- model.hadSelected = !model.hadSelected;
|
|
|
- [weakSelf checkSelectCount:1];
|
|
|
- [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
- }];
|
|
|
- sendB.rightImgeView.hidden = NO;
|
|
|
- return sendB;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -459,18 +520,22 @@
|
|
|
}
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
|
|
{
|
|
|
- UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
|
|
|
- view.backgroundColor = UIColorHex(0xF0EFF4);
|
|
|
- UILabel * titleL = [UILabel new];
|
|
|
- [view addSubview:titleL];
|
|
|
- titleL.textColor = UIColorHex(0x666666);
|
|
|
- titleL.font = Kfont(13);
|
|
|
- titleL.text = @"";
|
|
|
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_offset(48);
|
|
|
- make.centerY.mas_equalTo(view);
|
|
|
- }];
|
|
|
- return view;
|
|
|
+ if (!self.IsSubVC && section > 0) {
|
|
|
+ UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
|
|
|
+ view.backgroundColor = UIColorHex(0xF0EFF4);
|
|
|
+ UILabel * titleL = [UILabel new];
|
|
|
+ [view addSubview:titleL];
|
|
|
+ titleL.textColor = UIColorHex(0x666666);
|
|
|
+ titleL.font = Kfont(13);
|
|
|
+ titleL.text = @"最近聊天";
|
|
|
+ [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_offset(48);
|
|
|
+ make.centerY.mas_equalTo(view);
|
|
|
+ }];
|
|
|
+ return view;
|
|
|
+ }else{
|
|
|
+ return [UIView new];
|
|
|
+ }
|
|
|
}
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
if (self.IsSubVC) {
|
|
@@ -519,81 +584,75 @@
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
}else{
|
|
|
SelectModel *model = self.usersSourceDataArray[indexPath.row];
|
|
|
- if (!model.IsDisable) {
|
|
|
- model.hadSelected = !model.hadSelected;
|
|
|
- [self.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
- }
|
|
|
+ model.hadSelected = !model.hadSelected;
|
|
|
+ [self checkSelectCount:model];
|
|
|
+ [self.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
NSArray * array = [self.dataSourceArray objectAtIndex:indexPath.section];
|
|
|
- MailModel * model = [array objectAtIndex:indexPath.row];
|
|
|
- switch (model.TypeId) {
|
|
|
- case MailListUserType:
|
|
|
+ switch (indexPath.section) {
|
|
|
+ case 0:
|
|
|
{
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
- case MailListDesType:
|
|
|
- {
|
|
|
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
|
|
|
- vc.indexId = self.departSourceDataArray[indexPath.row].Id;
|
|
|
- vc.isDefalutPage = 2;
|
|
|
- vc.isMyGroup = 1;
|
|
|
- vc.SourceType = 1;
|
|
|
- vc.isShow = self.isShow;
|
|
|
- vc.IsSubVC = YES;
|
|
|
- vc.UserIds = self.UserIds;
|
|
|
- vc.titleStr = self.titleStr;
|
|
|
- vc.grouperArray = self.grouperArray;
|
|
|
- vc.isAllSelected = self.isAllSelected;
|
|
|
- [self.navigationController pushViewController:vc animated:YES];
|
|
|
- }
|
|
|
- break;
|
|
|
- case MailListSysType:
|
|
|
- {
|
|
|
-
|
|
|
+ MailModel * model = [array objectAtIndex:indexPath.row];
|
|
|
+ switch (model.TypeId) {
|
|
|
+ case MailListUserType:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MailListDesType:
|
|
|
+ {
|
|
|
+ AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
|
|
|
+ vc.indexId = self.departSourceDataArray[indexPath.row].Id;
|
|
|
+ vc.isDefalutPage = 2;
|
|
|
+ vc.isMyGroup = 1;
|
|
|
+ vc.SourceType = 1;
|
|
|
+ vc.isShow = self.isShow;
|
|
|
+ vc.IsSubVC = YES;
|
|
|
+ vc.UserIds = self.UserIds;
|
|
|
+ vc.titleStr = self.titleStr;
|
|
|
+ vc.grouperArray = self.grouperArray;
|
|
|
+ vc.isAllSelected = self.isAllSelected;
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MailListSysType:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
|
|
|
+ vc.indexId = self.departSourceDataArray[indexPath.row].Id;
|
|
|
+ vc.isDefalutPage = 2;
|
|
|
+ vc.isMyGroup = 2;
|
|
|
+ vc.titleStr = self.titleStr;
|
|
|
+ vc.SourceType = 3;
|
|
|
+ vc.IsSubVC = YES;
|
|
|
+ vc.isShow = self.isShow;
|
|
|
+ vc.UserIds = self.UserIds;
|
|
|
+ vc.grouperArray = self.grouperArray;
|
|
|
+ vc.isAllSelected = self.isAllSelected;
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
|
|
|
- vc.indexId = self.departSourceDataArray[indexPath.row].Id;
|
|
|
- vc.isDefalutPage = 2;
|
|
|
- vc.isMyGroup = 2;
|
|
|
- vc.titleStr = self.titleStr;
|
|
|
- vc.SourceType = 3;
|
|
|
- vc.IsSubVC = YES;
|
|
|
- vc.isShow = self.isShow;
|
|
|
- vc.UserIds = self.UserIds;
|
|
|
- vc.grouperArray = self.grouperArray;
|
|
|
- vc.isAllSelected = self.isAllSelected;
|
|
|
- [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ SelectModel * model = [array objectAtIndex:indexPath.row];
|
|
|
+ model.hadSelected = !model.hadSelected;
|
|
|
+ [self checkSelectCount:model];
|
|
|
+ [self.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-- (NSInteger)countOfSelectArray
|
|
|
-{
|
|
|
- NSInteger count = 0;
|
|
|
- for (SelectModel * model in self.usersSourceDataArray) {
|
|
|
- if (model.hadSelected) {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- for (Department * model in self.departSourceDataArray) {
|
|
|
- if (model.hadSelected) {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (count > 0) {
|
|
|
- [self.myNavigationBar.rightButton setTitleColor:UIColorHex(#3979D3) forState:UIControlStateNormal];
|
|
|
- }else{
|
|
|
- [self.myNavigationBar.rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
|
|
|
- }
|
|
|
- return count;
|
|
|
-}
|
|
|
+
|
|
|
- (BOOL)checkAllSelect:(NSInteger)index
|
|
|
{
|
|
|
switch (index) {
|
|
@@ -624,10 +683,20 @@
|
|
|
default:
|
|
|
{
|
|
|
for (NSArray * array in self.dataSourceArray) {
|
|
|
- for (MailModel * model in array) {
|
|
|
- if (!model.IsSelect) {
|
|
|
- [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
- return NO;
|
|
|
+ for (id sub in array) {
|
|
|
+ if ([sub isKindOfClass:[MailModel class]]) {
|
|
|
+ MailModel * model = (MailModel *)sub;
|
|
|
+ if (!model.IsSelect) {
|
|
|
+ [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ([sub isKindOfClass:[SelectModel class]]) {
|
|
|
+ SelectModel * model = (SelectModel *)sub;
|
|
|
+ if (!model.hadSelected) {
|
|
|
+ [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -637,46 +706,112 @@
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-- (void)checkSelectCount:(NSInteger)index
|
|
|
+- (void)checkSelectCount:(id)detail
|
|
|
{
|
|
|
NSInteger count = 0;
|
|
|
- switch (index) {
|
|
|
- case 0:
|
|
|
- {
|
|
|
- for (SelectModel * model in self.usersSourceDataArray) {
|
|
|
- if (model.hadSelected) {
|
|
|
+ for (SelectModel * model in self.usersSourceDataArray) {
|
|
|
+ if (model.hadSelected) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (NSArray * subArray in self.dataSourceArray) {
|
|
|
+ for (id sub in subArray) {
|
|
|
+ if ([sub isKindOfClass:[MailModel class]]) {
|
|
|
+ MailModel * model = (MailModel *)sub;
|
|
|
+ if (model.IsSelect) {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- {
|
|
|
- for (Department * model in self.departSourceDataArray) {
|
|
|
+ if ([sub isKindOfClass:[SelectModel class]]) {
|
|
|
+ SelectModel * model = (SelectModel *)sub;
|
|
|
if (model.hadSelected) {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- break;
|
|
|
- default:
|
|
|
- {
|
|
|
- for (NSArray * array in self.dataSourceArray) {
|
|
|
- for (MailModel * model in array) {
|
|
|
- if (model.IsSelect) {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ for (SelectModel * model in self.departSourceDataArray) {
|
|
|
+ if (model.hadSelected) {
|
|
|
+ count++;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
self.selectCountL.text = [NSString stringWithFormat:@"%ld",count];
|
|
|
- if (count > 0) {
|
|
|
- [self.myNavigationBar.rightButton setTitleColor:UIColorHex(#3979D3) forState:UIControlStateNormal];
|
|
|
- }else{
|
|
|
- [self.myNavigationBar.rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
|
|
|
+ [self countMailArray:@[detail]];
|
|
|
+}
|
|
|
+- (void)countMailArray:(NSArray *)sssArray
|
|
|
+{
|
|
|
+ for (id detail in sssArray) {
|
|
|
+ NSMutableArray * mailArray = [NSMutableArray arrayWithArray:USERDEFAULTSGET(MAILSELECT)];
|
|
|
+ SelectModel * ssmodel = [self addSelectModel:detail];
|
|
|
+
|
|
|
+ __block BOOL isEque = NO;
|
|
|
+ [mailArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+ SelectModel * sModel = (SelectModel*) [NSKeyedUnarchiver unarchiveObjectWithData:(NSData *)obj];
|
|
|
+ if (sModel.SourceType == ssmodel.SourceType && sModel.SourceId == ssmodel.SourceId) {
|
|
|
+ isEque = YES;
|
|
|
+ [mailArray removeObject:obj];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ if (!isEque) {
|
|
|
+ NSData * ssdata = [NSKeyedArchiver archivedDataWithRootObject:ssmodel];
|
|
|
+ [mailArray addObject:ssdata];
|
|
|
+ }
|
|
|
+ USERDEFAULTSSET(mailArray, MAILSELECT);
|
|
|
+
|
|
|
+
|
|
|
+ if (mailArray.count > 0) {
|
|
|
+ self.myNavigationBar.rightButton.enabled = YES;
|
|
|
+ [self.myNavigationBar.rightButton setTitleColor:UIColorHex(#3979D3) forState:UIControlStateNormal];
|
|
|
+ [self.myNavigationBar.rightButton setTitle:[NSString stringWithFormat:@"确定(%ld)",(long)mailArray.count] forState:UIControlStateNormal];
|
|
|
+ }else{
|
|
|
+ self.myNavigationBar.rightButton.enabled = NO;
|
|
|
+ [self.myNavigationBar.rightButton setTitle:@"确定" forState:UIControlStateNormal];
|
|
|
+ [self.myNavigationBar.rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+- (SelectModel *)addSelectModel:(id)model
|
|
|
+{
|
|
|
+ if ([model isKindOfClass:[SelectModel class]]) {
|
|
|
+ SelectModel * sModel = (SelectModel *)model;
|
|
|
+ sModel.SourceType = 0;
|
|
|
+ sModel.SourceId = sModel.UserId;
|
|
|
+ sModel.SourceName = sModel.UserName;
|
|
|
+ sModel.hadSelected = sModel.hadSelected;
|
|
|
+ sModel.AvatarUrl = sModel.AvatarUrl;
|
|
|
+ return sModel;
|
|
|
+ }
|
|
|
+ if ([model isKindOfClass:[MailModel class]]) {
|
|
|
+ MailModel * mModel = (MailModel *)model;
|
|
|
+ SelectModel * sModel = [[SelectModel alloc] init];
|
|
|
+ sModel.SourceType = mModel.TypeId;
|
|
|
+ sModel.SourceId = 0;
|
|
|
+ sModel.SourceName = mModel.Name;
|
|
|
+ sModel.TypeValue = 0;
|
|
|
+ sModel.hadSelected = mModel.IsSelect;
|
|
|
+ return sModel;
|
|
|
+ }
|
|
|
+ if ([model isKindOfClass:[MailSubModel class]]) {
|
|
|
+ MailSubModel * mModel = (MailSubModel *)model;
|
|
|
+ SelectModel * sModel = [[SelectModel alloc] init];
|
|
|
+ sModel.SourceType = mModel.TypeId;
|
|
|
+ sModel.SourceId = mModel.Id;
|
|
|
+ sModel.SourceName = mModel.Name;
|
|
|
+ sModel.TypeValue = mModel.TypeValue;
|
|
|
+ sModel.hadSelected = mModel.IsSelect;
|
|
|
+ return sModel;
|
|
|
}
|
|
|
+ if ([model isKindOfClass:[Department class]]) {
|
|
|
+ Department * mModel = (Department *)model;
|
|
|
+ SelectModel * sModel = [[SelectModel alloc] init];
|
|
|
+ sModel.SourceType = 1;
|
|
|
+ sModel.SourceId = mModel.Id;
|
|
|
+ sModel.SourceName = mModel.Name;
|
|
|
+ sModel.TypeValue = 0;
|
|
|
+ sModel.hadSelected = mModel.hadSelected;
|
|
|
+ return sModel;
|
|
|
+ }
|
|
|
+ return nil;
|
|
|
}
|
|
|
#pragma mark - 网络数据请求
|
|
|
- (void)getdata{
|
|
@@ -698,19 +833,39 @@
|
|
|
SHOWLOADING
|
|
|
WS(weakSelf);
|
|
|
[self.dataSourceArray removeAllObjects];
|
|
|
+ [self.OtherArray removeAllObjects];
|
|
|
[[HttpManager sharedHttpManager] GETUrl:Host(API_APP_User_Link) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
|
|
|
NSLog(@"%@",responseObject);
|
|
|
REMOVESHOW
|
|
|
NSMutableArray * fArray = [NSMutableArray array];
|
|
|
- NSMutableArray * sArray = [NSMutableArray array];
|
|
|
if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
|
|
|
NSArray * array = responseObject[@"Items"];
|
|
|
for (NSDictionary * dict in array) {
|
|
|
MailModel * model = [MailModel modelWithDictionary:dict];
|
|
|
[fArray addObject:model];
|
|
|
}
|
|
|
- MailModel * omodel = [MailModel modelWithDictionary:@{@"Name":@"其他",@"TypeId":@(0)}];
|
|
|
- [fArray addObject:omodel];
|
|
|
+ if ([responseObject[@"FriendUsers"] isKindOfClass:[NSArray class]]) {
|
|
|
+ NSArray * array = responseObject[@"FriendUsers"];
|
|
|
+ for (NSDictionary * dict in array) {
|
|
|
+ SelectModel * smodel = [[SelectModel alloc] initDict:dict];
|
|
|
+ smodel.SourceId = smodel.UserId;
|
|
|
+ smodel.SourceName = smodel.UserName;
|
|
|
+ smodel.SourceType = 0;
|
|
|
+ [weakSelf.OtherArray addObject:smodel];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ NSMutableArray * sArray = [NSMutableArray array];
|
|
|
+
|
|
|
+ if ([responseObject[@"LatelyChatUsers"] isKindOfClass:[NSArray class]]) {
|
|
|
+ NSArray * array = responseObject[@"LatelyChatUsers"];
|
|
|
+ for (NSDictionary * dict in array) {
|
|
|
+ SelectModel * smodel = [[SelectModel alloc] initDict:dict];
|
|
|
+ smodel.SourceId = smodel.UserId;
|
|
|
+ smodel.SourceName = smodel.UserName;
|
|
|
+ smodel.SourceType = 0;
|
|
|
+ [sArray addObject:smodel];
|
|
|
+ }
|
|
|
+ }
|
|
|
[weakSelf.dataSourceArray addObject:fArray];
|
|
|
[weakSelf.dataSourceArray addObject:sArray];
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -914,6 +1069,14 @@
|
|
|
}
|
|
|
return _dataSourceArray;
|
|
|
}
|
|
|
+- (NSMutableArray *)OtherArray
|
|
|
+{
|
|
|
+ if (!_OtherArray) {
|
|
|
+ _OtherArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ return _OtherArray;
|
|
|
+}
|
|
|
+
|
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
|
{
|
|
|
[super viewWillDisappear:animated];
|