123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- //
- // RegionsDetail.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/4/18.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "RegionsDetail.h"
- #import <BaiduMapAPI_Map/BMKMapComponent.h>
- #import "TileViewController.h"
- @interface RegionsDetail ()<BMKMapViewDelegate>
- {
- //审核button
- UIButton *_btn1;
- UIButton *_btn2;
-
- //电子围栏
- BMKMapView* _mapView;
- BMKPolygon * _polygo;
-
- HolderView *_holderV;
- NSMutableArray *_dataImgs;
- }
- @end
- @implementation RegionsDetail
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"教学区域详情";
-
- _dataImgs = [[NSMutableArray alloc]init];
-
- [self setSegmentControllWithTitles:@[@"基本信息",@"电子围栏",@"纸质图片"]];
-
- if ([[NSString stringWithFormat:@"%@",self.dataSource[@"RI_AUDIT_STATUS"]] integerValue] == 0) {
- [self createBottomBarWithtoolTitles:@[@"不通过审核",@"通过审核"]];
- }
-
- [self creatDZWL];
- [self getAreaImgs];
-
- UITableView *tableV = _tableViews[2];
- _holderV = [[HolderView alloc]initWithFrame:tableV.frame];
- [_holderV freshBlock:^{
- [self getAreaImgs];
- }];
- [_mainScroolView addSubview:_holderV];
- }
- -(void)setData{
- _keysArr = @[
- @[@"教学区域名称",@"RI_NAME"],
- @[@"教学区域类型",@"RI_TYPE"],
- @[@"教学区域地址",@"RI_ADDRESS"],
- @[@"教学区域编号",@"RI_SEQ"],
- @[@"教学区域面积(单位m2)",@"RI_AREA"],
-
- @[@"可容纳车辆",@"RI_TOTALVEHNUM"],
- @[@"已投放车辆数",@"RI_CURVEHNUM"],
-
- @[@"培训车型",@"RI_VEHICLETYPE"],
- @[@"培训机构编码",@"RI_INSCODE"],
-
- @[@"启用标识",@"RI_FLAG"],
- @[@"原因(不同意启用的原因)",@"RI_REASON"],
-
- @[@"审核状态",@"RI_AUDIT_STATUS"],
- @[@"审核操作时间",@"RI_AUDIT_TIME"],
- @[@"通知状态",@"RI_NOTIFY_STATUS"],
- @[@"通知时间",@"RI_NOTIFY_TIME"],
- @[@"备案状态",@"RI_RECORD_STATUS"],
- @[@"备案/解除备案时间",@"RI_RECORD_TIME"]
- ];
- [super setData];
- }
- #pragma mark 创建BottomBarButton
- -(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
-
- CGRect newFrame = CGRectMake(0, kNavOffSet+JOb_DETAIL_SEGBAR_HEIGHT, kSize.width, kSize.height-kNavOffSet-JOb_DETAIL_SEGBAR_HEIGHT-JOb_DETAIL_BOTTOMBAR_HEIGHT-SafeAreaBottomHeight);
- _mainScroolView.frame = newFrame;
-
- int i=0;
- for (UIView *view in _mainScroolView.subviews) {
- CGRect newFrame = CGRectMake(kSize.width*i++, 0, kSize.width, kSize.height-kNavOffSet-JOb_DETAIL_SEGBAR_HEIGHT-JOb_DETAIL_BOTTOMBAR_HEIGHT-SafeAreaBottomHeight);
- view.frame = newFrame;
- }
-
- float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
- float HeightBth = JOb_DETAIL_BOTTOMBAR_HEIGHT;
- for (int i=0; i<toolTitles.count; i++) {
- UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
- button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-SafeAreaBottomHeight, widthBtn, HeightBth);
- [button setTitle:toolTitles[i] forState:UIControlStateNormal];
- UIColor * color = COLOR_THEME;
- button.backgroundColor = color;
- [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- button.tag = 100+i;
- if (i==0) {
- _btn1 = button;
- }else if (i==1){
- _btn2 = button;
- }
-
- [self.view addSubview:button];
- }
- }
- -(void)btnClick:(UIButton *)sender{
-
- NSString *str = sender.tag == 100 ? @"确定不通过审核" : @"确定通过审核";
-
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"审核" message:str preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }]];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- if (sender.tag == 100) {
- [self auditRegionWithStatus:@"2"];
- }else if (sender.tag == 101){
- [self auditRegionWithStatus:@"1"];
- }
- }]];
- [self presentViewController:alertFind animated:true completion:nil];
-
-
- }
- #pragma mark 重写代理方法
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- if ([_tableViews indexOfObject:tableView] != 0) {
- return 1;
- }
-
- return [_keysArr count];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if ([_tableViews indexOfObject:tableView] != 0) {
- return tableView.height;
- }
- return [super tableView:tableView heightForRowAtIndexPath:indexPath];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
-
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
- }
-
- if ([_tableViews indexOfObject:tableView] == 1) {
-
- [cell.contentView addSubview:_mapView];
- return cell;
- }else if ([_tableViews indexOfObject:tableView] == 2){
-
- if (cell.contentView.subviews.count != 0) {
- [[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- TileViewController *vc = [[TileViewController alloc]initWithImageNames:_dataImgs];
- [self addChildViewController:vc];
- [cell.contentView addSubview:vc.view];
- return cell;
- }
-
-
- if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
- cell.detailTextLabel.numberOfLines = 0;
- cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
- }else{
- cell.detailTextLabel.numberOfLines = 1;
- cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
- }
-
- NSString * key = _keysArr[indexPath.row][1];
- cell.textLabel.text = _keysArr[indexPath.row][0];
- if ([key isEqualToString:@"RI_TYPE"]) {
- NSString *sex = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = [sex isEqualToString:@"1"] ? @"第二部分" : @"第三部分" ;
- }else if ([key isEqualToString:@"RI_RECORD_STATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- cell.detailTextLabel.text = [status isEqualToString:@"1"] ? @"已备案" : @"未备案" ;
- }else if ([key isEqualToString:@"RI_NOTIFY_STATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- switch ([status integerValue]) {
- case 0:
- cell.detailTextLabel.text = @"未通知";
- break;
- case 1:
- cell.detailTextLabel.text = @"已通知";
- break;
- case 2:
- cell.detailTextLabel.text = @"通知失败";
- break;
-
- default:
- break;
- }
- }else if ([key isEqualToString:@"RI_AUDIT_STATUS"]){
- NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
-
- switch ([status integerValue]) {
- case 0:
- cell.detailTextLabel.text = @"待审核";
- break;
- case 1:
- cell.detailTextLabel.text = @"审核通过";
- break;
- case 2:
- cell.detailTextLabel.text = @"审核不通过";
- break;
-
- default:
- break;
- }
- }else{
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[key]];
- }
-
- return cell;
- }
- #pragma mark 电子围栏相关
- -(void)creatDZWL{
-
- _mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0, kSize.width,kSize.height-kNavOffSet)];
- //设置地图缩放级别
- [_mapView setZoomLevel:16];
- _mapView.mapType = BMKMapTypeStandard;
- _mapView.delegate = self;
-
- NSString * str = self.dataSource[@"RI_POLYGON"];
- NSArray * arr = [str componentsSeparatedByString:@";"];
-
- NSInteger k = arr.count-1;//最后一个为空
- CLLocationCoordinate2D * coords = malloc(k*sizeof(CLLocationCoordinate2D));
- for (int i = 0; i < k; i++) {
- NSArray * locationArr = [arr[i] componentsSeparatedByString:@","];
- coords[i].latitude = [locationArr[1] floatValue];
- coords[i].longitude = [locationArr[0] floatValue];
- if (i==1) {
- _mapView.centerCoordinate = coords[i];
- }
- }
- _polygo = [BMKPolygon polygonWithCoordinates:coords count:k];
- [_mapView addOverlay:_polygo];
- }
- //根据overlay生成对应的View
- - (BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id <BMKOverlay>)overlay{
- BMKPolygonView* polygonView = [[BMKPolygonView alloc] initWithOverlay:overlay];
- polygonView.strokeColor = [[UIColor alloc] initWithRed:0.0 green:0 blue:0.5 alpha:1];
- polygonView.fillColor = [[UIColor alloc] initWithRed:0 green:1 blue:1 alpha:0.2];
- polygonView.lineWidth =2.0;
- polygonView.lineDash = (overlay == _polygo);
- return polygonView;
- }
- -(void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [_mapView viewWillAppear];
- _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放
- }
- -(void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [_mapView viewWillDisappear];
- _mapView.delegate = nil; // 不用时,置nil
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- if (scrollView.contentOffset.x >= kSize.width) {
- _mainScroolView.scrollEnabled = NO;
- UITableView * v = _tableViews[1];
- v.scrollEnabled = NO;
- }
- else {
- _mainScroolView.scrollEnabled = YES;
- }
- }
- #pragma mark 网络请求
- -(void)auditRegionWithStatus:(NSString *)status{
-
- NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
- [mDic setObject:self.dataSource[@"RI_ID"] forKey:@"id"];
- [mDic setObject:status forKey:@"status"];
- [self getDataWithDic:mDic method:@"auditRegion" block:^(NSDictionary *successDic) {
- [self showMsgByMBWithString:@"审核成功!"];
- //审核完移除审核按钮
- // [_btn1 removeFromSuperview];
- // [_btn2 removeFromSuperview];
- //刷新待审核list
- if (self.block) {
- self.block();
- }
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- -(void)getAreaImgs{
-
- //判断网络是否连接
- if (![NetworkManager connectedToNetWork]) {
- [self showMsgByAlertVCWithString:@"网络连接异常"];
- return;
- }
-
- NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
- [mDic setObject:self.dataSource[@"RI_INSCODE"] forKey:@"inscode"];
- [mDic setObject:self.dataSource[@"RI_SEQ"] forKey:@"seq"];
-
- [MBProgressHUD hideHUDForView:self.view animated:NO];
- [MBProgressHUD showHUDAddedTo:self.view animated:NO];
- [NetworkManager requestWithMethod:@"getSchoolRegionImg" parameters:mDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
-
- _holderV.hidden = NO;
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- if (failureStr) {
- [self showMsgByAlertVCWithString:failureStr];
- return;
- }
-
- if ([successDic[@"code"] isEqualToString:@"1"]) {
- [self showMsgByAlertVCWithString:successDic[@"msg"]];
- return;
- }
-
- [_dataImgs removeAllObjects];
- _dataImgs = successDic[@"body"];
-
- if (_dataImgs.count > 0) {
- _holderV.hidden = YES;
- }
-
- [_tableViews[2] reloadData];
-
- }];
-
-
- }
- @end
|