123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709 |
- //
- // coachRecordVC.m
- // jiaPeiC
- //
- // Created by apple on 16/3/8.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- //带教记录
- #import "coachRecordVC.h"
- #import "AddRecordVC.h"
- #import "AppDelegate.h"
- #import "Tools.h"
- #import "DetailTJVC.h"
- #import "RecordCell.h"
- #import <MJRefresh.h>
- typedef NS_ENUM(NSInteger, MyGetDataType) {
- //正常请求数据
- MyGetDataTypeNomal=0,
- //下拉刷新请求数据
- MyGetDataTypeHeaderRefresh,
- //上拉加载更多请求数据
- MyGetDataTypeFooterRefresh
- };
- @interface coachRecordVC ()<UITableViewDelegate,UITableViewDataSource>
- {
- //记录页书
- NSInteger _currentPageNum;
- //正在加载的状态
- BOOL _IS_LOADING;
- //加载数据的类型
- MyGetDataType _getDataType;
-
- HolderView *holderV;
- UITextField *tfName;
- UITableView *mainTableView;
- NSMutableArray *models;//底部foottab数据源
- NSArray *xArray;
- NSMutableArray *teachTypes;
- NSString *searchString;
- }
- @end
- @implementation coachRecordVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- _currentPageNum = 0;
- _IS_LOADING = NO;
- _getDataType = MyGetDataTypeNomal;
-
- models = [NSMutableArray array];
- xArray = [NSArray array];
- teachTypes = [NSMutableArray array];
-
- float h,bd,w,x,y;
-
- x = bd = 10;
- w = (kSize.width - bd*4)/6.0;
- h = 50;
- y = kNavOffSet + bd;
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w * 2, h)];
- label.text = _stuDic[@"STU_NAME"];
- label.textColor = kTitleColor;
- label.textAlignment = NSTextAlignmentCenter;
- [label setFont:[UIFont scaleSize:21]];
- [self.view addSubview:label];
-
- UILabel *telLabel = [[UILabel alloc] initWithFrame:CGRectMake(x + 2*w + 2*bd, y + 8, w * 4, h - 8)];
- //用富文本将电话号码
- NSString *telString = [NSString stringWithFormat:@"电话号码:%@",_stuDic[@"TSO_PHONE"]];
- NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:telString];
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:contentTextColor
- range:NSMakeRange(0, 5)];
- [aAttributedString addAttribute:NSForegroundColorAttributeName
- value:defGreen
- range:NSMakeRange(5, telString.length - 5)];
-
- telLabel.attributedText = aAttributedString;
- telLabel.textAlignment = NSTextAlignmentCenter;
- [telLabel setFont:[UIFont scaleSize:Font16]];
- [self.view addSubview:telLabel];
-
- //电话按钮
- UIButton *telBtn = [[UIButton alloc] initWithFrame:CGRectMake(x + 2*w + 2*bd, y, w * 4, h)];
- [telBtn target:self Tag:1];
- [self addV:telBtn];
-
- y += h + bd + 8;
- h -= 10;
-
- UIImageView *btnImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, y + 5, 30, 30)];
- btnImg.image = [UIImage imageNamed:@"xiuxue.png"];
- [self addV:btnImg];
-
- UIButton *btn;
- btn = [[UIButton alloc] initWithFrame:CGRectMake(0, y, kSize.width/2.0, h)];
- [btn setTitle:@"添加日志" textColor:kTitleColor font:Font16 fotState:UIControlStateNormal];
- [btn borderColor:lineColor width:2 cornorRadios:0];
- [self addV:btn];
- [btn target:self Tag:2];
-
- btnImg = [[UIImageView alloc] initWithFrame:CGRectMake(kSize.width/2.0 + 8, y + 5, 30, 30)];
- btnImg.image = [UIImage imageNamed:@"record.png"];
- [self addV:btnImg];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2.0 - 2, y, kSize.width/2.0 + 2, h)];
- [btn setTitle:@"日志统计" textColor:kTitleColor font:Font16 fotState:UIControlStateNormal];
- [btn borderColor:lineColor width:2 cornorRadios:0];
- [self addV:btn];
- [btn target:self Tag:3];
-
- y += h + 2;
- mainTableView = [[UITableView alloc] initWithFrame:kFrame];
- mainTableView.y = y;
- mainTableView.height = kSize.height - mainTableView.y - kSafeAreaBottomHeight;
- [mainTableView setDelegate:self];
- [mainTableView setDataSource:self];
- mainTableView.estimatedSectionFooterHeight = 0;
- [self addV:mainTableView];
- [mainTableView setTableFooterView:[UIView new]];
-
- holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
- [holderV freshBlock:^{
- [self getMyTeachLogs];
- }];
- [self addV:holderV];
- [holderV setHidden:YES];
-
- [self setRefreshAction];
-
- //休学记录==> 获取教学日志类型==〉日志记录
- [self getStuXXList];
-
- }
- -(void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 1) {
- //拨打电话
- NSString* tel = _stuDic[@"TSO_PHONE"];
- if (tel && ![tel isEqualToString:@""]) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]]];
- }
- }
- if (sender.tag == 2) {
-
- if ([_stuDic[@"SUBJECT"] integerValue] == 1 || [_stuDic[@"SUBJECT"] integerValue] == 4) {
- ShowMsg(@"当前科目无需添加日志!");
- return;
- }
- AddRecordVC *vc = [[AddRecordVC alloc] init];
- vc.refreshTeachlogs = ^{
- [self headerRefresh];
- };
- vc.stuDic = _stuDic;
- vc.view.backgroundColor = backGroundColor;
- [vc configNavBar];
- [self.navigationController pushViewController:vc animated:YES];
- }
- if (sender.tag == 3) {
-
- DetailTJVC *TJVC = [[DetailTJVC alloc] init];
- [TJVC configNavBar];
- TJVC.view.backgroundColor = backGroundColor;
- [self.navigationController pushViewController:TJVC animated:YES];
- }
- }
- #pragma mark - 下拉刷新,上拉加载 -
- -(void)setRefreshAction{
-
- // 下拉刷新
- __weak typeof(self) weakSelf = self;
- MJRefreshNormalHeader *mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakSelf headerRefresh];
- }];
- mainTableView.mj_header = mj_header;
-
- MJRefreshBackNormalFooter *mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- [weakSelf footerRefresh];
- }];
- mainTableView.mj_footer = mj_footer;
-
- }
- #pragma mark - 数据加载更多和刷新 -
- -(void)headerRefresh{
- //设置获取数据的方式
- _getDataType=MyGetDataTypeHeaderRefresh;
- //加载数据
- [self getMyTeachLogs];
- [mainTableView.mj_header endRefreshing];
- }
- -(void)footerRefresh{
- //设置获取数据的方式
- _getDataType=MyGetDataTypeFooterRefresh;
- //加载数据
- [self getMyTeachLogs];
- [mainTableView.mj_footer endRefreshing];
- }
- #pragma mark 数据请求
- //请求休学信息
- - (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)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"];// @lee 这个判断似乎没用
- }
- }
-
- 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:@"%ld",(long)needLoadPage]];
-
- NSString* method = @"getMyTeachLogs";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //设置加载状态
- _IS_LOADING=NO;
- //处理数据
- //如果获取到了数据,而且是下拉刷新,清空数组。
- if (_getDataType==MyGetDataTypeHeaderRefresh){
- [models removeAllObjects];
- }
- NSArray *bodyArray = root[@"body"];
- if (bodyArray && bodyArray.count > 0) {
- //追加数据
- [models addObjectsFromArray:bodyArray];
- //计数器+1
- _currentPageNum=needLoadPage;
- }
- if (xArray.count >0 || models.count >0) {
- [holderV setHidden:YES];
- }
- //刷新界面
- [mainTableView reloadData];
- //恢复初始状态。
- _getDataType=MyGetDataTypeNomal;
-
- }];
- }
- - (void)deleteTeachTypesWithRow:(NSInteger)row
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSDictionary *dic = models[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();
- //NSLog(@"日志删除---->%@----->%@",arr,root);
- if (!root) {
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- }
-
- [models removeObjectAtIndex:row];
- [mainTableView reloadData];
- }];
- }
- #pragma mark - tableview delegate
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- if (xArray.count > 0 && models.count > 0) {
- return 2;
- }else{
- return 1;
- }
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- 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 && models.count > 0) {
-
- if (section == 0) {
- return xLabel;
- }else{
- return rLabel;
- }
- }else if (xArray.count > 0){
- return xLabel;
- }else if (models.count > 0){
- return rLabel;
- }else{
- return [UILabel new];
- }
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 40;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if (xArray.count > 0 && models.count > 0) {
-
- if (section == 0) {
- return xArray.count;
- }else{
- return models.count;
- }
- }else if (xArray.count > 0){
- return xArray.count;
- }else if (models.count > 0){
- return models.count;
- }else{
- return 0;
- }
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- RecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- cell = [[RecordCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- }
-
- @try {
-
- if (xArray.count > 0 && models.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 = models[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 = NO;
- //日期
- 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){
-
- NSDictionary *dic = xArray[indexPath.row];
- //♦
- cell.textLabel.adjustsFontSizeToFitWidth = YES;
- 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 = models[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 = NO;
-
- //日期
- 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;
- }
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (xArray.count > 0 && indexPath.section == 0) {
- return 80.5;
- }
- NSDictionary *dic = models[indexPath.row];
- CGFloat height = [[NSString stringWithFormat:@"备注:%@",dic[@"TL_REMARK"]] heightForWid:kSize.width - 20 Font:15];
-
- return height + 70.5;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (xArray.count > 0 && models.count > 0) {
-
- if (indexPath.section == 0) {
- return;
- }else{
- AddRecordVC *vc = [[AddRecordVC alloc] init];
- vc.stuDic = _stuDic;
- vc.refreshTeachlogs = ^{
- [self headerRefresh];
- };
- vc.teachType = teachTypes;
- vc.recordDic = models[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.stuDic = _stuDic;
- vc.refreshTeachlogs = ^{
- [self headerRefresh];
- };
- vc.teachType = teachTypes;
- vc.recordDic = models[indexPath.row];
- vc.view.backgroundColor = backGroundColor;
- [vc configNavBar];
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- //表的编辑
- -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (xArray.count > 0) {
- if (indexPath.section == 0) {
- return NO;
- }
- }
- return YES;
- }
- //记得默认是yes
- -(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return YES;
- }
- -(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return @"删除";
- }
- -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [self deleteTeachTypesWithRow:indexPath.row];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|