123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- {
- 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
|