| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- //
- // SingleProfitSearchCell.m
- // IBOSSmini
- //
- // Created by apple on 2017/5/19.
- // Copyright © 2017年 elongtian. All rights reserved.
- //
- #import "SingleProfitSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SingleProfitSearchModel.h"
- #import "SideSlipConfig.h"
- #import "CustomerAchievementTextVC.h"
- #import "BRDatePickerView.h"
- @interface SingleProfitSearchCell () <UITextFieldDelegate,CustomerReportTextProtocol>
- @property (strong, nonatomic) SideSlipModel *regionModel;
- @property (strong,nonatomic) BRDatePickerView *dealDatePicker;
- @property (copy, nonatomic) NSString *tempStartDate;
- @property (copy, nonatomic) NSString *tempEndDate;
- @property (copy, nonatomic) NSString *mBusinessType;
- @property (weak, nonatomic) IBOutlet UIButton *btnSaleSlip;
- @property (weak, nonatomic) IBOutlet UIButton *btnSaleOrder;
- @end
- @implementation SingleProfitSearchCell
- /**
- 高度
-
- @return <#return value description#>
- */
- - (CGFloat)cellHeight {
- return 543.5;
- }
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- SingleProfitSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"SingleProfitSearchCell" owner:nil options:nil][0];
- cell.txtCustomerName.delegate = cell;
- cell.txtCustomerCode.delegate=cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- awakeFromNib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- Identifier
-
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
-
- return @"SearchTableViewCell";
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- _btnSaleSlip.layer.borderColor=[[UIColor redColor] CGColor];
- _btnSaleOrder.layer.borderColor=[[UIColor grayColor] CGColor];
- _mBusinessType = @"7";
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerCode.inputAccessoryView=keyBoardAccessoryView;
- }
- /**
- 更新model
- 关宏厚2017-7-6
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- NSString *startDateStr=[DateFormat getDateBefore:31];
- NSString *endDateStr=[DateFormat getCurrentDate];
- [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal];
- _sStartDate= _btnStartDate.titleLabel.text;
- [_btnEndDate setTitle:endDateStr forState:UIControlStateNormal];
- _sEndDate =_btnEndDate.titleLabel.text;
- [self updateModel];
- }
- /**
- 更新frame
-
- @param w <#w description#>
- */
- - (void)updateFrame:(CGFloat)w{
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
-
- [_txtCustomerName setText:@""];
- [_txtCustomerCode setText:@""];
- [_btnOrg setTitle:@"请选择业务部门" forState:UIControlStateNormal];
- _sOrg = @"";
- [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
- _sStaff = @"";
- [_btnStartDate setTitle:@"请选择账务开始日期" forState:UIControlStateNormal];
- _sStartDate = @"";
- [_btnEndDate setTitle:@"请选择账务结束日期" forState:UIControlStateNormal];
- _sEndDate = @"";
- }
- /**
- 文本编辑时候 弹出取消完成按钮
-
- @return <#return value description#>
- */
- - (UIView *)createKeyBoardAccessoryView {
- UIView *keyBoardAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, ACCESSORY_VIEW_HEIGHT)];
- [keyBoardAccessoryView setBackgroundColor:[UIColor hexColor:@"e1e1e1"]];
- UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(ACCESSORY_BUTTON_LEADING_TRAILING, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
- [backButton setTitle:@"取消" forState:UIControlStateNormal];
- [backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
- [backButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [backButton addTarget:self action:@selector(accessoryButtonBack) forControlEvents:UIControlEventTouchUpInside];
- UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - ACCESSORY_BUTTON_LEADING_TRAILING - ACCESSORY_BUTTON_WIDTH, 0, ACCESSORY_BUTTON_WIDTH, ACCESSORY_VIEW_HEIGHT)];
- [doneButton setTitle:@"完成" forState:UIControlStateNormal];
- [doneButton setTitleColor:[UIColor hexColor:FILTER_RED_STRING] forState:UIControlStateNormal];
- [doneButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [doneButton addTarget:self action:@selector(accessoryButtonDone) forControlEvents:UIControlEventTouchUpInside];
- [keyBoardAccessoryView addSubview:backButton];
- [keyBoardAccessoryView addSubview:doneButton];
- return keyBoardAccessoryView;
- }
- /**
- 文本编辑结束事件
-
- @param textField <#textField description#>
- */
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- [self updateModel];
- }
- /**
- 触摸事件
-
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_txtCustomerName resignFirstResponder];
- [_txtCustomerCode resignFirstResponder];
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
- NSLog(@"accessoryButtonBack");
- [self hideKey];}
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- NSLog(@"accessoryButtonDone");
- [_txtCustomerName resignFirstResponder];
- [_txtCustomerCode resignFirstResponder];
- [self hideKey];
- }
- /**
- 业务员 业务部门
-
- @param Amodel <#Amodel description#>
- @param cr <#cr description#>
- */
- -(void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
-
- //返回值
- if(cr== ReportAchiementDepartmt){
- _sOrg=Amodel.organizationCode;
- [self.btnOrg setTitle:Amodel.organizationName forState:UIControlStateNormal];
- }
- // 业务员
- if(cr==ReportAchiementmn){
- _sStaff = Amodel.staffName;
- [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
- }
-
- [self updateModel];
- }
- /**
- * 隐藏键盘
- */
- -(void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 组织机构
-
- @param sender <#sender description#>
- */
- - (IBAction)showOrg:(id)sender {
- CustomerAchievementTextVC *tc=[[CustomerAchievementTextVC alloc ]init];
- tc.cDelegate = self;
- tc.isPresentViewFlag = YES;
- tc.showDialogViewTag=ReportAchiementDepartmt;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
-
- }
- /**
- 业务员
-
- @param sender <#sender description#>
- */
- - (IBAction)showStaff:(id)sender {
- CustomerAchievementTextVC *tc=[[CustomerAchievementTextVC alloc ]init];
- tc.cDelegate = self;
- tc.isPresentViewFlag = YES;
- tc.showDialogViewTag=ReportAchiementmn;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
-
- }
- /**
- 账务开始日期
-
- @param sender <#sender description#>
- */
- - (IBAction)showStaDate:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempStartDate=date;
- } andCompletionBlock:^(void){
- weakself.sStartDate = _tempStartDate;
- [weakself.btnStartDate setTitle:weakself.sStartDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
-
- }
- /**
- 账务结束日期
-
- @param sender <#sender description#>
- */
- - (IBAction)showEndDate:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempEndDate=date;
- } andCompletionBlock:^(void){
- weakself.sEndDate = _tempEndDate;
- [weakself.btnEndDate setTitle:weakself.sEndDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- - (IBAction)clickSaleSlip:(id)sender {
- if([_mBusinessType intValue] == 6){
- _mBusinessType = @"7";
- _btnSaleSlip.layer.borderColor=[[UIColor redColor] CGColor];
- [_btnSaleSlip setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; _btnSaleOrder.layer.borderColor=[[UIColor grayColor] CGColor];
- [_btnSaleOrder setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
- [self updateModel];
- }
- }
- - (IBAction)clickSalesOrder:(id)sender {
- if([_mBusinessType intValue] == 7){
- _mBusinessType = @"6";
- _btnSaleSlip.layer.borderColor=[[UIColor grayColor] CGColor];
- [_btnSaleSlip setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
-
- _btnSaleOrder.layer.borderColor=[[UIColor redColor] CGColor];
- [_btnSaleOrder setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
-
- [self updateModel];
- }
- }
- /**
- 更新model
- */
- - (void)updateModel{
- SingleProfitSearchModel *model = [[SingleProfitSearchModel alloc] init];
- model.sCustomerName = [_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.sCustomerCode=[_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.sBusinessType = _mBusinessType;
- model.sOrg = _sOrg;
- model.sStaff = _sStaff;
- model.sStartDate = _sStartDate;
- model.sEndDate = _sEndDate;
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:SINGLE_PROFIT_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- @end
|