SafeList.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // SafeList.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/9.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "SafeList.h"
  9. #import "SafeDetail.h"
  10. @interface SafeList ()
  11. @end
  12. @implementation SafeList
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.navigationItem.title = @"安全员列表";
  16. [self getData];
  17. __weak typeof(self) weakSelf = self;
  18. self.holdervBlock = ^{
  19. [weakSelf getData];
  20. };
  21. }
  22. -(void)getData{
  23. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  24. [mDic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"];
  25. [mDic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"];
  26. [mDic setValue:defUser.userDict[@"school"] forKey:@"schoolId"];
  27. [mDic setValue:@"" forKey:@"name"];
  28. [mDic setValue:@"" forKey:@"idcard"];
  29. [mDic setValue:@"" forKey:@"mobile"];
  30. [self getDataWithDic:mDic method:@"securityguards" block:^(NSDictionary *successdic) {
  31. NSArray * arr = successdic[@"body"];
  32. if (arr.count != 0) {
  33. self.holderV.hidden = YES;
  34. }
  35. for (NSDictionary * dic in arr) {
  36. if (![self.sectionTitles containsObject:dic[@"ZM"]]) {
  37. [self.sectionTitles addObject:dic[@"ZM"]];
  38. [self.dataSource addObject:[NSMutableArray new]];
  39. }
  40. }
  41. //排序
  42. [self.sectionTitles sortUsingSelector:@selector(compare:)];
  43. for (NSDictionary * dic in arr) {
  44. NSInteger location = [self.sectionTitles indexOfObject:dic[@"ZM"]];
  45. [self.dataSource[location] addObject:dic];
  46. }
  47. [self.tableView reloadData];
  48. }];
  49. }
  50. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  51. {
  52. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath];
  53. if ([self.dataSource[indexPath.section] count] > 0) {
  54. cell.textLabel.text = self.dataSource[indexPath.section][indexPath.row][@"SI_NAME"];
  55. }
  56. return cell;
  57. }
  58. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  59. SafeDetail * vc = [[SafeDetail alloc]init];
  60. vc.dataSource = self.dataSource[indexPath.section][indexPath.row];
  61. [self navPushHideTabbarToVC:vc];
  62. }
  63. - (void)didReceiveMemoryWarning {
  64. [super didReceiveMemoryWarning];
  65. // Dispose of any resources that can be recreated.
  66. }
  67. /*
  68. #pragma mark - Navigation
  69. // In a storyboard-based application, you will often want to do a little preparation before navigation
  70. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  71. // Get the new view controller using [segue destinationViewController].
  72. // Pass the selected object to the new view controller.
  73. }
  74. */
  75. @end