// // ReceiveBoltView.m // XFFruit // // Created by 陈俊俊 on 15/10/13. // Copyright (c) 2015年 Xummer. All rights reserved. // #import "ReceiveBoltView.h" #import "MaskCell.h" #define TableHeight 45 #define LeftMargin 80 #define TotalHeight 224 #define LeftHeight 44 #define BottomHeight 50 @interface ReceiveBoltView () { UIView *_leftView; UIButton *_currentBtn; NSIndexPath *_currentIndexPath; NSString *_state; UIButton *_clearBtn; } @property (nonatomic,strong)NSString *state; @property (nonatomic,strong)NSString *billNumber; @property (nonatomic,strong)NSString *goodLike; @end @implementation ReceiveBoltView - (instancetype)initWithFrame:(CGRect)frame state:(NSString *)state billNumber:(NSString *)billNumber goodLike:(NSString *)goodLike{ self = [super initWithFrame:frame]; if (self) { self.billNumber = billNumber; self.goodLike = goodLike; self.state = state; [self createView]; [self createRightView]; [self preferData]; } return self; } - (void)preferData{ if ([self.state isEqualToString:TRANSPORT_STATE_UNRECEIVED]) { _currentIndexPath = [NSIndexPath indexPathForRow:0 inSection:0]; }else if ([self.state isEqualToString:TRANSPORT_STATE_RECEIVED]) { _currentIndexPath = [NSIndexPath indexPathForRow:1 inSection:0]; }else if ([self.state isEqualToString:TRANSPORT_STATE_PROCESS]) { _currentIndexPath = [NSIndexPath indexPathForRow:2 inSection:0]; }else if ([self.state isEqualToString:TRANSPORT_STATE_PROCESSFAIL]) { _currentIndexPath = [NSIndexPath indexPathForRow:3 inSection:0]; } else { } self.billFiled.hidden = YES; if(self.billNumber.length > 0){ self.billFiled.text = self.billNumber; } self.goodFiled.hidden = YES; if (self.goodLike.length > 0) { self.goodFiled.text = self.goodLike; } } #pragma mark - 创建视图 - (void)createView { _leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, LeftMargin,self.frame.size.height- BottomHeight)]; [self addSubview:_leftView]; NSArray *arr = @[@"按状态",@"单号等于",@"商品类似于"]; for (NSInteger i = 0; i 0) { cell.Commitbtn.hidden = YES; [cell setTitleStr:self.dataArr[indexPath.row]]; } if (_currentIndexPath) { if (indexPath.row == _currentIndexPath.row) { cell.Commitbtn.hidden = NO; }else{ cell.Commitbtn.hidden = YES; } } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //获取选中的cell MaskCell *currentCell = (MaskCell *)[tableView cellForRowAtIndexPath:_currentIndexPath]; currentCell.Commitbtn.hidden = YES; MaskCell *cell = (MaskCell *)[tableView cellForRowAtIndexPath:indexPath]; cell.Commitbtn.hidden = NO; _currentIndexPath = indexPath; NSString *stateStr = @""; if (indexPath.row == 0) { stateStr = TRANSFER_STATE_UNRECEIVED; }else if(indexPath.row == 1){ stateStr = TRANSFER_STATE_RECEIVED; }else if(indexPath.row == 2){ stateStr = TRANSFER_STATE_PROCESS; }else if(indexPath.row == 3){ stateStr = TRANSFER_STATE_PROCESSFAIL; } [self.delegate getBoltValueSelectRow:stateStr]; } - (void)textFieldDidEndEditing:(UITextField *)textField{ if (textField == self.billFiled) { // if (self.userFiled.text.length > 0) { [self.delegate getBillNumberEqual:self.billFiled.text]; // } }else if(textField == self.goodFiled){ // if (self.billFiled.text.length > 0) { [self.delegate getGoodLike:self.goodFiled.text]; // } } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return TableHeight; } @end