SingleProfitSearchCell.m 10 KB

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