TrainInfoVC.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. //
  2. // TrainInfoVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/29.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "TrainInfoVC.h"
  9. #import "TrainRecord.h"
  10. #import "TrainDetailVC.h"
  11. #import "TrainInfoTableViewCell.h"
  12. #import "TrainHoursSubTableViewCell.h"
  13. @interface TrainInfoVC ()<UITableViewDataSource,UITableViewDelegate>
  14. {
  15. UITableView *mainTableView;
  16. BOOL isclose[3];
  17. NSArray<NSString *> *totalTimeArray;
  18. NSMutableDictionary *dataDic;
  19. NSDictionary *otherDic;//培训科目是否审核字段
  20. NSMutableArray *timeArray;
  21. NSInteger whichOne;
  22. }
  23. @property (nonatomic, readwrite, assign) NSInteger RATIONKS;
  24. @property (nonatomic, readwrite, copy) NSString *RATIONKSMC;
  25. @end
  26. @implementation TrainInfoVC
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.title = @"我的学时";
  30. self.RATIONKS = 60;
  31. self.view.backgroundColor = backGroundColor;
  32. [self configNavigationBar];
  33. [self myInit];//
  34. [self getStudentStatusByStuOutIdNew];
  35. }
  36. -(void)viewWillAppear:(BOOL)animated{
  37. [super viewWillAppear:animated];
  38. [self clearData];//初始化数据
  39. [self getTotalTrainTime];//获取总需要学时
  40. }
  41. - (void)clearData{
  42. totalTimeArray = [NSArray array];
  43. dataDic = [NSMutableDictionary dictionaryWithCapacity:4];
  44. NSArray *array1 = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:@"1"];
  45. NSArray *array4 = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:@"4"];
  46. if (array4.count < 1) {
  47. array4 = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:@"3"];
  48. }
  49. for (int i = 1; i < 5; i ++) {
  50. NSMutableDictionary *rowDic = [NSMutableDictionary dictionaryWithCapacity:2];
  51. if (i == 1) {
  52. [rowDic setObject:[NSMutableArray arrayWithArray:array1] forKey:@"0"];
  53. [rowDic setObject:[NSMutableArray array] forKey:@"2"];
  54. [rowDic setObject:[NSMutableArray array] forKey:@"3"];
  55. }else if (i == 4) {
  56. [rowDic setObject:[NSMutableArray arrayWithArray:array4] forKey:@"0"];
  57. [rowDic setObject:[NSMutableArray array] forKey:@"2"];
  58. [rowDic setObject:[NSMutableArray array] forKey:@"3"];
  59. }else{
  60. [rowDic setObject:[NSMutableArray array] forKey:@"0"];
  61. }
  62. [rowDic setObject:[NSMutableArray array] forKey:@"1"];
  63. [dataDic setObject:rowDic forKey:[NSString stringWithFormat:@"%d",i]];
  64. }
  65. }
  66. -(void)setTotalTimeArray
  67. {
  68. /*
  69. 科目一理论
  70. 科目二模拟
  71. 科目二实操
  72. 科目三模拟
  73. 科目三实操
  74. 科目三理论
  75. 科目四理论
  76. 资格证是没有的
  77. @"小车",@"C1",@"货车",@"A2",@"客车",@"A1",@"摩托车",@"D",
  78. @"教练",@"4",@"客运",@"1",@"货运",@"2",@"危险品",@"3",@"出租车",@"5"
  79. */
  80. if ([RQ_USER_MANAGER.currentUser.carType isEqualToString:@"C1"]) {
  81. totalTimeArray = @[@"720",@"240",@"720",@"240",@"1200",@"600"];
  82. }else if ([RQ_USER_MANAGER.currentUser.carType isEqualToString:@"A2"]){
  83. totalTimeArray = @[@"600",@"120",@"2280",@"240",@"1080",@"960"];
  84. }else if ([RQ_USER_MANAGER.currentUser.carType isEqualToString:@"A1"]){
  85. totalTimeArray = @[@"600",@"240",@"1920",@"240",@"960",@"960"];
  86. }else if ([RQ_USER_MANAGER.currentUser.carType isEqualToString:@"D"]){
  87. totalTimeArray = @[@"600",@"120",@"480",@"120",@"480",@"480"];
  88. }else{
  89. totalTimeArray = @[@"0",@"0",@"0",@"0",@"0",@"0"];
  90. }
  91. }
  92. -(void)myInit
  93. {
  94. mainTableView = [[UITableView alloc] initWithFrame:kFrame];
  95. mainTableView.height -= kNavOffSet;
  96. mainTableView.delegate = self;
  97. mainTableView.dataSource = self;
  98. mainTableView.estimatedSectionFooterHeight = 0;
  99. mainTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  100. [self.view addSubview:mainTableView];
  101. [mainTableView registerNib:[UINib nibWithNibName:@"TrainHoursSubTableViewCell" bundle:nil] forCellReuseIdentifier:@"TrainHoursSubTableViewCell"];
  102. }
  103. #pragma mark 数据请求
  104. //获取总需学时
  105. -(void)getTotalTrainTime
  106. {
  107. if (![Util connectedToNetWork]) {
  108. showMsgUnconnect();
  109. return;
  110. }
  111. NSMutableArray* arr = [NSMutableArray array];
  112. [arr addPro:@"cx" Value:RQ_USER_MANAGER.currentUser.carType];
  113. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  114. NSString* method = @"getTrainSubjectCredit";
  115. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  116. if (!root || [root[@"code"] intValue] == 1)
  117. {
  118. [self setTotalTimeArray];
  119. [self getTrainInfo];//获取已完成学时
  120. return;
  121. }
  122. if (!RQObjectIsNil(root[@"other"])) {
  123. if ([root[@"other"] isKindOfClass:[NSDictionary class]]) {
  124. NSDictionary *dic = root[@"other"];
  125. if (!RQObjectIsNil(dic[@"KS"])) {
  126. NSInteger KS = [dic[@"KS"] integerValue];
  127. _RATIONKS = KS;
  128. }
  129. if (!RQObjectIsNil(dic[@"KSMC"])) {
  130. NSString *KSMC = [NSString stringWithFormat:@"%@",dic[@"KSMC"]];
  131. _RATIONKSMC = KSMC;
  132. }
  133. }
  134. }
  135. NSArray *array = root[@"body"];//@[@"720",@"240",@"720",@"240",@"1200",@"600"];
  136. NSMutableArray *totalArray = [NSMutableArray array];
  137. for (int i = 1; i < 7; i ++) {
  138. for (NSDictionary *dic in array) {
  139. if ([dic[@"SUBJECT"] intValue] == i) {
  140. [totalArray addObject:dic[@"RATION"]];
  141. }
  142. }
  143. }
  144. totalTimeArray = nil;
  145. totalTimeArray = [NSArray arrayWithArray:totalArray];
  146. [self getTrainInfo];//获取已完成学时
  147. }];
  148. }
  149. //获取计时信息
  150. - (void)getTrainInfo {
  151. [LoadingView showHUD];
  152. if (![Util connectedToNetWork]) {
  153. showMsgUnconnect();
  154. return;
  155. }
  156. NSMutableArray* arr = [NSMutableArray array];
  157. [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId];
  158. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  159. NSString* method = @"getTrainFinishNew";
  160. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  161. RemoveHUD();
  162. if (!root || [root[@"code"] intValue] != 0) {
  163. if ([root[@"body"] isKindOfClass:[NSString class]] && ![root[@"body"] isEqualToString:@""]) {
  164. ShowMsg(root[@"body"]);
  165. }else {
  166. ShowMsg(root[@"msg"]);
  167. }
  168. [mainTableView reloadData];
  169. return;
  170. }
  171. if ([root[@"body"] isKindOfClass:[NSArray class]] && [(NSArray *)root[@"body"] count] < 1)
  172. {
  173. [mainTableView reloadData];
  174. return;
  175. }
  176. NSArray *arr = root[@"body"];
  177. otherDic = root[@"other"];
  178. /*
  179. CRI_VAILD_TIME:有效学时
  180. CRI_TRAIN_SUBJECT:学时阶段 1-4
  181. CRI_DURATION:培训学时
  182. PXKMTYPE:1实操 2课堂教练 3模拟器教学 4远程教练(理论)
  183. TCI_PHOTO_PATH:教练员照片
  184. TCI_NAME:教练名称
  185. CRI_STARTTIME:开始时间
  186. CRI_ENDTIME:结束时间
  187. */
  188. for (NSDictionary *dic in arr) {
  189. //解析数据
  190. switch ([dic[@"PXKMTYPE"] integerValue]) {
  191. case 1:
  192. {
  193. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"1"] addObject:dic];
  194. }
  195. break;
  196. case 2://科一/四 终端理论学时
  197. {
  198. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"2"] addObject:dic];
  199. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"3"] addObject:dic];
  200. }
  201. break;
  202. case 3:
  203. {
  204. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"0"] addObject:dic];
  205. }
  206. break;
  207. case 4:
  208. {
  209. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"1"] addObject:dic];
  210. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"3"] addObject:dic];
  211. }
  212. break;
  213. default:
  214. break;
  215. }
  216. }
  217. [mainTableView reloadData];
  218. }];
  219. }
  220. - (void)getStudentStatusByStuOutIdNew {
  221. if (![Util connectedToNetWork]) {
  222. ShowMsg(@"请检查网络连接。");
  223. RemoveHUD();
  224. return;
  225. }
  226. NSMutableArray *arr = [NSMutableArray array];
  227. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuOutId"];
  228. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  229. NSString* method = @"getStudentStatusByStuOutIdNew";
  230. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  231. RemoveHUD();
  232. if (!dict) {
  233. ShowMsgFailed();
  234. return;
  235. }
  236. if ([dict[@"code"] intValue] != 1) {
  237. if ([(NSString *)dict[@"body"][@"history"] isEqualToString:@"1"]) {
  238. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"2019年之前报名前的旧系统学员,送审即在旧系统送审。此界面仅做参考。详情请咨询驾校工作人员" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  239. }
  240. }else {
  241. if (dict[@"body"] && [dict[@"body"] isKindOfClass:[NSString class]]) {
  242. if (![(NSString *)dict[@"body"] isEqualToString:@""]) {
  243. ShowMsg([NSString stringWithFormat:@"%@",dict[@"body"]]);
  244. }else {
  245. ShowMsg(@"暂无返回消息");
  246. }
  247. }else {
  248. ShowMsg(dict[@"msg"]);
  249. }
  250. }
  251. }];
  252. }
  253. #pragma mark tableView delegate
  254. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  255. return 4;
  256. }
  257. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  258. if (RQ_USER_MANAGER.isycbd) {
  259. /// 开启远程教育(人脸远程比对)
  260. return (isclose[section])? 0 : ((section == 0 || section == 3)? 4 : 2);
  261. } else {
  262. return (isclose[section])? 0 : 2;
  263. }
  264. }
  265. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  266. {
  267. NSString *section = [NSString stringWithFormat:@"%d",(int)indexPath.section + 1];
  268. NSString *row = [NSString stringWithFormat:@"%d",(int)indexPath.row];
  269. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:section] objectForKey:row];
  270. if ((indexPath.section == 0 || indexPath.section == 3) && indexPath.row == 0) {
  271. //本地学时
  272. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  273. if (cell == nil)
  274. {
  275. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  276. cell.backgroundColor = backGroundColor;
  277. cell.x += 20;
  278. cell.width -= 20;
  279. cell.textLabel.font = [UIFont scaleSize:FontTitle];
  280. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  281. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  282. }
  283. __block int time = 0;
  284. [[rowArray.rac_sequence.signal filter:^BOOL(id _Nullable value) {
  285. return [value isKindOfClass:[TrainRecord class]];
  286. }] subscribeNext:^(TrainRecord *train) {
  287. time += [train.trainTime intValue];
  288. }] ;
  289. int hour = time/(_RATIONKS? : 60);
  290. int min = time%(_RATIONKS? : 60);
  291. NSString *dbTime = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
  292. if (hour == 0)
  293. {
  294. dbTime = [NSString stringWithFormat:@"%d分钟",min];
  295. if (min == 0) {
  296. dbTime = @"0分钟";
  297. }
  298. }
  299. if (time != 0) {
  300. cell.textLabel.text = [NSString stringWithFormat:@"理论(未上传) %@",dbTime];
  301. }else {
  302. cell.textLabel.text = [NSString stringWithFormat:@"学时已全部上传"];
  303. }
  304. return cell;
  305. } else {
  306. TrainHoursSubTableViewCell *trainHoursSubTableViewCell = [tableView dequeueReusableCellWithIdentifier:@"TrainHoursSubTableViewCell"];
  307. if (!trainHoursSubTableViewCell) {
  308. trainHoursSubTableViewCell = [[NSBundle mainBundle] loadNibNamed:@"TrainHoursSubTableViewCell" owner:self options:nil].firstObject;
  309. }
  310. TrainInfoTableViewCell *trainInfoTableViewCell = [TrainInfoTableViewCell cellForTabelView:tableView];
  311. trainInfoTableViewCell.RATIONKS = _RATIONKS;
  312. trainInfoTableViewCell.RATIONKSMC = _RATIONKSMC;
  313. switch (indexPath.section) {
  314. case 0:
  315. case 3: {
  316. switch (indexPath.row) {
  317. case 1: {
  318. if (RQ_USER_MANAGER.isycbd) {
  319. /// 开启远程教育(人脸远程比对)
  320. trainHoursSubTableViewCell.thoryHoursLabel.text = @"远程教育(理论)";
  321. NSString *totalTimeString = [self getTotalTime:rowArray];
  322. trainHoursSubTableViewCell.classHoursLabel.text = [NSString stringWithFormat:@"已完成%@",totalTimeString];
  323. return trainHoursSubTableViewCell;
  324. } else {
  325. trainInfoTableViewCell.titleString = @"理论";
  326. trainInfoTableViewCell.allNeedTime = [(indexPath.section == 0)? (totalTimeArray.firstObject? : @"720") : (totalTimeArray.lastObject? : @"600") integerValue];
  327. trainInfoTableViewCell.dataArray = rowArray;
  328. return trainInfoTableViewCell;
  329. }
  330. }
  331. case 2: {
  332. trainHoursSubTableViewCell.thoryHoursLabel.text = @"课堂教育(理论)";
  333. NSString *totalTimeString = [self getTotalTime:rowArray];
  334. trainHoursSubTableViewCell.classHoursLabel.text = [NSString stringWithFormat:@"已完成%@",totalTimeString];
  335. return trainHoursSubTableViewCell;
  336. }
  337. case 3: {
  338. trainInfoTableViewCell.titleString = @"理论";
  339. trainInfoTableViewCell.allNeedTime = [(indexPath.section == 0)? (totalTimeArray.firstObject? : @"720") : (totalTimeArray.lastObject? : @"600") integerValue];
  340. trainInfoTableViewCell.dataArray = rowArray;
  341. return trainInfoTableViewCell;
  342. }
  343. default:
  344. return trainInfoTableViewCell;
  345. }
  346. case 1:
  347. case 2: {
  348. NSInteger index = indexPath.section * 2 + indexPath.row - 1;
  349. NSString *allTimeString = @"720";
  350. if (totalTimeArray.count > index) {
  351. allTimeString = totalTimeArray[index];
  352. }
  353. trainInfoTableViewCell.titleString = indexPath.row == 0? @"模拟" : @"实操";
  354. trainInfoTableViewCell.allNeedTime = [allTimeString integerValue];
  355. trainInfoTableViewCell.dataArray = rowArray;
  356. return trainInfoTableViewCell;
  357. }
  358. return trainInfoTableViewCell;
  359. }
  360. default:
  361. return trainInfoTableViewCell;
  362. }
  363. }
  364. }
  365. -(NSString *)getTotalTime:(NSMutableArray *)array
  366. {
  367. if ([array count] < 1)
  368. {
  369. return @"0分钟";
  370. }
  371. int time = 0;
  372. for (NSDictionary *dic in array)
  373. {
  374. time += [dic[@"CRI_DURATION"] intValue];//CRI_VAILD_TIME
  375. }
  376. int hour = time/(_RATIONKS? : 60);
  377. int min = time%(_RATIONKS? : 60);
  378. NSString *timeString = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
  379. if (hour == 0)
  380. {
  381. timeString = [NSString stringWithFormat:@"%d分钟",min];
  382. }
  383. return timeString;
  384. }
  385. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  386. {
  387. UIView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headview"];
  388. if (!view) {
  389. view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
  390. view.backgroundColor = backGroundColor;
  391. view.layer.borderWidth = .5;
  392. view.layer.borderColor = RQlineColor.CGColor;
  393. //科目
  394. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 120, 50)];
  395. label.tag = 1;
  396. [view addSubview:label];
  397. //审核通过 未审核
  398. label = [[UILabel alloc] initWithFrame:CGRectMake(200, 0, 120, 50)];
  399. label.tag = 2;
  400. [label setText:@"" Font:FontTitle TextColor:[UIColor redColor] Alignment:NSTextAlignmentCenter];
  401. [view addSubview:label];
  402. UIImageView *secImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 15, 20, 20)];
  403. secImage.image = [UIImage imageNamed:@"location_more_arrow"];
  404. [view addSubview:secImage];
  405. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
  406. [btn addTarget:self action:@selector(clickToChange:) forControlEvents:UIControlEventTouchUpInside];
  407. [view addSubview:btn];
  408. }
  409. for (UIView *subview in view.subviews) {
  410. if ([subview isKindOfClass:[UILabel class]]) {
  411. UILabel *label = (UILabel *)subview;
  412. if (label.tag == 1) {
  413. if (section == 0)
  414. {
  415. label.text = @"科目一";
  416. }
  417. if (section == 1)
  418. {
  419. label.text = @"科目二";
  420. }
  421. if (section == 2)
  422. {
  423. label.text = @"科目三";
  424. }
  425. if (section == 3)
  426. {
  427. label.text = @"科目四";
  428. }
  429. }
  430. if (label.tag == 2) {
  431. if ([otherDic isKindOfClass:[NSDictionary class]]) {
  432. if (section == 0)
  433. {
  434. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"1"] objectForKey:@"1"];
  435. if (rowArray.count > 0) {
  436. if ([otherDic[@"SRI_TRAIN_ONE_STATUS"] integerValue] == 2) {
  437. label.text = @"审核通过";
  438. label.textColor = RQ_MAIN_COLOR;
  439. }else {
  440. label.text = @"未审核";
  441. label.textColor = [UIColor redColor];
  442. }
  443. }else {
  444. label.text = @"";
  445. }
  446. }
  447. if (section == 1)
  448. {
  449. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"2"] objectForKey:@"0"];
  450. if (rowArray.count > 0) {
  451. if ([otherDic[@"SRI_TRAIN_TWO_STATUS"] integerValue] == 2) {
  452. label.text = @"审核通过";
  453. label.textColor = RQ_MAIN_COLOR;
  454. }else {
  455. label.text = @"未审核";
  456. label.textColor = [UIColor redColor];
  457. }
  458. }else {
  459. label.text = @"";
  460. }
  461. }
  462. if (section == 2)
  463. {
  464. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"3"] objectForKey:@"0"];
  465. if (rowArray.count > 0) {
  466. if ([otherDic[@"SRI_TRAIN_THREE_STATUS"] integerValue] == 2) {
  467. label.text = @"审核通过";
  468. label.textColor = RQ_MAIN_COLOR;
  469. }else {
  470. label.text = @"未审核";
  471. label.textColor = [UIColor redColor];
  472. }
  473. }else {
  474. label.text = @"";
  475. }
  476. }
  477. if (section == 3)
  478. {
  479. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"4"] objectForKey:@"1"];
  480. if (rowArray.count > 0) {
  481. if ([otherDic[@"SRI_TRAIN_FOUR_STATUS"] integerValue] == 2) {
  482. label.text = @"审核通过";
  483. label.textColor = RQ_MAIN_COLOR;
  484. }else {
  485. label.text = @"未审核";
  486. label.textColor = [UIColor redColor];
  487. }
  488. }else {
  489. label.text = @"";
  490. }
  491. }
  492. }else {
  493. label.text = @"";
  494. }
  495. }
  496. }
  497. if ([subview isKindOfClass:[UIImageView class]]) {
  498. UIImageView *secImage = (UIImageView *)subview;
  499. secImage.transform = isclose[section] == NO?CGAffineTransformMakeRotation(M_PI):CGAffineTransformIdentity;
  500. }
  501. if ([subview isKindOfClass:[UIButton class]]) {
  502. UIButton *btn = (UIButton *)subview;
  503. btn.tag = section;
  504. }
  505. }
  506. return view;
  507. }
  508. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  509. {
  510. if ((indexPath.section == 0 || indexPath.section == 3) && indexPath.row == 0) {
  511. return 45;
  512. }else{
  513. return 80;
  514. }
  515. }
  516. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  517. {
  518. return 50;
  519. }
  520. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  521. {
  522. return .1;
  523. }
  524. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  525. {
  526. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:[NSString stringWithFormat:@"%d",(int)indexPath.section + 1]] objectForKey:[NSString stringWithFormat:@"%d",(int)indexPath.row]];
  527. TrainDetailVC *detail = [[TrainDetailVC alloc] init];
  528. detail.RATIONKS = _RATIONKS;
  529. detail.RATIONKSMC = _RATIONKSMC;
  530. if (RQ_USER_MANAGER.isycbd == 1) {
  531. __block NSInteger trainTime = 0;
  532. if (rowArray.count > 0 && [rowArray.firstObject isKindOfClass:[TrainRecord class]]) {
  533. [rowArray.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
  534. trainTime = trainTime + record.trainTime.integerValue;
  535. } completed:^{
  536. if (trainTime >= 30) {
  537. detail.datasourceArray = rowArray;
  538. }
  539. }];
  540. } else {
  541. detail.datasourceArray = rowArray;
  542. }
  543. } else {
  544. detail.datasourceArray = rowArray;
  545. }
  546. detail.type = @"2";
  547. if ((indexPath.section == 0 || indexPath.section == 3) && indexPath.row == 0) {
  548. //本地的学时 要上传
  549. detail.type = @"1";
  550. }
  551. [self navPushHideTabbarToVC:detail];
  552. }
  553. - (void)clickToChange:(UIButton *)sender
  554. {
  555. isclose[sender.tag] = !isclose[sender.tag];
  556. [mainTableView reloadData];
  557. }
  558. - (void)didReceiveMemoryWarning {
  559. [super didReceiveMemoryWarning];
  560. // Dispose of any resources that can be recreated.
  561. }
  562. @end