CoachListVC.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 "MengBanView.h"
  11. #import "SYBaseCell.h"
  12. @interface CoachListVC ()
  13. {
  14. MengBanView * _mengBanView;
  15. NSString * _status;
  16. }
  17. @end
  18. @implementation CoachListVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.navigationItem.title = @"教练列表";
  22. // [self customRightBtn];
  23. _status = @"1";
  24. [self getData];
  25. __weak typeof(self) weakSelf = self;
  26. _block = ^{
  27. [weakSelf getData];
  28. };
  29. [self.tableView registerNib:[UINib nibWithNibName:@"SYBaseCell" bundle:nil] forCellReuseIdentifier:@"SYBaseCellId"];
  30. }
  31. -(void)customRightBtn{
  32. UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)];
  33. item.tintColor = COLOR_THEME;
  34. self.navigationItem.rightBarButtonItem = item;
  35. }
  36. -(void)setMengbanView{
  37. if (_mengBanView) {
  38. [_mengBanView showView];
  39. return;
  40. }
  41. NSArray * btnarr = @[@"待审核",@"审核通过",@"审核驳回"];
  42. _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:@[btnarr] block:^(NSArray *array) {
  43. if ([array[0] isEqualToString:@"待审核"]) {
  44. _status = @"0";
  45. }else if ([array[0] isEqualToString:@"审核通过"]){
  46. _status = @"1";
  47. }else if ([array[0] isEqualToString:@"审核驳回"]){
  48. _status = @"2";
  49. }
  50. [self getData];
  51. }];
  52. [_mengBanView showView];
  53. }
  54. -(void)getData{
  55. NSMutableDictionary * mdic = [NSMutableDictionary new];
  56. [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_DQBH"]] forKey:@"dqbh"];
  57. [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_QXBH"]] forKey:@"qxbh"];
  58. [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_INSCODE"]] forKey:@"inscode"];
  59. [mdic setValue:@"" forKey:@"coachName"];
  60. [mdic setValue:@"" forKey:@"idcard"];
  61. [mdic setValue:@"" forKey:@"isPage"];
  62. [mdic setValue:@"" forKey:@"pageSize"];
  63. [mdic setValue:@"" forKey:@"currentPage"];
  64. [mdic setValue:_status forKey:@"auditStatus"];
  65. [mdic setValue:@"" forKey:@"phone"];
  66. _requsetDic = mdic;
  67. [self getDataWithDic:mdic method:@"coachs" block:^(NSDictionary *successdic) {
  68. //
  69. [_sectionTitles removeAllObjects];
  70. [_dataSource removeAllObjects];
  71. NSArray * arr = successdic[@"body"];
  72. if (arr.count != 0) {
  73. self.holderV.hidden = YES;
  74. }
  75. for (NSDictionary * dic in arr) {
  76. if (![_sectionTitles containsObject:dic[@"ZM"]]) {
  77. [_sectionTitles addObject:dic[@"ZM"]];
  78. [_dataSource addObject:[NSMutableArray new]];
  79. }
  80. }
  81. //排序
  82. [_sectionTitles sortUsingSelector:@selector(compare:)];
  83. for (NSDictionary * dic in arr) {
  84. NSInteger location = [_sectionTitles indexOfObject:dic[@"ZM"]];
  85. [_dataSource[location] addObject:dic];
  86. }
  87. [self.tableView reloadData];
  88. }];
  89. }
  90. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  91. {
  92. NSDictionary * dic;
  93. if (_hasSearch) {
  94. dic = _resultArray[indexPath.row][0];
  95. }else{
  96. dic = _dataSource[indexPath.section][indexPath.row];
  97. }
  98. SYBaseCell * cell = [tableView dequeueReusableCellWithIdentifier:@"SYBaseCellId" forIndexPath:indexPath];
  99. cell.nameLab.text = dic[@"CI_NAME"];
  100. NSString *str = [NSString stringWithFormat:@"%@",dic[@"CI_LOCK_STATUS"]];
  101. cell.lockingImgV.hidden = [str intValue]==0;
  102. return cell;
  103. }
  104. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  105. NSDictionary * dic;
  106. NSIndexPath *correctIndexP;
  107. if (_hasSearch) {
  108. dic = _resultArray[indexPath.row][0];
  109. correctIndexP = _resultArray[indexPath.row][1];
  110. }else{
  111. dic = _dataSource[indexPath.section][indexPath.row];
  112. correctIndexP = indexPath;
  113. }
  114. CoachDetail * coachvc = [[CoachDetail alloc]init];
  115. coachvc.lockBlock = ^(NSDictionary *data) {
  116. [_dataSource[correctIndexP.section] replaceObjectAtIndex:correctIndexP.row withObject:data];
  117. [self.tableView reloadData];
  118. };
  119. [_requsetDic setValue:dic[@"CI_IDCARD"] forKey:@"idcard"];
  120. coachvc.requesetDic = _requsetDic;
  121. coachvc.coachNum = dic[@"CI_COACHNUM"];
  122. [self.navigationController pushViewController:coachvc animated:YES];
  123. }
  124. #pragma mark - 搜索代理
  125. - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
  126. {
  127. NSString *searchString = _searchController.searchBar.text;
  128. // NSLog(@"searchString-->%@",searchString);
  129. _hasSearch = NO;
  130. if (searchString.length > 0) {
  131. [_resultArray removeAllObjects];
  132. int i=0,j=0;
  133. if ([searchString integerValue] == 0)
  134. {//汉字
  135. for (NSArray *sectionArr in _dataSource)
  136. {
  137. j=0;
  138. for (NSDictionary *dic in sectionArr)
  139. {
  140. NSIndexPath *path = [NSIndexPath indexPathForRow:j inSection:i];
  141. if ([dic[@"CI_NAME"] rangeOfString:searchString].location != NSNotFound)
  142. {
  143. [_resultArray addObject:@[dic,path]];
  144. }
  145. j++;
  146. }
  147. i++;
  148. }
  149. }else{
  150. for (NSArray *sectionArr in _dataSource)
  151. {
  152. j=0;
  153. for (NSDictionary *dic in sectionArr)
  154. {
  155. NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:j];
  156. BOOL isTrue1 = [[NSString stringWithFormat:@"%@",dic[@"CI_MOBILE"]] rangeOfString:searchString].location != NSNotFound;
  157. BOOL isTrue2 = [[NSString stringWithFormat:@"%@",dic[@"CI_IDCARD"]] rangeOfString:searchString].location != NSNotFound;
  158. if (isTrue2)
  159. {
  160. [_resultArray addObject:@[dic,path]];
  161. }else if(isTrue1)
  162. {
  163. [_resultArray addObject:@[dic,path]];
  164. }
  165. j++;
  166. }
  167. i++;
  168. }
  169. }
  170. _hasSearch = YES;
  171. }
  172. [self.tableView reloadData];
  173. }
  174. - (void)didReceiveMemoryWarning {
  175. [super didReceiveMemoryWarning];
  176. // Dispose of any resources that can be recreated.
  177. }
  178. /*
  179. #pragma mark - Navigation
  180. // In a storyboard-based application, you will often want to do a little preparation before navigation
  181. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  182. // Get the new view controller using [segue destinationViewController].
  183. // Pass the selected object to the new view controller.
  184. }
  185. */
  186. @end