DetailTJVC.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //
  2. // DetailTJVC.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/3/18.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "DetailTJVC.h"
  9. #import "PickTimeV.h"
  10. #import "DateView.h"
  11. #import "TJCell.h"
  12. @interface DetailTJVC ()<UITableViewDataSource,UITableViewDelegate>
  13. {
  14. UITableView *mainTableView;
  15. HolderView *holderV;
  16. UIButton *styleBtn,*beginTBtn,*endTBtn;
  17. UILabel *numLabel;
  18. NSArray *dataArray;
  19. NSString *exerciseStyle;
  20. NSString *beginDate;
  21. NSString *endDate;
  22. }
  23. @end
  24. @implementation DetailTJVC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.title = @"日志统计";
  28. float bd,x,y,w,h;
  29. x = bd = 10;
  30. y = kNavOffSet + 10;
  31. w = kSize.width - 20;
  32. h = 50;
  33. UIView *bgView;
  34. UILabel *label;
  35. UIButton *button;
  36. bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
  37. [bgView boardWid:2 Color:lineColor];
  38. [bgView corner:5];
  39. [self addV:bgView];
  40. label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , w - bd, h)];
  41. [label setText:[NSString stringWithFormat:@"统计类型:"] Font:18 TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
  42. [self addV:label];
  43. float widt = [label.text sizeForFont:18].width;
  44. button = [[UIButton alloc] initWithFrame:CGRectMake(x + widt - 10, y , w - widt + 10, h)];
  45. [button setTitle:@"请选择日志类型" textColor:defGreen font:17 fotState:UIControlStateNormal];
  46. [button target:self Tag:1];
  47. [self addV:button];
  48. styleBtn = button;
  49. y += h + bd;
  50. bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
  51. [bgView boardWid:2 Color:lineColor];
  52. [bgView corner:5];
  53. [self addV:bgView];
  54. NSString *titString = @"统计时间:";
  55. float wid = [titString sizeForFont:18].width;
  56. label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , wid, h)];
  57. [label setText:titString Font:18 TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
  58. [self addV:label];
  59. x += 4 + wid;
  60. w = (w - 10 - wid)/2.0;
  61. label = [[UILabel alloc] initWithFrame:CGRectMake(x + w - 2, y + h/2.0, 10, 2)];
  62. label.backgroundColor = contentTextColor;
  63. [self addV:label];
  64. button = [[UIButton alloc] initWithFrame:CGRectMake(x, y , w, h)];
  65. [button setTitle:@"请选择开始时间" textColor:defGreen font:17 fotState:UIControlStateNormal];
  66. [button target:self Tag:2];
  67. [self addV:button];
  68. beginTBtn = button;
  69. x += w + 6;
  70. button = [[UIButton alloc] initWithFrame:CGRectMake(x , y , w, h)];
  71. [button setTitle:@"请选择结束时间" textColor:defGreen font:17 fotState:UIControlStateNormal];
  72. [button target:self Tag:3];
  73. [self addV:button];
  74. endTBtn = button;
  75. x = bd;
  76. y += h + 5;
  77. w = 200;
  78. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y , w, h)];
  79. label.backgroundColor = backGroundColor;
  80. [label setText:titString Font:18 TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
  81. label.text = @"当前条件下共有0人";
  82. [self addV:label];
  83. numLabel = label;
  84. x = kSize.width - 100;
  85. h = 40;
  86. w = 80;
  87. button = [[UIButton alloc] initWithFrame:CGRectMake(x , y , w, h)];
  88. [button setTitle:@"查询" textColor:[UIColor whiteColor] font:18 fotState:UIControlStateNormal];
  89. button.backgroundColor = defGreen;
  90. [button corner:10];
  91. [button target:self Tag:4];
  92. [self addV:button];
  93. label = [[UILabel alloc] initWithFrame:CGRectMake(bd, y + 48, kSize.width - 2*bd, 2)];
  94. label.backgroundColor = lineColor;
  95. [self addV:label];
  96. mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  97. mainTableView.delegate = self;
  98. mainTableView.backgroundColor = backGroundColor;
  99. mainTableView.dataSource = self;
  100. mainTableView.y = y + 50;
  101. mainTableView.height = kSize.height - y - 50;
  102. mainTableView.tableFooterView = [UIView new];
  103. [self addV:mainTableView];
  104. holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
  105. holderV.backgroundColor = backGroundColor;
  106. [holderV freshBlock:^{
  107. [self getMyTeachStatistics];
  108. }];
  109. [self addV:holderV];
  110. }
  111. -(void)btnClick:(UIButton *)sender
  112. {
  113. if (sender.tag == 1) {
  114. //选择日记类型
  115. PickTimeV *pickV = [[PickTimeV alloc] init];
  116. //23 无实意 只是为了让picktimeV 与之对应
  117. pickV.KM = @"23";
  118. [pickV setWhichVC:@"AddRecordVC"];
  119. [pickV complete:^(NSDictionary* obj) {
  120. [styleBtn setTitle:obj[@"TC_TEACH_TYPE"] forState:UIControlStateNormal];
  121. exerciseStyle = obj[@"TC_ID"];
  122. }];
  123. [pickV show];
  124. }
  125. if (sender.tag == 2) {
  126. //选择日志开始时间
  127. DateView *dateV = [[DateView alloc] init];
  128. [dateV setStyle:0];
  129. [dateV showWithComplete:^(NSString * result) {
  130. //NSLog(@"kaishi-->%@",result); //eg:2016-03-11
  131. beginDate = result;
  132. [beginTBtn setTitle:beginDate forState:UIControlStateNormal];
  133. }];
  134. }
  135. if (sender.tag == 3) {
  136. //选择日志结束时间
  137. DateView *dateV = [[DateView alloc] init];
  138. [dateV setStyle:0];
  139. [dateV showWithComplete:^(NSString * result) {
  140. //NSLog(@"jieshu-->%@",result); //eg:2016-03-11
  141. endDate = result;
  142. [endTBtn setTitle:endDate forState:UIControlStateNormal];
  143. }];
  144. }
  145. if (sender.tag == 4) {
  146. [self getMyTeachStatistics];
  147. }
  148. }
  149. //tableview delegate
  150. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  151. {
  152. return dataArray.count;
  153. }
  154. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  155. {
  156. TJCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  157. if (cell == nil)
  158. {
  159. cell = [[TJCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  160. }
  161. NSDictionary *dic = dataArray[indexPath.row];
  162. NSString *dateString = dic[@"TL_CRDATE"];
  163. if (dateString.length > 10) {
  164. dateString = [dateString substringWithRange:NSMakeRange(5, 5)];
  165. }
  166. NSString *dString = [NSString stringWithFormat:@"%@ [%@]",dic[@"TELPHONE"],dateString];
  167. if (dString.length > 8)
  168. {
  169. NSMutableAttributedString * aString = [[NSMutableAttributedString alloc] initWithString:dString];
  170. [aString addAttribute:NSForegroundColorAttributeName
  171. value:[UIColor redColor]
  172. range:NSMakeRange(dString.length - 7, 1)];
  173. [aString addAttribute:NSForegroundColorAttributeName
  174. value:[UIColor redColor]
  175. range:NSMakeRange(dString.length - 1, 1)];
  176. cell.dateLabel.attributedText = aString;
  177. }else{
  178. //防止没电话号码导致意外
  179. cell.dateLabel.text = dString;
  180. }
  181. cell.textLabel.text = [NSString stringWithFormat:@"%d、%@",(int)indexPath.row + 1,dic[@"TL_NAME"]];
  182. return cell;
  183. }
  184. //数据请求
  185. - (void)getMyTeachStatistics
  186. {
  187. [LoadingView showHUD];
  188. if (![Util connectedToNetWork]) {
  189. showMsgUnconnect();
  190. return;
  191. }
  192. NSMutableArray *arr=[NSMutableArray array];
  193. [arr addPro:@"coaSfzhm" Value:defUser.userDict[@"idcard"]];
  194. if (exerciseStyle) {
  195. [arr addPro:@"teachId" Value:exerciseStyle];
  196. }
  197. [arr addPro:@"startDate" Value:beginDate];
  198. [arr addPro:@"endDate" Value:endDate];
  199. NSString* method = @"getMyTeachStatistics";
  200. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  201. RemoveHUD();
  202. //NSLog(@"日志统计---->%@----->%@",arr,root);
  203. [holderV setHidden:NO];
  204. if (!root) {
  205. ShowMsgFailed();
  206. return ;
  207. }
  208. if ([root[@"code"] isEqualToString:@"1"]) {
  209. ShowMsg(root[@"body"]);
  210. return;
  211. }
  212. if ([[root[@"body"] allKeys] containsObject:@"COUNT"]) {
  213. NSString *num = [root[@"body"] objectForKey:@"COUNT"];
  214. numLabel.text = [NSString stringWithFormat:@"当前条件下共有%@人",num];
  215. }
  216. if ([[root[@"body"] allKeys] containsObject:@"LIST"]) {
  217. dataArray = [root[@"body"] objectForKey:@"LIST"];
  218. if ([dataArray count] == 0) {
  219. ShowMsg(@"暂无数据");
  220. }else{
  221. [holderV setHidden:YES];
  222. [mainTableView reloadData];
  223. }
  224. }
  225. }];
  226. }
  227. - (void)didReceiveMemoryWarning {
  228. [super didReceiveMemoryWarning];
  229. // Dispose of any resources that can be recreated.
  230. }
  231. @end