OrderSalesSearchTableViewCell.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. //
  2. // OrderSalesSearchTableViewCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2017/5/26.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "OrderSalesSearchTableViewCell.h"
  9. #import "StatusInfoTextVC.h"
  10. #import "StatusInfo.h"
  11. #import "UIColor+hexColor.h"
  12. #import "SideSlipConfig.h"
  13. @implementation OrderSalesSearchTableViewCell
  14. /**
  15. awakeFromNib
  16. */
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. }
  20. /**
  21. 单据类型
  22. @param sender <#sender description#>
  23. */
  24. - (IBAction)selectInvoiceType:(id)sender {
  25. [self initStatus];
  26. StatusInfoTextVC *tc=[[StatusInfoTextVC alloc] init];
  27. tc.sdelegate=self;
  28. tc.isPresentViewFlag=YES;
  29. [tc.filterArr addObjectsFromArray: _arrayStatus];
  30. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  31. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  32. }
  33. }
  34. #pragma mark -- 委托事件
  35. -(void)showStatusValue:(StatusInfo *)s{
  36. NSString *statusId=s.statusId;
  37. [_btnInvoiceType setTitle:s.name forState:UIControlStateNormal];
  38. [_searchModel setInvoiceTypeId:statusId];
  39. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  40. _slideModel.customDict =_mutDict;
  41. }
  42. /**
  43. 单据类型数据源
  44. */
  45. -(void)initStatus{
  46. _arrayStatus=[NSMutableArray new];
  47. StatusInfo* s=[[StatusInfo alloc]init];
  48. s.statusId=@"0";
  49. s.name=@"全部";
  50. [_arrayStatus addObject:s];
  51. s=[[StatusInfo alloc]init];
  52. s.statusId=@"1";
  53. s.name=@"订单";
  54. [_arrayStatus addObject:s];
  55. s=[[StatusInfo alloc]init];
  56. s.statusId=@"2";
  57. s.name=@"销售单";
  58. [_arrayStatus addObject:s];
  59. s=[[StatusInfo alloc]init];
  60. s.statusId=@"3";
  61. s.name=@"销售单(包含转单)";
  62. [_arrayStatus addObject:s];
  63. }
  64. /**
  65. 开始日期
  66. @param sender <#sender description#>
  67. */
  68. - (IBAction)selectStartDate:(id)sender {
  69. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  70. [_brdatePicker configureSelectionBlock:^(NSString *date){
  71. _startDate=date;
  72. } andCompletionBlock:^(void){
  73. [_searchModel setStartDate:_startDate];
  74. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  75. _slideModel.customDict =_mutDict;
  76. [_btnStartDate setTitle:_startDate forState:UIControlStateNormal];
  77. } andCancelBlock:^(void){
  78. _startDate=_btnStartDate.titleLabel.text;
  79. }];
  80. [_brdatePicker show];
  81. }
  82. /**
  83. 结束日期
  84. @param sender <#sender description#>
  85. */
  86. - (IBAction)selectEndDate:(id)sender {
  87. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  88. [_brdatePicker configureSelectionBlock:^(NSString *date){
  89. _endDate=date;
  90. } andCompletionBlock:^(void){
  91. [_searchModel setEndDate:_endDate];
  92. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  93. _slideModel.customDict = _mutDict;
  94. [_btnEndDate setTitle:_endDate forState:UIControlStateNormal];
  95. } andCancelBlock:^(void){
  96. _endDate=_btnEndDate.titleLabel.text;
  97. }];
  98. [_brdatePicker show];
  99. }
  100. /**
  101. 过滤冲正数据
  102. @param sender <#sender description#>
  103. */
  104. - (IBAction)changeCorrectStatus:(id)sender {
  105. if([_searchModel.correctStatus isEqualToString:@"1"]){
  106. _searchModel.correctStatus=@"0";
  107. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  108. _slideModel.customDict = _mutDict;
  109. [_btnFilter setTitle:@"未过滤" forState:UIControlStateNormal];
  110. [ _btnFilter setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
  111. _btnFilter.layer.borderColor=[UIColor lightGrayColor].CGColor;
  112. }
  113. else{
  114. _searchModel.correctStatus=@"1";
  115. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  116. _slideModel.customDict = _mutDict;
  117. [_btnFilter setTitle:@"已过滤" forState:UIControlStateNormal];
  118. [ _btnFilter setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  119. _btnFilter.layer.borderColor=[UIColor redColor].CGColor;
  120. }
  121. }
  122. /**
  123. cell
  124. @param indexPath <#indexPath description#>
  125. @return <#return value description#>
  126. */
  127. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  128. OrderSalesSearchTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"OrderSalesSearchTableViewCell" owner:nil options:nil][0];
  129. cell.txtCustomerName.delegate = cell;
  130. cell.txtContactTelephone.delegate=cell;
  131. cell.btnFilter.layer.borderColor=[UIColor redColor].CGColor;
  132. [cell.btnFilter setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  133. cell.btnFilter.layer.borderWidth=1;
  134. [cell configureKeyboard];
  135. return cell;
  136. }
  137. /**
  138. 键盘配置
  139. */
  140. - (void)configureKeyboard {
  141. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  142. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  143. _txtContactTelephone.inputAccessoryView = keyBoardAccessoryView;
  144. }
  145. /**
  146. 高度
  147. @return <#return value description#>
  148. */
  149. - (CGFloat)cellHeight {
  150. return 505.0f;
  151. }
  152. /**
  153. 文本框编辑
  154. @param textField <#textField description#>
  155. */
  156. - (void)textFieldDidEndEditing:(UITextField *)textField {
  157. _searchModel.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  158. _searchModel.contactTelephone = [_txtContactTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  159. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  160. _slideModel.customDict = _mutDict;
  161. }
  162. /**
  163. <#Description#>
  164. 关宏厚 2017-7-6
  165. @param model <#model description#>
  166. @param indexPath <#indexPath description#>
  167. */
  168. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  169. indexPath:(NSIndexPath *)indexPath {
  170. _slideModel=*model;
  171. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  172. _searchModel=[OrderSalesSearchModel new];
  173. _searchModel.correctStatus=@"1";
  174. NSString *startDateStr= [DateFormat getDateBefore:7];
  175. NSString *endDataStr=[DateFormat getCurrentDate];
  176. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  177. _startDate= _btnStartDate.titleLabel.text;
  178. [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal];
  179. _endDate= _btnEndDate.titleLabel.text;
  180. _searchModel.startDate=_startDate;
  181. _searchModel.endDate=_endDate;
  182. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  183. _slideModel.customDict = _mutDict;
  184. }
  185. + (NSString *)cellReuseIdentifier {
  186. return @"SearchTableViewCell";
  187. }
  188. /**
  189. 文本编辑时候 弹出取消完成按钮
  190. @return <#return value description#>
  191. */
  192. - (UIView *)createKeyBoardAccessoryView {
  193. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  194. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  195. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  196. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  197. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  198. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  199. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  200. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  201. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  202. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  203. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  204. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  205. [keyBoardAccessoryView addSubview:backButton];
  206. [keyBoardAccessoryView addSubview:doneButton];
  207. return keyBoardAccessoryView;
  208. }
  209. /**
  210. 长度
  211. @param textField <#textField description#>
  212. @param range <#range description#>
  213. @param string <#string description#>
  214. @return <#return value description#>
  215. */
  216. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  217. return YES;
  218. }
  219. /**
  220. 触摸事件
  221. @param touches <#touches description#>
  222. @param event <#event description#>
  223. */
  224. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  225. [self hideKey];
  226. [_txtCustomerName resignFirstResponder];
  227. [_txtContactTelephone resignFirstResponder];
  228. }
  229. /**
  230. 取消文本
  231. */
  232. - (void)accessoryButtonBack {
  233. [self hideKey];}
  234. /**
  235. 确定文本
  236. */
  237. - (void)accessoryButtonDone {
  238. [_txtCustomerName resignFirstResponder];
  239. [_txtContactTelephone resignFirstResponder];
  240. [self hideKey];
  241. }
  242. /**
  243. * 隐藏键盘
  244. */
  245. - (void)hideKey
  246. {
  247. [self.contentView endEditing:YES];
  248. }
  249. @end