AddLookUpUserSecondVC.m 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. //
  2. // AddLookUpUserSecondVC.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/25.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "AddLookUpUserSecondVC.h"
  9. #import "SendInfoGroupCell.h"
  10. #import "SendGroupBCell.h"
  11. #import "MailListSearchVC.h"
  12. #import "MyTDGroupView.h"
  13. #import "MailModel.h"
  14. #import "MailListCell.h"
  15. @interface AddLookUpUserSecondVC ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (nonatomic, strong) TDTableView *myTableView;
  17. @property (nonatomic, strong) UIView *listHeaderVIew;
  18. @property (nonatomic, strong) TDButton *serachButton;
  19. @property (nonatomic, strong) AddressBookGroupModel *addressBookModel;
  20. @property (nonatomic,assign) NSInteger indexflag;
  21. @property (nonatomic, strong) NSMutableArray <SelectModel*>*selectArray;
  22. @property (nonatomic, strong) NSMutableArray <Department *>*selectDepartArray;
  23. @property (nonatomic, strong) NSMutableArray <SelectModel*>*usersSourceDataArray;
  24. @property (nonatomic, strong) NSMutableArray *dataSourceArray;
  25. @property (nonatomic, strong) NSMutableArray *OtherArray;
  26. @property (nonatomic, strong) UIView *SortView;
  27. @property (nonatomic, strong) UIButton *allSelectBtn;
  28. @property (nonatomic, strong) UILabel *selectCountL;
  29. @end
  30. @implementation AddLookUpUserSecondVC
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. [self getdata];
  34. [self.view addSubview:self.listHeaderVIew];
  35. [self.listHeaderVIew mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.right.mas_equalTo(self.view);
  37. make.top.mas_equalTo(self.myNavigationBar.mas_bottom);
  38. make.height.mas_offset(44);
  39. }];
  40. [self addSortV];
  41. [self.view addSubview:self.myTableView];
  42. [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.mas_equalTo(self.SortView.mas_bottom);
  44. make.left.right.mas_equalTo(self.view);
  45. make.bottom.mas_equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  46. }];
  47. WS(weakSelf);
  48. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  49. MailListSearchVC *vc = [[MailListSearchVC alloc] init];
  50. vc.notChangeColor = weakSelf.notSearchChangeColor;
  51. vc.IsAddUser = YES;
  52. vc.isShow = weakSelf.isShow;
  53. vc.UserIds = weakSelf.UserIds;
  54. vc.DepartmentId = weakSelf.indexId;
  55. vc.SearchType = weakSelf.isMyGroup;
  56. [weakSelf.navigationController pushViewController:vc animated:YES];
  57. }];
  58. [self.listHeaderVIew addGestureRecognizer:tap];
  59. self.fd_prefersNavigationBarHidden = YES;
  60. self.view.backgroundColor = UIColorHex(#FFFFFF);
  61. self.myTableView.backgroundColor = UIColorHex(#F5F6F8);
  62. [self createnavi];
  63. }
  64. #pragma mark - 导航视图
  65. - (void)createnavi{
  66. self.myNavigationBar.titleLabel.text = self.titleStr;
  67. [self.myNavigationBar.rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  68. [self.myNavigationBar.rightButton setTitle:@"确定" forState:UIControlStateNormal];
  69. [[self.myNavigationBar.rightButton titleLabel] setFont:[UIFont systemFontOfSize:15.f]];
  70. self.myNavigationBar.rightButton.hidden = NO;
  71. [self.myNavigationBar.rightButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  72. make.centerY.equalTo(self.myNavigationBar.backButton);
  73. make.height.mas_offset(@44);
  74. make.right.mas_equalTo(self.myNavigationBar.mas_right).offset(-15);
  75. }];
  76. }
  77. #pragma mark - 导航事件处理
  78. -(void)back{
  79. [self.navigationController popViewControllerAnimated:YES];
  80. }
  81. -(void)back1{
  82. for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
  83. NSLog(@"%@",self.navigationController.viewControllers[i]);
  84. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyWorkWordVC")]
  85. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"ChatNewGroupVC")]
  86. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"H5ViewController")]
  87. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicCreateVC")]
  88. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyFavoriteNewFindVC")]
  89. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"ChatNewRowVC")]
  90. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicGroupUserVC")]
  91. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
  92. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"CreateInterLeterVC")]
  93. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MailListByZuVC")]) {
  94. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  95. return;
  96. }
  97. }
  98. }
  99. //全选操作
  100. - (void)selectedAction{
  101. if (self.isAllSelected) {
  102. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  103. }else{
  104. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  105. }
  106. if (self.IsSubVC) {
  107. NSInteger count = 0;
  108. for(NSInteger i = 0 ; i < 2 ; i++){
  109. if (i == 0) {
  110. for (Department *depart in self.departSourceDataArray) {
  111. depart.hadSelected = self.isAllSelected;
  112. if (depart.hadSelected) {
  113. count ++;
  114. }
  115. [self countMailArray:@[depart]];
  116. }
  117. }
  118. if (i == 1) {
  119. for (SelectModel * model in self.usersSourceDataArray) {
  120. model.hadSelected = self.isAllSelected;
  121. if (model.hadSelected) {
  122. count ++;
  123. }
  124. [self countMailArray:@[model]];
  125. }
  126. }
  127. }
  128. self.selectCountL.text = [NSString stringWithFormat:@"%ld",count];
  129. }else{
  130. NSInteger count = 0;
  131. for (NSArray * array in self.dataSourceArray) {
  132. for (id sub in array) {
  133. if ([sub isKindOfClass:[MailModel class]]) {
  134. MailModel * model = (MailModel *)sub;
  135. model.IsSelect = self.isAllSelected;
  136. if (model.IsSelect) {
  137. count ++;
  138. }
  139. [self countMailArray:@[model]];
  140. }
  141. if ([sub isKindOfClass:[SelectModel class]]) {
  142. SelectModel * model = (SelectModel *)sub;
  143. model.hadSelected = self.isAllSelected;
  144. if (model.hadSelected) {
  145. count ++;
  146. }
  147. [self countMailArray:@[model]];
  148. }
  149. }
  150. }
  151. self.selectCountL.text = [NSString stringWithFormat:@"%ld",count];
  152. }
  153. [self.myTableView reloadData];
  154. }
  155. // 左边按钮 全选 取消全选
  156. - (void)secondBarButtonItems:(TDButton *)sender{
  157. [super menuAction:sender];
  158. }
  159. - (void)rightButtonAction:(TDButton *)sender{
  160. [self confirmAction:sender];
  161. }
  162. - (BOOL)hidesBottomBarWhenPushed{
  163. return YES;
  164. }
  165. - (void)confirmAction:(UIButton*)btn{
  166. if (self.isAllSelected) {
  167. NSMutableArray * mailArray = [NSMutableArray arrayWithArray:USERDEFAULTSGET(MAILSELECT)];
  168. NSMutableArray * addArray = [NSMutableArray array];
  169. for (id mail in mailArray) {
  170. NSData * data = (NSData *)mail;
  171. SelectModel * sModel = (SelectModel*) [NSKeyedUnarchiver unarchiveObjectWithData:data];
  172. [addArray addObject:sModel];
  173. }
  174. if (addArray.count > 0) {
  175. [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":addArray}];
  176. [self back1];
  177. }
  178. }else{
  179. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  180. if (self.dataSourceArray.count > 0) {
  181. NSMutableArray * mArray = [NSMutableArray array];
  182. for (NSArray * array in self.dataSourceArray) {
  183. for (id sub in array) {
  184. if ([sub isKindOfClass:[MailModel class]]) {
  185. MailModel * model = (MailModel *)sub;
  186. if (model.IsSelect) {
  187. [mArray addObject:@{@"SourceType":@(model.TypeId),@"SourceId":@(0)}];
  188. }
  189. }
  190. if ([sub isKindOfClass:[SelectModel class]]) {
  191. SelectModel * model = (SelectModel *)sub;
  192. if (model.hadSelected) {
  193. [mArray addObject:@{@"SourceType":@(0),@"SourceId":@(model.UserId)}];
  194. }
  195. }
  196. }
  197. }
  198. if (mArray.count > 0) {
  199. [paraDict setValue:mArray forKey:@"Item"];
  200. }
  201. }
  202. if (self.departSourceDataArray.count > 0) {
  203. NSMutableArray * mArray = [NSMutableArray array];
  204. for (Department *model in self.departSourceDataArray) {
  205. if (model.hadSelected) {
  206. [mArray addObject:@{@"SourceType":@(1),@"SourceId":@(model.Id)}];
  207. }
  208. }
  209. if (mArray.count > 0) {
  210. [paraDict setValue:mArray forKey:@"Item"];
  211. }
  212. }
  213. [self.selectArray removeAllObjects];
  214. SHOWLOADING
  215. WS(weakSelf);
  216. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_User_Middle) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  217. REMOVESHOW
  218. for (NSDictionary *dict in responseObject) {
  219. SelectModel * model = [SelectModel modelWithDictionary:dict];
  220. model.UserId = model.Id;
  221. model.UserName = model.Name;
  222. model.SourceType = weakSelf.SourceType;
  223. model.SourceId = model.UserId;
  224. model.SourceName = model.UserName;
  225. [weakSelf.selectArray addObject:model];
  226. }
  227. [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":weakSelf.selectArray}];
  228. [weakSelf back1];
  229. } failure:^(NSError * _Nonnull error) {
  230. SHOWERROR([ZYCTool handerResultData:error]);
  231. }];
  232. }
  233. // if (self.isAllSelected) {
  234. // //获取所有被选中的分组
  235. // NSMutableArray *groupIDArray = [NSMutableArray array];
  236. // for (Department *model in self.departSourceDataArray) {
  237. // if (model.hadSelected) {
  238. // [groupIDArray addObject:model];
  239. // }
  240. // }
  241. // for (SelectModel *mode in self.usersSourceDataArray) {
  242. // if (mode.hadSelected) {
  243. // mode.SourceType = 0;
  244. // mode.SourceId = mode.UserId;
  245. // mode.SourceName = mode.UserName;
  246. // [self.selectArray addObject:mode];
  247. // }
  248. // }
  249. // if (groupIDArray.count == 0) {
  250. // NSLog(@"选中%@",self.selectArray);
  251. // [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":self.selectArray}];
  252. // [self back1];
  253. // return;
  254. // } else {
  255. // NSMutableArray *selectedUsers = [[NSMutableArray alloc] init];
  256. // //把部门转换为成员
  257. // for (Department *model in groupIDArray) {
  258. // SelectModel *selectModel = [[SelectModel alloc] init];
  259. // selectModel.UserId = model.Id;
  260. // selectModel.UserName = model.Name ? model.Name : model.GroupName;
  261. // selectModel.SourceType = self.SourceType;
  262. // selectModel.SourceId = model.Id;
  263. // selectModel.SourceName = model.Name ? model.Name : model.GroupName;
  264. // [selectedUsers addObject:selectModel];
  265. // if ([model.Name isEqualToString:@"单位通讯录"]) {
  266. // selectModel.SourceType = 1;
  267. // }else if ([model.Name isEqualToString:@"自建通讯录"]) {
  268. // selectModel.SourceType = 3;
  269. // }
  270. // }
  271. // if (self.selectArray.count > 0) {
  272. // [selectedUsers addObjectsFromArray:self.selectArray];
  273. // }
  274. // [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":selectedUsers}];
  275. // [self back1];
  276. // return;
  277. // }
  278. // }
  279. // NSMutableArray *groupIDArray = [NSMutableArray array];
  280. // for (Department *model in self.departSourceDataArray) {
  281. // if (model.hadSelected) {
  282. // [groupIDArray addObject:@(model.Id)];
  283. // }
  284. // }
  285. // for (SelectModel *mode in self.usersSourceDataArray) {
  286. // if (mode.hadSelected) {
  287. // [self.selectArray addObject:mode];
  288. // }
  289. // }
  290. // if (self.selectArray.count > 0) {
  291. // NSLog(@"选中%@",self.selectArray);
  292. // [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":self.selectArray}];
  293. // [self back1];
  294. // return;
  295. // }else{
  296. // NSMutableDictionary *dic = @{@"ItemId":groupIDArray}.mutableCopy;
  297. // [dic setValue:@(self.isMyGroup) forKey:@"TypeId"];
  298. // if (self.isDefalutPage == 1) {
  299. // [dic setValue:@[@(0)] forKey:@"ItemId"];
  300. // if (self.indexflag == 0) {
  301. // if (self.departSourceDataArray.firstObject.hadSelected) {
  302. // [dic setValue:@(1) forKey:@"TypeId"];
  303. // }else{
  304. // [dic setValue:@(2) forKey:@"TypeId"];
  305. // }
  306. // }else if (self.indexflag == 1) {
  307. // if (self.departSourceDataArray.firstObject.hadSelected) {
  308. // [dic setValue:@(1) forKey:@"TypeId"];
  309. // }else{
  310. // [dic setValue:@(2) forKey:@"TypeId"];
  311. // }
  312. // }else if (self.indexflag == 2){
  313. // [dic setValue:@(1) forKey:@"TypeId"];
  314. // }
  315. // }
  316. // NSLog(@"请求参数1%@",dic);
  317. // [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddChaoSongRen_Post] parameters:dic responseStyle:JOSN success:^(id _Nonnull responseObject) {
  318. // REMOVESHOW
  319. // for (NSDictionary *dict in responseObject) {
  320. // SelectModel * model = [SelectModel modelWithDictionary:dict];
  321. // model.UserId = model.Id;
  322. // model.UserName = model.Name;
  323. // model.SourceType = weakSelf.SourceType;
  324. // model.SourceId = model.UserId;
  325. // model.SourceName = model.UserName;
  326. // [weakSelf.selectArray addObject:model];
  327. // }
  328. // [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFI_ChaoSongRen object:nil userInfo:@{@"selectPeople":weakSelf.selectArray}];
  329. // [weakSelf back1];
  330. // } failure:^(NSError * _Nonnull error) {
  331. // SHOWERROR([ZYCTool handerResultData:error]);
  332. // }];
  333. // }
  334. }
  335. //- (void)setRIghtButtonTitle:(NSInteger)indeflag{
  336. // [self.myNavigationBar.rightButton setTitle:[NSString stringWithFormat:@"确定(%ld)",(long)indeflag] forState:UIControlStateNormal];
  337. // if (self.isDefalutPage == 1){
  338. // if (indeflag == 2) {
  339. // [self.myNavigationBar.backButton2 setTitle:@"取消全选" forState:UIControlStateNormal];
  340. // }else{
  341. // [self.myNavigationBar.backButton2 setTitle:@"全选" forState:UIControlStateNormal];
  342. // }
  343. // }else{
  344. // [self.myNavigationBar.backButton2 setTitle:@"全选" forState:UIControlStateNormal];
  345. // }
  346. //}
  347. #pragma mark - setter
  348. - (TDTableView *)myTableView{
  349. if (!_myTableView) {
  350. _myTableView = [[TDTableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  351. _myTableView.delegate = self;
  352. _myTableView.dataSource = self;
  353. [self.myTableView registerNib:[UINib nibWithNibName:@"SendInfoGroupCell" bundle:nil] forCellReuseIdentifier:@"SendInfoGroupCell"];//SendGroupBCell
  354. [self.myTableView registerNib:[UINib nibWithNibName:@"SendGroupBCell" bundle:nil] forCellReuseIdentifier:@"SendGroupBCell"];
  355. }
  356. return _myTableView;
  357. }
  358. - (UIView *)listHeaderVIew{
  359. if (!_listHeaderVIew) {
  360. _listHeaderVIew = [UIView new];
  361. _listHeaderVIew.backgroundColor = UIColorHex(#FFFFFF);
  362. MyTDGroupView * groupView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 4, SCREEN_WIDTH, 36)];
  363. [_listHeaderVIew addSubview:groupView];
  364. }
  365. return _listHeaderVIew;
  366. }
  367. - (TDButton *)serachButton{
  368. if (!_serachButton) {
  369. _serachButton = [[TDButton alloc]initWithFrame:CGRectMake(20,5, kGXScreenWidth-40,40)];
  370. [_serachButton setTitle:@"搜索" forState:UIControlStateNormal];
  371. [[_serachButton titleLabel] setFont:[UIFont systemFontOfSize:14.f]];
  372. [_serachButton setImage:IMG(@"sendinfo_search") forState:UIControlStateNormal];
  373. [_serachButton setTitleColor:UIColorHex(B6B7B9) forState:UIControlStateNormal];
  374. _serachButton.backgroundColor = UIColorHex(F5F6F8);
  375. [_serachButton addTarget:self action:@selector(searchhander:) forControlEvents:UIControlEventTouchDown];
  376. [_serachButton layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:2];
  377. _serachButton.layer.cornerRadius = 20;
  378. _serachButton.layer.masksToBounds = YES;
  379. }
  380. return _serachButton;
  381. }
  382. - (NSMutableArray<SelectModel *> *)selectArray{
  383. if (!_selectArray) {
  384. _selectArray = [NSMutableArray array];
  385. }
  386. return _selectArray;
  387. }
  388. #pragma mark -UITableViewDelegate,UITableViewDataSource
  389. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  390. if (!self.IsSubVC) {
  391. return self.dataSourceArray.count;
  392. }else{
  393. return 2;
  394. }
  395. }
  396. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  397. if (!self.IsSubVC) {
  398. NSArray * array = self.dataSourceArray[section];
  399. return [array count];
  400. }else{
  401. if (section == 0) {
  402. return self.departSourceDataArray.count;
  403. }else{
  404. return self.usersSourceDataArray.count;
  405. }
  406. }
  407. }
  408. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  409. WS(weakSelf);
  410. if (!self.IsSubVC) {
  411. if ([self checkAllSelect:2]) {
  412. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  413. }else{
  414. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  415. }
  416. NSString *cellIdentifier2 = @"SendGroupBCell";
  417. SendGroupBCell * cell = (SendGroupBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
  418. NSArray * array = self.dataSourceArray[indexPath.section];
  419. switch (indexPath.section) {
  420. case 0:
  421. {
  422. if (array.count > 0) {
  423. MailModel * model = array[indexPath.row];
  424. [cell setDataModel:model];
  425. [cell.selectbuton setAction:^{
  426. model.IsSelect = !model.IsSelect;
  427. [weakSelf checkSelectCount:model];
  428. [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  429. }];
  430. }
  431. }
  432. break;
  433. default:{
  434. NSString *cellIdentifier = @"SendInfoGroupCell";
  435. SendInfoGroupCell * detailCommentCell = (SendInfoGroupCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  436. SelectModel *model = array[indexPath.row];
  437. [detailCommentCell loadDataDepartUserModel:model indexWith:indexPath];
  438. [detailCommentCell.selectbuton setAction:^{
  439. model.hadSelected = !model.hadSelected;
  440. [weakSelf checkSelectCount:model];
  441. [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  442. }];
  443. detailCommentCell.rightImgeView.hidden = YES;
  444. return detailCommentCell;
  445. }
  446. break;
  447. }
  448. return cell;
  449. }else{
  450. if (indexPath.section == 1) {
  451. if ([self checkAllSelect:0]) {
  452. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  453. }else{
  454. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  455. }
  456. NSString *cellIdentifier = @"SendInfoGroupCell";
  457. SendInfoGroupCell * detailCommentCell = (SendInfoGroupCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  458. SelectModel *model = self.usersSourceDataArray[indexPath.row];
  459. [detailCommentCell loadDataDepartUserModel:model indexWith:indexPath];
  460. [detailCommentCell.selectbuton setAction:^{
  461. model.hadSelected = !model.hadSelected;
  462. [weakSelf checkSelectCount:model];
  463. [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  464. }];
  465. detailCommentCell.rightImgeView.hidden = YES;
  466. return detailCommentCell;
  467. }else{
  468. if ([self checkAllSelect:1]) {
  469. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  470. }else{
  471. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  472. }
  473. NSString *cellIdentifier2 = @"SendGroupBCell";
  474. SendGroupBCell * sendB = (SendGroupBCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
  475. Department *model = self.departSourceDataArray[indexPath.row];
  476. [sendB loadDataModelDepartment: model WithIndex:indexPath];
  477. [sendB.selectbuton setAction:^{
  478. model.hadSelected = !model.hadSelected;
  479. [weakSelf checkSelectCount:model];
  480. [weakSelf.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  481. }];
  482. sendB.rightImgeView.hidden = NO;
  483. return sendB;
  484. }
  485. }
  486. }
  487. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  488. return 65.f;
  489. }
  490. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  491. {
  492. if (!self.IsSubVC && section > 0) {
  493. return 36.f;
  494. }else{
  495. return 0.01f;
  496. }
  497. }
  498. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  499. {
  500. return 0.01f;
  501. }
  502. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  503. {
  504. if (!self.IsSubVC && section > 0) {
  505. UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  506. view.backgroundColor = UIColorHex(0xF0EFF4);
  507. UILabel * titleL = [UILabel new];
  508. [view addSubview:titleL];
  509. titleL.textColor = UIColorHex(0x666666);
  510. titleL.font = Kfont(13);
  511. titleL.text = @"最近聊天";
  512. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  513. make.left.mas_offset(48);
  514. make.centerY.mas_equalTo(view);
  515. }];
  516. return view;
  517. }else{
  518. return [UIView new];
  519. }
  520. }
  521. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  522. if (self.IsSubVC) {
  523. if (self.isDefalutPage == 1) {
  524. if (indexPath.row == 0) { //
  525. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  526. vc.indexId = self.departSourceDataArray[indexPath.row].Id;
  527. vc.isDefalutPage = 2;
  528. vc.isMyGroup = 1;
  529. vc.SourceType = 1;
  530. vc.IsSubVC = YES;
  531. vc.isShow = self.isShow;
  532. vc.UserIds = self.UserIds;
  533. vc.titleStr = self.titleStr;
  534. vc.grouperArray = self.grouperArray;
  535. vc.isAllSelected = self.isAllSelected;
  536. [self.navigationController pushViewController:vc animated:YES];
  537. }else{
  538. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  539. vc.indexId = self.departSourceDataArray[indexPath.row].Id;
  540. vc.isDefalutPage = 2;
  541. vc.isMyGroup = 2;
  542. vc.titleStr = self.titleStr;
  543. vc.SourceType = 3;
  544. vc.IsSubVC = YES;
  545. vc.isShow = self.isShow;
  546. vc.UserIds = self.UserIds;
  547. vc.grouperArray = self.grouperArray;
  548. vc.isAllSelected = self.isAllSelected;
  549. [self.navigationController pushViewController:vc animated:YES];
  550. }
  551. }else{
  552. if (indexPath.section == 0) {
  553. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  554. Department *model = self.departSourceDataArray[indexPath.row];
  555. vc.indexId = model.Id;
  556. vc.isDefalutPage = 2;
  557. vc.IsSubVC = YES;
  558. vc.isShow = self.isShow;
  559. vc.UserIds = self.UserIds;
  560. vc.titleStr = self.titleStr;
  561. vc.isMyGroup = self.isMyGroup;
  562. vc.SourceType = self.SourceType;
  563. vc.grouperArray = self.grouperArray;
  564. vc.isAllSelected = self.isAllSelected;
  565. [self.navigationController pushViewController:vc animated:YES];
  566. }else{
  567. SelectModel *model = self.usersSourceDataArray[indexPath.row];
  568. model.hadSelected = !model.hadSelected;
  569. [self checkSelectCount:model];
  570. [self.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  571. }
  572. }
  573. }else{
  574. NSArray * array = [self.dataSourceArray objectAtIndex:indexPath.section];
  575. switch (indexPath.section) {
  576. case 0:
  577. {
  578. MailModel * model = [array objectAtIndex:indexPath.row];
  579. switch (model.TypeId) {
  580. case MailListUserType:
  581. {
  582. }
  583. break;
  584. case MailListDesType:
  585. {
  586. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  587. vc.indexId = self.departSourceDataArray[indexPath.row].Id;
  588. vc.isDefalutPage = 2;
  589. vc.isMyGroup = 1;
  590. vc.SourceType = 1;
  591. vc.isShow = self.isShow;
  592. vc.IsSubVC = YES;
  593. vc.UserIds = self.UserIds;
  594. vc.titleStr = self.titleStr;
  595. vc.grouperArray = self.grouperArray;
  596. vc.isAllSelected = self.isAllSelected;
  597. [self.navigationController pushViewController:vc animated:YES];
  598. }
  599. break;
  600. case MailListSysType:
  601. {
  602. }
  603. break;
  604. default:
  605. {
  606. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  607. vc.indexId = self.departSourceDataArray[indexPath.row].Id;
  608. vc.isDefalutPage = 2;
  609. vc.isMyGroup = 2;
  610. vc.titleStr = self.titleStr;
  611. vc.SourceType = 3;
  612. vc.IsSubVC = YES;
  613. vc.isShow = self.isShow;
  614. vc.UserIds = self.UserIds;
  615. vc.grouperArray = self.grouperArray;
  616. vc.isAllSelected = self.isAllSelected;
  617. [self.navigationController pushViewController:vc animated:YES];
  618. }
  619. break;
  620. }
  621. }
  622. break;
  623. default:
  624. {
  625. SelectModel * model = [array objectAtIndex:indexPath.row];
  626. model.hadSelected = !model.hadSelected;
  627. [self checkSelectCount:model];
  628. [self.myTableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  629. }
  630. break;
  631. }
  632. }
  633. }
  634. - (BOOL)checkAllSelect:(NSInteger)index
  635. {
  636. switch (index) {
  637. case 0:
  638. {
  639. for (SelectModel * model in self.usersSourceDataArray) {
  640. if (!model.hadSelected) {
  641. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  642. return NO;
  643. }
  644. }
  645. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  646. return YES;
  647. }
  648. break;
  649. case 1:
  650. {
  651. for (Department * model in self.departSourceDataArray) {
  652. if (!model.hadSelected) {
  653. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  654. return NO;
  655. }
  656. }
  657. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  658. return YES;
  659. }
  660. break;
  661. default:
  662. {
  663. for (NSArray * array in self.dataSourceArray) {
  664. for (id sub in array) {
  665. if ([sub isKindOfClass:[MailModel class]]) {
  666. MailModel * model = (MailModel *)sub;
  667. if (!model.IsSelect) {
  668. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  669. return NO;
  670. }
  671. }
  672. if ([sub isKindOfClass:[SelectModel class]]) {
  673. SelectModel * model = (SelectModel *)sub;
  674. if (!model.hadSelected) {
  675. [self.allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  676. return NO;
  677. }
  678. }
  679. }
  680. }
  681. [self.allSelectBtn setImage:IMG(@"sendinfo_yes") forState:UIControlStateNormal];
  682. return YES;
  683. }
  684. break;
  685. }
  686. }
  687. - (void)checkSelectCount:(id)detail
  688. {
  689. NSInteger count = 0;
  690. for (SelectModel * model in self.usersSourceDataArray) {
  691. if (model.hadSelected) {
  692. count++;
  693. }
  694. }
  695. for (NSArray * subArray in self.dataSourceArray) {
  696. for (id sub in subArray) {
  697. if ([sub isKindOfClass:[MailModel class]]) {
  698. MailModel * model = (MailModel *)sub;
  699. if (model.IsSelect) {
  700. count++;
  701. }
  702. }
  703. if ([sub isKindOfClass:[SelectModel class]]) {
  704. SelectModel * model = (SelectModel *)sub;
  705. if (model.hadSelected) {
  706. count++;
  707. }
  708. }
  709. }
  710. }
  711. for (SelectModel * model in self.departSourceDataArray) {
  712. if (model.hadSelected) {
  713. count++;
  714. }
  715. }
  716. self.selectCountL.text = [NSString stringWithFormat:@"%ld",count];
  717. [self countMailArray:@[detail]];
  718. }
  719. - (void)countMailArray:(NSArray *)sssArray
  720. {
  721. for (id detail in sssArray) {
  722. NSMutableArray * mailArray = [NSMutableArray arrayWithArray:USERDEFAULTSGET(MAILSELECT)];
  723. SelectModel * ssmodel = [self addSelectModel:detail];
  724. __block BOOL isEque = NO;
  725. [mailArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  726. SelectModel * sModel = (SelectModel*) [NSKeyedUnarchiver unarchiveObjectWithData:(NSData *)obj];
  727. if (sModel.SourceType == ssmodel.SourceType && sModel.SourceId == ssmodel.SourceId) {
  728. isEque = YES;
  729. [mailArray removeObject:obj];
  730. }
  731. }];
  732. if (!isEque) {
  733. NSData * ssdata = [NSKeyedArchiver archivedDataWithRootObject:ssmodel];
  734. [mailArray addObject:ssdata];
  735. }
  736. USERDEFAULTSSET(mailArray, MAILSELECT);
  737. if (mailArray.count > 0) {
  738. self.myNavigationBar.rightButton.enabled = YES;
  739. [self.myNavigationBar.rightButton setTitleColor:UIColorHex(#3979D3) forState:UIControlStateNormal];
  740. [self.myNavigationBar.rightButton setTitle:[NSString stringWithFormat:@"确定(%ld)",(long)mailArray.count] forState:UIControlStateNormal];
  741. }else{
  742. self.myNavigationBar.rightButton.enabled = NO;
  743. [self.myNavigationBar.rightButton setTitle:@"确定" forState:UIControlStateNormal];
  744. [self.myNavigationBar.rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  745. }
  746. }
  747. }
  748. - (SelectModel *)addSelectModel:(id)model
  749. {
  750. if ([model isKindOfClass:[SelectModel class]]) {
  751. SelectModel * sModel = (SelectModel *)model;
  752. sModel.SourceType = 0;
  753. sModel.SourceId = sModel.UserId;
  754. sModel.SourceName = sModel.UserName;
  755. sModel.hadSelected = sModel.hadSelected;
  756. sModel.AvatarUrl = sModel.AvatarUrl;
  757. return sModel;
  758. }
  759. if ([model isKindOfClass:[MailModel class]]) {
  760. MailModel * mModel = (MailModel *)model;
  761. SelectModel * sModel = [[SelectModel alloc] init];
  762. sModel.SourceType = mModel.TypeId;
  763. sModel.SourceId = 0;
  764. sModel.SourceName = mModel.Name;
  765. sModel.TypeValue = 0;
  766. sModel.hadSelected = mModel.IsSelect;
  767. return sModel;
  768. }
  769. if ([model isKindOfClass:[MailSubModel class]]) {
  770. MailSubModel * mModel = (MailSubModel *)model;
  771. SelectModel * sModel = [[SelectModel alloc] init];
  772. sModel.SourceType = mModel.TypeId;
  773. sModel.SourceId = mModel.Id;
  774. sModel.SourceName = mModel.Name;
  775. sModel.TypeValue = mModel.TypeValue;
  776. sModel.hadSelected = mModel.IsSelect;
  777. return sModel;
  778. }
  779. if ([model isKindOfClass:[Department class]]) {
  780. Department * mModel = (Department *)model;
  781. SelectModel * sModel = [[SelectModel alloc] init];
  782. sModel.SourceType = 1;
  783. sModel.SourceId = mModel.Id;
  784. sModel.SourceName = mModel.Name;
  785. sModel.TypeValue = 0;
  786. sModel.hadSelected = mModel.hadSelected;
  787. return sModel;
  788. }
  789. return nil;
  790. }
  791. #pragma mark - 网络数据请求
  792. - (void)getdata{
  793. if (!self.IsSubVC) {
  794. [self getRootData];
  795. }
  796. if (self.isDefalutPage == 1) {
  797. return ;
  798. }
  799. if (self.isMyGroup == 1) {
  800. [self defaltGroupData];
  801. }
  802. if (self.isMyGroup == 2) {
  803. [self myGroupData];
  804. }
  805. }
  806. - (void)getRootData
  807. {
  808. SHOWLOADING
  809. WS(weakSelf);
  810. [self.dataSourceArray removeAllObjects];
  811. [self.OtherArray removeAllObjects];
  812. [[HttpManager sharedHttpManager] GETUrl:Host(API_APP_User_Link) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  813. NSLog(@"%@",responseObject);
  814. REMOVESHOW
  815. NSMutableArray * fArray = [NSMutableArray array];
  816. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  817. NSArray * array = responseObject[@"Items"];
  818. for (NSDictionary * dict in array) {
  819. MailModel * model = [MailModel modelWithDictionary:dict];
  820. [fArray addObject:model];
  821. }
  822. if ([responseObject[@"FriendUsers"] isKindOfClass:[NSArray class]]) {
  823. NSArray * array = responseObject[@"FriendUsers"];
  824. for (NSDictionary * dict in array) {
  825. SelectModel * smodel = [[SelectModel alloc] initDict:dict];
  826. smodel.SourceId = smodel.UserId;
  827. smodel.SourceName = smodel.UserName;
  828. smodel.SourceType = 0;
  829. [weakSelf.OtherArray addObject:smodel];
  830. }
  831. }
  832. NSMutableArray * sArray = [NSMutableArray array];
  833. if ([responseObject[@"LatelyChatUsers"] isKindOfClass:[NSArray class]]) {
  834. NSArray * array = responseObject[@"LatelyChatUsers"];
  835. for (NSDictionary * dict in array) {
  836. SelectModel * smodel = [[SelectModel alloc] initDict:dict];
  837. smodel.SourceId = smodel.UserId;
  838. smodel.SourceName = smodel.UserName;
  839. smodel.SourceType = 0;
  840. [sArray addObject:smodel];
  841. }
  842. }
  843. [weakSelf.dataSourceArray addObject:fArray];
  844. [weakSelf.dataSourceArray addObject:sArray];
  845. dispatch_async(dispatch_get_main_queue(), ^{
  846. [weakSelf.myTableView reloadData];
  847. });
  848. }
  849. } failure:^(NSError * _Nonnull error) {
  850. REMOVESHOW
  851. }];
  852. }
  853. - (void)defaltGroupData{
  854. SHOWLOADING
  855. NSDictionary * paraDict = @{@"DepartmentId":@(self.indexId),@"UserIds":self.UserIds,@"IsShow":@(self.isShow)};
  856. NSLog(@"%@",paraDict);
  857. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddressBookGroup_DepartemntDetail_Post] parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  858. REMOVESHOW;
  859. NSDictionary *dic = responseObject;
  860. NSArray *departMentArray = dic[@"Departments"];
  861. NSMutableArray *departMentMutableArray = [NSMutableArray array];
  862. for (NSDictionary *dic2 in departMentArray) {
  863. Department *model = [[Department alloc]initWithDictionary:dic2 error:nil];
  864. [departMentMutableArray addObject:model];
  865. }
  866. self.departSourceDataArray = departMentMutableArray;
  867. NSArray *userArray = dic[@"Users"];
  868. NSMutableArray *usersMutableArray = [NSMutableArray array];
  869. for (NSDictionary *dic2 in userArray) {
  870. SelectModel * model = [[SelectModel alloc] initDict:dic2];
  871. [usersMutableArray addObject:model];
  872. }
  873. for (SelectModel * model in self.grouperArray) {
  874. for (SelectModel * userModel in usersMutableArray) {
  875. if (userModel.UserId == model.UserId) {
  876. userModel.IsDelete = YES;
  877. }
  878. }
  879. }
  880. NSMutableArray * checkUserArray = [NSMutableArray array];
  881. for (SelectModel * model in usersMutableArray) {
  882. if (!model.IsDelete) {
  883. [checkUserArray addObject:model];
  884. }
  885. }
  886. self.usersSourceDataArray = checkUserArray;
  887. [self.myTableView reloadData];
  888. } failure:^(NSError * _Nonnull error) {
  889. SHOWERROR([ZYCTool handerResultData:error]);
  890. }];
  891. }
  892. - (void)myGroupData{
  893. SHOWLOADING
  894. NSDictionary * paraDict = @{@"AddressBookGroupId":@(self.indexId),@"UserIds":self.UserIds,@"IsShow":@(self.isShow)};
  895. NSLog(@"%@",paraDict);
  896. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddressBookGroupUser_Get_Post] parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  897. REMOVESHOW;
  898. NSDictionary *dic = responseObject;
  899. NSArray *departMentArray = dic[@"AddressBookGroups"];
  900. NSMutableArray *departMentMutableArray = [NSMutableArray array];
  901. for (NSDictionary *dic2 in departMentArray) {
  902. Department *model = [[Department alloc]initWithDictionary:dic2 error:nil];
  903. [departMentMutableArray addObject:model];
  904. }
  905. self.departSourceDataArray = departMentMutableArray;
  906. NSArray *userArray = dic[@"AddressBookGroupUsers"];
  907. NSMutableArray *usersMutableArray = [NSMutableArray array];
  908. for (NSDictionary *dic2 in userArray) {
  909. SelectModel * model = [SelectModel modelWithDictionary:dic2];
  910. [usersMutableArray addObject:model];
  911. }
  912. for (SelectModel * model in self.grouperArray) {
  913. for (SelectModel * userModel in usersMutableArray) {
  914. if (userModel.UserId == model.UserId) {
  915. userModel.IsDelete = YES;
  916. }
  917. }
  918. }
  919. NSMutableArray * checkUserArray = [NSMutableArray array];
  920. for (SelectModel * model in usersMutableArray) {
  921. if (!model.IsDelete) {
  922. [checkUserArray addObject:model];
  923. }
  924. }
  925. self.usersSourceDataArray = checkUserArray;
  926. [self.myTableView reloadData];
  927. } failure:^(NSError * _Nonnull error) {
  928. SHOWERROR([ZYCTool handerResultData:error]);
  929. }];
  930. }
  931. #pragma mark - 搜索事件处理
  932. - (void)searchhander:(TDButton *)sedner{
  933. }
  934. -(void)getSearchKeyWord:(NSString *)searchWord{
  935. NSLog(@"%@",searchWord);
  936. if(searchWord.length > 0){
  937. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  938. [dict setObject:searchWord forKey:@"Key"];
  939. WEAKSELF
  940. [[HttpManager sharedHttpManager] POSTWithUrl:Host(AddressBookGroup_Search_Post) parameters:dict success:^(id _Nonnull responseObject) {
  941. STRONGSELF
  942. NSArray *array = responseObject;
  943. if (array.count == 0) {
  944. SHOWERROR(@"没有搜到结果");
  945. }else{
  946. NSArray *userArray = responseObject;
  947. NSMutableArray *usersMutableArray = [NSMutableArray array];
  948. for (NSDictionary *dic2 in userArray) {
  949. SelectModel * model = [[SelectModel alloc] initDict:dic2];
  950. [usersMutableArray addObject:model];
  951. }
  952. [strongSelf.departSourceDataArray removeAllObjects];
  953. strongSelf.usersSourceDataArray = usersMutableArray;
  954. [strongSelf.myTableView reloadData];
  955. [strongSelf.myTableView reloadData];
  956. }
  957. } failure:^(NSError * _Nonnull error) {
  958. SHOWERROR([ZYCTool handerResultData:error])
  959. }];
  960. }else{
  961. }
  962. }
  963. - (void)canCelAllSelect
  964. {
  965. for (SelectModel * model in self.usersSourceDataArray) {
  966. model.hadSelected = NO;
  967. }
  968. for (Department * model in self.departSourceDataArray) {
  969. model.hadSelected = NO;
  970. }
  971. }
  972. - (UIButton *)allSelectBtn
  973. {
  974. if (!_allSelectBtn) {
  975. _allSelectBtn = [UIButton new];
  976. [_allSelectBtn setImage:IMG(@"sendinfo_no") forState:UIControlStateNormal];
  977. }
  978. return _allSelectBtn;
  979. }
  980. - (UILabel *)selectCountL
  981. {
  982. if (!_selectCountL) {
  983. _selectCountL = [UILabel new];
  984. _selectCountL.font = Kfont(13);
  985. _selectCountL.text = @"0";
  986. _selectCountL.textColor = UIColorHex(0x0F88EB);
  987. }
  988. return _selectCountL;
  989. }
  990. - (UIView *)SortView
  991. {
  992. if (!_SortView) {
  993. _SortView = [UIView new];
  994. _SortView.backgroundColor = UIColorHex(0xF0EFF4);
  995. }
  996. return _SortView;
  997. }
  998. - (void)addSortV
  999. {
  1000. [self.view addSubview:self.SortView];
  1001. [self.SortView mas_makeConstraints:^(MASConstraintMaker *make) {
  1002. make.left.right.mas_equalTo(self.view);
  1003. make.height.mas_offset(38);
  1004. make.top.mas_equalTo(self.listHeaderVIew.mas_bottom);
  1005. }];
  1006. [self.SortView addSubview:self.allSelectBtn];
  1007. [self.SortView addSubview:self.selectCountL];
  1008. [self.allSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1009. make.left.mas_offset(5);
  1010. make.centerY.mas_equalTo(self.SortView);
  1011. make.size.mas_offset(CGSizeMake(38, 38));
  1012. }];
  1013. UILabel * leftL = [UILabel new];
  1014. leftL.text = @"已选:";
  1015. leftL.textColor = UIColorHex(0x666666);
  1016. leftL.font = Kfont(13);
  1017. [self.SortView addSubview:leftL];
  1018. [leftL mas_makeConstraints:^(MASConstraintMaker *make) {
  1019. make.left.mas_equalTo(self.allSelectBtn.mas_right).offset(5);
  1020. make.centerY.mas_equalTo(self.SortView);
  1021. }];
  1022. [self.selectCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  1023. make.left.mas_equalTo(leftL.mas_right).offset(8);
  1024. make.centerY.mas_equalTo(self.SortView);
  1025. }];
  1026. WS(weakSelf);
  1027. [self.allSelectBtn setAction:^{
  1028. weakSelf.isAllSelected = !weakSelf.isAllSelected;
  1029. [weakSelf selectedAction];
  1030. }];
  1031. }
  1032. - (NSMutableArray *)dataSourceArray
  1033. {
  1034. if (!_dataSourceArray) {
  1035. _dataSourceArray = [NSMutableArray array];
  1036. }
  1037. return _dataSourceArray;
  1038. }
  1039. - (NSMutableArray *)OtherArray
  1040. {
  1041. if (!_OtherArray) {
  1042. _OtherArray = [NSMutableArray array];
  1043. }
  1044. return _OtherArray;
  1045. }
  1046. - (void)viewWillDisappear:(BOOL)animated
  1047. {
  1048. [super viewWillDisappear:animated];
  1049. [self canCelAllSelect];
  1050. [self.myTableView reloadData];
  1051. }
  1052. @end