123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- //
- // CoachListVC.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/8.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "CoachListVC.h"
- #import "CoachDetail.h"
- #import "MengBanView.h"
- #import "SYBaseCell.h"
- @interface CoachListVC ()
- {
- MengBanView * _mengBanView;
- NSString * _status;
- }
- @end
- @implementation CoachListVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"教练列表";
-
- // [self customRightBtn];
-
- _status = @"1";
- [self getData];
-
- __weak typeof(self) weakSelf = self;
- _block = ^{
- [weakSelf getData];
- };
- [self.tableView registerNib:[UINib nibWithNibName:@"SYBaseCell" bundle:nil] forCellReuseIdentifier:@"SYBaseCellId"];
- }
- -(void)customRightBtn{
- UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)];
- item.tintColor = COLOR_THEME;
- self.navigationItem.rightBarButtonItem = item;
- }
- -(void)setMengbanView{
-
- if (_mengBanView) {
- [_mengBanView showView];
- return;
- }
-
- NSArray * btnarr = @[@"待审核",@"审核通过",@"审核驳回"];
- _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:@[btnarr] block:^(NSArray *array) {
-
- if ([array[0] isEqualToString:@"待审核"]) {
- _status = @"0";
- }else if ([array[0] isEqualToString:@"审核通过"]){
- _status = @"1";
- }else if ([array[0] isEqualToString:@"审核驳回"]){
- _status = @"2";
- }
- [self getData];
- }];
- [_mengBanView showView];
- }
- -(void)getData{
-
- NSMutableDictionary * mdic = [NSMutableDictionary new];
- [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_DQBH"]] forKey:@"dqbh"];
- [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_QXBH"]] forKey:@"qxbh"];
- [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_INSCODE"]] forKey:@"inscode"];
- [mdic setValue:@"" forKey:@"coachName"];
- [mdic setValue:@"" forKey:@"idcard"];
- [mdic setValue:@"" forKey:@"isPage"];
- [mdic setValue:@"" forKey:@"pageSize"];
- [mdic setValue:@"" forKey:@"currentPage"];
- [mdic setValue:_status forKey:@"auditStatus"];
- [mdic setValue:@"" forKey:@"phone"];
-
- _requsetDic = mdic;
- [self getDataWithDic:mdic method:@"coachs" block:^(NSDictionary *successdic) {
-
- //
- [_sectionTitles removeAllObjects];
- [_dataSource removeAllObjects];
-
- NSArray * arr = successdic[@"body"];
- if (arr.count != 0) {
- self.holderV.hidden = YES;
- }
-
- for (NSDictionary * dic in arr) {
- if (![_sectionTitles containsObject:dic[@"ZM"]]) {
- [_sectionTitles addObject:dic[@"ZM"]];
- [_dataSource addObject:[NSMutableArray new]];
- }
- }
-
- //排序
- [_sectionTitles sortUsingSelector:@selector(compare:)];
-
- for (NSDictionary * dic in arr) {
- NSInteger location = [_sectionTitles indexOfObject:dic[@"ZM"]];
- [_dataSource[location] addObject:dic];
- }
-
- [self.tableView reloadData];
- }];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSDictionary * dic;
- if (_hasSearch) {
- dic = _resultArray[indexPath.row][0];
- }else{
- dic = _dataSource[indexPath.section][indexPath.row];
- }
-
- SYBaseCell * cell = [tableView dequeueReusableCellWithIdentifier:@"SYBaseCellId" forIndexPath:indexPath];
- cell.nameLab.text = dic[@"CI_NAME"];
- NSString *str = [NSString stringWithFormat:@"%@",dic[@"CI_LOCK_STATUS"]];
- cell.lockingImgV.hidden = [str intValue]==0;
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- NSDictionary * dic;
- NSIndexPath *correctIndexP;
- if (_hasSearch) {
- dic = _resultArray[indexPath.row][0];
- correctIndexP = _resultArray[indexPath.row][1];
- }else{
- dic = _dataSource[indexPath.section][indexPath.row];
- correctIndexP = indexPath;
- }
-
- CoachDetail * coachvc = [[CoachDetail alloc]init];
- coachvc.lockBlock = ^(NSDictionary *data) {
- [_dataSource[correctIndexP.section] replaceObjectAtIndex:correctIndexP.row withObject:data];
- [self.tableView reloadData];
- };
- [_requsetDic setValue:dic[@"CI_IDCARD"] forKey:@"idcard"];
- coachvc.requesetDic = _requsetDic;
- coachvc.coachNum = dic[@"CI_COACHNUM"];
- [self.navigationController pushViewController:coachvc animated:YES];
- }
- #pragma mark - 搜索代理
- - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
- {
- NSString *searchString = _searchController.searchBar.text;
- // NSLog(@"searchString-->%@",searchString);
- _hasSearch = NO;
- if (searchString.length > 0) {
- [_resultArray removeAllObjects];
- int i=0,j=0;
- if ([searchString integerValue] == 0)
- {//汉字
- for (NSArray *sectionArr in _dataSource)
- {
- j=0;
- for (NSDictionary *dic in sectionArr)
- {
- NSIndexPath *path = [NSIndexPath indexPathForRow:j inSection:i];
- if ([dic[@"CI_NAME"] rangeOfString:searchString].location != NSNotFound)
- {
- [_resultArray addObject:@[dic,path]];
- }
- j++;
- }
- i++;
- }
-
- }else{
-
- for (NSArray *sectionArr in _dataSource)
- {
- j=0;
- for (NSDictionary *dic in sectionArr)
- {
- NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:j];
- BOOL isTrue1 = [[NSString stringWithFormat:@"%@",dic[@"CI_MOBILE"]] rangeOfString:searchString].location != NSNotFound;
- BOOL isTrue2 = [[NSString stringWithFormat:@"%@",dic[@"CI_IDCARD"]] rangeOfString:searchString].location != NSNotFound;
- if (isTrue2)
- {
- [_resultArray addObject:@[dic,path]];
- }else if(isTrue1)
- {
- [_resultArray addObject:@[dic,path]];
- }
- j++;
- }
- i++;
- }
- }
- _hasSearch = YES;
- }
- [self.tableView 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
|