123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- //
- // FaceColloectVC.m
- // LN_School
- //
- // Created by apple on 2017/9/11.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "FaceColloectVC.h"
- #import "FaceColloectView.h"
- #import "UIImageView+WebCache.h"
- @interface FaceColloectVC ()<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource, THDatePickerDelegate>
- {
- UITextField *searchTF;
- UIScrollView *mainScroll;
- UITableView *stuListTableView;
- FaceColloectView *face0,*face1,*face2,*face3,*face4,*face5;
-
- NSMutableArray *faceArrray;
- NSArray *stuListArray;
- }
- @property (nonatomic, strong) UIView *stuListView;
- @property (nonatomic, strong) THDatePickerViewController * datePicker;
- @property (nonatomic, retain) NSDate * curDate;
- @property (nonatomic, retain) NSDateFormatter * formatter;
- @end
- @implementation FaceColloectVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor = [UIColor whiteColor];
- self.navigationItem.title = @"人脸采集";
- [self goBackByNavigation];
-
-
- UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 100, 40)];
- textField.borderStyle = UITextBorderStyleRoundedRect;
- textField.placeholder = @"请输入学员证件或姓名";
- [self.view addSubview:textField];
- searchTF = textField;
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
- btn.frame = CGRectMake(kSize.width - 70, 10, 50, 40);
- [btn borderCornorRadios:7];
- btn.backgroundColor = RQMianColor;
- [btn setTitle:@"查找" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
- [btn target:self Tag:1];
- [self.view addSubview:btn];
-
- if (_keyWord.length > 0) {
- searchTF.text = _keyWord;
- [self getStudentData];
- }
-
- if (!_currentDate) [self creatRightNavigationItem];
- }
- //学员列表
- - (void)initStuList {
-
- [[UIApplication sharedApplication].keyWindow addSubview:self.stuListView];
- [stuListTableView reloadData];
- }
- -(UIView *)stuListView {
-
- if (!_stuListView) {
- _stuListView = [[UIView alloc] initWithFrame:kFrame];
- _stuListView.backgroundColor = windowBlockColor;
-
- stuListTableView = [[UITableView alloc] initWithFrame:CGRectMake(20, kSize.height/2.0 - 150, kSize.width - 40, 260) style:UITableViewStylePlain];
- [stuListTableView borderCornorRadios:5];
- stuListTableView.delegate = self;
- stuListTableView.dataSource = self;
- stuListTableView.rowHeight = 50;
- stuListTableView.estimatedSectionFooterHeight = 0;
- [_stuListView addSubview:stuListTableView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake( 0, 0, kSize.width - 40, 50)];
- [label addSelfViewWithRect:CGRectMake(10, 49, kSize.width - 60, 1) Color:kLineColor];
- [label setText:@"选择学员" Font:Font21 TextColor:KTitleColor Alignment:NSTextAlignmentCenter];
- [stuListTableView setTableHeaderView:label];
- }
-
- return _stuListView;
- }
- //显示照片
- - (void)setMainScrollWithNSDictionary:(NSDictionary *)dic {
-
- if (!mainScroll) {
- mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 60, kSize.width, kSize.height - 60 - kNavOffSet)];
- mainScroll.delegate = self;
- [self.view addSubview:mainScroll];
-
- //@RQ-MARK 1.0.2修改:“人脸采集”详情模块中移除其他侧面照等四处照片并修改上传照片方式(去除审核等多种状态)
- NSArray *titleArray = @[@"证件照",@"正脸照"];
- //计算一个相片的高度
- CGFloat h = (kSize.width/2.0 - 20)*3/4.0 + 40 + 25;
- faceArrray = [NSMutableArray arrayWithCapacity:titleArray.count];
- for (int i = 0; i < titleArray.count; i ++) {
-
- int column = i%2;
- int row = i/2;
-
- FaceColloectView *face = [[FaceColloectView alloc] initWithFrame:CGRectMake(column*kSize.width/2.0, row*h, kSize.width/2.0, h)];
- [face borderColor:kLineColor width:0.7 cornorRadios:1];
- face.titleLabel.text = titleArray[i];
- face.superVC = self;
- face.type = [NSString stringWithFormat:@"%d",i];
- [mainScroll addSubview:face];
- [faceArrray addObject:face];
- }
-
-
- if (faceArrray.count > 1) {
- face0 = faceArrray[0];
- face1 = faceArrray[1];
- }
-
- [mainScroll setContentSize:CGSizeMake(kSize.width, CGRectGetMaxY(face1.frame) + 100)];
-
-
- face0.clickBtn.hidden = YES;
- face0.titleLabel.width += face0.titleLabel.width;
- }
-
- face0.titleLabel.text = [NSString stringWithFormat:@"%@\n证件照",dic[@"TSO_NAME"]];
- NSString *faceImgPath = dic[@"TSO_PHOTO_PATH"];
- if (!faceImgPath) {
- faceImgPath = @"";
- }
- faceImgPath = [faceImgPath stringByReplacingOccurrencesOfString:@"//tms" withString:@"/tms"];
-
- // [SDWebImageDownloader.sharedDownloader setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
- // forHTTPHeaderField:@"Accept"];
- [face0.faceImg sd_setImageWithURL:[NSURL URLWithString:faceImgPath] placeholderImage:[UIImage imageNamed:@"NOImg"]];
-
-
- //有新的数据就清楚之前的数据 并更新学员的ID
- for (FaceColloectView *faceView in faceArrray) {
- // faceView.dataDic = nil;
- faceView.stuID = dic[@"TSO_ID"];
- }
-
- //添加模版数据
- NSArray *faceList = dic[@"FACELIST"];
- if (faceList.count > 0) {
- for (NSDictionary *faceDic in faceList) {
- if ([faceDic[@"TYPE"] integerValue] == 0 || [faceDic[@"TYPE"] integerValue] == 1) {
- FaceColloectView *faceView = faceArrray[[faceDic[@"TYPE"] integerValue]];
- faceView.dataDic = faceDic;
- }
- // FaceColloectView *faceView = faceArrray[[faceDic[@"TYPE"] integerValue]];
- // faceView.dataDic = faceDic;
- }
- }
- }
- - (void)btnClick:(UIButton *)sender {
-
- if (searchTF.text.length < 1) {
- ShowMsg(@"请输入学员信息!");
- return;
- }
-
- [self.view endEditing:YES];
- _keyWord = searchTF.text;
- [self getStudentData];
- }
- - (void)creatRightNavigationItem {
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"选择日期" style:UIBarButtonItemStylePlain target:self action:@selector(rightNavigationItemClick)];
- [self.navigationItem.rightBarButtonItem setTintColor:RQMianColor];
- }
- - (void)rightNavigationItemClick {
- [self.view endEditing:YES];
- self.datePicker.date = self.curDate;
- [self presentSemiViewController:self.datePicker withOptions:@{
- KNSemiModalOptionKeys.pushParentBack : @(NO),
- KNSemiModalOptionKeys.animationDuration : @(0.3),
- KNSemiModalOptionKeys.shadowOpacity : @(0.3),
- }];
- }
- #pragma mark tableView
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return stuListArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- [cell.imageView borderCornorRadios:3];
- cell.imageView.frame = (CGRect){10,5,40,40};
- cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
- }
-
- NSDictionary *dic = stuListArray[indexPath.row];
-
- NSString *faceImgPath = dic[@"TSO_PHOTO_PATH"];
- if (!faceImgPath) {
- faceImgPath = @"";
- }
- [cell.imageView sd_setImageWithURL:[NSURL URLWithString:faceImgPath] placeholderImage:[UIImage imageNamed:@"NOImg"]];
-
- cell.textLabel.text = dic[@"TSO_NAME"];
-
- cell.detailTextLabel.text = dic[@"TSO_IDCARD"];
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- [self.stuListView removeFromSuperview];
- [self setMainScrollWithNSDictionary:stuListArray[indexPath.row]];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 0.1;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- return [UIView new];
- }
- #pragma mark 数据请求
- -(void)getStudentData{
-
- //判断网络是否连接
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary * mdic = [NSMutableDictionary new];
-
- [mdic setValue:_keyWord forKey:@"keyWord"];
- //@RQ-MARK 1.0.2修改:“人脸采集”模块展示单天报名学员(可进行人脸采集)
- [mdic setValue:_currentDate? [self.formatter stringFromDate:_currentDate] : [self.formatter stringFromDate:self.curDate] forKey:@"applyTime"];
-
- [NetManager requestAnythingWithURL:@"getStudentList" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
- if (!root) {
- ShowMsg(@"学员信息查询失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
-
- if ([root[@"body"] count] < 1) {
- ShowMsg(@"查询不到该学员,请确认查询条件");
- return;
- }else if ([root[@"body"] count] == 1) {
- //查询到单独学员 直接显示
- [self setMainScrollWithNSDictionary:[root[@"body"] firstObject]];
- }else {
- //查询到多个学员 展示列表
- self->stuListArray = root[@"body"];
- [self initStuList];
- }
- }];
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView {
- [self.view endEditing:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- #pragma mark - THDatePickerDelegate
- - (void)datePickerDonePressed:(THDatePickerViewController *)datePicker {
- self.curDate = datePicker.date;
- [self getStudentData];
- [self dismissSemiModalView];
- }
- - (void)datePickerCancelPressed:(THDatePickerViewController *)datePicker {
- [self dismissSemiModalView];
- }
- - (void)datePicker:(THDatePickerViewController *)datePicker selectedDate:(NSDate *)selectedDate {
- NSLog(@"Date selected: %@",[self.formatter stringFromDate:selectedDate]);
- }
- #pragma mark - Lazy Loading
- - (THDatePickerViewController *)datePicker {
- if (!_datePicker) {
- _datePicker = [THDatePickerViewController datePicker];
- _datePicker.delegate = self;
- _datePicker.currentDateColorSelected = RQMianColor;//当前日期被选中颜色
- _datePicker.currentDateColor = [UIColor redColor];//当前日期颜色
- _datePicker.selectedBackgroundColor = [UIColor lightGrayColor];//选中日期背景色
- [_datePicker setDisableYearSwitch:YES];//关闭左右滑动切换年
- [_datePicker setAllowClearDate:NO];
- [_datePicker setClearAsToday:YES];
- [_datePicker setAutoCloseOnSelectDate:NO];
- [_datePicker setAllowSelectionOfSelectedDate:YES];
- [_datePicker setDaysInHistorySelection:0];
- [_datePicker setDaysInFutureSelection:0];
- _datePicker.rounded = YES;
- }
- return _datePicker;
- }
- - (NSDateFormatter *)formatter {
- if (!_formatter) {
- _formatter = [[NSDateFormatter alloc] init];
- [_formatter setDateFormat:@"yyyy-MM-dd"];
- }
- return _formatter;
- }
- - (NSDate *)curDate {
- if (!_curDate) {
- _curDate = [NSDate date];
- }
- return _curDate;
- }
- @end
|