fpVC.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. //
  2. // fpVC.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/3/15.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "fpVC.h"
  9. #import "DateView.h"
  10. #import "MyStuVC.h"
  11. #import "CLWeeklyCalendarView.h"
  12. @interface fpVC ()<CLWeeklyCalendarViewDelegate,UITableViewDataSource,UITableViewDelegate>
  13. {
  14. NSString *fpTime;
  15. NSString *keMuState;
  16. NSMutableArray *models;
  17. UIButton *dateBtn;
  18. DateView *dateV;
  19. HolderView *holderV;
  20. UITableView *mainTableView;
  21. UIBarButtonItem *item;
  22. }
  23. @property (nonatomic, strong) CLWeeklyCalendarView* calendarView;
  24. @end
  25. @implementation fpVC
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. models = [NSMutableArray array];
  29. [self myInit];
  30. }
  31. -(void)myInit
  32. {
  33. [self.view addSubview:self.calendarView];
  34. // item = [[UIBarButtonItem alloc] initWithTitle:@"科目选择" style:UIBarButtonItemStyleDone target:self action:@selector(clickToChooseKeMu)];
  35. // [item setTintColor:defGreen];
  36. // [self.navigationItem setRightBarButtonItem:item];
  37. CGFloat y = kNavOffSet + self.calendarView.height;
  38. mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  39. mainTableView.y = y;
  40. mainTableView.height = kSize.height - mainTableView.y;
  41. mainTableView.delegate = self;
  42. mainTableView.dataSource = self;
  43. [mainTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
  44. [self.view addSubview:mainTableView];
  45. holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
  46. [holderV freshBlock:^{
  47. [self getMyStudentByFp];
  48. }];
  49. [self addV:holderV];
  50. keMuState = @"";
  51. [self getMyStudentByFp];//@lee 这里是不是不需要调用了,因为月历还是周历的代理里面会调一次?
  52. }
  53. -(CLWeeklyCalendarView *)calendarView
  54. {
  55. if(!_calendarView){
  56. _calendarView = [[CLWeeklyCalendarView alloc] initWithFrame:CGRectMake(0, kNavOffSet, kSize.width, 120)];
  57. _calendarView.delegate = self;
  58. }
  59. return _calendarView;
  60. }
  61. #pragma mark - CLWeeklyCalendarViewDelegate
  62. -(NSDictionary *)CLCalendarBehaviorAttributes
  63. {
  64. //CLCalendarSelectedDatePrintFormatDefault 显示选中日期格式
  65. return @{
  66. //CLCalendarWeekStartDay : @2, //Start Day of the week, from 1-7 Mon-Sun -- default 1
  67. // CLCalendarDayTitleTextColor : [UIColor yellowColor],
  68. // CLCalendarSelectedDatePrintColor : [UIColor greenColor],
  69. };
  70. }
  71. -(void)dailyCalendarViewDidSelect:(NSDate *)date
  72. {
  73. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  74. [formatter setDateFormat:@"yyyy-MM-dd"];
  75. fpTime = [formatter stringFromDate:date];
  76. [self getMyStudentByFp];
  77. }
  78. //这些东西弃用了
  79. -(void)clickToChooseKeMu{
  80. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"科目选择" delegate:self cancelButtonTitle:@"全部学员" otherButtonTitles:@"科目二",@"科目三", nil];
  81. [alert show];
  82. }
  83. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  84. {
  85. if (buttonIndex == 0) {
  86. keMuState = @"";
  87. [item setTitle:@"全部学员"];
  88. }else if (buttonIndex == 1) {
  89. keMuState = @"2";
  90. [item setTitle:@"科目二"];
  91. }else{
  92. keMuState = @"3";
  93. [item setTitle:@"科目三"];
  94. }
  95. [self getMyStudentByFp];
  96. }
  97. #pragma mark tableview delegate
  98. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  99. {
  100. return models.count;
  101. }
  102. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  103. {
  104. //如果要简单显示 可以试试这个
  105. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  106. if (cell == nil)
  107. {
  108. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
  109. }
  110. NSDictionary *dic = models[indexPath.row];
  111. NSString *sex = [[NSString stringWithFormat:@"%@",dic[@"SEX"]] integerValue] == 1? @"男":@"女";
  112. cell.textLabel.text = [NSString stringWithFormat:@"%@ %@ %@ 科目%@",dic[@"XM"],sex,dic[@"TELPHONE"],[dic[@"SUBJECT"] isEqualToString:@"2"] ?@"二":@"三"];
  113. NSString *dateString = dic[@"CRDATE"];
  114. if (dateString.length > 10) {
  115. dateString = [dateString substringToIndex:10];
  116. }
  117. cell.detailTextLabel.text = [NSString stringWithFormat:@"报名时间:%@",dateString];
  118. return cell;
  119. }
  120. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  121. {
  122. //@lee 未测试(同步from辽宁) 并且这里可能还需要一个xxid。又或者利用学员详情页的第一个接口判定休学状态(还不清楚具体哪个key)
  123. NSDictionary *dic = models[indexPath.row];
  124. NSMutableDictionary *mDic = [NSMutableDictionary dictionaryWithDictionary:dic];
  125. if (dic[@"XM"]) {
  126. [mDic setObject:dic[@"XM"] forKey:@"STU_NAME"];
  127. [mDic removeObjectForKey:@"XM"];
  128. }
  129. if (dic[@"STU_ID"]) {
  130. [mDic setObject:dic[@"STU_ID"] forKey:@"TSO_ID"];
  131. [mDic removeObjectForKey:@"STU_ID"];
  132. }
  133. MyStuVC *vc = [[MyStuVC alloc] init];
  134. vc.stuDic = mDic;
  135. [vc.view setBackgroundColor:backGroundColor];
  136. [vc configNavBar];
  137. [vc setTitle:@"学员详情"];
  138. [self.navigationController pushViewController:vc animated:YES];
  139. }
  140. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  141. {
  142. return .1;
  143. }
  144. #pragma mark 数据请求
  145. - (void)getMyStudentByFp
  146. {
  147. [LoadingView showHUD];
  148. if (![Util connectedToNetWork]) {
  149. showMsgUnconnect();
  150. return;
  151. }
  152. if (!fpTime || fpTime.length == 0) {
  153. fpTime = [self getNowDate];
  154. }
  155. NSMutableArray *arr = [NSMutableArray array];
  156. [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
  157. [arr addPro:@"fptime" Value:fpTime];
  158. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  159. [arr addPro:@"isPage" Value:@"0"];
  160. [arr addPro:@"pageSize" Value:@"0"];
  161. [arr addPro:@"currentPage" Value:@"0"];
  162. NSString* method = @"getMyStudentByFp";
  163. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  164. RemoveHUD();
  165. //NSLog(@"分配的学员---->%@----->%@",arr,root);
  166. if (!root) {
  167. [holderV setHidden:NO];
  168. return;
  169. }
  170. if ([root[@"code"] isEqualToString:@"1"]) {
  171. ShowMsg(root[@"body"]);
  172. [holderV setHidden:NO];
  173. return;
  174. }
  175. if ([root[@"body"] count] == 0) {
  176. [holderV setHidden:NO];
  177. return;
  178. }
  179. models = root[@"body"];
  180. [holderV setHidden:YES];
  181. [mainTableView reloadData];
  182. }];
  183. }
  184. -(NSString *)getNowDate
  185. {
  186. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  187. [formatter setDateFormat:@"yyyy-MM-dd"];
  188. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  189. return dateString;
  190. }
  191. - (void)didReceiveMemoryWarning {
  192. [super didReceiveMemoryWarning];
  193. // Dispose of any resources that can be recreated.
  194. }
  195. @end