coachRecordVC.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. //
  2. // coachRecordVC.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/3/8.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. //带教记录
  9. #import "coachRecordVC.h"
  10. #import "AddRecordVC.h"
  11. #import "AppDelegate.h"
  12. #import "Tools.h"
  13. #import "DetailTJVC.h"
  14. #import "RecordCell.h"
  15. #import <MJRefresh.h>
  16. typedef NS_ENUM(NSInteger, MyGetDataType) {
  17. //正常请求数据
  18. MyGetDataTypeNomal=0,
  19. //下拉刷新请求数据
  20. MyGetDataTypeHeaderRefresh,
  21. //上拉加载更多请求数据
  22. MyGetDataTypeFooterRefresh
  23. };
  24. @interface coachRecordVC ()<UITableViewDelegate,UITableViewDataSource>
  25. {
  26. //记录页书
  27. NSInteger _currentPageNum;
  28. //正在加载的状态
  29. BOOL _IS_LOADING;
  30. //加载数据的类型
  31. MyGetDataType _getDataType;
  32. HolderView *holderV;
  33. UITextField *tfName;
  34. UITableView *mainTableView;
  35. NSMutableArray *models;//底部foottab数据源
  36. NSArray *xArray;
  37. NSMutableArray *teachTypes;
  38. NSString *searchString;
  39. }
  40. @end
  41. @implementation coachRecordVC
  42. - (void)viewDidLoad {
  43. [super viewDidLoad];
  44. _currentPageNum = 0;
  45. _IS_LOADING = NO;
  46. _getDataType = MyGetDataTypeNomal;
  47. models = [NSMutableArray array];
  48. xArray = [NSArray array];
  49. teachTypes = [NSMutableArray array];
  50. float h,bd,w,x,y;
  51. x = bd = 10;
  52. w = (kSize.width - bd*4)/6.0;
  53. h = 50;
  54. y = kNavOffSet + bd;
  55. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w * 2, h)];
  56. label.text = _stuDic[@"STU_NAME"];
  57. label.textColor = kTitleColor;
  58. label.textAlignment = NSTextAlignmentCenter;
  59. [label setFont:[UIFont scaleSize:21]];
  60. [self.view addSubview:label];
  61. UILabel *telLabel = [[UILabel alloc] initWithFrame:CGRectMake(x + 2*w + 2*bd, y + 8, w * 4, h - 8)];
  62. //用富文本将电话号码
  63. NSString *telString = [NSString stringWithFormat:@"电话号码:%@",_stuDic[@"TSO_PHONE"]];
  64. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:telString];
  65. [aAttributedString addAttribute:NSForegroundColorAttributeName
  66. value:contentTextColor
  67. range:NSMakeRange(0, 5)];
  68. [aAttributedString addAttribute:NSForegroundColorAttributeName
  69. value:defGreen
  70. range:NSMakeRange(5, telString.length - 5)];
  71. telLabel.attributedText = aAttributedString;
  72. telLabel.textAlignment = NSTextAlignmentCenter;
  73. [telLabel setFont:[UIFont scaleSize:Font16]];
  74. [self.view addSubview:telLabel];
  75. //电话按钮
  76. UIButton *telBtn = [[UIButton alloc] initWithFrame:CGRectMake(x + 2*w + 2*bd, y, w * 4, h)];
  77. [telBtn target:self Tag:1];
  78. [self addV:telBtn];
  79. y += h + bd + 8;
  80. h -= 10;
  81. UIImageView *btnImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, y + 5, 30, 30)];
  82. btnImg.image = [UIImage imageNamed:@"xiuxue.png"];
  83. [self addV:btnImg];
  84. UIButton *btn;
  85. btn = [[UIButton alloc] initWithFrame:CGRectMake(0, y, kSize.width/2.0, h)];
  86. [btn setTitle:@"添加日志" textColor:kTitleColor font:Font16 fotState:UIControlStateNormal];
  87. [btn borderColor:lineColor width:2 cornorRadios:0];
  88. [self addV:btn];
  89. [btn target:self Tag:2];
  90. btnImg = [[UIImageView alloc] initWithFrame:CGRectMake(kSize.width/2.0 + 8, y + 5, 30, 30)];
  91. btnImg.image = [UIImage imageNamed:@"record.png"];
  92. [self addV:btnImg];
  93. btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2.0 - 2, y, kSize.width/2.0 + 2, h)];
  94. [btn setTitle:@"日志统计" textColor:kTitleColor font:Font16 fotState:UIControlStateNormal];
  95. [btn borderColor:lineColor width:2 cornorRadios:0];
  96. [self addV:btn];
  97. [btn target:self Tag:3];
  98. y += h + 2;
  99. mainTableView = [[UITableView alloc] initWithFrame:kFrame];
  100. mainTableView.y = y;
  101. mainTableView.height = kSize.height - mainTableView.y - kSafeAreaBottomHeight;
  102. [mainTableView setDelegate:self];
  103. [mainTableView setDataSource:self];
  104. mainTableView.estimatedSectionFooterHeight = 0;
  105. [self addV:mainTableView];
  106. [mainTableView setTableFooterView:[UIView new]];
  107. holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
  108. [holderV freshBlock:^{
  109. [self getMyTeachLogs];
  110. }];
  111. [self addV:holderV];
  112. [holderV setHidden:YES];
  113. [self setRefreshAction];
  114. //休学记录==> 获取教学日志类型==〉日志记录
  115. [self getStuXXList];
  116. }
  117. -(void)btnClick:(UIButton *)sender
  118. {
  119. if (sender.tag == 1) {
  120. //拨打电话
  121. NSString* tel = _stuDic[@"TSO_PHONE"];
  122. if (tel && ![tel isEqualToString:@""]) {
  123. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]]];
  124. }
  125. }
  126. if (sender.tag == 2) {
  127. if ([_stuDic[@"SUBJECT"] integerValue] == 1 || [_stuDic[@"SUBJECT"] integerValue] == 4) {
  128. ShowMsg(@"当前科目无需添加日志!");
  129. return;
  130. }
  131. AddRecordVC *vc = [[AddRecordVC alloc] init];
  132. vc.refreshTeachlogs = ^{
  133. [self headerRefresh];
  134. };
  135. vc.stuDic = _stuDic;
  136. vc.view.backgroundColor = backGroundColor;
  137. [vc configNavBar];
  138. [self.navigationController pushViewController:vc animated:YES];
  139. }
  140. if (sender.tag == 3) {
  141. DetailTJVC *TJVC = [[DetailTJVC alloc] init];
  142. [TJVC configNavBar];
  143. TJVC.view.backgroundColor = backGroundColor;
  144. [self.navigationController pushViewController:TJVC animated:YES];
  145. }
  146. }
  147. #pragma mark - 下拉刷新,上拉加载 -
  148. -(void)setRefreshAction{
  149. // 下拉刷新
  150. __weak typeof(self) weakSelf = self;
  151. MJRefreshNormalHeader *mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  152. [weakSelf headerRefresh];
  153. }];
  154. mainTableView.mj_header = mj_header;
  155. MJRefreshBackNormalFooter *mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  156. [weakSelf footerRefresh];
  157. }];
  158. mainTableView.mj_footer = mj_footer;
  159. }
  160. #pragma mark - 数据加载更多和刷新 -
  161. -(void)headerRefresh{
  162. //设置获取数据的方式
  163. _getDataType=MyGetDataTypeHeaderRefresh;
  164. //加载数据
  165. [self getMyTeachLogs];
  166. [mainTableView.mj_header endRefreshing];
  167. }
  168. -(void)footerRefresh{
  169. //设置获取数据的方式
  170. _getDataType=MyGetDataTypeFooterRefresh;
  171. //加载数据
  172. [self getMyTeachLogs];
  173. [mainTableView.mj_footer endRefreshing];
  174. }
  175. #pragma mark 数据请求
  176. //请求休学信息
  177. - (void)getStuXXList
  178. {
  179. [LoadingView showHUD];
  180. if (![Util connectedToNetWork]) {
  181. showMsgUnconnect();
  182. return;
  183. }
  184. NSMutableArray *arr=[NSMutableArray array];
  185. [arr addPro:@"stuSfzhm" Value:_stuDic[@"STU_SFZHM"]];
  186. [arr addPro:@"jxbh" Value:defUser.userDict[@"jxbh"]];
  187. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  188. [arr addPro:@"isPage" Value:@"0"];
  189. [arr addPro:@"pageSize" Value:@"0"];
  190. [arr addPro:@"currentPage" Value:@"0"];
  191. NSString* method = @"stuXXList";
  192. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  193. RemoveHUD();
  194. [self getTeachTypes];
  195. if (!root) {
  196. return ;
  197. }
  198. if ([root[@"code"] isEqualToString:@"1"]) {
  199. return;
  200. }
  201. xArray = root[@"body"];
  202. }];
  203. }
  204. //请求类型 有关日志信息
  205. - (void)getTeachTypes
  206. {
  207. NSMutableArray *array = [NSMutableArray arrayWithObjects:@"车辆基础操作",@"直线控制离合",@"倒车入库左倒",@"倒车入库右倒",@"科目二全套训练",@"预约科目二考试",@"考试日期",@"路跑",@"变更车道",@"会车与超车",@"靠边停车和掉头",@"灯光使用",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"", nil];
  208. NSMutableArray *arr = [NSMutableArray array];
  209. [arr addPro:@"subject" Value:@""];
  210. [arr addPro:@"type" Value:@"1"];
  211. NSString* method = @"getTeachTypes";
  212. [LoadingView showHUD];
  213. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  214. RemoveHUD();
  215. if (!root || [root[@"code"] isEqualToString:@"1"]) {
  216. NSString *filePath = [Tools getPathWithFileName:@"getTeachTypes.plist"];
  217. if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
  218. NSArray *arr = [NSArray arrayWithContentsOfFile:filePath];
  219. [teachTypes removeAllObjects];
  220. for (NSDictionary *dic in arr) {
  221. [teachTypes addObject:dic[@"TC_TEACH_TYPE"]];
  222. }
  223. }else{
  224. teachTypes = array;
  225. }
  226. [self headerRefresh];
  227. return;
  228. }
  229. NSString *filePath = [Tools getPathWithFileName:@"getTeachTypes.plist"];
  230. [root[@"body"] writeToFile:filePath atomically:YES];
  231. [teachTypes removeAllObjects];
  232. for (NSDictionary *dic in root[@"body"]) {
  233. [teachTypes addObject:dic[@"TC_TEACH_TYPE"]];
  234. }
  235. [self headerRefresh];
  236. }];
  237. }
  238. - (void)getMyTeachLogs
  239. {
  240. //判断当前是否正在加载数据。如果正在加载数据,直接return。
  241. if (_IS_LOADING) {
  242. return;
  243. }
  244. [LoadingView showHUD];
  245. _IS_LOADING=YES;
  246. //获取第一页数据
  247. NSInteger needLoadPage;
  248. needLoadPage=_currentPageNum+1;
  249. if (_getDataType==MyGetDataTypeHeaderRefresh) {
  250. needLoadPage=1;
  251. }
  252. NSString *queryValue = @"";
  253. if ([_stuDic isKindOfClass:[NSDictionary class]]) {
  254. if ([[_stuDic allKeys] count] != 0) {
  255. queryValue = _stuDic[@"TSO_ID"];// @lee 这个判断似乎没用
  256. }
  257. }
  258. NSMutableArray *arr=[NSMutableArray array];
  259. [arr addPro:@"queryValue" Value:queryValue];
  260. [arr addPro:@"isPage" Value:@"1"];
  261. [arr addPro:@"pageSize" Value:@"10"];
  262. [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%ld",(long)needLoadPage]];
  263. NSString* method = @"getMyTeachLogs";
  264. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  265. RemoveHUD();
  266. //设置加载状态
  267. _IS_LOADING=NO;
  268. //处理数据
  269. //如果获取到了数据,而且是下拉刷新,清空数组。
  270. if (_getDataType==MyGetDataTypeHeaderRefresh){
  271. [models removeAllObjects];
  272. }
  273. NSArray *bodyArray = root[@"body"];
  274. if (bodyArray && bodyArray.count > 0) {
  275. //追加数据
  276. [models addObjectsFromArray:bodyArray];
  277. //计数器+1
  278. _currentPageNum=needLoadPage;
  279. }
  280. if (xArray.count >0 || models.count >0) {
  281. [holderV setHidden:YES];
  282. }
  283. //刷新界面
  284. [mainTableView reloadData];
  285. //恢复初始状态。
  286. _getDataType=MyGetDataTypeNomal;
  287. }];
  288. }
  289. - (void)deleteTeachTypesWithRow:(NSInteger)row
  290. {
  291. if (![Util connectedToNetWork]) {
  292. showMsgUnconnect();
  293. return;
  294. }
  295. NSDictionary *dic = models[row];
  296. NSMutableArray *arr = [NSMutableArray array];
  297. [arr addPro:@"id" Value:dic[@"TL_ID"]];
  298. NSString* method = @"deleteMyTeachLog";
  299. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  300. RemoveHUD();
  301. //NSLog(@"日志删除---->%@----->%@",arr,root);
  302. if (!root) {
  303. return;
  304. }
  305. if ([root[@"code"] isEqualToString:@"1"]) {
  306. ShowMsg(root[@"body"]);
  307. }
  308. [models removeObjectAtIndex:row];
  309. [mainTableView reloadData];
  310. }];
  311. }
  312. #pragma mark - tableview delegate
  313. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  314. {
  315. if (xArray.count > 0 && models.count > 0) {
  316. return 2;
  317. }else{
  318. return 1;
  319. }
  320. }
  321. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  322. {
  323. UILabel *xLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
  324. xLabel.backgroundColor = [UIColor colorWithWhite:.9 alpha:1];
  325. xLabel.text = @"休学记录";
  326. xLabel.font = [UIFont scaleSize:20];
  327. xLabel.textAlignment = NSTextAlignmentCenter;
  328. UILabel *rLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
  329. rLabel.backgroundColor = [UIColor colorWithWhite:.9 alpha:1];
  330. rLabel.text = @"学员日志";
  331. rLabel.font = [UIFont scaleSize:20];
  332. rLabel.textAlignment = NSTextAlignmentCenter;
  333. if (xArray.count > 0 && models.count > 0) {
  334. if (section == 0) {
  335. return xLabel;
  336. }else{
  337. return rLabel;
  338. }
  339. }else if (xArray.count > 0){
  340. return xLabel;
  341. }else if (models.count > 0){
  342. return rLabel;
  343. }else{
  344. return [UILabel new];
  345. }
  346. }
  347. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  348. {
  349. return 40;
  350. }
  351. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  352. {
  353. return .1;
  354. }
  355. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  356. {
  357. if (xArray.count > 0 && models.count > 0) {
  358. if (section == 0) {
  359. return xArray.count;
  360. }else{
  361. return models.count;
  362. }
  363. }else if (xArray.count > 0){
  364. return xArray.count;
  365. }else if (models.count > 0){
  366. return models.count;
  367. }else{
  368. return 0;
  369. }
  370. }
  371. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  372. {
  373. RecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  374. if (cell == nil)
  375. {
  376. cell = [[RecordCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
  377. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  378. }
  379. @try {
  380. if (xArray.count > 0 && models.count > 0) {
  381. if (indexPath.section == 0) {
  382. NSDictionary *dic = xArray[indexPath.row];
  383. cell.textLabel.adjustsFontSizeToFitWidth = YES;
  384. cell.textLabel.text = [NSString stringWithFormat:@"● 该学员于%@休学",dic[@"CRDATE"]];
  385. cell.detailTextLabel.text = @"";
  386. if ([dic[@"REASON"] length] > 0) {
  387. cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: %@",dic[@"REASON"]];
  388. }
  389. if (cell.detailTextLabel.text.length > 0) {
  390. NSString *remarkString = cell.detailTextLabel.text;
  391. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  392. [aAttributedString addAttribute:NSForegroundColorAttributeName
  393. value:[UIColor orangeColor]
  394. range:NSMakeRange(0, 5)];
  395. [aAttributedString addAttribute:NSForegroundColorAttributeName
  396. value:contentTextColor
  397. range:NSMakeRange(5, remarkString.length - 5)];
  398. cell.detailTextLabel.attributedText = aAttributedString;
  399. }
  400. cell.detailTextLabel.numberOfLines = 0;
  401. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  402. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  403. cell.detailTextLabel.height = detailTextHight + 10;
  404. cell.dateLabel.text = @"";
  405. }else{
  406. NSDictionary *dic = models[indexPath.row];
  407. NSString *teachStyle = teachTypes[[dic[@"TL_TEACH_ID"] integerValue] - 1];
  408. NSString *remarkS = [NSString stringWithFormat:@"%d、[%@]",(int)indexPath.row + 1,teachStyle];
  409. NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:remarkS];
  410. [aString addAttribute:NSForegroundColorAttributeName
  411. value:[UIColor orangeColor]
  412. range:NSMakeRange(2, 1)];
  413. [aString addAttribute:NSForegroundColorAttributeName
  414. value:[UIColor orangeColor]
  415. range:NSMakeRange(remarkS.length - 1, 1)];
  416. cell.textLabel.attributedText = aString;
  417. cell.textLabel.adjustsFontSizeToFitWidth = NO;
  418. //日期
  419. NSString *km = [dic[@"TL_SUBJECT"] isEqualToString:@"2"]?@"科二":@"科三";
  420. NSString *dateString = dic[@"TL_CRDATE"];
  421. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  422. [formatter setDateFormat:@"yyyy-MM-dd"];
  423. NSDate *cDate = [formatter dateFromString:dateString];
  424. [formatter setDateFormat:@"MM.dd.yyyy"];
  425. dateString = [formatter stringFromDate:cDate];
  426. cell.dateLabel.text = [NSString stringWithFormat:@"%@ %@",dateString,km];
  427. //如果没有 就不显示
  428. //cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: 暂无备注"];
  429. cell.detailTextLabel.text = @"";
  430. if ([dic[@"TL_REMARK"] length] > 0) {
  431. cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: %@",dic[@"TL_REMARK"]];
  432. }
  433. if (cell.detailTextLabel.text.length > 0) {
  434. NSString *remarkString = cell.detailTextLabel.text;
  435. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  436. [aAttributedString addAttribute:NSForegroundColorAttributeName
  437. value:[UIColor orangeColor]
  438. range:NSMakeRange(0, 3)];
  439. [aAttributedString addAttribute:NSForegroundColorAttributeName
  440. value:contentTextColor
  441. range:NSMakeRange(3, remarkString.length - 3)];
  442. cell.detailTextLabel.attributedText = aAttributedString;
  443. }
  444. cell.detailTextLabel.numberOfLines = 0;
  445. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  446. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  447. cell.detailTextLabel.height = detailTextHight + 10;
  448. }
  449. }else if (xArray.count > 0){
  450. NSDictionary *dic = xArray[indexPath.row];
  451. //♦
  452. cell.textLabel.adjustsFontSizeToFitWidth = YES;
  453. cell.textLabel.text = [NSString stringWithFormat:@"● 该学员于%@被写入休学状态",dic[@"CRDATE"]];
  454. //cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: 暂无"];
  455. cell.detailTextLabel.text = @"";
  456. if ([dic[@"REASON"] length] > 0) {
  457. cell.detailTextLabel.text = [NSString stringWithFormat:@"休学原因: %@",dic[@"REASON"]];
  458. }
  459. if (cell.detailTextLabel.text.length > 0) {
  460. NSString *remarkString = cell.detailTextLabel.text;
  461. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  462. [aAttributedString addAttribute:NSForegroundColorAttributeName
  463. value:[UIColor orangeColor]
  464. range:NSMakeRange(0, 5)];
  465. [aAttributedString addAttribute:NSForegroundColorAttributeName
  466. value:contentTextColor
  467. range:NSMakeRange(5, remarkString.length - 5)];
  468. cell.detailTextLabel.attributedText = aAttributedString;
  469. }
  470. cell.detailTextLabel.numberOfLines = 0;
  471. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  472. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  473. cell.detailTextLabel.height = detailTextHight + 10;
  474. cell.dateLabel.text = @"";
  475. }
  476. else{
  477. NSDictionary *dic = models[indexPath.row];
  478. NSString *teachStyle = teachTypes[[dic[@"TL_TEACH_ID"] integerValue] - 1];
  479. NSString *remarkS = [NSString stringWithFormat:@"%d、[%@]",(int)indexPath.row + 1,teachStyle];
  480. NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:remarkS];
  481. [aString addAttribute:NSForegroundColorAttributeName
  482. value:[UIColor orangeColor]
  483. range:NSMakeRange(2, 1)];
  484. [aString addAttribute:NSForegroundColorAttributeName
  485. value:[UIColor orangeColor]
  486. range:NSMakeRange(remarkS.length - 1, 1)];
  487. cell.textLabel.attributedText = aString;
  488. cell.textLabel.adjustsFontSizeToFitWidth = NO;
  489. //日期
  490. NSString *km = [dic[@"TL_SUBJECT"] isEqualToString:@"2"]?@"科二":@"科三";
  491. NSString *dateString = dic[@"TL_CRDATE"];
  492. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  493. [formatter setDateFormat:@"yyyy-MM-dd"];
  494. NSDate *cDate = [formatter dateFromString:dateString];
  495. [formatter setDateFormat:@"MM.dd.yyyy"];
  496. dateString = [formatter stringFromDate:cDate];
  497. cell.dateLabel.text = [NSString stringWithFormat:@"%@ %@",dateString,km];
  498. //cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: 暂无备注"];
  499. cell.detailTextLabel.text = @"";
  500. if ([dic[@"TL_REMARK"] length] > 0) {
  501. cell.detailTextLabel.text = [NSString stringWithFormat:@"备注: %@",dic[@"TL_REMARK"]];
  502. }
  503. if (cell.detailTextLabel.text.length > 0) {
  504. NSString *remarkString = cell.detailTextLabel.text;
  505. NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:remarkString];
  506. [aAttributedString addAttribute:NSForegroundColorAttributeName
  507. value:[UIColor orangeColor]
  508. range:NSMakeRange(0, 3)];
  509. [aAttributedString addAttribute:NSForegroundColorAttributeName
  510. value:contentTextColor
  511. range:NSMakeRange(3, remarkString.length - 3)];
  512. cell.detailTextLabel.attributedText = aAttributedString;
  513. }
  514. cell.detailTextLabel.numberOfLines = 0;
  515. [cell.detailTextLabel setFont:[UIFont scaleSize:15]];
  516. CGFloat detailTextHight = [cell.detailTextLabel.text heightForWid:kSize.width - 20 Font:15];
  517. cell.detailTextLabel.height = detailTextHight + 10;
  518. }
  519. }
  520. @catch (NSException *exception) {
  521. }
  522. @finally {
  523. return cell;
  524. }
  525. }
  526. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  527. {
  528. if (xArray.count > 0 && indexPath.section == 0) {
  529. return 80.5;
  530. }
  531. NSDictionary *dic = models[indexPath.row];
  532. CGFloat height = [[NSString stringWithFormat:@"备注:%@",dic[@"TL_REMARK"]] heightForWid:kSize.width - 20 Font:15];
  533. return height + 70.5;
  534. }
  535. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  536. {
  537. if (xArray.count > 0 && models.count > 0) {
  538. if (indexPath.section == 0) {
  539. return;
  540. }else{
  541. AddRecordVC *vc = [[AddRecordVC alloc] init];
  542. vc.stuDic = _stuDic;
  543. vc.refreshTeachlogs = ^{
  544. [self headerRefresh];
  545. };
  546. vc.teachType = teachTypes;
  547. vc.recordDic = models[indexPath.row];
  548. vc.view.backgroundColor = backGroundColor;
  549. [vc configNavBar];
  550. [self.navigationController pushViewController:vc animated:YES];
  551. }
  552. }else if (xArray.count > 0){
  553. return;
  554. }else{
  555. AddRecordVC *vc = [[AddRecordVC alloc] init];
  556. vc.stuDic = _stuDic;
  557. vc.refreshTeachlogs = ^{
  558. [self headerRefresh];
  559. };
  560. vc.teachType = teachTypes;
  561. vc.recordDic = models[indexPath.row];
  562. vc.view.backgroundColor = backGroundColor;
  563. [vc configNavBar];
  564. [self.navigationController pushViewController:vc animated:YES];
  565. }
  566. }
  567. //表的编辑
  568. -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  569. {
  570. if (xArray.count > 0) {
  571. if (indexPath.section == 0) {
  572. return NO;
  573. }
  574. }
  575. return YES;
  576. }
  577. //记得默认是yes
  578. -(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
  579. {
  580. return YES;
  581. }
  582. -(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
  583. {
  584. return @"删除";
  585. }
  586. -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  587. {
  588. [self deleteTeachTypesWithRow:indexPath.row];
  589. }
  590. - (void)didReceiveMemoryWarning {
  591. [super didReceiveMemoryWarning];
  592. // Dispose of any resources that can be recreated.
  593. }
  594. @end