InstallUnreceiptSearchCell.m 7.0 KB

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