CoachListVC.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // CoachListVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/8.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "CoachListVC.h"
  9. #import "CoachDetail.h"
  10. #import "CoachApplyVC.h"
  11. #import "SYBaseCell.h"
  12. @interface CoachListVC ()
  13. @end
  14. @implementation CoachListVC
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.navigationItem.title = @"教练列表";
  18. [self getData];
  19. __weak typeof(self) weakSelf = self;
  20. self.holdervBlock = ^{
  21. [weakSelf getData];
  22. };
  23. [self.tableView registerNib:[UINib nibWithNibName:@"SYBaseCell" bundle:nil] forCellReuseIdentifier:@"SYBaseCellId"];
  24. [Tools permissionValidationWithID:@"21" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  25. if (isCan) {
  26. [self customRightBtn];
  27. }
  28. }];
  29. }
  30. -(void)customRightBtn{
  31. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  32. btn.frame = CGRectMake(0, 0, 80, 44);
  33. btn.titleLabel.font = [UIFont systemFontOfSize:17];
  34. [btn setTitle:@"新增教练" forState:UIControlStateNormal];
  35. [btn setTitleColor:defGreen forState:UIControlStateNormal];
  36. [btn addTarget:self action:@selector(addNewCoach) forControlEvents:UIControlEventTouchUpInside];
  37. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  38. }
  39. -(void)addNewCoach{
  40. // if (!myDelegate.isSchool) {
  41. // ShowMsg(@"驾校管理员才可以新增操作");
  42. // return;
  43. // }
  44. CoachApplyVC *vc = [[CoachApplyVC alloc] init];
  45. vc.block = ^{
  46. [self getData];
  47. };
  48. [self navPushHideTabbarToVC:vc];
  49. }
  50. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  51. return 44;
  52. }
  53. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  54. {
  55. SYBaseCell * cell = [tableView dequeueReusableCellWithIdentifier:@"SYBaseCellId" forIndexPath:indexPath];
  56. cell.nameLab.text = _dataSource[indexPath.section][indexPath.row][@"TCI_NAME"];
  57. NSString *str = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section][indexPath.row][@"TCI_LOCK_STATUS"]];
  58. cell.lockingImgV.hidden = [str intValue]==0;
  59. return cell;
  60. }
  61. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  62. CoachDetail * coachvc = [[CoachDetail alloc]init];
  63. [_requsetDic setValue:_dataSource[indexPath.section][indexPath.row][@"TCI_IDCARD"] forKey:@"idcard"];
  64. coachvc.requesetDic = _requsetDic;
  65. coachvc.coachNum = _dataSource[indexPath.section][indexPath.row][@"TCI_COACHNUM"];
  66. [self navPushHideTabbarToVC:coachvc];
  67. }
  68. #pragma mark - 数据请求
  69. -(void)getData{
  70. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  71. [mDic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"];
  72. [mDic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"];
  73. [mDic setValue:defUser.userDict[@"school"] forKey:@"schoolId"];
  74. [mDic setValue:@"" forKey:@"name"];
  75. [mDic setValue:@"" forKey:@"idcard"];
  76. [mDic setValue:@"" forKey:@"mobile"];
  77. _requsetDic = mDic;
  78. [self getDataWithDic:mDic method:@"coachs" block:^(NSDictionary *successdic) {
  79. NSArray * arr = successdic[@"body"];
  80. if (arr.count != 0) {
  81. self.holderV.hidden = YES;
  82. }
  83. for (NSDictionary * dic in arr) {
  84. if (![_sectionTitles containsObject:dic[@"ZM"]]) {
  85. [_sectionTitles addObject:dic[@"ZM"]];
  86. [_dataSource addObject:[NSMutableArray new]];
  87. }
  88. }
  89. //排序
  90. [_sectionTitles sortUsingSelector:@selector(compare:)];
  91. for (NSDictionary * dic in arr) {
  92. NSInteger location = [_sectionTitles indexOfObject:dic[@"ZM"]];
  93. [_dataSource[location] addObject:dic];
  94. }
  95. [self.tableView reloadData];
  96. }];
  97. }
  98. @end