// // 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" #import "FaceColloectVC.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:@[@"基本信息",@"教学日志",@"培训记录表"] isBttomBar:YES]; //,@"打卡记录",@"学时审核记录",@"锁定历史记录" 教学日志可能要gg [self createBottomBarWithtoolTitle:@"查看人脸采集照片"]; // 第一次进来请求除基本信息[由上一级传进来]以外的数据 [self getTrainTimesRecords]; // [self getStudentSigns]; // [self getStudentAuditRecords]; UITableView * tabV = _tableViews[1]; [self createHeaderViewWithTableView:tabV]; _holderV1 = [[HolderView alloc] initWithFrame:tabV.frame]; [_holderV1 freshBlock:^{ [self getTrainTimesRecords]; }]; [_mainScroolView addSubview:_holderV1]; } -(void)setData{ _keysArr = @[ // @[@"所属机构",@""], @[@"证件类型",@"TSO_CARDTYPE"], @[@"证件号码",@"TSO_IDCARD"], @[@"姓名",@"TSO_NAME"], @[@"性别",@"TSO_SEX"], @[@"手机号码",@"TSO_PHONE"], @[@"来源(推荐人)",@"TSO_SOURCE"], @[@"国籍",@"TSO_NATIONALITY"], @[@"业务类型",@"TSO_BUSITYPE"], @[@"培训车型",@"TSO_TRAINTYPE"], @[@"原准驾车型",@"TSO_PERDRITYPE"], @[@"驾驶证号",@"TSO_DRILICNUM"], @[@"驾驶证初领日期",@"TSO_FSTDRILICDATE"], @[@"培训模式",@"TSO_TRAIN_MODE"], @[@"报名日期",@"TSO_APPLYDATE"], @[@"全国统一编号",@"TSO_STUNUM"], @[@"备案时间",@"TSO_RECORD_DATE"], @[@"联系地址",@"TSO_ADDRESS"] ]; [super setData]; } -(void)createHeaderViewWithTableView:(UITableView *)tabV{ UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, 200)]; view.backgroundColor = [UIColor whiteColor]; tabV.tableHeaderView = view; NSArray *titles = @[@"科目",@"总计时长"]; NSArray *kemuArr = @[@"科一",@"科二",@"科三",@"科四"]; NSArray *keys = @[@"ONETIME",@"TWOTIME",@"THREETIME",@"FOURTIME"]; CGFloat x = kSize.width/3; CGFloat height = 40; for (int i=0; i<4; i++) { if (i<2) { UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(i*x, 0, x*(i+1), height)]; [lab1 setText:titles[i] Font:14 TextColor:KTitleColor Alignment:NSTextAlignmentCenter]; [view addSubview:lab1]; } UILabel *lab2 = [[UILabel alloc]initWithFrame:CGRectMake(0, height*(i+1), x, height)]; [lab2 setText:kemuArr[i] Font:14 TextColor:KSubTitleColor Alignment:NSTextAlignmentCenter]; [view addSubview:lab2]; UILabel *lab3 = [[UILabel alloc]initWithFrame:CGRectMake(x, height*(i+1), x*2, height)]; [lab3 setText:self.dataSource[keys[i]] Font:14 TextColor:KSubTitleColor Alignment:NSTextAlignmentCenter]; [view addSubview:lab3]; } for (int i=0; i<6; i++) { if (i<2) { UILabel *vLine = [[UILabel alloc]initWithFrame:CGRectMake(1+(x-2/4)*i, 0, 1, 200)]; vLine.backgroundColor = kLineColor; [view addSubview:vLine]; } UILabel *vLine = [[UILabel alloc]initWithFrame:CGRectMake(2, height*i, kSize.width-4, 1)]; vLine.backgroundColor = kLineColor; [view addSubview:vLine]; } } #pragma mark 创建BottomBarButton -(void)createBottomBarWithtoolTitle:(NSString *)title{ UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; button.frame = CGRectMake(0, kSize.height-kNavOffSet-JOb_DETAIL_BOTTOMBAR_HEIGHT-kSafeAreaBottomHeight, kSize.width, JOb_DETAIL_BOTTOMBAR_HEIGHT); button.backgroundColor = RQMianColor; [button setTitle:title textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal]; [button addTarget:self action:@selector(goToFaceColloectVC) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; } -(void)goToFaceColloectVC { FaceColloectVC *faceVC = [[FaceColloectVC alloc] init]; faceVC.keyWord = self.dataSource[@"TSO_IDCARD"]; faceVC.currentDate = [NSDate date]; [self navPushHideTabbarToVC:faceVC]; } #pragma mark 重写代理方法 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSInteger index = [_tableViews indexOfObject:tableView]; if (index == 1) { return _teachLogDataArr.count; }else if (index == 2+4396){ return _signDataArr.count; }else if (index == 3+4396){ return _shenheDataArr.count; }else if (index == 4-2){ return 1; } return [_keysArr count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ NSInteger index = [_tableViews indexOfObject:tableView]; if (index == 1) { return 150; }else if (index == 4-2){ return kSize.height-kNavOffSet-JOb_DETAIL_BOTTOMBAR_HEIGHT-JOb_DETAIL_SEGBAR_HEIGHT-kSafeAreaBottomHeight; } return [super tableView:tableView heightForRowAtIndexPath:indexPath]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if ([_tableViews indexOfObject:tableView] == 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 ([_tableViews indexOfObject:tableView] == 2+4396) { 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 ([_tableViews indexOfObject:tableView] == 3+4396) { 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 ([_tableViews indexOfObject:tableView] == 4-2) { 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-50-kNavOffSet-kSafeAreaBottomHeight)]; // // webV.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);某种比例不变 webV.scalesPageToFit=YES; webV.multipleTouchEnabled=YES; webV.userInteractionEnabled=YES; webV.backgroundColor = [UIColor whiteColor]; [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; } //这里面有很多自己独有的key类型,所以就不麻烦父类去判定了 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 if ([key isEqualToString:@"TSO_TRAIN_MODE"]){//培训模式 0 传统模式 1 先学后付 2 分段式收费 NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]]; switch ([status integerValue]) { case 0: cell.detailTextLabel.text = @"传统模式"; break; case 1: cell.detailTextLabel.text = @"先学后付"; break; case 2: cell.detailTextLabel.text = @"分段式收费"; break; default: break; } }else{ cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]]; } return cell; } #pragma mark 数据请求 -(void)getTrainTimesRecords{ NSMutableDictionary * mdic = [[NSMutableDictionary alloc]init]; [mdic setValue:@"" forKey:@"isPage"]; [mdic setValue:@"" forKey:@"pageSize"]; [mdic setValue:@"" forKey:@"currentPage"]; [mdic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"]; [mdic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"]; [mdic setObject:defUser.userDict[@"school"] forKey:@"schoolId"]; [mdic setObject:@"" forKey:@"isReport"]; [mdic setObject:@"" forKey:@"trainSubject"]; [mdic setObject:self.dataSource[@"TSO_NAME"] forKey:@"studentName"]; [mdic setObject:@"" forKey:@"coachName"]; [mdic setObject:defUser.userDict[@"id"] forKey:@"userId"]; NSString *method = @"trainRecords"; [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) { [_holderV1 setHidden:NO]; if (!root) { return; } if ([root[@"code"] integerValue] == 1) { return; } _teachLogDataArr = root[@"body"]; if (_teachLogDataArr.count > 0) { _holderV1.hidden = YES; } [_tableViews[1] reloadData]; }]; } -(void)getStudentSigns{ // NSMutableDictionary * mdic = [NSMutableDictionary new]; // [mdic setValue:self.requesetDic[@"stunum"] forKey:@"stunum"]; // [mdic setValue:@"" forKey:@"isPage"]; // [mdic setValue:@"" forKey:@"pageSize"]; // [mdic setValue:@"" forKey:@"currentPage"]; // // [self getDataWithDic:mdic method:@"getStudentSigns" block:^(NSDictionary *successdic) { // // _signDataArr = successdic[@"body"]; // [_tableViews[2] reloadData]; // }]; } -(void)getStudentAuditRecords{ // NSMutableDictionary * mdic = [NSMutableDictionary new]; // [mdic setValue:self.requesetDic[@"stunum"] forKey:@"stunum"]; // [mdic setValue:@"" forKey:@"isPage"]; // [mdic setValue:@"" forKey:@"pageSize"]; // [mdic setValue:@"" forKey:@"currentPage"]; // // [self getDataWithDic:mdic method:@"getStudentAuditRecords" block:^(NSDictionary *successdic) { // // _shenheDataArr = successdic[@"body"]; // [_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