// // AveragePriceMonitorSearchCellTableViewCell.m // IBOSS // // Created by guan hong hou on 2017/9/7. // Copyright © 2017年 elongtian. All rights reserved. // // 功能描述:均价监控搜索cell #import "AveragePriceMonitorSearchCellTableViewCell.h" #import "BusinessDepartmentTreeViewController.h" #import "GoodsKindViewController.h" #import "DateFormat.h" #import "StatusInfo.h" #import "StatusInfoTextVC.h" @implementation AveragePriceMonitorSearchCellTableViewCell static AveragePriceMonitorSearchCellTableViewCell *searchCell; #pragma 公有函数 /** 加载xib */ - (void)awakeFromNib { [super awakeFromNib]; } /** 单据类型数据源 */ - (void)initStatus{ _arrayStatus = [[NSMutableArray alloc]init]; StatusInfo* s = [[StatusInfo alloc]init]; s = [[StatusInfo alloc]init]; s.statusId = @"1"; s.name = @"订单"; [_arrayStatus addObject:s]; s = [[StatusInfo alloc]init]; s.statusId = @"2"; s.name = @"销售单"; [_arrayStatus addObject:s]; } #pragma 委托函数 /** 单元格高度 @return <#return value description#> */ - (CGFloat)cellHeight { return 280.0f; } /** 加载tableviewcell @param indexPath <#indexPath description#> @return <#return value description#> */ + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath { AveragePriceMonitorSearchCellTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"AveragePriceMonitorSearchCellTableViewCell" owner:nil options:nil][0]; searchCell = cell; return cell; } /** 初始化cell数据 @param model <#model description#> @param indexPath <#indexPath description#> */ - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath { _slideModel = *model; _searchModel=[[AveragePriceMonitorSearchModel alloc]init]; NSString *startDateStr= [DateFormat getDateBefore:31]; NSString *endDataStr = [DateFormat getCurrentDate]; [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal]; _startDate= _btnStartDate.titleLabel.text; [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal]; _endDate= _btnEndDate.titleLabel.text; _searchModel.startDate=_startDate; _searchModel.endDate=_endDate; UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)]; UITapGestureRecognizer *toSalesTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toSalesClick)]; [self.lblIncludeGift addGestureRecognizer:labelTapGestureRecognizer]; self.isIncludeGift =@"0"; self.lblIncludeGift.text = @"不包含"; self.lblIncludeGift.userInteractionEnabled = YES; self.lblIncludeGift.layer.borderColor = [UIColor lightGrayColor].CGColor; self.lblIncludeGift.layer.borderWidth =1; _searchModel.invoiceType=@"1"; [self.lblOrderToSales addGestureRecognizer:toSalesTapGestureRecognizer]; self.isIncludeOrderToSales =@"0"; self.lblOrderToSales.text = @"不包含"; self.lblOrderToSales.userInteractionEnabled = YES; self.lblOrderToSales.layer.borderColor = [UIColor lightGrayColor].CGColor; self.lblOrderToSales.layer.borderWidth =1; _searchModel.isIncludeOrderToSales=@"0"; [self.btnInvoiceType setTitle:@"订单" forState:UIControlStateNormal]; _searchModel.giftFlag=_isIncludeGift; _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 重置按钮 事件 */ - (void)resetData { [_btnBusinessDepartment setTitle:@"请选择业务部门" forState:UIControlStateNormal]; _searchModel.businessDepartmentCode=@""; [_btnGoodsType setTitle:@"请选择商品种类" forState:UIControlStateNormal]; _searchModel.goodsType=@""; NSString *startDateStr= [DateFormat getDateBefore:31]; NSString *endDataStr = [DateFormat getCurrentDate]; [_btnStartDate setTitle:startDateStr forState:UIControlStateNormal]; _startDate= _btnStartDate.titleLabel.text; [_btnEndDate setTitle:endDataStr forState:UIControlStateNormal]; self.isIncludeGift =@"0"; self.lblIncludeGift.text = @"不包含"; self.lblIncludeGift.layer.borderColor = [UIColor lightGrayColor].CGColor; self.lblIncludeGift.layer.borderWidth =1; _searchModel.giftFlag=_isIncludeGift; _searchModel.invoiceType=@"1"; [self.btnInvoiceType setTitle:@"订单" forState:UIControlStateNormal]; self.isIncludeOrderToSales =@"0"; self.lblOrderToSales.text = @"不包含"; self.lblOrderToSales.userInteractionEnabled =YES; self.lblOrderToSales.layer.borderColor = [UIColor lightGrayColor].CGColor; self.lblOrderToSales.layer.borderWidth =1; _searchModel.isIncludeOrderToSales=@"0"; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 返回tableviewcell标识 @return <#return value description#> */ + (NSString *)cellReuseIdentifier { return @"SearchTableViewCell"; } /** 业务部门回调函数 @param code <#code description#> @param name <#name description#> */ -(void)achievementDataTreeResult:(NSString *)code name:(NSString*)name{ [self.btnBusinessDepartment setTitle:name forState:UIControlStateNormal]; _searchModel.businessDepartmentCode=code; _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 产品种类回调函数 @param id <#id description#> @param name <#name description#> */ -(void)kindDataTreeResult:(NSString *)id name:(NSString*)name{ [self.btnGoodsType setTitle:name forState:UIControlStateNormal]; _searchModel.goodsType=id; _mutDict = [NSMutableDictionary dictionaryWithDictionary:_slideModel.customDict]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 单据类型回调 @param s <#s description#> */ - (void)showStatusValue:(StatusInfo *)s{ NSString *statusId=s.statusId; [_btnInvoiceType setTitle:s.name forState:UIControlStateNormal]; [_searchModel setInvoiceType:statusId]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict =_mutDict; } #pragma 私有函数 /** 是否包含赠品点击事件 */ -(void)labelClick{ if ( [self.isIncludeGift isEqualToString:@"1"]) { self.lblIncludeGift.layer.borderColor = [UIColor lightGrayColor].CGColor; self.isIncludeGift =@"0"; self.lblIncludeGift.text = @"不包含"; self.lblIncludeGift.textColor = [UIColor lightGrayColor]; }else{ self.lblIncludeGift.layer.borderColor = [UIColor redColor].CGColor; self.isIncludeGift = @"1"; self.lblIncludeGift.text = @"包含"; self.lblIncludeGift.textColor = [UIColor redColor]; } _searchModel.giftFlag=_isIncludeGift; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } /** 是否包含转单的销售单点击事件 */ -(void)toSalesClick{ if([_searchModel.invoiceType isEqualToString:@"2"]){ if ( [self.isIncludeOrderToSales isEqualToString:@"1"]) { self.lblOrderToSales.layer.borderColor = [UIColor lightGrayColor].CGColor; self.isIncludeOrderToSales =@"0"; self.lblOrderToSales.text = @"不包含"; self.lblOrderToSales.textColor = [UIColor lightGrayColor]; }else{ self.lblOrderToSales.layer.borderColor = [UIColor redColor].CGColor; self.isIncludeOrderToSales = @"1"; self.lblOrderToSales.text = @"包含"; self.lblOrderToSales.textColor = [UIColor redColor]; } _searchModel.isIncludeOrderToSales=_isIncludeOrderToSales; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; } } /** 业务部门点击事件 @param sender <#sender description#> */ - (IBAction)businessDepartmentAction:(id)sender { BusinessDepartmentTreeViewController*tc = [[ BusinessDepartmentTreeViewController alloc] init]; tc.isPresentViewFlag=YES; tc.cDelegate=self; if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) { [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES]; } } /** 产品种类点击事件 @param sender <#sender description#> */ - (IBAction)goodsTypeAction:(id)sender { GoodsKindViewController *gc= [[ GoodsKindViewController alloc] init]; gc.isPresentViewFlag=YES; gc.cDelegate=self; if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) { [self.delegate sideSlipTableViewCellNeedsDismissViewController:gc animated:YES]; } } /** 开始日期点击事件 @param sender <#sender description#> */ - (IBAction)startDateAction:(id)sender { _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [ _brDatePicker configureSelectionBlock:^(NSString *date){ _startDate=date; } andCompletionBlock:^(void){ [_searchModel setStartDate:_startDate]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict =_mutDict; [_btnStartDate setTitle:_startDate forState:UIControlStateNormal]; } andCancelBlock:^(void){ _startDate=_btnStartDate.titleLabel.text; }]; [_brDatePicker show]; } /** 结束日期点击事件 @param sender <#sender description#> */ - (IBAction)endDateAction:(id)sender { _brDatePicker = [BRDatePickerView PickerAlertWithTitle:@""]; [_brDatePicker configureSelectionBlock:^(NSString *date){ _endDate=date; } andCompletionBlock:^(void){ [_searchModel setEndDate:_endDate]; [_mutDict setValue:_searchModel forKey:SEARCH_RANGE_MODEL]; _slideModel.customDict = _mutDict; [_btnEndDate setTitle:_endDate forState:UIControlStateNormal]; } andCancelBlock:^(void){ _endDate=_btnEndDate.titleLabel.text; }]; [_brDatePicker show]; } /** 单据类型点击事件 @param sender <#sender description#> */ - (IBAction)invoiceTypeAction:(id)sender { [self initStatus]; StatusInfoTextVC *tc = [[StatusInfoTextVC alloc] init]; tc.sdelegate=self; tc.isPresentViewFlag=YES; [tc.arrFilter addObjectsFromArray: _arrayStatus]; if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) { [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES]; } } @end