| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- //
- // SalesAnalysisSearchCell
- // IBOSS
- //
- // Created by apple on 2017/5/15.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:商品畅滞销分析抽屉Cell
- #import "SalesAnalysisSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SideSlipConfig.h"
- #import "SalesAnalysisSearchModel.h"
- #import "BRDatePickerView.h"
- #import "DateFormat.h"
- #import "BrandSearchViewController.h"
- @interface SalesAnalysisSearchCell() <UITextFieldDelegate ,BaseIDAndNameProtocol>{
-
- /**
- 存储选择的排序方式
- */
- UILabel *_selectLable;
-
- /**
- 开始时间
- */
- NSString *_strStartDate;
-
- /**
- 结束时间
- */
- NSString * _strEndDate;
-
- /**
- 品牌ID
- */
- NSString * _strCommodityBrandID;
-
- /**
- 品牌名称
- */
- NSString *_strCommodityBrand;
-
- /**
- 时间控件
- */
- BRDatePickerView *_brdatePicker;
- }
- /**
- 抽屉对象model
- */
- @property (strong,nonatomic) SideSlipModel *regionModel;
- @end
- @implementation SalesAnalysisSearchCell
- /**
- cell
-
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- SalesAnalysisSearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"SalesAnalysisSearchCell" owner:nil options:nil][0];
- cell.fieldOnlyCode.delegate = cell;
- cell.fieldCommodityName.delegate = cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- 初始化Cell
-
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- [self initUI];
- [self updateModel];
- }
- /**
- 弹出商品品牌
-
- @param sender sender description
- */
- - (IBAction)showCommodityBrand:(id)sender {
- BrandSearchViewController *tc = [[BrandSearchViewController alloc ]init];
- tc.bDelegate = self;
- tc.isPresentViewFlag = YES;
- tc.showDialogViewTag = baseIdAndNameBrand;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 品牌回调函数
-
- @param model <#model description#>
- @param value <#value description#>
- */
- - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)m BaseIDAndName:(baseIdAndName)value{
- if (value == baseIdAndNameBrand) {
- _strCommodityBrandID = m.id;
- _strCommodityBrand = m.name;
- [self.btnCommodityBrand setTitle:m.name forState:UIControlStateNormal];
- }
- [self updateModel];
- }
- /**
- 显示开始时间
-
- @param sender <#sender description#>
- */
- - (IBAction)showStartDate:(id)sender {
- _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brdatePicker configureSelectionBlock:^(NSString *date){
- _strStartDate = date;
- } andCompletionBlock:^(void){
- [_btnStartDate setTitle:_strStartDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
- _strStartDate= _btnStartDate.titleLabel.text;
- [self updateModel];
-
- }];
- [_brdatePicker show];
- }
- /**
- 显示结束时间
-
- @param sender <#sender description#>
- */
- - (IBAction)showEndDate:(id)sender {
- _brdatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_brdatePicker configureSelectionBlock:^(NSString *date){
- _strEndDate = date;
- } andCompletionBlock:^(void){
- [_btnEndDate setTitle:_strEndDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
- _strEndDate = _btnEndDate.titleLabel.text;
- [self updateModel];
- }];
- [_brdatePicker show];
- }
- /**
- 选中销售数量
- */
- - (void) selectSalesVolumes{
- [self selectSort:self.btnSalesVolumes];
- }
- /**
- 选中销售金额
- */
- - (void) selectSalesAmount {
- [self selectSort:self.btnSalesAmount];
- }
- /**
- 选中销售次数
- */
- - (void) selectSalesTimes {
- [self selectSort:self.btnSalesTimes];
- }
- /**
- 切换排序
-
- @param lab <#lab description#>
- */
- - (void)selectSort: (UILabel *) lab {
- if(_selectLable == lab){
- return;
- }else{
- _selectLable.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- _selectLable.textColor = NavBarUnEnbleItemColor;
- _selectLable = lab;
- _selectLable.layer.borderColor = [[UIColor redColor] CGColor];
- _selectLable.textColor = [UIColor redColor];
- [self updateModel];
- }
- }
- /**
- 区分渠道
- */
- - (void)selectChannel{
- [self distinguish:self.btnChannel];
- }
- /**
- 区分等级
- */
- - (void)selectGrade{
- [self distinguish:self.btnGrade];
- }
- /**
- 区分色号
- */
- - (void)selectAreaColor{
- [self distinguish:self.btnAreaColor];
- }
- /**
- 区分规格
- */
- - (void)selectSpecification{
- [self distinguish:self.btnSpecification];
- }
- /**
- 区分规格
- */
- - (void)distinguish:(UILabel *) lbl{
- switch (lbl.tag) {
- case 0:
- lbl.tag = 1;
- lbl.layer.borderColor = [[UIColor redColor] CGColor];
- lbl.textColor = [UIColor redColor];
- break;
- case 1:
- lbl.tag = 0;
- lbl.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- lbl.textColor = NavBarUnEnbleItemColor;
- break;
- default:
- break;
- }
- [self updateModel];
- }
- /**
- awakeFromNib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _fieldOnlyCode.inputAccessoryView = keyBoardAccessoryView;
- _fieldCommodityName.inputAccessoryView = keyBoardAccessoryView;
- }
- /**
- 文本编辑时候 弹出取消完成按钮
-
- @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;
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
- [self hideKey];
- }
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- [_fieldOnlyCode resignFirstResponder];
- [_fieldCommodityName resignFirstResponder];
- [self hideKey];
- }
- /**
- * 隐藏键盘
- */
- - (void)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
- [_fieldOnlyCode setText:@""];
- [_fieldCommodityName setText:@""];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- SalesAnalysisSearchModel *model = [[SalesAnalysisSearchModel alloc] init];
- model.strOnlyCode = [_fieldOnlyCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.strCommodityName = [_fieldCommodityName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.strCommodityBrandID = _strCommodityBrandID;
- model.strCommodityBrand = _strCommodityBrand;
- model.strStartDate = _strStartDate;
- model.strEndDate = _strEndDate;
- model.strType = [NSString stringWithFormat:@"%ld",(long)_selectLable.tag];
- model.strGrade = [NSString stringWithFormat:@"%ld",(long)_btnGrade.tag];
- model.strChannel = [NSString stringWithFormat:@"%ld",(long)_btnChannel.tag];
- model.strSpecification = [NSString stringWithFormat:@"%ld",(long)_btnSpecification.tag];
- model.strAreaColor = [NSString stringWithFormat:@"%ld",(long)_btnAreaColor.tag];
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:SALESANALYSIS_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- /**
- Identifier
-
- @return
- */
- + (NSString *)cellReuseIdentifier {
- return @"SalesAnalysisSearchCell";
- }
- /**
- 高度
-
- @return return value description
- */
- - (CGFloat)cellHeight {
- return 669;
- }
- /**
- 文本编辑结束事件
-
- @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];
- [_fieldOnlyCode resignFirstResponder];
- [_fieldCommodityName resignFirstResponder];
- }
- /**
- 初始化布局
- */
- - (void)initUI {
- self.btnSalesVolumes.layer.borderWidth = 0.5;
- self.btnSalesVolumes.layer.cornerRadius = 5;
- self.btnSalesVolumes.tag = 1;
- self.btnSalesVolumes.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnSalesVolumes.textColor = NavBarUnEnbleItemColor;
- self.btnSalesAmount.layer.borderWidth = 0.5;
- self.btnSalesAmount.layer.cornerRadius = 5;
- self.btnSalesAmount.tag = 2;
- self.btnSalesAmount.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnSalesAmount.textColor = NavBarUnEnbleItemColor;
- self.btnSalesTimes.layer.borderWidth = 0.5;
- self.btnSalesTimes.layer.cornerRadius = 5;
- self.btnSalesTimes.tag = 3;
- self.btnSalesTimes.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnSalesTimes.textColor = NavBarUnEnbleItemColor;
- [self selectSort:self.btnSalesVolumes];
- self.btnChannel.layer.borderWidth = 0.5;
- self.btnChannel.layer.cornerRadius = 5;
- self.btnChannel.tag = 0;
- self.btnChannel.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnChannel.textColor = NavBarUnEnbleItemColor;
- self.btnGrade.layer.borderWidth = 0.5;
- self.btnGrade.layer.cornerRadius = 5;
- self.btnGrade.tag = 0;
- self.btnGrade.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnGrade.textColor = NavBarUnEnbleItemColor;
- self.btnAreaColor.layer.borderWidth = 0.5;
- self.btnAreaColor.layer.cornerRadius = 5;
- self.btnAreaColor.tag = 0;
- self.btnAreaColor.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnAreaColor.textColor = NavBarUnEnbleItemColor;
- self.btnSpecification.layer.borderWidth = 0.5;
- self.btnSpecification.layer.cornerRadius = 5;
- self.btnSpecification.tag = 0;
- self.btnSpecification.layer.borderColor = [NavBarUnEnbleItemColor CGColor];
- self.btnSpecification.textColor = NavBarUnEnbleItemColor;
- UITapGestureRecognizer *channelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectChannel)];
- // 2. 将点击事件添加到label上
- [self.btnChannel addGestureRecognizer:channelTapGestureRecognizer];
- self.btnChannel.userInteractionEnabled = YES; // 可以理解为设置label可被点击
-
- UITapGestureRecognizer *gradeTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectGrade)];
- // 2. 将点击事件添加到label上
- [self.btnGrade addGestureRecognizer:gradeTapGestureRecognizer];
- self.btnGrade.userInteractionEnabled = YES; // 可以理解为设置label可被点击
-
- UITapGestureRecognizer *areaColorTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectAreaColor)];
- // 2. 将点击事件添加到label上
- [self.btnAreaColor addGestureRecognizer:areaColorTapGestureRecognizer];
- self.btnAreaColor.userInteractionEnabled = YES; // 可以理解为设置label可被点击
-
- UITapGestureRecognizer *specificationTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectSpecification)];
- // 2. 将点击事件添加到label上
- [self.btnSpecification addGestureRecognizer:specificationTapGestureRecognizer];
- self.btnSpecification.userInteractionEnabled = YES; // 可以理解为设置label可被点击
-
- UITapGestureRecognizer *salesVolumesTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectSalesVolumes)];
- // 2. 将点击事件添加到label上
- [self.btnSalesVolumes addGestureRecognizer:salesVolumesTapGestureRecognizer];
- self.btnSalesVolumes.userInteractionEnabled = YES; // 可以理解为设置label可被点击
- UITapGestureRecognizer *salesAmountTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectSalesAmount)];
- // 2. 将点击事件添加到label上
- [self.btnSalesAmount addGestureRecognizer:salesAmountTapGestureRecognizer];
- self.btnSalesAmount.userInteractionEnabled = YES; // 可以理解为设置label可被点击
- UITapGestureRecognizer *salesTimesTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectSalesTimes)];
- // 2. 将点击事件添加到label上
- [self.btnSalesTimes addGestureRecognizer:salesTimesTapGestureRecognizer];
- self.btnSalesTimes.userInteractionEnabled = YES; // 可以理解为设置label可被点击
- _strCommodityBrandID = @"";
- _strEndDate = [DateFormat getCurrentDate];
- _strStartDate = [DateFormat getDateBefore:31];
- [_btnEndDate setTitle:_strEndDate forState:UIControlStateNormal];
- [_btnStartDate setTitle:_strStartDate forState:UIControlStateNormal];
- }
- @end
|