123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // StudentList.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/8.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "StudentList.h"
- #import "StudentDetail.h"
- #import "StudentListCell.h"
- @interface StudentList ()
- {
- UIView *headerView;
- }
- @end
- @implementation StudentList
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"学员列表";
-
- headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
- headerView.backgroundColor = [UIColor whiteColor];
-
- CGFloat wid = kSize.width/4.0 - 4.0;
- NSArray *titleArray = @[@"姓名",@"性别",@"车型",@"报名日期"];
- for (int i = 0; i < 4; i ++) {
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(wid * i, 0, wid, 50)];
- label.font = [UIFont systemFontOfSize:18 weight:14];
- label.textAlignment = NSTextAlignmentCenter;
- label.text = titleArray[i];
- [headerView addSubview:label];
- }
- headerView.hidden = YES;
-
- self.tableView.tableHeaderView = headerView;
-
- [self.tableView registerNib:[UINib nibWithNibName:@"StudentListCell" bundle:nil] forCellReuseIdentifier:@"studentListCell"];
-
- [self getData];
-
- __weak typeof(self) weakSelf = self;
- _block = ^{
- [weakSelf getData];
- };
- }
- -(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:@"studentName"];
- [mdic setValue:@"" forKey:@"idcard"];
- [mdic setValue:@"" forKey:@"isPage"];
- [mdic setValue:@"" forKey:@"pageSize"];
- [mdic setValue:@"" forKey:@"currentPage"];
-
- _requsetDic = mdic;
-
- [self getDataWithDic:mdic method:@"students" block:^(NSDictionary *successdic) {
- NSArray * arr = successdic[@"body"];
- if (arr.count != 0) {
- self.holderV.hidden = YES;
- headerView.hidden = NO;
- }
-
- 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
- {
- StudentListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"studentListCell" forIndexPath:indexPath];
- if ([_dataSource[indexPath.section] count] > 0) {
- cell.dataDic = _dataSource[indexPath.section][indexPath.row];
- }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 44;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- NSDictionary * dic = _dataSource[indexPath.section][indexPath.row];
- [_requsetDic setValue:dic[@"TSO_IDCARD"] forKey:@"idcard"];
- [_requsetDic setValue:dic[@"TSO_STUNUM"] forKey:@"stunum"];
- [_requsetDic setValue:@"" forKey:@"subject"];
-
- StudentDetail * vc = [[StudentDetail alloc]init];
- vc.dataSource = _dataSource[indexPath.section][indexPath.row];//传入不再请求数据
- vc.requesetDic = _requsetDic;//方便日志,记录查询
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|