// // workVC.m // LN_School // // Created by apple on 2017/4/5. // Copyright © 2017年 Danson. All rights reserved. // #import "workVC.h" #import "SIcon_button.h" #import "SignUpVC.h" #import "CheckCourseVC.h" #import "TerminalMapVC.h" #import "StudentList.h" #import "CoachListVC.h" #import "SafeList.h" #import "AssessorList.h" #import "CarList.h" #import "payinRealityVC.h" #import "TrainPriceList.h" #import "QuitSch.h" #import "RepairViewController.h" #import "EvaluationListVC.h" #import "ComplaintsListVC.h" #import "RegionsList.h" #import "StuExamSearchSetVC.h" #import "AllCoachPlanVC.h" #import "FenceSiteVC.h" #import "WaringVC.h" #import "FaceColloectVC.h" #import "MessageList.h" #import "TCSListVC.h" #import "NBZOverCarListVC.h" #import "AdvertisingColumn.h" @interface workVC () { //待办事项 SIcon_button *btn1; SIcon_button *btn2; SIcon_button *btn3; SIcon_button *btn4; SIcon_button *btn5; UILabel *realNameLabel; } @end @implementation workVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"工作";//某某驾校 self.navigationController.navigationBar.translucent = NO; self.view.backgroundColor = KBackGroundColor; [self myInit]; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.tabBarController.tabBar.hidden = NO; //刷新待办事项 [self getStatistics]; NSString *nameString = @"欢迎您!"; if ([defUser.userDict[@"realName"] length] > 0) { nameString = [NSString stringWithFormat:@" %@,欢迎您!",defUser.userDict[@"realName"]]; } realNameLabel.text = nameString; } - (void)myInit { // UIView *noUseView = [UIView new]; // [self.view addSubview:noUseView]; CGFloat x, y, w, h, bd; x = 0; y = 0; w = kSize.width; h = kSize.height - kNavOffSet - kTabBarHeight; UIScrollView *mainScroll = [[UIScrollView alloc] initWithFrame:KSetDIYFrame]; mainScroll.showsVerticalScrollIndicator = NO; [self.view addSubview:mainScroll]; bd = 10; x = 0; y = 0; w = kSize.width; h = kSize.width*201/720; AdvertisingColumn *adview = [[AdvertisingColumn alloc] KSetxywh]; [adview setImgArray:@[@"横幅广告1",@"横幅广告2",@"横幅广告3"]]; [mainScroll addSubview:adview]; y += h; h = 40; UILabel *label = [[UILabel alloc] KSetxywh]; label.backgroundColor = [UIColor whiteColor]; NSString *nameString = @"欢迎您!"; if ([defUser.userDict[@"realName"] length] > 0) { nameString = [NSString stringWithFormat:@" %@,欢迎您!",defUser.userDict[@"realName"]]; } [label setText:nameString Font:24 TextColor:KTitleColor]; [mainScroll addSubview:label]; realNameLabel = label; [label addViewWithRect:CGRectMake(x, y + h - 1, w, 1)]; //待办事项 y += h + bd; h = 30; label = [[UILabel alloc] KSetxywh]; label.backgroundColor = [UIColor whiteColor]; [label setText:@" 待办事项" Font:Font18 TextColor:KTitleColor]; [mainScroll addSubview:label]; [label addViewWithRect:CGRectMake(x, y, w, 1)]; [label addViewWithRect:CGRectMake(x, y + h - 1, w, 1)]; NSArray *imageArray = @[@"work_1",@"work_1",@"work_1",@"work_1",@"work_1"]; NSArray *titleArray = @[@"年检到期",@"保险到期",@"综合检测",@"未读消息",@"终端在线"]; y += h; w = h = kSize.width/titleArray.count; for (int i = 0; i < titleArray.count; i ++) { SIcon_button *btn = [[SIcon_button alloc] initWithFrame:CGRectMake(i*w, y, w, h)]; [btn setImage:[UIImage imageNamed:imageArray[i]] withTitle:titleArray[i] textColor:KTitleColor Font:Font16 forState:UIControlStateNormal]; [btn target:self Tag:i + 0]; [mainScroll addSubview:btn]; btn.contentLabel.text = @"0"; switch (i) { case 0: btn1 = btn; break; case 1: btn2 = btn; break; case 2: btn3 = btn; break; case 3: btn4 = btn; break; case 4: btn5 = btn; break; default: break; } } //常用功能 y += h + bd; w = kSize.width; h = 30; label = [[UILabel alloc] KSetxywh]; label.backgroundColor = [UIColor whiteColor]; [label setText:@" 常用功能" Font:Font18 TextColor:KTitleColor]; [mainScroll addSubview:label]; [label addViewWithRect:CGRectMake(x, y, w, 1)]; [label addViewWithRect:CGRectMake(x, y + h - 1, w, 1)]; y += h; w = h = kSize.width/4.0; //添加功能 直接在这里添加 注意:图片数要和title数一致 ,@"学时送审" ,@"work_6" titleArray = @[@"退学管理",@"线下支付",@"培训价格",@"教练车辆",@"终端管理",@"设备报修",@"预约管理",@"车辆报警"];//,@"人脸采集" @"学员报名", imageArray = @[@"work_5",@"work_7",@"work_8",@"work_9",@"work_10",@"work_Rep",@"work_Pla",@"work_waring"];//,@"work_face" @"work_4" int maxI = (int)ceilf(titleArray.count/4.0) * 4; for (int i = 0; i < maxI; i ++) { int row = i/4; int column = i%4; SIcon_button *btn = [[SIcon_button alloc] initWithFrame:CGRectMake(column*w, y + row*h, w, h)]; if (i < titleArray.count) { [btn setImage:[UIImage imageNamed:imageArray[i]] withTitle:titleArray[i] textColor:KTitleColor Font:Font16 forState:UIControlStateNormal]; [btn target:self Tag:i + 6]; }else { btn.userInteractionEnabled = NO; } [mainScroll addSubview:btn]; if (i%4 != 3) { [btn addViewWithRect:CGRectMake((column + 1) * w - 1, y + row * h, 1, h)]; }else{ [btn addViewWithRect:CGRectMake(0, y + (row + 1) * h - 1, kSize.width, 1)]; } } //其他功能 int maxRow = (int)ceilf(titleArray.count/4.0); y += maxRow * h + bd; w = kSize.width; h = 30; label = [[UILabel alloc] KSetxywh]; label.backgroundColor = [UIColor whiteColor]; [label setText:@" 其它功能" Font:Font18 TextColor:KTitleColor]; [mainScroll addSubview:label]; [label addViewWithRect:CGRectMake(x, y, w, 1)]; [label addViewWithRect:CGRectMake(x, y + h - 1, w, 1)]; y += h; w = h = kSize.width/4.0; //添加功能 直接在这里添加 注意:图片数要和title数一致 titleArray = @[@"学员",@"教练员",@"安全员",@"考核员",@"评价管理",@"投诉管理",@"预考成绩",@"电子围栏",@"训练场地",@"理论教室",@"报名点"]; imageArray = @[@"work_11",@"work_12",@"work_13",@"work_14",@"work_Eva",@"work_Com",@"work_Exa",@"work_Reg",@"work_Tra",@"work_Clsr",@"work_Bmd"]; maxI = (int)ceilf(titleArray.count/4.0) * 4; for (int i = 0; i < maxI; i ++) { int row = i/4; int column = i%4; SIcon_button *btn = [[SIcon_button alloc] initWithFrame:CGRectMake(column*w, y + row*h, w, h)]; if (i < titleArray.count) { [btn setImage:[UIImage imageNamed:imageArray[i]] withTitle:titleArray[i] textColor:KTitleColor Font:Font16 forState:UIControlStateNormal]; [btn target:self Tag:i + 20]; }else { btn.userInteractionEnabled = NO; } [mainScroll addSubview:btn]; if (i%4 != 3) { [btn addViewWithRect:CGRectMake((column + 1) * w - 1, y + row * h, 1, h)]; }else{ [btn addViewWithRect:CGRectMake(0, y + (row + 1) * h - 1, kSize.width, 1)]; } } UIView *lastView = mainScroll.subviews.lastObject; [mainScroll setContentSize:CGSizeMake(kSize.width, lastView.bottom + 2*bd)]; } - (void)btnClick:(UIButton *)sender { // SIcon_button *btn = (SIcon_button *)sender; // NSLog(@"工作点击----><>%@",btn.contentLabel.text); switch (sender.tag) { case 0://年检到期 case 1://保险到期 case 2://综合性能检测到期 { [Tools permissionValidationWithID:@"9" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } NBZOverCarListVC * vc = [[NBZOverCarListVC alloc]init]; vc.vcType = sender.tag+1; [self navPushHideTabbarToVC:vc]; }]; } break; case 3://未读消息 { MessageList *vc = [[MessageList alloc]init]; [self navPushHideTabbarToVC:vc]; } break; case 4://终端在线 { [Tools permissionValidationWithID:@"81" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } TerminalMapVC *vc = [[TerminalMapVC alloc] init]; [self navPushHideTabbarToVC:vc]; }]; } break; //常用功能 // case 5://学员报名 // { // SignUpVC *vc = [[SignUpVC alloc] init]; // [self navPushHideTabbarToVC:vc]; // } // break; case 6://退学管理 { [Tools permissionValidationWithID:@"1102" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } QuitSch * vc = [[QuitSch alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; // case 7://学时送审 // { // CheckCourseVC *vc = [[CheckCourseVC alloc] init]; // [self navPushHideTabbarToVC:vc]; // } // break; case 7://线下支付 { payinRealityVC *vc = [[payinRealityVC alloc] init]; [self navPushHideTabbarToVC:vc]; } break; case 8://培训价格 { [Tools permissionValidationWithID:@"12" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } TrainPriceList * vc = [[TrainPriceList alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 9://教练车辆 { [Tools permissionValidationWithID:@"9" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } CarList * vc = [[CarList alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 10://终端管理 { [Tools permissionValidationWithID:@"81" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } TerminalMapVC *vc = [[TerminalMapVC alloc] init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 11://设备报修 { RepairViewController *vc = [[RepairViewController alloc]init]; [self navPushHideTabbarToVC:vc]; } break; case 12://预约管理 { [Tools permissionValidationWithID:@"1082" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } [self getSchPlaces]; }]; } break; case 13://报警 { [Tools permissionValidationWithID:@"81" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } WaringVC *vc = [[WaringVC alloc] init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 14://人脸采集 { FaceColloectVC *vc = [[FaceColloectVC alloc] init]; [self navPushHideTabbarToVC:vc]; } break; //其他功能 case 20://学员 { [Tools permissionValidationWithID:@"52" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } StudentList * vc = [[StudentList alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 21://教练员 { [Tools permissionValidationWithID:@"8" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } CoachListVC * vc = [[CoachListVC alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 22://安全员 { [Tools permissionValidationWithID:@"11" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } SafeList *vc = [[SafeList alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 23://考核员 { [Tools permissionValidationWithID:@"10" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } AssessorList * vc = [[AssessorList alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 24://评价 { EvaluationListVC * vc = [[EvaluationListVC alloc]init]; [self navPushHideTabbarToVC:vc]; } break; case 25://投诉 { ComplaintsListVC * vc = [[ComplaintsListVC alloc]init]; [self navPushHideTabbarToVC:vc]; } break; case 26://预考成绩 { StuExamSearchSetVC * vc = [[StuExamSearchSetVC alloc]init]; [self navPushHideTabbarToVC:vc]; } break; case 27://电子围栏 { [Tools permissionValidationWithID:@"13" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } RegionsList * vc = [[RegionsList alloc]init]; [self navPushHideTabbarToVC:vc]; }]; } break; case 28://训练场地 { [Tools permissionValidationWithID:@"2041" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } TCSListVC *vc = [[TCSListVC alloc]init]; vc.vcType = @"T"; [self navPushHideTabbarToVC:vc]; }]; } break; case 29://理论教室 { [Tools permissionValidationWithID:@"1245" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } TCSListVC *vc = [[TCSListVC alloc]init]; vc.vcType = @"C"; [self navPushHideTabbarToVC:vc]; }]; } break; case 30://报名点 { [Tools permissionValidationWithID:@"1146" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } TCSListVC *vc = [[TCSListVC alloc]init]; vc.vcType = @"S"; [self navPushHideTabbarToVC:vc]; }]; } break; default: break; } } #pragma mark 数据请求 - (void)getStatistics { if (![NetManager connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableDictionary *dic = [NSMutableDictionary dictionary]; [dic setObject:defUser.userDict[@"id"] forKey:@"userId"]; [dic setObject:defUser.userDict[@"dqbh"] forKey:@"dqbh"]; [dic setObject:defUser.userDict[@"qxbh"] forKey:@"qxbh"]; NSString *method = @"getStatistics"; [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) { if (!root) { return; } if ([root[@"code"] integerValue] == 1) { return; } NSDictionary * dic = root[@"body"]; btn1.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"INSPECTION_CT"]]; btn2.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"INSURANCE_CT"]]; btn3.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"COMPREHENSIVE_CT"]]; btn4.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"MSG_CT"]]; btn5.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"CONNECT_CT"]]; }]; } #pragma mark 查是否有场地 - (void)getSchPlaces { if (![NetManager connectedToNetWork]) { AllCoachPlanVC *vc = [[AllCoachPlanVC alloc] init]; [self navPushHideTabbarToVC:vc]; return; } NSMutableDictionary *dic = [NSMutableDictionary dictionary]; [dic setObject:defUser.userDict[@"school"] forKey:@"schid"]; NSString *method = @"getSchPlaces"; [MBProgressHUD showLoadToView:self.view]; [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) { [MBProgressHUD hideHUDForView:self.view]; if (!root) { AllCoachPlanVC *vc = [[AllCoachPlanVC alloc] init]; [self navPushHideTabbarToVC:vc]; return; } if ([root[@"code"] integerValue] == 1) { AllCoachPlanVC *vc = [[AllCoachPlanVC alloc] init]; [self navPushHideTabbarToVC:vc]; return; } if ([root[@"body"] count] < 1) { AllCoachPlanVC *vc = [[AllCoachPlanVC alloc] init]; [self navPushHideTabbarToVC:vc]; }else { FenceSiteVC *vc = [[FenceSiteVC alloc] init]; vc.dataArray = root[@"body"]; [self navPushHideTabbarToVC:vc]; } }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end