// // InstallReceiptSearchCell.m // IBOSS // // Created by guan hong hou on 2017/8/29. // Copyright © 2017年 elongtian. All rights reserved. // // 功能描述:安装回执搜索单元格 #import "InstallReceiptSearchCell.h" #import "StatusInfo.h" #import "UIColor+hexColor.h" #import "SideSlipConfig.h" @implementation InstallReceiptSearchCell #pragma mark - 公有函数 /** 加载xib文件 */ - (void)awakeFromNib { [super awakeFromNib]; } /** 单元格高度 @return <#return value description#> */ - (CGFloat)cellHeight { return 601.5f; } /** 初始化回执类型 */ - (NSMutableArray *)getMutableArray{ NSMutableArray *arrayStatus = [[NSMutableArray alloc]init]; StatusInfo* s=[[StatusInfo alloc]init]; s.statusId=@"1"; s.name=@"完成"; [arrayStatus addObject:s]; s=[[StatusInfo alloc]init]; s.statusId=@"3"; s.name=@"推迟安装"; [arrayStatus addObject:s]; s=[[StatusInfo alloc]init]; s.statusId=@""; s.name=@"全部"; [arrayStatus addObject:s]; return arrayStatus; } #pragma mark - 委托函数 /** 状态回调函数 @param s <#s description#> */ - (void)showStatusValue:(StatusInfo*)s{ [_btnReceiptType setTitle:s.name forState:UIControlStateNormal]; _receiptType = s.statusId; [_searchModel setReceiptType:_receiptType]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 重置按钮 事件 */ - (void)resetData { [_txtArrangementNo setText:@""]; [_btnStartDate setTitle:@"请选择回执开始日期" forState:UIControlStateNormal]; [_btnEndDate setTitle:@"请选择回执结束日期" forState:UIControlStateNormal]; [_btnReceiptType setTitle:@"请选择回执类型" forState:UIControlStateNormal]; _searchModel.deliveryNo= @""; _searchModel.customerName=@""; _searchModel.customerAddress=@""; _searchModel.customerTelephone=@""; _searchModel.startDate =@""; _searchModel.endDate=@""; _searchModel.receiptType=@""; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 加载tableviewcell @param indexPath <#indexPath description#> @return <#return value description#> */ + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath { InstallReceiptSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"InstallReceiptSearchCell" owner:nil options:nil][0]; cell.txtArrangementNo.delegate=cell; cell.txtCustomerName.delegate=cell; cell.txtCustomerAddress.delegate=cell; cell.txtCustomerTelephone.delegate=cell; [cell configureKeyboard]; return cell; } /** 文本框编辑 @param textField <#textField description#> */ - (void)textFieldDidEndEditing:(UITextField *)textField { _searchModel.deliveryNo = [_txtArrangementNo.text stringByReplacingOccurrencesOfString:@" " withString:@""]; _searchModel.customerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""]; _searchModel.customerAddress = [_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""]; _searchModel.customerTelephone = [_txtCustomerTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 初始化cell数据 @param model <#model description#> @param indexPath <#indexPath description#> */ - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath { _slideModel = *model; _searchModel = [DeliveryReceiptSearchModel new]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict]; } /** 返回tableviewcell标识 @return <#return value description#> */ + (NSString *)cellReuseIdentifier { return @"SearchTableViewCell"; } /** 校验文本 @param textField <#textField description#> @param range <#range description#> @param string <#string description#> @return <#return value description#> */ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { return YES; } /** 触摸事件 @param touches <#touches description#> @param event <#event description#> */ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self hideKey]; [_txtArrangementNo resignFirstResponder]; [_txtCustomerName resignFirstResponder]; [_txtCustomerTelephone resignFirstResponder]; [_txtCustomerAddress resignFirstResponder]; } #pragma mark - 私有函数 /** 键盘配置 */ - (void)configureKeyboard { UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView]; _txtArrangementNo.inputAccessoryView=keyBoardAccessoryView; _txtCustomerName.inputAccessoryView=keyBoardAccessoryView; _txtCustomerAddress.inputAccessoryView=keyBoardAccessoryView; _txtCustomerTelephone.inputAccessoryView=keyBoardAccessoryView; } /** 开始日期点击事件 @param sender <#sender description#> */ - (IBAction)startDateAction:(id)sender { _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_brdatePicker configureSelectionBlock:^(NSString *date){ _startDate=date; } andCompletionBlock:^(void){ [_searchModel setStartDate:_startDate]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict =_mutDict; [_btnStartDate setTitle:_startDate forState:UIControlStateNormal]; } andCancelBlock:^(void){ _startDate=_btnStartDate.titleLabel.text; }]; [_brdatePicker show]; } /** 结束日期点击事件 @param sender <#sender description#> */ - (IBAction)endDateAction:(id)sender { _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_brdatePicker configureSelectionBlock:^(NSString *date){ _endDate=date; } andCompletionBlock:^(void){ [_searchModel setEndDate:_endDate]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; [_btnEndDate setTitle:_endDate forState:UIControlStateNormal]; } andCancelBlock:^(void){ _endDate=_btnEndDate.titleLabel.text; }]; [_brdatePicker show]; } /** 回执类型点击事件 @param sender <#sender description#> */ - (IBAction)receiptTypeAction:(id)sender { StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init]; tc.sdelegate = self; tc.isPresentViewFlag = YES; [tc.arrFilter addObjectsFromArray: [self getMutableArray]]; if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) { [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES]; } } /** 文本编辑时候 弹出取消完成按钮 @return <#return value description#> */ - (UIView *)createKeyBoardAccessoryView { UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)]; [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]]; UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)]; [backButton setTitle:@"取消" forState:UIControlStateNormal]; [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]]; [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside]; UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)]; [doneButton setTitle:@"完成" forState:UIControlStateNormal]; [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal]; [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]]; [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside]; [keyBoardAccessoryView addSubview:backButton]; [keyBoardAccessoryView addSubview:doneButton]; return keyBoardAccessoryView; } /** 取消文本 */ - (void)accessoryButtonBack { [self hideKey];} /** 确定文本 */ - (void)accessoryButtonDone { [_txtArrangementNo resignFirstResponder]; [_txtCustomerName resignFirstResponder]; [_txtCustomerTelephone resignFirstResponder]; [_txtCustomerAddress resignFirstResponder]; [self hideKey]; } /** * 隐藏键盘 */ - (void)hideKey { [self.contentView endEditing:YES]; } @end