CustomerBalanceSearchCell.m 9.3 KB

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