CustomerBalanceSearchCell.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. //
  2. // CustomerBalanceSearchCell.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/5/24.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:客户往来余额查询条件单元格
  9. //
  10. #import "CustomerBalanceSearchCell.h"
  11. #import "UIColor+hexColor.h"
  12. #import "CustomerBalanceSearchModel.h"
  13. #import "SideSlipConfig.h"
  14. #import "CustomerAchievementTextVC.h"
  15. #import "BaseIDAndNameViewController.h"
  16. @interface CustomerBalanceSearchCell()<CustomerReportTextProtocol,BaseIDAndNameProtocol,UITextFieldDelegate>
  17. /**
  18. 抽屉对象model
  19. */
  20. @property (strong,nonatomic) SideSlipModel *regionModel;
  21. @end
  22. @implementation CustomerBalanceSearchCell
  23. /**
  24. 高度
  25. @return <#return value description#>
  26. */
  27. - (CGFloat)cellHeight {
  28. return 705.0f;
  29. }
  30. /**
  31. cell
  32. @param indexPath <#indexPath description#>
  33. @return <#return value description#>
  34. */
  35. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  36. CustomerBalanceSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"CustomerBalanceSearchCell" owner:nil options:nil][0];
  37. cell.txtCustomerAddress.delegate = cell;
  38. cell.txtCustomerCode.delegate=cell;
  39. cell.txtCustomerName.delegate=cell;
  40. cell.txtSecondaryStaff.delegate=cell;
  41. [cell configureKeyboard];
  42. return cell;
  43. }
  44. /**
  45. awakeFromNib
  46. */
  47. - (void)awakeFromNib {
  48. [super awakeFromNib];
  49. }
  50. /**
  51. Identifier
  52. @return <#return value description#>
  53. */
  54. + (NSString *)cellReuseIdentifier {
  55. return @"CustomerBalanceSearchCell";
  56. }
  57. /**
  58. 更新model
  59. @param model <#model description#>
  60. @param indexPath <#indexPath description#>
  61. */
  62. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  63. self.regionModel = *model;
  64. _btnFilter.tag = 0;
  65. [_btnFilter setTitle:@"不过滤" forState:UIControlStateNormal];
  66. _btnFilter.layer.borderWidth = 1;
  67. _btnFilter.layer.borderColor = [UIColor lightGrayColor].CGColor;
  68. [_btnFilter setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
  69. [self updateModel];
  70. }
  71. - (IBAction)clickFilterAction:(id)sender {
  72. switch (_btnFilter.tag) {
  73. case 0:
  74. _btnFilter.tag = 1;
  75. _btnFilter.layer.borderColor = [[UIColor redColor] CGColor];
  76. _btnFilter.layer.borderWidth = 1;
  77. [_btnFilter setTitle:@"过滤" forState:UIControlStateNormal];
  78. [_btnFilter setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
  79. break;
  80. case 1:
  81. _btnFilter.tag = 0;
  82. _btnFilter.layer.borderWidth = 1;
  83. _btnFilter.layer.borderColor = [UIColor lightGrayColor].CGColor;
  84. [_btnFilter setTitle:@"不过滤" forState:UIControlStateNormal];
  85. [_btnFilter setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
  86. break;
  87. default:
  88. break;
  89. }
  90. [self updateModel];
  91. }
  92. /**
  93. 重置按钮 事件
  94. */
  95. - (void)resetData {
  96. [_btnOrg setTitle:@"请选择业务部门" forState:UIControlStateNormal];
  97. _sOrg = @"";
  98. [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
  99. _sStaff = @"";
  100. [_btnSummaryType setTitle:@"请选择汇总类型" forState:UIControlStateNormal];
  101. _sSummaryType = @"";
  102. [_txtCustomerCode setText:@""];
  103. [_txtSecondaryStaff setText:@""];
  104. [_txtCustomerAddress setText:@""];
  105. [_txtCustomerName setText:@""];
  106. }
  107. /**
  108. 键盘配置
  109. */
  110. - (void)configureKeyboard {
  111. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  112. _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
  113. _txtCustomerAddress.inputAccessoryView = keyBoardAccessoryView;
  114. _txtCustomerName.inputAccessoryView=keyBoardAccessoryView;
  115. _txtSecondaryStaff.inputAccessoryView=keyBoardAccessoryView;
  116. }
  117. /**
  118. 长度
  119. @param textField <#textField description#>
  120. @param range <#range description#>
  121. @param string <#string description#>
  122. @return <#return value description#>
  123. */
  124. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  125. return YES;
  126. }
  127. /**
  128. 文本编辑结束事件
  129. @param textField <#textField description#>
  130. */
  131. - (void)textFieldDidEndEditing:(UITextField *)textField {
  132. [self updateModel];
  133. }
  134. /**
  135. 触摸事件
  136. @param touches <#touches description#>
  137. @param event <#event description#>
  138. */
  139. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  140. [self hideKey];
  141. [_txtCustomerCode resignFirstResponder];
  142. [_txtCustomerAddress resignFirstResponder];
  143. [_txtCustomerName resignFirstResponder];
  144. [_txtSecondaryStaff resignFirstResponder];
  145. }
  146. /**
  147. 文本编辑时候 弹出取消完成按钮
  148. @return <#return value description#>
  149. */
  150. - (UIView *)createKeyBoardAccessoryView {
  151. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  152. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  153. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  154. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  155. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  156. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  157. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  158. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  159. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  160. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  161. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  162. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  163. [keyBoardAccessoryView addSubview:backButton];
  164. [keyBoardAccessoryView addSubview:doneButton];
  165. return keyBoardAccessoryView;
  166. }
  167. /**
  168. 取消文本
  169. */
  170. - (void)accessoryButtonBack {
  171. [self hideKey];}
  172. /**
  173. 确定文本
  174. */
  175. - (void)accessoryButtonDone {
  176. [self hideKey];
  177. }
  178. /**
  179. 汇总类型
  180. @param model <#model description#>
  181. @param value <#value description#>
  182. */
  183. - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)model BaseIDAndName:(baseIdAndName)value{
  184. //返回值
  185. if(value == baseIdAndNameSummaryType){
  186. _sSummaryType=model.id;
  187. [self.btnSummaryType setTitle:model.name forState:UIControlStateNormal];
  188. }
  189. [self updateModel];
  190. }
  191. /**
  192. 业务员 业务部门
  193. @param Amodel <#Amodel description#>
  194. @param cr <#cr description#>
  195. */
  196. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  197. //返回值
  198. if(cr == ReportAchiementDepartmt){
  199. _sOrg=Amodel.organizationId;
  200. [self.btnOrg setTitle:Amodel.organizationName forState:UIControlStateNormal];
  201. }
  202. // 业务员
  203. if(cr == ReportAchiementmn){
  204. _sStaff = Amodel.staffId;
  205. [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
  206. }
  207. [self updateModel];
  208. }
  209. /**
  210. * 隐藏键盘
  211. */
  212. - (void)hideKey
  213. {
  214. [self.contentView endEditing:YES];
  215. }
  216. /**
  217. 组织机构
  218. @param sender <#sender description#>
  219. */
  220. - (IBAction)showOrg:(id)sender {
  221. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  222. tc.cDelegate = self;
  223. tc.flag = NO;
  224. tc.isPresentViewFlag = YES;
  225. tc.showDialogViewTag=ReportAchiementDepartmt;
  226. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  227. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  228. }
  229. }
  230. /**
  231. 业务员
  232. @param sender <#sender description#>
  233. */
  234. - (IBAction)showStaff:(id)sender {
  235. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  236. tc.cDelegate = self;
  237. tc.isPresentViewFlag = YES;
  238. tc.showDialogViewTag=ReportAchiementmn;
  239. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  240. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  241. }
  242. }
  243. /**
  244. 汇总类型
  245. @param sender <#sender description#>
  246. */
  247. - (IBAction)showSummaryType:(id)sender {
  248. BaseIDAndNameViewController *tc = [[BaseIDAndNameViewController alloc ]init];
  249. tc.bDelegate = self;
  250. tc.isPresentViewFlg = YES;
  251. NSMutableArray *arr = [[NSMutableArray alloc]init];
  252. BaseIDAndNameModel *m = [[BaseIDAndNameModel alloc ] init];
  253. m.id = @"1";
  254. m.name = @"客户编码";
  255. [arr addObject:m];
  256. m = [[BaseIDAndNameModel alloc ] init];
  257. m.id = @"2";
  258. m.name = @"业务部门";
  259. [arr addObject:m];
  260. m = [[BaseIDAndNameModel alloc ] init];
  261. m.id = @"3";
  262. m.name = @"业务员";
  263. [arr addObject:m];
  264. tc.arrFilter = arr;
  265. tc.arrSearch = arr;
  266. tc.showDialogViewTag = baseIdAndNameSummaryType;
  267. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  268. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  269. }
  270. }
  271. /**
  272. 更新model
  273. */
  274. - (void)updateModel{
  275. CustomerBalanceSearchModel *model = [[CustomerBalanceSearchModel alloc] init];
  276. model.sOrg = _sOrg;
  277. model.sStaff = _sStaff;
  278. model.sSummaryType = _sSummaryType;
  279. if(_btnFilter.tag == 0){
  280. model.filter = @"";
  281. }else{
  282. model.filter = @"true";
  283. }
  284. model.sCustomerCode = [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  285. model.sCustomerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  286. model.sCustomerAddress=[_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  287. model.sSecondaryStaff=[_txtSecondaryStaff.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  288. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  289. [mutDict setValue:model forKey:CUSTOMER_BALANCE_SEARCH_RANGE_MODEL];
  290. _regionModel.customDict = [mutDict copy];
  291. }
  292. @end