BusinessDepartmentTreeViewController.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. //
  2. // BusinessDepartmentTreeViewController.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2017/9/7.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. // 功能描述:业务部门树型控制器
  9. #import "BusinessDepartmentTreeViewController.h"
  10. #import "AchiementDepartmentInfoModel.h"
  11. #import "Util.h"
  12. #import "BusinessDepartmentTreeTableViewCell.h"
  13. #import "BusinessDepartmentFrame.h"
  14. @interface BusinessDepartmentTreeViewController (){
  15. /**
  16. 业务部门tableview数据源
  17. */
  18. NSMutableArray *dataSource;
  19. }
  20. @end
  21. @implementation BusinessDepartmentTreeViewController
  22. #pragma 公共函数
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. dataSource = [NSMutableArray new];
  26. [self initUI];
  27. [self initData];
  28. }
  29. #pragma 委托函数
  30. /**
  31. 数据成功回调
  32. @param sender sender description
  33. */
  34. - (void)onRequestSuccess:(ASIDownManager *)sender {
  35. // 取消进度条
  36. [self cancel];
  37. // 服务器返回数据
  38. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  39. // 服务器返回数据状态值
  40. int iStatus = resultModel.status;
  41. // 服务器返回数据消息
  42. NSString *message = resultModel.message;
  43. // 服务器返回数据状态值正确
  44. if (iStatus == 0)
  45. {
  46. // 服务器返回数据结果
  47. NSArray *approvArr = (NSArray *)resultModel.result;
  48. if(approvArr != nil&&approvArr.count>0)
  49. {
  50. _arrSearch=[[NSMutableArray alloc]init];
  51. _treeArray=[[NSMutableArray alloc]init];
  52. for(int i=0;i<approvArr.count;i++){
  53. NSDictionary *dic=approvArr[i];
  54. NSInteger organizationId= [[dic objectForKey:@"OrganizationID"]integerValue];
  55. NSString *organizationCode=[dic objectForKey:@"OrganizationCode"];
  56. NSString *organizationName=[dic objectForKey:@"OrganizationName"];
  57. AchiementDepartmentInfoModel *info = [AchiementDepartmentInfoModel new];
  58. [info setOrganizationId:[NSString stringWithFormat:@"%ld",(long)organizationId]];
  59. [info setOrganizationCode:organizationCode];
  60. [info setOrganizationName:organizationName];
  61. [_arrSearch addObject:info];
  62. }
  63. NSInteger minLength= [Util findDepartmentsRootNodeLength:_arrSearch];
  64. NSMutableArray *parentArray=[Util findAllParents:_arrSearch minLength:minLength];
  65. for(int i=0;i<parentArray.count;i++){
  66. AchiementDepartmentInfoModel *infoModel=parentArray[i];
  67. BusinessDepartmentFrame *frame=[BusinessDepartmentFrame new];
  68. NSInteger minLength= [Util findDepartmentsRootNodeLength:_arrSearch];
  69. NSInteger n=infoModel.organizationCode.length/minLength;
  70. [infoModel setIsExpand:NO];
  71. [infoModel setLevelType:[NSString stringWithFormat:@"Level_Type_%ld",(long)n-1]];
  72. [frame setDepartmentFrame:infoModel];
  73. [_treeArray addObject:frame];
  74. AchiementDepartmentInfoModel *model= frame.departmentModel;
  75. [Util bindChildByParent:model allArray:_arrSearch ];
  76. }
  77. //设置数据源
  78. for (int i=0; i<_treeArray.count; i++) {
  79. BusinessDepartmentFrame *frm_1 = [_treeArray objectAtIndex:i];
  80. NSMutableArray *array = [NSMutableArray new];
  81. [array addObject:frm_1];
  82. [dataSource addObject:array];
  83. }
  84. [self.departmentTableView reloadData];
  85. [self autoExpandTree];
  86. }
  87. }
  88. // 服务器返回数据状态值异常
  89. else if(iStatus == ActionResultStatusAuthError
  90. ||iStatus == ActionResultStatusNoLogin
  91. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue)
  92. {
  93. [self showReLoginDialog:message];
  94. }
  95. // 其他情况
  96. else
  97. {
  98. [self showAlertViewText:message];
  99. }
  100. }
  101. /**
  102. 数据异常回调
  103. @param sender <#sender description#>
  104. */
  105. - (void)onRequestFail:(ASIDownManager *)sender {
  106. [self cancel];
  107. [self showAlertViewText:@"网络异常"];
  108. }
  109. /**
  110. table view的分区数
  111. @param tableView <#tableView description#>
  112. @return <#return value description#>
  113. */
  114. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  115. return dataSource.count;
  116. }
  117. /**
  118. tableview cell的高度
  119. @param tableView
  120. @param indexPath
  121. @return
  122. */
  123. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  124. {
  125. NSMutableArray *arr = [dataSource objectAtIndex:indexPath.section];
  126. BusinessDepartmentFrame *testFrame = [arr objectAtIndex:indexPath.row];
  127. return testFrame.cellHeight;
  128. }
  129. /**
  130. table view的行数
  131. @param tableView <#tableView description#>
  132. @param section <#section description#>
  133. @return <#return value description#>
  134. */
  135. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  136. NSMutableArray *models = [dataSource objectAtIndex:section];
  137. return models.count;
  138. }
  139. /**
  140. 加载tableview cell
  141. @param tableView <#tableView description#>
  142. @param indexPath <#indexPath description#>
  143. @return <#return value description#>
  144. */
  145. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  146. static NSString *cellID = @"CELLID";
  147. BusinessDepartmentTreeTableViewCell *cell = [[BusinessDepartmentTreeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  148. NSMutableArray *arr = [dataSource objectAtIndex:indexPath.section];
  149. BusinessDepartmentFrame *testFrame = [arr objectAtIndex:indexPath.row];
  150. [cell setUIWithModel:testFrame];
  151. [cell.checkBT addTarget:self action:@selector(selectBTClick:event:) forControlEvents:UIControlEventTouchUpInside];
  152. return cell;
  153. }
  154. /**
  155. table view的点击事件
  156. @param tableView <#tableView description#>
  157. @param indexPath <#indexPath description#>
  158. */
  159. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  160. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  161. NSInteger section= indexPath.section;
  162. NSMutableArray *array = [dataSource objectAtIndex:section];
  163. NSInteger row= indexPath.row;
  164. BusinessDepartmentFrame *tes = [array objectAtIndex:row];
  165. if(tes!=nil){
  166. if(tes.departmentModel!=nil){
  167. if (tes.departmentModel.childArray!=nil&&tes.departmentModel.childArray.count>0) {
  168. tes.departmentModel.isExpand = !tes.departmentModel.isExpand;
  169. [self reloadSection:section withMyTestFrame:tes withExpand:tes.departmentModel.isExpand];
  170. }
  171. }
  172. }
  173. }
  174. /**
  175. tableview的header高度
  176. @param tableView <#tableView description#>
  177. @param section <#section description#>
  178. @return <#return value description#>
  179. */
  180. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  181. return 0.01;
  182. }
  183. /**
  184. table view的footer 高度
  185. @param tableView <#tableView description#>
  186. @param section <#section description#>
  187. @return <#return value description#>
  188. */
  189. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  190. return 0.01;
  191. }
  192. #pragma 私有函数
  193. /**
  194. 初始化UI
  195. */
  196. -(void)initUI{
  197. if (_isPresentViewFlag)
  198. {
  199. UIView *vTitle = [[UIView alloc]init];
  200. vTitle.frame = CGRectMake(0, 0, Screen_Width, 44 + rectStatusHeight);
  201. vTitle.backgroundColor = NavigationBarTintColor;
  202. [self.view addSubview:vTitle];
  203. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  204. [button setImage:[UIImage imageNamed:@"icon_back"]
  205. forState:UIControlStateNormal];
  206. [button addTarget:self action:@selector(goBack)
  207. forControlEvents:UIControlEventTouchUpInside];
  208. button.frame = CGRectMake(20, rectStatusHeight + 13, 9, 15);
  209. [vTitle addSubview:button];
  210. UILabel *lblTitle = [[UILabel alloc]init];
  211. lblTitle.frame = CGRectMake(9, rectStatusHeight + 13, Screen_Width-2*9 - 20, 15);
  212. lblTitle.textColor = [UIColor whiteColor];
  213. lblTitle.text = @"请选择";
  214. lblTitle.textAlignment = NSTextAlignmentCenter;
  215. [vTitle addSubview:lblTitle];
  216. UIButton *btnSure=[UIButton buttonWithType:UIButtonTypeCustom];
  217. [btnSure setTitle:@"确定" forState:UIControlStateNormal];
  218. [btnSure addTarget:self action:@selector(submit)
  219. forControlEvents:UIControlEventTouchUpInside];
  220. btnSure.titleLabel.font= [UIFont systemFontOfSize: 15.0];
  221. btnSure.frame = CGRectMake(CGRectGetWidth(vTitle.frame)-60, rectStatusHeight + 13,40, 15);
  222. [vTitle addSubview:btnSure];
  223. }
  224. else
  225. {
  226. self.navigationItem.title = @"请选择";
  227. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  228. [button setImage:[UIImage imageNamed:@"icon_back"]
  229. forState:UIControlStateNormal];
  230. [button addTarget:self action:@selector(goBack)
  231. forControlEvents:UIControlEventTouchUpInside];
  232. button.frame = CGRectMake(0, 0,45,22);
  233. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  234. self.navigationItem.leftBarButtonItem = menuButton;
  235. [self.navigationController setNavigationBarHidden:NO];
  236. }
  237. _departmentTableView = [[UITableView alloc] initWithFrame:CGRectZero];
  238. if (_isPresentViewFlag) {
  239. self.departmentTableView.frame = CGRectMake(0, 44 + rectStatusHeight, self.view.bounds.size.width, self.view.bounds.size.height - 44 - rectStatusHeight - 1) ;
  240. }
  241. else{
  242. self.departmentTableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-rectNavHeight - rectStatusHeight - 1) ;
  243. }
  244. _departmentTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  245. _departmentTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  246. _departmentTableView.delegate = self;
  247. _departmentTableView.dataSource=self;
  248. [self.view addSubview: _departmentTableView];
  249. }
  250. /**
  251. 自动展开列表
  252. */
  253. -(void)autoExpandTree{
  254. NSInteger section= 0;
  255. NSMutableArray *array = [dataSource objectAtIndex:section];
  256. NSInteger row= 0;
  257. BusinessDepartmentFrame *frm = [array objectAtIndex:row];
  258. if (frm.departmentModel.childArray!=nil&&frm.departmentModel.childArray.count>0) {
  259. frm.departmentModel.isExpand = !frm.departmentModel.isExpand;
  260. [self reloadSection:section withMyTestFrame:frm withExpand:frm.departmentModel.isExpand];
  261. }
  262. }
  263. /**
  264. 返回按钮
  265. */
  266. -(void)goBack{
  267. if (_isPresentViewFlag) {
  268. [self dismissViewControllerAnimated:YES completion:nil];
  269. }else{
  270. [self.navigationController popViewControllerAnimated:YES];
  271. }
  272. }
  273. /**
  274. 初始化数据
  275. */
  276. -(void)initData{
  277. self.downManager = [[ASIDownManager alloc] init];
  278. self.downManager.delegate=self;
  279. self.downManager.onRequestSuccess=@selector(onRequestSuccess:);
  280. self.downManager.onRequestFail=@selector(onRequestFail:);
  281. [self startLoading];
  282. NSString *urlStr = ServerURL;
  283. NSMutableDictionary *dict = [NSMutableDictionary new];
  284. [dict setObject:@"GetOrganizationDataSource" forKey:@"Action"];
  285. [dict setObject:@"" forKey:@"OrganizationName"];
  286. [dict setObject:@"" forKey:@"OrganizationCode"];
  287. [dict setObject:kkAccountCode forKey:@"AccountCode"];
  288. [dict setObject:kkUserCode forKey:@"UserCode"];
  289. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  290. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  291. [self.downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
  292. }
  293. /**
  294. 进度条隐藏
  295. */
  296. - (void)cancel {
  297. [self stopLoading];
  298. }
  299. /**
  300. 确定按钮
  301. */
  302. -(void)submit{
  303. _departmentCodeResultArray=[[NSMutableArray alloc]init];
  304. _departmentNameResultArray=[[NSMutableArray alloc]init];
  305. if(dataSource!=nil&&dataSource.count>0){
  306. for (NSMutableArray *arr0 in dataSource) {
  307. [self getAllSelectedTreeArray:arr0];
  308. }
  309. NSString *departmentCodeResultStr=[_departmentCodeResultArray componentsJoinedByString:@","];
  310. NSString *departmentNameResultStr=[_departmentNameResultArray componentsJoinedByString:@","];
  311. if ([self.cDelegate respondsToSelector:@selector(achievementDataTreeResult: name:)]) {
  312. [self.cDelegate achievementDataTreeResult:departmentCodeResultStr name:departmentNameResultStr];
  313. }
  314. //是否是dismissViewController
  315. if (_isPresentViewFlag) {
  316. [self dismissViewControllerAnimated:YES completion:nil];
  317. }else{
  318. [self.navigationController popViewControllerAnimated:YES];
  319. }
  320. }
  321. }
  322. /**
  323. 获取所有的选中的列表
  324. @param treeArray <#treeArray description#>
  325. */
  326. -(void)getAllSelectedTreeArray:(NSMutableArray*) treeArray{
  327. for(BusinessDepartmentFrame *frm in treeArray){
  328. if(frm.departmentModel.isSelect){
  329. NSString *organizationCode=frm.departmentModel.organizationCode;
  330. NSString *organizationName=frm.departmentModel.organizationName;
  331. if(![_departmentCodeResultArray containsObject:organizationCode]){
  332. [_departmentCodeResultArray addObject:organizationCode];
  333. }
  334. if(![_departmentNameResultArray containsObject:organizationName]){
  335. [_departmentNameResultArray addObject:organizationName];
  336. }
  337. if(frm.departmentModel.childArray!=nil&&frm.departmentModel.childArray.count>0){
  338. [self getAllSelectedTreeArray:frm.departmentModel.childArray];
  339. }
  340. }
  341. }
  342. }
  343. /**
  344. 重新加载section
  345. @param section <#section description#>
  346. @param model <#model description#>
  347. @param isExpand <#isExpand description#>
  348. */
  349. - (void)reloadSection:(NSInteger)section withMyTestFrame:(BusinessDepartmentFrame *)frm withExpand:(BOOL)isExpand{
  350. NSMutableArray *arry1 = [dataSource objectAtIndex:section];
  351. NSInteger index = [arry1 indexOfObject:frm];
  352. NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(index+1, frm.departmentModel.childArray.count)];
  353. if (isExpand){
  354. if(frm!=nil){
  355. if(frm.departmentModel!=nil){
  356. AchiementDepartmentInfoModel *model=frm.departmentModel;
  357. if(model.childArray!=nil&&model.childArray.count>0){
  358. for (int i =0; i<model.childArray.count; i++) {
  359. BusinessDepartmentFrame *frame = [model.childArray objectAtIndex:i];
  360. if(frame!=nil){
  361. if(frame.departmentModel!=nil){
  362. frame.departmentModel.isExpand = NO;
  363. }
  364. }
  365. }
  366. [arry1 insertObjects:frm.departmentModel.childArray atIndexes:indexSet];
  367. }
  368. }
  369. }
  370. }
  371. else{
  372. if(frm!=nil){
  373. if(frm.departmentModel!=nil){
  374. if((frm.departmentModel.childArray!=nil&&frm.departmentModel.childArray.count>0)&&(arry1!=nil&&arry1.count>0)){
  375. [self removeChild:arry1 frame:frm];
  376. }
  377. }
  378. }
  379. }
  380. NSIndexSet *reloadSet = [NSIndexSet indexSetWithIndex:section];
  381. [self.departmentTableView reloadSections:reloadSet withRowAnimation:UITableViewRowAnimationAutomatic];
  382. }
  383. /**
  384. 收回列表
  385. @param arry <#arry description#>
  386. @param model <#model description#>
  387. */
  388. -(void)removeChild:(NSMutableArray*)arry frame:(BusinessDepartmentFrame *)frm{
  389. if(frm.departmentModel.childArray!=nil&&frm.departmentModel.childArray.count>0){
  390. for(BusinessDepartmentFrame *childFrame in frm.departmentModel.childArray){
  391. if([arry containsObject:childFrame]){
  392. [arry removeObject:childFrame];
  393. }
  394. if(childFrame.departmentModel.childArray!=nil&&childFrame.departmentModel.childArray.count>0){
  395. [self removeChild:arry frame:childFrame];
  396. }
  397. }
  398. }
  399. }
  400. /**
  401. check box点击事件
  402. @param sender <#sender description#>
  403. */
  404. - (void)selectBTClick:(UIButton*)sender event:(id)event{
  405. UITableView *cell = (UITableView *)sender.superview.superview;
  406. NSSet *touches =[event allTouches];
  407. UITouch *touch =[touches anyObject];
  408. CGPoint currentTouchPosition = [touch locationInView:self.departmentTableView];
  409. NSIndexPath *indexPath= [self.departmentTableView indexPathForRowAtPoint:currentTouchPosition];
  410. BusinessDepartmentTreeTableViewCell *businessCell= [self.departmentTableView cellForRowAtIndexPath:indexPath];
  411. businessCell.achievementModel.isSelect = !businessCell.achievementModel.isSelect;
  412. [businessCell.checkBT setImage:businessCell.achievementModel.isSelect ? [UIImage imageNamed:@"order_checked"]:[UIImage imageNamed:@"order_unchecked"] forState:UIControlStateNormal];
  413. if(businessCell.achievementModel.childArray!=nil&&businessCell.achievementModel.childArray.count>0)
  414. {
  415. [self selectAllChildNode:businessCell.achievementModel.childArray achievementCell:&businessCell];
  416. }
  417. if(dataSource!=nil&&dataSource.count>0){
  418. for (NSMutableArray *arr0 in dataSource) {
  419. [self selectParentNode:arr0 achievementFrame:businessCell.achievementFrame];
  420. }
  421. for (NSMutableArray *arr0 in dataSource) {
  422. [self deSelectParentNode:arr0 achievementFrame:businessCell.achievementFrame];
  423. }
  424. }
  425. [self.departmentTableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
  426. }
  427. /**
  428. 选中和反选所有的子节点
  429. @param childArray <#childArray description#>
  430. @param cell <#cell description#>
  431. */
  432. -(void)selectAllChildNode:(NSMutableArray*)childArray achievementCell:(BusinessDepartmentTreeTableViewCell*__autoreleasing *)cell{
  433. for(BusinessDepartmentFrame *frm in childArray){
  434. if(frm!=nil){
  435. BusinessDepartmentTreeTableViewCell* achievementCell=*cell;
  436. frm.departmentModel.isSelect=achievementCell.achievementModel.isSelect;
  437. if(frm.departmentModel.childArray!=nil&&frm.departmentModel.childArray>0){
  438. [self selectAllChildNode:frm.departmentModel.childArray achievementCell:&achievementCell];
  439. }
  440. }
  441. }
  442. }
  443. /**
  444. 选中子节点的父节点
  445. @param array <#array description#>
  446. @param achievementModel <#achievementModel description#>
  447. */
  448. -(void)selectParentNode:(NSMutableArray*)array achievementFrame:(BusinessDepartmentFrame*)achievementFrame{
  449. for(BusinessDepartmentFrame *frame in array){
  450. if(frame!=nil){
  451. if(frame.departmentModel!=nil){
  452. if(frame.departmentModel.childArray!=nil&&frame.departmentModel.childArray.count>0){
  453. if([frame.departmentModel.childArray containsObject:achievementFrame]){
  454. if(achievementFrame.departmentModel.isSelect){
  455. if([self isSelectAllChild:frame.departmentModel]){
  456. frame.departmentModel.isSelect=YES;
  457. }
  458. if(dataSource!=nil&&dataSource.count>0){
  459. for (NSMutableArray *arr0 in dataSource) {
  460. [self selectParentNode:arr0 achievementFrame:frame];
  461. }
  462. }
  463. }
  464. }
  465. for(BusinessDepartmentFrame *mo in frame.departmentModel.childArray){
  466. if(mo!=nil){
  467. if(mo.departmentModel!=nil){
  468. if(mo.departmentModel.childArray!=nil&&mo.departmentModel.childArray.count>0){
  469. [self selectParentNode:mo.departmentModel.childArray achievementFrame:achievementFrame];
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. }
  478. }
  479. /**
  480. 是否选中所有的子节点
  481. @param model <#model description#>
  482. @return <#return value description#>
  483. */
  484. -(Boolean)isSelectAllChild:(AchiementDepartmentInfoModel*)model{
  485. int i=0;
  486. Boolean flag = NO;
  487. if(model.childArray!=nil&&model.childArray.count>0){
  488. for(BusinessDepartmentFrame *frame in model.childArray){
  489. if(frame.departmentModel.isSelect){
  490. i++;
  491. }
  492. }
  493. if(model.childArray.count==i){
  494. flag=YES;
  495. }
  496. else{
  497. flag=NO;
  498. }
  499. }
  500. return flag;
  501. }
  502. /**
  503. 反选子节点的父节点
  504. @param array <#array description#>
  505. @param achievementModel <#achievementModel description#>
  506. */
  507. -(void)deSelectParentNode:(NSMutableArray*)array achievementFrame:(BusinessDepartmentFrame*)achievementFrame{
  508. for(BusinessDepartmentFrame *frame in array){
  509. if(frame.departmentModel.childArray!=nil&&frame.departmentModel.childArray.count>0){
  510. if(frame!=nil){
  511. if(frame.departmentModel!=nil){
  512. if([frame.departmentModel.childArray containsObject:achievementFrame]){
  513. if(!achievementFrame.departmentModel.isSelect){
  514. frame.departmentModel.isSelect=NO;
  515. if(dataSource!=nil&&dataSource.count>0){
  516. for (NSMutableArray *arr0 in dataSource) {
  517. [self deSelectParentNode:arr0 achievementFrame:frame];
  518. }
  519. }
  520. }
  521. }
  522. for(BusinessDepartmentFrame *mo in frame.departmentModel.childArray){
  523. if(mo!=nil){
  524. if(mo.departmentModel!=nil){
  525. if(mo.departmentModel.childArray!=nil&&mo.departmentModel.childArray.count>0){
  526. [self deSelectParentNode:mo.departmentModel.childArray achievementFrame:achievementFrame];
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. }
  534. }
  535. }
  536. @end