RegionsList.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // RegionsList.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/18.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "RegionsList.h"
  9. #import "RegionsCell.h"
  10. #import "RegionsDetail.h"
  11. #import "MengBanView.h"
  12. #import "CollectRegionsInfoVC.h"
  13. @interface RegionsList ()<UITableViewDelegate,UITableViewDataSource>
  14. {
  15. MengBanView * _mengBanView;
  16. UIButton * _statusBtn;
  17. NSMutableDictionary * _requsetDic;
  18. NSString * _status;
  19. UITableView * _tableView;
  20. NSMutableArray *_dataSurce;
  21. HolderView * holderV;
  22. }
  23. @end
  24. @implementation RegionsList
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.navigationItem.title = @"教学区域列表";
  28. self.navigationController.navigationBar.translucent = NO;
  29. //RQ-MARK 1.0.3 新增:“电子围栏”模块新增“采集围栏”功能
  30. [self customRightBtn];
  31. [self goBackByNavigation];
  32. _status = @"";
  33. _dataSurce = [NSMutableArray new];
  34. _requsetDic = [NSMutableDictionary new];
  35. [self myInit];
  36. [self getData];
  37. }
  38. -(void)myInit{
  39. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)];
  40. _tableView.dataSource = self;
  41. _tableView.delegate = self;
  42. _tableView.tableFooterView = [UIView new];
  43. [self.view addSubview:_tableView];
  44. holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
  45. [holderV freshBlock:^{
  46. [self getData];
  47. }];
  48. [self.view addSubview:holderV];
  49. }
  50. -(void)customRightBtn{
  51. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  52. btn.frame = CGRectMake(0, 0, 80, 44);
  53. btn.titleLabel.font = [UIFont systemFontOfSize:17];
  54. [btn setTitle:@"采集围栏" forState:UIControlStateNormal];
  55. [btn setTitleColor:RQMianColor forState:UIControlStateNormal];
  56. [btn addTarget:self action:@selector(collectRegions) forControlEvents:UIControlEventTouchUpInside];
  57. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  58. }
  59. - (void)collectRegions {
  60. // if (!myDelegate.isSchool) {
  61. // ShowMsg(@"驾校管理员才可以进行此操作!");
  62. // return;
  63. // }
  64. CollectRegionsInfoVC *vc = [[CollectRegionsInfoVC alloc] init];
  65. [self.navigationController pushViewController:vc animated:YES];
  66. }
  67. #pragma mark tableview代理方法
  68. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  69. return _dataSurce.count;
  70. }
  71. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  72. return 75;
  73. }
  74. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath{
  75. RegionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  76. if (!cell) {
  77. cell = [[[NSBundle mainBundle] loadNibNamed:@"RegionsCell" owner:nil options:nil]lastObject];
  78. }
  79. [cell upDataWithDic:_dataSurce[indexPath.row]];
  80. return cell;
  81. }
  82. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  83. RegionsDetail * vc = [[RegionsDetail alloc]init];
  84. [_requsetDic setValue:_dataSurce[indexPath.row][@"TCO_CARNUM"] forKey:@"idcard"];
  85. vc.requesetDic = _requsetDic;
  86. vc.dataSource = _dataSurce[indexPath.row];
  87. [self.navigationController pushViewController:vc animated:YES];
  88. }
  89. #pragma mark 数据请求
  90. - (void)getData{
  91. //判断网络是否连接
  92. if (![NetManager connectedToNetWork]) {
  93. showMsgUnconnect();
  94. return;
  95. }
  96. NSMutableDictionary * mdic = [NSMutableDictionary new];
  97. [mdic setValue:defUser.userDict[@"school"] forKey:@"jxbh"];
  98. _requsetDic = mdic;
  99. [NetManager requestAnythingWithURL:@"getAreas" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
  100. holderV.hidden = NO;
  101. if (!root) {
  102. ShowMsg(@"数据请求失败,请重试");
  103. return;
  104. }
  105. if ([root[@"code"] integerValue] == 1) {
  106. ShowMsg(root[@"msg"]);
  107. return;
  108. }
  109. _dataSurce = root[@"body"];
  110. if (_dataSurce.count > 0) {
  111. holderV.hidden = YES;
  112. }
  113. [_tableView reloadData];
  114. }];
  115. }
  116. - (void)didReceiveMemoryWarning {
  117. [super didReceiveMemoryWarning];
  118. // Dispose of any resources that can be recreated.
  119. }
  120. /*
  121. #pragma mark - Navigation
  122. // In a storyboard-based application, you will often want to do a little preparation before navigation
  123. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  124. // Get the new view controller using [segue destinationViewController].
  125. // Pass the selected object to the new view controller.
  126. }
  127. */
  128. @end