SalesOutStorageSearchCell.m 9.8 KB

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