RepairReceiptSearchCell.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. // ReceiptSearchCell
  2. // IOBSS 2.0
  3. //
  4. // Created by 刘瀚璘 on 2017.7.17
  5. // Copyright 2017 沈阳东科云信软件有限公司. All rights reserved.
  6. //
  7. // 系统名称:
  8. // 功能描述:搜索Cell
  9. #import "SideSlipBaseTableViewCell.h"
  10. #import "RepairReceiptSearchCell.h"
  11. #import "UIColor+hexColor.h"
  12. #import "SideSlipConfig.h"
  13. #import "ReceiptSearchModel.h"
  14. #import "BRDatePickerView.h"
  15. #import "StatusInfo.h"
  16. #import "StatusInfoTextVC.h"
  17. @interface RepairReceiptSearchCell() <UITextFieldDelegate,StatusInfoTextDelegate>{
  18. /**
  19. 开始时间
  20. */
  21. NSString *_strStartDate;
  22. /**
  23. 结束时间
  24. */
  25. NSString *_strEndDate;
  26. /**
  27. 回执类型
  28. */
  29. NSString *_strReceiptType;
  30. /**
  31. 时间控件
  32. */
  33. BRDatePickerView *_brdatePicker;
  34. }
  35. /**
  36. 抽屉对象model
  37. */
  38. @property (strong,nonatomic) SideSlipModel *regionModel;
  39. @end
  40. @implementation RepairReceiptSearchCell
  41. /**
  42. cell
  43. @param indexPath <#indexPath description#>
  44. @return <#return value description#>
  45. */
  46. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  47. RepairReceiptSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"RepairReceiptSearchCell" owner:nil options:nil][0];
  48. cell.receiptOrderNo.delegate = cell;
  49. cell.txtCustomerName.delegate=cell;
  50. cell.txtCustomerAddress.delegate=cell;
  51. cell.txtCustomerTelephone.delegate=cell;
  52. [cell configureKeyboard];
  53. return cell;
  54. }
  55. /**
  56. 初始化Cell
  57. @param model <#model description#>
  58. @param indexPath <#indexPath description#>
  59. */
  60. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  61. self.regionModel = *model;
  62. _strEndDate = @"";
  63. _strStartDate = @"";
  64. _strReceiptType = @"";
  65. [self updateModel];
  66. }
  67. /**
  68. awakeFromNib
  69. */
  70. - (void)awakeFromNib {
  71. [super awakeFromNib];
  72. }
  73. /**
  74. 显示开始时间
  75. @param sender <#sender description#>
  76. */
  77. - (IBAction)showStartDate:(id)sender {
  78. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  79. [_brdatePicker configureSelectionBlock:^(NSString *date){
  80. _strStartDate = date;
  81. } andCompletionBlock:^(void){
  82. [_btnStartDate setTitle:_strStartDate forState:UIControlStateNormal];
  83. [self updateModel];
  84. } andCancelBlock:^(void){
  85. if([_btnStartDate.titleLabel.text isEqualToString:@"请选择回执开始日期"]){
  86. _strStartDate = @"";
  87. }else{
  88. _strStartDate = _btnStartDate.titleLabel.text;
  89. }
  90. [self updateModel];
  91. }];
  92. [_brdatePicker show];
  93. }
  94. /**
  95. 显示结束时间
  96. @param sender <#sender description#>
  97. */
  98. - (IBAction)showEndDate:(id)sender {
  99. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  100. [_brdatePicker configureSelectionBlock:^(NSString *date){
  101. _strEndDate = date;
  102. } andCompletionBlock:^(void){
  103. [_btnEndDate setTitle:_strEndDate forState:UIControlStateNormal];
  104. [self updateModel];
  105. } andCancelBlock:^(void){
  106. if([_btnEndDate.titleLabel.text isEqualToString:@"请选择回执结束日期"]){
  107. _strEndDate = @"";
  108. }else{
  109. _strEndDate = _btnEndDate.titleLabel.text;
  110. }
  111. [self updateModel];
  112. }];
  113. [_brdatePicker show];
  114. }
  115. /**
  116. 弹出回执状态
  117. @param sender <#sender description#>
  118. */
  119. - (IBAction)showReceiptType:(id)sender {
  120. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  121. tc.sdelegate = self;
  122. tc.isPresentViewFlag = YES;
  123. [tc.arrFilter addObjectsFromArray: [self getMutableArray]];
  124. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  125. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  126. }
  127. }
  128. /**
  129. 状态回调函数
  130. @param s <#s description#>
  131. */
  132. - (void)showStatusValue:(StatusInfo*)s{
  133. [_btnReceiptType setTitle:s.name forState:UIControlStateNormal];
  134. _strReceiptType = s.statusId;
  135. [self updateModel];
  136. }
  137. /**
  138. 初始化回执类型
  139. */
  140. - (NSMutableArray *)getMutableArray{
  141. NSMutableArray *arrayStatus = [[NSMutableArray alloc]init];
  142. StatusInfo *s = [[StatusInfo alloc]init];
  143. s.statusId = @"0";
  144. s.name = @"再次安排";
  145. [arrayStatus addObject:s];
  146. s = [[StatusInfo alloc]init];
  147. s.statusId = @"1";
  148. s.name = @"完成";
  149. [arrayStatus addObject:s];
  150. s = [[StatusInfo alloc]init];
  151. s.statusId = @"2";
  152. s.name = @"全部";
  153. [arrayStatus addObject:s];
  154. return arrayStatus;
  155. }
  156. /**
  157. 键盘配置
  158. */
  159. - (void)configureKeyboard {
  160. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  161. _receiptOrderNo.inputAccessoryView = keyBoardAccessoryView;
  162. _txtCustomerName.inputAccessoryView=keyBoardAccessoryView;
  163. _txtCustomerAddress.inputAccessoryView=keyBoardAccessoryView;
  164. _txtCustomerTelephone.inputAccessoryView=keyBoardAccessoryView;
  165. }
  166. /**
  167. 文本编辑时候 弹出取消完成按钮
  168. @return <#return value description#>
  169. */
  170. - (UIView *)createKeyBoardAccessoryView {
  171. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  172. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  173. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  174. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  175. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  176. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  177. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  178. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  179. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  180. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  181. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  182. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  183. [keyBoardAccessoryView addSubview:backButton];
  184. [keyBoardAccessoryView addSubview:doneButton];
  185. return keyBoardAccessoryView;
  186. }
  187. /**
  188. 取消文本
  189. */
  190. - (void)accessoryButtonBack {
  191. [self hideKey];
  192. }
  193. /**
  194. 确定文本
  195. */
  196. - (void)accessoryButtonDone {
  197. [self hideKey];
  198. }
  199. /**
  200. * 隐藏键盘
  201. */
  202. - (void)hideKey{
  203. [_receiptOrderNo resignFirstResponder];
  204. [_txtCustomerName resignFirstResponder ];
  205. [_txtCustomerAddress resignFirstResponder];
  206. [_txtCustomerTelephone resignFirstResponder];
  207. [self.contentView endEditing:YES];
  208. }
  209. /**
  210. 重置按钮 事件
  211. */
  212. - (void)resetData {
  213. [_receiptOrderNo setText:@""];
  214. [_txtCustomerName setText:@""];
  215. [_txtCustomerAddress setText:@""];
  216. [_txtCustomerTelephone setText:@""];
  217. }
  218. /**
  219. 更新model
  220. */
  221. - (void)updateModel{
  222. ReceiptSearchModel *model = [[ReceiptSearchModel alloc] init];
  223. model.strReceiptOrderNo = [_receiptOrderNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  224. model.customerName=[_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  225. model.customerAddress=[_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  226. model.customerTelephone=[_txtCustomerTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  227. model.strStartDate = _strStartDate;
  228. model.strEndDate = _strEndDate;
  229. model.strReceiptType = _strReceiptType;
  230. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  231. [mutDict setValue:model forKey:RECEIPT_SEARCH_MODEL];
  232. _regionModel.customDict = [mutDict copy];
  233. }
  234. /**
  235. Identifier
  236. @return
  237. */
  238. + (NSString *)cellReuseIdentifier {
  239. return @"RepairReceiptSearchCell";
  240. }
  241. /**
  242. 高度
  243. @return return value description
  244. */
  245. - (CGFloat)cellHeight {
  246. return 624;
  247. }
  248. /**
  249. 文本编辑结束事件
  250. @param textField <#textField description#>
  251. */
  252. - (void)textFieldDidEndEditing:(UITextField *)textField {
  253. [self updateModel];
  254. }
  255. /**
  256. 触摸事件
  257. @param touches <#touches description#>
  258. @param event <#event description#>
  259. */
  260. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  261. [self hideKey];
  262. }
  263. @end