RepairNoReciptSearchCell.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // NoReciptSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by ssl on 2017/8/28.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "UIColor+hexColor.h"
  9. #import "SideSlipConfig.h"
  10. #import "WareSearchViewController.h"
  11. #import "NoReceiptSearchModel.h"
  12. #import "BRDatePickerView.h"
  13. #import "RepairNoReciptSearchCell.h"
  14. @interface RepairNoReciptSearchCell() <UITextFieldDelegate, BaseIDAndNameProtocol>{
  15. /**
  16. 开始时间
  17. */
  18. NSString *_strStartDate;
  19. /**
  20. 结束时间
  21. */
  22. NSString *_strEndDate;
  23. /**
  24. 时间控件
  25. */
  26. BRDatePickerView *_brdatePicker;
  27. }
  28. /**
  29. 抽屉对象model
  30. */
  31. @property (strong,nonatomic) SideSlipModel *regionModel;
  32. @end
  33. @implementation RepairNoReciptSearchCell
  34. /**
  35. cell
  36. @param indexPath <#indexPath description#>
  37. @return <#return value description#>
  38. */
  39. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  40. RepairNoReciptSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"RepairNoReciptSearchCell" owner:nil options:nil][0];
  41. cell.customerName.delegate = cell;
  42. cell.arrangementOrderNo.delegate = cell;
  43. cell.presaleOrderNo.delegate = cell;
  44. [cell configureKeyboard];
  45. return cell;
  46. }
  47. /**
  48. 初始化Cell
  49. @param model <#model description#>
  50. @param indexPath <#indexPath description#>
  51. */
  52. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  53. self.regionModel = *model;
  54. _strEndDate = @"";
  55. _strStartDate = @"";
  56. [self updateModel];
  57. }
  58. /**
  59. awakeFromNib
  60. */
  61. - (void)awakeFromNib {
  62. [super awakeFromNib];
  63. }
  64. /**
  65. 显示开始时间
  66. @param sender <#sender description#>
  67. */
  68. - (IBAction)showStartDate:(id)sender {
  69. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  70. [_brdatePicker configureSelectionBlock:^(NSString *date){
  71. _strStartDate = date;
  72. } andCompletionBlock:^(void){
  73. [_btnStartDate setTitle:_strStartDate forState:UIControlStateNormal];
  74. [self updateModel];
  75. } andCancelBlock:^(void){
  76. if([_btnStartDate.titleLabel.text isEqualToString:@"请选择维修开始日期"]){
  77. _strStartDate = @"";
  78. }else{
  79. _strStartDate = _btnStartDate.titleLabel.text;
  80. }
  81. [self updateModel];
  82. }];
  83. [_brdatePicker show];
  84. }
  85. /**
  86. 显示结束时间
  87. @param sender <#sender description#>
  88. */
  89. - (IBAction)showEndDate:(id)sender {
  90. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  91. [_brdatePicker configureSelectionBlock:^(NSString *date){
  92. _strEndDate = date;
  93. } andCompletionBlock:^(void){
  94. [_btnEndDate setTitle:_strEndDate forState:UIControlStateNormal];
  95. [self updateModel];
  96. } andCancelBlock:^(void){
  97. if([_btnEndDate.titleLabel.text isEqualToString:@"请选择维修结束日期"]){
  98. _strEndDate = @"";
  99. }else{
  100. _strEndDate = _btnEndDate.titleLabel.text;
  101. }
  102. [self updateModel];
  103. }];
  104. [_brdatePicker show];
  105. }
  106. /**
  107. 键盘配置
  108. */
  109. - (void)configureKeyboard {
  110. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  111. _arrangementOrderNo.inputAccessoryView = keyBoardAccessoryView;
  112. _presaleOrderNo.inputAccessoryView = keyBoardAccessoryView;
  113. _customerName.inputAccessoryView = keyBoardAccessoryView;
  114. }
  115. /**
  116. 文本编辑时候 弹出取消完成按钮
  117. @return <#return value description#>
  118. */
  119. - (UIView *)createKeyBoardAccessoryView {
  120. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  121. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  122. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  123. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  124. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  125. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  126. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  127. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  128. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  129. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  130. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  131. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  132. [keyBoardAccessoryView addSubview:backButton];
  133. [keyBoardAccessoryView addSubview:doneButton];
  134. return keyBoardAccessoryView;
  135. }
  136. /**
  137. 取消文本
  138. */
  139. - (void)accessoryButtonBack {
  140. [self hideKey];
  141. }
  142. /**
  143. 确定文本
  144. */
  145. - (void)accessoryButtonDone {
  146. [self hideKey];
  147. }
  148. /**
  149. * 隐藏键盘
  150. */
  151. - (void)hideKey
  152. { [_arrangementOrderNo resignFirstResponder];
  153. [_presaleOrderNo resignFirstResponder];
  154. [_customerName resignFirstResponder];
  155. [self.contentView endEditing:YES];
  156. }
  157. /**
  158. 重置按钮 事件
  159. */
  160. - (void)resetData {
  161. [_arrangementOrderNo setText:@""];
  162. [_presaleOrderNo setText:@""];
  163. [_customerName setText:@""];
  164. }
  165. /**
  166. 更新model
  167. */
  168. - (void)updateModel{
  169. NoReceiptSearchModel *model = [[NoReceiptSearchModel alloc] init];
  170. model.strArrangementOrderNo = [_arrangementOrderNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  171. model.strPresaleOrderNo = [_presaleOrderNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  172. model.strCustomerName = [_customerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  173. model.strStartDate = _strStartDate;
  174. model.strEndDate = _strEndDate;
  175. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  176. [mutDict setValue:model forKey:NORECEIPT_SEARCH_MODEL];
  177. _regionModel.customDict = [mutDict copy];
  178. }
  179. /**
  180. Identifier
  181. @return
  182. */
  183. + (NSString *)cellReuseIdentifier {
  184. return @"RepairNoReciptSearchCell";
  185. }
  186. /**
  187. 高度
  188. @return return value description
  189. */
  190. - (CGFloat)cellHeight {
  191. return 669;
  192. }
  193. /**
  194. 文本编辑结束事件
  195. @param textField <#textField description#>
  196. */
  197. - (void)textFieldDidEndEditing:(UITextField *)textField {
  198. [self updateModel];
  199. }
  200. /**
  201. 触摸事件
  202. @param touches <#touches description#>
  203. @param event <#event description#>
  204. */
  205. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  206. [self hideKey];
  207. [_arrangementOrderNo resignFirstResponder];
  208. [_customerName resignFirstResponder];
  209. [_presaleOrderNo resignFirstResponder];
  210. }
  211. @end