TrainInfoVC.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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. [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser.outId];
  115. NSString* method = @"getTrainSubjectCredit";
  116. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  117. if (!root || [root[@"code"] intValue] == 1)
  118. {
  119. [self setTotalTimeArray];
  120. [self getTrainInfo];//获取已完成学时
  121. return;
  122. }
  123. if (!RQObjectIsNil(root[@"other"])) {
  124. if ([root[@"other"] isKindOfClass:[NSDictionary class]]) {
  125. NSDictionary *dic = root[@"other"];
  126. if (!RQObjectIsNil(dic[@"KS"])) {
  127. NSInteger KS = [dic[@"KS"] integerValue];
  128. _RATIONKS = KS;
  129. }
  130. if (!RQObjectIsNil(dic[@"KSMC"])) {
  131. NSString *KSMC = [NSString stringWithFormat:@"%@",dic[@"KSMC"]];
  132. _RATIONKSMC = KSMC;
  133. }
  134. }
  135. }
  136. NSArray *array = root[@"body"];//@[@"720",@"240",@"720",@"240",@"1200",@"600"];
  137. NSMutableArray *totalArray = [NSMutableArray array];
  138. for (int i = 1; i < 7; i ++) {
  139. for (NSDictionary *dic in array) {
  140. if ([dic[@"SUBJECT"] intValue] == i) {
  141. [totalArray addObject:dic[@"RATION"]];
  142. }
  143. }
  144. }
  145. totalTimeArray = nil;
  146. totalTimeArray = [NSArray arrayWithArray:totalArray];
  147. [self getTrainInfo];//获取已完成学时
  148. }];
  149. }
  150. //获取计时信息
  151. - (void)getTrainInfo {
  152. [LoadingView showHUD];
  153. if (![Util connectedToNetWork]) {
  154. showMsgUnconnect();
  155. return;
  156. }
  157. NSMutableArray* arr = [NSMutableArray array];
  158. [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId];
  159. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  160. NSString* method = @"getTrainFinishNew";
  161. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  162. RemoveHUD();
  163. if (!root || [root[@"code"] intValue] != 0) {
  164. if ([root[@"body"] isKindOfClass:[NSString class]] && ![root[@"body"] isEqualToString:@""]) {
  165. ShowMsg(root[@"body"]);
  166. }else {
  167. ShowMsg(root[@"msg"]);
  168. }
  169. [mainTableView reloadData];
  170. return;
  171. }
  172. if ([root[@"body"] isKindOfClass:[NSArray class]] && [(NSArray *)root[@"body"] count] < 1)
  173. {
  174. [mainTableView reloadData];
  175. return;
  176. }
  177. NSArray *arr = root[@"body"];
  178. otherDic = root[@"other"];
  179. /*
  180. CRI_VAILD_TIME:有效学时
  181. CRI_TRAIN_SUBJECT:学时阶段 1-4
  182. CRI_DURATION:培训学时
  183. PXKMTYPE:1实操 2课堂教练 3模拟器教学 4远程教练(理论)
  184. TCI_PHOTO_PATH:教练员照片
  185. TCI_NAME:教练名称
  186. CRI_STARTTIME:开始时间
  187. CRI_ENDTIME:结束时间
  188. */
  189. for (NSDictionary *dic in arr) {
  190. //解析数据
  191. switch ([dic[@"PXKMTYPE"] integerValue]) {
  192. case 1:
  193. {
  194. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"1"] addObject:dic];
  195. }
  196. break;
  197. case 2://科一/四 终端理论学时
  198. {
  199. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"2"] addObject:dic];
  200. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"3"] addObject:dic];
  201. }
  202. break;
  203. case 3:
  204. {
  205. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"0"] addObject:dic];
  206. }
  207. break;
  208. case 4:
  209. {
  210. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"1"] addObject:dic];
  211. [[[dataDic objectForKey:dic[@"CRI_TRAIN_SUBJECT"]] objectForKey:@"3"] addObject:dic];
  212. }
  213. break;
  214. default:
  215. break;
  216. }
  217. }
  218. [mainTableView reloadData];
  219. }];
  220. }
  221. - (void)getStudentStatusByStuOutIdNew {
  222. if (![Util connectedToNetWork]) {
  223. ShowMsg(@"请检查网络连接。");
  224. RemoveHUD();
  225. return;
  226. }
  227. NSMutableArray *arr = [NSMutableArray array];
  228. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuOutId"];
  229. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  230. NSString* method = @"getStudentStatusByStuOutIdNew";
  231. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  232. RemoveHUD();
  233. if (!dict) {
  234. ShowMsgFailed();
  235. return;
  236. }
  237. if ([dict[@"code"] intValue] != 1) {
  238. if ([(NSString *)dict[@"body"][@"history"] isEqualToString:@"1"]) {
  239. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"2019年之前报名前的旧系统学员,送审即在旧系统送审。此界面仅做参考。详情请咨询驾校工作人员" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  240. }
  241. }else {
  242. if (dict[@"body"] && [dict[@"body"] isKindOfClass:[NSString class]]) {
  243. if (![(NSString *)dict[@"body"] isEqualToString:@""]) {
  244. ShowMsg([NSString stringWithFormat:@"%@",dict[@"body"]]);
  245. }else {
  246. ShowMsg(@"暂无返回消息");
  247. }
  248. }else {
  249. ShowMsg(dict[@"msg"]);
  250. }
  251. }
  252. }];
  253. }
  254. #pragma mark tableView delegate
  255. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  256. return 4;
  257. }
  258. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  259. NSInteger count = 0;
  260. if (RQ_USER_MANAGER.isycbd) {
  261. /// 开启远程教育(人脸远程比对)
  262. count = (isclose[section])? 0 : ((section == 0 || section == 3)? 4 : 3);
  263. } else {
  264. count = (isclose[section])? 0 : ((section == 0 || section == 3)? 4 : 3);
  265. }
  266. return count;
  267. }
  268. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  269. {
  270. NSString *section = [NSString stringWithFormat:@"%d",(int)indexPath.section + 1];
  271. NSString *row = [NSString stringWithFormat:@"%d",(int)indexPath.row];
  272. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:section] objectForKey:row];
  273. if ((indexPath.section == 0 || indexPath.section == 3) && indexPath.row == 0) {
  274. //本地学时
  275. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  276. if (cell == nil)
  277. {
  278. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  279. cell.backgroundColor = backGroundColor;
  280. cell.x += 20;
  281. cell.width -= 20;
  282. cell.textLabel.font = [UIFont scaleSize:FontTitle];
  283. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  284. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  285. }
  286. __block int time = 0;
  287. [[rowArray.rac_sequence.signal filter:^BOOL(id _Nullable value) {
  288. return [value isKindOfClass:[TrainRecord class]];
  289. }] subscribeNext:^(TrainRecord *train) {
  290. time += [train.trainTime intValue];
  291. }] ;
  292. int hour = time/(_RATIONKS? : 60);
  293. int min = time%(_RATIONKS? : 60);
  294. NSString *dbTime = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
  295. if (hour == 0)
  296. {
  297. dbTime = [NSString stringWithFormat:@"%d分钟",min];
  298. if (min == 0) {
  299. dbTime = @"0分钟";
  300. }
  301. }
  302. if (time != 0) {
  303. cell.textLabel.text = [NSString stringWithFormat:@"理论(未上传) %@",dbTime];
  304. }else {
  305. cell.textLabel.text = [NSString stringWithFormat:@"学时已全部上传"];
  306. }
  307. return cell;
  308. } else {
  309. TrainHoursSubTableViewCell *trainHoursSubTableViewCell = [tableView dequeueReusableCellWithIdentifier:@"TrainHoursSubTableViewCell"];
  310. if (!trainHoursSubTableViewCell) {
  311. trainHoursSubTableViewCell = [[NSBundle mainBundle] loadNibNamed:@"TrainHoursSubTableViewCell" owner:self options:nil].firstObject;
  312. }
  313. TrainInfoTableViewCell *trainInfoTableViewCell = [TrainInfoTableViewCell cellForTabelView:tableView];
  314. trainInfoTableViewCell.RATIONKS = _RATIONKS;
  315. trainInfoTableViewCell.RATIONKSMC = _RATIONKSMC;
  316. switch (indexPath.section) {
  317. case 0:
  318. case 3: {
  319. switch (indexPath.row) {
  320. case 1: {
  321. if (RQ_USER_MANAGER.isycbd) {
  322. /// 开启远程教育(人脸远程比对)
  323. trainHoursSubTableViewCell.thoryHoursLabel.text = @"远程教育(理论)";
  324. NSString *totalTimeString = [self getTotalTime:rowArray];
  325. trainHoursSubTableViewCell.classHoursLabel.text = [NSString stringWithFormat:@"已完成%@",totalTimeString];
  326. return trainHoursSubTableViewCell;
  327. } else {
  328. NSString *titleString = @"理论";
  329. if(indexPath.row == 3){
  330. titleString = @"总学时";
  331. }
  332. trainInfoTableViewCell.titleString = titleString;
  333. trainInfoTableViewCell.allNeedTime = [(indexPath.section == 0)? (totalTimeArray.firstObject? : @"720") : (totalTimeArray.lastObject? : @"600") integerValue];
  334. trainInfoTableViewCell.dataArray = rowArray;
  335. return trainInfoTableViewCell;
  336. }
  337. }
  338. case 2: {
  339. trainHoursSubTableViewCell.thoryHoursLabel.text = @"课堂教育(理论)";
  340. NSString *totalTimeString = [self getTotalTime:rowArray];
  341. trainHoursSubTableViewCell.classHoursLabel.text = [NSString stringWithFormat:@"已完成%@",totalTimeString];
  342. return trainHoursSubTableViewCell;
  343. }
  344. case 3: {
  345. NSString *titleString = @"理论";
  346. if(indexPath.row == 3){
  347. titleString = @"总学时";
  348. }
  349. trainInfoTableViewCell.titleString = titleString;
  350. trainInfoTableViewCell.allNeedTime = [(indexPath.section == 0)? (totalTimeArray.firstObject? : @"720") : (totalTimeArray.lastObject? : @"600") integerValue];
  351. trainInfoTableViewCell.dataArray = rowArray;
  352. return trainInfoTableViewCell;
  353. }
  354. default:
  355. return trainInfoTableViewCell;
  356. }
  357. case 1:
  358. case 2: {
  359. NSInteger index = indexPath.section * 2 + indexPath.row - 1;
  360. NSString *allTimeString = @"720";
  361. if (totalTimeArray.count > index) {
  362. allTimeString = totalTimeArray[index];
  363. }
  364. NSString *titleString = indexPath.row == 0? @"模拟" : @"实操";
  365. NSString *timeKey = [NSString stringWithFormat:@"%@_%@",section,row];
  366. dataDic[timeKey] = allTimeString;
  367. trainInfoTableViewCell.mileage_label.text = @"";
  368. if(indexPath.row == 2){
  369. titleString = @"总学时";
  370. NSMutableArray *array_0 = (NSMutableArray *)[[dataDic objectForKey:section] objectForKey:@"0"];
  371. NSMutableArray *array_1 = (NSMutableArray *)[[dataDic objectForKey:section] objectForKey:@"1"];
  372. rowArray = [NSMutableArray arrayWithArray:array_0];
  373. [rowArray addObjectsFromArray:array_1];
  374. int value = [dataDic[[NSString stringWithFormat:@"%@_0",section]] intValue]+
  375. [dataDic[[NSString stringWithFormat:@"%@_1",section]] intValue];
  376. allTimeString = [NSString stringWithFormat:@"%d",value];
  377. int mileage = 0;
  378. if(rowArray.count >0){
  379. for (NSDictionary *item in rowArray) {
  380. mileage += [item[@"CRI_MILEAGE"] intValue];
  381. }
  382. trainInfoTableViewCell.mileage_label.text = [NSString stringWithFormat:@"总里程:%.2f公里",mileage/1000.0];
  383. }
  384. }
  385. trainInfoTableViewCell.titleString = titleString;
  386. trainInfoTableViewCell.allNeedTime = [allTimeString integerValue];
  387. trainInfoTableViewCell.dataArray = rowArray;
  388. return trainInfoTableViewCell;
  389. }
  390. return trainInfoTableViewCell;
  391. }
  392. default:
  393. return trainInfoTableViewCell;
  394. }
  395. }
  396. }
  397. -(NSString *)getTotalTime:(NSMutableArray *)array
  398. {
  399. if ([array count] < 1)
  400. {
  401. return @"0分钟";
  402. }
  403. int time = 0;
  404. for (NSDictionary *dic in array)
  405. {
  406. time += [dic[@"CRI_DURATION"] intValue];//CRI_VAILD_TIME
  407. }
  408. int hour = time/(_RATIONKS? : 60);
  409. int min = time%(_RATIONKS? : 60);
  410. NSString *timeString = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
  411. if (hour == 0)
  412. {
  413. timeString = [NSString stringWithFormat:@"%d分钟",min];
  414. }
  415. return timeString;
  416. }
  417. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  418. {
  419. UIView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headview"];
  420. if (!view) {
  421. view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
  422. view.backgroundColor = backGroundColor;
  423. view.layer.borderWidth = .5;
  424. view.layer.borderColor = RQlineColor.CGColor;
  425. //科目
  426. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 120, 50)];
  427. label.tag = 1;
  428. [view addSubview:label];
  429. //审核通过 未审核
  430. label = [[UILabel alloc] initWithFrame:CGRectMake(200, 0, 120, 50)];
  431. label.tag = 2;
  432. [label setText:@"" Font:FontTitle TextColor:[UIColor redColor] Alignment:NSTextAlignmentCenter];
  433. [view addSubview:label];
  434. UIImageView *secImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 15, 20, 20)];
  435. secImage.image = [UIImage imageNamed:@"location_more_arrow"];
  436. [view addSubview:secImage];
  437. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
  438. [btn addTarget:self action:@selector(clickToChange:) forControlEvents:UIControlEventTouchUpInside];
  439. [view addSubview:btn];
  440. }
  441. for (UIView *subview in view.subviews) {
  442. if ([subview isKindOfClass:[UILabel class]]) {
  443. UILabel *label = (UILabel *)subview;
  444. if (label.tag == 1) {
  445. if (section == 0)
  446. {
  447. label.text = @"科目一";
  448. }
  449. if (section == 1)
  450. {
  451. label.text = @"科目二";
  452. }
  453. if (section == 2)
  454. {
  455. label.text = @"科目三";
  456. }
  457. if (section == 3)
  458. {
  459. label.text = @"科目四";
  460. }
  461. }
  462. if (label.tag == 2) {
  463. if ([otherDic isKindOfClass:[NSDictionary class]]) {
  464. if (section == 0)
  465. {
  466. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"1"] objectForKey:@"1"];
  467. if (rowArray.count > 0) {
  468. if ([otherDic[@"SRI_TRAIN_ONE_STATUS"] integerValue] == 2) {
  469. label.text = @"审核通过";
  470. label.textColor = RQ_MAIN_COLOR;
  471. }else {
  472. label.text = @"未审核";
  473. label.textColor = [UIColor redColor];
  474. }
  475. }else {
  476. label.text = @"";
  477. }
  478. }
  479. if (section == 1)
  480. {
  481. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"2"] objectForKey:@"1"];
  482. if (rowArray.count > 0) {
  483. if ([otherDic[@"SRI_TRAIN_TWO_STATUS"] integerValue] == 2) {
  484. label.text = @"审核通过";
  485. label.textColor = RQ_MAIN_COLOR;
  486. }else {
  487. label.text = @"未审核";
  488. label.textColor = [UIColor redColor];
  489. }
  490. }else {
  491. label.text = @"";
  492. }
  493. }
  494. if (section == 2)
  495. {
  496. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"3"] objectForKey:@"1"];
  497. if (rowArray.count > 0) {
  498. if ([otherDic[@"SRI_TRAIN_THREE_STATUS"] integerValue] == 2) {
  499. label.text = @"审核通过";
  500. label.textColor = RQ_MAIN_COLOR;
  501. }else {
  502. label.text = @"未审核";
  503. label.textColor = [UIColor redColor];
  504. }
  505. }else {
  506. label.text = @"";
  507. }
  508. }
  509. if (section == 3)
  510. {
  511. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:@"4"] objectForKey:@"1"];
  512. if (rowArray.count > 0) {
  513. if ([otherDic[@"SRI_TRAIN_FOUR_STATUS"] integerValue] == 2) {
  514. label.text = @"审核通过";
  515. label.textColor = RQ_MAIN_COLOR;
  516. }else {
  517. label.text = @"未审核";
  518. label.textColor = [UIColor redColor];
  519. }
  520. }else {
  521. label.text = @"";
  522. }
  523. }
  524. }else {
  525. label.text = @"";
  526. }
  527. }
  528. }
  529. if ([subview isKindOfClass:[UIImageView class]]) {
  530. UIImageView *secImage = (UIImageView *)subview;
  531. secImage.transform = isclose[section] == NO?CGAffineTransformMakeRotation(M_PI):CGAffineTransformIdentity;
  532. }
  533. if ([subview isKindOfClass:[UIButton class]]) {
  534. UIButton *btn = (UIButton *)subview;
  535. btn.tag = section;
  536. }
  537. }
  538. return view;
  539. }
  540. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  541. {
  542. if ((indexPath.section == 0 || indexPath.section == 3) && indexPath.row == 0) {
  543. return 45;
  544. }else if (indexPath.section == 2) {
  545. return 100;
  546. }else{
  547. return 80;
  548. }
  549. }
  550. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  551. {
  552. return 50;
  553. }
  554. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  555. {
  556. return .1;
  557. }
  558. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  559. {
  560. NSMutableArray *rowArray = (NSMutableArray *)[[dataDic objectForKey:[NSString stringWithFormat:@"%d",(int)indexPath.section + 1]] objectForKey:[NSString stringWithFormat:@"%d",(int)indexPath.row]];
  561. TrainDetailVC *detail = [[TrainDetailVC alloc] init];
  562. detail.RATIONKS = _RATIONKS;
  563. detail.RATIONKSMC = _RATIONKSMC;
  564. if (RQ_USER_MANAGER.isycbd == 1) {
  565. __block NSInteger trainTime = 0;
  566. if (rowArray.count > 0 && [rowArray.firstObject isKindOfClass:[TrainRecord class]]) {
  567. [rowArray.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
  568. trainTime = trainTime + record.trainTime.integerValue;
  569. } completed:^{
  570. if (trainTime >= 30) {
  571. detail.datasourceArray = rowArray;
  572. }
  573. }];
  574. } else {
  575. detail.datasourceArray = rowArray;
  576. }
  577. } else {
  578. detail.datasourceArray = rowArray;
  579. }
  580. detail.type = @"2";
  581. if ((indexPath.section == 0 || indexPath.section == 3) && indexPath.row == 0) {
  582. //本地的学时 要上传
  583. detail.type = @"1";
  584. }
  585. [self navPushHideTabbarToVC:detail];
  586. }
  587. - (void)clickToChange:(UIButton *)sender
  588. {
  589. isclose[sender.tag] = !isclose[sender.tag];
  590. [mainTableView reloadData];
  591. }
  592. - (void)didReceiveMemoryWarning {
  593. [super didReceiveMemoryWarning];
  594. // Dispose of any resources that can be recreated.
  595. }
  596. @end