| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- //
- // IntermediateCustomerVC.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/2/1.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "SalesOrderGradeVC.h"
- @interface SalesOrderGradeVC ()
- @end
- @implementation SalesOrderGradeVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self loadNavStyle];
- _gradeCheckedList=[[NSMutableArray alloc]init];
-
- }
- -(void)loadNavStyle
- {
- UIView *vTitle = [[UIView alloc]init];
- //是否是dismissViewController
- if (_isPresentViewFlag) {
-
- vTitle.frame = CGRectMake(0, 0, Screen_Width, 44 + rectStatusHeight);
- vTitle.backgroundColor = NavigationBarTintColor;
- [self.view addSubview:vTitle];
-
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(20, rectStatusHeight + 13, 9, 15);
- [vTitle addSubview:button];
- UILabel *lblTitle = [[UILabel alloc]init];
- lblTitle.frame = CGRectMake(9, rectStatusHeight + 13, Screen_Width-2*9 - 20, 15);
- lblTitle.textColor = [UIColor whiteColor];
- lblTitle.text = @"请选择";
- lblTitle.textAlignment = NSTextAlignmentCenter;
- [vTitle addSubview:lblTitle];
-
- UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [rightButton setTitle:@"确定" forState:UIControlStateNormal];
- [rightButton addTarget:self action:@selector(submitData)
- forControlEvents:UIControlEventTouchUpInside];
- rightButton.frame = CGRectMake(Screen_Width-50, rectStatusHeight + 13,50, 15);
- [vTitle addSubview:rightButton];
- }
- else
- {
- self.navigationItem.title = @"请选择";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- [self.navigationController setNavigationBarHidden:NO];
- //右边
- UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
- [btnAdd addTarget:self action:@selector(submitData)
- forControlEvents:UIControlEventTouchUpInside];
- btnAdd.frame = CGRectMake(0, 0,60,14);
- [btnAdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- btnAdd.titleLabel.font=[UIFont systemFontOfSize:16];
- [btnAdd setTitle:@"确定" forState:UIControlStateNormal];
-
- }
-
- _tableView = [UITableView new];
- _tableView.delegate=self;
- _tableView.dataSource=self;
-
- //是否是dismissViewController
- if (_isPresentViewFlag) {
- self.tableView.frame = CGRectMake(0,CGRectGetMaxY(vTitle.frame), self.view.bounds.size.width, self.view.bounds.size.height -CGRectGetMaxY(vTitle.frame)) ;
- }
- else{
- self.tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-rectNavHeight - rectStatusHeight - 1) ;
- }
-
- [self.view addSubview:_tableView];
-
-
- if(_gradeList!=nil&&_gradeList.count>0){
- [_tableView reloadData];
- }
-
-
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0, 15, 18);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- }
- -(void)submitData{
- for(GradeFrame *frame in _gradeList){
- if(frame.gModel.isCheckedStatus){
- [_gradeCheckedList addObject:frame];
- }
- }
- if([self.gradeDelegate respondsToSelector:@selector(showGradeInfo:)])
- {
- [self.gradeDelegate showGradeInfo:_gradeCheckedList];
-
- }
- if (_isPresentViewFlag) {
- [self dismissViewControllerAnimated:YES completion:nil];
- }else{
- [self.navigationController popViewControllerAnimated:YES];
- }
-
-
- }
- #pragma mark - tableView回调
- /**
- 单元格cell个数
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_gradeList count];
- }
- /**
- <#Description#>
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 高度
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- GradeFrame *frame= [_gradeList objectAtIndex:indexPath.row];
- return frame.cellHeight ;
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifier = @"GradeCell";
- GradeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
- cell=[[GradeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- GradeFrame *gradeFrame = [_gradeList objectAtIndex:indexPath.row];
- cell.delegate = self;
- [cell parseGradeInfo:gradeFrame];
- cell.cellIndex=indexPath.row;
- BOOL checked = gradeFrame.gModel.isCheckedStatus;
- [cell setCheckBackground:checked];
- return cell;
- }
- -(void) btnGradeCheckPressed:(GradeCell *)cell{
- GradeFrame *gradeFrame= _gradeList[cell.cellIndex];
- GradeModel *gradeModel= gradeFrame.gModel;
- gradeModel.isCheckedStatus=!gradeModel.isCheckedStatus;
- [_tableView reloadData];
- }
- - (void)goBack
- {
- if([self.gradeDelegate respondsToSelector:@selector(recoveryData)])
- {
- [self.gradeDelegate recoveryData];
-
- }
-
- if (_isPresentViewFlag) {
- [self dismissViewControllerAnimated:YES completion:nil];
- }else{
- [self.navigationController popViewControllerAnimated:YES];
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- @end
|