123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597 |
- //
- // AddLookUpUserSecondVC.m
- // smartRhino
- //
- // Created by tederen on 2019/11/25.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "AddLookUpUserSecondVC.h"
- #import "SendInfoGroupCell.h"
- #import "SendGroupBCell.h"
- #import "MailListSearchVC.h"
- #import "MyTDGroupView.h"
- @interface AddLookUpUserSecondVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) TDTableView *myTableView;
- @property (nonatomic, strong) UIView *listHeaderVIew;
- @property (nonatomic, strong) TDButton *serachButton;
- @property (nonatomic, strong) AddressBookGroupModel *addressBookModel;
- @property (nonatomic,assign) NSInteger indexflag;
- @property (nonatomic, strong) NSMutableArray <SelectModel*>*selectArray;
- @property (nonatomic, strong) NSMutableArray <Department *>*selectDepartArray;
- @property (nonatomic, strong) NSMutableArray <SelectModel*>*usersSourceDataArray;
- @end
- @implementation AddLookUpUserSecondVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self getdata];
- [self.view addSubview:self.myTableView];
- self.myTableView.frame = CGRectMake(0,kNavigationHeight+5,kGXScreenWidth, kGXScreenHeigh - kNavigationHeight-5);
- [self.myTableView setTableHeaderView:self.listHeaderVIew];
- WS(weakSelf);
- UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
- MailListSearchVC *vc = [[MailListSearchVC alloc] init];
- vc.notChangeColor = weakSelf.notSearchChangeColor;
- vc.IsAddUser = YES;
- vc.isShow = weakSelf.isShow;
- vc.UserIds = weakSelf.UserIds;
- vc.DepartmentId = weakSelf.indexId;
- vc.SearchType = weakSelf.isMyGroup;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [self.listHeaderVIew addGestureRecognizer:tap];
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = UIColorHex(#FFFFFF);
- self.myTableView.backgroundColor = UIColorHex(#F5F6F8);
- [self createnavi];
- }
- #pragma mark - 导航视图
- - (void)createnavi{
- self.myNavigationBar.titleLabel.text = self.titleStr;
- [self.myNavigationBar.backButton2 setImage:nil forState:UIControlStateNormal];
- [self.myNavigationBar.backButton2 setTitle:@"全选" forState:UIControlStateNormal];
- [self.myNavigationBar.backButton2 setTitleColor:UIColorHex(#3979D3) forState:UIControlStateNormal];
- [[self.myNavigationBar.backButton titleLabel] setFont:[UIFont systemFontOfSize:15.f]];
- [self.myNavigationBar.backButton2 mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.myNavigationBar.backButton);
- make.left.mas_equalTo(self.myNavigationBar.backButton.mas_right);
- make.height.mas_offset(@44);
- make.width.mas_greaterThanOrEqualTo(10);
- }];
- [self.myNavigationBar.rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
- [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) {
- make.centerY.equalTo(self.myNavigationBar.backButton);
- make.height.mas_offset(@44);
- make.right.mas_equalTo(self.myNavigationBar.mas_right).offset(-15);
- }];
- }
- #pragma mark - 导航事件处理
- -(void)back{
- [self.navigationController popViewControllerAnimated:YES];
-
- }
- -(void)back1{
- for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
- NSLog(@"%@",self.navigationController.viewControllers[i]);
- if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyWorkWordVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"ChatNewGroupVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"H5ViewController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicCreateVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyFavoriteNewFindVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"ChatNewRowVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicGroupUserVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"CreateInterLeterVC")]
- || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MailListByZuVC")]) {
- [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
- return;
- }
- }
- }
- //全选操作
- - (void)selectedAction:(UIButton*)btn{
- btn.selected = !btn.selected;
- for(int i = 0 ; i < 2 ; i++){
- if (i == 0) {
- for (Department *depart in self.departSourceDataArray) {
- depart.hadSelected = btn.selected;
- }
- }
- if (i == 1) {
- for (SelectModel *depart in self.usersSourceDataArray) {
- depart.hadSelected = btn.selected;
- }
- }
- }
- [self.myTableView reloadData];
- }
- // 左边按钮 全选 取消全选
- - (void)secondBarButtonItems:(TDButton *)sender{
- [self selectedAction:sender];
- }
- - (void)rightButtonAction:(TDButton *)sender{
- [self confirmAction:sender];
- }
- - (BOOL)hidesBottomBarWhenPushed{
- return YES;
- }
- - (void)confirmAction:(UIButton*)btn{
- if (self.isAllSelected) {
- //获取所有被选中的分组
- NSMutableArray *groupIDArray = [NSMutableArray array];
- for (Department *model in self.departSourceDataArray) {
- if (model.hadSelected) {
- [groupIDArray addObject:model];
- }
- }
- for (SelectModel *mode in self.usersSourceDataArray) {
- if (mode.hadSelected) {
- mode.SourceType = 0;
- mode.SourceId = mode.UserId;
- mode.SourceName = mode.UserName;
- [self.selectArray addObject:mode];
- }
- }
- if (groupIDArray.count == 0) {
- NSLog(@"选中%@",self.selectArray);
- [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":self.selectArray}];
- [self back1];
- return;
- } else {
- NSMutableArray *selectedUsers = [[NSMutableArray alloc] init];
- //把部门转换为成员
- for (Department *model in groupIDArray) {
- SelectModel *selectModel = [[SelectModel alloc] init];
- selectModel.UserId = model.Id;
- selectModel.UserName = model.Name ? model.Name : model.GroupName;
- selectModel.SourceType = self.SourceType;
- selectModel.SourceId = model.Id;
- selectModel.SourceName = model.Name ? model.Name : model.GroupName;
- [selectedUsers addObject:selectModel];
- if ([model.Name isEqualToString:@"单位通讯录"]) {
- selectModel.SourceType = 1;
- }else if ([model.Name isEqualToString:@"自建通讯录"]) {
- selectModel.SourceType = 3;
- }
- }
- if (self.selectArray.count > 0) {
- [selectedUsers addObjectsFromArray:self.selectArray];
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":selectedUsers}];
- [self back1];
- return;
- }
- }
- NSMutableArray *groupIDArray = [NSMutableArray array];
- for (Department *model in self.departSourceDataArray) {
- if (model.hadSelected) {
- [groupIDArray addObject:@(model.Id)];
- }
- }
- for (SelectModel *mode in self.usersSourceDataArray) {
- if (mode.hadSelected) {
- [self.selectArray addObject:mode];
- }
- }
- NSMutableDictionary *dic = @{@"ItemId":groupIDArray}.mutableCopy;
- [dic setValue:@(self.isMyGroup) forKey:@"TypeId"];
- NSLog(@"请求参数1%@",dic);
- if (groupIDArray.count == 0) {
- NSLog(@"选中%@",self.selectArray);
- [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":self.selectArray}];
- [self back1];
- return;
- }else{
- if (self.isDefalutPage == 1) {
- [dic setValue:@[@(0)] forKey:@"ItemId"];
- if (self.indexflag == 0) {
- if (self.departSourceDataArray.firstObject.hadSelected) {
- [dic setValue:@(1) forKey:@"TypeId"];
- }else{
- [dic setValue:@(2) forKey:@"TypeId"];
- }
- }else if (self.indexflag == 1) {
- if (self.departSourceDataArray.firstObject.hadSelected) {
- [dic setValue:@(1) forKey:@"TypeId"];
- }else{
- [dic setValue:@(2) forKey:@"TypeId"];
- }
- }else if (self.indexflag == 2){
- [dic setValue:@(1) forKey:@"TypeId"];
- }
- }
- 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) {
- 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];
- if (self.isDefalutPage == 1){
- if (indeflag == 2) {
- [self.myNavigationBar.backButton2 setTitle:@"取消全选" forState:UIControlStateNormal];
- }else{
- [self.myNavigationBar.backButton2 setTitle:@"全选" forState:UIControlStateNormal];
- }
- }else{
- [self.myNavigationBar.backButton2 setTitle:@"全选" forState:UIControlStateNormal];
- }
-
- }
- #pragma mark - setter
- - (TDTableView *)myTableView{
- if (!_myTableView) {
- _myTableView = [[TDTableView alloc]init ];
- _myTableView.delegate = self;
- _myTableView.dataSource = self;
- [self.myTableView registerNib:[UINib nibWithNibName:@"SendInfoGroupCell" bundle:nil] forCellReuseIdentifier:@"SendInfoGroupCell"];//SendGroupBCell
- [self.myTableView registerNib:[UINib nibWithNibName:@"SendGroupBCell" bundle:nil] forCellReuseIdentifier:@"SendGroupBCell"];
- }
- return _myTableView;
- }
- - (UIView *)listHeaderVIew{
- if (!_listHeaderVIew) {
- _listHeaderVIew = [[UIView alloc]initWithFrame:CGRectMake(0,0,kGXScreenWidth,44)];
- _listHeaderVIew.backgroundColor = UIColorHex(#FFFFFF);
- MyTDGroupView * groupView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 4, SCREEN_WIDTH, 36)];
- [_listHeaderVIew addSubview:groupView];
- }
- return _listHeaderVIew;
- }
- - (TDButton *)serachButton{
- if (!_serachButton) {
- _serachButton = [[TDButton alloc]initWithFrame:CGRectMake(20,5, kGXScreenWidth-40,40)];
- [_serachButton setTitle:@"搜索" forState:UIControlStateNormal];
- [[_serachButton titleLabel] setFont:[UIFont systemFontOfSize:14.f]];
- [_serachButton setImage:IMG(@"sendinfo_search") forState:UIControlStateNormal];
- [_serachButton setTitleColor:UIColorHex(B6B7B9) forState:UIControlStateNormal];
- _serachButton.backgroundColor = UIColorHex(F5F6F8);
- [_serachButton addTarget:self action:@selector(searchhander:) forControlEvents:UIControlEventTouchDown];
- [_serachButton layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:2];
- _serachButton.layer.cornerRadius = 20;
- _serachButton.layer.masksToBounds = YES;
- }
- return _serachButton;
- }
- - (NSMutableArray<SelectModel *> *)selectArray{
- if (!_selectArray) {
- _selectArray = [NSMutableArray array];
- }
- return _selectArray;
- }
- #pragma mark -UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 2;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- if (section == 0) {
- return self.departSourceDataArray.count;
- }else{
- return self.usersSourceDataArray.count;
- }
- return 0;
- }
- - (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 (indexPath.section == 1) {
- if ([self checkAllSelect:0]) {
- [self.myNavigationBar.backButton2 setTitle:@"取消全选" forState:UIControlStateNormal];
- }else{
- [self.myNavigationBar.backButton2 setTitle:@"全选" 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.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- }];
- detailCommentCell.rightImgeView.hidden = YES;
- return detailCommentCell;
- }else{
- if ([self checkAllSelect:1]) {
- [self.myNavigationBar.backButton2 setTitle:@"取消全选" forState:UIControlStateNormal];
- }else{
- [self.myNavigationBar.backButton2 setTitle:@"全选" 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.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- }];
- sendB.rightImgeView.hidden = NO;
- return sendB;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 65;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.isDefalutPage == 1) {
- if (indexPath.row == 0) { //
- 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.UserIds = self.UserIds;
- vc.titleStr = self.titleStr;
- vc.grouperArray = self.grouperArray;
- vc.isAllSelected = self.isAllSelected;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- 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.isShow = self.isShow;
- vc.UserIds = self.UserIds;
- vc.grouperArray = self.grouperArray;
- vc.isAllSelected = self.isAllSelected;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }else{
- if (indexPath.section == 0) {
- AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
- Department *model = self.departSourceDataArray[indexPath.row];
- vc.indexId = model.Id;
- vc.isDefalutPage = 2;
- vc.isShow = self.isShow;
- vc.UserIds = self.UserIds;
- vc.titleStr = self.titleStr;
- vc.isMyGroup = self.isMyGroup;
- vc.SourceType = self.SourceType;
- vc.grouperArray = self.grouperArray;
- vc.isAllSelected = self.isAllSelected;
- [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];
- }
- }
- }
- }
- - (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) {
- case 0:
- {
- for (SelectModel * model in self.usersSourceDataArray) {
- if (!model.hadSelected) {
- return NO;
- }
- }
- return YES;
- }
- break;
- default:
- {
- for (Department * model in self.departSourceDataArray) {
- if (!model.hadSelected) {
- return NO;
- }
- }
- return YES;
- }
- break;
- }
- }
- #pragma mark - 网络数据请求
- - (void)getdata{
- if (self.isDefalutPage == 1) {
- return ;
- }
- SHOWLOADING
- if (self.isMyGroup == 1) {
- [self defaltGroupData];
- }
- if (self.isMyGroup == 2) {
- [self myGroupData];
- }
-
- }
- - (void)defaltGroupData{
- NSDictionary * paraDict = @{@"DepartmentId":@(self.indexId),@"UserIds":self.UserIds,@"IsShow":@(self.isShow)};
- NSLog(@"%@",paraDict);
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddressBookGroup_DepartemntDetail_Post] parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- REMOVESHOW;
- NSDictionary *dic = responseObject;
- NSArray *departMentArray = dic[@"Departments"];
- NSMutableArray *departMentMutableArray = [NSMutableArray array];
- for (NSDictionary *dic2 in departMentArray) {
- Department *model = [[Department alloc]initWithDictionary:dic2 error:nil];
- [departMentMutableArray addObject:model];
- }
- self.departSourceDataArray = departMentMutableArray;
- NSArray *userArray = dic[@"Users"];
- NSMutableArray *usersMutableArray = [NSMutableArray array];
- for (NSDictionary *dic2 in userArray) {
- SelectModel * model = [[SelectModel alloc] initDict:dic2];
- [usersMutableArray addObject:model];
- }
- for (SelectModel * model in self.grouperArray) {
- for (SelectModel * userModel in usersMutableArray) {
- if (userModel.UserId == model.UserId) {
- userModel.IsDelete = YES;
- }
- }
- }
- NSMutableArray * checkUserArray = [NSMutableArray array];
- for (SelectModel * model in usersMutableArray) {
- if (!model.IsDelete) {
- [checkUserArray addObject:model];
- }
- }
- self.usersSourceDataArray = checkUserArray;
- [self.myTableView reloadData];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)myGroupData{
- NSDictionary * paraDict = @{@"AddressBookGroupId":@(self.indexId),@"UserIds":self.UserIds,@"IsShow":@(self.isShow)};
- NSLog(@"%@",paraDict);
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddressBookGroupUser_Get_Post] parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- REMOVESHOW;
- NSDictionary *dic = responseObject;
- NSArray *departMentArray = dic[@"AddressBookGroups"];
- NSMutableArray *departMentMutableArray = [NSMutableArray array];
- for (NSDictionary *dic2 in departMentArray) {
- Department *model = [[Department alloc]initWithDictionary:dic2 error:nil];
- [departMentMutableArray addObject:model];
- }
- self.departSourceDataArray = departMentMutableArray;
- NSArray *userArray = dic[@"AddressBookGroupUsers"];
- NSMutableArray *usersMutableArray = [NSMutableArray array];
- for (NSDictionary *dic2 in userArray) {
- SelectModel * model = [SelectModel modelWithDictionary:dic2];
- [usersMutableArray addObject:model];
- }
- for (SelectModel * model in self.grouperArray) {
- for (SelectModel * userModel in usersMutableArray) {
- if (userModel.UserId == model.UserId) {
- userModel.IsDelete = YES;
- }
- }
- }
- NSMutableArray * checkUserArray = [NSMutableArray array];
- for (SelectModel * model in usersMutableArray) {
- if (!model.IsDelete) {
- [checkUserArray addObject:model];
- }
- }
- self.usersSourceDataArray = checkUserArray;
- [self.myTableView reloadData];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - 搜索事件处理
- - (void)searchhander:(TDButton *)sedner{
-
- }
- -(void)getSearchKeyWord:(NSString *)searchWord{
- NSLog(@"%@",searchWord);
- if(searchWord.length > 0){
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:searchWord forKey:@"Key"];
-
- WEAKSELF
-
-
- [[HttpManager sharedHttpManager] POSTWithUrl:Host(AddressBookGroup_Search_Post) parameters:dict success:^(id _Nonnull responseObject) {
- STRONGSELF
- NSArray *array = responseObject;
- if (array.count == 0) {
- SHOWERROR(@"没有搜到结果");
- }else{
-
- NSArray *userArray = responseObject;
- NSMutableArray *usersMutableArray = [NSMutableArray array];
- for (NSDictionary *dic2 in userArray) {
- SelectModel * model = [[SelectModel alloc] initDict:dic2];
- [usersMutableArray addObject:model];
- }
- [strongSelf.departSourceDataArray removeAllObjects];
- strongSelf.usersSourceDataArray = usersMutableArray;
- [strongSelf.myTableView reloadData];
- [strongSelf.myTableView reloadData];
-
- }
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error])
-
- }];
- }else{
-
- }
- }
- - (void)canCelAllSelect
- {
- for (SelectModel * model in self.usersSourceDataArray) {
- model.hadSelected = NO;
- }
- for (Department * model in self.departSourceDataArray) {
- model.hadSelected = NO;
- }
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self canCelAllSelect];
- [self.myTableView reloadData];
- }
- @end
|