123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- //
- // fpVC.m
- // jiaPeiC
- //
- // Created by apple on 16/3/15.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "fpVC.h"
- #import "DateView.h"
- #import "MyStuVC.h"
- #import "CLWeeklyCalendarView.h"
- @interface fpVC ()<CLWeeklyCalendarViewDelegate,UITableViewDataSource,UITableViewDelegate>
- {
- NSString *fpTime;
- NSString *keMuState;
- NSMutableArray *models;
-
- UIButton *dateBtn;
- DateView *dateV;
- HolderView *holderV;
- UITableView *mainTableView;
- UIBarButtonItem *item;
- }
- @property (nonatomic, strong) CLWeeklyCalendarView* calendarView;
- @end
- @implementation fpVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- models = [NSMutableArray array];
- [self myInit];
- }
- -(void)myInit
- {
- [self.view addSubview:self.calendarView];
-
- // item = [[UIBarButtonItem alloc] initWithTitle:@"科目选择" style:UIBarButtonItemStyleDone target:self action:@selector(clickToChooseKeMu)];
- // [item setTintColor:defGreen];
- // [self.navigationItem setRightBarButtonItem:item];
-
- CGFloat y = kNavOffSet + self.calendarView.height;
-
- mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
- mainTableView.y = y;
- mainTableView.height = kSize.height - mainTableView.y;
- mainTableView.delegate = self;
- mainTableView.dataSource = self;
- [mainTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
- [self.view addSubview:mainTableView];
-
- holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
- [holderV freshBlock:^{
-
- [self getMyStudentByFp];
- }];
- [self addV:holderV];
-
- keMuState = @"";
- [self getMyStudentByFp];//@lee 这里是不是不需要调用了,因为月历还是周历的代理里面会调一次?
- }
- -(CLWeeklyCalendarView *)calendarView
- {
- if(!_calendarView){
- _calendarView = [[CLWeeklyCalendarView alloc] initWithFrame:CGRectMake(0, kNavOffSet, kSize.width, 120)];
- _calendarView.delegate = self;
- }
- return _calendarView;
- }
- #pragma mark - CLWeeklyCalendarViewDelegate
- -(NSDictionary *)CLCalendarBehaviorAttributes
- {
- //CLCalendarSelectedDatePrintFormatDefault 显示选中日期格式
- return @{
- //CLCalendarWeekStartDay : @2, //Start Day of the week, from 1-7 Mon-Sun -- default 1
- // CLCalendarDayTitleTextColor : [UIColor yellowColor],
- // CLCalendarSelectedDatePrintColor : [UIColor greenColor],
- };
- }
- -(void)dailyCalendarViewDidSelect:(NSDate *)date
- {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- fpTime = [formatter stringFromDate:date];
- [self getMyStudentByFp];
- }
- //这些东西弃用了
- -(void)clickToChooseKeMu{
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"科目选择" delegate:self cancelButtonTitle:@"全部学员" otherButtonTitles:@"科目二",@"科目三", nil];
- [alert show];
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (buttonIndex == 0) {
-
- keMuState = @"";
- [item setTitle:@"全部学员"];
- }else if (buttonIndex == 1) {
-
- keMuState = @"2";
- [item setTitle:@"科目二"];
- }else{
- keMuState = @"3";
- [item setTitle:@"科目三"];
- }
-
- [self getMyStudentByFp];
- }
- #pragma mark tableview delegate
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return models.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- //如果要简单显示 可以试试这个
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- }
- NSDictionary *dic = models[indexPath.row];
- NSString *sex = [[NSString stringWithFormat:@"%@",dic[@"SEX"]] integerValue] == 1? @"男":@"女";
- cell.textLabel.text = [NSString stringWithFormat:@"%@ %@ %@ 科目%@",dic[@"XM"],sex,dic[@"TELPHONE"],[dic[@"SUBJECT"] isEqualToString:@"2"] ?@"二":@"三"];
- NSString *dateString = dic[@"CRDATE"];
- if (dateString.length > 10) {
- dateString = [dateString substringToIndex:10];
- }
- cell.detailTextLabel.text = [NSString stringWithFormat:@"报名时间:%@",dateString];
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- //@lee 未测试(同步from辽宁) 并且这里可能还需要一个xxid。又或者利用学员详情页的第一个接口判定休学状态(还不清楚具体哪个key)
- NSDictionary *dic = models[indexPath.row];
- NSMutableDictionary *mDic = [NSMutableDictionary dictionaryWithDictionary:dic];
- if (dic[@"XM"]) {
- [mDic setObject:dic[@"XM"] forKey:@"STU_NAME"];
- [mDic removeObjectForKey:@"XM"];
- }
- if (dic[@"STU_ID"]) {
- [mDic setObject:dic[@"STU_ID"] forKey:@"TSO_ID"];
- [mDic removeObjectForKey:@"STU_ID"];
- }
-
- MyStuVC *vc = [[MyStuVC alloc] init];
- vc.stuDic = mDic;
- [vc.view setBackgroundColor:backGroundColor];
- [vc configNavBar];
- [vc setTitle:@"学员详情"];
- [self.navigationController pushViewController:vc animated:YES];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- #pragma mark 数据请求
- - (void)getMyStudentByFp
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- if (!fpTime || fpTime.length == 0) {
-
- fpTime = [self getNowDate];
- }
-
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
- [arr addPro:@"fptime" Value:fpTime];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
- [arr addPro:@"isPage" Value:@"0"];
- [arr addPro:@"pageSize" Value:@"0"];
- [arr addPro:@"currentPage" Value:@"0"];
- NSString* method = @"getMyStudentByFp";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //NSLog(@"分配的学员---->%@----->%@",arr,root);
-
- if (!root) {
-
- [holderV setHidden:NO];
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
-
- ShowMsg(root[@"body"]);
- [holderV setHidden:NO];
- return;
- }
-
- if ([root[@"body"] count] == 0) {
-
- [holderV setHidden:NO];
- return;
- }
-
- models = root[@"body"];
- [holderV setHidden:YES];
- [mainTableView reloadData];
- }];
- }
- -(NSString *)getNowDate
- {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *dateString = [formatter stringFromDate:[NSDate date]];
- return dateString;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|