StudentList.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // StudentList.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/8.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "StudentList.h"
  9. #import "StudentDetail.h"
  10. #import "StudentListCell.h"
  11. @interface StudentList ()
  12. {
  13. UIView *headerView;
  14. }
  15. @end
  16. @implementation StudentList
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.navigationItem.title = @"学员列表";
  20. headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
  21. headerView.backgroundColor = [UIColor whiteColor];
  22. CGFloat wid = kSize.width/4.0 - 4.0;
  23. NSArray *titleArray = @[@"姓名",@"性别",@"车型",@"报名日期"];
  24. for (int i = 0; i < 4; i ++) {
  25. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(wid * i, 0, wid, 50)];
  26. label.font = [UIFont systemFontOfSize:18 weight:14];
  27. label.textAlignment = NSTextAlignmentCenter;
  28. label.text = titleArray[i];
  29. [headerView addSubview:label];
  30. }
  31. headerView.hidden = YES;
  32. self.tableView.tableHeaderView = headerView;
  33. [self.tableView registerNib:[UINib nibWithNibName:@"StudentListCell" bundle:nil] forCellReuseIdentifier:@"studentListCell"];
  34. [self getData];
  35. __weak typeof(self) weakSelf = self;
  36. _block = ^{
  37. [weakSelf getData];
  38. };
  39. }
  40. -(void)getData{
  41. NSMutableDictionary * mdic = [NSMutableDictionary new];
  42. [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_DQBH"]] forKey:@"dqbh"];
  43. [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_QXBH"]] forKey:@"qxbh"];
  44. [mdic setValue:[NSString stringWithFormat:@"%@",_shcDic[@"TSI_INSCODE"]] forKey:@"inscode"];
  45. [mdic setValue:@"" forKey:@"studentName"];
  46. [mdic setValue:@"" forKey:@"idcard"];
  47. [mdic setValue:@"" forKey:@"isPage"];
  48. [mdic setValue:@"" forKey:@"pageSize"];
  49. [mdic setValue:@"" forKey:@"currentPage"];
  50. _requsetDic = mdic;
  51. [self getDataWithDic:mdic method:@"students" block:^(NSDictionary *successdic) {
  52. NSArray * arr = successdic[@"body"];
  53. if (arr.count != 0) {
  54. self.holderV.hidden = YES;
  55. headerView.hidden = NO;
  56. }
  57. for (NSDictionary * dic in arr) {
  58. if (![_sectionTitles containsObject:dic[@"ZM"]]) {
  59. [_sectionTitles addObject:dic[@"ZM"]];
  60. [_dataSource addObject:[NSMutableArray new]];
  61. }
  62. }
  63. //排序
  64. [_sectionTitles sortUsingSelector:@selector(compare:)];
  65. for (NSDictionary * dic in arr) {
  66. NSInteger location = [_sectionTitles indexOfObject:dic[@"ZM"]];
  67. [_dataSource[location] addObject:dic];
  68. }
  69. [self.tableView reloadData];
  70. }];
  71. }
  72. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  73. {
  74. StudentListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"studentListCell" forIndexPath:indexPath];
  75. if ([_dataSource[indexPath.section] count] > 0) {
  76. cell.dataDic = _dataSource[indexPath.section][indexPath.row];
  77. }
  78. return cell;
  79. }
  80. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  81. return 44;
  82. }
  83. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  84. NSDictionary * dic = _dataSource[indexPath.section][indexPath.row];
  85. [_requsetDic setValue:dic[@"TSO_IDCARD"] forKey:@"idcard"];
  86. [_requsetDic setValue:dic[@"TSO_STUNUM"] forKey:@"stunum"];
  87. [_requsetDic setValue:@"" forKey:@"subject"];
  88. StudentDetail * vc = [[StudentDetail alloc]init];
  89. vc.dataSource = _dataSource[indexPath.section][indexPath.row];//传入不再请求数据
  90. vc.requesetDic = _requsetDic;//方便日志,记录查询
  91. [self.navigationController pushViewController:vc animated:YES];
  92. }
  93. - (void)didReceiveMemoryWarning {
  94. [super didReceiveMemoryWarning];
  95. // Dispose of any resources that can be recreated.
  96. }
  97. @end