DispatchReceiptSearchCell.m 7.2 KB

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