CoachDetail.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. //
  2. // CoachDetail.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/10.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "CoachDetail.h"
  9. #import "LockCell.h"
  10. @interface CoachDetail ()
  11. {
  12. BOOL _isLock;//锁定状态
  13. UIButton * _locakBtn;//锁定/解锁
  14. NSArray * _dataArr;
  15. HolderView * _holderV;
  16. }
  17. @end
  18. @implementation CoachDetail
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.navigationItem.title = @"教练详情";
  22. if (self.byWillDo) {
  23. [self createBottomBarWithtoolTitles:@[@"审核"]];
  24. [self setSegmentControllWithTitles:@[@"基本信息"]];
  25. }else{
  26. [self createBottomBarWithtoolTitles:@[@"锁定/解锁"]];
  27. [self setSegmentControllWithTitles:@[@"基本信息",@"锁定历史记录"]];
  28. [self getLockRecords];
  29. [self getRequsetData];
  30. UITableView * tabV = [_tableViews lastObject];
  31. _holderV = [[HolderView alloc] initWithFrame:tabV.frame];
  32. [_holderV freshBlock:^{
  33. [self getLockRecords];
  34. }];
  35. [_mainScroolView addSubview:_holderV];
  36. }
  37. }
  38. -(void)setData{
  39. _keysArr = @[
  40. @[@"培训机构编号",@"CI_INSCODE"],
  41. @[@"教练全国编号",@"CI_COACHNUM"],
  42. @[@"姓名",@"CI_NAME"],
  43. @[@"性别",@"CI_SEX"],
  44. @[@"证件号",@"CI_IDCARD"],
  45. @[@"手机号码",@"CI_MOBILE"],
  46. @[@"联系地址",@"CI_ADDRESS"],
  47. @[@"驾驶证号",@"CI_DRILICENCE"],
  48. @[@"驾驶证初领日期",@"CI_FSTDRILICDATE"],
  49. @[@"职业资格证号",@"CI_OCCUPATIONNO"],
  50. @[@"职业资格等级",@"CI_OCCUPATIONLEVEL"],
  51. @[@"准驾车型",@"CI_DRIPERMITTED"],
  52. @[@"准教车型",@"CI_TEACHPERMITTED"],
  53. @[@"供职状态",@"CI_EMPLOYSTATUS"],
  54. @[@"入职日期",@"CI_HIREDATE"],
  55. @[@"离职日期",@"CI_LEAVEDATE"],
  56. @[@"备案状态",@"CI_RECORD_STATUS"],
  57. @[@"备案时间",@"CI_RECORD_TIME"],
  58. @[@"锁定状态",@"CI_LOCK_STATUS"],
  59. @[@"锁定/解锁时间",@"CI_LOCK_DATE"]];
  60. [super setData];
  61. }
  62. -(void)getRequsetData{
  63. [self getDataWithDic:self.requesetDic method:@"coachs" block:^(NSDictionary *successDic) {
  64. self.dataSource = [NSMutableDictionary dictionaryWithDictionary:successDic[@"body"][0]];
  65. [_tableViews[0] reloadData];
  66. _isLock = [[NSString stringWithFormat:@"%@",self.dataSource[@"CI_LOCK_STATUS"]] isEqualToString:@"1"];
  67. [_locakBtn setTitle:_isLock ? @"解锁" : @"锁定" forState:UIControlStateNormal];
  68. }];
  69. }
  70. -(void)getLockRecords{
  71. //判断网络是否连接
  72. if (![NetworkManager connectedToNetWork]) {
  73. [self showMsgByAlertVCWithString:@"网络连接异常"];
  74. return;
  75. }
  76. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  77. [mDic setObject:self.coachNum forKey:@"objnum"];
  78. [mDic setObject:@"2" forKey:@"type"];
  79. [MBProgressHUD hideHUDForView:self.view animated:NO];//强行先掉一次@lee
  80. [MBProgressHUD showHUDAddedTo:self.view animated:NO];
  81. [NetworkManager requestWithMethod:@"lockLogs" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  82. [MBProgressHUD hideHUDForView:self.view animated:YES];
  83. [_holderV setHidden:NO];
  84. if (failureStr) {
  85. [self showMsgByAlertVCWithString:failureStr];
  86. return;
  87. }
  88. if ([successDic[@"code"] isEqualToString:@"1"]) {
  89. [self showMsgByAlertVCWithString:successDic[@"msg"]];
  90. return;
  91. }
  92. _dataArr = successDic[@"body"];
  93. if (_dataArr.count != 0) {
  94. _holderV.hidden = YES;
  95. }
  96. [_tableViews[1] reloadData];
  97. }];
  98. }
  99. #pragma mark 创建BottomBarButton
  100. -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
  101. float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
  102. float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT;
  103. for (int i=0; i<toolTitles.count; i++) {
  104. UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
  105. button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-SafeAreaBottomHeight, widthBtn, HeightBth);
  106. if (i == 0 && self.byWillDo == NO) {
  107. [button setTitle:@"锁定" forState:UIControlStateNormal];
  108. _locakBtn = button;
  109. }else{
  110. [button setTitle:toolTitles[i] forState:UIControlStateNormal];
  111. }
  112. UIColor * color = COLOR_THEME;
  113. button.backgroundColor = color;
  114. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  115. [button addTarget:self action:@selector(lockReason) forControlEvents:UIControlEventTouchUpInside];
  116. button.tag = 100+i;
  117. [self.view addSubview:button];
  118. }
  119. }
  120. -(void)lockReason{
  121. if (self.byWillDo && self.shenheBLock) {
  122. self.shenheBLock();
  123. return;
  124. }
  125. NSString * title = _isLock ? @"解锁":@"锁定";
  126. NSString *message = [NSString stringWithFormat:@"请输入%@理由:",title];
  127. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
  128. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  129. textField.placeholder = [NSString stringWithFormat:@"(必须填写,否则将无法完成%@)",title];
  130. }];
  131. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  132. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  133. UITextField *tf = alertFind.textFields[0];
  134. if (tf.text.length > 0) {
  135. [self lockCoachWithReason:tf.text];
  136. }else{
  137. [self showMsgByMBWithString:@"操作失败,请输入锁定/解锁理由"];
  138. }
  139. }]];
  140. [self presentViewController:alertFind animated:true completion:nil];
  141. }
  142. -(void)lockCoachWithReason:(NSString *)reason{
  143. NSMutableDictionary * mdic = [NSMutableDictionary new];
  144. [mdic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"userId"];
  145. [mdic setValue:reason forKey:@"reason"];
  146. [mdic setValue:_isLock ? @"0" : @"1" forKey:@"status"];//类型 类型 1 锁定 0 解锁
  147. [mdic setValue:self.dataSource[@"CI_COACHNUM"] forKey:@"coachnum"];
  148. [self getDataWithDic:mdic method:@"lockCoach" block:^(NSDictionary *successdic) {
  149. //解锁成功,重新请求数据
  150. [self getRequsetData];
  151. [self getLockRecords];
  152. }];
  153. }
  154. #pragma mark 重写代理方法
  155. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  156. if ([_tableViews indexOfObject:tableView] == 1) {
  157. return _dataArr.count;
  158. }
  159. return [_keysArr count];
  160. }
  161. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  162. if ([_tableViews indexOfObject:tableView] == 1) {
  163. return 85;
  164. }
  165. return [super tableView:tableView heightForRowAtIndexPath:indexPath];
  166. }
  167. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  168. {
  169. if ([_tableViews indexOfObject:tableView] == 1) {
  170. LockCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  171. if (!cell) {
  172. cell = [[[NSBundle mainBundle] loadNibNamed:@"LockCell" owner:nil options:nil]lastObject];
  173. }
  174. [cell upDataWithDic:_dataArr[indexPath.row]];
  175. return cell;
  176. }
  177. return [super tableView:tableView cellForRowAtIndexPath:indexPath];
  178. }
  179. - (void)didReceiveMemoryWarning {
  180. [super didReceiveMemoryWarning];
  181. // Dispose of any resources that can be recreated.
  182. }
  183. /*
  184. #pragma mark - Navigation
  185. // In a storyboard-based application, you will often want to do a little preparation before navigation
  186. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  187. // Get the new view controller using [segue destinationViewController].
  188. // Pass the selected object to the new view controller.
  189. }
  190. */
  191. @end