StuExamSearchSetVC.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. //
  2. // StuExamSearchSetVC.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/6/16.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "StuExamSearchSetVC.h"
  9. #import "DateView.h"
  10. #import "StuExamsListVC.h"
  11. @interface StuExamSearchSetVC ()
  12. {
  13. NSInteger _baseCount; //记录基本子视图个数(判断是否已经有待选择view)
  14. NSMutableArray *_selectArr; //所有选择数据
  15. UIButton *_selectedBtn;
  16. }
  17. @property (weak, nonatomic) IBOutlet UIButton *startTime;//1
  18. @property (weak, nonatomic) IBOutlet UIButton *endTIme;
  19. @property (weak, nonatomic) IBOutlet UIButton *subject;
  20. @property (weak, nonatomic) IBOutlet UIButton *count;
  21. @property (weak, nonatomic) IBOutlet UIButton *score;//5
  22. @property (weak, nonatomic) IBOutlet UITextField *StuTf;//100
  23. @property (weak, nonatomic) IBOutlet UITextField *jxbhTf;//101
  24. @property (weak, nonatomic) IBOutlet UIButton *searchBtn;//7
  25. @end
  26. @implementation StuExamSearchSetVC
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.navigationItem.title = @"预考成绩查询";
  30. self.view.backgroundColor = KBackGroundColor;
  31. self.navigationController.navigationBar.translucent = NO;
  32. [self goBackByNavigation];
  33. [_startTime setTitleColor:defGreen forState:UIControlStateNormal];
  34. [_endTIme setTitleColor:defGreen forState:UIControlStateNormal];
  35. [_subject setTitleColor:defGreen forState:UIControlStateNormal];
  36. [_count setTitleColor:defGreen forState:UIControlStateNormal];
  37. [_score setTitleColor:defGreen forState:UIControlStateNormal];
  38. [_searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  39. _searchBtn.backgroundColor = defGreen;
  40. _searchBtn.clipsToBounds = YES;
  41. _searchBtn.layer.cornerRadius = 10;
  42. _baseCount = self.view.subviews.count;
  43. _selectArr = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@"",@""]];
  44. }
  45. - (void)didReceiveMemoryWarning {
  46. [super didReceiveMemoryWarning];
  47. // Dispose of any resources that can be recreated.
  48. }
  49. - (IBAction)btnClick:(id)sender {
  50. if (self.view.subviews.count > _baseCount) {
  51. [[self.view.subviews lastObject] removeFromSuperview];
  52. }
  53. UIButton *button = (UIButton *)sender;
  54. NSLog(@"%ld",(long)button.tag);
  55. switch (button.tag) {
  56. case 1:
  57. {
  58. [self creatDateViewWithButton:button];
  59. }
  60. break;
  61. case 2:
  62. {
  63. [self creatDateViewWithButton:button];
  64. }
  65. break;
  66. case 3:
  67. {
  68. [self creatMenuWithTitles1:@[@"科目一",@"科目四"] button:button];
  69. }
  70. break;
  71. case 4:
  72. {
  73. [self creatMenuWithTitles2:@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"] button:button];
  74. }
  75. break;
  76. case 5:
  77. {
  78. [self creatMenuWithTitles3:@[@"90",@"91",@"92",@"93",@"94",@"95",@"96",@"97",@"98",@"99",@"100"] button:button];
  79. }
  80. break;
  81. case 6:
  82. {
  83. [self dismissViewControllerAnimated:YES completion:nil];
  84. }
  85. break;
  86. case 7:
  87. {
  88. [self search];
  89. }
  90. break;
  91. default:
  92. break;
  93. }
  94. }
  95. -(void)creatDateViewWithButton:(UIButton *)button{
  96. if (self.view.subviews.count > _baseCount) {
  97. [[self.view.subviews lastObject] removeFromSuperview];
  98. }
  99. DateView *dateV = [[DateView alloc] init];
  100. [dateV setStyle:0];
  101. [dateV showWithComplete:^(NSString * result) {
  102. //更新UI
  103. [button setTitle:result forState:UIControlStateNormal];
  104. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:result];
  105. }];
  106. }
  107. -(void)creatMenuWithTitles1:(NSArray *)titles button:(UIButton *)button{
  108. _selectedBtn = button;
  109. if (self.view.subviews.count > _baseCount) {
  110. [[self.view.subviews lastObject] removeFromSuperview];
  111. }
  112. UIAlertController *ac = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  113. //添加操作
  114. [ac addAction:[UIAlertAction actionWithTitle:@"全部" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  115. [_selectedBtn setTitle:@"全部" forState:UIControlStateNormal];
  116. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:@""];
  117. }]];
  118. for (NSString *str in titles) {
  119. [ac addAction:[UIAlertAction actionWithTitle:str style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  120. [_selectedBtn setTitle:str forState:UIControlStateNormal];
  121. NSString *newStr = [str isEqualToString:@"科目一"] ? @"1" : @"4";
  122. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:newStr];
  123. }]];
  124. }
  125. [self presentViewController:ac animated:YES completion:nil];
  126. }
  127. -(void)creatMenuWithTitles2:(NSArray *)titles button:(UIButton *)button{
  128. _selectedBtn = button;
  129. if (self.view.subviews.count > _baseCount) {
  130. [[self.view.subviews lastObject] removeFromSuperview];
  131. }
  132. UIAlertController *ac = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  133. //添加操作
  134. for (NSString *str in titles) {
  135. [ac addAction:[UIAlertAction actionWithTitle:str style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  136. [_selectedBtn setTitle:[str stringByAppendingString:@"次以上"] forState:UIControlStateNormal];
  137. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:str];
  138. }]];
  139. }
  140. [self presentViewController:ac animated:YES completion:nil];
  141. }
  142. -(void)creatMenuWithTitles3:(NSArray *)titles button:(UIButton *)button{
  143. _selectedBtn = button;
  144. if (self.view.subviews.count > _baseCount) {
  145. [[self.view.subviews lastObject] removeFromSuperview];
  146. }
  147. UIAlertController *ac = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  148. //添加操作
  149. for (NSString *str in titles) {
  150. if ([str isEqualToString:@"100"]) {
  151. [ac addAction:[UIAlertAction actionWithTitle:str style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  152. [_selectedBtn setTitle:[str stringByAppendingString:@"分"] forState:UIControlStateNormal];
  153. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:str];
  154. }]];
  155. }else{
  156. [ac addAction:[UIAlertAction actionWithTitle:str style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  157. [_selectedBtn setTitle:[str stringByAppendingString:@"分以上"] forState:UIControlStateNormal];
  158. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:str];
  159. }]];
  160. }
  161. }
  162. [self presentViewController:ac animated:YES completion:nil];
  163. }
  164. #pragma mark UITextFiled代理
  165. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  166. NSString *newStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
  167. [_selectArr replaceObjectAtIndex:textField.tag-100+5 withObject:newStr];
  168. return YES;
  169. }
  170. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  171. if (self.view.subviews.count > _baseCount) {
  172. [[self.view.subviews lastObject] removeFromSuperview];
  173. return;
  174. }
  175. [self.view endEditing:YES];
  176. }
  177. -(void)search{
  178. NSMutableDictionary * mDic = [NSMutableDictionary new];
  179. [mDic setObject:_selectArr[0] forKey:@"startTime"];
  180. [mDic setObject:_selectArr[1] forKey:@"endTime"];
  181. [mDic setObject:_selectArr[2] forKey:@"subject"];
  182. [mDic setObject:_selectArr[3] forKey:@"count"];
  183. [mDic setObject:_selectArr[4] forKey:@"score"];
  184. [mDic setObject:_selectArr[5] forKey:@"idcard"];
  185. [mDic setObject:_selectArr[6] forKey:@"jxbh"];
  186. StuExamsListVC * vc = [[StuExamsListVC alloc]init];
  187. vc.requestDic = mDic;
  188. [self.navigationController pushViewController:vc animated:YES];
  189. }
  190. /*
  191. #pragma mark - Navigation
  192. // In a storyboard-based application, you will often want to do a little preparation before navigation
  193. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  194. // Get the new view controller using [segue destinationViewController].
  195. // Pass the selected object to the new view controller.
  196. }
  197. */
  198. @end