123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- //
- // CoachDetail.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/10.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "CoachDetail.h"
- #import "LockCell.h"
- #import "UploadCoachContractVC.h"
- #import "TileViewController.h"
- @interface CoachDetail ()
- {
- BOOL _isLock;//锁定状态
- UIButton * _locakBtn;//锁定/解锁
- NSArray * _dataArr;
-
- HolderView *_holderV;
-
- NSMutableArray *_dataImgs;
- HolderView *_holderV2;
-
- BOOL _isPermission;//上传合同权限
- }
- @end
- @implementation CoachDetail
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"教练详情";
- _dataArr = [[NSArray alloc]init];
- _dataImgs = [[NSMutableArray alloc]init];
-
- [Tools permissionValidationWithID:@"1187" view:self.view result:^(BOOL isCan, NSString *failureStr) {
- _isPermission = isCan;
- if (isCan) {
- [self setSegmentControllWithTitles:@[@"基本信息",@"锁定历史记录",@"合同"] isBttomBar:YES];
- [self createBottomBarWithtoolTitle:@"上传教练合同"];
- }else{
- [self setSegmentControllWithTitles:@[@"基本信息",@"锁定历史记录",@"合同"] isBttomBar:NO];
- }
-
-
-
- [self getRequsetData];
- [self getLockRecords];
-
- UITableView * tabV = _tableViews[1];
- _holderV = [[HolderView alloc] initWithFrame:tabV.frame];
- [_holderV freshBlock:^{
-
- [self getLockRecords];
- }];
- [_mainScroolView addSubview:_holderV];
-
- UITableView *tableV = _tableViews[2];
- _holderV2 = [[HolderView alloc]initWithFrame:tableV.frame];
- _holderV2.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT;
- [_holderV2 freshBlock:^{
- [self getRequsetData];
- }];
- [_mainScroolView addSubview:_holderV2];
-
- }];
- }
- -(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]];
- self.headImgStr = self.dataSource[@"TCI_PHOTO_PATH"];
- [_tableViews[0] reloadData];
-
-
- [_dataImgs removeAllObjects];
- _dataImgs = [NSMutableArray arrayWithArray:[self.dataSource[@"TCI_PROTOCOL_PATH"] componentsSeparatedByString:@","]];
- if (_dataImgs.count > 0) {
- _holderV2.hidden = YES;
- }
- [_tableViews[2] 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"];
-
- [MBProgressHUD showLoadToView:self.view];
- [NetManager requestAnythingWithURL:@"getLockRecords" dictionary:mDic dataArray:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
- _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)createBottomBarWithtoolTitle:(NSString *)title{
-
- UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
- button.frame = CGRectMake(0, kSize.height-kNavOffSet-JOb_DETAIL_BOTTOMBAR_HEIGHT-SafeAreaBottomHeight, kSize.width, JOb_DETAIL_BOTTOMBAR_HEIGHT);
- button.backgroundColor = defGreen;
- [button setTitle:title textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
- [button addTarget:self action:@selector(goToUploadCoachContractVC) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:button];
- }
- -(void)goToUploadCoachContractVC {
-
- // NSLog(@"coachNum--->%@-----dataSource------>%@",self.coachNum,self.dataSource);
-
- UploadCoachContractVC *uploadVC = [[UploadCoachContractVC alloc] init];
- uploadVC.coachID = [NSString stringWithFormat:@"%@",self.dataSource[@"TCI_ID"]];
- uploadVC.imgPaths = self.dataSource[@"TCI_PROTOCOL_PATH"];
- uploadVC.block = ^{
- [self getRequsetData];
- self.currentIndex = 2;
- };
- [self navPushHideTabbarToVC:uploadVC];
- }
- -(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;
- }
-
- if ([_tableViews indexOfObject:tableView] == 2) {
- return 1;
- }
-
- return [super tableView:tableView numberOfRowsInSection:section];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if ([_tableViews indexOfObject:tableView] == 1) {
- return 44;
- }
-
- if ([_tableViews indexOfObject:tableView] == 2) {
- CGFloat height = _isPermission ? JOb_DETAIL_BOTTOMBAR_HEIGHT : 0;
- return kSize.height-kNavOffSet-height-JOb_DETAIL_SEGBAR_HEIGHT-SafeAreaBottomHeight;
- }
-
- return [super tableView:tableView heightForRowAtIndexPath:indexPath];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if ([_tableViews indexOfObject:tableView] == 1) {
-
- LockCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LockCellId"];
- if (!cell) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"LockCell" owner:nil options:nil]lastObject];
- }
- [cell upDataWithDic:_dataArr[indexPath.row]];
-
- return cell;
- }
-
- if ([_tableViews indexOfObject:tableView] == 2) {
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
-
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
- }
- if (cell.contentView.subviews.count != 0) {
- [[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- TileViewController *vc = [[TileViewController alloc]initWithImageNames:_dataImgs];
- CGFloat height = _isPermission ? JOb_DETAIL_BOTTOMBAR_HEIGHT : 0;
- vc.view.height -= 64+JOb_DETAIL_SEGBAR_HEIGHT+height;
- [self addChildViewController:vc];
- [cell.contentView addSubview:vc.view];
-
- return cell;
-
- }
-
- return [super tableView:tableView cellForRowAtIndexPath:indexPath];
- }
- #pragma mark - 上传头像
- -(void)uploadHeadImg:(UIImage*)image
- {
- NSData *data = UIImagePNGRepresentation([image scaledToWid:100]);
- NSString *imgString = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
-
- [dic setObject:imgString forKey:@"content"];
- [dic setObject:self.dataSource[@"TCI_ID"] forKey:@"coachId"];//这个值新增不要,此处修改要
-
- NSString *method = @"uploadCoachPhoto";
- [MBProgressHUD showLoadToView:self.view];
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!root) {
- ShowMsg(@"上传头像失败!");
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowErrorMsg(root[@"msg"]);
- return;
- }
-
- //上传照片成功
- self.headImgStr = root[@"body"];
- ShowMsg(root[@"msg"]);
- [_tableViews[0] 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
|