CustomerCurrentAccountSummarySearchCell.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. //
  2. // CustomerCurrentAccountSummarySearchCell.m
  3. // IBOSS
  4. //
  5. // Created by 关宏厚 on 2021/2/24.
  6. // Copyright © 2021 elongtian. All rights reserved.
  7. //
  8. #import "CustomerCurrentAccountSummarySearchCell.h"
  9. @implementation CustomerCurrentAccountSummarySearchCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. }
  13. /**
  14. 高度
  15. @return return value description
  16. */
  17. - (CGFloat)cellHeight {
  18. return 782.0f;
  19. }
  20. /**
  21. Identifier
  22. @return <#return value description#>
  23. */
  24. + (NSString *)cellReuseIdentifier {
  25. return @"CustomerCurrentAccountSummarySearchCell";
  26. }
  27. /**
  28. 更新model
  29. @param model <#model description#>
  30. @param indexPath <#indexPath description#>
  31. */
  32. - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
  33. self.regionModel = *model;
  34. // 1. 创建一个点击事件,点击时触发labelClick方法
  35. UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
  36. // 2. 将点击事件添加到label上
  37. [self.lblFilterZeroAmount addGestureRecognizer:labelTapGestureRecognizer];
  38. self.lblFilterZeroAmount.userInteractionEnabled = YES; // 可以理解为设置label可被点击
  39. self.lblFilterZeroAmount.layer.borderWidth = 1;
  40. self.lblFilterZeroAmount.layer.borderColor = [UIColor redColor].CGColor;
  41. self.isFilterZeroAmount = YES;
  42. self.lblFilterZeroAmount.text = @"已过滤";
  43. self.lblFilterZeroAmount.textColor = [UIColor redColor];
  44. NSString *startDateStr = [DateFormat getCurrentDate];
  45. NSString *endDateStr = [DateFormat getCurrentDate];
  46. [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
  47. _sAccountStartDate= _btnStartDate.titleLabel.text;
  48. [_btnEndDate setTitle:endDateStr forState:UIControlStateNormal];
  49. _sAccountEndDate =_btnEndDate.titleLabel.text;
  50. [self updateModel];
  51. }
  52. /**
  53. 零库存过滤
  54. */
  55. - (void)labelClick{
  56. if (self.isFilterZeroAmount) {
  57. self.lblFilterZeroAmount.layer.borderColor = [UIColor lightGrayColor].CGColor;
  58. self.isFilterZeroAmount = NO;
  59. self.lblFilterZeroAmount.text = @"未过滤";
  60. self.lblFilterZeroAmount.textColor = [UIColor lightGrayColor];
  61. }else{
  62. self.lblFilterZeroAmount.layer.borderColor = [UIColor redColor].CGColor;
  63. self.isFilterZeroAmount = YES;
  64. self.lblFilterZeroAmount.text = @"已过滤";
  65. self.lblFilterZeroAmount.textColor = [UIColor redColor];
  66. }
  67. [self updateModel];
  68. }
  69. - (void)customerReportTextDoneDatas:(CustomerReportTextInfoModel *)model CustomerReport:(CustomerReport)cr{
  70. //渠道返回值
  71. if(cr == ReportCumstomerChannel){
  72. self.sChannelId=model.idCode;
  73. [self.btnChannel setTitle:model.name forState:UIControlStateNormal];
  74. [self.btnChannel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  75. }
  76. [self updateModel];
  77. }
  78. /**
  79. cell
  80. @param indexPath <#indexPath description#>
  81. @return <#return value description#>
  82. */
  83. + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
  84. CustomerCurrentAccountSummarySearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"CustomerCurrentAccountSummarySearchCell" owner:nil options:nil][0];
  85. cell.txtCustomerCode.delegate = cell;
  86. cell.txtCustomerName.delegate = cell;
  87. cell.txtTelephone.delegate = cell;
  88. cell.txtCustomerAddress.delegate=cell;
  89. [cell configureKeyboard];
  90. return cell;
  91. }
  92. /**
  93. 键盘配置
  94. */
  95. - (void)configureKeyboard {
  96. UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
  97. _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
  98. _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
  99. _txtTelephone.inputAccessoryView = keyBoardAccessoryView;
  100. _txtCustomerAddress.inputAccessoryView=keyBoardAccessoryView;
  101. }
  102. /**
  103. 文本编辑时候 弹出取消完成按钮
  104. @return <#return value description#>
  105. */
  106. - (UIView *)createKeyBoardAccessoryView {
  107. UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
  108. [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
  109. UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  110. [backButton setTitle:@"取消" forState:UIControlStateNormal];
  111. [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  112. [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  113. [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
  114. UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
  115. [doneButton setTitle:@"完成" forState:UIControlStateNormal];
  116. [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
  117. [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  118. [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
  119. [keyBoardAccessoryView addSubview:backButton];
  120. [keyBoardAccessoryView addSubview:doneButton];
  121. return keyBoardAccessoryView;
  122. }
  123. /**
  124. 长度
  125. @param textField <#textField description#>
  126. @param range <#range description#>
  127. @param string <#string description#>
  128. @return <#return value description#>
  129. */
  130. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  131. return YES;
  132. }
  133. /**
  134. * 隐藏键盘
  135. */
  136. - (void)hideKey
  137. {
  138. [self.contentView endEditing:YES];
  139. }
  140. /**
  141. 文本编辑结束事件
  142. @param textField <#textField description#>
  143. */
  144. - (void)textFieldDidEndEditing:(UITextField *)textField {
  145. [self updateModel];
  146. }
  147. /**
  148. 触摸事件
  149. @param touches <#touches description#>
  150. @param event <#event description#>
  151. */
  152. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  153. [self hideKey];
  154. [_txtCustomerCode resignFirstResponder];
  155. [_txtCustomerName resignFirstResponder];
  156. [_txtTelephone resignFirstResponder];
  157. [_txtCustomerAddress resignFirstResponder];
  158. }
  159. /**
  160. 取消文本
  161. */
  162. - (void)accessoryButtonBack {
  163. [self hideKey];}
  164. /**
  165. 确定文本
  166. */
  167. - (void)accessoryButtonDone {
  168. [_txtCustomerCode resignFirstResponder];
  169. [_txtCustomerName resignFirstResponder];
  170. [_txtTelephone resignFirstResponder];
  171. [_txtCustomerAddress resignFirstResponder];
  172. [self hideKey];
  173. }
  174. - (IBAction)clickDepartmentAction:(id)sender {
  175. CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
  176. tc.cDelegate = self;
  177. tc.isPresentViewFlag = YES;
  178. tc.flag = YES;
  179. tc.showDialogViewTag=ReportAchiementDepartmt;
  180. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  181. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  182. }
  183. }
  184. /**
  185. 业务员 业务部门
  186. @param Amodel <#Amodel description#>
  187. @param cr <#cr description#>
  188. */
  189. - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
  190. //返回值
  191. if(cr == ReportAchiementDepartmt){
  192. _organizationCode = Amodel.organizationCode;
  193. [self.btnDepartment setTitle:Amodel.organizationName forState:UIControlStateNormal];
  194. }
  195. [self updateModel];
  196. }
  197. - (IBAction)clickChannelAction:(id)sender {
  198. CustomerReportTextVC *tc = [[CustomerReportTextVC alloc] init];
  199. tc.delegate=self;
  200. tc.isPresentViewFlag=YES;
  201. tc.dataSourceCode = @"T_MST_Channel";
  202. tc.showDialogViewTag=ReportCumstomerChannel;
  203. if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
  204. [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
  205. }
  206. }
  207. - (IBAction)clickStartDateAction:(id)sender {
  208. __weak typeof(self) weakself=self;
  209. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  210. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  211. self->_tempAccountStartDate=date;
  212. } andCompletionBlock:^(void){
  213. weakself.sAccountStartDate = self->_tempAccountStartDate;
  214. [weakself.btnStartDate setTitle: weakself.sAccountStartDate forState:UIControlStateNormal];
  215. [self updateModel];
  216. } andCancelBlock:^(void){
  217. }];
  218. [_dealDatePicker show];
  219. }
  220. - (IBAction)clickEndDateAction:(id)sender {
  221. __weak typeof(self) weakself=self;
  222. _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
  223. [_dealDatePicker configureSelectionBlock:^(NSString *date){
  224. self->_tempAccountEndDate=date;
  225. } andCompletionBlock:^(void){
  226. weakself.sAccountEndDate = self->_tempAccountEndDate;
  227. [weakself.btnEndDate setTitle:weakself.sAccountEndDate forState:UIControlStateNormal];
  228. [self updateModel];
  229. }
  230. andCancelBlock:^(void){
  231. }];
  232. [_dealDatePicker show];
  233. }
  234. -(void)updateModel
  235. {
  236. CustomerCurrentSummarySearchModel *searchModel=[CustomerCurrentSummarySearchModel new];
  237. searchModel.organizationCode=_organizationCode;
  238. searchModel.channelId=_sChannelId;
  239. searchModel.startDate=_sAccountStartDate;
  240. searchModel.endDate=_sAccountEndDate;
  241. searchModel.customerCode=[_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  242. searchModel.customerName=[_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  243. searchModel.customerTelephone=[_txtTelephone.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  244. searchModel.customerAddress=[_txtCustomerAddress.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  245. searchModel.isFilterZeroAmount=_isFilterZeroAmount;
  246. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
  247. [mutDict setValue:searchModel forKey:CUSTOMER_CURRENT_SUMMARY_SEARCH_MODEL];
  248. _regionModel.customDict = [mutDict copy];
  249. }
  250. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  251. [super setSelected:selected animated:animated];
  252. }
  253. @end