OrderAuditSearchCell.m 11 KB

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