// // JobVC.m // LNManager // // Created by EchoShacolee on 2017/4/13. // Copyright © 2017年 lee. All rights reserved. // #import "JobVC.h" #import "SchoolListVC.h" #import "RegionsList.h" #import "XueShiCheckList.h" #import "EvaluationListVC.h" #import "ComplaintsListVC.h" #import "WaringVC.h" #import "NotifySelectObjVC.h" #import "AdvertisingColumn.h" @interface JobVC () { NSArray *_titleArr; UITableView * _tableView; NSMutableArray *_topLabArr;//存放需要更新显示的lab } @end @implementation JobVC - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"工作"; _titleArr = @[@[@"预警信息",@"未读消息",@"待审围栏",@"在线终端"],//@"待我审核", @[@"投诉管理",@"教学日志",@"通知下发",@"终端管理"],//@"学时审核", @[@"机构管理", @"教练管理", @"考核员管理", @"安全员管理", @"教练车管理", @"学员管理", @"教学区域", @"评价管理", //@"举报管理", @"预警"]]; _topLabArr = [NSMutableArray new]; [self myInit]; } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self getData]; [self getWillDoVCNews]; } -(void)viewWillDisappear:(BOOL)animated{ // [self setHidesBottomBarWhenPushed:NO]; [super viewWillDisappear:animated]; } -(void)myInit{ _tableView = [[UITableView alloc]initWithFrame:kFrame style:UITableViewStyleGrouped]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.showsVerticalScrollIndicator = NO; _tableView.estimatedRowHeight = 0; _tableView.estimatedSectionHeaderHeight = 0; _tableView.estimatedSectionFooterHeight = 0; [self.view addSubview:_tableView]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 100)]; _tableView.tableFooterView = view; } #pragma mark tableview代理相关 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 3; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 1; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ CGFloat height = kSize.width/4; switch (indexPath.section) { case 0: return kSize.width*((double)201/721);//+height 隐藏预警信息/未读消息。。。 break; case 1: return height+30+40; break; case 2: return height*3+30; break; default: break; } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSArray * imgTitles = @[@[@"ic_tousu_manager",@"ic_teach_log",@"ic_notify",@"ic_terminal_manager"],//ic_check_train @[@"ic_school_manager", @"ic_coach_manager", @"ic_assessor_manager", @"ic_securitor_manager", @"ic_car_manager", @"ic_student_manager", @"ic_teach_area", @"ic_pingjia_manager", @"ic_waring_manager", // @"ic_jubao_manager", @"ic_waring_manager", ]]; NSString * cellId = [NSString stringWithFormat:@"cellId%ld",(long)indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (cell) { return cell; }else{ cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; cell.selectionStyle = UITableViewCellSelectionStyleNone; CGSize size = kSize;//cell.contentView.frame.size因为上面的特殊处理导致这个行不通了 CGFloat height = kSize.width/4; if (indexPath.section == 0) { for (int i=0; i<[_titleArr[0] count]; i++) { UILabel *topLab = [[UILabel alloc]init]; topLab.text = @"0"; [_topLabArr addObject:topLab]; UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(i*size.width/4, kSize.width*((double)201/721), size.width/4, size.width/4); [button setTitleUnderImgWithTitle:_titleArr[0][i] TitleColor:[UIColor grayColor] Image:nil label:topLab]; button.tag = 10+i; [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; // [cell.contentView addSubview:button]; 去掉预警/未读消息 } NSArray *topImgs = @[@"job_top1",@"job_top2",@"job_top3"]; AdvertisingColumn *adView = [[AdvertisingColumn alloc]initWithFrame:CGRectMake(0, 0, size.width, kSize.width*((double)201/721))]; [adView setImgArray:topImgs]; [cell.contentView addSubview:adView]; }else if (indexPath.section == 1){ // UILabel * lab2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kSize.width, 40)]; lab2.text = [NSString stringWithFormat:@" %@,欢迎您!",MYAPPDELEGATE.userDic[@"realName"]]; lab2.textColor = RGB_COLOR(70, 70, 70); lab2.font = [UIFont systemFontOfSize:20]; lab2.layer.borderWidth = .7f; lab2.layer.borderColor = [UIColor colorWithRed:230/255.0f green:230/255.0f blue:230/255.0f alpha:1].CGColor; [cell.contentView addSubview:lab2]; // UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 40, kSize.width, 30)]; lab.text = @" 常用功能"; lab.textColor = [UIColor darkGrayColor]; lab.font = [UIFont systemFontOfSize:17]; [cell.contentView addSubview:lab]; // for (int i=0; i<[_titleArr[1] count]; i++) { UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(i*size.width/4, 70, size.width/4, height); [button setTitleUnderImgWithTitle:_titleArr[1][i] TitleColor:[UIColor blackColor] Image:[UIImage imageNamed:imgTitles[0][i]] label:nil]; button.tag = 100+i; [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:button]; } }else if (indexPath.section == 2){ UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kSize.width, 30)]; lab.text = @" 其它功能"; lab.textColor = [UIColor darkGrayColor]; lab.font = [UIFont systemFontOfSize:17]; [cell.contentView addSubview:lab]; for (int i=0; i<[_titleArr[2] count]; i++) { UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(i%4*size.width/4, 30+i/4*height, size.width/4, height); [button setTitleUnderImgWithTitle:_titleArr[2][i] TitleColor:[UIColor blackColor] Image:[UIImage imageNamed:imgTitles[1][i]] label:nil]; button.tag = 1000+i; [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:button]; } } return cell; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return .1; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { if (section == 0) { return 0.1f;//设置为0无效 } return 15; } -(void)btnClick:(UIButton *)sender{ //type/@[@"驾校管理0",@"教练管理1",@"考核员管理2",@"安全员管理3",@"教练车管理5",@"学员管理4",@"学时审核6"] @"教学日志"7 @"通知下发"8 终端管理9 家学区域 10 switch (sender.tag) { case 10: { // XueShiCheckList * vc = [[XueShiCheckList alloc]init]; // [self.navigationController pushViewController:vc animated:YES]; //预警 WaringVC *vc = [[WaringVC alloc] init]; [self.navigationController pushViewController:vc animated:YES]; } break; case 11: { //未读消息 self.tabBarController.selectedIndex = 0; } break; case 12: { //待审核教学区域 [Tools permissionValidationWithID:@"804" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } RegionsList *vc = [[RegionsList alloc]init]; vc.type = @"1"; [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 13: { //在线终端 SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"终端管理"; vc.type = 9;//终端管理 [self.navigationController pushViewController:vc animated:YES]; } break; case 100: { ComplaintsListVC *vc = [[ComplaintsListVC alloc]init]; vc.navigationItem.title = @"投诉管理"; [self.navigationController pushViewController:vc animated:YES]; } break; case 101: { [Tools permissionValidationWithID:@"18" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"教学日志"; vc.type = 7;//教学日志 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 102: { //通知下发 NotifySelectObjVC *vc = [[NotifySelectObjVC alloc]init]; vc.navigationItem.title = @"通知下发"; [self.navigationController pushViewController:vc animated:YES]; } break; case 103: { [Tools permissionValidationWithID:@"15" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"终端管理"; vc.type = 9;//终端管理 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1000: { [Tools permissionValidationWithID:@"9" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"驾校管理"; vc.type = 0;//驾校管理0 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1001: { [Tools permissionValidationWithID:@"10" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"教练管理"; vc.type = 1;//教练管理1 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1002: { [Tools permissionValidationWithID:@"11" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"考核员管理"; vc.type = 2;//考核员管理2 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1003: { [Tools permissionValidationWithID:@"12" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"安全员管理"; vc.type = 3;//安全员管理3 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1004: { [Tools permissionValidationWithID:@"13" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"教练车管理"; vc.type = 5;//@""教练车管理5 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1005: { [Tools permissionValidationWithID:@"17" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } SchoolListVC *vc = [[SchoolListVC alloc]init]; vc.navigationItem.title = @"学员管理"; vc.type = 4;//学员管理4 [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1006: { [Tools permissionValidationWithID:@"563" result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } //教学区域 RegionsList *vc = [[RegionsList alloc]init]; [self.navigationController pushViewController:vc animated:YES]; }]; } break; case 1007: { //评价管理 EvaluationListVC *vc = [[EvaluationListVC alloc]init]; vc.navigationItem.title = @"评价管理"; [self.navigationController pushViewController:vc animated:YES]; } break; case 1008: { //预警 WaringVC *vc = [[WaringVC alloc] init]; [self.navigationController pushViewController:vc animated:YES]; } break; default: break; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - 网络请求 -(void)getWillDoVCNews{ NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init]; [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"]; [NetworkManager requestWithMethod:@"getMsgStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { if (failureStr) { return; } if ([successDic[@"code"] isEqualToString:@"1"]) { return; } NSArray * keys = @[@"SYSTEMNOTICENUM",@"REGIONAUDITNUM",@"SCHOOLAUDITNUM",@"COACHAUDITNUM",@"CARAUDITNUM",@"DEVAUDITNUM",@"NOTICENUM"]; NSDictionary * dic = successDic[@"body"][0]; int count = 0; for (int i=0; i