DeliveryUnreceiptSearchCell.m 7.5 KB

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