StockingSearchCell.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //
  2. // StockingSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/27.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "StockingSearchCell.h"
  9. #import "UIColor+hexColor.h"
  10. #import "SideSlipConfig.h"
  11. #import "StockingSearchModel.h"
  12. #import "SideSlipModel.h"
  13. @interface StockingSearchCell()<UITextFieldDelegate>
  14. @property (strong, nonatomic) SideSlipModel *regionModel;
  15. @end
  16. @implementation StockingSearchCell
  17. /**
  18. 高度
  19. @return <#return value description#>
  20. */
  21. - (CGFloat)cellHeight {
  22. return 270.0f;
  23. }
  24. /**
  25. cell
  26. @param indexPath <#indexPath description#>
  27. @return <#return value description#>
  28. */
  29. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  30. StockingSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"StockingSearchCell" owner:nil options:nil][0];
  31. cell.txtStockingNo.delegate = cell;
  32. cell.txtWare.delegate = cell;
  33. cell.txtOnlyCode.delegate = cell;
  34. [cell configureKeyboard];
  35. return cell;
  36. }
  37. /**
  38. awakeFromNib
  39. */
  40. - (void)awakeFromNib {
  41. [super awakeFromNib];
  42. }
  43. /**
  44. Identifier
  45. @return <#return value description#>
  46. */
  47. + (NSString *)cellReuseIdentifier {
  48. return @"StockingSearchCell";
  49. }
  50. /**
  51. 键盘配置
  52. */
  53. - (void)configureKeyboard {
  54. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  55. _txtStockingNo.inputAccessoryView = keyBoardAccessoryView;
  56. _txtWare.inputAccessoryView = keyBoardAccessoryView;
  57. _txtOnlyCode.inputAccessoryView = keyBoardAccessoryView;
  58. }
  59. /**
  60. 更新model
  61. @param model <#model description#>
  62. @param indexPath <#indexPath description#>
  63. */
  64. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  65. self.regionModel = *model;
  66. }
  67. /**
  68. 更新frame
  69. @param w <#w description#>
  70. */
  71. - (void)updateFrame:(CGFloat)w{
  72. }
  73. /**
  74. 重置按钮 事件
  75. */
  76. - (void)resetData {
  77. [_txtOnlyCode setText:@""];
  78. [_txtStockingNo setText:@""];
  79. [_txtWare setText:@""];
  80. }
  81. /**
  82. 文本编辑时候 弹出取消完成按钮
  83. @return <#return value description#>
  84. */
  85. - (UIView *)createKeyBoardAccessoryView {
  86. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  87. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  88. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  89. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  90. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  91. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  92. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  93. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  94. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  95. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  96. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  97. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  98. [keyBoardAccessoryView addSubview:backButton];
  99. [keyBoardAccessoryView addSubview:doneButton];
  100. return keyBoardAccessoryView;
  101. }
  102. /**
  103. 长度
  104. @param textField <#textField description#>
  105. @param range <#range description#>
  106. @param string <#string description#>
  107. @return <#return value description#>
  108. */
  109. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  110. return YES;
  111. }
  112. /**
  113. 文本编辑结束事件
  114. @param textField <#textField description#>
  115. */
  116. - (void)textFieldDidEndEditing:(UITextField *)textField {
  117. [self updateModel];
  118. }
  119. /**
  120. 触摸事件
  121. @param touches <#touches description#>
  122. @param event <#event description#>
  123. */
  124. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  125. [self hideKey];
  126. [_txtWare resignFirstResponder];
  127. [_txtStockingNo resignFirstResponder];
  128. [_txtOnlyCode resignFirstResponder];
  129. }
  130. /**
  131. 取消文本
  132. */
  133. - (void)accessoryButtonBack {
  134. [self hideKey];}
  135. /**
  136. 确定文本
  137. */
  138. - (void)accessoryButtonDone {
  139. [_txtWare resignFirstResponder];
  140. [_txtStockingNo resignFirstResponder];
  141. [_txtOnlyCode resignFirstResponder];
  142. [self hideKey];
  143. }
  144. /**
  145. * 隐藏键盘
  146. */
  147. - (void)hideKey
  148. {
  149. [self.contentView endEditing:YES];
  150. }
  151. /**
  152. 更新model
  153. */
  154. - (void)updateModel{
  155. StockingSearchModel *model = [[StockingSearchModel alloc] init];
  156. model.onlyCode = [_txtOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  157. model.stockingNo = [_txtStockingNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  158. model.warehouse = [_txtWare.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  159. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  160. [mutDict setValue:model forKey:STOCKING_SEARCH_RANGE_MODEL];
  161. _regionModel.customDict = [mutDict copy];
  162. }
  163. @end