IntermediateCustomerVC.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 "IntermediateCustomerVC.h"
  9. @interface IntermediateCustomerVC ()
  10. @end
  11. @implementation IntermediateCustomerVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self loadNavStyle];
  15. _intermediateCustomerCheckedList=[[NSMutableArray alloc]init];
  16. [self initUI];
  17. }
  18. -(void)loadNavStyle
  19. {
  20. //右边
  21. UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
  22. [btnAdd addTarget:self action:@selector(submitData)
  23. forControlEvents:UIControlEventTouchUpInside];
  24. btnAdd.frame = CGRectMake(0, 0,60,14);
  25. [btnAdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  26. btnAdd.titleLabel.font=[UIFont systemFontOfSize:16];
  27. [btnAdd setTitle:@"确定" forState:UIControlStateNormal];
  28. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:btnAdd];
  29. self.navigationItem.title=@"请选择";
  30. self.navigationItem.rightBarButtonItem = menubtnAdd;
  31. //返回
  32. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  33. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  34. forState:UIControlStateNormal];
  35. [button addTarget:self action:@selector(goBack)
  36. forControlEvents:UIControlEventTouchUpInside];
  37. button.frame = CGRectMake(0, 0, 15, 18);
  38. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  39. self.navigationItem.leftBarButtonItem = menuButton;
  40. }
  41. -(void)submitData{
  42. for(IntermediateCustomerFrame *frame in _intermediateCustomerList){
  43. if(frame.intermediateCustomerModel.isCheckedStatus){
  44. [_intermediateCustomerCheckedList addObject:frame];
  45. }
  46. }
  47. if([self.intermediateCustomerDelegate respondsToSelector:@selector(showIntermediateCustomerInfo:)])
  48. {
  49. [self.intermediateCustomerDelegate showIntermediateCustomerInfo:_intermediateCustomerCheckedList];
  50. }
  51. [self.navigationController popViewControllerAnimated:YES];
  52. }
  53. -(void)initUI{
  54. _vTableView = [[UITableView alloc]
  55. initWithFrame:CGRectMake(0,
  56. 0,
  57. self.view.frame.size.width,
  58. self.view.frame.size.height)];
  59. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  60. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  61. _vTableView.backgroundColor = [UIColor whiteColor];
  62. _vTableView.delegate = self;
  63. _vTableView.dataSource=self;
  64. [self.view addSubview:_vTableView];
  65. if(_intermediateCustomerList!=nil&&_intermediateCustomerList.count>0){
  66. [_vTableView reloadData];
  67. }
  68. }
  69. #pragma mark - tableView回调
  70. /**
  71. 单元格cell个数
  72. @param tableView <#tableView description#>
  73. @param section <#section description#>
  74. @return <#return value description#>
  75. */
  76. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  77. {
  78. return [_intermediateCustomerList count];
  79. }
  80. /**
  81. <#Description#>
  82. @param tableView <#tableView description#>
  83. @return <#return value description#>
  84. */
  85. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  86. return 1;
  87. }
  88. /**
  89. 高度
  90. @param tableView <#tableView description#>
  91. @param indexPath <#indexPath description#>
  92. @return <#return value description#>
  93. */
  94. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  95. IntermediateCustomerFrame *frame= [_intermediateCustomerList objectAtIndex:indexPath.row];
  96. return frame.cellHeight ;
  97. }
  98. /**
  99. 每个单元格cell
  100. @param tableView <#tableView description#>
  101. @param indexPath <#indexPath description#>
  102. @return <#return value description#>
  103. */
  104. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  105. {
  106. static NSString *cellIdentifier = @"IntermediateCustomerCell";
  107. IntermediateCustomerCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  108. cell=[[IntermediateCustomerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  109. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  110. IntermediateCustomerFrame *intermediateCustomerFrame = [_intermediateCustomerList objectAtIndex:indexPath.row];
  111. cell.delegate = self;
  112. [cell parseIntermediateCustomerInfo:intermediateCustomerFrame];
  113. cell.cellIndex=indexPath.row;
  114. BOOL checked = intermediateCustomerFrame.intermediateCustomerModel.isCheckedStatus;
  115. [cell setCheckBackground:checked];
  116. return cell;
  117. }
  118. -(void) btnIntermediateCustomerCheckPressed:(IntermediateCustomerCell *)cell{
  119. IntermediateCustomerFrame *customerFrame= _intermediateCustomerList[cell.cellIndex];
  120. IntermediateCustomerModel *customerModel= customerFrame.intermediateCustomerModel;
  121. customerModel.isCheckedStatus=!customerModel.isCheckedStatus;
  122. [_vTableView reloadData];
  123. }
  124. - (void)goBack
  125. {
  126. if([self.intermediateCustomerDelegate respondsToSelector:@selector(recoveryData)])
  127. {
  128. [self.intermediateCustomerDelegate recoveryData];
  129. }
  130. [self.navigationController popViewControllerAnimated:YES];
  131. }
  132. - (void)didReceiveMemoryWarning {
  133. [super didReceiveMemoryWarning];
  134. }
  135. @end