RequirementNoReceiptSearchCell.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. //
  2. // RequirementNoReceiptSearchCell.m
  3. // IBOSSHSH
  4. //
  5. // Created by ssl on 2018/1/12.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "RequirementNoReceiptSearchCell.h"
  9. #import "DateFormat.h"
  10. #import "UIColor+hexColor.h"
  11. #import "SideSlipConfig.h"
  12. @implementation RequirementNoReceiptSearchCell
  13. static RequirementNoReceiptSearchCell* searchCell;
  14. #pragma 公有函数
  15. /**
  16. 加载xib
  17. */
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. }
  21. #pragma 委托函数
  22. /**
  23. 单元格高度
  24. @return <#return value description#>
  25. */
  26. - (CGFloat)cellHeight {
  27. return 509.0f;
  28. }
  29. /**
  30. 加载tableviewcell
  31. @param indexPath <#indexPath description#>
  32. @return <#return value description#>
  33. */
  34. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  35. RequirementNoReceiptSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"RequirementNoReceiptSearchCell" owner:nil options:nil][0];
  36. cell.txtArrangementNo.delegate=cell;
  37. cell.txtDeliveryNo.delegate=cell;
  38. cell.txtCustomerName.delegate=cell;
  39. searchCell = cell;
  40. [cell configureKeyboard];
  41. return cell;
  42. }
  43. /**
  44. 文本框编辑
  45. @param textField <#textField description#>
  46. */
  47. - (void)textFieldDidEndEditing:(UITextField *)textField {
  48. _searchModel.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  49. _searchModel.deliveryNo = [_txtDeliveryNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  50. _searchModel.arrangementNo=[_txtArrangementNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  51. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  52. _slideModel.customDict = _mutDict;
  53. }
  54. /**
  55. 初始化cell数据
  56. @param model <#model description#>
  57. @param indexPath <#indexPath description#>
  58. */
  59. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  60. indexPath:(NSIndexPath *)indexPath {
  61. _slideModel = *model;
  62. _searchModel = [RequirementNoReceiptSearchModel new];
  63. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  64. _slideModel.customDict = _mutDict;
  65. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  66. }
  67. /**
  68. 重置按钮 事件
  69. */
  70. - (void)resetData {
  71. [_txtArrangementNo setText:@""];
  72. [_txtDeliveryNo setText:@""];
  73. [_btnStartDate setTitle:@"请选择回执开始日期" forState:UIControlStateNormal];
  74. [_btnEndDate setTitle:@"请选择回执结束日期" forState:UIControlStateNormal];
  75. [_txtCustomerName setText:@""];
  76. _searchModel.deliveryNo= @"";
  77. _searchModel.startDate =@"";
  78. _searchModel.endDate=@"";
  79. _searchModel.customerName=@"";
  80. _searchModel.arrangementNo=@"";
  81. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  82. _slideModel.customDict = _mutDict;
  83. }
  84. /**
  85. 返回tableviewcell标识
  86. @return <#return value description#>
  87. */
  88. + (NSString *)cellReuseIdentifier {
  89. return @"SearchTableViewCell";
  90. }
  91. /**
  92. 校验文本
  93. @param textField <#textField description#>
  94. @param range <#range description#>
  95. @param string <#string description#>
  96. @return <#return value description#>
  97. */
  98. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  99. return YES;
  100. }
  101. /**
  102. 触摸事件
  103. @param touches <#touches description#>
  104. @param event <#event description#>
  105. */
  106. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  107. [self hideKey];
  108. [_txtCustomerName resignFirstResponder];
  109. [_txtDeliveryNo resignFirstResponder];
  110. [_txtArrangementNo resignFirstResponder];
  111. }
  112. #pragma 私有函数
  113. /**
  114. 开始日期点击监听器
  115. @param sender <#sender description#>
  116. */
  117. - (IBAction)startDateAction:(id)sender {
  118. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  119. [_brdatePicker configureSelectionBlock:^(NSString *date){
  120. _startDate=date;
  121. } andCompletionBlock:^(void){
  122. [_searchModel setStartDate:_startDate];
  123. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  124. _slideModel.customDict =_mutDict;
  125. [_btnStartDate setTitle:_startDate forState:UIControlStateNormal];
  126. } andCancelBlock:^(void){
  127. _startDate=_btnStartDate.titleLabel.text;
  128. }];
  129. [_brdatePicker show];
  130. }
  131. /**
  132. 结束日期点击监听器
  133. @param sender <#sender description#>
  134. */
  135. - (IBAction)endDateAction:(id)sender {
  136. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  137. [_brdatePicker configureSelectionBlock:^(NSString *date){
  138. _endDate=date;
  139. } andCompletionBlock:^(void){
  140. [_searchModel setEndDate:_endDate];
  141. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  142. _slideModel.customDict = _mutDict;
  143. [_btnEndDate setTitle:_endDate forState:UIControlStateNormal];
  144. } andCancelBlock:^(void){
  145. _endDate=_btnEndDate.titleLabel.text;
  146. }];
  147. [_brdatePicker show];
  148. }
  149. /**
  150. 键盘配置
  151. */
  152. - (void)configureKeyboard {
  153. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  154. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  155. _txtDeliveryNo.inputAccessoryView=keyBoardAccessoryView;
  156. _txtCustomerName.inputAccessoryView=keyBoardAccessoryView;
  157. }
  158. /**
  159. 文本编辑时候 弹出取消完成按钮
  160. @return <#return value description#>
  161. */
  162. - (UIView *)createKeyBoardAccessoryView {
  163. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  164. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  165. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  166. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  167. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  168. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  169. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  170. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  171. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  172. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  173. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  174. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  175. [keyBoardAccessoryView addSubview:backButton];
  176. [keyBoardAccessoryView addSubview:doneButton];
  177. return keyBoardAccessoryView;
  178. }
  179. /**
  180. 取消文本
  181. */
  182. - (void)accessoryButtonBack {
  183. [self hideKey];}
  184. /**
  185. 确定文本
  186. */
  187. - (void)accessoryButtonDone {
  188. [_txtCustomerName resignFirstResponder];
  189. [_txtDeliveryNo resignFirstResponder];
  190. [_txtArrangementNo resignFirstResponder]; [self hideKey];
  191. }
  192. /**
  193. * 隐藏键盘
  194. */
  195. - (void)hideKey
  196. {
  197. [self.contentView endEditing:YES];
  198. }
  199. @end