RegionsList.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.view.backgroundColor = [UIColor whiteColor];
  28. self.navigationItem.title = @"教学区域列表";
  29. self.navigationController.navigationBar.translucent = NO;
  30. [self goBackByNavigation];
  31. _status = @"";
  32. _dataSurce = [NSMutableArray new];
  33. _requsetDic = [NSMutableDictionary new];
  34. [self myInit];
  35. [self getData];
  36. [Tools permissionValidationWithID:@"47" view:self.view result:^(BOOL isCan, NSString *failureStr) {
  37. if (isCan) {
  38. [self customRightBtn];
  39. }
  40. }];
  41. }
  42. -(void)myInit{
  43. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)];
  44. _tableView.dataSource = self;
  45. _tableView.delegate = self;
  46. _tableView.tableFooterView = [UIView new];
  47. [self.view addSubview:_tableView];
  48. holderV = [[HolderView alloc]initWithFrame:_tableView.frame];
  49. [holderV freshBlock:^{
  50. [self getData];
  51. }];
  52. [self.view addSubview:holderV];
  53. }
  54. -(void)customRightBtn{
  55. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  56. btn.frame = CGRectMake(0, 0, 80, 44);
  57. btn.titleLabel.font = [UIFont systemFontOfSize:17];
  58. [btn setTitle:@"采集围栏" forState:UIControlStateNormal];
  59. [btn setTitleColor:defGreen forState:UIControlStateNormal];
  60. [btn addTarget:self action:@selector(collectRegions) forControlEvents:UIControlEventTouchUpInside];
  61. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  62. }
  63. - (void)collectRegions {
  64. // if (!myDelegate.isSchool) {
  65. // ShowMsg(@"驾校管理员才可以进行此操作!");
  66. // return;
  67. // }
  68. CollectRegionsInfoVC *vc = [[CollectRegionsInfoVC alloc] init];
  69. [self.navigationController pushViewController:vc animated:YES];
  70. }
  71. -(void)setMengbanView{
  72. if (_mengBanView) {
  73. [_mengBanView showView];
  74. return;
  75. }
  76. NSArray * btnarr = @[@"待审核",@"审核通过",@"审核不通过"];
  77. NSArray * buttonsArray = @[btnarr];
  78. _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:YES block:^(NSArray *array) {
  79. if ([array[0] isEqualToString:@"待审核"]) {
  80. _status = @"0";
  81. }else if ([array[0] isEqualToString:@"审核通过"]){
  82. _status = @"1";
  83. }else if ([array[0] isEqualToString:@"审核不通过"]){
  84. _status = @"2";
  85. }
  86. [self getData];
  87. }];
  88. [_mengBanView showView];
  89. }
  90. #pragma mark tableview代理方法
  91. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  92. return _dataSurce.count;
  93. }
  94. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  95. return 75;
  96. }
  97. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath{
  98. RegionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  99. if (!cell) {
  100. cell = [[[NSBundle mainBundle] loadNibNamed:@"RegionsCell" owner:nil options:nil]lastObject];
  101. }
  102. [cell upDataWithDic:_dataSurce[indexPath.row]];
  103. return cell;
  104. }
  105. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  106. RegionsDetail * vc = [[RegionsDetail alloc]init];
  107. [_requsetDic setValue:_dataSurce[indexPath.row][@"TCO_CARNUM"] forKey:@"idcard"];
  108. vc.requesetDic = _requsetDic;
  109. vc.dataSource = _dataSurce[indexPath.row];
  110. [self.navigationController pushViewController:vc animated:YES];
  111. }
  112. #pragma mark 数据请求
  113. - (void)getData{
  114. //判断网络是否连接
  115. if (![NetManager connectedToNetWork]) {
  116. showMsgUnconnect();
  117. return;
  118. }
  119. NSMutableDictionary * mdic = [NSMutableDictionary new];
  120. [mdic setValue:defUser.userDict[@"school"] forKey:@"jxbh"];
  121. _requsetDic = mdic;
  122. [MBProgressHUD showLoadToView:self.view];
  123. [NetManager requestAnythingWithURL:@"getAreas" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
  124. [MBProgressHUD hideHUDForView:self.view];
  125. holderV.hidden = NO;
  126. if (!root) {
  127. ShowMsg(@"数据请求失败,请重试");
  128. return;
  129. }
  130. if ([root[@"code"] integerValue] == 1) {
  131. ShowMsg(root[@"msg"]);
  132. return;
  133. }
  134. _dataSurce = root[@"body"];
  135. if (_dataSurce.count > 0) {
  136. holderV.hidden = YES;
  137. }
  138. [_tableView reloadData];
  139. }];
  140. }
  141. - (void)didReceiveMemoryWarning {
  142. [super didReceiveMemoryWarning];
  143. // Dispose of any resources that can be recreated.
  144. }
  145. /*
  146. #pragma mark - Navigation
  147. // In a storyboard-based application, you will often want to do a little preparation before navigation
  148. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  149. // Get the new view controller using [segue destinationViewController].
  150. // Pass the selected object to the new view controller.
  151. }
  152. */
  153. @end