// // 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 "NewMessage.h" #import "WaringVC.h" #import "FaceColloectVC.h" @interface workVC () { //待办事项 SIcon_button *btn1; SIcon_button *btn2; SIcon_button *btn3; SIcon_button *btn4; } @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]; } - (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 = 120; UIImageView *imageAD = [[UIImageView alloc] KSetxywh]; imageAD.contentMode = UIViewContentModeScaleAspectFill; imageAD.layer.masksToBounds = YES; imageAD.image = [UIImage imageNamed:@"defaultImg"]; [mainScroll addSubview:imageAD]; y += h; h = 40; UILabel *label = [[UILabel alloc] KSetxywh]; label.backgroundColor = [UIColor whiteColor]; NSString * nameString = [NSString stringWithFormat:@" %@,欢迎您!",defUser.userDict[@"realName"]]; [label setText:nameString Font:24 TextColor:KTitleColor]; [mainScroll addSubview: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)]; y += h; w = h = kSize.width/4.0; NSArray *imageArray = @[@"work_1",@"work_1",@"work_1",@"work_1"]; NSArray *titleArray = @[@"待我审核",@"未读消息",@"教学区域",@"终端在线"]; for (int i = 0; i < 4; 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 + 1]; [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; 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数一致 //@RQ-MARK 1.0.2修改:”学时送审“模块取消 人脸采集模块位置上移至原“学时送审位置” titleArray = @[@"学员报名",@"退学管理",@"人脸采集",@"线下支付",@"培训价格",@"教练车辆",@"终端管理",@"设备报修",@"预约管理",@"报警信息"]; imageArray = @[@"work_4",@"work_5",@"work_face",@"work_7",@"work_8",@"work_9",@"work_10",@"work_Rep",@"work_Pla",@"work_waring"]; 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 + 5]; }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_Reg",@"work_Exa"]; 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 1://待我审核 { CheckCourseVC *vc = [[CheckCourseVC alloc] init]; [self navPushHideTabbarToVC:vc]; } break; case 2://未读消息 { // NewMessage *vc = [[NewMessage alloc]init]; // [self navPushHideTabbarToVC:vc]; } break; case 3://教学区域 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://人脸采集 { // StudentList * vc = [[StudentList alloc]init]; // vc.pageType = PageType_FaceCapture; // [self navPushHideTabbarToVC:vc]; FaceColloectVC *vc = [[FaceColloectVC alloc] init]; [self navPushHideTabbarToVC:vc]; } break; case 8://线下支付 { payinRealityVC *vc = [[payinRealityVC alloc] init]; [self navPushHideTabbarToVC:vc]; } break; case 9://培训价格 { [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 10://教练车辆 { [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 11://终端管理 { ShowMsgUnOpen(); // [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 12://设备报修 { RepairViewController *vc = [[RepairViewController alloc]init]; [self navPushHideTabbarToVC:vc]; } break; case 13://预约管理 { [Tools permissionValidationWithID:@"1082" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } [self getSchPlaces]; }]; } break; case 14://报警 { [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 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://电子围栏 { [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 27://预考成绩 { StuExamSearchSetVC * vc = [[StuExamSearchSetVC alloc]init]; [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"]; self->btn1.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"TRAIN_CT"]]; self->btn2.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"MSG_CT"]]; self->btn3.contentLabel.text = [NSString stringWithFormat:@"%@",dic[@"REGION_CT"]]; self->btn4.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"; [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) { 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