StockingSearchCell.m 5.3 KB

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