RequirementReceiptSearchCell.m 7.5 KB

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