MyStuVC.m 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. //
  2. // MyStuVC.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 15/12/17.
  6. // Copyright © 2015年 JCZ. All rights reserved.
  7. //
  8. #import "MyStuVC.h"
  9. #import "StudentTableCell.h"
  10. #import "RecordCell.h"
  11. #import "Tools.h"
  12. #import "AddRecordVC.h"//修改所添加日志(教练添加对学员的带教记录)
  13. #import "SelfAppointmentVC.h"//查看自主预约(改功能屏蔽)
  14. #import "MyGradeVC.h"//查看科一/四成绩
  15. #import <MJRefresh.h>
  16. typedef NS_ENUM(NSInteger, MyGetDataType) {
  17. //正常请求数据
  18. MyGetDataTypeNomal=0,
  19. //下拉刷新请求数据
  20. MyGetDataTypeHeaderRefresh,
  21. //上拉加载更多请求数据
  22. MyGetDataTypeFooterRefresh
  23. };
  24. @interface MyStuVC ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,UITextViewDelegate>
  25. {
  26. NSMutableArray *teachTypes;//
  27. NSMutableArray *footData;//teachlogs
  28. NSMutableArray *models;//students
  29. NSArray *xArray;//休学记录s
  30. //记录页书
  31. NSInteger _currentPageNum;
  32. //正在加载的状态
  33. BOOL _IS_LOADING;
  34. //加载数据的类型
  35. MyGetDataType _getDataType;
  36. UITableView *myTabelView;//tag=0
  37. UITableView *footTableView;//tag=1
  38. HolderView *holderV;
  39. UITextView *tfReason;
  40. NSString *state;
  41. //休学原因
  42. NSString *reasonString;
  43. NSString *XXID;
  44. UILabel *remindLabel;
  45. UIButton *xxBtn;
  46. UILabel *xxLabel;
  47. NSString *searchString;
  48. UIView *backView;
  49. UIView *alertV;
  50. BOOL xiuXue;//休学状态
  51. //下拉框
  52. UIView *blockBackView;
  53. UIView *btnBar;
  54. }
  55. @end
  56. @implementation MyStuVC
  57. - (void)viewDidLoad {
  58. [super viewDidLoad];
  59. [self myInit];
  60. //获取学员个人信息==》休学记录==> 获取教学日志类型==〉日志记录
  61. [self getStuInfoByCoach];
  62. }
  63. -(void)viewWillDisappear:(BOOL)animated
  64. {
  65. [super viewWillDisappear:animated];
  66. [self.view endEditing:YES];
  67. RemoveHUD();
  68. }
  69. -(void)viewDidAppear:(BOOL)animated
  70. {
  71. [super viewDidAppear:animated];
  72. }
  73. - (void)didReceiveMemoryWarning {
  74. [super didReceiveMemoryWarning];
  75. }
  76. #pragma mark - 下拉刷新,上拉加载 -
  77. -(void)setRefreshAction{
  78. // 下拉刷新
  79. __weak typeof(self) weakSelf = self;
  80. MJRefreshNormalHeader *mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  81. [weakSelf headerRefresh];
  82. }];
  83. footTableView.mj_header = mj_header;
  84. MJRefreshBackNormalFooter *mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  85. [weakSelf footerRefresh];
  86. }];
  87. footTableView.mj_footer = mj_footer;
  88. }
  89. #pragma mark - 数据加载更多和刷新 -
  90. -(void)headerRefresh{
  91. //设置获取数据的方式
  92. _getDataType=MyGetDataTypeHeaderRefresh;
  93. //加载数据
  94. [self getMyTeachLogs];
  95. [footTableView.mj_header endRefreshing];
  96. }
  97. -(void)footerRefresh{
  98. //设置获取数据的方式
  99. _getDataType=MyGetDataTypeFooterRefresh;
  100. //加载数据
  101. [self getMyTeachLogs];
  102. [footTableView.mj_footer endRefreshing];
  103. }
  104. #pragma mark -
  105. -(void)myInit
  106. {
  107. [self addV:[UIView new]];
  108. _currentPageNum = 0;
  109. _IS_LOADING = NO;
  110. _getDataType = MyGetDataTypeNomal;
  111. models = [NSMutableArray array];
  112. footData = [NSMutableArray array];
  113. xArray = [NSArray array];
  114. teachTypes = [NSMutableArray array];
  115. //设置初始休学状态
  116. if ([[_stuDic allKeys] containsObject:@"XX_ID"]) {
  117. if ([_stuDic[@"XX_ID"] length] > 0) {
  118. xiuXue = YES;
  119. }
  120. }
  121. UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"学员信息" style:UIBarButtonItemStyleDone target:self action:@selector(clickToSearch)];
  122. [item setTintColor:defGreen];
  123. [self.navigationItem setRightBarButtonItem:item];
  124. UITableView* tv = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
  125. tv.y = kNavOffSet;
  126. tv.height = kSize.height - tv.y;
  127. myTabelView = tv;
  128. [myTabelView setDelegate:self];
  129. [myTabelView setDataSource:self];
  130. [myTabelView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
  131. myTabelView.tag = 0;
  132. [self addV:tv];
  133. [tv setTableFooterView:[UIView new]];
  134. holderV = [[HolderView alloc] initWithFrame:tv.frame];
  135. [holderV freshBlock:^{
  136. [self getStuInfoByCoach];
  137. }];
  138. [self addV:holderV];
  139. [holderV setHidden:YES];
  140. }
  141. #pragma mark - tableview delegate
  142. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  143. {
  144. if (tableView.tag == 1) {
  145. if (xArray.count > 0 && footData.count > 0) {
  146. return 2;
  147. }else{
  148. return 1;
  149. }
  150. }
  151. return 1;
  152. }
  153. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  154. {
  155. if (tableView.tag == 1) {
  156. if (xArray.count > 0 && footData.count > 0) {
  157. if (section == 0) {
  158. return xArray.count;
  159. }else{
  160. return footData.count;
  161. }
  162. }else if (xArray.count > 0){
  163. return xArray.count;
  164. }else if (footData.count > 0){
  165. return footData.count;
  166. }else{
  167. return 0;
  168. }
  169. }
  170. return models.count;
  171. }
  172. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  173. {
  174. if (tableView.tag == 1) {
  175. RecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"recordCell"];
  176. if (cell == nil)
  177. {
  178. cell = [[RecordCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"recordCell"];
  179. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  180. }
  181. @try {
  182. if (xArray.count > 0 && footData.count > 0) {
  183. if (indexPath.section == 0) {
  184. NSDictionary *dic = xArray[indexPath.row];
  185. cell.textLabel.adjustsFontSizeToFitWidth = YES;
  186. cell.textLabel.text = [NSString stringWithFormat:@"● 该学员于%@休学",dic[@"CRDATE"]];
  187. cell.detailTextLabel.text = @"";
  188. if ([dic[@"REASON"] length] > 0) {
  189. cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: %@",dic[@"REASON"]];
  190. }
  191. if (cell.detailTextLabel.text.length > 0) {
  192. NSString *remarkString = cell.detailTextLabel.text;
  193. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  194. [aAttributedString addAttribute:NSForegroundColorAttributeName
  195. value:[UIColor orangeColor]
  196. range:NSMakeRange(0, 5)];
  197. [aAttributedString addAttribute:NSForegroundColorAttributeName
  198. value:contentTextColor
  199. range:NSMakeRange(5, remarkString.length - 5)];
  200. cell.detailTextLabel.attributedText = aAttributedString;
  201. }
  202. cell.detailTextLabel.numberOfLines = 0;
  203. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  204. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  205. cell.detailTextLabel.height = detailTextHight + 10;
  206. cell.dateLabel.text = @"";
  207. }else{
  208. NSDictionary *dic = footData[indexPath.row];
  209. NSString *teachStyle = teachTypes[[dic[@"TL_TEACH_ID"] integerValue] - 1];
  210. NSString *remarkS = [NSString stringWithFormat:@"%d、[%@]",(int)indexPath.row + 1,teachStyle];
  211. NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:remarkS];
  212. [aString addAttribute:NSForegroundColorAttributeName
  213. value:[UIColor orangeColor]
  214. range:NSMakeRange(2, 1)];
  215. [aString addAttribute:NSForegroundColorAttributeName
  216. value:[UIColor orangeColor]
  217. range:NSMakeRange(remarkS.length - 1, 1)];
  218. cell.textLabel.attributedText = aString;
  219. cell.textLabel.adjustsFontSizeToFitWidth = YES;
  220. //日期
  221. NSString *km = [dic[@"TL_SUBJECT"] isEqualToString:@"2"]?@"科二":@"科三";
  222. NSString *dateString = dic[@"TL_CRDATE"];
  223. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  224. [formatter setDateFormat:@"yyyy-MM-dd"];
  225. NSDate *cDate = [formatter dateFromString:dateString];
  226. [formatter setDateFormat:@"MM.dd.yyyy"];
  227. dateString = [formatter stringFromDate:cDate];
  228. cell.dateLabel.text = [NSString stringWithFormat:@"%@ %@",dateString,km];
  229. //如果没有 就不显示
  230. //cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: 暂无备注"];
  231. cell.detailTextLabel.text = @"";
  232. if ([dic[@"TL_REMARK"] length] > 0) {
  233. cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: %@",dic[@"TL_REMARK"]];
  234. }
  235. if (cell.detailTextLabel.text.length > 0) {
  236. NSString *remarkString = cell.detailTextLabel.text;
  237. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  238. [aAttributedString addAttribute:NSForegroundColorAttributeName
  239. value:[UIColor orangeColor]
  240. range:NSMakeRange(0, 3)];
  241. [aAttributedString addAttribute:NSForegroundColorAttributeName
  242. value:contentTextColor
  243. range:NSMakeRange(3, remarkString.length - 3)];
  244. cell.detailTextLabel.attributedText = aAttributedString;
  245. }
  246. cell.detailTextLabel.numberOfLines = 0;
  247. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  248. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  249. cell.detailTextLabel.height = detailTextHight + 10;
  250. }
  251. }else if (xArray.count > 0){
  252. cell.textLabel.adjustsFontSizeToFitWidth = YES;
  253. NSDictionary *dic = xArray[indexPath.row];
  254. //♦
  255. cell.textLabel.text = [NSString stringWithFormat:@"● 该学员于%@被写入休学状态",dic[@"CRDATE"]];
  256. //cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: 暂无"];
  257. cell.detailTextLabel.text = @"";
  258. if ([dic[@"REASON"] length] > 0) {
  259. cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: %@",dic[@"REASON"]];
  260. }
  261. if (cell.detailTextLabel.text.length > 0) {
  262. NSString *remarkString = cell.detailTextLabel.text;
  263. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  264. [aAttributedString addAttribute:NSForegroundColorAttributeName
  265. value:[UIColor orangeColor]
  266. range:NSMakeRange(0, 5)];
  267. [aAttributedString addAttribute:NSForegroundColorAttributeName
  268. value:contentTextColor
  269. range:NSMakeRange(5, remarkString.length - 5)];
  270. cell.detailTextLabel.attributedText = aAttributedString;
  271. }
  272. cell.detailTextLabel.numberOfLines = 0;
  273. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  274. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  275. cell.detailTextLabel.height = detailTextHight + 10;
  276. cell.dateLabel.text = @"";
  277. }
  278. else{
  279. NSDictionary *dic = footData[indexPath.row];
  280. NSString *teachStyle = teachTypes[[dic[@"TL_TEACH_ID"] integerValue] - 1];
  281. NSString *remarkS = [NSString stringWithFormat:@"%d、[%@]",(int)indexPath.row + 1,teachStyle];
  282. NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:remarkS];
  283. [aString addAttribute:NSForegroundColorAttributeName
  284. value:[UIColor orangeColor]
  285. range:NSMakeRange(2, 1)];
  286. [aString addAttribute:NSForegroundColorAttributeName
  287. value:[UIColor orangeColor]
  288. range:NSMakeRange(remarkS.length - 1, 1)];
  289. cell.textLabel.attributedText = aString;
  290. cell.textLabel.adjustsFontSizeToFitWidth = YES;
  291. //日期
  292. NSString *km = [dic[@"TL_SUBJECT"] isEqualToString:@"2"]?@"科二":@"科三";
  293. NSString *dateString = dic[@"TL_CRDATE"];
  294. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  295. [formatter setDateFormat:@"yyyy-MM-dd"];
  296. NSDate *cDate = [formatter dateFromString:dateString];
  297. [formatter setDateFormat:@"MM.dd.yyyy"];
  298. dateString = [formatter stringFromDate:cDate];
  299. cell.dateLabel.text = [NSString stringWithFormat:@"%@ %@",dateString,km];
  300. //cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: 暂无备注"];
  301. cell.detailTextLabel.text = @"";
  302. if ([dic[@"TL_REMARK"] length] > 0) {
  303. cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: %@",dic[@"TL_REMARK"]];
  304. }
  305. if (cell.detailTextLabel.text.length > 0) {
  306. NSString *remarkString = cell.detailTextLabel.text;
  307. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  308. [aAttributedString addAttribute:NSForegroundColorAttributeName
  309. value:[UIColor orangeColor]
  310. range:NSMakeRange(0, 3)];
  311. [aAttributedString addAttribute:NSForegroundColorAttributeName
  312. value:contentTextColor
  313. range:NSMakeRange(3, remarkString.length - 3)];
  314. cell.detailTextLabel.attributedText = aAttributedString;
  315. }
  316. cell.detailTextLabel.numberOfLines = 0;
  317. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  318. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  319. cell.detailTextLabel.height = detailTextHight + 10;
  320. }
  321. }
  322. @catch (NSException *exception) {
  323. }
  324. @finally {
  325. return cell;
  326. }
  327. }
  328. StudentTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  329. if (cell == nil) {
  330. cell = [[[NSBundle mainBundle] loadNibNamed:@"StudentTableCell" owner:nil options:nil] firstObject];
  331. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  332. }
  333. cell.studeState = [_stuDic[@"SUBJECT"] integerValue];
  334. [cell setModel:models[indexPath.row]];
  335. NSString *titleString = @"添加休学";
  336. if (xiuXue) {
  337. titleString = @"取消休学";
  338. }
  339. [cell.xxBtn setTitle:titleString textColor:defGreen font:Font14 fotState:UIControlStateNormal];
  340. [cell.xxBtn corner:5];
  341. [cell.xxBtn target:self Tag:1];
  342. xxBtn = cell.xxBtn;
  343. return cell;
  344. }
  345. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  346. {
  347. if (tableView.tag == 1) {
  348. if (xArray.count > 0 && indexPath.section == 0) {
  349. return 80.5;
  350. }
  351. NSDictionary *dic = footData[indexPath.row];
  352. CGFloat height = [[NSString stringWithFormat:@"备注:%@",dic[@"TL_REMARK"]] heightForWid:kSize.width - 20 Font:15];
  353. return height + 70.5;
  354. }else{
  355. return 225;
  356. }
  357. }
  358. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  359. {
  360. if (tableView.tag == 1) {
  361. UILabel *xLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
  362. xLabel.backgroundColor = [UIColor colorWithWhite:.9 alpha:1];
  363. xLabel.text = @"休学记录";
  364. xLabel.font = [UIFont scaleSize:20];
  365. xLabel.textAlignment = NSTextAlignmentCenter;
  366. UILabel *rLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
  367. rLabel.backgroundColor = [UIColor colorWithWhite:.9 alpha:1];
  368. rLabel.text = @"学员日志";
  369. rLabel.font = [UIFont scaleSize:20];
  370. rLabel.textAlignment = NSTextAlignmentCenter;
  371. if (xArray.count > 0 && footData.count > 0) {
  372. if (section == 0) {
  373. return xLabel;
  374. }else{
  375. return rLabel;
  376. }
  377. }else if (xArray.count > 0){
  378. return xLabel;
  379. }else if (footData.count > 0){
  380. return rLabel;
  381. }else{
  382. return [UILabel new];
  383. }
  384. }
  385. return [UIView new];
  386. }
  387. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  388. {
  389. if (tableView.tag == 1) {
  390. UIView *view = [UIView new];
  391. return view;
  392. }
  393. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet - 240)];
  394. view.backgroundColor = backGroundColor;
  395. if (models.count > 0)
  396. {
  397. UITableView* tv = [[UITableView alloc] initWithFrame:kFrame];
  398. tv.y = 5;
  399. tv.height = kSize.height - kNavOffSet - 225-5;
  400. tv.delegate = self;
  401. tv.dataSource = self;
  402. tv.tag = 1;
  403. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 2)];
  404. headView.backgroundColor = lineColor;
  405. tv.tableHeaderView = headView;
  406. [tv setTableFooterView:[UIView new]];
  407. [view addSubview:tv];
  408. footTableView = tv;
  409. }
  410. return view;
  411. }
  412. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  413. {
  414. if (tableView.tag == 1) {
  415. return .1;
  416. }
  417. return kSize.height - kNavOffSet - 225;
  418. }
  419. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  420. {
  421. if (tableView.tag == 1) {
  422. return 40;
  423. }
  424. return .1;
  425. }
  426. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  427. {
  428. if (tableView.tag == 1) {
  429. if (xArray.count > 0 && footData.count > 0) {
  430. if (indexPath.section == 0) {
  431. return;
  432. }else{
  433. AddRecordVC *vc = [[AddRecordVC alloc] init];
  434. vc.refreshTeachlogs = ^{
  435. [self headerRefresh];
  436. };
  437. vc.stuDic = _stuDic;
  438. vc.teachType = teachTypes;
  439. vc.recordDic = footData[indexPath.row];
  440. vc.view.backgroundColor = backGroundColor;
  441. [vc configNavBar];
  442. [self.navigationController pushViewController:vc animated:YES];
  443. }
  444. }else if (xArray.count > 0){
  445. return;
  446. }else{
  447. AddRecordVC *vc = [[AddRecordVC alloc] init];
  448. vc.refreshTeachlogs = ^{
  449. [self headerRefresh];
  450. };
  451. vc.stuDic = _stuDic;
  452. vc.teachType = teachTypes;
  453. vc.recordDic = footData[indexPath.row];
  454. vc.view.backgroundColor = backGroundColor;
  455. [vc configNavBar];
  456. [self.navigationController pushViewController:vc animated:YES];
  457. }
  458. }
  459. }
  460. //表的编辑
  461. -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  462. {
  463. if (tableView.tag == 1) {
  464. if (xArray.count > 0) {
  465. if (indexPath.section == 0) {
  466. return NO;
  467. }
  468. }
  469. return YES;
  470. }else{
  471. return NO;
  472. }
  473. }
  474. //记得默认是yes
  475. -(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
  476. {
  477. if (tableView.tag == 1) {
  478. return YES;
  479. }else{
  480. return NO;
  481. }
  482. }
  483. -(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
  484. {
  485. return @"删除";
  486. }
  487. -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  488. {
  489. [self deleteTeachTypesWithRow:indexPath.row];
  490. }
  491. #pragma mark btn事件
  492. -(void)btnClick:(UIButton *)sender
  493. {
  494. if (xiuXue) {
  495. [self delStuXX];
  496. }else{
  497. backView = [[UIView alloc] initWithFrame:kFrame];
  498. backView.backgroundColor = [UIColor blackColor];
  499. backView.alpha = .3;
  500. [self.view addSubview:backView];
  501. alertV = [[UIView alloc] init];
  502. alertV.bounds = CGRectMake(0, 0, 280, 250);
  503. alertV.y -= 80;
  504. alertV.alpha = 1;
  505. alertV.center = CGPointMake(kSize.width/2.0, kSize.height/2.0);
  506. alertV.backgroundColor = backGroundColor;
  507. [alertV corner:15];
  508. [self.view addSubview:alertV];
  509. tfReason = [[UITextView alloc] initWithFrame:CGRectMake(10, 20, 260, 140)];
  510. tfReason.delegate = self;
  511. [tfReason setFont:[UIFont scaleSize:Font18]];
  512. [alertV addSubview:tfReason];
  513. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 260, 30)];
  514. label.text = @"请输入休学原因(100字以内)";
  515. label.textColor = contentTextColor;
  516. [alertV addSubview:label];
  517. remindLabel = label;
  518. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(190, 190, 70, 40)];
  519. btn.backgroundColor = defGreen;
  520. [btn setTitle:@"确定" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
  521. [btn corner:5];
  522. [btn addTarget:self action:@selector(clickToAddXX:) forControlEvents:UIControlEventTouchUpInside];
  523. btn.tag = 4;
  524. [alertV addSubview:btn];
  525. btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 190, 70, 40)];
  526. btn.backgroundColor = defGreen;
  527. [btn setTitle:@"取消" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
  528. [btn corner:5];
  529. [btn addTarget:self action:@selector(clickToAddXX:) forControlEvents:UIControlEventTouchUpInside];
  530. btn.tag = 5;
  531. [alertV addSubview:btn];
  532. }
  533. }
  534. -(void)clickToAddXX:(UIButton *)sender
  535. {
  536. if (sender.tag == 5) {
  537. [alertV removeFromSuperview];
  538. [backView removeFromSuperview];
  539. return;
  540. }
  541. if (tfReason.text.length > 100) {
  542. ShowMsg(@"字数不能超过100字");
  543. return;
  544. }
  545. [self.view endEditing:YES];
  546. reasonString = tfReason.text;
  547. if (!reasonString) {
  548. reasonString = @"";
  549. }
  550. [alertV removeFromSuperview];
  551. [backView removeFromSuperview];
  552. [self uploadStuXX];
  553. }
  554. -(void)clickToSearch
  555. {
  556. if (backView || btnBar) {
  557. //做关闭的操作
  558. [self removeSearchView];
  559. return;
  560. }
  561. backView = [[UIView alloc] initWithFrame:kFrame];
  562. backView.backgroundColor = [UIColor colorWithWhite:.7 alpha:.1];
  563. UITapGestureRecognizer *tapGR=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
  564. [backView addGestureRecognizer:tapGR];
  565. [self.view addSubview:backView];
  566. btnBar = [[UIView alloc] initWithFrame:CGRectMake(0, -70, kSize.width, 70)];
  567. [btnBar setBackgroundColor:[UIColor whiteColor]];
  568. [self.view addSubview:btnBar];
  569. NSArray *titles = @[@"科一成绩",@"科四成绩"];//@"预约信息" 屏蔽
  570. CGFloat w = (kSize.width - 40)/3.0;
  571. CGFloat h = 35;
  572. for (int i = 0; i < titles.count; i ++) {
  573. int row = i/titles.count;
  574. int column = i%titles.count;
  575. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10 + column*(w + 10), 20 + row*(h + 10), w, h)];
  576. [btn borderColor:lineColor width:1 cornorRadios:3];
  577. [btn setTitle:titles[i] textColor:titleColor font:Font16 fotState:UIControlStateNormal];
  578. //点击状态的按钮
  579. [btn setTitleColor:[UIColor colorWithRed:55/255.0 green:147/255.0 blue:239/255.0 alpha:1] forState:UIControlStateHighlighted];
  580. [btn addTarget:self action:@selector(clickToSearchVC:) forControlEvents:UIControlEventTouchUpInside];
  581. btn.tag = i - 3 +1;
  582. [btnBar addSubview:btn];
  583. }
  584. [UIView animateWithDuration:.4 animations:^{
  585. backView.backgroundColor = [UIColor colorWithWhite:.3 alpha:.5];
  586. btnBar.y = kNavOffSet;
  587. }];
  588. }
  589. -(void)clickToSearchVC:(UIButton *)btn
  590. {
  591. NSString *sfzhm = @"";
  592. if ([_stuDic isKindOfClass:[NSDictionary class]]) {
  593. if ([[_stuDic allKeys] count] != 0) {
  594. sfzhm = _stuDic[@"TSO_ID"];
  595. }
  596. }
  597. if (btn.tag == -3) {
  598. //自主预约
  599. SelfAppointmentVC *vc = [[SelfAppointmentVC alloc] init];
  600. vc.type = @"1";
  601. vc.sfzhm = sfzhm;
  602. [self.navigationController pushViewController:vc animated:YES];
  603. }
  604. if (btn.tag == -2) {
  605. //学员科一成绩
  606. MyGradeVC *vc = [[MyGradeVC alloc] init];
  607. vc.identifyNum = sfzhm;
  608. vc.stuName = _stuDic[@"STU_NAME"];
  609. vc.kmString = @"1";
  610. [self.navigationController pushViewController:vc animated:YES];
  611. }
  612. if (btn.tag == -1) {
  613. //学员科四成绩
  614. MyGradeVC *vc = [[MyGradeVC alloc] init];
  615. vc.identifyNum = sfzhm;
  616. vc.stuName = _stuDic[@"STU_NAME"];
  617. vc.kmString = @"4";
  618. [self.navigationController pushViewController:vc animated:YES];
  619. }
  620. [self removeSearchView];
  621. }
  622. -(void)tapAction:(UITapGestureRecognizer *)gesture
  623. {
  624. //做关闭的操作
  625. [self removeSearchView];
  626. }
  627. -(void)removeSearchView
  628. {
  629. [UIView animateWithDuration:.4 animations:^{
  630. backView.backgroundColor = [UIColor colorWithWhite:.7 alpha:.1];
  631. btnBar.y = -70 - kNavOffSet;
  632. } completion:^(BOOL finished) {
  633. [backView removeFromSuperview];
  634. [btnBar removeFromSuperview];
  635. backView = nil;
  636. btnBar = nil;
  637. }];
  638. }
  639. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  640. {
  641. [self.view endEditing:YES];
  642. }
  643. -(void)textViewDidBeginEditing:(UITextView *)textView
  644. {
  645. [remindLabel setTextColor:lineColor];
  646. }
  647. -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  648. {
  649. NSMutableString * changedString=[[NSMutableString alloc]initWithString:textView.text];
  650. [changedString replaceCharactersInRange:range withString:text];
  651. if (changedString.length > 0) {
  652. [remindLabel setHidden:YES];
  653. }else{
  654. [remindLabel setHidden:NO];
  655. }
  656. return YES;
  657. }
  658. #pragma mark 数据请求
  659. /**可以考虑持久保存。如果当前没网络,就读取本地数据。
  660. */
  661. - (void)getStuInfoByCoach
  662. {
  663. [LoadingView showHUD];
  664. if (![Util connectedToNetWork]) {
  665. showMsgUnconnect();
  666. return;
  667. }
  668. searchString = _stuDic[@"STU_SFZHM"];
  669. if (searchString.length < 1) {
  670. searchString = _stuDic[@"SFZMHM"];
  671. }
  672. NSMutableArray *arr = [NSMutableArray array];
  673. [arr addPro:@"queryValue" Value:searchString];
  674. [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
  675. [arr addPro:@"fptime" Value:@""];
  676. [arr addPro:@"subject" Value:[NSString stringWithFormat:@"%@",_stuDic[@"SUBJECT"]]];
  677. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  678. [arr addPro:@"isPage" Value:@""];
  679. [arr addPro:@"pageSize" Value:@""];
  680. [arr addPro:@"currentPage" Value:@""];
  681. NSString* method = @"getMyStudentsByCoachAccount";
  682. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  683. RemoveHUD();
  684. [holderV setHidden:NO];
  685. if (!root) {
  686. return ;
  687. }
  688. if ([root[@"code"] isEqualToString:@"1"]) {
  689. return;
  690. }
  691. if ([root[@"body"] count] == 0) {
  692. //ShowMsg(@"暂无数据");
  693. return;
  694. }
  695. models = root[@"body"];
  696. if (models.count >0) {
  697. [myTabelView reloadData];
  698. [holderV setHidden:YES];
  699. [self getStuXXList];
  700. }else{
  701. [holderV setHidden:NO];
  702. }
  703. }];
  704. }
  705. //休学记录列表
  706. - (void)getStuXXList
  707. {
  708. [LoadingView showHUD];
  709. if (![Util connectedToNetWork]) {
  710. showMsgUnconnect();
  711. return;
  712. }
  713. NSMutableArray *arr=[NSMutableArray array];
  714. [arr addPro:@"stuSfzhm" Value:_stuDic[@"STU_SFZHM"]];
  715. [arr addPro:@"jxbh" Value:defUser.userDict[@"jxbh"]];
  716. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  717. [arr addPro:@"isPage" Value:@"0"];
  718. [arr addPro:@"pageSize" Value:@"0"];
  719. [arr addPro:@"currentPage" Value:@"0"];
  720. NSString* method = @"stuXXList";
  721. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  722. RemoveHUD();
  723. [self getTeachTypes];
  724. if (!root) {
  725. return ;
  726. }
  727. if ([root[@"code"] isEqualToString:@"1"]) {
  728. return;
  729. }
  730. xArray = root[@"body"];
  731. }];
  732. }
  733. //添加休学
  734. - (void)uploadStuXX
  735. {
  736. [LoadingView showHUD];
  737. if (![Util connectedToNetWork]) {
  738. showMsgUnconnect();
  739. return;
  740. }
  741. NSMutableArray *arr = [NSMutableArray array];
  742. [arr addPro:@"stuName" Value:_stuDic[@"STU_NAME"]];
  743. [arr addPro:@"stuSfzhm" Value:_stuDic[@"STU_SFZHM"]];
  744. [arr addPro:@"coaName" Value:defUser.userDict[@"name"]];
  745. [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
  746. [arr addPro:@"reason" Value:reasonString];
  747. [arr addPro:@"subject" Value:[NSString stringWithFormat:@"%@",_stuDic[@"SUBJECT"]]];
  748. [arr addPro:@"jxbh" Value:defUser.userDict[@"jxbh"]];
  749. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  750. NSString* method = @"uploadStuXX";
  751. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  752. RemoveHUD();
  753. if (!root) {
  754. ShowMsg(@"加入休学失败!");
  755. return ;
  756. }
  757. if ([root[@"code"] isEqualToString:@"1"]) {
  758. ShowMsg(root[@"body"]);
  759. return;
  760. }
  761. //改变按钮标题和点击状态
  762. [xxBtn setTitle:@"取消休学" forState:UIControlStateNormal];
  763. xiuXue = YES;
  764. XXID = root[@"body"];
  765. [self getStuXXList];
  766. if (self.refreshStuList) {
  767. self.refreshStuList();
  768. }
  769. }];
  770. }
  771. //取消休学
  772. - (void)delStuXX
  773. {
  774. [LoadingView showHUD];
  775. if (![Util connectedToNetWork]) {
  776. showMsgUnconnect();
  777. return;
  778. }
  779. if (XXID.length == 0) {
  780. XXID = _stuDic[@"XX_ID"];
  781. }
  782. NSMutableArray *arr = [NSMutableArray array];
  783. [arr addPro:@"xxid" Value:XXID];
  784. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  785. NSString* method = @"delStuXX";
  786. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  787. RemoveHUD();
  788. if (!root) {
  789. ShowMsg(@"取消休学失败!");
  790. return ;
  791. }
  792. if ([root[@"code"] isEqualToString:@"1"]) {
  793. ShowMsg(root[@"body"]);
  794. return;
  795. }
  796. //改变按钮标题和点击状态
  797. [xxBtn setTitle:@"添加休学" forState:UIControlStateNormal];
  798. xiuXue = NO;
  799. [self getStuXXList];
  800. if (self.refreshStuList) {
  801. self.refreshStuList();
  802. }
  803. }];
  804. }
  805. -(NSString *)getNowDate
  806. {
  807. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  808. [formatter setDateFormat:@"yyyy-MM-dd"];
  809. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  810. return dateString;
  811. }
  812. //请求类型 有关日志信息
  813. - (void)getTeachTypes
  814. {
  815. NSMutableArray *array = [NSMutableArray arrayWithObjects:@"车辆基础操作",@"直线控制离合",@"倒车入库左倒",@"倒车入库右倒",@"科目二全套训练",@"预约科目二考试",@"考试日期",@"路跑",@"变更车道",@"会车与超车",@"靠边停车和掉头",@"灯光使用",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"", nil];
  816. NSMutableArray *arr = [NSMutableArray array];
  817. [arr addPro:@"subject" Value:@""];
  818. [arr addPro:@"type" Value:@"1"];
  819. NSString* method = @"getTeachTypes";
  820. [LoadingView showHUD];
  821. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  822. RemoveHUD();
  823. if (!root || [root[@"code"] isEqualToString:@"1"]) {
  824. NSString *filePath = [Tools getPathWithFileName:@"getTeachTypes.plist"];
  825. if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
  826. NSArray *arr = [NSArray arrayWithContentsOfFile:filePath];
  827. [teachTypes removeAllObjects];
  828. for (NSDictionary *dic in arr) {
  829. [teachTypes addObject:dic[@"TC_TEACH_TYPE"]];
  830. }
  831. }else{
  832. teachTypes = array;
  833. }
  834. [self headerRefresh];
  835. return;
  836. }
  837. NSString *filePath = [Tools getPathWithFileName:@"getTeachTypes.plist"];
  838. [root[@"body"] writeToFile:filePath atomically:YES];
  839. [teachTypes removeAllObjects];
  840. for (NSDictionary *dic in root[@"body"]) {
  841. [teachTypes addObject:dic[@"TC_TEACH_TYPE"]];
  842. }
  843. [self headerRefresh];
  844. }];
  845. }
  846. - (void)getMyTeachLogs
  847. {
  848. //判断当前是否正在加载数据。如果正在加载数据,直接return。
  849. if (_IS_LOADING) {
  850. return;
  851. }
  852. [LoadingView showHUD];
  853. _IS_LOADING=YES;
  854. //获取第一页数据
  855. NSInteger needLoadPage;
  856. needLoadPage=_currentPageNum+1;
  857. if (_getDataType==MyGetDataTypeHeaderRefresh) {
  858. needLoadPage=1;
  859. }
  860. NSString *queryValue = @"";
  861. if ([_stuDic isKindOfClass:[NSDictionary class]]) {
  862. if ([[_stuDic allKeys] count] != 0) {
  863. queryValue = _stuDic[@"TSO_ID"];
  864. }
  865. }
  866. NSMutableArray *arr=[NSMutableArray array];
  867. [arr addPro:@"queryValue" Value:queryValue];
  868. [arr addPro:@"isPage" Value:@"1"];
  869. [arr addPro:@"pageSize" Value:@"10"];
  870. [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)needLoadPage]];
  871. NSString* method = @"getMyTeachLogs";
  872. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  873. RemoveHUD();
  874. //设置加载状态
  875. _IS_LOADING=NO;
  876. if (!root) {
  877. ShowMsg(@"数据请求失败,请重试");
  878. return;
  879. }
  880. if ([root[@"code"] integerValue] != 0) {
  881. ShowMsg(root[@"body"]);
  882. return;
  883. }
  884. //处理数据
  885. //如果获取到了数据,而且是下拉刷新,清空数组。
  886. if (_getDataType==MyGetDataTypeHeaderRefresh){
  887. [footData removeAllObjects];
  888. }
  889. NSArray *bodyArray = root[@"body"];
  890. if (bodyArray && bodyArray.count > 0) {
  891. //追加数据
  892. [footData addObjectsFromArray:bodyArray];
  893. //计数器+1
  894. _currentPageNum=needLoadPage;
  895. }
  896. //刷新界面
  897. [footTableView reloadData];
  898. //恢复初始状态。
  899. _getDataType=MyGetDataTypeNomal;
  900. }];
  901. }
  902. - (void)deleteTeachTypesWithRow:(NSInteger)row
  903. {
  904. [LoadingView showHUD];
  905. if (![Util connectedToNetWork]) {
  906. showMsgUnconnect();
  907. return;
  908. }
  909. NSDictionary *dic = footData[row];
  910. NSMutableArray *arr = [NSMutableArray array];
  911. [arr addPro:@"id" Value:dic[@"TL_ID"]];
  912. NSString* method = @"deleteMyTeachLog";
  913. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  914. RemoveHUD();
  915. if (!root) {
  916. return;
  917. }
  918. if ([root[@"code"] isEqualToString:@"1"]) {
  919. ShowMsg(root[@"body"]);
  920. }
  921. [footData removeObjectAtIndex:row];
  922. [footTableView reloadData];
  923. }];
  924. }
  925. @end