// // NewClassroomVC.m // LN_School // // Created by apple on 2017/12/12. // Copyright © 2017年 Danson. All rights reserved. // #import "NewClassroomVC.h" #import NSString *const classSchoolName = @"schoolName"; NSString *const className = @"trName"; NSString *const classAddress = @"trAddress"; NSString *const classStuNum = @"trStuNum"; NSString *const classArea = @"area"; NSString *const classStartTime = @"startDate"; NSString *const classEndTime = @"endDate"; NSString *const classType = @"trType"; @interface NewClassroomVC () { NSDateFormatter *_dataFormatter; } @end @implementation NewClassroomVC -(instancetype)init { self = [super init]; if (self){ [self initializeForm]; } return self; } -(void)initializeForm { XLFormDescriptor *form = [XLFormDescriptor formDescriptor];//创建表单 form = [XLFormDescriptor formDescriptorWithTitle:@"新增理论教室"]; XLFormSectionDescriptor *section = [XLFormSectionDescriptor formSectionWithTitle:@"必填项"]; //创建区 [form addFormSection:section]; //机构名 XLFormRowDescriptor *row = [XLFormRowDescriptor formRowDescriptorWithTag:classSchoolName rowType:XLFormRowDescriptorTypeInfo title:@"所属机构"]; //创建cell row.value = defUser.userDict[@"schoolName"]; [section addFormRow:row]; //教室名称 row = [XLFormRowDescriptor formRowDescriptorWithTag:className rowType:XLFormRowDescriptorTypeText title:@"教室名称"]; [row.cellConfigAtConfigure setObject:@"请输入名称" forKey:@"textField.placeholder"]; row.required = YES; [section addFormRow:row]; //教室地址 row = [XLFormRowDescriptor formRowDescriptorWithTag:classAddress rowType:XLFormRowDescriptorTypeText title:@"教室地址"]; [row.cellConfigAtConfigure setObject:@"请输入地址" forKey:@"textField.placeholder"]; row.required = YES; [section addFormRow:row]; //最大人数 row = [XLFormRowDescriptor formRowDescriptorWithTag:classStuNum rowType:XLFormRowDescriptorTypeInteger title:@"最大人数(个)"]; row.required = YES; [row.cellConfigAtConfigure setObject:@"请输入最大限制人数(个)" forKey:@"textField.placeholder"]; [row addValidator:[XLFormRegexValidator formRegexValidatorWithMsg:@"人数超出最大值" regex:@"^\\d{1,4}$"]]; [section addFormRow:row]; //教室面积(m2) row = [XLFormRowDescriptor formRowDescriptorWithTag:classArea rowType:XLFormRowDescriptorTypeInteger title:@"教室面积(m2)"]; row.required = YES; [row.cellConfigAtConfigure setObject:@"请输入面积(m2)" forKey:@"textField.placeholder"]; [row addValidator:[XLFormRegexValidator formRegexValidatorWithMsg:@"输入面积限制10个字符以内" regex:@"^\\d{1,10}$"]]; [section addFormRow:row]; // 开课时间 row = [XLFormRowDescriptor formRowDescriptorWithTag:classStartTime rowType:XLFormRowDescriptorTypeTimeInline title:@"开课时间"]; // NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"]; // [row.cellConfigAtConfigure setObject:locale forKey:@"locale"]; [row.cellConfigAtConfigure setObject:@(10) forKey:@"minuteInterval"]; _dataFormatter=[[NSDateFormatter alloc]init]; _dataFormatter.dateFormat=@"HH:mm"; row.value = [_dataFormatter dateFromString:@"08:00"]; row.required = YES; [section addFormRow:row]; //下课时间 row = [XLFormRowDescriptor formRowDescriptorWithTag:classEndTime rowType:XLFormRowDescriptorTypeTimeInline title:@"下课时间"]; // [row.cellConfigAtConfigure setObject:locale forKey:@"locale"]; [row.cellConfigAtConfigure setObject:@(10) forKey:@"minuteInterval"]; NSString *str = @"17:00"; row.value = [_dataFormatter dateFromString:str]; row.required = YES; [section addFormRow:row]; //教室类型 1 理论教室 2 模拟训练教学室 3 通用 row = [XLFormRowDescriptor formRowDescriptorWithTag:classType rowType:XLFormRowDescriptorTypeSelectorPush title:@"教室类型"]; row.required = YES;//需要下面判断 NSMutableArray *arr = [NSMutableArray array]; NSArray *titles = @[@"请选择",@"多媒体理论教室",@"模拟训练教学室",@"通用",@"教具教室"]; for (int i=0; i