SalesSlipSearchCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. //
  2. // SalesSlipSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by ssl on 2018/1/26.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesSlipSearchCell.h"
  9. #import "UIColor+hexColor.h"
  10. #import "SideSlipConfig.h"
  11. @interface SalesSlipSearchCell () <UITextFieldDelegate>
  12. @end
  13. @implementation SalesSlipSearchCell
  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 668.5;
  49. }
  50. /**
  51. cell
  52. @param indexPath <#indexPath description#>
  53. @return <#return value description#>
  54. */
  55. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  56. SalesSlipSearchCell *cell = [[NSBundle mainBundle]
  57. loadNibNamed:@"SalesSlipSearchCell"
  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.draftBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  90. cell.draftBtn.layer.borderWidth=1;
  91. cell.draftBtn.layer.cornerRadius=4;
  92. cell.draftBtn.titleLabel.textColor=NavBarUnEnbleItemColor;
  93. cell.draftBtn.tag=0;
  94. [ cell.draftBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  95. [ cell.draftBtn addTarget:cell action:@selector(draftStatus)
  96. forControlEvents:UIControlEventTouchUpInside];
  97. cell.finshSaleBtn.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  98. cell.finshSaleBtn.hidden = YES;
  99. cell.finshSaleBtn.layer.borderWidth=1;
  100. cell.finshSaleBtn.layer.cornerRadius=4;
  101. cell.finshSaleBtn.titleLabel.textColor=NavBarUnEnbleItemColor;
  102. cell.finshSaleBtn.tag=0;
  103. [ cell.finshSaleBtn setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  104. [ cell.finshSaleBtn addTarget:cell action:@selector(finshSaleStatus)
  105. forControlEvents:UIControlEventTouchUpInside];
  106. cell.orderNoTxt.delegate = cell;
  107. cell.customerNameTxt.delegate=cell;
  108. cell.productCodeTxt.delegate=cell;
  109. cell.customerCodeTxt.delegate=cell;
  110. cell.customerAddressTxt.delegate=cell;
  111. [cell configureKeyboard];
  112. return cell;
  113. }
  114. /**
  115. 区分规格
  116. */
  117. - (void)distinguish:(UIButton *) btn{
  118. switch (btn.tag) {
  119. case 0:
  120. btn.tag = 1;
  121. btn.layer.borderColor = [[UIColor redColor] CGColor];
  122. [btn setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
  123. break;
  124. case 1:
  125. btn.tag = 0;
  126. btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  127. [btn setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
  128. break;
  129. default:
  130. break;
  131. }
  132. [self updateModel];
  133. }
  134. -(void)sureStatus{
  135. [self distinguish:_sureBtn];
  136. }
  137. -(void)completeStatus{
  138. [self distinguish:_completeBtn];
  139. }
  140. -(void)incompleteStatus{
  141. [self distinguish:_inCompleteBtn];
  142. }
  143. -(void)draftStatus{
  144. [self distinguish:_draftBtn];
  145. }
  146. -(void)finshSaleStatus{
  147. [self distinguish:_finshSaleBtn];
  148. }
  149. -(void)correctStatus{
  150. [self distinguish:_correctBtn];
  151. }
  152. /**
  153. 更新model
  154. */
  155. - (void)updateModel{
  156. SalesSlipSearchModel *model = [[SalesSlipSearchModel alloc] init];
  157. NSString *orderNoStr=[_orderNoTxt.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  158. model.SalesNo =orderNoStr;
  159. NSString *customerNameStr=@"";
  160. customerNameStr= [_customerNameTxt.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  161. model.customerName =customerNameStr;
  162. NSString *startDateStr=@"";
  163. startDateStr=_startDateBtn.currentTitle;;
  164. model.startDate =startDateStr ;
  165. NSString *endDateStr=@"";
  166. endDateStr=_endDateBtn.currentTitle;
  167. model.endDate=endDateStr;
  168. NSString *goodsCodeStr=@"";
  169. goodsCodeStr= _productCodeTxt.text;
  170. model.goodsCode=goodsCodeStr;
  171. NSString *customerCodeStr=@"";
  172. customerCodeStr=_customerCodeTxt.text;
  173. model.customerCode=customerCodeStr;
  174. NSString *customerAddressStr=@"";
  175. customerAddressStr=_customerAddressTxt.text;
  176. model.customerAddress=customerAddressStr;
  177. _invoiceStatus=@"";
  178. if(_sureBtn.tag==1 ){
  179. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"4,"];
  180. }
  181. if(_completeBtn.tag==1){
  182. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"7,"];
  183. }
  184. if(_draftBtn.tag==1){
  185. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"11,"];
  186. }
  187. if(_finshSaleBtn.tag==1){
  188. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"6,"];
  189. }
  190. if(_inCompleteBtn.tag==1){
  191. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"5,"];
  192. }
  193. if(_correctBtn.tag==1){
  194. _invoiceStatus= [NSString stringWithFormat:@"%@%@",_invoiceStatus,@"10,"];
  195. }
  196. if(_invoiceStatus.length>0){
  197. _invoiceStatus= [NSString stringWithFormat:@"%@%@",@",",_invoiceStatus];
  198. }
  199. model.invoiceStatus=_invoiceStatus;
  200. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  201. [mutDict setValue:model forKey:ORDER_SEARCH_RANGE_MODEL];
  202. _regionModel.customDict = [mutDict copy];
  203. }
  204. /**
  205. Identifier
  206. @return <#return value description#>
  207. */
  208. + (NSString *)cellReuseIdentifier {
  209. return @"OrderListSearchCell";
  210. }
  211. /**
  212. 重置按钮 事件
  213. */
  214. - (void)resetData {
  215. [_orderNoTxt setText:@""];
  216. [_customerNameTxt setText:@""];
  217. [_startDateBtn setTitle:@"请选择开始账务日期" forState:UIControlStateNormal];
  218. _startDate = @"";
  219. [_endDateBtn setTitle:@"请选择结束账务日期" forState:UIControlStateNormal];
  220. _endDate = @"";
  221. [_productCodeTxt setText:@""];
  222. [_customerCodeTxt setText:@""];
  223. [_customerAddressTxt setText:@""];
  224. _sureBtn.tag=0;
  225. _completeBtn.tag=0;
  226. _inCompleteBtn.tag=0;
  227. _correctBtn.tag=0;
  228. _invoiceStatus=@"";
  229. }
  230. /**
  231. 长度
  232. @param textField <#textField description#>
  233. @param range <#range description#>
  234. @param string <#string description#>
  235. @return <#return value description#>
  236. */
  237. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  238. return YES;
  239. }
  240. /**
  241. 文本编辑结束事件
  242. @param textField <#textField description#>
  243. */
  244. - (void)textFieldDidEndEditing:(UITextField *)textField {
  245. [self updateModel];
  246. }
  247. /**
  248. * 隐藏键盘
  249. */
  250. -(void)hideKey
  251. {
  252. [self.contentView endEditing:YES];
  253. }
  254. /**
  255. 取消文本
  256. */
  257. - (void)accessoryButtonBack {
  258. NSLog(@"accessoryButtonBack");
  259. [self hideKey];}
  260. /**
  261. 确定文本
  262. */
  263. - (void)accessoryButtonDone {
  264. NSLog(@"accessoryButtonDone");
  265. [_orderNoTxt resignFirstResponder];
  266. [_customerNameTxt resignFirstResponder];
  267. [_productCodeTxt resignFirstResponder];
  268. [_customerCodeTxt resignFirstResponder];
  269. [_customerAddressTxt resignFirstResponder];
  270. [self hideKey];
  271. }
  272. /**
  273. 触摸事件
  274. @param touches <#touches description#>
  275. @param event <#event description#>
  276. */
  277. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  278. [self hideKey];
  279. [_orderNoTxt resignFirstResponder];
  280. [_customerNameTxt resignFirstResponder];
  281. [_productCodeTxt resignFirstResponder];
  282. [_customerCodeTxt resignFirstResponder];
  283. [_customerAddressTxt resignFirstResponder];
  284. }
  285. /**
  286. 更新model
  287. @param model <#model description#>
  288. @param indexPath <#indexPath description#>
  289. */
  290. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  291. indexPath:(NSIndexPath *)indexPath{
  292. self.regionModel = *model;
  293. }
  294. /**
  295. 键盘配置
  296. */
  297. - (void)configureKeyboard {
  298. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  299. _orderNoTxt.inputAccessoryView = keyBoardAccessoryView;
  300. _customerNameTxt.inputAccessoryView = keyBoardAccessoryView;
  301. _productCodeTxt.inputAccessoryView = keyBoardAccessoryView;
  302. _customerCodeTxt.inputAccessoryView = keyBoardAccessoryView;
  303. _customerAddressTxt.inputAccessoryView = keyBoardAccessoryView;
  304. }
  305. /**
  306. 文本编辑时候 弹出取消完成按钮
  307. @return <#return value description#>
  308. */
  309. - (UIView *)createKeyBoardAccessoryView {
  310. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  311. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  312. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  313. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  314. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  315. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  316. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  317. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  318. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  319. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  320. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  321. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  322. [keyBoardAccessoryView addSubview:backButton];
  323. [keyBoardAccessoryView addSubview:doneButton];
  324. return keyBoardAccessoryView;
  325. }
  326. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  327. [super setSelected:selected animated:animated];
  328. }
  329. @end