// // 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 = @"教练详情"; if (self.byWillDo) { [self createBottomBarWithtoolTitles:@[@"审核"]]; [self setSegmentControllWithTitles:@[@"基本信息"]]; }else{ [self createBottomBarWithtoolTitles:@[@"锁定/解锁"]]; [self setSegmentControllWithTitles:@[@"基本信息",@"锁定历史记录"]]; UITableView *tableV = _tableViews[1]; tableV.estimatedRowHeight=100; tableV.rowHeight=UITableViewAutomaticDimension; [self getLockRecords]; [self getRequsetData]; UITableView * tabV = [_tableViews lastObject]; _holderV = [[HolderView alloc] initWithFrame:tabV.frame]; [_holderV freshBlock:^{ [self getLockRecords]; }]; [_mainScroolView addSubview:_holderV]; } } -(void)setData{ _keysArr = @[ @[@"培训机构编号",@"CI_INSCODE"], @[@"教练全国编号",@"CI_COACHNUM"], @[@"姓名",@"CI_NAME"], @[@"性别",@"CI_SEX"], @[@"证件号",@"CI_IDCARD"], @[@"手机号码",@"CI_MOBILE"], @[@"联系地址",@"CI_ADDRESS"], @[@"驾驶证号",@"CI_DRILICENCE"], @[@"驾驶证初领日期",@"CI_FSTDRILICDATE"], @[@"职业资格证号",@"CI_OCCUPATIONNO"], @[@"职业资格等级",@"CI_OCCUPATIONLEVEL"], @[@"准驾车型",@"CI_DRIPERMITTED"], @[@"准教车型",@"CI_TEACHPERMITTED"], @[@"供职状态",@"CI_EMPLOYSTATUS"], @[@"入职日期",@"CI_HIREDATE"], @[@"离职日期",@"CI_LEAVEDATE"], @[@"备案状态",@"CI_RECORD_STATUS"], @[@"备案时间",@"CI_RECORD_TIME"], @[@"锁定状态",@"CI_LOCK_STATUS"], @[@"锁定/解锁时间",@"CI_LOCK_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[@"CI_LOCK_STATUS"]] isEqualToString:@"1"]; [_locakBtn setTitle:_isLock ? @"解锁" : @"锁定" forState:UIControlStateNormal]; // if (self.lockBlock) { self.lockBlock(self.dataSource); } }]; } -(void)getLockRecords{ //判断网络是否连接 if (![NetworkManager connectedToNetWork]) { [self showMsgByAlertVCWithString:@"网络连接异常"]; return; } NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init]; [mDic setObject:self.coachNum forKey:@"objnum"]; [mDic setObject:@"2" forKey:@"type"]; [MBProgressHUD hideHUDForView:self.view animated:NO]; [MBProgressHUD showHUDAddedTo:self.view animated:NO]; [NetworkManager requestWithMethod:@"lockLogs" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { [MBProgressHUD hideHUDForView:self.view animated:YES]; [_holderV setHidden:NO]; if (failureStr) { [self showMsgByAlertVCWithString:failureStr]; return; } if ([successDic[@"code"] isEqualToString:@"1"]) { [self showMsgByAlertVCWithString:successDic[@"msg"]]; return; } _dataArr = successDic[@"body"]; if (_dataArr.count != 0) { _holderV.hidden = YES; } [_tableViews[1] reloadData]; }]; } #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{ [self showMsgByMBWithString:@"操作失败,请输入锁定/解锁理由"]; } }]]; NSString *theId = _isLock ? @"550":@"549"; [Tools permissionValidationWithID:theId result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { [self showMsgByMBWithString:failureStr]; } return; } [self presentViewController:alertFind animated:true completion:nil]; }]; } -(void)lockCoachWithReason:(NSString *)reason{ NSMutableDictionary * mdic = [NSMutableDictionary new]; [mdic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"]; [mdic setValue:reason forKey:@"reason"]; [mdic setValue:_isLock ? @"0" : @"1" forKey:@"status"];//类型 类型 1 锁定 0 解锁 [mdic setValue:self.dataSource[@"CI_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 [_keysArr count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if ([_tableViews indexOfObject:tableView] == 1) { return [LockCell heightForDic:_dataArr[indexPath.row]]; } 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]; } - (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