// // StudentChangeSchoolVC.m // jiaPei // // Created by 张嵘 on 2020/12/1. // Copyright © 2020 JCZ. All rights reserved. // #import "StudentChangeSchoolVC.h" #import "StudentChangeSchoolModel.h" @interface StudentChangeSchoolVC () /// viewModel @property (nonatomic, readonly, strong) RQStudentChangeSchoolViewModel *viewModel; @property (nonatomic, readwrite, strong) StudentChangeSchoolModel * studentChangeSchoolModel; @property (nonatomic , assign) ScsInSchoolAudit SCS_IN_SCHOOL_AUDIT; @end @implementation StudentChangeSchoolVC @dynamic viewModel; #pragma mark - SystemMethod - (void)viewDidLoad { [super viewDidLoad]; [self initUI]; } #pragma mark - Private Functions - (void)initUI { @weakify(self) self.title = @"转校记录"; self.SCS_IN_SCHOOL_AUDIT = ScsInSchoolAudit_Default; [self configNavigationBar]; _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ @strongify(self) [self getData]; }]; [_tableView.mj_header beginRefreshing]; [RACObserve(self, SCS_IN_SCHOOL_AUDIT) subscribeNext:^(id _Nullable x) { @strongify(self) self.footerView.hidden = self.SCS_IN_SCHOOL_AUDIT != ScsInSchoolAudit_Wait; }]; _bottomConst.constant = kSafeAreaBottomHeight; self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH, CGFLOAT_MIN)]; } /// 请求数据 - (void)getData { @weakify(self) NSMutableArray *arr = [NSMutableArray array]; [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city]; [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId]; NSString *method = @"getStudentChangeSchool"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) { @strongify(self) [self.tableView.mj_header endRefreshing]; if (!root) { ShowMsgFailed(); return; } if ([root[@"code"] isEqualToString:@"0"]) { self.studentChangeSchoolModel = [StudentChangeSchoolModel modelWithDictionary:root[@"body"]]; if (!_studentChangeSchoolModel) { ShowMsg(@"暂无转校记录!"); [self.navigationController popToRootViewControllerAnimated:YES]; } self.SCS_IN_SCHOOL_AUDIT = self.studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT; [self.tableView reloadData]; }else { if ([root[@"body"] isKindOfClass:[NSString class]]) { ShowMsg(root[@"body"]); } else { ShowMsg(root[@"msg"]); } return; } }]; } - (IBAction)confirmAction:(id)sender { @weakify(self) [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"是否同意转校?" alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:@[@"同意",@"拒绝"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) { @strongify(self) switch (selectedOtherButtonIndex) { case 0: ///同意 [self updateStudentChangeSchoolWithAudit:@"3"]; break; case 1: ///拒绝 [self updateStudentChangeSchoolWithAudit:@"4"]; break; default: break; } }]; } - (void)updateStudentChangeSchoolWithAudit:(NSString *)audit { @weakify(self) /// * URL=http://192.168.1.6:8082/student/updateStudentChangeSchool?ts={timestamp}&sign={sign_str}&user={cert_sn} /// * HTTP方法:POST /// * 报文格式:{'stuOutId':'3502004042','audit':'3','dqbh':'3502'} audit :3同意 4拒绝 /// * return结果: {"body":"","code":"0"} NSMutableArray *arr = [NSMutableArray array]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.outId,@"stuOutId", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:audit,@"audit", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.city,@"dqbh", nil]]; NSString *method1 = @"updateStudentChangeSchool"; [jiaPeiManager requestAnythingWithURL:method1 array:arr data:nil completion:^(NSDictionary *dict) { @strongify(self) RemoveHUD(); if ([dict[@"code"] isEqualToString:@"0"]) { [self getData]; } else { ShowMsg(dict[@"msg"]); } }]; } #pragma mark - UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 6; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"]; } switch (indexPath.row) { case 0: { cell.textLabel.text = @"姓名"; cell.detailTextLabel.text = self.studentChangeSchoolModel.TSO_NAME? : @"返回姓名为空"; break; } case 1: { cell.textLabel.text = @"身份证号码"; cell.detailTextLabel.text = self.studentChangeSchoolModel.TSO_IDCARD? : @"返回身份证号码为空"; break; } case 2: { cell.textLabel.text = @"转出驾校"; cell.detailTextLabel.text = self.studentChangeSchoolModel.OUT_SCHOOL? : @"返回转出驾校为空"; break; } case 3: { cell.textLabel.text = @"转入驾校"; cell.detailTextLabel.text = self.studentChangeSchoolModel.IN_SCHOOL? : @"返回转入驾校为空"; break; } case 4: { cell.textLabel.text = @"管理部门审核情况"; cell.detailTextLabel.text = (self.studentChangeSchoolModel.SCS_AUDIT_VIEW == ScsAuditViewType_Wait)? @"待审核" : ((self.studentChangeSchoolModel.SCS_AUDIT_VIEW == ScsAuditViewType_Pass)? @"审核通过" : ((self.studentChangeSchoolModel.SCS_AUDIT_VIEW == ScsAuditViewType_Return)? @"审核未通过" : @"暂无审核状态")) ; break; } case 5: { cell.textLabel.text = @"转校进度"; switch (self.studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT) { /// 学员待确认 case ScsInSchoolAudit_Wait: cell.detailTextLabel.text = @"学员待确认"; break; /// 驾校同意 case ScsInSchoolAudit_SchAllow: cell.detailTextLabel.text = @"驾校同意"; break; /// 驾校不接收 case ScsInSchoolAudit_SchRefuse: cell.detailTextLabel.text = @"驾校不接收"; break; /// 学员同意 case ScsInSchoolAudit_StuAllow: cell.detailTextLabel.text = @"学员同意"; break; /// 学员拒绝 case ScsInSchoolAudit_StuRefuse: cell.detailTextLabel.text = @"学员拒绝"; break; default: cell.detailTextLabel.text = @"未知进度"; break; } break; } default: break; } return cell; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [UIView new]; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { return [UIView new]; } - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section { return 0.01; } - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section { return 0.01; } #pragma mark - LazyLoad - (StudentChangeSchoolModel *)studentChangeSchoolModel { if (!_studentChangeSchoolModel) { _studentChangeSchoolModel = [[StudentChangeSchoolModel alloc] init]; _studentChangeSchoolModel.TSO_NAME = @"本地数据-张三"; _studentChangeSchoolModel.TSO_IDCARD = @"本地数据-3501**********1234"; _studentChangeSchoolModel.OUT_SCHOOL = @"本地数据-驾校A"; _studentChangeSchoolModel.IN_SCHOOL = @"本地数据-驾校B"; _studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT = ScsInSchoolAudit_Default; _studentChangeSchoolModel.SCS_AUDIT_VIEW = ScsAuditViewType_Default; self.SCS_IN_SCHOOL_AUDIT = _studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT; } return _studentChangeSchoolModel; } @end