StuRecordVC.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. //
  2. // StuRecordVC.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/8/30.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "StuRecordVC.h"
  9. #import "HolderView.h"
  10. #import "DateView.h"
  11. #import "MyGradeVC.h"
  12. @interface StuRecordVC ()<UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate,UIPickerViewDataSource,UIPickerViewDelegate,UISearchResultsUpdating,UITextFieldDelegate>
  13. {
  14. UITableView *_contactTable;
  15. HolderView *holderV;
  16. UIBarButtonItem *item;
  17. UIView *backView;
  18. UITextField *idcardTF,*jxbhTF;
  19. UIButton *scoreBtn,*countBtn,*beginDateBtn,*endDateBtn,*kemuBtn;
  20. UIPickerView *picker;
  21. UIView *bgView;
  22. //搜索条件
  23. NSArray *pickDataArray;
  24. NSInteger whichPicker;
  25. NSString *scoreString;
  26. NSString *countString;
  27. NSString *beginDate;
  28. NSString *endDate;
  29. NSString *kemuString;
  30. NSString *idcardString;
  31. NSString *jxbhString;
  32. //添加索引加的参数
  33. UISearchController *_searchController;
  34. NSMutableArray *_tableSourceArray;
  35. NSMutableArray *_letterArray;
  36. NSMutableArray *_resultArray;
  37. NSMutableArray *models;
  38. NSMutableDictionary *groupDic;
  39. }
  40. @end
  41. @implementation StuRecordVC
  42. - (void)viewDidLoad {
  43. [super viewDidLoad];
  44. self.title = @"学员预考成绩";
  45. //self.view.backgroundColor = backGroundColor;
  46. //[self configNavBar];
  47. _tableSourceArray = [[NSMutableArray alloc] init];
  48. _letterArray = [[NSMutableArray alloc] init];
  49. _resultArray = [[NSMutableArray alloc] init];
  50. groupDic = [[NSMutableDictionary alloc] init];
  51. models = [[NSMutableArray alloc] init];
  52. pickDataArray = @[@[@"90",@"91",@"92",@"93",@"94",@"95",@"96",@"97",@"98",@"99",@"100"],@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"]];
  53. scoreString = @"90";
  54. countString = @"1";
  55. beginDate = @"";
  56. endDate = @"";
  57. kemuString = @"1";//科一和科四
  58. idcardString = @"";
  59. jxbhString = @"";
  60. //获取26个大写字母
  61. for (int i = 65; i < 91; i ++)
  62. {
  63. NSString * letter = [[NSString alloc] initWithBytes:&i length:1 encoding:NSUTF8StringEncoding];
  64. [_letterArray addObject:letter];
  65. }
  66. item = [[UIBarButtonItem alloc] initWithTitle:@"条件搜索" style:UIBarButtonItemStyleDone target:self action:@selector(clickToSearch)];
  67. [item setTintColor:defGreen];
  68. [self.navigationItem setRightBarButtonItem:item];
  69. _contactTable = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  70. _contactTable.delegate = self;
  71. _contactTable.dataSource = self;
  72. //设置sectionIndex
  73. [_contactTable setSectionIndexBackgroundColor:[UIColor clearColor]];
  74. [_contactTable setSectionIndexColor:[UIColor redColor]];
  75. [self.view addSubview:_contactTable];
  76. _searchController =[[UISearchController alloc]initWithSearchResultsController:nil];
  77. [_searchController.searchBar sizeToFit];
  78. _searchController.searchResultsUpdater = self;
  79. //这个是在搜索时候将之前的隐藏 包括表 无法点击 适合弹出新的tableviewcontroller 默认yes
  80. _searchController.dimsBackgroundDuringPresentation = NO;
  81. //这个是搜索时候隐藏导航栏
  82. _searchController.hidesNavigationBarDuringPresentation = NO;
  83. _searchController.searchBar.placeholder=@"请输入学员姓名或者电话";
  84. _contactTable.sectionIndexColor = [UIColor blueColor];
  85. _contactTable.tableHeaderView=_searchController.searchBar;
  86. holderV = [[HolderView alloc] initWithFrame:_contactTable.frame];
  87. [holderV freshBlock:^{
  88. [self getMyStudentByScore];
  89. }];
  90. [self.view addSubview:holderV];
  91. [self getMyStudentByScore];
  92. }
  93. -(void)viewWillDisappear:(BOOL)animated
  94. {
  95. [super viewWillDisappear:animated];
  96. [self.view endEditing:YES];
  97. RemoveHUD();
  98. //这个一定要写 要不然会在退出去下一个页面时候 搜索栏有一定时间的存留
  99. if (_searchController.active) {
  100. _searchController.active = NO;
  101. if (_searchController.searchBar && _searchController.searchBar.superview) {
  102. //NSLog(@"这个也一直执行");
  103. [_searchController.searchBar removeFromSuperview];
  104. }
  105. }
  106. }
  107. #pragma mark maintableview delegate (索引)
  108. -(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
  109. {
  110. return _letterArray;
  111. }
  112. //响应点击索引时的委托方法
  113. -(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
  114. {
  115. NSInteger count = 0;
  116. //NSLog(@"%@-%d",title,(int)index);
  117. NSArray *array = [[groupDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
  118. //为了找到索引中没有字目的前一个字母 也是醉了
  119. if (![array containsObject:title]) {
  120. int index = (int)[_letterArray indexOfObject:title];
  121. for (int i = index; i > 0; i --) {
  122. if ([array containsObject:_letterArray[i]]) {
  123. title = _letterArray[i];
  124. break;
  125. }
  126. }
  127. }
  128. for(NSString *character in array)
  129. {
  130. if([character isEqualToString:title])
  131. {
  132. return count;
  133. }
  134. count ++;
  135. }
  136. return 0;
  137. }
  138. -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
  139. {
  140. if (tableView == _contactTable)
  141. {
  142. if (_searchController.searchBar.text.length > 0) {
  143. if (_resultArray.count > 0) {
  144. NSString *str = [[_resultArray firstObject] substringToIndex:1];
  145. for (NSDictionary *dic in models) {
  146. if ([dic[@"XM"] hasPrefix:str]) {
  147. return dic[@"PY_FIRST"];
  148. }
  149. }
  150. }
  151. //这个永远不会返回 因为 result为空 就不会有这个
  152. return @"A";
  153. }else{
  154. NSArray * array = [[groupDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
  155. return [array objectAtIndex:section];
  156. }
  157. }
  158. else
  159. {
  160. NSString *str = [[_resultArray firstObject] substringToIndex:1];
  161. for (NSDictionary *dic in models) {
  162. if ([dic[@"XM"] hasPrefix:str]) {
  163. return dic[@"PY_FIRST"];
  164. }
  165. }
  166. }
  167. //这个永远不会返回 因为 result为空 就不会有这个
  168. return @"A";
  169. }
  170. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  171. {
  172. //最外层else 相当于对版本适配了 只有iOS8以下 才会进的方法
  173. if (tableView == _contactTable)
  174. {
  175. if (_searchController.searchBar.text.length > 0) {
  176. if (_resultArray.count > 0) {
  177. return 1;
  178. }else{
  179. return 0;
  180. }
  181. }
  182. return [[groupDic allKeys] count];
  183. }
  184. else
  185. {
  186. if (_resultArray.count > 0) {
  187. return 1;
  188. }else{
  189. return 0;
  190. }
  191. }
  192. }
  193. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  194. {
  195. if (tableView == _contactTable)
  196. {
  197. //sortedArrayUsingSelector 排序
  198. if (_searchController.searchBar.text.length > 0) {
  199. return _resultArray.count;
  200. }
  201. NSArray * array = [[groupDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
  202. return [[groupDic objectForKey:array[section]] count];
  203. }
  204. else
  205. {
  206. //显示搜索的结果
  207. return _resultArray.count;
  208. }
  209. }
  210. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  211. {
  212. static NSString * Identifier = @"cell";
  213. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
  214. if (cell == nil)
  215. {
  216. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Identifier];
  217. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  218. }
  219. NSString *p;
  220. if (tableView == _contactTable)
  221. {
  222. if (_searchController.searchBar.text.length > 0) {
  223. p = _resultArray[indexPath.row];
  224. }else{
  225. NSArray * array = [[groupDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
  226. p = [[groupDic objectForKey:[array objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
  227. }
  228. }
  229. else
  230. {
  231. p = _resultArray[indexPath.row];
  232. }
  233. [cell.textLabel setText:p];
  234. // //如果有休学 用不同颜色标注出来
  235. // if ([p hasSuffix:@"已休学"]) {
  236. // NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:p];
  237. // NSRange sufRange = [p rangeOfString:@"已休学"];
  238. // [str addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:sufRange];
  239. // cell.textLabel.attributedText = str;
  240. // }else{
  241. // [cell.textLabel setText:p];
  242. // }
  243. return cell;
  244. }
  245. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  246. {
  247. NSString *showString;
  248. if (tableView == _contactTable)
  249. {
  250. if (_searchController.searchBar.text.length > 0) {
  251. showString = _resultArray[indexPath.row];
  252. }else{
  253. NSArray * array = [[groupDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
  254. showString = [[groupDic objectForKey:[array objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
  255. }
  256. }else{
  257. showString = _resultArray[indexPath.row];
  258. }
  259. for (NSDictionary *dic in models) {
  260. BOOL isHas;
  261. if (kSize.width > 350.0){
  262. isHas = [showString hasPrefix:[NSString stringWithFormat:@"%@ %@",dic[@"XM"],dic[@"SJHM"]]];
  263. }else{
  264. isHas = [showString hasPrefix:[NSString stringWithFormat:@"%@ %@",dic[@"XM"],dic[@"SJHM"]]];
  265. }
  266. if (isHas) {
  267. //从这个地方去学员成绩
  268. MyGradeVC *gradeVC = [[MyGradeVC alloc] init];
  269. gradeVC.kmString = kemuString;
  270. gradeVC.identifyNum = dic[@"USERID"];
  271. gradeVC.stuName = dic[@"XM"];
  272. [self.navigationController pushViewController:gradeVC animated:YES];
  273. return;
  274. }
  275. }
  276. }
  277. #pragma mark UISearchDisplayController 代理方法
  278. - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
  279. {
  280. //[self searchBarTextDidBeginEditing:_searchController.searchBar];
  281. NSString *searchString = _searchController.searchBar.text;
  282. //NSLog(@"searchString-->%@",searchString);
  283. [_resultArray removeAllObjects];
  284. for (NSString * name in _tableSourceArray)
  285. {
  286. if ([name rangeOfString:searchString].location != NSNotFound)
  287. {
  288. [_resultArray addObject:name];
  289. }
  290. }
  291. //NSLog(@"_resultArray-->%@",_resultArray);
  292. [_contactTable reloadData];
  293. }
  294. #pragma mark pickerView
  295. -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
  296. {
  297. return 1;
  298. }
  299. //每列对应多少行
  300. -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
  301. {
  302. //1.获取当前的列
  303. NSArray *arayM = pickDataArray[whichPicker];
  304. //2.返回当前列对应的行数
  305. return arayM.count;
  306. }
  307. //每列每行对应显示的数据是什么
  308. -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
  309. {
  310. //1.获取当前的列
  311. NSArray *arayM = pickDataArray[whichPicker];
  312. //2.获取当前列对应的行的数据
  313. return arayM[row];
  314. }
  315. -(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
  316. {
  317. return 40;
  318. }
  319. //选中
  320. -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
  321. {
  322. //获取对应列,对应行的数据
  323. NSString *exceptValue = pickDataArray[whichPicker][row];
  324. //赋值
  325. if (whichPicker == 0) {
  326. [scoreBtn setTitle:exceptValue forState:UIControlStateNormal];
  327. scoreString = exceptValue;
  328. }
  329. if (whichPicker == 1) {
  330. [countBtn setTitle:exceptValue forState:UIControlStateNormal];
  331. countString = exceptValue;
  332. }
  333. }
  334. #pragma mark --触发事件
  335. -(void)clickToSearch
  336. {
  337. item.enabled = NO;
  338. backView = [[UIView alloc] initWithFrame:kFrame];
  339. backView.backgroundColor = [UIColor colorWithWhite:.1 alpha:.5];
  340. [self.view addSubview:backView];
  341. CGFloat x, y, w, h, bd;
  342. x = 20;
  343. w = kSize.width - 2*x;
  344. h = 460;
  345. y = (kSize.height - h)/2.0;
  346. UIView *searchView = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  347. searchView.backgroundColor = KBackGroundColor;
  348. [searchView borderCornorRadios:5];
  349. [backView addSubview:searchView];
  350. x = y = bd = 10;
  351. w = searchView.width - 30;
  352. h = 40;
  353. NSArray *titles = @[@"学员成绩:",@"连续次数:",@"开始时间:",@"结束时间:",@"考试科目:",@"驾校编号:",@"学员证件号:"];
  354. NSString *beginStr = beginDate;
  355. if (beginStr.length < 1) {
  356. beginStr = @"请选择开始时间";
  357. }
  358. NSString *endStr = endDate;
  359. if (endStr.length < 1) {
  360. endStr = @"请选择结束时间";
  361. }
  362. NSString *kemuStr = @"科目一";
  363. if ([kemuString isEqualToString:@"4"]) {
  364. kemuStr = @"科目四";
  365. }
  366. NSArray *btnTitles = @[scoreString,countString,beginStr,endStr,kemuStr,@"",@""];
  367. NSArray *describes = @[@"分以上",@"次以上"];
  368. NSMutableArray *btns = [NSMutableArray arrayWithCapacity:6];
  369. for (int i = 0; i < 7; i ++) {
  370. UIView *backV = [[UIView alloc] initWithFrame:CGRectMake(x, y + i*(h + bd) , w, h)];
  371. [backV borderColor:kLineColor width:2 cornorRadios:5];
  372. [searchView addSubview:backV];
  373. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y + i*(h + bd) , 100, h)];
  374. [label setText:titles[i] Font:Font16 TextColor:KContentTextColor Alignment:NSTextAlignmentLeft];
  375. [searchView addSubview:label];
  376. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x + bd + 110, y + i*(h + bd) , w - x - bd - 110, h)];
  377. [button setTitle:btnTitles[i] textColor:KContentTextColor font:Font16 fotState:UIControlStateNormal];
  378. button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  379. [button target:self Tag:i + 1];
  380. [searchView addSubview:button];
  381. [btns addObject:button];
  382. if (i < 2) {
  383. [button addViewWithRect:CGRectMake(x + bd + 100, y + i*(h + bd) + 30 , 35, 1.5) Color:KContentTextColor];
  384. label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd + 150, y + i*(h + bd) , w - x - bd - 150, h)];
  385. [label setText:describes[i] Font:Font16 TextColor:KContentTextColor Alignment:NSTextAlignmentLeft];
  386. [searchView addSubview:label];
  387. }else if (i == 5){
  388. [button removeFromSuperview];
  389. jxbhTF = [[UITextField alloc]initWithFrame:CGRectMake(x + bd + 110, y + i*(h + bd) , w - x - bd - 110, h)];
  390. jxbhTF.placeholder = @"请输入驾校编号";
  391. jxbhTF.delegate = self;
  392. [searchView addSubview:jxbhTF];
  393. }else if (i == 6){
  394. [button removeFromSuperview];
  395. idcardTF = [[UITextField alloc]initWithFrame:CGRectMake(x + bd + 110, y + i*(h + bd) , w - x - bd - 110, h)];
  396. idcardTF.placeholder = @"请输入学员证件号";
  397. idcardTF.delegate = self;
  398. [searchView addSubview:idcardTF];
  399. }else{
  400. button.x -= 10;
  401. button.width += 10;
  402. }
  403. }
  404. scoreBtn = btns[0];
  405. countBtn = btns[1];
  406. beginDateBtn = btns[2];
  407. endDateBtn = btns[3];
  408. kemuBtn = btns[4];
  409. y += 6*(h + bd);
  410. w = (w - 2*bd)/2.0;
  411. NSArray *titleArrays = @[@"取消",@"查询"];
  412. for (int i = 0; i < 2; i ++) {
  413. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x + i*(w + 2*bd), y , w, h)];
  414. [button setTitle:titleArrays[i] textColor:defGreen font:Font16 fotState:UIControlStateNormal];
  415. [button borderColor:kLineColor width:2 cornorRadios:5];
  416. [button target:self Tag:i + 7];//7 8
  417. [searchView addSubview:button];
  418. }
  419. }
  420. -(void)btnClick:(UIButton *)sender
  421. {
  422. if (bgView && sender.tag < 4) {
  423. ShowMsg(@"请先选择分数或者连续次数");
  424. return;
  425. }
  426. switch (sender.tag) {
  427. case 1:
  428. {
  429. whichPicker = 0;
  430. bgView = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - 180, kSize.width, 180)];
  431. bgView.backgroundColor = [UIColor whiteColor];
  432. [self.view addSubview:bgView];
  433. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2.0 - 20, 0, kSize.width/2.0, 35)];
  434. [btn setTitle:@"完成" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  435. btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  436. [btn target:self Tag:9];
  437. [bgView addSubview:btn];
  438. picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 30, kSize.width, 150)];
  439. picker.delegate = self;
  440. picker.dataSource = self;
  441. [bgView addSubview:picker];
  442. [btn addViewWithRect:CGRectMake(0, 35, kSize.width, 1.5) Color:KContentTextColor];
  443. }
  444. break;
  445. case 2:
  446. {
  447. whichPicker = 1;
  448. bgView = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - 180, kSize.width, 180)];
  449. bgView.backgroundColor = [UIColor whiteColor];
  450. [self.view addSubview:bgView];
  451. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2.0 - 20, 0, kSize.width/2.0, 35)];
  452. [btn setTitle:@"完成" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  453. btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  454. [btn target:self Tag:9];
  455. [bgView addSubview:btn];
  456. picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 30, kSize.width, 150)];
  457. picker.delegate = self;
  458. picker.dataSource = self;
  459. [bgView addSubview:picker];
  460. [btn addViewWithRect:CGRectMake(0, 35, kSize.width, 1.5) Color:KContentTextColor];
  461. }
  462. break;
  463. case 3:
  464. {
  465. DateView *dateV = [[DateView alloc] init];
  466. [dateV setStyle:0];
  467. [dateV showWithComplete:^(NSString * result) {
  468. beginDate = result;
  469. [beginDateBtn setTitle:beginDate forState:UIControlStateNormal];
  470. }];
  471. }
  472. break;
  473. case 4:
  474. {
  475. DateView *dateV = [[DateView alloc] init];
  476. [dateV setStyle:0];
  477. [dateV showWithComplete:^(NSString * result) {
  478. endDate = result;
  479. [endDateBtn setTitle:endDate forState:UIControlStateNormal];
  480. }];
  481. }
  482. break;
  483. case 5:
  484. {
  485. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"请选择科目" delegate:self cancelButtonTitle:@"科目一" otherButtonTitles:@"科目四", nil];
  486. alert.tag = 2;
  487. [alert show];
  488. }
  489. break;
  490. case 7:
  491. {
  492. if (backView) {
  493. //取消的时候 如果picker还在 要移除了
  494. if (bgView) {
  495. [bgView removeFromSuperview];
  496. bgView = nil;
  497. }
  498. [backView removeFromSuperview];
  499. }
  500. item.enabled = YES;
  501. }
  502. break;
  503. case 8:
  504. {
  505. if (backView) {
  506. //取消的时候 如果picker还在 要移除了
  507. if (bgView) {
  508. [bgView removeFromSuperview];
  509. bgView = nil;
  510. }
  511. [backView removeFromSuperview];
  512. }
  513. item.enabled = YES;
  514. [self getMyStudentByScore];
  515. }
  516. break;
  517. case 9://whichPicker 完成
  518. {
  519. if (bgView) {
  520. [bgView removeFromSuperview];
  521. bgView = nil;
  522. }
  523. }
  524. break;
  525. default:
  526. break;
  527. }
  528. }
  529. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  530. {
  531. if (alertView.tag == 2){
  532. if (buttonIndex == 0) {
  533. //取消 科目一
  534. kemuString = @"1";
  535. [kemuBtn setTitle:@"科目一" forState:UIControlStateNormal];
  536. }else if (buttonIndex == 1){
  537. kemuString = @"4";
  538. [kemuBtn setTitle:@"科目四" forState:UIControlStateNormal];
  539. }
  540. }
  541. }
  542. #pragma mark 数据请求
  543. /**
  544. * 根据连续次数和成绩查询满足的学员
  545. * @param String score 满足考试分数
  546. * @param String count 连续次数
  547. * @param String isYk 是否已预考
  548. * @param String zjhm 教练证件号码
  549. * */
  550. //String getMyStudentByScore(String serviceName, String key,String score,String count,String isYk,String zjhm);
  551. //考试成绩
  552. - (void)getMyStudentByScore
  553. {
  554. if (![NetManager connectedToNetWork]) {
  555. showMsgUnconnect();
  556. return;
  557. }
  558. NSMutableDictionary * mDic = [NSMutableDictionary new];
  559. [mDic setObject:idcardString forKey:@"idcard"];
  560. [mDic setObject:kemuString forKey:@"subject"];
  561. [mDic setObject:scoreString forKey:@"score"];
  562. [mDic setObject:countString forKey:@"count"];
  563. [mDic setObject:beginDate forKey:@"startTime"];
  564. [mDic setObject:endDate forKey:@"endTime"];
  565. [mDic setObject:jxbhString forKey:@"jxbh"];
  566. NSString* method = @"getStuExams";
  567. [NetManager requestAnythingWithURL:method dictionary:mDic dataArray:nil completion:^(NSDictionary *root) {
  568. [holderV setHidden:NO];
  569. if (!root) {
  570. ShowErrorMsg(@"请求失败!");
  571. return;
  572. }
  573. if ([root[@"code"] isEqualToString:@"1"]) {
  574. ShowErrorMsg(root[@"msg"]);
  575. return;
  576. }
  577. if ([root[@"body"] count] < 1) {
  578. ShowMsg(@"已加载全部数据");
  579. return;
  580. }
  581. [holderV setHidden:YES];
  582. models = root[@"body"];
  583. // [self acceptData];
  584. }];
  585. }
  586. -(void)acceptData
  587. {
  588. _searchController.searchBar.placeholder=[NSString stringWithFormat:@"请输入学员姓名或电话(当前共%d人)",(int)models.count];
  589. [groupDic removeAllObjects];
  590. [_tableSourceArray removeAllObjects];
  591. /**
  592. * LLJLMC = 陈恺声,
  593. CRDATE = 2016-02-17 10:26:14,
  594. ZJHM = 130425198104097711,
  595. SJHM = 15272271043,
  596. LXDH = 15272271043,
  597. XM = 张运奇,
  598. CX = C1,
  599. PY_FIRST = Z,
  600. XB = 男,
  601. ID = 776976
  602. */
  603. NSString *keMuString;
  604. for (NSDictionary *dic in models) {
  605. keMuString = @"科目一";
  606. if ([kemuString isEqualToString:@"4"]) {
  607. keMuString = @"科目四";
  608. }
  609. NSString *letter = dic[@"PY_FIRST"];
  610. if (![groupDic objectForKey:letter]) {
  611. [groupDic setObject:[NSMutableArray array] forKey:letter];
  612. }
  613. if (kSize.width > 350.0){
  614. [_tableSourceArray addObject:[NSString stringWithFormat:@"%@ %@ %@",dic[@"XM"],dic[@"SJHM"],keMuString]];
  615. [[groupDic objectForKey:letter] addObject:[NSString stringWithFormat:@"%@ %@ %@",dic[@"XM"],dic[@"SJHM"],keMuString]];
  616. }else{
  617. [_tableSourceArray addObject:[NSString stringWithFormat:@"%@ %@ %@",dic[@"XM"],dic[@"SJHM"],keMuString]];
  618. [[groupDic objectForKey:letter] addObject:[NSString stringWithFormat:@"%@ %@ %@",dic[@"XM"],dic[@"SJHM"],keMuString]];
  619. }
  620. }
  621. [_contactTable reloadData];
  622. }
  623. - (void)didReceiveMemoryWarning {
  624. [super didReceiveMemoryWarning];
  625. }
  626. @end