123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- //
- // StuExamSearchSetVC.m
- // LN_School
- //
- // Created by EchoShacolee on 2017/6/16.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "StuExamSearchSetVC.h"
- #import "DateView.h"
- #import "StuExamsListVC.h"
- @interface StuExamSearchSetVC ()
- {
- NSInteger _baseCount; //记录基本子视图个数(判断是否已经有待选择view)
- NSMutableArray *_selectArr; //所有选择数据
- UIButton *_selectedBtn;
-
- }
- @property (weak, nonatomic) IBOutlet UIButton *startTime;//1
- @property (weak, nonatomic) IBOutlet UIButton *endTIme;
- @property (weak, nonatomic) IBOutlet UIButton *subject;
- @property (weak, nonatomic) IBOutlet UIButton *count;
- @property (weak, nonatomic) IBOutlet UIButton *score;//5
- @property (weak, nonatomic) IBOutlet UITextField *StuTf;//100
- @property (weak, nonatomic) IBOutlet UITextField *jxbhTf;//101
- @property (weak, nonatomic) IBOutlet UIButton *searchBtn;//7
- @end
- @implementation StuExamSearchSetVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"预考成绩查询";
- self.view.backgroundColor = KBackGroundColor;
- self.navigationController.navigationBar.translucent = NO;
- [self goBackByNavigation];
-
- [_startTime setTitleColor:RQMianColor forState:UIControlStateNormal];
- [_endTIme setTitleColor:RQMianColor forState:UIControlStateNormal];
- [_subject setTitleColor:RQMianColor forState:UIControlStateNormal];
- [_count setTitleColor:RQMianColor forState:UIControlStateNormal];
- [_score setTitleColor:RQMianColor forState:UIControlStateNormal];
- [_searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- _searchBtn.backgroundColor = RQMianColor;
- _searchBtn.clipsToBounds = YES;
- _searchBtn.layer.cornerRadius = 10;
-
- _baseCount = self.view.subviews.count;
- _selectArr = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@"",@""]];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (IBAction)btnClick:(id)sender {
-
- if (self.view.subviews.count > _baseCount) {
- [[self.view.subviews lastObject] removeFromSuperview];
- }
-
- UIButton *button = (UIButton *)sender;
- NSLog(@"%ld",(long)button.tag);
- switch (button.tag) {
- case 1:
- {
- [self creatDateViewWithButton:button];
- }
- break;
- case 2:
- {
- [self creatDateViewWithButton:button];
- }
- break;
- case 3:
- {
- [self creatMenuWithTitles1:@[@"科目一",@"科目四"] button:button];
- }
- break;
- case 4:
- {
- [self creatMenuWithTitles2:@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"] button:button];
- }
- break;
- case 5:
- {
- [self creatMenuWithTitles3:@[@"90",@"91",@"92",@"93",@"94",@"95",@"96",@"97",@"98",@"99",@"100"] button:button];
- }
- break;
- case 6:
- {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- break;
- case 7:
- {
- [self search];
- }
- break;
- default:
- break;
- }
- }
- -(void)creatDateViewWithButton:(UIButton *)button{
-
- if (self.view.subviews.count > _baseCount) {
- [[self.view.subviews lastObject] removeFromSuperview];
- }
-
- DateView *dateV = [[DateView alloc] init];
-
- [dateV setStyle:0];
- [dateV showWithComplete:^(NSString * result) {
- //更新UI
- [button setTitle:result forState:UIControlStateNormal];
- [_selectArr replaceObjectAtIndex:button.tag-1 withObject:result];
- }];
-
- }
- -(void)creatMenuWithTitles1:(NSArray *)titles button:(UIButton *)button{
-
- _selectedBtn = button;
- if (self.view.subviews.count > _baseCount) {
- [[self.view.subviews lastObject] removeFromSuperview];
- }
-
- NSMutableArray *titlesArr = [NSMutableArray arrayWithArray:titles];
- [titlesArr insertObject:@"全部" atIndex:0];
-
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"选择科目" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:titlesArr.copy otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex != NSNotFound) {
- [_selectedBtn setTitle:titlesArr[selectedOtherButtonIndex] forState:UIControlStateNormal];
- [_selectArr replaceObjectAtIndex:button.tag-1 withObject:@[@"",@"1",@"4"][selectedOtherButtonIndex]];
- }
- }];
- }
- -(void)creatMenuWithTitles2:(NSArray *)titles button:(UIButton *)button{
-
- _selectedBtn = button;
- if (self.view.subviews.count > _baseCount) {
- [[self.view.subviews lastObject] removeFromSuperview];
- }
-
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"连续次数" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:titles otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex != NSNotFound) {
- [_selectedBtn setTitle:[titles[selectedOtherButtonIndex] stringByAppendingString:@"次以上"] forState:UIControlStateNormal];
- [_selectArr replaceObjectAtIndex:button.tag-1 withObject:titles[selectedOtherButtonIndex]];
- }
- }];
-
- }
- -(void)creatMenuWithTitles3:(NSArray *)titles button:(UIButton *)button{
-
- _selectedBtn = button;
- if (self.view.subviews.count > _baseCount) {
- [[self.view.subviews lastObject] removeFromSuperview];
- }
-
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"学员成绩" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:titles otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex != NSNotFound) {
- if ([titles[selectedOtherButtonIndex] isEqualToString:@"100"]) {
- [_selectedBtn setTitle:[titles[selectedOtherButtonIndex] stringByAppendingString:@"分"] forState:UIControlStateNormal];
- [_selectArr replaceObjectAtIndex:button.tag-1 withObject:titles[selectedOtherButtonIndex]];
- }else{
- [_selectedBtn setTitle:[titles[selectedOtherButtonIndex] stringByAppendingString:@"分以上"] forState:UIControlStateNormal];
- [_selectArr replaceObjectAtIndex:button.tag-1 withObject:titles[selectedOtherButtonIndex]];
- }
- }
- }];
- }
- #pragma mark UITextFiled代理
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
-
- NSString *newStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
-
- [_selectArr replaceObjectAtIndex:textField.tag-100+5 withObject:newStr];
-
- return YES;
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
-
- if (self.view.subviews.count > _baseCount) {
- [[self.view.subviews lastObject] removeFromSuperview];
- return;
- }
- [self.view endEditing:YES];
- }
- -(void)search{
-
- NSMutableDictionary * mDic = [NSMutableDictionary new];
- [mDic setObject:_selectArr[0] forKey:@"startTime"];
- [mDic setObject:_selectArr[1] forKey:@"endTime"];
- [mDic setObject:_selectArr[2] forKey:@"subject"];
- [mDic setObject:_selectArr[3] forKey:@"count"];
- [mDic setObject:_selectArr[4] forKey:@"score"];
- [mDic setObject:_selectArr[5] forKey:@"idcard"];
- [mDic setObject:_selectArr[6] forKey:@"jxbh"];
-
- StuExamsListVC * vc = [[StuExamsListVC alloc]init];
- vc.requestDic = mDic;
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- /*
- #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
|