// // StudentDetail.m // LNManager // // Created by EchoShacolee on 2017/4/10. // Copyright © 2017年 lee. All rights reserved. // #import "StudentDetail.h" #import "TeachLogCell.h" #import "SignsCell.h" #import "ShenHeCell.h" @interface StudentDetail () { NSArray *_teachLogDataArr;//教学日志 NSArray *_signDataArr;// 签到记录 NSArray *_shenheDataArr;//审核记录 HolderView * _holderV1; HolderView * _holderV2; HolderView * _holderV3; } @end @implementation StudentDetail - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"学员详情"; _teachLogDataArr = [[NSArray alloc]init]; _signDataArr = [[NSArray alloc]init]; _shenheDataArr = [[NSArray alloc]init]; [self setSegmentControllWithTitles:@[@"基本信息",@"教学日志",@"签到记录",@"审核记录",@"培训记录表"]]; // 第一次进来请求除基本信息[由上一级传进来(含培训记录表)]以外的数据 [self getTrainTimesRecords]; [self getStudentSigns]; [self getStudentAuditRecords]; UITableView * tabV = _tableViews[1]; _holderV1 = [[HolderView alloc] initWithFrame:tabV.frame]; _holderV1.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT; [_holderV1 freshBlock:^{ [self getTrainTimesRecords]; }]; [_mainScroolView addSubview:_holderV1]; UITableView * tabV2 = _tableViews[2]; _holderV2 = [[HolderView alloc] initWithFrame:tabV2.frame]; _holderV2.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT; [_holderV2 freshBlock:^{ [self getStudentSigns]; }]; [_mainScroolView addSubview:_holderV2]; UITableView * tabV3 = _tableViews[3]; _holderV3 = [[HolderView alloc] initWithFrame:tabV3.frame]; _holderV3.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT; [_holderV3 freshBlock:^{ [self getStudentAuditRecords]; }]; [_mainScroolView addSubview:_holderV3]; } -(void)setData{ _keysArr = @[ // @[@"所属机构",@""], @[@"证件类型",@"TSO_CARDTYPE"], @[@"证件号码",@"TSO_IDCARD"], @[@"姓名",@"TSO_NAME"], @[@"性别",@"TSO_SEX"], @[@"手机号码",@"TSO_PHONE"], // @[@"来源(推荐人)",@""], @[@"国籍",@"TSO_NATIONALITY"], @[@"业务类型",@"TSO_BUSITYPE"], @[@"培训车型",@"TSO_TRAINTYPE"], @[@"原准驾车型",@"TSO_PERDRITYPE"], @[@"驾驶证号",@"TSO_DRILICNUM"], @[@"驾驶证初领日期",@"TSO_FSTDRILICDATE"], @[@"报名日期",@"TSO_APPLYDATE"], @[@"联系地址",@"TSO_ADDRESS"], @[@"全国统一编号",@"TSO_STUNUM"], // @[@"备案时间",@""] ]; [super setData]; } #pragma mark 重写代理方法 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSInteger index = [_tableViews indexOfObject:tableView]; if (index == 1) { return _teachLogDataArr.count; }else if (index == 2){ return _signDataArr.count; }else if (index == 3){ return _shenheDataArr.count; }else if (index == 4){ return 1; } return [_keysArr count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ NSInteger index = [_tableViews indexOfObject:tableView]; if (index == 1) { return 150; } if (index == 2){ return 44; } if (index == 3){ return 44; } if (index == 4){ return tableView.height; } return [super tableView:tableView heightForRowAtIndexPath:indexPath]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger index = [_tableViews indexOfObject:tableView]; if (index == 1) { TeachLogCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellTeach"]; if (!cell) { //加载xib文件创建cell cell = [[[NSBundle mainBundle] loadNibNamed:@"TeachLogCell" owner:nil options:nil] lastObject]; } [cell setDataWithDic:_teachLogDataArr[indexPath.row]]; return cell; } if (index == 2) { SignsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellSign"]; if (!cell) { //加载xib文件创建cell cell = [[[NSBundle mainBundle] loadNibNamed:@"SignsCell" owner:nil options:nil] lastObject]; } [cell updataWithDic:_signDataArr[indexPath.row]]; return cell; } if (index == 3) { ShenHeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellTShenhe"]; if (!cell) { //加载xib文件创建cell cell = [[[NSBundle mainBundle] loadNibNamed:@"ShenHeCell" owner:nil options:nil] lastObject]; } [cell updataWithDic:_shenheDataArr[indexPath.row]]; return cell; } if (index == 4) { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pxjlbCellId"]; if (!cell) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pxjlbCellId"]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } //培训记录表 if ([self.dataSource[@"PDFPATH"] length] > 0) { UIWebView *webV = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-JOb_DETAIL_SEGBAR_HEIGHT-kNavOffSet)]; // webV.multipleTouchEnabled=YES; webV.userInteractionEnabled=YES; [cell.contentView addSubview:webV]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.dataSource[@"PDFPATH"]]]; [webV loadRequest:request]; }else{ cell.textLabel.text = @"暂无数据"; cell.textLabel.textAlignment = NSTextAlignmentCenter; } return cell; } //index == 0 UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"]; } if ([_statusArr[indexPath.row] isEqualToNumber:@1]) { cell.detailTextLabel.numberOfLines = 0; cell.detailTextLabel.textAlignment = NSTextAlignmentLeft; }else{ cell.detailTextLabel.numberOfLines = 1; cell.detailTextLabel.textAlignment = NSTextAlignmentRight; } NSString * key = _keysArr[indexPath.row][1]; cell.textLabel.text = _keysArr[indexPath.row][0]; if ([key isEqualToString:@"TSO_SEX"]) { NSString *sex = [NSString stringWithFormat:@"%@",self.dataSource[key]]; cell.detailTextLabel.text = [sex isEqualToString:@"1"] ? @"男" : @"女" ; }else if ([key isEqualToString:@"TSO_BUSITYPE"]){ NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]]; switch ([status integerValue]) { case 0: cell.detailTextLabel.text = @"初领"; break; case 1: cell.detailTextLabel.text = @"增领"; break; case 9: cell.detailTextLabel.text = @"其他"; break; default: break; } }else if ([key isEqualToString:@"TSO_CARDTYPE"]){ NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]]; switch ([status integerValue]) { case 1: cell.detailTextLabel.text = @"身份证"; break; case 2: cell.detailTextLabel.text = @"护照"; break; case 3: cell.detailTextLabel.text = @"军官证"; break; case 0: cell.detailTextLabel.text = @"其他"; break; default: break; } }else{ cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]]; } return cell; } #pragma mark 数据请求 -(void)getTrainTimesRecords{ //判断网络是否连接 if (![NetworkManager connectedToNetWork]) { [self showMsgByAlertVCWithString:@"网络连接异常"]; return; } [MBProgressHUD hideHUDForView:self.view animated:NO]; [MBProgressHUD showHUDAddedTo:self.view animated:NO]; [NetworkManager requestWithMethod:@"trainTimesRecords" parameters:self.requesetDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { [MBProgressHUD hideHUDForView:self.view animated:YES]; [_holderV1 setHidden:NO]; if (failureStr) { [self showMsgByAlertVCWithString:failureStr]; return; } if ([successDic[@"code"] isEqualToString:@"1"]) { [self showMsgByAlertVCWithString:successDic[@"msg"]]; return; } _teachLogDataArr = successDic[@"body"]; if (_teachLogDataArr.count > 0) { _holderV1.hidden = YES; } [_tableViews[1] reloadData]; }]; } -(void)getStudentSigns{ //判断网络是否连接 if (![NetworkManager connectedToNetWork]) { [self showMsgByAlertVCWithString:@"网络连接异常"]; return; } NSMutableDictionary * mdic = [NSMutableDictionary new]; [mdic setValue:self.requesetDic[@"stunum"] forKey:@"stunum"]; [mdic setValue:@"" forKey:@"isPage"]; [mdic setValue:@"" forKey:@"pageSize"]; [mdic setValue:@"" forKey:@"currentPage"]; [MBProgressHUD hideHUDForView:self.view animated:NO]; [MBProgressHUD showHUDAddedTo:self.view animated:NO]; [NetworkManager requestWithMethod:@"getStudentSigns" parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { [MBProgressHUD hideHUDForView:self.view animated:YES]; [_holderV2 setHidden:NO]; if (failureStr) { [self showMsgByAlertVCWithString:failureStr]; return; } if ([successDic[@"code"] isEqualToString:@"1"]) { [self showMsgByAlertVCWithString:successDic[@"msg"]]; return; } _signDataArr = successDic[@"body"]; if (_signDataArr.count > 0) { _holderV2.hidden = YES; } [_tableViews[2] reloadData]; }]; } -(void)getStudentAuditRecords{ //判断网络是否连接 if (![NetworkManager connectedToNetWork]) { [self showMsgByAlertVCWithString:@"网络连接异常"]; return; } NSMutableDictionary * mdic = [NSMutableDictionary new]; [mdic setValue:self.requesetDic[@"stunum"] forKey:@"stunum"]; [mdic setValue:@"" forKey:@"isPage"]; [mdic setValue:@"" forKey:@"pageSize"]; [mdic setValue:@"" forKey:@"currentPage"]; [MBProgressHUD hideHUDForView:self.view animated:NO]; [MBProgressHUD showHUDAddedTo:self.view animated:NO]; [NetworkManager requestWithMethod:@"getStudentAuditRecords" parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { [MBProgressHUD hideHUDForView:self.view animated:YES]; [_holderV3 setHidden:NO]; if (failureStr) { [self showMsgByAlertVCWithString:failureStr]; return; } if ([successDic[@"code"] isEqualToString:@"1"]) { [self showMsgByAlertVCWithString:successDic[@"msg"]]; return; } _shenheDataArr = successDic[@"body"]; if (_shenheDataArr.count > 0) { _holderV3.hidden = YES; } [_tableViews[3] reloadData]; }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #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