SingleProfitSearchCell.m 9.8 KB

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