InventoryFreezeOrderSearchCell.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //
  2. // InventoryFreezeOrderSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/5/11.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryFreezeOrderSearchCell.h"
  9. @implementation InventoryFreezeOrderSearchCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. }
  13. #pragma mark - 委托函数
  14. /**
  15. 高度
  16. @return return value description
  17. */
  18. - (CGFloat)cellHeight {
  19. return 449.0f;
  20. }
  21. /**
  22. cell
  23. @param indexPath <#indexPath description#>
  24. @return <#return value description#>
  25. */
  26. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  27. InventoryFreezeOrderSearchCell *cell = [[NSBundle mainBundle]
  28. loadNibNamed:@"InventoryFreezeOrderSearchCell"
  29. owner:nil
  30. options:nil][0];
  31. cell.txtCustomerCode.delegate = cell;
  32. cell.txtContacts.delegate = cell;
  33. cell.txtTelephone.delegate=cell;
  34. [cell configureKeyboard];
  35. return cell;
  36. }
  37. - (void)configureKeyboard {
  38. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  39. _txtCustomerCode.inputAccessoryView=keyBoardAccessoryView;
  40. _txtContacts.inputAccessoryView=keyBoardAccessoryView;
  41. _txtTelephone.inputAccessoryView=keyBoardAccessoryView;
  42. }
  43. /**
  44. 文本编辑时候 弹出取消完成按钮
  45. @return <#return value description#>
  46. */
  47. - (UIView *)createKeyBoardAccessoryView {
  48. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  49. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  50. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  51. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  52. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  53. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  54. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  55. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  56. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  57. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  58. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  59. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  60. [keyBoardAccessoryView addSubview:backButton];
  61. [keyBoardAccessoryView addSubview:doneButton];
  62. return keyBoardAccessoryView;
  63. }
  64. /**
  65. 取消文本
  66. */
  67. - (void)accessoryButtonBack {
  68. [self hideKey];}
  69. /**
  70. 确定文本
  71. */
  72. - (void)accessoryButtonDone {
  73. [_txtCustomerCode resignFirstResponder];
  74. [_txtContacts resignFirstResponder];
  75. [_txtTelephone resignFirstResponder];
  76. [self hideKey];
  77. }
  78. /**
  79. * 隐藏键盘
  80. */
  81. - (void)hideKey
  82. {
  83. [self.contentView endEditing:YES];
  84. }
  85. /**
  86. 文本编辑结束事件
  87. @param textField <#textField description#>
  88. */
  89. - (void)textFieldDidEndEditing:(UITextField *)textField {
  90. [self updateModel];
  91. }
  92. /**
  93. 重置按钮 事件
  94. */
  95. - (void)resetData {
  96. [_txtCustomerCode setText:@""];
  97. [_txtContacts setText:@""];
  98. [_txtTelephone setText:@""];
  99. [self.btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
  100. _staffName=@"";
  101. [self.btnFreezeReason setTitle:@"请选择冻结原因" forState:UIControlStateNormal];
  102. _freezeReasonName=@"";
  103. }
  104. /**
  105. 更新model
  106. @param model <#model description#>
  107. @param indexPath <#indexPath description#>
  108. */
  109. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  110. indexPath:(NSIndexPath *)indexPath{
  111. self.regionModel = *model;
  112. [self updateModel];
  113. }
  114. /**
  115. 业务员
  116. @param Amodel <#Amodel description#>
  117. @param cr <#cr description#>
  118. */
  119. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  120. // 业务员
  121. if(cr == ReportAchiementmn){
  122. _staffName = Amodel.staffName;
  123. [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
  124. [self.btnStaff setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  125. }
  126. [self updateModel];
  127. }
  128. /**
  129. 长度
  130. @param textField <#textField description#>
  131. @param range <#range description#>
  132. @param string <#string description#>
  133. @return <#return value description#>
  134. */
  135. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  136. return YES;
  137. }
  138. /**
  139. Identifier
  140. @return <#return value description#>
  141. */
  142. + (NSString *)cellReuseIdentifier {
  143. return @"InventoryFreezeOrderSearchCell";
  144. }
  145. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  146. [super setSelected:selected animated:animated];
  147. }
  148. - (IBAction)clickStaffAction:(id)sender {
  149. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  150. tc.cDelegate = self;
  151. tc.isPresentViewFlag = YES;
  152. tc.showDialogViewTag=ReportAchiementmn;
  153. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  154. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  155. }
  156. }
  157. - (IBAction)clickFreezeReasonAction:(id)sender {
  158. FreezeReasonViewController *tc = [[FreezeReasonViewController alloc ]init];
  159. tc.inventoryDelegate = self;
  160. tc.isPresentVc = YES;
  161. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  162. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  163. }
  164. }
  165. -(void)getFreezeReason:(NSString*)reasonId name:(NSString*)reasonName
  166. {
  167. _freezeReasonName=reasonName;
  168. [_btnFreezeReason setTitle:_freezeReasonName forState:UIControlStateNormal];
  169. [_btnFreezeReason setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  170. [self updateModel];
  171. }
  172. -(void)updateModel
  173. {
  174. InventoryFreezeOrderSearchModel *searchModel=[[InventoryFreezeOrderSearchModel alloc]init];
  175. searchModel.customerCode = [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  176. searchModel.contacts=[_txtContacts.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  177. searchModel.telephone=[_txtTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  178. searchModel.staffName=_staffName;
  179. searchModel.freezeReasonName=_freezeReasonName;
  180. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  181. [mutDict setValue:searchModel forKey:INVENTORY_FREEZE_ORDER_SEARCH_MODEL];
  182. _regionModel.customDict = [mutDict copy];
  183. }
  184. @end