HistoryOrderSearchTableViewCell.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // HistoryOrderSearchTableViewCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2017/5/23.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "HistoryOrderSearchTableViewCell.h"
  9. #import "UIColor+hexColor.h"
  10. #import "SideSlipConfig.h"
  11. #import "DateFormat.h"
  12. @implementation HistoryOrderSearchTableViewCell
  13. #pragma mark - 公共函数
  14. /**
  15. 加载xib函数
  16. */
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. }
  20. #pragma mark - 委托函数
  21. /**
  22. textfield委托回调函数
  23. */
  24. - (void)textFieldDidEndEditing:(UITextField *)textField {
  25. _searchModel.orderNo = [_txtOrderNO.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  26. _searchModel.customerCode = [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  27. _searchModel.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  28. _searchModel.customerAddress = [_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  29. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  30. _slideModel.customDict = _mutDict;
  31. }
  32. /**
  33. 选择开始日期
  34. */
  35. - (IBAction)selectStartDate:(id)sender {
  36. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  37. [_brDatePicker configureSelectionBlock:^(NSString *date){
  38. _startDate=date;
  39. } andCompletionBlock:^(void){
  40. [_searchModel setStartDate:_startDate];
  41. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  42. _slideModel.customDict =_mutDict;
  43. [_btnStartDate setTitle:_startDate forState:UIControlStateNormal];
  44. } andCancelBlock:^(void){
  45. _startDate=_btnStartDate.titleLabel.text;
  46. }];
  47. [_brDatePicker show];
  48. }
  49. //返回cell的高度
  50. - (CGFloat)cellHeight {
  51. return 509.0f;
  52. }
  53. //选择结束日期
  54. - (IBAction)selectEndDate:(id)sender {
  55. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  56. [_brDatePicker configureSelectionBlock:^(NSString *date){
  57. _endDate=date;
  58. } andCompletionBlock:^(void){
  59. [_searchModel setEndDate:_endDate];
  60. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  61. _slideModel.customDict = _mutDict;
  62. [_btnEndDate setTitle:_endDate forState:UIControlStateNormal];
  63. } andCancelBlock:^(void){
  64. _endDate=_btnEndDate.titleLabel.text;
  65. }];
  66. [_brDatePicker show];
  67. }
  68. //创建cell
  69. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  70. HistoryOrderSearchTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"HistoryOrderSearchTableViewCell" owner:nil options:nil][0];
  71. cell.txtOrderNO.delegate = cell;
  72. cell.txtCustomerCode.delegate=cell;
  73. cell.txtCustomerName.delegate=cell;
  74. cell.txtCustomerAddress.delegate=cell;
  75. [cell configureKeyboard];
  76. return cell;
  77. }
  78. /**
  79. 键盘配置
  80. */
  81. - (void)configureKeyboard {
  82. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  83. _txtOrderNO.inputAccessoryView = keyBoardAccessoryView;
  84. _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
  85. _txtCustomerName.inputAccessoryView=keyBoardAccessoryView;
  86. _txtCustomerAddress.inputAccessoryView=keyBoardAccessoryView;
  87. }
  88. /**
  89. 文本编辑时候 弹出取消完成按钮
  90. @return <#return value description#>
  91. */
  92. - (UIView *)createKeyBoardAccessoryView {
  93. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  94. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  95. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  96. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  97. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  98. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  99. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  100. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  101. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  102. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  103. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  104. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  105. [keyBoardAccessoryView addSubview:backButton];
  106. [keyBoardAccessoryView addSubview:doneButton];
  107. return keyBoardAccessoryView;
  108. }
  109. /**
  110. 取消文本
  111. */
  112. - (void)accessoryButtonBack {
  113. NSLog(@"accessoryButtonBack");
  114. [self hideKey];}
  115. /**
  116. 确定文本
  117. */
  118. - (void)accessoryButtonDone {
  119. NSLog(@"accessoryButtonDone");
  120. [_txtOrderNO resignFirstResponder];
  121. [_txtCustomerCode resignFirstResponder];
  122. [_txtCustomerName resignFirstResponder];
  123. [_txtCustomerAddress resignFirstResponder];
  124. [self hideKey];
  125. }
  126. /**
  127. 触摸事件
  128. @param touches <#touches description#>
  129. @param event <#event description#>
  130. */
  131. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  132. [self hideKey];
  133. [_txtCustomerName resignFirstResponder];
  134. }
  135. /**
  136. * 隐藏键盘
  137. */
  138. -(void)hideKey
  139. {
  140. [self.contentView endEditing:YES];
  141. }
  142. //更新cell
  143. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  144. indexPath:(NSIndexPath *)indexPath {
  145. _slideModel=*model;
  146. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  147. _searchModel=[HistoryOrderSearchModel new];
  148. NSString *startDateStr=[DateFormat getDateBefore:31];
  149. NSString *endDateStr=[DateFormat getCurrentDate];
  150. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  151. _startDate= _btnStartDate.titleLabel.text;
  152. _searchModel.startDate=_startDate;
  153. [_btnEndDate setTitle:endDateStr forState:UIControlStateNormal];
  154. _endDate =_btnEndDate.titleLabel.text;
  155. _searchModel.endDate=_endDate;
  156. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  157. _slideModel.customDict = _mutDict;
  158. }
  159. //返回cell identifier
  160. + (NSString *)cellReuseIdentifier {
  161. return @"SearchTableViewCell";
  162. }
  163. @end