123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- {
- 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<keys.count; i++) {
- NSString *str = dic[keys[i]];
- count += [str intValue];
- }
-
- UITabBarController *tabC = (UITabBarController *)self.parentViewController.parentViewController;
- if (count == 0) {
- [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:nil];
- }else{
- [[[tabC.tabBar items] objectAtIndex:0] setBadgeValue:[NSString stringWithFormat:@"%d", count]];
- }
-
- [_tableView reloadData];
- }];
-
- }
- -(void)getData{
-
- NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
- [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
- [mDic setValue:MYAPPDELEGATE.userDic[@"qxbh"] forKey:@"qxbh"];
- [mDic setValue:MYAPPDELEGATE.userDic[@"dqbh"] forKey:@"dqbh"];
- [NetworkManager requestWithMethod:@"getStatistics" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
-
- if (failureStr) {
-
- return;
- }
-
- if ([successDic[@"code"] isEqualToString:@"1"]) {
-
- return;
- }
-
- NSArray * keys = @[@"warningCnt",@"msgCnt",@"auditRegionCnt",@"onlineDevCnt"];
- if (successDic) {
- NSDictionary * dic = successDic[@"body"];
- int i=0;
- for (UILabel *lab in _topLabArr) {
- lab.text = [NSString stringWithFormat:@"%@",dic[keys[i]]];
- NSInteger count = [lab.text integerValue];
- lab.text = count<999?[NSString stringWithFormat:@"%ld",(long)count]:@"999+";
- i++;
- }
- }
- }];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|