// // 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.view.backgroundColor = [UIColor whiteColor]; self.navigationItem.title = @"教学区域列表"; self.navigationController.navigationBar.translucent = NO; [self goBackByNavigation]; _status = @""; _dataSurce = [NSMutableArray new]; _requsetDic = [NSMutableDictionary new]; [self myInit]; [self getData]; [Tools permissionValidationWithID:@"47" view:self.view result:^(BOOL isCan, NSString *failureStr) { if (isCan) { [self customRightBtn]; } }]; } -(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:defGreen 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]; } -(void)setMengbanView{ if (_mengBanView) { [_mengBanView showView]; return; } NSArray * btnarr = @[@"待审核",@"审核通过",@"审核不通过"]; NSArray * buttonsArray = @[btnarr]; _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:YES block:^(NSArray *array) { if ([array[0] isEqualToString:@"待审核"]) { _status = @"0"; }else if ([array[0] isEqualToString:@"审核通过"]){ _status = @"1"; }else if ([array[0] isEqualToString:@"审核不通过"]){ _status = @"2"; } [self getData]; }]; [_mengBanView showView]; } #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; [MBProgressHUD showLoadToView:self.view]; [NetManager requestAnythingWithURL:@"getAreas" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) { [MBProgressHUD hideHUDForView:self.view]; 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