OrderListSearchCell.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. //
  2. // OrderListSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/1/22.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "OrderListSearchCell.h"
  9. #import "UIColor+hexColor.h"
  10. #import "SideSlipConfig.h"
  11. @interface OrderListSearchCell () <UITextFieldDelegate>
  12. @end
  13. @implementation OrderListSearchCell
  14. - (IBAction)showEndDate:(id)sender {
  15. __weak typeof(self) weakself=self;
  16. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  17. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  18. _tempEndDate=date;
  19. } andCompletionBlock:^(void){
  20. weakself.endDate = _tempEndDate;
  21. [weakself.endDateBtn setTitle:weakself.endDate forState:UIControlStateNormal];
  22. [self updateModel];
  23. } andCancelBlock:^(void){
  24. }];
  25. [_dealDatePicker show];
  26. }
  27. - (void)awakeFromNib {
  28. [super awakeFromNib];
  29. }
  30. - (IBAction)showStartDate:(id)sender {
  31. __weak typeof(self) weakself=self;
  32. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  33. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  34. _tempStartDate=date;
  35. } andCompletionBlock:^(void){
  36. weakself.startDate = _tempStartDate;
  37. [weakself.startDateBtn setTitle:weakself.startDate forState:UIControlStateNormal];
  38. [self updateModel];
  39. } andCancelBlock:^(void){
  40. }];
  41. [_dealDatePicker show];
  42. }
  43. /**
  44. 高度
  45. @return return value description
  46. */
  47. - (CGFloat)cellHeight {
  48. return 623.5f;
  49. }
  50. /**
  51. cell
  52. @param indexPath <#indexPath description#>
  53. @return <#return value description#>
  54. */
  55. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  56. OrderListSearchCell *cell = [[NSBundle mainBundle]
  57. loadNibNamed:@"OrderListSearchCell"
  58. owner:nil
  59. options:nil][0];
  60. cell.sureBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  61. cell.sureBtn.layer.borderWidth=1;
  62. cell.sureBtn.tag=0;
  63. cell.sureBtn.layer.cornerRadius=4;
  64. [ cell.sureBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  65. [cell.sureBtn addTarget:cell action:@selector(sureStatus) forControlEvents:UIControlEventTouchUpInside];
  66. cell.orderNoTxt.delegate = cell;
  67. cell.completeBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  68. cell.completeBtn.layer.borderWidth=1;
  69. cell.completeBtn.layer.cornerRadius=4;
  70. [ cell.completeBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  71. cell.completeBtn.tag=0;
  72. [ cell.completeBtn addTarget:cell action:@selector(completeStatus)
  73. forControlEvents:UIControlEventTouchUpInside];
  74. cell.inCompleteBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  75. cell.inCompleteBtn.layer.borderWidth=1;
  76. cell.inCompleteBtn.layer.cornerRadius=4;
  77. cell.inCompleteBtn.titleLabel.textColor=NavBarUnEnbleItemColor;
  78. cell.inCompleteBtn.tag=0;
  79. [ cell.inCompleteBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  80. [ cell.inCompleteBtn addTarget:cell action:@selector(incompleteStatus)
  81. forControlEvents:UIControlEventTouchUpInside];
  82. cell.correctBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  83. cell.correctBtn.layer.borderWidth=1;
  84. cell.correctBtn.layer.cornerRadius=4;
  85. cell.correctBtn.tag=0;
  86. [cell.correctBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  87. [cell.correctBtn addTarget:cell action:@selector(correctStatus)
  88. forControlEvents:UIControlEventTouchUpInside];
  89. cell.orderNoTxt.delegate = cell;
  90. cell.customerNameTxt.delegate=cell;
  91. cell.productCodeTxt.delegate=cell;
  92. cell.customerCodeTxt.delegate=cell;
  93. cell.customerAddressTxt.delegate=cell;
  94. [cell configureKeyboard];
  95. return cell;
  96. }
  97. /**
  98. 区分规格
  99. */
  100. - (void)distinguish:(UIButton *) btn{
  101. switch (btn.tag) {
  102. case 0:
  103. btn.tag = 1;
  104. btn.layer.borderColor = [[UIColor redColor] CGColor];
  105. [btn setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
  106. break;
  107. case 1:
  108. btn.tag = 0;
  109. btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  110. [btn setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
  111. break;
  112. default:
  113. break;
  114. }
  115. [self updateModel];
  116. }
  117. -(void)sureStatus{
  118. [self distinguish:_sureBtn];
  119. }
  120. -(void)completeStatus{
  121. [self distinguish:_completeBtn];
  122. }
  123. -(void)incompleteStatus{
  124. [self distinguish:_inCompleteBtn];
  125. }
  126. -(void)correctStatus{
  127. [self distinguish:_correctBtn];
  128. }
  129. /**
  130. 更新model
  131. */
  132. - (void)updateModel{
  133. OrderSearchModel *model = [[ OrderSearchModel alloc] init];
  134. NSString *orderNoStr=[_orderNoTxt.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  135. model.orderNo =orderNoStr;
  136. NSString *customerNameStr=@"";
  137. customerNameStr= [_customerNameTxt.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  138. model.customerName =customerNameStr;
  139. NSString *startDateStr=@"";
  140. startDateStr=_startDateBtn.currentTitle;
  141. model.startDate =startDateStr ;
  142. NSString *endDateStr =@"";
  143. endDateStr=_endDateBtn.currentTitle;
  144. model.endDate=endDateStr;
  145. NSString *goodsCodeStr=@"";
  146. goodsCodeStr= _productCodeTxt.text;
  147. model.goodsCode=goodsCodeStr;
  148. NSString *customerCodeStr=@"";
  149. customerCodeStr=_customerCodeTxt.text;
  150. model.customerCode=customerCodeStr;
  151. NSString *customerAddressStr=@"";
  152. customerAddressStr=_customerAddressTxt.text;
  153. model.customerAddress=customerAddressStr;
  154. _invoiceStatus=@"";
  155. if(_sureBtn.tag==1 ){
  156. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"4,"];
  157. }
  158. if(_completeBtn.tag==1){
  159. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"7,"];
  160. }
  161. if(_inCompleteBtn.tag==1){
  162. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"5,"];
  163. }
  164. if(_correctBtn.tag==1){
  165. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"10,"];
  166. }
  167. if(_invoiceStatus.length>0){
  168. _invoiceStatus= [NSString stringWithFormat:@"%@%@",@",",_invoiceStatus];
  169. }
  170. model.invoiceStatus=_invoiceStatus;
  171. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  172. [mutDict setValue:model forKey:ORDER_SEARCH_RANGE_MODEL];
  173. _regionModel.customDict = [mutDict copy];
  174. }
  175. /**
  176. Identifier
  177. @return <#return value description#>
  178. */
  179. + (NSString *)cellReuseIdentifier {
  180. return @"OrderListSearchCell";
  181. }
  182. /**
  183. 重置按钮 事件
  184. */
  185. - (void)resetData {
  186. [_orderNoTxt setText:@""];
  187. [_customerNameTxt setText:@""];
  188. [_startDateBtn setTitle:@"请选择开始账务日期" forState:UIControlStateNormal];
  189. _startDate = @"";
  190. [_endDateBtn setTitle:@"请选择结束账务日期" forState:UIControlStateNormal];
  191. _endDate = @"";
  192. [_productCodeTxt setText:@""];
  193. [_customerCodeTxt setText:@""];
  194. [_customerAddressTxt setText:@""];
  195. _sureBtn.tag=0;
  196. _completeBtn.tag=0;
  197. _inCompleteBtn.tag=0;
  198. _correctBtn.tag=0;
  199. _invoiceStatus=@"";
  200. }
  201. /**
  202. 长度
  203. @param textField <#textField description#>
  204. @param range <#range description#>
  205. @param string <#string description#>
  206. @return <#return value description#>
  207. */
  208. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  209. return YES;
  210. }
  211. /**
  212. 文本编辑结束事件
  213. @param textField <#textField description#>
  214. */
  215. - (void)textFieldDidEndEditing:(UITextField *)textField {
  216. [self updateModel];
  217. }
  218. /**
  219. * 隐藏键盘
  220. */
  221. -(void)hideKey
  222. {
  223. [self.contentView endEditing:YES];
  224. }
  225. /**
  226. 取消文本
  227. */
  228. - (void)accessoryButtonBack {
  229. NSLog(@"accessoryButtonBack");
  230. [self hideKey];}
  231. /**
  232. 确定文本
  233. */
  234. - (void)accessoryButtonDone {
  235. NSLog(@"accessoryButtonDone");
  236. [_orderNoTxt resignFirstResponder];
  237. [_customerNameTxt resignFirstResponder];
  238. [_productCodeTxt resignFirstResponder];
  239. [_customerCodeTxt resignFirstResponder];
  240. [_customerAddressTxt resignFirstResponder];
  241. [self hideKey];
  242. }
  243. /**
  244. 触摸事件
  245. @param touches <#touches description#>
  246. @param event <#event description#>
  247. */
  248. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  249. [self hideKey];
  250. [_orderNoTxt resignFirstResponder];
  251. [_customerNameTxt resignFirstResponder];
  252. [_productCodeTxt resignFirstResponder];
  253. [_customerCodeTxt resignFirstResponder];
  254. [_customerAddressTxt resignFirstResponder];
  255. }
  256. /**
  257. 更新model
  258. @param model <#model description#>
  259. @param indexPath <#indexPath description#>
  260. */
  261. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  262. indexPath:(NSIndexPath *)indexPath{
  263. self.regionModel = *model;
  264. }
  265. /**
  266. 键盘配置
  267. */
  268. - (void)configureKeyboard {
  269. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  270. _orderNoTxt.inputAccessoryView = keyBoardAccessoryView;
  271. _customerNameTxt.inputAccessoryView = keyBoardAccessoryView;
  272. _productCodeTxt.inputAccessoryView = keyBoardAccessoryView;
  273. _customerCodeTxt.inputAccessoryView = keyBoardAccessoryView;
  274. _customerAddressTxt.inputAccessoryView = keyBoardAccessoryView;
  275. }
  276. /**
  277. 文本编辑时候 弹出取消完成按钮
  278. @return <#return value description#>
  279. */
  280. - (UIView *)createKeyBoardAccessoryView {
  281. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  282. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  283. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  284. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  285. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  286. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  287. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  288. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  289. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  290. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  291. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  292. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  293. [keyBoardAccessoryView addSubview:backButton];
  294. [keyBoardAccessoryView addSubview:doneButton];
  295. return keyBoardAccessoryView;
  296. }
  297. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  298. [super setSelected:selected animated:animated];
  299. }
  300. @end