WillDoVC.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. //
  2. // WillDoVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/6.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "WillDoVC.h"
  9. #import "WillDoCell.h"
  10. #import "WD_DetailVC.h"
  11. #import "RegionsList.h"
  12. @interface WillDoVC ()<UITableViewDelegate,UITableViewDataSource>
  13. {
  14. UITableView *_tableView;
  15. NSMutableArray *_dataArray;
  16. NSArray *_titleArray;
  17. NSArray *_shortTitleArray;
  18. NSArray *_imagesArray;
  19. }
  20. @end
  21. @implementation WillDoVC
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.navigationItem.title = @"待办";
  25. self.view.backgroundColor = [UIColor whiteColor];
  26. //@"学时审核",,@"学时" ,@"study_check"
  27. _titleArray = @[@"系统升级公告",@"教学区域审核",@"驾校审核通知",@"教练审核通知",@"教练车审核通知",@"终端审核通知",@"管理部门下发通知"];
  28. _shortTitleArray = @[@"公告",@"围栏",@"驾校",@"教练",@"车辆",@"终端",@"转校",@"通知"];
  29. _imagesArray = @[@"system_notify",@"teach_area",@"school_check",@"coach_check",@"car_check",@"terminal_check",@"notify"];
  30. _dataArray = [NSMutableArray new];
  31. [self myInit];
  32. }
  33. -(void)viewWillAppear:(BOOL)animated{
  34. [super viewWillAppear:animated];
  35. [self getData];
  36. }
  37. -(void)myInit{
  38. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height - kTabBarHeight) style:UITableViewStylePlain];
  39. _tableView.rowHeight = 70.0f;
  40. _tableView.delegate = self;
  41. _tableView.dataSource = self;
  42. _tableView.backgroundColor = RGB_COLOR(242, 243, 241);
  43. _tableView.showsVerticalScrollIndicator = NO;
  44. [self.view addSubview:_tableView];
  45. [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"];
  46. UIView *view = [UIView new];
  47. _tableView.tableFooterView = view;
  48. }
  49. #pragma mark tableview代理方法
  50. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  51. return _titleArray.count;
  52. }
  53. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  54. WillDoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WillDoCellId" forIndexPath:indexPath];
  55. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  56. cell.imageName = _imagesArray[indexPath.row];
  57. cell.titleLabel.text = _titleArray[indexPath.row];
  58. if (_dataArray.count == _titleArray.count) {
  59. NSString * str = [NSString stringWithFormat:@"%@",_dataArray[indexPath.row]];
  60. if ([str floatValue] == 0) {
  61. cell.markNumLabel.hidden = YES;
  62. }else{
  63. cell.markNumLabel.hidden = NO;
  64. cell.markNumLabel.text = [str integerValue]>999?@"999+":str;
  65. }
  66. }
  67. return cell;
  68. }
  69. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  70. if (indexPath.row == 1){
  71. [Tools permissionValidationWithID:@"804" result:^(BOOL isCan, NSString *failureStr) {
  72. if (!isCan) {
  73. if (failureStr) {
  74. [self showMsgByMBWithString:failureStr];
  75. }
  76. return;
  77. }
  78. RegionsList * vc = [[RegionsList alloc]init];
  79. vc.type = @"1";
  80. [self.navigationController pushViewController:vc animated:YES];
  81. }];
  82. return;
  83. }
  84. WD_DetailVC * vc = [[WD_DetailVC alloc]init];
  85. vc.navigationItem.title = _titleArray[indexPath.row];
  86. vc.type = [NSString stringWithFormat:@"%ld",(long)indexPath.row +1];
  87. NSArray *arr = @[@"2",@"3",@"4",@"5",@"6"];
  88. if ([arr containsObject:vc.type]) {
  89. NSInteger theId = [vc.type integerValue]+802;
  90. [Tools permissionValidationWithID:[NSString stringWithFormat:@"%ld",theId] result:^(BOOL isCan, NSString *failureStr) {
  91. if (!isCan) {
  92. if (failureStr) {
  93. [self showMsgByMBWithString:failureStr];
  94. }
  95. return;
  96. }else{
  97. [self.navigationController pushViewController:vc animated:YES];
  98. }
  99. }];
  100. }else{
  101. [self.navigationController pushViewController:vc animated:YES];
  102. }
  103. }
  104. - (void)didReceiveMemoryWarning {
  105. [super didReceiveMemoryWarning];
  106. // Dispose of any resources that can be recreated.
  107. }
  108. #pragma mark 网络请求
  109. -(void)getData{
  110. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  111. [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  112. [NetworkManager requestWithMethod:@"getMsgStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  113. if (failureStr) {
  114. return;
  115. }
  116. if ([successDic[@"code"] isEqualToString:@"1"]) {
  117. return;
  118. }
  119. [_dataArray removeAllObjects];
  120. //,@"TIMEAUDITNUM"
  121. NSArray * keys = @[@"SYSTEMNOTICENUM",@"REGIONAUDITNUM",@"SCHOOLAUDITNUM",@"COACHAUDITNUM",@"CARAUDITNUM",@"DEVAUDITNUM",@"NOTICENUM"];
  122. NSDictionary * dic = successDic[@"body"][0];
  123. int count = 0;
  124. for (int i=0; i<keys.count; i++) {
  125. [_dataArray addObject:dic[keys[i]]];
  126. count += [[_dataArray lastObject] intValue];
  127. }
  128. UITabBarController *tabC = (UITabBarController *)self.parentViewController.parentViewController;
  129. if (count == 0) {
  130. [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:nil];
  131. }else{
  132. [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:[NSString stringWithFormat:@"%d", count]];
  133. }
  134. [_tableView reloadData];
  135. }];
  136. }
  137. @end