InventoryOrderSearchListCell.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. //
  2. // InventoryOrderSearchListCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2020/5/7.
  6. // Copyright © 2020 elongtian. All rights reserved.
  7. //
  8. #import "InventoryOrderSearchListCell.h"
  9. @implementation InventoryOrderSearchListCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. }
  13. #pragma mark - 委托函数
  14. /**
  15. 高度
  16. @return return value description
  17. */
  18. - (CGFloat)cellHeight {
  19. return 788.0f;
  20. }
  21. /**
  22. cell
  23. @param indexPath <#indexPath description#>
  24. @return <#return value description#>
  25. */
  26. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  27. InventoryOrderSearchListCell *cell = [[NSBundle mainBundle]
  28. loadNibNamed:@"InventoryOrderSearchListCell"
  29. owner:nil
  30. options:nil][0];
  31. cell.txtCustomerName.delegate = cell;
  32. cell.txtContacts.delegate = cell;
  33. cell.txtTelephone.delegate = cell;
  34. cell.txtTelephone.keyboardType=UIKeyboardTypeNumberPad;
  35. [cell configureKeyboard];
  36. return cell;
  37. }
  38. - (void)configureKeyboard {
  39. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  40. _txtCustomerName.inputAccessoryView=keyBoardAccessoryView;
  41. _txtContacts.inputAccessoryView=keyBoardAccessoryView;
  42. _txtTelephone.inputAccessoryView = keyBoardAccessoryView;
  43. }
  44. /**
  45. 文本编辑时候 弹出取消完成按钮
  46. @return <#return value description#>
  47. */
  48. - (UIView *)createKeyBoardAccessoryView {
  49. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  50. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  51. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  52. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  53. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  54. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  55. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  56. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  57. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  58. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  59. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  60. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  61. [keyBoardAccessoryView addSubview:backButton];
  62. [keyBoardAccessoryView addSubview:doneButton];
  63. return keyBoardAccessoryView;
  64. }
  65. /**
  66. 取消文本
  67. */
  68. - (void)accessoryButtonBack {
  69. [self hideKey];}
  70. /**
  71. 确定文本
  72. */
  73. - (void)accessoryButtonDone {
  74. [_txtCustomerName resignFirstResponder];
  75. [_txtContacts resignFirstResponder];
  76. [_txtTelephone resignFirstResponder];
  77. [self hideKey];
  78. }
  79. /**
  80. 文本编辑结束事件
  81. @param textField <#textField description#>
  82. */
  83. - (void)textFieldDidEndEditing:(UITextField *)textField {
  84. [self updateModel];
  85. }
  86. /**
  87. 更新model
  88. @param model <#model description#>
  89. @param indexPath <#indexPath description#>
  90. */
  91. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  92. indexPath:(NSIndexPath *)indexPath{
  93. self.regionModel = *model;
  94. [self updateModel];
  95. }
  96. /**
  97. 长度
  98. @param textField <#textField description#>
  99. @param range <#range description#>
  100. @param string <#string description#>
  101. @return <#return value description#>
  102. */
  103. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  104. return YES;
  105. }
  106. /**
  107. Identifier
  108. @return <#return value description#>
  109. */
  110. + (NSString *)cellReuseIdentifier {
  111. return @"InventoryOrderSearchListCell";
  112. }
  113. /**
  114. 重置按钮 事件
  115. */
  116. - (void)resetData {
  117. [_txtCustomerName setText:@""];
  118. [_txtContacts setText:@""];
  119. [_txtTelephone setText:@""];
  120. [self.btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
  121. _staffName=@"";
  122. [self.btnFreezeReason setTitle:@"请选择冻结原因" forState:UIControlStateNormal];
  123. _freezeReasonName=@"";
  124. [self.btnAccountStartDate setTitle:@"请选择账务开始日期" forState:UIControlStateNormal];
  125. _accountStartDate=@"";
  126. [self.btnAccountEndDate setTitle:@"请选择账务结束日期" forState:UIControlStateNormal];
  127. _accountEndDate=@"";
  128. [self.btnFreezeStartDate setTitle:@"请选择冻结截止开始日期" forState:UIControlStateNormal];
  129. _freezeStartDate=@"";
  130. [self.btnFreezeEndDate setTitle:@"请选择冻结截止结束日期" forState:UIControlStateNormal];
  131. _freezeEndDate=@"";
  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. [_txtCustomerName resignFirstResponder];
  141. [_txtContacts resignFirstResponder];
  142. [_txtTelephone resignFirstResponder];
  143. }
  144. /**
  145. * 隐藏键盘
  146. */
  147. - (void)hideKey
  148. {
  149. [self.contentView endEditing:YES];
  150. }
  151. - (IBAction)staffClickAction:(id)sender {
  152. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  153. tc.cDelegate = self;
  154. tc.isPresentViewFlag = YES;
  155. tc.showDialogViewTag=ReportAchiementmn;
  156. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  157. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  158. }
  159. }
  160. /**
  161. 业务员
  162. @param Amodel <#Amodel description#>
  163. @param cr <#cr description#>
  164. */
  165. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  166. // 业务员
  167. if(cr == ReportAchiementmn){
  168. _staffName = Amodel.staffName;
  169. [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
  170. }
  171. [self updateModel];
  172. }
  173. -(void)getFreezeReason:(NSString*)reasonId name:(NSString*)reasonName
  174. {
  175. _freezeReasonId=reasonId;
  176. _freezeReasonName=reasonName;
  177. [_btnFreezeReason setTitle:_freezeReasonName forState:UIControlStateNormal];
  178. [_btnFreezeReason setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  179. [self updateModel];
  180. }
  181. - (IBAction)freezeReasonClickAction:(id)sender {
  182. FreezeReasonViewController *tc = [[FreezeReasonViewController alloc ]init];
  183. tc.inventoryDelegate = self;
  184. tc.isPresentVc = YES;
  185. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  186. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  187. }
  188. }
  189. - (IBAction)accountStartDateClickAction:(id)sender {
  190. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  191. [_brDatePicker configureSelectionBlock:^(NSString *date){
  192. self->_accountStartDate=date;
  193. } andCompletionBlock:^(void){
  194. [self->_btnAccountStartDate setTitle:self->_accountStartDate forState:UIControlStateNormal];
  195. [self updateModel];
  196. } andCancelBlock:^(void){
  197. self->_accountStartDate=self->_btnAccountStartDate.titleLabel.text;
  198. }];
  199. [_brDatePicker show];
  200. }
  201. - (IBAction)accountEndDateClickAction:(id)sender {
  202. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  203. [_brDatePicker configureSelectionBlock:^(NSString *date){
  204. self->_accountEndDate=date;
  205. } andCompletionBlock:^(void){
  206. [self->_btnAccountEndDate setTitle:self->_accountEndDate forState:UIControlStateNormal];
  207. [self updateModel];
  208. } andCancelBlock:^(void){
  209. self->_accountEndDate=self->_btnAccountEndDate.titleLabel.text;
  210. }];
  211. [_brDatePicker show];
  212. }
  213. - (IBAction)freezeStartDateClickAction:(id)sender {
  214. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  215. [_brDatePicker configureSelectionBlock:^(NSString *date){
  216. self->_freezeStartDate=date;
  217. } andCompletionBlock:^(void){
  218. [self->_btnFreezeStartDate setTitle:self->_freezeStartDate forState:UIControlStateNormal];
  219. [self updateModel];
  220. } andCancelBlock:^(void){
  221. self->_freezeStartDate=self->_btnFreezeStartDate.titleLabel.text;
  222. }];
  223. [_brDatePicker show];
  224. }
  225. - (IBAction)freezeEndDateClickAction:(id)sender {
  226. _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  227. [_brDatePicker configureSelectionBlock:^(NSString *date){
  228. self->_freezeEndDate=date;
  229. } andCompletionBlock:^(void){
  230. [self->_btnFreezeEndDate setTitle:self->_freezeEndDate forState:UIControlStateNormal];
  231. [self updateModel];
  232. } andCancelBlock:^(void){
  233. self->_freezeEndDate=self->_btnFreezeEndDate.titleLabel.text;
  234. }];
  235. [_brDatePicker show];
  236. }
  237. -(void)updateModel
  238. {
  239. InventoryFreezeOrderSearchModel *searchModel=[[InventoryFreezeOrderSearchModel alloc]init];
  240. searchModel.customerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  241. searchModel.contacts=[_txtContacts.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  242. searchModel.telephone=[_txtTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  243. searchModel.staffName=_staffName;
  244. searchModel.freezeReasonName=_freezeReasonName;
  245. searchModel.accountStartDate=_accountStartDate;
  246. searchModel.accountEndDate=_accountEndDate;
  247. searchModel.freezeStartDate=_freezeStartDate;
  248. searchModel.freezeEndDate=_freezeEndDate;
  249. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  250. [mutDict setValue:searchModel forKey:INVENTORY_FREEZE_ORDER_SEARCH_MODEL];
  251. _regionModel.customDict = [mutDict copy];
  252. }
  253. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  254. [super setSelected:selected animated:animated];
  255. }
  256. @end