GoodsKindViewController.m 23 KB

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