DeliveryReceiptSearchCell.m 8.6 KB

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