1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117 |
- //
- // MyStuVC.m
- // jiaPeiC
- //
- // Created by apple on 15/12/17.
- // Copyright © 2015年 JCZ. All rights reserved.
- //
- #import "MyStuVC.h"
- #import "StudentTableCell.h"
- #import "RecordCell.h"
- #import "Tools.h"
- #import "AddRecordVC.h"//修改所添加日志(教练添加对学员的带教记录)
- #import "SelfAppointmentVC.h"//查看自主预约(改功能屏蔽)
- #import "MyGradeVC.h"//查看科一/四成绩
- #import <MJRefresh.h>
- typedef NS_ENUM(NSInteger, MyGetDataType) {
- //正常请求数据
- MyGetDataTypeNomal=0,
- //下拉刷新请求数据
- MyGetDataTypeHeaderRefresh,
- //上拉加载更多请求数据
- MyGetDataTypeFooterRefresh
- };
- @interface MyStuVC ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,UITextViewDelegate>
- {
- NSMutableArray *teachTypes;//
- NSMutableArray *footData;//teachlogs
- NSMutableArray *models;//students
- NSArray *xArray;//休学记录s
-
- //记录页书
- NSInteger _currentPageNum;
- //正在加载的状态
- BOOL _IS_LOADING;
- //加载数据的类型
- MyGetDataType _getDataType;
-
- UITableView *myTabelView;//tag=0
- UITableView *footTableView;//tag=1
- HolderView *holderV;
- UITextView *tfReason;
- NSString *state;
-
- //休学原因
- NSString *reasonString;
- NSString *XXID;
- UILabel *remindLabel;
- UIButton *xxBtn;
- UILabel *xxLabel;
- NSString *searchString;
- UIView *backView;
- UIView *alertV;
-
- BOOL xiuXue;//休学状态
-
-
- //下拉框
- UIView *blockBackView;
- UIView *btnBar;
- }
- @end
- @implementation MyStuVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
-
- //获取学员个人信息==》休学记录==> 获取教学日志类型==〉日志记录
- [self getStuInfoByCoach];
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self.view endEditing:YES];
- RemoveHUD();
- }
- -(void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- #pragma mark - 下拉刷新,上拉加载 -
- -(void)setRefreshAction{
-
- // 下拉刷新
- __weak typeof(self) weakSelf = self;
- MJRefreshNormalHeader *mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakSelf headerRefresh];
- }];
- footTableView.mj_header = mj_header;
-
- MJRefreshBackNormalFooter *mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- [weakSelf footerRefresh];
- }];
- footTableView.mj_footer = mj_footer;
-
- }
- #pragma mark - 数据加载更多和刷新 -
- -(void)headerRefresh{
- //设置获取数据的方式
- _getDataType=MyGetDataTypeHeaderRefresh;
- //加载数据
- [self getMyTeachLogs];
- [footTableView.mj_header endRefreshing];
- }
- -(void)footerRefresh{
- //设置获取数据的方式
- _getDataType=MyGetDataTypeFooterRefresh;
- //加载数据
- [self getMyTeachLogs];
- [footTableView.mj_footer endRefreshing];
- }
- #pragma mark -
- -(void)myInit
- {
- [self addV:[UIView new]];
-
- _currentPageNum = 0;
- _IS_LOADING = NO;
- _getDataType = MyGetDataTypeNomal;
-
- models = [NSMutableArray array];
- footData = [NSMutableArray array];
- xArray = [NSArray array];
- teachTypes = [NSMutableArray array];
-
- //设置初始休学状态
- if ([[_stuDic allKeys] containsObject:@"XX_ID"]) {
-
- if ([_stuDic[@"XX_ID"] length] > 0) {
-
- xiuXue = YES;
- }
- }
-
- UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"学员信息" style:UIBarButtonItemStyleDone target:self action:@selector(clickToSearch)];
- [item setTintColor:defGreen];
- [self.navigationItem setRightBarButtonItem:item];
-
- UITableView* tv = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
- tv.y = kNavOffSet;
- tv.height = kSize.height - tv.y;
- myTabelView = tv;
- [myTabelView setDelegate:self];
- [myTabelView setDataSource:self];
- [myTabelView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- myTabelView.tag = 0;
- [self addV:tv];
- [tv setTableFooterView:[UIView new]];
-
-
- holderV = [[HolderView alloc] initWithFrame:tv.frame];
- [holderV freshBlock:^{
- [self getStuInfoByCoach];
- }];
- [self addV:holderV];
- [holderV setHidden:YES];
- }
- #pragma mark - tableview delegate
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- if (tableView.tag == 1) {
- if (xArray.count > 0 && footData.count > 0) {
- return 2;
- }else{
- return 1;
- }
- }
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if (tableView.tag == 1) {
-
- if (xArray.count > 0 && footData.count > 0) {
-
- if (section == 0) {
- return xArray.count;
- }else{
- return footData.count;
- }
- }else if (xArray.count > 0){
- return xArray.count;
- }else if (footData.count > 0){
- return footData.count;
- }else{
- return 0;
- }
- }
- return models.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView.tag == 1) {
-
- RecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"recordCell"];
- if (cell == nil)
- {
- cell = [[RecordCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"recordCell"];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- }
-
- @try {
-
- if (xArray.count > 0 && footData.count > 0) {
-
- if (indexPath.section == 0) {
- NSDictionary *dic = xArray[indexPath.row];
- cell.textLabel.adjustsFontSizeToFitWidth = YES;
- cell.textLabel.text = [NSString stringWithFormat:@"● 该学员于%@休学",dic[@"CRDATE"]];
- cell.detailTextLabel.text = @"";
- if ([dic[@"REASON"] length] > 0) {
- cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: %@",dic[@"REASON"]];
- }
-
- if (cell.detailTextLabel.text.length > 0) {
- NSString *remarkString = cell.detailTextLabel.text;
- NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
-
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(0, 5)];
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:contentTextColor
- range:NSMakeRange(5, remarkString.length - 5)];
- cell.detailTextLabel.attributedText = aAttributedString;
- }
-
-
- cell.detailTextLabel.numberOfLines = 0;
- [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
-
- CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
- cell.detailTextLabel.height = detailTextHight + 10;
-
- cell.dateLabel.text = @"";
- }else{
- NSDictionary *dic = footData[indexPath.row];
-
- NSString *teachStyle = teachTypes[[dic[@"TL_TEACH_ID"] integerValue] - 1];
- NSString *remarkS = [NSString stringWithFormat:@"%d、[%@]",(int)indexPath.row + 1,teachStyle];
- NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:remarkS];
-
- [aString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(2, 1)];
- [aString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(remarkS.length - 1, 1)];
- cell.textLabel.attributedText = aString;
- cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
- //日期
- NSString *km = [dic[@"TL_SUBJECT"] isEqualToString:@"2"]?@"科二":@"科三";
-
- NSString *dateString = dic[@"TL_CRDATE"];
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSDate *cDate = [formatter dateFromString:dateString];
- [formatter setDateFormat:@"MM.dd.yyyy"];
- dateString = [formatter stringFromDate:cDate];
- cell.dateLabel.text = [NSString stringWithFormat:@"%@ %@",dateString,km];
-
- //如果没有 就不显示
- //cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: 暂无备注"];
- cell.detailTextLabel.text = @"";
- if ([dic[@"TL_REMARK"] length] > 0) {
- cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: %@",dic[@"TL_REMARK"]];
- }
-
- if (cell.detailTextLabel.text.length > 0) {
-
- NSString *remarkString = cell.detailTextLabel.text;
- NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
-
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(0, 3)];
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:contentTextColor
- range:NSMakeRange(3, remarkString.length - 3)];
- cell.detailTextLabel.attributedText = aAttributedString;
- }
-
- cell.detailTextLabel.numberOfLines = 0;
- [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
-
- CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
- cell.detailTextLabel.height = detailTextHight + 10;
- }
- }else if (xArray.count > 0){
-
- cell.textLabel.adjustsFontSizeToFitWidth = YES;
- NSDictionary *dic = xArray[indexPath.row];
- //♦
- cell.textLabel.text = [NSString stringWithFormat:@"● 该学员于%@被写入休学状态",dic[@"CRDATE"]];
-
- //cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: 暂无"];
- cell.detailTextLabel.text = @"";
- if ([dic[@"REASON"] length] > 0) {
- cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: %@",dic[@"REASON"]];
- }
-
- if (cell.detailTextLabel.text.length > 0) {
-
- NSString *remarkString = cell.detailTextLabel.text;
- NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
-
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(0, 5)];
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:contentTextColor
- range:NSMakeRange(5, remarkString.length - 5)];
- cell.detailTextLabel.attributedText = aAttributedString;
- }
-
- cell.detailTextLabel.numberOfLines = 0;
- [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
-
- CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
- cell.detailTextLabel.height = detailTextHight + 10;
-
- cell.dateLabel.text = @"";
- }
- else{
-
- NSDictionary *dic = footData[indexPath.row];
- NSString *teachStyle = teachTypes[[dic[@"TL_TEACH_ID"] integerValue] - 1];
- NSString *remarkS = [NSString stringWithFormat:@"%d、[%@]",(int)indexPath.row + 1,teachStyle];
- NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:remarkS];
-
- [aString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(2, 1)];
- [aString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(remarkS.length - 1, 1)];
-
- cell.textLabel.attributedText = aString;
- cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
- //日期
- NSString *km = [dic[@"TL_SUBJECT"] isEqualToString:@"2"]?@"科二":@"科三";
-
- NSString *dateString = dic[@"TL_CRDATE"];
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSDate *cDate = [formatter dateFromString:dateString];
- [formatter setDateFormat:@"MM.dd.yyyy"];
- dateString = [formatter stringFromDate:cDate];
- cell.dateLabel.text = [NSString stringWithFormat:@"%@ %@",dateString,km];
-
- //cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: 暂无备注"];
- cell.detailTextLabel.text = @"";
- if ([dic[@"TL_REMARK"] length] > 0) {
- cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: %@",dic[@"TL_REMARK"]];
- }
-
- if (cell.detailTextLabel.text.length > 0) {
-
- NSString *remarkString = cell.detailTextLabel.text;
- NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
-
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:[UIColor orangeColor]
- range:NSMakeRange(0, 3)];
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:contentTextColor
- range:NSMakeRange(3, remarkString.length - 3)];
- cell.detailTextLabel.attributedText = aAttributedString;
- }
-
- cell.detailTextLabel.numberOfLines = 0;
- [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
-
- CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
- cell.detailTextLabel.height = detailTextHight + 10;
- }
- }
- @catch (NSException *exception) {
-
- }
- @finally {
- return cell;
- }
- }
-
-
- StudentTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"StudentTableCell" owner:nil options:nil] firstObject];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
-
- cell.studeState = [_stuDic[@"SUBJECT"] integerValue];
- [cell setModel:models[indexPath.row]];
-
- NSString *titleString = @"添加休学";
- if (xiuXue) {
- titleString = @"取消休学";
- }
- [cell.xxBtn setTitle:titleString textColor:defGreen font:Font14 fotState:UIControlStateNormal];
- [cell.xxBtn corner:5];
- [cell.xxBtn target:self Tag:1];
- xxBtn = cell.xxBtn;
-
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView.tag == 1) {
-
- if (xArray.count > 0 && indexPath.section == 0) {
- return 80.5;
- }
-
- NSDictionary *dic = footData[indexPath.row];
- CGFloat height = [[NSString stringWithFormat:@"备注:%@",dic[@"TL_REMARK"]] heightForWid:kSize.width - 20 Font:15];
- return height + 70.5;
-
- }else{
-
- return 225;
- }
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- if (tableView.tag == 1) {
- UILabel *xLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
- xLabel.backgroundColor = [UIColor colorWithWhite:.9 alpha:1];
- xLabel.text = @"休学记录";
- xLabel.font = [UIFont scaleSize:20];
- xLabel.textAlignment = NSTextAlignmentCenter;
-
- UILabel *rLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
- rLabel.backgroundColor = [UIColor colorWithWhite:.9 alpha:1];
- rLabel.text = @"学员日志";
- rLabel.font = [UIFont scaleSize:20];
- rLabel.textAlignment = NSTextAlignmentCenter;
-
- if (xArray.count > 0 && footData.count > 0) {
-
- if (section == 0) {
- return xLabel;
- }else{
- return rLabel;
- }
- }else if (xArray.count > 0){
- return xLabel;
- }else if (footData.count > 0){
- return rLabel;
- }else{
- return [UILabel new];
- }
- }
- return [UIView new];
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- {
- if (tableView.tag == 1) {
-
- UIView *view = [UIView new];
- return view;
- }
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet - 240)];
- view.backgroundColor = backGroundColor;
- if (models.count > 0)
- {
- UITableView* tv = [[UITableView alloc] initWithFrame:kFrame];
- tv.y = 5;
- tv.height = kSize.height - kNavOffSet - 225-5;
-
- tv.delegate = self;
- tv.dataSource = self;
- tv.tag = 1;
- UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 2)];
- headView.backgroundColor = lineColor;
- tv.tableHeaderView = headView;
- [tv setTableFooterView:[UIView new]];
- [view addSubview:tv];
- footTableView = tv;
- }
-
- return view;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- if (tableView.tag == 1) {
- return .1;
- }
- return kSize.height - kNavOffSet - 225;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- if (tableView.tag == 1) {
- return 40;
- }
- return .1;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView.tag == 1) {
-
- if (xArray.count > 0 && footData.count > 0) {
-
- if (indexPath.section == 0) {
- return;
- }else{
- AddRecordVC *vc = [[AddRecordVC alloc] init];
- vc.refreshTeachlogs = ^{
- [self headerRefresh];
- };
- vc.stuDic = _stuDic;
- vc.teachType = teachTypes;
- vc.recordDic = footData[indexPath.row];
- vc.view.backgroundColor = backGroundColor;
- [vc configNavBar];
- [self.navigationController pushViewController:vc animated:YES];
- }
- }else if (xArray.count > 0){
- return;
- }else{
- AddRecordVC *vc = [[AddRecordVC alloc] init];
- vc.refreshTeachlogs = ^{
- [self headerRefresh];
- };
- vc.stuDic = _stuDic;
- vc.teachType = teachTypes;
- vc.recordDic = footData[indexPath.row];
- vc.view.backgroundColor = backGroundColor;
- [vc configNavBar];
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- }
- //表的编辑
- -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView.tag == 1) {
- if (xArray.count > 0) {
- if (indexPath.section == 0) {
- return NO;
- }
- }
- return YES;
- }else{
- return NO;
- }
- }
- //记得默认是yes
- -(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView.tag == 1) {
- return YES;
- }else{
- return NO;
- }
- }
- -(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return @"删除";
- }
- -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [self deleteTeachTypesWithRow:indexPath.row];
- }
- #pragma mark btn事件
- -(void)btnClick:(UIButton *)sender
- {
-
- if (xiuXue) {
- [self delStuXX];
- }else{
-
- backView = [[UIView alloc] initWithFrame:kFrame];
- backView.backgroundColor = [UIColor blackColor];
- backView.alpha = .3;
- [self.view addSubview:backView];
-
- alertV = [[UIView alloc] init];
- alertV.bounds = CGRectMake(0, 0, 280, 250);
- alertV.y -= 80;
- alertV.alpha = 1;
- alertV.center = CGPointMake(kSize.width/2.0, kSize.height/2.0);
- alertV.backgroundColor = backGroundColor;
- [alertV corner:15];
- [self.view addSubview:alertV];
-
- tfReason = [[UITextView alloc] initWithFrame:CGRectMake(10, 20, 260, 140)];
- tfReason.delegate = self;
- [tfReason setFont:[UIFont scaleSize:Font18]];
- [alertV addSubview:tfReason];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 260, 30)];
- label.text = @"请输入休学原因(100字以内)";
- label.textColor = contentTextColor;
- [alertV addSubview:label];
- remindLabel = label;
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(190, 190, 70, 40)];
- btn.backgroundColor = defGreen;
- [btn setTitle:@"确定" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
- [btn corner:5];
- [btn addTarget:self action:@selector(clickToAddXX:) forControlEvents:UIControlEventTouchUpInside];
- btn.tag = 4;
- [alertV addSubview:btn];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 190, 70, 40)];
- btn.backgroundColor = defGreen;
- [btn setTitle:@"取消" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
- [btn corner:5];
- [btn addTarget:self action:@selector(clickToAddXX:) forControlEvents:UIControlEventTouchUpInside];
- btn.tag = 5;
- [alertV addSubview:btn];
- }
- }
- -(void)clickToAddXX:(UIButton *)sender
- {
- if (sender.tag == 5) {
-
- [alertV removeFromSuperview];
- [backView removeFromSuperview];
- return;
- }
- if (tfReason.text.length > 100) {
- ShowMsg(@"字数不能超过100字");
- return;
- }
-
- [self.view endEditing:YES];
- reasonString = tfReason.text;
- if (!reasonString) {
- reasonString = @"";
- }
-
- [alertV removeFromSuperview];
- [backView removeFromSuperview];
-
- [self uploadStuXX];
- }
- -(void)clickToSearch
- {
- if (backView || btnBar) {
- //做关闭的操作
- [self removeSearchView];
- return;
- }
-
- backView = [[UIView alloc] initWithFrame:kFrame];
- backView.backgroundColor = [UIColor colorWithWhite:.7 alpha:.1];
- UITapGestureRecognizer *tapGR=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
- [backView addGestureRecognizer:tapGR];
- [self.view addSubview:backView];
-
- btnBar = [[UIView alloc] initWithFrame:CGRectMake(0, -70, kSize.width, 70)];
- [btnBar setBackgroundColor:[UIColor whiteColor]];
- [self.view addSubview:btnBar];
-
- NSArray *titles = @[@"科一成绩",@"科四成绩"];//@"预约信息" 屏蔽
- CGFloat w = (kSize.width - 40)/3.0;
- CGFloat h = 35;
- for (int i = 0; i < titles.count; i ++) {
-
- int row = i/titles.count;
- int column = i%titles.count;
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10 + column*(w + 10), 20 + row*(h + 10), w, h)];
- [btn borderColor:lineColor width:1 cornorRadios:3];
- [btn setTitle:titles[i] textColor:titleColor font:Font16 fotState:UIControlStateNormal];
- //点击状态的按钮
- [btn setTitleColor:[UIColor colorWithRed:55/255.0 green:147/255.0 blue:239/255.0 alpha:1] forState:UIControlStateHighlighted];
-
- [btn addTarget:self action:@selector(clickToSearchVC:) forControlEvents:UIControlEventTouchUpInside];
- btn.tag = i - 3 +1;
- [btnBar addSubview:btn];
-
- }
-
- [UIView animateWithDuration:.4 animations:^{
-
- backView.backgroundColor = [UIColor colorWithWhite:.3 alpha:.5];
- btnBar.y = kNavOffSet;
- }];
-
- }
- -(void)clickToSearchVC:(UIButton *)btn
- {
- NSString *sfzhm = @"";
-
- if ([_stuDic isKindOfClass:[NSDictionary class]]) {
-
- if ([[_stuDic allKeys] count] != 0) {
-
- sfzhm = _stuDic[@"TSO_ID"];
- }
- }
-
- if (btn.tag == -3) {
- //自主预约
- SelfAppointmentVC *vc = [[SelfAppointmentVC alloc] init];
- vc.type = @"1";
- vc.sfzhm = sfzhm;
- [self.navigationController pushViewController:vc animated:YES];
- }
-
- if (btn.tag == -2) {
- //学员科一成绩
- MyGradeVC *vc = [[MyGradeVC alloc] init];
- vc.identifyNum = sfzhm;
- vc.stuName = _stuDic[@"STU_NAME"];
- vc.kmString = @"1";
- [self.navigationController pushViewController:vc animated:YES];
- }
-
- if (btn.tag == -1) {
- //学员科四成绩
- MyGradeVC *vc = [[MyGradeVC alloc] init];
- vc.identifyNum = sfzhm;
- vc.stuName = _stuDic[@"STU_NAME"];
- vc.kmString = @"4";
- [self.navigationController pushViewController:vc animated:YES];
- }
-
- [self removeSearchView];
- }
- -(void)tapAction:(UITapGestureRecognizer *)gesture
- {
- //做关闭的操作
- [self removeSearchView];
- }
- -(void)removeSearchView
- {
- [UIView animateWithDuration:.4 animations:^{
- backView.backgroundColor = [UIColor colorWithWhite:.7 alpha:.1];
- btnBar.y = -70 - kNavOffSet;
- } completion:^(BOOL finished) {
- [backView removeFromSuperview];
- [btnBar removeFromSuperview];
- backView = nil;
- btnBar = nil;
- }];
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
- -(void)textViewDidBeginEditing:(UITextView *)textView
- {
- [remindLabel setTextColor:lineColor];
- }
- -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- NSMutableString * changedString=[[NSMutableString alloc]initWithString:textView.text];
- [changedString replaceCharactersInRange:range withString:text];
-
- if (changedString.length > 0) {
- [remindLabel setHidden:YES];
- }else{
- [remindLabel setHidden:NO];
- }
- return YES;
- }
- #pragma mark 数据请求
- /**可以考虑持久保存。如果当前没网络,就读取本地数据。
- */
- - (void)getStuInfoByCoach
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- searchString = _stuDic[@"STU_SFZHM"];
- if (searchString.length < 1) {
- searchString = _stuDic[@"SFZMHM"];
- }
-
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"queryValue" Value:searchString];
- [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
- [arr addPro:@"fptime" Value:@""];
- [arr addPro:@"subject" Value:[NSString stringWithFormat:@"%@",_stuDic[@"SUBJECT"]]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
- [arr addPro:@"isPage" Value:@""];
- [arr addPro:@"pageSize" Value:@""];
- [arr addPro:@"currentPage" Value:@""];
-
- NSString* method = @"getMyStudentsByCoachAccount";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- [holderV setHidden:NO];
- if (!root) {
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- return;
- }
- if ([root[@"body"] count] == 0) {
- //ShowMsg(@"暂无数据");
- return;
- }
-
- models = root[@"body"];
- if (models.count >0) {
- [myTabelView reloadData];
- [holderV setHidden:YES];
- [self getStuXXList];
- }else{
- [holderV setHidden:NO];
- }
- }];
- }
- //休学记录列表
- - (void)getStuXXList
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"stuSfzhm" Value:_stuDic[@"STU_SFZHM"]];
- [arr addPro:@"jxbh" Value:defUser.userDict[@"jxbh"]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
- [arr addPro:@"isPage" Value:@"0"];
- [arr addPro:@"pageSize" Value:@"0"];
- [arr addPro:@"currentPage" Value:@"0"];
-
- NSString* method = @"stuXXList";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- [self getTeachTypes];
- if (!root) {
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- return;
- }
- xArray = root[@"body"];
- }];
- }
- //添加休学
- - (void)uploadStuXX
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr = [NSMutableArray array];
-
- [arr addPro:@"stuName" Value:_stuDic[@"STU_NAME"]];
- [arr addPro:@"stuSfzhm" Value:_stuDic[@"STU_SFZHM"]];
- [arr addPro:@"coaName" Value:defUser.userDict[@"name"]];
- [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
- [arr addPro:@"reason" Value:reasonString];
- [arr addPro:@"subject" Value:[NSString stringWithFormat:@"%@",_stuDic[@"SUBJECT"]]];
- [arr addPro:@"jxbh" Value:defUser.userDict[@"jxbh"]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
- NSString* method = @"uploadStuXX";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- if (!root) {
- ShowMsg(@"加入休学失败!");
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
- //改变按钮标题和点击状态
- [xxBtn setTitle:@"取消休学" forState:UIControlStateNormal];
- xiuXue = YES;
- XXID = root[@"body"];
-
- [self getStuXXList];
- if (self.refreshStuList) {
- self.refreshStuList();
- }
- }];
- }
- //取消休学
- - (void)delStuXX
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- if (XXID.length == 0) {
- XXID = _stuDic[@"XX_ID"];
- }
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"xxid" Value:XXID];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
-
- NSString* method = @"delStuXX";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- if (!root) {
- ShowMsg(@"取消休学失败!");
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
- //改变按钮标题和点击状态
- [xxBtn setTitle:@"添加休学" forState:UIControlStateNormal];
- xiuXue = NO;
-
- [self getStuXXList];
- if (self.refreshStuList) {
- self.refreshStuList();
- }
- }];
- }
- -(NSString *)getNowDate
- {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *dateString = [formatter stringFromDate:[NSDate date]];
- return dateString;
- }
- //请求类型 有关日志信息
- - (void)getTeachTypes
- {
- NSMutableArray *array = [NSMutableArray arrayWithObjects:@"车辆基础操作",@"直线控制离合",@"倒车入库左倒",@"倒车入库右倒",@"科目二全套训练",@"预约科目二考试",@"考试日期",@"路跑",@"变更车道",@"会车与超车",@"靠边停车和掉头",@"灯光使用",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"", nil];
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"subject" Value:@""];
- [arr addPro:@"type" Value:@"1"];
- NSString* method = @"getTeachTypes";
- [LoadingView showHUD];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- if (!root || [root[@"code"] isEqualToString:@"1"]) {
- NSString *filePath = [Tools getPathWithFileName:@"getTeachTypes.plist"];
- if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
- NSArray *arr = [NSArray arrayWithContentsOfFile:filePath];
- [teachTypes removeAllObjects];
- for (NSDictionary *dic in arr) {
- [teachTypes addObject:dic[@"TC_TEACH_TYPE"]];
- }
- }else{
- teachTypes = array;
- }
- [self headerRefresh];
- return;
- }
-
- NSString *filePath = [Tools getPathWithFileName:@"getTeachTypes.plist"];
- [root[@"body"] writeToFile:filePath atomically:YES];
- [teachTypes removeAllObjects];
- for (NSDictionary *dic in root[@"body"]) {
- [teachTypes addObject:dic[@"TC_TEACH_TYPE"]];
- }
-
- [self headerRefresh];
- }];
- }
- - (void)getMyTeachLogs
- {
- //判断当前是否正在加载数据。如果正在加载数据,直接return。
- if (_IS_LOADING) {
- return;
- }
-
- [LoadingView showHUD];
- _IS_LOADING=YES;
- //获取第一页数据
- NSInteger needLoadPage;
- needLoadPage=_currentPageNum+1;
- if (_getDataType==MyGetDataTypeHeaderRefresh) {
- needLoadPage=1;
- }
-
- NSString *queryValue = @"";
-
- if ([_stuDic isKindOfClass:[NSDictionary class]]) {
- if ([[_stuDic allKeys] count] != 0) {
- queryValue = _stuDic[@"TSO_ID"];
- }
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"queryValue" Value:queryValue];
- [arr addPro:@"isPage" Value:@"1"];
- [arr addPro:@"pageSize" Value:@"10"];
- [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)needLoadPage]];
-
- NSString* method = @"getMyTeachLogs";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //设置加载状态
- _IS_LOADING=NO;
-
- if (!root) {
- ShowMsg(@"数据请求失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] != 0) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- //处理数据
- //如果获取到了数据,而且是下拉刷新,清空数组。
- if (_getDataType==MyGetDataTypeHeaderRefresh){
- [footData removeAllObjects];
- }
- NSArray *bodyArray = root[@"body"];
- if (bodyArray && bodyArray.count > 0) {
- //追加数据
- [footData addObjectsFromArray:bodyArray];
- //计数器+1
- _currentPageNum=needLoadPage;
- }
- //刷新界面
- [footTableView reloadData];
- //恢复初始状态。
- _getDataType=MyGetDataTypeNomal;
- }];
- }
- - (void)deleteTeachTypesWithRow:(NSInteger)row
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- NSDictionary *dic = footData[row];
-
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"id" Value:dic[@"TL_ID"]];
-
- NSString* method = @"deleteMyTeachLog";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- if (!root) {
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- }
-
- [footData removeObjectAtIndex:row];
- [footTableView reloadData];
- }];
- }
- @end
|