| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //
- // StockingSearchCell.m
- // IBOSSmini
- //
- // Created by apple on 2017/5/27.
- // Copyright © 2017年 elongtian. All rights reserved.
- //
- #import "StockingSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SideSlipConfig.h"
- #import "StockingSearchModel.h"
- #import "SideSlipModel.h"
- @interface StockingSearchCell()<UITextFieldDelegate>
- @property (strong, nonatomic) SideSlipModel *regionModel;
- @end
- @implementation StockingSearchCell
- /**
- 高度
-
- @return <#return value description#>
- */
- - (CGFloat)cellHeight {
- return 270.0f;
- }
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- StockingSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"StockingSearchCell" owner:nil options:nil][0];
- cell.txtStockingNo.delegate = cell;
- cell.txtWare.delegate = cell;
- cell.txtOnlyCode.delegate = cell;
-
- [cell configureKeyboard];
- return cell;
- }
- /**
- awakeFromNib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- Identifier
-
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
-
- return @"StockingSearchCell";
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtStockingNo.inputAccessoryView = keyBoardAccessoryView;
- _txtWare.inputAccessoryView = keyBoardAccessoryView;
- _txtOnlyCode.inputAccessoryView = keyBoardAccessoryView;
- }
- /**
- 更新model
-
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- }
- /**
- 更新frame
-
- @param w <#w description#>
- */
- - (void)updateFrame:(CGFloat)w{
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
-
- [_txtOnlyCode setText:@""];
- [_txtStockingNo setText:@""];
- [_txtWare setText:@""];
- }
- /**
- 文本编辑时候 弹出取消完成按钮
-
- @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 textField <#textField description#>
- */
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- [self updateModel];
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_txtWare resignFirstResponder];
- [_txtStockingNo resignFirstResponder];
- [_txtOnlyCode resignFirstResponder];
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
- [self hideKey];}
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- [_txtWare resignFirstResponder];
- [_txtStockingNo resignFirstResponder];
- [_txtOnlyCode resignFirstResponder];
- [self hideKey];
- }
- /**
- * 隐藏键盘
- */
- - (void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- StockingSearchModel *model = [[StockingSearchModel alloc] init];
- model.onlyCode = [_txtOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.stockingNo = [_txtStockingNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.warehouse = [_txtWare.text stringByReplacingOccurrencesOfString:@" " withString:@""];
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:STOCKING_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- @end
|