// // OrderSalesSearchTableViewCell.m // IBOSSmini // // Created by guan hong hou on 2017/5/26. // Copyright © 2017年 elongtian. All rights reserved. // #import "OrderSalesSearchTableViewCell.h" #import "StatusInfoTextVC.h" #import "StatusInfo.h" #import "UIColor+hexColor.h" #import "SideSlipConfig.h" @implementation OrderSalesSearchTableViewCell /** awakeFromNib */ - (void)awakeFromNib { [super awakeFromNib]; } /** 单据类型 @param sender <#sender description#> */ - (IBAction)selectInvoiceType:(id)sender { [self initStatus]; StatusInfoTextVC *tc=[[StatusInfoTextVC alloc] init]; tc.sdelegate=self; tc.isPresentViewFlag=YES; [tc.filterArr addObjectsFromArray: _arrayStatus]; if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) { [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES]; } } #pragma mark -- 委托事件 -(void)showStatusValue:(StatusInfo *)s{ NSString *statusId=s.statusId; [_btnInvoiceType setTitle:s.name forState:UIControlStateNormal]; [_searchModel setInvoiceTypeId:statusId]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict =_mutDict; } /** 单据类型数据源 */ -(void)initStatus{ _arrayStatus=[NSMutableArray new]; StatusInfo* s=[[StatusInfo alloc]init]; s.statusId=@"0"; s.name=@"全部"; [_arrayStatus addObject:s]; s=[[StatusInfo alloc]init]; s.statusId=@"1"; s.name=@"订单"; [_arrayStatus addObject:s]; s=[[StatusInfo alloc]init]; s.statusId=@"2"; s.name=@"销售单"; [_arrayStatus addObject:s]; s=[[StatusInfo alloc]init]; s.statusId=@"3"; s.name=@"销售单(包含转单)"; [_arrayStatus addObject:s]; } /** 开始日期 @param sender <#sender description#> */ - (IBAction)selectStartDate:(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)selectEndDate:(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)changeCorrectStatus:(id)sender { if([_searchModel.correctStatus isEqualToString:@"1"]){ _searchModel.correctStatus=@"0"; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; [_btnFilter setTitle:@"未过滤" forState:UIControlStateNormal]; [ _btnFilter setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal]; _btnFilter.layer.borderColor=[UIColor lightGrayColor].CGColor; } else{ _searchModel.correctStatus=@"1"; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; [_btnFilter setTitle:@"已过滤" forState:UIControlStateNormal]; [ _btnFilter setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; _btnFilter.layer.borderColor=[UIColor redColor].CGColor; } } /** cell @param indexPath <#indexPath description#> @return <#return value description#> */ + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath { OrderSalesSearchTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"OrderSalesSearchTableViewCell" owner:nil options:nil][0]; cell.txtCustomerName.delegate = cell; cell.txtContactTelephone.delegate=cell; cell.btnFilter.layer.borderColor=[UIColor redColor].CGColor; [cell.btnFilter setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; cell.btnFilter.layer.borderWidth=1; [cell configureKeyboard]; return cell; } /** 键盘配置 */ - (void)configureKeyboard { UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView]; _txtCustomerName.inputAccessoryView = keyBoardAccessoryView; _txtContactTelephone.inputAccessoryView = keyBoardAccessoryView; } /** 高度 @return <#return value description#> */ - (CGFloat)cellHeight { return 505.0f; } /** 文本框编辑 @param textField <#textField description#> */ - (void)textFieldDidEndEditing:(UITextField *)textField { _searchModel.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""]; _searchModel.contactTelephone = [_txtContactTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** <#Description#> 关宏厚 2017-7-6 @param model <#model description#> @param indexPath <#indexPath description#> */ - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath { _slideModel=*model; _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict]; _searchModel=[OrderSalesSearchModel new]; _searchModel.correctStatus=@"1"; NSString *startDateStr= [DateFormat getDateBefore:7]; NSString *endDataStr=[DateFormat getCurrentDate]; [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal]; _startDate= _btnStartDate.titleLabel.text; [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal]; _endDate= _btnEndDate.titleLabel.text; _searchModel.startDate=_startDate; _searchModel.endDate=_endDate; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } + (NSString *)cellReuseIdentifier { return @"SearchTableViewCell"; } /** 文本编辑时候 弹出取消完成按钮 @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; } /** 长度 @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]; [_txtCustomerName resignFirstResponder]; [_txtContactTelephone resignFirstResponder]; } /** 取消文本 */ - (void)accessoryButtonBack { [self hideKey];} /** 确定文本 */ - (void)accessoryButtonDone { [_txtCustomerName resignFirstResponder]; [_txtContactTelephone resignFirstResponder]; [self hideKey]; } /** * 隐藏键盘 */ - (void)hideKey { [self.contentView endEditing:YES]; } @end