StudentChangeSchoolVC.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // StudentChangeSchoolVC.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2020/12/1.
  6. // Copyright © 2020 JCZ. All rights reserved.
  7. //
  8. #import "StudentChangeSchoolVC.h"
  9. #import "StudentChangeSchoolModel.h"
  10. @interface StudentChangeSchoolVC () <UITableViewDelegate, UITableViewDataSource>
  11. /// viewModel
  12. @property (nonatomic, readonly, strong) RQStudentChangeSchoolViewModel *viewModel;
  13. @property (nonatomic, readwrite, strong) StudentChangeSchoolModel * studentChangeSchoolModel;
  14. @property (nonatomic , assign) ScsInSchoolAudit SCS_IN_SCHOOL_AUDIT;
  15. @end
  16. @implementation StudentChangeSchoolVC
  17. @dynamic viewModel;
  18. #pragma mark - SystemMethod
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. [self initUI];
  22. }
  23. #pragma mark - Private Functions
  24. - (void)initUI {
  25. @weakify(self)
  26. self.title = @"转校记录";
  27. self.SCS_IN_SCHOOL_AUDIT = ScsInSchoolAudit_Default;
  28. [self configNavigationBar];
  29. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  30. @strongify(self)
  31. [self getData];
  32. }];
  33. [_tableView.mj_header beginRefreshing];
  34. [RACObserve(self, SCS_IN_SCHOOL_AUDIT) subscribeNext:^(id _Nullable x) {
  35. @strongify(self)
  36. self.footerView.hidden = self.SCS_IN_SCHOOL_AUDIT != ScsInSchoolAudit_Wait;
  37. }];
  38. _bottomConst.constant = kSafeAreaBottomHeight;
  39. self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH, CGFLOAT_MIN)];
  40. }
  41. /// 请求数据
  42. - (void)getData {
  43. @weakify(self)
  44. NSMutableArray *arr = [NSMutableArray array];
  45. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  46. [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId];
  47. NSString *method = @"getStudentChangeSchool";
  48. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  49. @strongify(self)
  50. [self.tableView.mj_header endRefreshing];
  51. if (!root) {
  52. ShowMsgFailed();
  53. return;
  54. }
  55. if ([root[@"code"] isEqualToString:@"0"]) {
  56. self.studentChangeSchoolModel = [StudentChangeSchoolModel modelWithDictionary:root[@"body"]];
  57. if (!_studentChangeSchoolModel) {
  58. ShowMsg(@"暂无转校记录!");
  59. [self.navigationController popToRootViewControllerAnimated:YES];
  60. }
  61. self.SCS_IN_SCHOOL_AUDIT = self.studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT;
  62. [self.tableView reloadData];
  63. }else {
  64. if ([root[@"body"] isKindOfClass:[NSString class]]) {
  65. ShowMsg(root[@"body"]);
  66. } else {
  67. ShowMsg(root[@"msg"]);
  68. }
  69. return;
  70. }
  71. }];
  72. }
  73. - (IBAction)confirmAction:(id)sender {
  74. @weakify(self)
  75. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"是否同意转校?" alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:@[@"同意",@"拒绝"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  76. @strongify(self)
  77. switch (selectedOtherButtonIndex) {
  78. case 0:
  79. ///同意
  80. [self updateStudentChangeSchoolWithAudit:@"3"];
  81. break;
  82. case 1:
  83. ///拒绝
  84. [self updateStudentChangeSchoolWithAudit:@"4"];
  85. break;
  86. default:
  87. break;
  88. }
  89. }];
  90. }
  91. - (void)updateStudentChangeSchoolWithAudit:(NSString *)audit {
  92. @weakify(self)
  93. /// * URL=http://192.168.1.6:8082/student/updateStudentChangeSchool?ts={timestamp}&sign={sign_str}&user={cert_sn}
  94. /// * HTTP方法:POST
  95. /// * 报文格式:{'stuOutId':'3502004042','audit':'3','dqbh':'3502'} audit :3同意 4拒绝
  96. /// * return结果: {"body":"","code":"0"}
  97. NSMutableArray *arr = [NSMutableArray array];
  98. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.outId,@"stuOutId", nil]];
  99. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:audit,@"audit", nil]];
  100. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.city,@"dqbh", nil]];
  101. NSString *method1 = @"updateStudentChangeSchool";
  102. [jiaPeiManager requestAnythingWithURL:method1 array:arr data:nil completion:^(NSDictionary *dict) {
  103. @strongify(self)
  104. RemoveHUD();
  105. if ([dict[@"code"] isEqualToString:@"0"]) {
  106. [self getData];
  107. } else {
  108. ShowMsg(dict[@"msg"]);
  109. }
  110. }];
  111. }
  112. #pragma mark - UITableViewDataSource
  113. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  114. return 6;
  115. }
  116. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  117. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
  118. if (!cell) {
  119. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"];
  120. }
  121. switch (indexPath.row) {
  122. case 0: {
  123. cell.textLabel.text = @"姓名";
  124. cell.detailTextLabel.text = self.studentChangeSchoolModel.TSO_NAME? : @"返回姓名为空";
  125. break;
  126. }
  127. case 1: {
  128. cell.textLabel.text = @"身份证号码";
  129. cell.detailTextLabel.text = self.studentChangeSchoolModel.TSO_IDCARD? : @"返回身份证号码为空";
  130. break;
  131. }
  132. case 2: {
  133. cell.textLabel.text = @"转出驾校";
  134. cell.detailTextLabel.text = self.studentChangeSchoolModel.OUT_SCHOOL? : @"返回转出驾校为空";
  135. break;
  136. }
  137. case 3: {
  138. cell.textLabel.text = @"转入驾校";
  139. cell.detailTextLabel.text = self.studentChangeSchoolModel.IN_SCHOOL? : @"返回转入驾校为空";
  140. break;
  141. }
  142. case 4: {
  143. cell.textLabel.text = @"管理部门审核情况";
  144. cell.detailTextLabel.text = (self.studentChangeSchoolModel.SCS_AUDIT_VIEW == ScsAuditViewType_Wait)? @"待审核" : ((self.studentChangeSchoolModel.SCS_AUDIT_VIEW == ScsAuditViewType_Pass)? @"审核通过" : ((self.studentChangeSchoolModel.SCS_AUDIT_VIEW == ScsAuditViewType_Return)? @"审核未通过" : @"暂无审核状态")) ;
  145. break;
  146. }
  147. case 5: {
  148. cell.textLabel.text = @"转校进度";
  149. switch (self.studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT) {
  150. /// 学员待确认
  151. case ScsInSchoolAudit_Wait:
  152. cell.detailTextLabel.text = @"学员待确认";
  153. break;
  154. /// 驾校同意
  155. case ScsInSchoolAudit_SchAllow:
  156. cell.detailTextLabel.text = @"驾校同意";
  157. break;
  158. /// 驾校不接收
  159. case ScsInSchoolAudit_SchRefuse:
  160. cell.detailTextLabel.text = @"驾校不接收";
  161. break;
  162. /// 学员同意
  163. case ScsInSchoolAudit_StuAllow:
  164. cell.detailTextLabel.text = @"学员同意";
  165. break;
  166. /// 学员拒绝
  167. case ScsInSchoolAudit_StuRefuse:
  168. cell.detailTextLabel.text = @"学员拒绝";
  169. break;
  170. default:
  171. cell.detailTextLabel.text = @"未知进度";
  172. break;
  173. }
  174. break;
  175. }
  176. default:
  177. break;
  178. }
  179. return cell;
  180. }
  181. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  182. return [UIView new];
  183. }
  184. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  185. return [UIView new];
  186. }
  187. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section {
  188. return 0.01;
  189. }
  190. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section {
  191. return 0.01;
  192. }
  193. #pragma mark - LazyLoad
  194. - (StudentChangeSchoolModel *)studentChangeSchoolModel {
  195. if (!_studentChangeSchoolModel) {
  196. _studentChangeSchoolModel = [[StudentChangeSchoolModel alloc] init];
  197. _studentChangeSchoolModel.TSO_NAME = @"本地数据-张三";
  198. _studentChangeSchoolModel.TSO_IDCARD = @"本地数据-3501**********1234";
  199. _studentChangeSchoolModel.OUT_SCHOOL = @"本地数据-驾校A";
  200. _studentChangeSchoolModel.IN_SCHOOL = @"本地数据-驾校B";
  201. _studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT = ScsInSchoolAudit_Default;
  202. _studentChangeSchoolModel.SCS_AUDIT_VIEW = ScsAuditViewType_Default;
  203. self.SCS_IN_SCHOOL_AUDIT = _studentChangeSchoolModel.SCS_IN_SCHOOL_AUDIT;
  204. }
  205. return _studentChangeSchoolModel;
  206. }
  207. @end