SalesOrderGradeVC.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //
  2. // IntermediateCustomerVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/2/1.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesOrderGradeVC.h"
  9. @interface SalesOrderGradeVC ()
  10. @end
  11. @implementation SalesOrderGradeVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self loadNavStyle];
  15. _gradeCheckedList=[[NSMutableArray alloc]init];
  16. }
  17. -(void)loadNavStyle
  18. {
  19. UIView *vTitle = [[UIView alloc]init];
  20. //是否是dismissViewController
  21. if (_isPresentViewFlag) {
  22. vTitle.frame = CGRectMake(0, 0, Screen_Width, 44 + rectStatusHeight);
  23. vTitle.backgroundColor = NavigationBarTintColor;
  24. [self.view addSubview:vTitle];
  25. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  26. [button setImage:[UIImage imageNamed:@"icon_back"]
  27. forState:UIControlStateNormal];
  28. [button addTarget:self action:@selector(goBack)
  29. forControlEvents:UIControlEventTouchUpInside];
  30. button.frame = CGRectMake(20, rectStatusHeight + 13, 9, 15);
  31. [vTitle addSubview:button];
  32. UILabel *lblTitle = [[UILabel alloc]init];
  33. lblTitle.frame = CGRectMake(9, rectStatusHeight + 13, Screen_Width-2*9 - 20, 15);
  34. lblTitle.textColor = [UIColor whiteColor];
  35. lblTitle.text = @"请选择";
  36. lblTitle.textAlignment = NSTextAlignmentCenter;
  37. [vTitle addSubview:lblTitle];
  38. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
  39. [rightButton setTitle:@"确定" forState:UIControlStateNormal];
  40. [rightButton addTarget:self action:@selector(submitData)
  41. forControlEvents:UIControlEventTouchUpInside];
  42. rightButton.frame = CGRectMake(Screen_Width-50, rectStatusHeight + 13,50, 15);
  43. [vTitle addSubview:rightButton];
  44. }
  45. else
  46. {
  47. self.navigationItem.title = @"请选择";
  48. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  49. [button setImage:[UIImage imageNamed:@"icon_back"]
  50. forState:UIControlStateNormal];
  51. [button addTarget:self action:@selector(goBack)
  52. forControlEvents:UIControlEventTouchUpInside];
  53. button.frame = CGRectMake(0, 0,45,22);
  54. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  55. self.navigationItem.leftBarButtonItem = menuButton;
  56. [self.navigationController setNavigationBarHidden:NO];
  57. //右边
  58. UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
  59. [btnAdd addTarget:self action:@selector(submitData)
  60. forControlEvents:UIControlEventTouchUpInside];
  61. btnAdd.frame = CGRectMake(0, 0,60,14);
  62. [btnAdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  63. btnAdd.titleLabel.font=[UIFont systemFontOfSize:16];
  64. [btnAdd setTitle:@"确定" forState:UIControlStateNormal];
  65. }
  66. _tableView = [UITableView new];
  67. _tableView.delegate=self;
  68. _tableView.dataSource=self;
  69. //是否是dismissViewController
  70. if (_isPresentViewFlag) {
  71. self.tableView.frame = CGRectMake(0,CGRectGetMaxY(vTitle.frame), self.view.bounds.size.width, self.view.bounds.size.height -CGRectGetMaxY(vTitle.frame)) ;
  72. }
  73. else{
  74. self.tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-rectNavHeight - rectStatusHeight - 1) ;
  75. }
  76. [self.view addSubview:_tableView];
  77. if(_gradeList!=nil&&_gradeList.count>0){
  78. [_tableView reloadData];
  79. }
  80. //返回
  81. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  82. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  83. forState:UIControlStateNormal];
  84. [button addTarget:self action:@selector(goBack)
  85. forControlEvents:UIControlEventTouchUpInside];
  86. button.frame = CGRectMake(0, 0, 15, 18);
  87. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  88. self.navigationItem.leftBarButtonItem = menuButton;
  89. }
  90. -(void)submitData{
  91. for(GradeFrame *frame in _gradeList){
  92. if(frame.gModel.isCheckedStatus){
  93. [_gradeCheckedList addObject:frame];
  94. }
  95. }
  96. if([self.gradeDelegate respondsToSelector:@selector(showGradeInfo:)])
  97. {
  98. [self.gradeDelegate showGradeInfo:_gradeCheckedList];
  99. }
  100. if (_isPresentViewFlag) {
  101. [self dismissViewControllerAnimated:YES completion:nil];
  102. }else{
  103. [self.navigationController popViewControllerAnimated:YES];
  104. }
  105. }
  106. #pragma mark - tableView回调
  107. /**
  108. 单元格cell个数
  109. @param tableView <#tableView description#>
  110. @param section <#section description#>
  111. @return <#return value description#>
  112. */
  113. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  114. {
  115. return [_gradeList count];
  116. }
  117. /**
  118. <#Description#>
  119. @param tableView <#tableView description#>
  120. @return <#return value description#>
  121. */
  122. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  123. return 1;
  124. }
  125. /**
  126. 高度
  127. @param tableView <#tableView description#>
  128. @param indexPath <#indexPath description#>
  129. @return <#return value description#>
  130. */
  131. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  132. GradeFrame *frame= [_gradeList objectAtIndex:indexPath.row];
  133. return frame.cellHeight ;
  134. }
  135. /**
  136. 每个单元格cell
  137. @param tableView <#tableView description#>
  138. @param indexPath <#indexPath description#>
  139. @return <#return value description#>
  140. */
  141. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  142. {
  143. static NSString *cellIdentifier = @"GradeCell";
  144. GradeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  145. cell=[[GradeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  146. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  147. GradeFrame *gradeFrame = [_gradeList objectAtIndex:indexPath.row];
  148. cell.delegate = self;
  149. [cell parseGradeInfo:gradeFrame];
  150. cell.cellIndex=indexPath.row;
  151. BOOL checked = gradeFrame.gModel.isCheckedStatus;
  152. [cell setCheckBackground:checked];
  153. return cell;
  154. }
  155. -(void) btnGradeCheckPressed:(GradeCell *)cell{
  156. GradeFrame *gradeFrame= _gradeList[cell.cellIndex];
  157. GradeModel *gradeModel= gradeFrame.gModel;
  158. gradeModel.isCheckedStatus=!gradeModel.isCheckedStatus;
  159. [_tableView reloadData];
  160. }
  161. - (void)goBack
  162. {
  163. if([self.gradeDelegate respondsToSelector:@selector(recoveryData)])
  164. {
  165. [self.gradeDelegate recoveryData];
  166. }
  167. if (_isPresentViewFlag) {
  168. [self dismissViewControllerAnimated:YES completion:nil];
  169. }else{
  170. [self.navigationController popViewControllerAnimated:YES];
  171. }
  172. }
  173. - (void)didReceiveMemoryWarning {
  174. [super didReceiveMemoryWarning];
  175. }
  176. @end