DispatchNoReceiptSearchCell.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 "DispatchNoReceiptSearchCell.h"
  9. #import "DateFormat.h"
  10. #import "UIColor+hexColor.h"
  11. #import "SideSlipConfig.h"
  12. @implementation DispatchNoReceiptSearchCell
  13. static DispatchNoReceiptSearchCell* 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 532.0f;
  28. }
  29. /**
  30. 加载tableviewcell
  31. @param indexPath <#indexPath description#>
  32. @return <#return value description#>
  33. */
  34. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  35. DispatchNoReceiptSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"DispatchNoReceiptSearchCell" owner:nil options:nil][0];
  36. cell.txtDispatchArrangementNo.delegate=cell;
  37. cell.txtTelephone.delegate=cell;
  38. cell.txtDispatchCustomerName.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. _dispatchSearchModel.customerName= [_txtDispatchCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  49. _dispatchSearchModel.customerTelephone = [_txtTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  50. _dispatchSearchModel.arrangementNo=[_txtDispatchArrangementNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  51. [_multDict setValue:_dispatchSearchModel forKey:SEARCH_RANGE_MODEL];
  52. _dispatchSlideModel.customDict = _multDict;
  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. _dispatchSlideModel = *model;
  62. _dispatchSearchModel = [DispatchNoReceiptSearchModel new];
  63. [_multDict setValue:_dispatchSearchModel forKey:SEARCH_RANGE_MODEL];
  64. _dispatchSlideModel.customDict = _multDict;
  65. _multDict = [NSMutableDictionary dictionaryWithDictionary:_dispatchSlideModel.customDict];
  66. }
  67. /**
  68. 重置按钮 事件
  69. */
  70. - (void)resetData {
  71. [_txtDispatchArrangementNo setText:@""];
  72. [_txtTelephone setText:@""];
  73. [_btnDispatchStartDate setTitle:@"请选择回执开始日期" forState:UIControlStateNormal];
  74. [_btnDispatchEndDate setTitle:@"请选择回执结束日期" forState:UIControlStateNormal];
  75. [_txtDispatchCustomerName setText:@""];
  76. _dispatchSearchModel.customerTelephone= @"";
  77. _dispatchSearchModel.startDate =@"";
  78. _dispatchSearchModel.endDate=@"";
  79. _dispatchSearchModel.customerName=@"";
  80. _dispatchSearchModel.arrangementNo=@"";
  81. [_multDict setValue:_dispatchSearchModel forKey:SEARCH_RANGE_MODEL];
  82. _dispatchSlideModel.customDict = _multDict;
  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. [_txtDispatchCustomerName resignFirstResponder];
  109. [_txtTelephone resignFirstResponder];
  110. [_txtDispatchArrangementNo 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. _dispatchStartDate=date;
  121. } andCompletionBlock:^(void){
  122. [_dispatchSearchModel setStartDate:_dispatchStartDate];
  123. [_multDict setValue:_dispatchSearchModel forKey:SEARCH_RANGE_MODEL];
  124. _dispatchSlideModel.customDict =_multDict;
  125. [_btnDispatchStartDate setTitle:_dispatchStartDate forState:UIControlStateNormal];
  126. } andCancelBlock:^(void){
  127. _dispatchStartDate=_btnDispatchStartDate.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. _dispatchEndDate=date;
  139. } andCompletionBlock:^(void){
  140. [_dispatchSearchModel setEndDate:_dispatchEndDate];
  141. [_multDict setValue:_dispatchSearchModel forKey:SEARCH_RANGE_MODEL];
  142. _dispatchSlideModel.customDict = _multDict;
  143. [_btnDispatchEndDate setTitle:_dispatchEndDate forState:UIControlStateNormal];
  144. } andCancelBlock:^(void){
  145. _dispatchEndDate=_btnDispatchEndDate.titleLabel.text;
  146. }];
  147. [_brDatePicker show];
  148. }
  149. /**
  150. 键盘配置
  151. */
  152. - (void)configureKeyboard {
  153. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  154. _txtDispatchCustomerName.inputAccessoryView = keyBoardAccessoryView;
  155. _txtTelephone.inputAccessoryView=keyBoardAccessoryView;
  156. _txtDispatchCustomerName.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. [_txtDispatchCustomerName resignFirstResponder];
  189. [_txtTelephone resignFirstResponder];
  190. [_txtDispatchArrangementNo resignFirstResponder];
  191. [self hideKey];
  192. }
  193. /**
  194. * 隐藏键盘
  195. */
  196. - (void)hideKey
  197. {
  198. [self.contentView endEditing:YES];
  199. }
  200. @end