SalesInStorageSearchCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. //
  2. // SalesInStorageSearchCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/4/20.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "SalesInStorageSearchCell.h"
  9. #import "UIColor+hexColor.h"
  10. #import "SideSlipConfig.h"
  11. @implementation SalesInStorageSearchCell
  12. #pragma mark 公共函数
  13. /**
  14. 加载xib
  15. */
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. }
  19. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  20. [super setSelected:selected animated:animated];
  21. }
  22. #pragma mark 委托函数
  23. /**
  24. 高度
  25. @return return value description
  26. */
  27. - (CGFloat)cellHeight {
  28. return 622.5;
  29. }
  30. - (void)customerReportTextDoneDatas:(CustomerReportTextInfoModel *)model CustomerReport:(CustomerReport)cr{
  31. if (model==nil) {
  32. return;
  33. }
  34. if(cr==ReportSupplier){
  35. _supplierId=model.idCode;
  36. _supplierName=model.name;
  37. [self.btnSupplier setTitle:_supplierName forState:UIControlStateNormal];
  38. }
  39. [self updateModel];
  40. }
  41. /**
  42. 业务员 业务部门
  43. @param Amodel <#Amodel description#>
  44. @param cr <#cr description#>
  45. */
  46. -(void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  47. //返回值
  48. if(cr== ReportAchiementDepartmt){
  49. _organizationCode=Amodel.organizationCode;
  50. [self.btnDepartment setTitle:Amodel.organizationName forState:UIControlStateNormal];
  51. }
  52. // 业务员
  53. if(cr==ReportAchiementmn){
  54. _staffId = Amodel.staffId;
  55. [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
  56. }
  57. [self updateModel];
  58. }
  59. /**
  60. 更新model
  61. @param model <#model description#>
  62. @param indexPath <#indexPath description#>
  63. */
  64. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  65. indexPath:(NSIndexPath *)indexPath{
  66. self.regionModel = *model;
  67. }
  68. /**
  69. Identifier
  70. @return <#return value description#>
  71. */
  72. + (NSString *)cellReuseIdentifier {
  73. return @"SalesInStorageSearchCell";
  74. }
  75. /**
  76. cell
  77. @param indexPath <#indexPath description#>
  78. @return <#return value description#>
  79. */
  80. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  81. SalesInStorageSearchCell *cell = [[NSBundle mainBundle]
  82. loadNibNamed:@"SalesInStorageSearchCell"
  83. owner:nil
  84. options:nil][0];
  85. cell.btnApprovePass.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  86. cell.btnApprovePass.layer.borderWidth=1;
  87. cell.btnApprovePass.tag=0;
  88. cell.btnApprovePass.layer.cornerRadius=4;
  89. [cell.btnApprovePass setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  90. [cell.btnApprovePass addTarget:cell action:@selector(approveStatus)
  91. forControlEvents:UIControlEventTouchUpInside];
  92. cell.btnCorrect.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
  93. cell.btnCorrect.layer.borderWidth=1;
  94. cell.btnCorrect.tag=0;
  95. cell.btnCorrect.layer.cornerRadius=4;
  96. [cell.btnCorrect setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
  97. [cell.btnCorrect addTarget:cell action:@selector(correctStatus)
  98. forControlEvents:UIControlEventTouchUpInside];
  99. cell.txtInStorageNo.delegate=cell;
  100. cell.txtCustomerCode.delegate=cell;
  101. [cell configureKeyboard];
  102. return cell;
  103. }
  104. /**
  105. 触摸事件
  106. @param touches <#touches description#>
  107. @param event <#event description#>
  108. */
  109. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  110. [self hideKey];
  111. [_txtCustomerCode resignFirstResponder];
  112. [_txtInStorageNo resignFirstResponder];
  113. }
  114. /**
  115. 长度
  116. @param textField <#textField description#>
  117. @param range <#range description#>
  118. @param string <#string description#>
  119. @return <#return value description#>
  120. */
  121. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  122. return YES;
  123. }
  124. /**
  125. 文本编辑结束事件
  126. @param textField <#textField description#>
  127. */
  128. - (void)textFieldDidEndEditing:(UITextField *)textField {
  129. [self updateModel];
  130. }
  131. /**
  132. 重置按钮 事件
  133. */
  134. - (void)resetData {
  135. [_txtInStorageNo setText:@""];
  136. [_txtCustomerCode setText:@""];
  137. [_btnStartDate setTitle:@"请选择开始账务日期" forState:UIControlStateNormal];
  138. _startDate = @"";
  139. [_btnEndDate setTitle:@"请选择结束账务日期" forState:UIControlStateNormal];
  140. _endDate = @"";
  141. [_btnSupplier setTitle:@"请选择供应商" forState:UIControlStateNormal];
  142. _supplierId=@"";
  143. [_btnDepartment setTitle:@"请选择业务部门" forState:UIControlStateNormal];
  144. [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
  145. _staffId=@"";
  146. _organizationCode=@"";
  147. _btnApprovePass.tag=0;
  148. _btnCorrect.tag=0;
  149. [_invoiceStatus setString:@""];
  150. }
  151. #pragma mark 私有函数
  152. /**
  153. 供应商点击函数
  154. @param sender <#sender description#>
  155. */
  156. - (IBAction)supplierClickAction:(id)sender {
  157. CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
  158. tc.delegate=self;
  159. tc.isPresentViewFlag=YES;
  160. tc.showDialogViewTag=ReportSupplier;
  161. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  162. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  163. }
  164. }
  165. /**
  166. 键盘配置
  167. */
  168. - (void)configureKeyboard {
  169. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  170. _txtInStorageNo.inputAccessoryView = keyBoardAccessoryView;
  171. _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
  172. }
  173. /**
  174. 文本编辑时候 弹出取消完成按钮
  175. @return <#return value description#>
  176. */
  177. - (UIView *)createKeyBoardAccessoryView {
  178. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  179. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  180. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  181. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  182. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  183. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  184. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  185. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  186. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  187. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  188. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  189. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  190. [keyBoardAccessoryView addSubview:backButton];
  191. [keyBoardAccessoryView addSubview:doneButton];
  192. return keyBoardAccessoryView;
  193. }
  194. /**
  195. * 隐藏键盘
  196. */
  197. -(void)hideKey
  198. {
  199. [self.contentView endEditing:YES];
  200. }
  201. /**
  202. 取消文本
  203. */
  204. - (void)accessoryButtonBack {
  205. [self hideKey];}
  206. /**
  207. 确定文本
  208. */
  209. - (void)accessoryButtonDone {
  210. [_txtCustomerCode resignFirstResponder];
  211. [_txtInStorageNo resignFirstResponder];
  212. [self hideKey];
  213. }
  214. /**
  215. 更新model
  216. */
  217. - (void)updateModel{
  218. OtherInStorageSearchModel *model = [[OtherInStorageSearchModel alloc] init];
  219. NSString *inStorageNoStr=[_txtInStorageNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  220. model.inStorageNo =inStorageNoStr;
  221. NSString *customerCodeStr=@"";
  222. customerCodeStr= [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  223. model.customerCode =customerCodeStr;
  224. NSString *startDateStr=@"";
  225. startDateStr=_btnStartDate.currentTitle;
  226. if([startDateStr isEqualToString:@"请选择开始账务日期"]){
  227. startDateStr=@"";
  228. }
  229. model.startDate =startDateStr ;
  230. NSString *endDateStr =@"";
  231. endDateStr=_btnEndDate.currentTitle;
  232. if([endDateStr isEqualToString:@"请选择结束账务日期"]){
  233. endDateStr=@"";
  234. }
  235. model.endDate=endDateStr;
  236. model.supplierId=_supplierId;
  237. model.organizationCode=_organizationCode;
  238. model.staffId=_staffId;
  239. _invoiceStatus=[[NSMutableString alloc] init];
  240. if(_btnApprovePass.tag==1 ){
  241. [_invoiceStatus appendString:@"3,"];
  242. }
  243. if(_btnCorrect.tag==1){
  244. [_invoiceStatus appendString:@"10,"];
  245. }
  246. if(_invoiceStatus.length>0){
  247. [_invoiceStatus deleteCharactersInRange:NSMakeRange(_invoiceStatus.length-1, 1)];
  248. }
  249. model.invoiceStatus=_invoiceStatus;
  250. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  251. [mutDict setValue:model forKey:SALES_IN_STORAGE_SEARCH_RANGE_MODEL];
  252. _regionModel.customDict = [mutDict copy];
  253. }
  254. /**
  255. 点击开始日期事件
  256. @param sender <#sender description#>
  257. */
  258. - (IBAction)startDateClickAction:(id)sender {
  259. __weak typeof(self) weakself=self;
  260. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  261. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  262. _tempStartDate=date;
  263. } andCompletionBlock:^(void){
  264. weakself.startDate = _tempStartDate;
  265. [weakself.btnStartDate setTitle:weakself.startDate forState:UIControlStateNormal];
  266. [self updateModel];
  267. } andCancelBlock:^(void){
  268. }];
  269. [_dealDatePicker show];
  270. }
  271. /**
  272. 点击结束日期事件
  273. @param sender <#sender description#>
  274. */
  275. - (IBAction)endDateClickAction:(id)sender {
  276. __weak typeof(self) weakself=self;
  277. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  278. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  279. _tempEndDate=date;
  280. } andCompletionBlock:^(void){
  281. weakself.endDate = _tempEndDate;
  282. [weakself.btnEndDate setTitle:weakself.endDate forState:UIControlStateNormal];
  283. [self updateModel];
  284. } andCancelBlock:^(void){
  285. }];
  286. [_dealDatePicker show];
  287. }
  288. /**
  289. 业务部门点击事件
  290. @param sender <#sender description#>
  291. */
  292. - (IBAction)departmentClickAction:(id)sender {
  293. CustomerAchievementTextVC *tc=[[CustomerAchievementTextVC alloc ]init];
  294. tc.cDelegate = self;
  295. tc.isPresentViewFlag = YES;
  296. tc.showDialogViewTag=ReportAchiementDepartmt;
  297. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  298. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  299. }
  300. }
  301. /**
  302. 业务员点击事件
  303. @param sender <#sender description#>
  304. */
  305. - (IBAction)staffClickAction:(id)sender {
  306. CustomerAchievementTextVC *tc=[[CustomerAchievementTextVC alloc ]init];
  307. tc.cDelegate = self;
  308. tc.isPresentViewFlag = YES;
  309. tc.showDialogViewTag=ReportAchiementmn;
  310. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  311. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  312. }
  313. }
  314. /**
  315. 审批状态切换函数
  316. */
  317. - (void)distinguish:(UIButton *) btn{
  318. switch (btn.tag) {
  319. case 0:
  320. btn.tag = 1;
  321. btn.layer.borderColor = [[UIColor redColor] CGColor];
  322. [btn setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
  323. break;
  324. case 1:
  325. btn.tag = 0;
  326. btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  327. [btn setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
  328. break;
  329. default:
  330. break;
  331. }
  332. [self updateModel];
  333. }
  334. /**
  335. 审批通过点击函数
  336. */
  337. -(void)approveStatus{
  338. [self distinguish:_btnApprovePass];
  339. }
  340. /**
  341. 冲正点击函数
  342. */
  343. -(void)correctStatus{
  344. [self distinguish:_btnCorrect];
  345. }
  346. @end