123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- //
- // CollectRegionsInfoVC.m
- // LN_School
- //
- // Created by apple on 2017/12/8.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "CollectRegionsInfoVC.h"
- #import "CollectRegionsVC.h"
- @interface CollectRegionsInfoVC ()<UIScrollViewDelegate>
- {
- NSMutableArray *fieldArray;
- NSMutableArray *selectCarType;
- NSArray *carTypeArray;
- }
- @end
- @implementation CollectRegionsInfoVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"围栏信息采集";
- self.view.backgroundColor = [UIColor whiteColor];
- self.navigationController.navigationBar.translucent = NO;
- [self goBackByNavigation];
-
-
- fieldArray = [NSMutableArray array];
- selectCarType = [NSMutableArray array];
- carTypeArray = @[@"A1",@"A2",@"A3",@"B1",@"B2",@"C1",@"C2",@"C3",@"C4",@"C5",@"D",@"E",@"F",@"M",@"N",@"p"];
-
- UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:kFrame];
- scrollView.delegate = self;
- [self.view addSubview:scrollView];
-
- CGFloat y = 20;
- CGFloat h = 40;
- NSArray *titleArray = @[@"场地名称:",@"场地面积(㎡):",@"可容纳车辆:",@"已投放车辆:",];
- for (int i = 0; i < titleArray.count; i ++) {
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, y + i*h + 4, 100, h - 5)];
- [label setText:titleArray[i] Font:Font17 TextColor:KTitleColor];
- [scrollView addSubview:label];
-
- [label addViewWithRect:CGRectMake(15, y + i*h + h - 1, kSize.width - 30, 1)];
-
- UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(120, y + i*h + 4, kSize.width - 130, h - 5)];
- tf.borderStyle = UITextBorderStyleNone;
- tf.textAlignment = NSTextAlignmentCenter;
- if (i != 0) {
- tf.keyboardType = UIKeyboardTypeNumberPad;
- }
- [scrollView addSubview:tf];
- [fieldArray addObject:tf];
- }
-
-
- y += titleArray.count*h + 10;
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, y, kSize.width - 40, 30)];
- [label setText:@"培训车型:" Font:Font17 TextColor:KTitleColor];
- [scrollView addSubview:label];
-
- y += 30;
- NSInteger wid = kSize.width;
- NSInteger num = wid/40;
- if (wid%40 < 15) {
- num -= 1;
- }
- CGFloat x = (kSize.width - 40*num + 5)/2.0;
-
- for (int i = 0; i < carTypeArray.count; i ++) {
- int row = i/num;
- int column = i%num;
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(x + column*40, y + row*40, 35, 35)];
- [btn setTitle:carTypeArray[i] textColor:KTitleColor font:Font17 fotState:UIControlStateNormal];
- btn.backgroundColor = [UIColor whiteColor];
- [btn borderColor:kLineColor width:1 cornorRadios:3];
- [btn target:self Tag:i + 1];
- [scrollView addSubview:btn];
- }
-
-
- y += (carTypeArray.count/num + 1) * 40 + 10;
- titleArray = @[@"场地地址:",@"备注:"];
- for (int i = 0; i < titleArray.count; i ++) {
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, y + i*h + 4, 100, h - 5)];
- [label setText:titleArray[i] Font:Font17 TextColor:KTitleColor];
- [scrollView addSubview:label];
-
- [label addViewWithRect:CGRectMake(15, y + i*h + h - 1, kSize.width - 30, 1)];
-
- UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(120, y + i*h + 4, kSize.width - 130, h - 5)];
- tf.borderStyle = UITextBorderStyleNone;
- tf.textAlignment = NSTextAlignmentCenter;
- [scrollView addSubview:tf];
- [fieldArray addObject:tf];
- }
-
-
- y += titleArray.count*h + 30;
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(20, y, kSize.width - 40, 40)];
- [btn setTitle:@"下一步" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
- btn.backgroundColor = RQMianColor;
- [btn borderCornorRadios:5];
- [btn target:self Tag:20];
- [scrollView addSubview:btn];
-
- [scrollView setContentSize:CGSizeMake(kSize.width, y + 40 + 240 + 100 + kSafeAreaBottomHeight)];
- }
- - (void)btnClick:(UIButton *)sender {
-
- [self.view endEditing:YES];
- UIButton *btn = (UIButton *)sender;
-
- if (btn.tag == 20) {//跳转至采集围栏
-
-
- for (int i = 0; i < fieldArray.count - 1; i ++) {
- UITextField *tf = fieldArray[i];
- if (tf.text.length < 1) {
- ShowMsg(@"请输入完整信息!");
- return;
- }
- }
-
- if (selectCarType.count < 1) {
- ShowMsg(@"请选择培训车型!");
- return;
- }
-
- //封装围栏信息
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- NSArray *keyArray = @[@"name",@"area",@"totalvehnum",@"curvehnum",@"address",@"remark"];
- for (int i = 0; i < fieldArray.count; i++) {
- UITextField *tf = fieldArray[i];
- [dic setObject:tf.text forKey:keyArray[i]];
- }
-
- NSString *allCarType = @"";
- for (NSString *carType in selectCarType) {
- allCarType = [allCarType stringByAppendingString:[NSString stringWithFormat:@"%@,",carType]];
- }
- if (allCarType.length > 0) {
- allCarType = [allCarType substringToIndex:allCarType.length - 1];
- }
- [dic setObject:allCarType forKey:@"vehicletype"];
-
- NSLog(@"-------->>>>%@",dic);
-
- CollectRegionsVC *vc = [[CollectRegionsVC alloc] init];
- vc.infoDic = dic;
- [self.navigationController pushViewController:vc animated:YES];
- return;
- }
-
-
- //选择车型
- NSString *carType = carTypeArray[btn.tag-1];
- if ([selectCarType containsObject:carType]) {
- //删除车型
- [selectCarType removeObject:carType];
- [btn setTitleColor:KTitleColor forState:UIControlStateNormal];
- btn.backgroundColor = [UIColor whiteColor];
- }else {
- //增加车型
- [selectCarType addObject:carType];
- [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- btn.backgroundColor = RQMianColor;
- }
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView {
- [self.view endEditing:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|