// // RegionsList.m // LNManager // // Created by EchoShacolee on 2017/4/18. // Copyright © 2017年 lee. All rights reserved. // #import "RegionsList.h" #import "RegionsCell.h" #import "RegionsDetail.h" #import "MengBanView.h" #import "CollectRegionsInfoVC.h" @interface RegionsList () { MengBanView * _mengBanView; UIButton * _statusBtn; NSMutableDictionary * _requsetDic; NSString * _status; UITableView * _tableView; NSMutableArray *_dataSurce; HolderView * holderV; } @end @implementation RegionsList - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"教学区域列表"; self.navigationController.navigationBar.translucent = NO; //RQ-MARK 1.0.3 新增:“电子围栏”模块新增“采集围栏”功能 [self customRightBtn]; [self goBackByNavigation]; _status = @""; _dataSurce = [NSMutableArray new]; _requsetDic = [NSMutableDictionary new]; [self myInit]; [self getData]; } -(void)myInit{ _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)]; _tableView.dataSource = self; _tableView.delegate = self; _tableView.tableFooterView = [UIView new]; [self.view addSubview:_tableView]; holderV = [[HolderView alloc]initWithFrame:_tableView.frame]; [holderV freshBlock:^{ [self getData]; }]; [self.view addSubview:holderV]; } -(void)customRightBtn{ UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem]; btn.frame = CGRectMake(0, 0, 80, 44); btn.titleLabel.font = [UIFont systemFontOfSize:17]; [btn setTitle:@"采集围栏" forState:UIControlStateNormal]; [btn setTitleColor:RQMianColor forState:UIControlStateNormal]; [btn addTarget:self action:@selector(collectRegions) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn]; } - (void)collectRegions { // if (!myDelegate.isSchool) { // ShowMsg(@"驾校管理员才可以进行此操作!"); // return; // } CollectRegionsInfoVC *vc = [[CollectRegionsInfoVC alloc] init]; [self.navigationController pushViewController:vc animated:YES]; } #pragma mark tableview代理方法 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _dataSurce.count; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 75; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath{ RegionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"]; if (!cell) { cell = [[[NSBundle mainBundle] loadNibNamed:@"RegionsCell" owner:nil options:nil]lastObject]; } [cell upDataWithDic:_dataSurce[indexPath.row]]; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ RegionsDetail * vc = [[RegionsDetail alloc]init]; [_requsetDic setValue:_dataSurce[indexPath.row][@"TCO_CARNUM"] forKey:@"idcard"]; vc.requesetDic = _requsetDic; vc.dataSource = _dataSurce[indexPath.row]; [self.navigationController pushViewController:vc animated:YES]; } #pragma mark 数据请求 - (void)getData{ //判断网络是否连接 if (![NetManager connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableDictionary * mdic = [NSMutableDictionary new]; [mdic setValue:defUser.userDict[@"school"] forKey:@"jxbh"]; _requsetDic = mdic; [NetManager requestAnythingWithURL:@"getAreas" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) { holderV.hidden = NO; if (!root) { ShowMsg(@"数据请求失败,请重试"); return; } if ([root[@"code"] integerValue] == 1) { ShowMsg(root[@"msg"]); return; } _dataSurce = root[@"body"]; if (_dataSurce.count > 0) { holderV.hidden = YES; } [_tableView reloadData]; }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end