// // CoachDetail.m // LNManager // // Created by EchoShacolee on 2017/4/10. // Copyright © 2017年 lee. All rights reserved. // #import "CoachDetail.h" #import "LockCell.h" @interface CoachDetail () { BOOL _isLock;//锁定状态 UIButton * _locakBtn;//锁定/解锁 NSArray * _dataArr; HolderView *_holderV; } @end @implementation CoachDetail - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"教练详情"; [self setSegmentControllWithTitles:@[@"基本信息",@"锁定历史记录"] isBttomBar:NO]; // [self createBottomBarWithtoolTitles:@[@"锁定/解锁"]]; [self getRequsetData]; [self getLockRecords]; UITableView * tabV = _tableViews[1]; _holderV = [[HolderView alloc] initWithFrame:tabV.frame]; [_holderV freshBlock:^{ [self getLockRecords]; }]; [_mainScroolView addSubview:_holderV]; } -(void)setData{ _keysArr = @[ // @[@"培训机构编号",@"TCI_INSCODE"],培训机构编号 @[@"姓名",@"TCI_NAME"], @[@"性别",@"TCI_SEX"], @[@"证件号",@"TCI_IDCARD"], @[@"手机号码",@"TCI_MOBILE"], @[@"联系地址",@"TCI_ADDRESS"], @[@"供职状态",@"TCI_EMPLOYSTATUS"], @[@"驾驶证号",@"TCI_DRILICENCE"], @[@"驾驶证初领日期",@"TCI_FSTDRILICDATE"], @[@"职业资格证号",@"TCI_OCCUPATIONNO"], @[@"职业资格等级",@"TCI_OCCUPATIONLEVEL"], @[@"准驾车型",@"TCI_DRIPERMITTED"], @[@"准教车型",@"TCI_TEACHPERMITTED"], @[@"入职日期",@"TCI_HIREDATE"], @[@"离职日期",@"TCI_LEAVEDATE"], @[@"全国统一编号",@"TCI_COACHNUM"], @[@"备案时间",@"TCI_RECORD_DATE"]]; [super setData]; } -(void)getRequsetData{ [self getDataWithDic:self.requesetDic method:@"coachs" block:^(NSDictionary *successDic) { self.dataSource = [NSMutableDictionary dictionaryWithDictionary:successDic[@"body"][0]]; [_tableViews[0] reloadData]; _isLock = [[NSString stringWithFormat:@"%@",self.dataSource[@"TCI_LOCK_STATUS"]] isEqualToString:@"1"]; [_locakBtn setTitle:_isLock ? @"解锁" : @"锁定" forState:UIControlStateNormal]; }]; } -(void)getLockRecords{ //判断网络是否连接 if (![NetManager connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init]; [mDic setObject:self.coachNum forKey:@"qgcode"]; [mDic setObject:@"2" forKey:@"type"]; [NetManager requestAnythingWithURL:@"getLockRecords" dictionary:mDic dataArray:nil completion:^(NSDictionary *root) { _holderV.hidden = NO; if (!root) { ShowMsg(@"数据请求失败,请重试"); return; } if ([root[@"code"] integerValue] == 1) { ShowMsg(root[@"msg"]); return; } _dataArr = root[@"body"]; if (_dataArr.count > 0) { _holderV.hidden = YES; } [_tableViews[1] reloadData]; _isLock = [[NSString stringWithFormat:@"%@",self.dataSource[@"TCI_LOCK_STATUS"]] isEqualToString:@"1"]; [_locakBtn setTitle:_isLock ? @"解锁" : @"锁定" forState:UIControlStateNormal]; }]; } #pragma mark 创建BottomBarButton -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{ float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count; float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT; for (int i=0; i 0) { [self lockCoachWithReason:tf.text]; }else{ ShowMsg(@"操作失败,请输入锁定/解锁理由"); } }]]; [self presentViewController:alertFind animated:true completion:nil]; } -(void)lockCoachWithReason:(NSString *)reason{ NSMutableDictionary * mdic = [NSMutableDictionary new]; [mdic setValue:defUser.userDict[@"id"] forKey:@"userId"]; [mdic setValue:reason forKey:@"reason"]; [mdic setValue:_isLock ? @"0" : @"1" forKey:@"status"];//类型 类型 1 锁定 0 解锁 [mdic setValue:self.dataSource[@"TCI_COACHNUM"] forKey:@"coachnum"]; [self getDataWithDic:mdic method:@"lockCoach" block:^(NSDictionary *successdic) { //解锁成功,重新请求数据 [self getRequsetData]; [self getLockRecords]; }]; } #pragma mark 重写代理方法 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if ([_tableViews indexOfObject:tableView] == 1) { return _dataArr.count; } return [super tableView:tableView numberOfRowsInSection:section]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if ([_tableViews indexOfObject:tableView] == 1) { return 85; } return [super tableView:tableView heightForRowAtIndexPath:indexPath]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if ([_tableViews indexOfObject:tableView] == 1) { LockCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"]; if (!cell) { cell = [[[NSBundle mainBundle] loadNibNamed:@"LockCell" owner:nil options:nil]lastObject]; } [cell upDataWithDic:_dataArr[indexPath.row]]; return cell; } return [super tableView:tableView cellForRowAtIndexPath:indexPath]; } @end