ComListCell.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //
  2. // ComListCell.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/5/31.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "ComListCell.h"
  9. #import "NSString+ex.h"
  10. @interface ComListCell()
  11. {
  12. UILabel *_coach;
  13. UILabel *_school;
  14. UILabel *_deptopinion;
  15. UILabel *_schopinion;
  16. UILabel *_content;
  17. UILabel *_student;
  18. UILabel *_time;
  19. UIButton *_oneBtn;
  20. UIView *_view;
  21. }
  22. @end
  23. @implementation ComListCell
  24. +(ComListCell *)cellForTabelView:(UITableView *)tableView{
  25. ComListCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ComListCell"];
  26. if (!cell) {
  27. cell = [[ComListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ComListCell"];
  28. }
  29. return cell;
  30. }
  31. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  32. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  33. self.selectionStyle = UITableViewCellSelectionStyleNone;
  34. self.contentView.backgroundColor = [UIColor whiteColor];
  35. NSArray * textArr = @[@"被投诉教练",@"机构名字",@"DEPTOPINION",@"SCHOPINION",@"评价内容",@"时间",@"学员"];
  36. NSMutableArray * labArr = [NSMutableArray new];
  37. //
  38. for (int i=0; i<textArr.count; i++) {
  39. UILabel * lab = [[UILabel alloc]init];
  40. lab.textColor = [UIColor blackColor];
  41. lab.textAlignment = NSTextAlignmentLeft;
  42. lab.font = [UIFont systemFontOfSize:14];
  43. [self.contentView addSubview:lab];
  44. [labArr addObject:lab];
  45. }
  46. _coach = labArr[0];
  47. _school = labArr[1];
  48. _deptopinion = labArr[2];
  49. _schopinion = labArr[3];
  50. _content = labArr[4];
  51. _time = labArr[5];
  52. _student = labArr[6];
  53. _time.textAlignment = NSTextAlignmentRight;
  54. _time.textColor = [UIColor lightGrayColor];
  55. _time.font = [UIFont systemFontOfSize:12];
  56. _content.numberOfLines = 0;
  57. _deptopinion.numberOfLines = 0;
  58. _schopinion.numberOfLines = 0;
  59. _oneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  60. [_oneBtn setTitle:@"处理" textColor:COLOR_THEME font:15 fotState:UIControlStateNormal];
  61. [_oneBtn setTitle:@"已处理" textColor:[UIColor lightGrayColor] font:14 fotState:UIControlStateSelected];
  62. [_oneBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  63. [self.contentView addSubview:_oneBtn];
  64. _view = [UIView new];
  65. _view.backgroundColor = KBackGroundColor;
  66. [self.contentView addSubview:_view];
  67. }
  68. return self;
  69. }
  70. - (void)updateWithDic:(NSDictionary *)dic {
  71. if ([dic[@"COACHNAME"] length] != 0) {
  72. _coach.text = [NSString stringWithFormat:@"被投诉教练 :%@",dic[@"COACHNAME"]];
  73. _school.text = [NSString stringWithFormat:@"所属机构 :%@",dic[@"SHORTNAME"]];
  74. }else{
  75. _coach.text = @"";
  76. _school.text = [NSString stringWithFormat:@"被投诉机构 :%@",dic[@"SHORTNAME"]];
  77. }
  78. NSString * timeStr = dic[@"TIME"];
  79. _time.text = [NSString stringWithFormat:@"%@",timeStr];
  80. if ([dic[@"CONTENT"] length] != 0) {
  81. _content.text = [NSString stringWithFormat:@"投诉内容 :%@",dic[@"CONTENT"]];
  82. }else{
  83. _content.text = @"";
  84. }
  85. if ([dic[@"SCHOPINION"] length] != 0) {
  86. _schopinion.text = [NSString stringWithFormat:@"机构意见 :%@",dic[@"SCHOPINION"]];
  87. }else{
  88. _schopinion.text = @"";
  89. }
  90. if ([dic[@"DEPTOPINION"] length] != 0) {
  91. _deptopinion.text = [NSString stringWithFormat:@"我的意见 :%@",dic[@"DEPTOPINION"]];
  92. _oneBtn.selected = YES;
  93. [_oneBtn borderColor:[UIColor lightGrayColor] width:1 cornorRadios:5];
  94. }else{
  95. _deptopinion.text = @"";
  96. _oneBtn.selected = NO;
  97. [_oneBtn borderColor:COLOR_THEME width:1 cornorRadios:5];
  98. }
  99. _student.text = [NSString stringWithFormat:@"学员 :%@",dic[@"TSO_NAME"]];
  100. }
  101. - (void)layoutSubviews{
  102. CGFloat wid = self.width;
  103. CGFloat x,y,w,h,bd;
  104. x = 0;
  105. w = wid;
  106. y = 0;
  107. h = 20;
  108. _view.frame = setDIYFrame;
  109. y += 5;
  110. x = 20;
  111. y += h;
  112. bd = 5;
  113. w = wid - 40;
  114. h = [_coach.text heightForWid:w Font:14];
  115. if (h != 0) {
  116. y += bd;
  117. }
  118. _coach.frame = setDIYFrame;
  119. _time.frame = setDIYFrame;
  120. y += h+bd;
  121. h = 17;
  122. _school.frame = setDIYFrame;
  123. if (_time.frame.size.height == 0) {
  124. _time.frame = setDIYFrame;
  125. }
  126. y += h;
  127. h = [_content.text heightForWid:w Font:14];
  128. if (h != 0) {
  129. y += bd;
  130. }
  131. _content.frame = setDIYFrame;
  132. y += h;
  133. h = [_schopinion.text heightForWid:w Font:14];
  134. if (h != 0) {
  135. y += bd;
  136. }
  137. _schopinion.frame = setDIYFrame;
  138. y += h;
  139. h = [_deptopinion.text heightForWid:w Font:14];
  140. if (h != 0) {
  141. y += bd;
  142. }
  143. _deptopinion.frame = setDIYFrame;
  144. y += h+bd;
  145. x = wid-70;
  146. h = 25;
  147. w = 50;
  148. _oneBtn.frame = setDIYFrame;
  149. // y += h;
  150. // _student.frame = setDIYFrame;
  151. }
  152. -(void)btnClick:(UIButton *)sender{
  153. if (self.block) {
  154. self.block();
  155. }
  156. }
  157. - (void)awakeFromNib {
  158. [super awakeFromNib];
  159. // Initialization code
  160. }
  161. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  162. [super setSelected:selected animated:animated];
  163. // Configure the view for the selected state
  164. }
  165. @end