OrderSalesApproveSearchCell.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. //
  2. // OrderSalesApproveSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2019/4/12.
  6. // Copyright © 2019 elongtian. All rights reserved.
  7. //
  8. #import "OrderSalesApproveSearchCell.h"
  9. #import "StatusInfo.h"
  10. @implementation OrderSalesApproveSearchCell
  11. - (void)awakeFromNib {
  12. [super awakeFromNib];
  13. }
  14. /**
  15. 单元格高度
  16. @return <#return value description#>
  17. */
  18. - (CGFloat)cellHeight {
  19. return 955.0f;
  20. }
  21. /**
  22. 加载tableviewcell
  23. @param indexPath <#indexPath description#>
  24. @return <#return value description#>
  25. */
  26. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  27. OrderSalesApproveSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"OrderSalesApproveSearchCell" owner:nil options:nil][0];
  28. cell.txtInvoiceNo.delegate = cell;
  29. cell.txtCustomerCode.delegate=cell;
  30. cell.txtCustomerName.delegate=cell;
  31. cell.txtCustomerAddress.delegate=cell;
  32. [cell configureKeyboard];
  33. return cell;
  34. }
  35. /**
  36. 键盘配置
  37. */
  38. - (void)configureKeyboard {
  39. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  40. _txtInvoiceNo.inputAccessoryView = keyBoardAccessoryView;
  41. _txtApprover.inputAccessoryView=keyBoardAccessoryView;
  42. _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
  43. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  44. _txtCustomerAddress.inputAccessoryView= keyBoardAccessoryView;
  45. }
  46. /**
  47. 文本编辑时候 弹出取消完成按钮
  48. @return <#return value description#>
  49. */
  50. - (UIView *)createKeyBoardAccessoryView {
  51. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  52. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  53. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  54. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  55. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  56. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  57. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  58. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  59. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  60. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  61. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  62. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  63. [keyBoardAccessoryView addSubview:backButton];
  64. [keyBoardAccessoryView addSubview:doneButton];
  65. return keyBoardAccessoryView;
  66. }
  67. /**
  68. 取消文本
  69. */
  70. - (void)accessoryButtonBack {
  71. [self hideKey];}
  72. /**
  73. 确定文本
  74. */
  75. - (void)accessoryButtonDone {
  76. [_txtInvoiceNo resignFirstResponder];
  77. [_txtApprover resignFirstResponder];
  78. [_txtCustomerCode resignFirstResponder];
  79. [_txtCustomerName resignFirstResponder];
  80. [_txtCustomerAddress resignFirstResponder];
  81. [self hideKey];
  82. }
  83. /**
  84. * 隐藏键盘
  85. */
  86. - (void)hideKey
  87. {
  88. [self.contentView endEditing:YES];
  89. }
  90. - (IBAction)clickStaffAction:(id)sender {
  91. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  92. tc.cDelegate = self;
  93. tc.isPresentViewFlag = YES;
  94. tc.showDialogViewTag=ReportAchiementmn;
  95. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  96. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  97. }
  98. }
  99. /**
  100. 更新model
  101. 关宏厚2017-7-6
  102. @param model <#model description#>
  103. @param indexPath <#indexPath description#>
  104. */
  105. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  106. self.regionModel = *model;
  107. NSString *startDateStr = [DateFormat getDateBefore:31];
  108. NSString *endDateStr = [DateFormat getCurrentDate];
  109. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  110. _sStartDate= _btnStartDate.titleLabel.text;
  111. [_btnEndDate setTitle:endDateStr forState:UIControlStateNormal];
  112. _sEndDate =_btnEndDate.titleLabel.text;
  113. [self updateModel];
  114. }
  115. /**
  116. Identifier
  117. @return <#return value description#>
  118. */
  119. + (NSString *)cellReuseIdentifier {
  120. return @"OrderSalesApproveSearchCell";
  121. }
  122. - (IBAction)clickInvoiceTypeAction:(id)sender
  123. {
  124. [self initStatus];
  125. _flag=@"invoiceType";
  126. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  127. tc.sdelegate=self;
  128. tc.isPresentViewFlag=YES;
  129. [tc.arrFilter addObjectsFromArray: _invoiceTypeList];
  130. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  131. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  132. }
  133. }
  134. /**
  135. 重置按钮 事件
  136. */
  137. - (void)resetData {
  138. _txtInvoiceNo.text=@"";
  139. _txtApprover.text=@"";
  140. _txtCustomerCode.text=@"";
  141. _txtCustomerName.text=@"";
  142. _txtCustomerAddress.text=@"";
  143. [_btnInvoiceType setTitle:@"请选择业务类型" forState:UIControlStateNormal];
  144. _invoiceType=@"0";
  145. [_btnApproveResult setTitle:@"请选择审批结果" forState:UIControlStateNormal];
  146. _approveResult=@"2";
  147. [_btnDepartment setTitle:@"请选择业务部门" forState:UIControlStateNormal];
  148. _organizationCode = @"";
  149. [_btnStartDate setTitle:@"请选择开始日期" forState:UIControlStateNormal];
  150. _sStartDate = @"";
  151. [_btnEndDate setTitle:@"请选择结束日期" forState:UIControlStateNormal];
  152. _sEndDate= @"";
  153. [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
  154. _staffId=@"";
  155. }
  156. /**
  157. 回调状态
  158. @param s <#s description#>
  159. */
  160. - (void)showStatusValue:(StatusInfo *)s{
  161. if([_flag isEqualToString:@"invoiceType"]){
  162. _invoiceType=s.statusId;
  163. [_btnInvoiceType setTitle:s.name forState:UIControlStateNormal];
  164. [self updateModel];
  165. }
  166. else if([_flag isEqualToString:@"approveResult"])
  167. {
  168. _approveResult=s.statusId;
  169. [_btnApproveResult setTitle:s.name forState:UIControlStateNormal];
  170. [self updateModel];
  171. }
  172. }
  173. /**
  174. 业务部门
  175. @param Amodel <#Amodel description#>
  176. @param cr <#cr description#>
  177. */
  178. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  179. //返回值
  180. if(cr == ReportAchiementDepartmt){
  181. _organizationCode=Amodel.organizationCode;
  182. [self.btnDepartment setTitle:Amodel.organizationName forState:UIControlStateNormal];
  183. }
  184. // 业务员
  185. if(cr == ReportAchiementmn){
  186. _staffId = Amodel.staffId;
  187. [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
  188. }
  189. [self updateModel];
  190. }
  191. - (IBAction)clickApproveResultAction:(id)sender {
  192. _flag=@"approveResult";
  193. [self initApproveList];
  194. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  195. tc.sdelegate=self;
  196. tc.isPresentViewFlag=YES;
  197. [tc.arrFilter addObjectsFromArray: _approveResultList];
  198. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  199. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  200. }
  201. }
  202. - (IBAction)clickApproveStartDateAction:(id)sender {
  203. __weak typeof(self) weakself=self;
  204. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  205. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  206. self->_tempStartDate=date;
  207. } andCompletionBlock:^(void){
  208. weakself.sStartDate = self->_tempStartDate;
  209. [weakself.btnStartDate setTitle: weakself.sStartDate forState:UIControlStateNormal];
  210. [self updateModel];
  211. } andCancelBlock:^(void){
  212. }];
  213. [_dealDatePicker show];
  214. }
  215. - (IBAction)clickApproveEndDateAction:(id)sender {
  216. __weak typeof(self) weakself=self;
  217. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  218. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  219. self->_tempEndDate=date;
  220. } andCompletionBlock:^(void){
  221. weakself.sEndDate = self->_tempEndDate;
  222. [weakself.btnEndDate setTitle:weakself.sEndDate forState:UIControlStateNormal];
  223. [self updateModel];
  224. }
  225. andCancelBlock:^(void){
  226. }];
  227. [_dealDatePicker show];
  228. }
  229. - (IBAction)clickDepartmentAction:(id)sender {
  230. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  231. tc.cDelegate = self;
  232. tc.isPresentViewFlag = YES;
  233. tc.flag = YES;
  234. tc.showDialogViewTag=ReportAchiementDepartmt;
  235. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  236. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  237. }
  238. }
  239. /**
  240. 触摸事件
  241. @param touches <#touches description#>
  242. @param event <#event description#>
  243. */
  244. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  245. [self hideKey];
  246. [_txtInvoiceNo resignFirstResponder];
  247. [_txtApprover resignFirstResponder];
  248. [_txtCustomerCode resignFirstResponder];
  249. [_txtCustomerName resignFirstResponder];
  250. [_txtCustomerAddress resignFirstResponder];
  251. }
  252. /**
  253. 长度
  254. @param textField <#textField description#>
  255. @param range <#range description#>
  256. @param string <#string description#>
  257. @return <#return value description#>
  258. */
  259. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  260. return YES;
  261. }
  262. /**
  263. 文本编辑结束事件
  264. @param textField <#textField description#>
  265. */
  266. - (void)textFieldDidEndEditing:(UITextField *)textField {
  267. [self updateModel];
  268. }
  269. /**
  270. 更新model
  271. */
  272. - (void)updateModel{
  273. OrderSalesApproveSearchModel *model = [[OrderSalesApproveSearchModel alloc] init];
  274. model.invoiceNo =[_txtInvoiceNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  275. model.reviewerName=[_txtApprover.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  276. model.customerCode=[_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  277. model.customerName=[_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  278. model.customerAddress=[_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  279. model.startDate = _sStartDate;
  280. model.endDate = _sEndDate;
  281. model.invoiceType=_invoiceType;
  282. model.organizationCode=_organizationCode;
  283. model.approveResult=_approveResult;
  284. model.staffId=_staffId;
  285. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  286. [mutDict setValue:model forKey:Order_SALES_APPROVE_SEARCH_MODEL];
  287. _regionModel.customDict = [mutDict copy];
  288. }
  289. /**
  290. 单据类型数据源
  291. */
  292. - (void)initStatus{
  293. _invoiceTypeList = [[NSMutableArray alloc]init];
  294. StatusInfo* s = [[StatusInfo alloc]init];
  295. s.statusId = @"0";
  296. s.name = @"全部";
  297. [_invoiceTypeList addObject:s];
  298. s = [[StatusInfo alloc]init];
  299. s.statusId = @"1";
  300. s.name = @"销售订单";
  301. [_invoiceTypeList addObject:s];
  302. s = [[StatusInfo alloc]init];
  303. s.statusId = @"2";
  304. s.name = @"订单存定金";
  305. [_invoiceTypeList addObject:s];
  306. s = [[StatusInfo alloc]init];
  307. s.statusId = @"3";
  308. s.name = @"订单取定金";
  309. [_invoiceTypeList addObject:s];
  310. s = [[StatusInfo alloc]init];
  311. s.statusId = @"5";
  312. s.name = @"销售单";
  313. [_invoiceTypeList addObject:s];
  314. s = [[StatusInfo alloc]init];
  315. s.statusId = @"6";
  316. s.name = @"订单申请";
  317. [_invoiceTypeList addObject:s];
  318. s = [[StatusInfo alloc]init];
  319. s.statusId = @"7";
  320. s.name = @"订单占库";
  321. [_invoiceTypeList addObject:s];
  322. s = [[StatusInfo alloc]init];
  323. s.statusId = @"8";
  324. s.name = @"退货登记";
  325. [_invoiceTypeList addObject:s];
  326. }
  327. -(void)initApproveList
  328. {
  329. _approveResultList=[[NSMutableArray alloc]init];
  330. StatusInfo* s = [[StatusInfo alloc]init];
  331. s.statusId = @"2";
  332. s.name = @"全部";
  333. [_approveResultList addObject:s];
  334. s = [[StatusInfo alloc]init];
  335. s.statusId = @"0";
  336. s.name = @"审批未通过";
  337. [_approveResultList addObject:s];
  338. s = [[StatusInfo alloc]init];
  339. s.statusId = @"1";
  340. s.name = @"审批通过";
  341. [_approveResultList addObject:s];
  342. }
  343. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  344. [super setSelected:selected animated:animated];
  345. }
  346. @end