StuExamSearchSetVC.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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:RQMianColor forState:UIControlStateNormal];
  34. [_endTIme setTitleColor:RQMianColor forState:UIControlStateNormal];
  35. [_subject setTitleColor:RQMianColor forState:UIControlStateNormal];
  36. [_count setTitleColor:RQMianColor forState:UIControlStateNormal];
  37. [_score setTitleColor:RQMianColor forState:UIControlStateNormal];
  38. [_searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  39. _searchBtn.backgroundColor = RQMianColor;
  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. NSMutableArray *titlesArr = [NSMutableArray arrayWithArray:titles];
  113. [titlesArr insertObject:@"全部" atIndex:0];
  114. [RQ_SHARE_FUNCTION showAlertWithTitle:@"选择科目" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:titlesArr.copy otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
  115. if (selectedOtherButtonIndex != NSNotFound) {
  116. [_selectedBtn setTitle:titlesArr[selectedOtherButtonIndex] forState:UIControlStateNormal];
  117. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:@[@"",@"1",@"4"][selectedOtherButtonIndex]];
  118. }
  119. }];
  120. }
  121. -(void)creatMenuWithTitles2:(NSArray *)titles button:(UIButton *)button{
  122. _selectedBtn = button;
  123. if (self.view.subviews.count > _baseCount) {
  124. [[self.view.subviews lastObject] removeFromSuperview];
  125. }
  126. [RQ_SHARE_FUNCTION showAlertWithTitle:@"连续次数" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:titles otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
  127. if (selectedOtherButtonIndex != NSNotFound) {
  128. [_selectedBtn setTitle:[titles[selectedOtherButtonIndex] stringByAppendingString:@"次以上"] forState:UIControlStateNormal];
  129. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:titles[selectedOtherButtonIndex]];
  130. }
  131. }];
  132. }
  133. -(void)creatMenuWithTitles3:(NSArray *)titles button:(UIButton *)button{
  134. _selectedBtn = button;
  135. if (self.view.subviews.count > _baseCount) {
  136. [[self.view.subviews lastObject] removeFromSuperview];
  137. }
  138. [RQ_SHARE_FUNCTION showAlertWithTitle:@"学员成绩" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:titles otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
  139. if (selectedOtherButtonIndex != NSNotFound) {
  140. if ([titles[selectedOtherButtonIndex] isEqualToString:@"100"]) {
  141. [_selectedBtn setTitle:[titles[selectedOtherButtonIndex] stringByAppendingString:@"分"] forState:UIControlStateNormal];
  142. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:titles[selectedOtherButtonIndex]];
  143. }else{
  144. [_selectedBtn setTitle:[titles[selectedOtherButtonIndex] stringByAppendingString:@"分以上"] forState:UIControlStateNormal];
  145. [_selectArr replaceObjectAtIndex:button.tag-1 withObject:titles[selectedOtherButtonIndex]];
  146. }
  147. }
  148. }];
  149. }
  150. #pragma mark UITextFiled代理
  151. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  152. NSString *newStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
  153. [_selectArr replaceObjectAtIndex:textField.tag-100+5 withObject:newStr];
  154. return YES;
  155. }
  156. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  157. if (self.view.subviews.count > _baseCount) {
  158. [[self.view.subviews lastObject] removeFromSuperview];
  159. return;
  160. }
  161. [self.view endEditing:YES];
  162. }
  163. -(void)search{
  164. NSMutableDictionary * mDic = [NSMutableDictionary new];
  165. [mDic setObject:_selectArr[0] forKey:@"startTime"];
  166. [mDic setObject:_selectArr[1] forKey:@"endTime"];
  167. [mDic setObject:_selectArr[2] forKey:@"subject"];
  168. [mDic setObject:_selectArr[3] forKey:@"count"];
  169. [mDic setObject:_selectArr[4] forKey:@"score"];
  170. [mDic setObject:_selectArr[5] forKey:@"idcard"];
  171. [mDic setObject:_selectArr[6] forKey:@"jxbh"];
  172. StuExamsListVC * vc = [[StuExamsListVC alloc]init];
  173. vc.requestDic = mDic;
  174. [self.navigationController pushViewController:vc animated:YES];
  175. }
  176. /*
  177. #pragma mark - Navigation
  178. // In a storyboard-based application, you will often want to do a little preparation before navigation
  179. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  180. // Get the new view controller using [segue destinationViewController].
  181. // Pass the selected object to the new view controller.
  182. }
  183. */
  184. @end