| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- //
- // ProcurementApplySearchCell.m
- // IBOSS
- //
- // Created by guan hong hou on 2018/7/23.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "ProcurementApplySearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SideSlipConfig.h"
- @implementation ProcurementApplySearchCell
- #pragma mark -公共函数
- /**
- 唤醒xib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- /**
- 汇总类型
- @return <#return value description#>
- */
- - (NSMutableArray *)summaryTypeArr{
- if (_summaryTypeArr == nil) {
- _summaryTypeArr = [[NSMutableArray alloc]init];
- BaseIDAndNameModel *m = [BaseIDAndNameModel new];
- m.id = @"1";
- m.name = @"请购单号";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"2";
- m.name = @"销售订单单号";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"3";
- m.name = @"商品品牌";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"4";
- m.name = @"商品规格";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"5";
- m.name = @"商品编码";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"6";
- m.name = @"商品种类";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"7";
- m.name = @"商品系列";
- [_summaryTypeArr addObject:m];
-
- m = [BaseIDAndNameModel new];
- m.id = @"8";
- m.name = @"请购人";
- [_summaryTypeArr addObject:m];
-
- }
- return _summaryTypeArr;
- }
- #pragma mark -委托函数
- /**
- 高度
- @return <#return value description#>
- */
- - (CGFloat)cellHeight {
- return 768.5;
- }
- /**
- 创建cell
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- ProcurementApplySearchCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ProcurementApplySearchCell" owner:nil options:nil][0];
- cell.txtApplyNo.delegate=cell;
- cell.txtApplyTitle.delegate=cell;
- cell.txtCustomerCode.delegate=cell;
- cell.txtCustomerName.delegate=cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- 更新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];
-
- }
- /**
- Identifier
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
-
- return @"ProcurementApplySearchCell";
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
-
- [_txtApplyNo setText:@""];
- [_txtApplyTitle setText:@""];
- [_txtCustomerCode setText:@""];
- [_txtCustomerName setText:@""];
- [_btnStartDate setTitle:@"请选择开始日期" forState:UIControlStateNormal];
- _sStartDate = @"";
- [_btnEndDate setTitle:@"请选择结束日期" forState:UIControlStateNormal];
- _sEndDate = @"";
- [_btnApplyDepartment setTitle:@"请选择申请部门" forState:UIControlStateNormal];
- _organizationCode = @"";
- [_btnApplier setTitle:@"请选择申请者" forState:UIControlStateNormal];
- _applierId = @"";
- [_btnSummaryType setTitle:@"请选择汇总类型" forState:UIControlStateNormal];
- _summaryTypeId=@"";
- }
- /**
- 长度
- @param textField <#textField description#>
- @param range <#range description#>
- @param string <#string description#>
- @return <#return value description#>
- */
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- return YES;
- }
- /**
- 文本编辑结束事件
-
- @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];
- [_txtApplyNo resignFirstResponder];
- [_txtCustomerCode resignFirstResponder];
- [_txtCustomerName resignFirstResponder];
- [_txtApplyTitle resignFirstResponder];
- }
- /**
- 业务员 业务部门
- @param Amodel <#Amodel description#>
- @param cr <#cr description#>
- */
- - (void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
-
- //返回值
- if(cr == ReportAchiementDepartmt){
- _organizationCode = Amodel.organizationCode;
- [_btnApplyDepartment setTitle:Amodel.organizationName forState:UIControlStateNormal];
- }
- // 业务员
- if(cr == ReportAchiementmn){
- _applierId = Amodel.staffId;
- [_btnApplier setTitle:Amodel.staffName forState:UIControlStateNormal];
- }
-
- [self updateModel];
- }
- /**
- 汇总类型
- @param model <#model description#>
- @param value <#value description#>
- */
- - (void)baseIDAndNameDoneDatas:(BaseIDAndNameModel *)model
- BaseIDAndName:(baseIdAndName)value{
- _summaryTypeId = model.id;
- [self.btnSummaryType setTitle:model.name forState:UIControlStateNormal];
- [self updateModel];
- }
- #pragma mark -私有函数
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtApplyNo.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerCode.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerName.inputAccessoryView = keyBoardAccessoryView;
- _txtApplyTitle.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)hideKey
- {
- [self.contentView endEditing:YES];
- }
- /**
- 取消文本
- */
- - (void)accessoryButtonBack {
-
- [self hideKey];}
- /**
- 确定文本
- */
- - (void)accessoryButtonDone {
- [_txtApplyTitle resignFirstResponder];
- [_txtCustomerCode resignFirstResponder];
- [_txtCustomerName resignFirstResponder];
- [_txtApplyNo resignFirstResponder];
- [self hideKey];
- }
- /**
- 点击请购部门事件
- @param sender <#sender description#>
- */
- - (IBAction)clickApplyDepartmentAction:(id)sender {
- CustomerAchievementTextVC *tc = [[CustomerAchievementTextVC alloc ]init];
- tc.cDelegate = self;
- tc.isPresentViewFlag = YES;
- tc.flag = YES;
- tc.showDialogViewTag=ReportAchiementDepartmt;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 点击申请者事件
- @param sender <#sender description#>
- */
- - (IBAction)clickApplierAction:(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)clickStartDateAction:(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)clickEndDateAction:(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];
- }
- /**
- 点击汇总类型
- @param sender <#sender description#>
- */
- - (IBAction)clickSummaryTypeAction:(id)sender {
- BaseIDAndNameViewController *tc = [[BaseIDAndNameViewController alloc ]init];
- tc.bDelegate = self;
- tc.isPresentViewFlg = YES;
- tc.arrFilter = self.summaryTypeArr;
- tc.arrSearch = self.summaryTypeArr;
- tc.showDialogViewTag = baseIdAndNameValueFlag;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 更新model
- */
- -(void)updateModel
- {
- ProcurementApplySearchModel *searchModel=[[ProcurementApplySearchModel alloc]init];
- searchModel.applyNo=[_txtApplyNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- searchModel.applyTitle=[_txtApplyTitle.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- searchModel.customerCode=[_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
-
- searchModel.customerName=[_txtCustomerName.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- searchModel.organizationCode=_organizationCode;
- searchModel.applierId=_applierId;
- searchModel.startDate=_sStartDate;
- searchModel.endDate=_sEndDate;
- searchModel.summaryTypeId=_summaryTypeId;
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:searchModel forKey:PROCUREMENT_APPLY_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
-
- }
- @end
|