StudentDetail.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. //
  2. // StudentDetail.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/10.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "StudentDetail.h"
  9. #import "TeachLogCell.h"
  10. #import "SignsCell.h"
  11. #import "ShenHeCell.h"
  12. @interface StudentDetail ()
  13. {
  14. NSArray *_teachLogDataArr;//教学日志
  15. NSArray *_signDataArr;// 签到记录
  16. NSArray *_shenheDataArr;//审核记录
  17. HolderView * _holderV1;
  18. HolderView * _holderV2;
  19. HolderView * _holderV3;
  20. }
  21. @end
  22. @implementation StudentDetail
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.navigationItem.title = @"学员详情";
  26. _teachLogDataArr = [[NSArray alloc]init];
  27. _signDataArr = [[NSArray alloc]init];
  28. _shenheDataArr = [[NSArray alloc]init];
  29. [self setSegmentControllWithTitles:@[@"基本信息",@"教学日志",@"签到记录",@"审核记录",@"培训记录表"]];
  30. // 第一次进来请求除基本信息[由上一级传进来(含培训记录表)]以外的数据
  31. [self getTrainTimesRecords];
  32. [self getStudentSigns];
  33. [self getStudentAuditRecords];
  34. UITableView * tabV = _tableViews[1];
  35. _holderV1 = [[HolderView alloc] initWithFrame:tabV.frame];
  36. _holderV1.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT;
  37. [_holderV1 freshBlock:^{
  38. [self getTrainTimesRecords];
  39. }];
  40. [_mainScroolView addSubview:_holderV1];
  41. UITableView * tabV2 = _tableViews[2];
  42. _holderV2 = [[HolderView alloc] initWithFrame:tabV2.frame];
  43. _holderV2.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT;
  44. [_holderV2 freshBlock:^{
  45. [self getStudentSigns];
  46. }];
  47. [_mainScroolView addSubview:_holderV2];
  48. UITableView * tabV3 = _tableViews[3];
  49. _holderV3 = [[HolderView alloc] initWithFrame:tabV3.frame];
  50. _holderV3.y -= JOb_DETAIL_BOTTOMBAR_HEIGHT;
  51. [_holderV3 freshBlock:^{
  52. [self getStudentAuditRecords];
  53. }];
  54. [_mainScroolView addSubview:_holderV3];
  55. }
  56. -(void)setData{
  57. _keysArr = @[
  58. // @[@"所属机构",@""],
  59. @[@"证件类型",@"TSO_CARDTYPE"],
  60. @[@"证件号码",@"TSO_IDCARD"],
  61. @[@"姓名",@"TSO_NAME"],
  62. @[@"性别",@"TSO_SEX"],
  63. @[@"手机号码",@"TSO_PHONE"],
  64. // @[@"来源(推荐人)",@""],
  65. @[@"国籍",@"TSO_NATIONALITY"],
  66. @[@"业务类型",@"TSO_BUSITYPE"],
  67. @[@"培训车型",@"TSO_TRAINTYPE"],
  68. @[@"原准驾车型",@"TSO_PERDRITYPE"],
  69. @[@"驾驶证号",@"TSO_DRILICNUM"],
  70. @[@"驾驶证初领日期",@"TSO_FSTDRILICDATE"],
  71. @[@"报名日期",@"TSO_APPLYDATE"],
  72. @[@"联系地址",@"TSO_ADDRESS"],
  73. @[@"全国统一编号",@"TSO_STUNUM"],
  74. // @[@"备案时间",@""]
  75. ];
  76. [super setData];
  77. }
  78. #pragma mark 重写代理方法
  79. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  80. NSInteger index = [_tableViews indexOfObject:tableView];
  81. if (index == 1) {
  82. return _teachLogDataArr.count;
  83. }else if (index == 2){
  84. return _signDataArr.count;
  85. }else if (index == 3){
  86. return _shenheDataArr.count;
  87. }else if (index == 4){
  88. return 1;
  89. }
  90. return [_keysArr count];
  91. }
  92. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  93. NSInteger index = [_tableViews indexOfObject:tableView];
  94. if (index == 1) {
  95. return 150;
  96. }
  97. if (index == 2){
  98. return 44;
  99. }
  100. if (index == 3){
  101. return 44;
  102. }
  103. if (index == 4){
  104. return tableView.height;
  105. }
  106. return [super tableView:tableView heightForRowAtIndexPath:indexPath];
  107. }
  108. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  109. {
  110. NSInteger index = [_tableViews indexOfObject:tableView];
  111. if (index == 1) {
  112. TeachLogCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellTeach"];
  113. if (!cell) {
  114. //加载xib文件创建cell
  115. cell = [[[NSBundle mainBundle] loadNibNamed:@"TeachLogCell" owner:nil options:nil] lastObject];
  116. }
  117. [cell setDataWithDic:_teachLogDataArr[indexPath.row]];
  118. return cell;
  119. }
  120. if (index == 2) {
  121. SignsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellSign"];
  122. if (!cell) {
  123. //加载xib文件创建cell
  124. cell = [[[NSBundle mainBundle] loadNibNamed:@"SignsCell" owner:nil options:nil] lastObject];
  125. }
  126. [cell updataWithDic:_signDataArr[indexPath.row]];
  127. return cell;
  128. }
  129. if (index == 3) {
  130. ShenHeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellTShenhe"];
  131. if (!cell) {
  132. //加载xib文件创建cell
  133. cell = [[[NSBundle mainBundle] loadNibNamed:@"ShenHeCell" owner:nil options:nil] lastObject];
  134. }
  135. [cell updataWithDic:_shenheDataArr[indexPath.row]];
  136. return cell;
  137. }
  138. if (index == 4) {
  139. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pxjlbCellId"];
  140. if (!cell) {
  141. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pxjlbCellId"];
  142. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  143. }
  144. //培训记录表
  145. if ([self.dataSource[@"PDFPATH"] length] > 0) {
  146. UIWebView *webV = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-JOb_DETAIL_SEGBAR_HEIGHT-kNavOffSet)];
  147. //
  148. webV.multipleTouchEnabled=YES;
  149. webV.userInteractionEnabled=YES;
  150. [cell.contentView addSubview:webV];
  151. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.dataSource[@"PDFPATH"]]];
  152. [webV loadRequest:request];
  153. }else{
  154. cell.textLabel.text = @"暂无数据";
  155. cell.textLabel.textAlignment = NSTextAlignmentCenter;
  156. }
  157. return cell;
  158. }
  159. //index == 0
  160. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  161. if (!cell) {
  162. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
  163. }
  164. if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
  165. cell.detailTextLabel.numberOfLines = 0;
  166. cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
  167. }else{
  168. cell.detailTextLabel.numberOfLines = 1;
  169. cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
  170. }
  171. NSString * key = _keysArr[indexPath.row][1];
  172. cell.textLabel.text = _keysArr[indexPath.row][0];
  173. if ([key isEqualToString:@"TSO_SEX"]) {
  174. NSString *sex = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  175. cell.detailTextLabel.text = [sex isEqualToString:@"1"] ? @"男" : @"女" ;
  176. }else if ([key isEqualToString:@"TSO_BUSITYPE"]){
  177. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  178. switch ([status integerValue]) {
  179. case 0:
  180. cell.detailTextLabel.text = @"初领";
  181. break;
  182. case 1:
  183. cell.detailTextLabel.text = @"增领";
  184. break;
  185. case 9:
  186. cell.detailTextLabel.text = @"其他";
  187. break;
  188. default:
  189. break;
  190. }
  191. }else if ([key isEqualToString:@"TSO_CARDTYPE"]){
  192. NSString *status = [NSString stringWithFormat:@"%@",self.dataSource[key]];
  193. switch ([status integerValue]) {
  194. case 1:
  195. cell.detailTextLabel.text = @"身份证";
  196. break;
  197. case 2:
  198. cell.detailTextLabel.text = @"护照";
  199. break;
  200. case 3:
  201. cell.detailTextLabel.text = @"军官证";
  202. break;
  203. case 0:
  204. cell.detailTextLabel.text = @"其他";
  205. break;
  206. default:
  207. break;
  208. }
  209. }else{
  210. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",self.dataSource[_keysArr[indexPath.row][1]]];
  211. }
  212. return cell;
  213. }
  214. #pragma mark 数据请求
  215. -(void)getTrainTimesRecords{
  216. //判断网络是否连接
  217. if (![NetworkManager connectedToNetWork]) {
  218. [self showMsgByAlertVCWithString:@"网络连接异常"];
  219. return;
  220. }
  221. [MBProgressHUD hideHUDForView:self.view animated:NO];
  222. [MBProgressHUD showHUDAddedTo:self.view animated:NO];
  223. [NetworkManager requestWithMethod:@"trainTimesRecords" parameters:self.requesetDic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  224. [MBProgressHUD hideHUDForView:self.view animated:YES];
  225. [_holderV1 setHidden:NO];
  226. if (failureStr) {
  227. [self showMsgByAlertVCWithString:failureStr];
  228. return;
  229. }
  230. if ([successDic[@"code"] isEqualToString:@"1"]) {
  231. [self showMsgByAlertVCWithString:successDic[@"msg"]];
  232. return;
  233. }
  234. _teachLogDataArr = successDic[@"body"];
  235. if (_teachLogDataArr.count > 0) {
  236. _holderV1.hidden = YES;
  237. }
  238. [_tableViews[1] reloadData];
  239. }];
  240. }
  241. -(void)getStudentSigns{
  242. //判断网络是否连接
  243. if (![NetworkManager connectedToNetWork]) {
  244. [self showMsgByAlertVCWithString:@"网络连接异常"];
  245. return;
  246. }
  247. NSMutableDictionary * mdic = [NSMutableDictionary new];
  248. [mdic setValue:self.requesetDic[@"stunum"] forKey:@"stunum"];
  249. [mdic setValue:@"" forKey:@"isPage"];
  250. [mdic setValue:@"" forKey:@"pageSize"];
  251. [mdic setValue:@"" forKey:@"currentPage"];
  252. [MBProgressHUD hideHUDForView:self.view animated:NO];
  253. [MBProgressHUD showHUDAddedTo:self.view animated:NO];
  254. [NetworkManager requestWithMethod:@"getStudentSigns" parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  255. [MBProgressHUD hideHUDForView:self.view animated:YES];
  256. [_holderV2 setHidden:NO];
  257. if (failureStr) {
  258. [self showMsgByAlertVCWithString:failureStr];
  259. return;
  260. }
  261. if ([successDic[@"code"] isEqualToString:@"1"]) {
  262. [self showMsgByAlertVCWithString:successDic[@"msg"]];
  263. return;
  264. }
  265. _signDataArr = successDic[@"body"];
  266. if (_signDataArr.count > 0) {
  267. _holderV2.hidden = YES;
  268. }
  269. [_tableViews[2] reloadData];
  270. }];
  271. }
  272. -(void)getStudentAuditRecords{
  273. //判断网络是否连接
  274. if (![NetworkManager connectedToNetWork]) {
  275. [self showMsgByAlertVCWithString:@"网络连接异常"];
  276. return;
  277. }
  278. NSMutableDictionary * mdic = [NSMutableDictionary new];
  279. [mdic setValue:self.requesetDic[@"stunum"] forKey:@"stunum"];
  280. [mdic setValue:@"" forKey:@"isPage"];
  281. [mdic setValue:@"" forKey:@"pageSize"];
  282. [mdic setValue:@"" forKey:@"currentPage"];
  283. [MBProgressHUD hideHUDForView:self.view animated:NO];
  284. [MBProgressHUD showHUDAddedTo:self.view animated:NO];
  285. [NetworkManager requestWithMethod:@"getStudentAuditRecords" parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  286. [MBProgressHUD hideHUDForView:self.view animated:YES];
  287. [_holderV3 setHidden:NO];
  288. if (failureStr) {
  289. [self showMsgByAlertVCWithString:failureStr];
  290. return;
  291. }
  292. if ([successDic[@"code"] isEqualToString:@"1"]) {
  293. [self showMsgByAlertVCWithString:successDic[@"msg"]];
  294. return;
  295. }
  296. _shenheDataArr = successDic[@"body"];
  297. if (_shenheDataArr.count > 0) {
  298. _holderV3.hidden = YES;
  299. }
  300. [_tableViews[3] reloadData];
  301. }];
  302. }
  303. - (void)didReceiveMemoryWarning {
  304. [super didReceiveMemoryWarning];
  305. // Dispose of any resources that can be recreated.
  306. }
  307. /*
  308. #pragma mark - Navigation
  309. // In a storyboard-based application, you will often want to do a little preparation before navigation
  310. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  311. // Get the new view controller using [segue destinationViewController].
  312. // Pass the selected object to the new view controller.
  313. }
  314. */
  315. @end