OrderSalesSearchTableViewCell.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. //
  2. // OrderSalesSearchTableViewCell.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2017/5/26.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:订单销售单查询单元格
  9. //
  10. #import "OrderSalesSearchTableViewCell.h"
  11. #import "StatusInfoTextVC.h"
  12. #import "StatusInfo.h"
  13. #import "UIColor+hexColor.h"
  14. #import "SideSlipConfig.h"
  15. @implementation OrderSalesSearchTableViewCell
  16. /**
  17. awakeFromNib
  18. */
  19. - (void)awakeFromNib {
  20. [super awakeFromNib];
  21. }
  22. /**
  23. 单据类型
  24. @param sender <#sender description#>
  25. */
  26. - (IBAction)selectInvoiceType:(id)sender {
  27. [self initStatus];
  28. StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init];
  29. tc.sdelegate=self;
  30. tc.isPresentViewFlag=YES;
  31. [tc.arrFilter addObjectsFromArray: _arrayStatus];
  32. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  33. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  34. }
  35. }
  36. - (IBAction)departmentClickAction:(id)sender {
  37. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  38. tc.cDelegate = self;
  39. tc.flag = YES;
  40. tc.isPresentViewFlag = YES;
  41. tc.showDialogViewTag=ReportAchiementDepartmt;
  42. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  43. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  44. }
  45. }
  46. /**
  47. 新增业务员选择(2019-05-21)
  48. @param sender
  49. */
  50. - (IBAction)salesmanClickAction:(id)sender {
  51. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  52. tc.cDelegate = self;
  53. tc.isPresentViewFlag = YES;
  54. tc.showDialogViewTag=ReportAchiementmn;
  55. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  56. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  57. }
  58. }
  59. #pragma mark -- 委托事件
  60. /**
  61. 回调状态
  62. @param s <#s description#>
  63. */
  64. - (void)showStatusValue:(StatusInfo *)s{
  65. NSString *statusId=s.statusId;
  66. [_btnInvoiceType setTitle:s.name forState:UIControlStateNormal];
  67. [_searchModel setInvoiceTypeId:statusId];
  68. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  69. _slideModel.customDict =_mutDict;
  70. }
  71. /**
  72. 单据类型数据源
  73. */
  74. - (void)initStatus{
  75. _arrayStatus = [[NSMutableArray alloc]init];
  76. StatusInfo* s = [[StatusInfo alloc]init];
  77. s.statusId = @"0";
  78. s.name = @"全部";
  79. [_arrayStatus addObject:s];
  80. s = [[StatusInfo alloc]init];
  81. s.statusId = @"1";
  82. s.name = @"订单";
  83. [_arrayStatus addObject:s];
  84. s = [[StatusInfo alloc]init];
  85. s.statusId = @"2";
  86. s.name = @"销售单";
  87. [_arrayStatus addObject:s];
  88. s = [[StatusInfo alloc]init];
  89. s.statusId = @"3";
  90. s.name = @"销售单(包含转单)";
  91. [_arrayStatus addObject:s];
  92. }
  93. /**
  94. 开始日期
  95. @param sender <#sender description#>
  96. */
  97. - (IBAction)selectStartDate:(id)sender {
  98. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  99. [_brdatePicker configureSelectionBlock:^(NSString *date){
  100. _startDate=date;
  101. } andCompletionBlock:^(void){
  102. [_searchModel setStartDate:_startDate];
  103. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  104. _slideModel.customDict =_mutDict;
  105. [_btnStartDate setTitle:_startDate forState:UIControlStateNormal];
  106. } andCancelBlock:^(void){
  107. _startDate=_btnStartDate.titleLabel.text;
  108. }];
  109. [_brdatePicker show];
  110. }
  111. /**
  112. 结束日期
  113. @param sender <#sender description#>
  114. */
  115. - (IBAction)selectEndDate:(id)sender {
  116. _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  117. [_brdatePicker configureSelectionBlock:^(NSString *date){
  118. _endDate=date;
  119. } andCompletionBlock:^(void){
  120. [_searchModel setEndDate:_endDate];
  121. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  122. _slideModel.customDict = _mutDict;
  123. [_btnEndDate setTitle:_endDate forState:UIControlStateNormal];
  124. } andCancelBlock:^(void){
  125. _endDate=_btnEndDate.titleLabel.text;
  126. }];
  127. [_brdatePicker show];
  128. }
  129. /**
  130. 过滤冲正数据
  131. @param sender <#sender description#>
  132. */
  133. - (IBAction)changeCorrectStatus:(id)sender {
  134. if([_searchModel.correctStatus isEqualToString:@"1"]){
  135. _searchModel.correctStatus = @"0";
  136. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  137. _slideModel.customDict = _mutDict;
  138. [_btnFilter setTitle:@"未过滤" forState:UIControlStateNormal];
  139. [ _btnFilter setTitleColor:[UIColor colorWithRed:128/255 green:128/255 blue:128/255 alpha:1] forState:UIControlStateNormal];
  140. _btnFilter.layer.borderColor = [UIColor lightGrayColor].CGColor;
  141. }
  142. else{
  143. _searchModel.correctStatus = @"1";
  144. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  145. _slideModel.customDict = _mutDict;
  146. [_btnFilter setTitle:@"已过滤" forState:UIControlStateNormal];
  147. [ _btnFilter setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  148. _btnFilter.layer.borderColor = [UIColor redColor].CGColor;
  149. }
  150. }
  151. /**
  152. cell
  153. @param indexPath <#indexPath description#>
  154. @return <#return value description#>
  155. */
  156. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  157. OrderSalesSearchTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"OrderSalesSearchTableViewCell" owner:nil options:nil][0];
  158. cell.txtCustomerName.delegate = cell;
  159. cell.txtContactTelephone.delegate=cell;
  160. cell.txtCustomerAddress.delegate=cell;
  161. cell.btnFilter.layer.borderColor = [UIColor redColor].CGColor;
  162. [cell.btnFilter setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  163. cell.btnFilter.layer.borderWidth=1;
  164. [cell configureKeyboard];
  165. return cell;
  166. }
  167. /**
  168. 键盘配置
  169. */
  170. - (void)configureKeyboard {
  171. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  172. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  173. _txtContactTelephone.inputAccessoryView = keyBoardAccessoryView;
  174. _txtCustomerAddress.inputAccessoryView=keyBoardAccessoryView;
  175. }
  176. /**
  177. 高度
  178. @return <#return value description#>
  179. */
  180. - (CGFloat)cellHeight {
  181. return 688.5f + 84.0f;
  182. }
  183. /**
  184. 文本框编辑
  185. @param textField <#textField description#>
  186. */
  187. - (void)textFieldDidEndEditing:(UITextField *)textField {
  188. _searchModel.customerName= [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  189. _searchModel.contactTelephone = [_txtContactTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  190. _searchModel.customerAddress=[_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  191. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  192. _slideModel.customDict = _mutDict;
  193. }
  194. /**
  195. <#Description#>
  196. 关宏厚 2017-7-6
  197. @param model <#model description#>
  198. @param indexPath <#indexPath description#>
  199. */
  200. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
  201. indexPath:(NSIndexPath *)indexPath {
  202. _slideModel=*model;
  203. _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict];
  204. _searchModel = [OrderSalesSearchModel new];
  205. _searchModel.correctStatus = @"1";
  206. _searchModel.departmentCode = _businessDepartmentCode;
  207. NSString *startDateStr= [DateFormat getDateBefore:31];
  208. NSString *endDataStr = [DateFormat getCurrentDate];
  209. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  210. _startDate= _btnStartDate.titleLabel.text;
  211. [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal];
  212. _endDate= _btnEndDate.titleLabel.text;
  213. _searchModel.startDate=_startDate;
  214. _searchModel.endDate=_endDate;
  215. _searchModel.staffId = _staffId;
  216. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  217. _slideModel.customDict = _mutDict;
  218. }
  219. + (NSString *)cellReuseIdentifier {
  220. return @"SearchTableViewCell";
  221. }
  222. /**
  223. 文本编辑时候 弹出取消完成按钮
  224. @return <#return value description#>
  225. */
  226. - (UIView *)createKeyBoardAccessoryView {
  227. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  228. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  229. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  230. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  231. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  232. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  233. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  234. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  235. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  236. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  237. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  238. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  239. [keyBoardAccessoryView addSubview:backButton];
  240. [keyBoardAccessoryView addSubview:doneButton];
  241. return keyBoardAccessoryView;
  242. }
  243. /**
  244. 校验文本
  245. @param textField <#textField description#>
  246. @param range <#range description#>
  247. @param string <#string description#>
  248. @return <#return value description#>
  249. */
  250. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  251. return YES;
  252. }
  253. /**
  254. 触摸事件
  255. @param touches <#touches description#>
  256. @param event <#event description#>
  257. */
  258. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  259. [self hideKey];
  260. [_txtCustomerName resignFirstResponder];
  261. [_txtContactTelephone resignFirstResponder];
  262. [_txtCustomerAddress resignFirstResponder];
  263. }
  264. /**
  265. 业务部门回调函数
  266. @param code <#code description#>
  267. @param name <#name description#>
  268. */
  269. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  270. //返回值
  271. if(cr == ReportAchiementDepartmt){
  272. _businessDepartmentCode = Amodel.organizationCode;
  273. [self.btnOrganization setTitle:Amodel.organizationName forState:UIControlStateNormal];
  274. [_searchModel setDepartmentCode:_businessDepartmentCode];
  275. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  276. _slideModel.customDict =_mutDict;
  277. }
  278. // 业务员
  279. if(cr == ReportAchiementmn){
  280. _staffId = Amodel.staffId;
  281. [self.btnSalesman setTitle:Amodel.staffName forState:UIControlStateNormal];
  282. [_searchModel setStaffId:_staffId];
  283. [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL];
  284. _slideModel.customDict =_mutDict;
  285. }
  286. }
  287. /**
  288. 取消文本
  289. */
  290. - (void)accessoryButtonBack {
  291. [self hideKey];}
  292. /**
  293. 确定文本
  294. */
  295. - (void)accessoryButtonDone {
  296. [_txtCustomerName resignFirstResponder];
  297. [_txtContactTelephone resignFirstResponder];
  298. [_txtCustomerAddress resignFirstResponder];
  299. [self hideKey];
  300. }
  301. /**
  302. * 隐藏键盘
  303. */
  304. - (void)hideKey
  305. {
  306. [self.contentView endEditing:YES];
  307. }
  308. @end