InstallReceiptSearchCell.m 8.8 KB

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