| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- //
- // SalesInStorageSearchCell.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/20.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "SalesInStorageSearchCell.h"
- #import "UIColor+hexColor.h"
- #import "SideSlipConfig.h"
- @implementation SalesInStorageSearchCell
- #pragma mark 公共函数
- /**
- 加载xib
- */
- - (void)awakeFromNib {
- [super awakeFromNib];
-
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
-
- }
- #pragma mark 委托函数
- /**
- 高度
- @return return value description
- */
- - (CGFloat)cellHeight {
- return 622.5;
- }
- - (void)customerReportTextDoneDatas:(CustomerReportTextInfoModel *)model CustomerReport:(CustomerReport)cr{
- if (model==nil) {
- return;
- }
-
- if(cr==ReportSupplier){
- _supplierId=model.idCode;
- _supplierName=model.name;
- [self.btnSupplier setTitle:_supplierName forState:UIControlStateNormal];
-
- }
-
- [self updateModel];
-
- }
- /**
- 业务员 业务部门
- @param Amodel <#Amodel description#>
- @param cr <#cr description#>
- */
- -(void)achiementData:(AchiementDepartmentInfoModel *)Amodel CustomerReport:(CustomerReport)cr{
-
- //返回值
- if(cr== ReportAchiementDepartmt){
- _organizationCode=Amodel.organizationCode;
- [self.btnDepartment setTitle:Amodel.organizationName forState:UIControlStateNormal];
- }
- // 业务员
- if(cr==ReportAchiementmn){
- _staffId = Amodel.staffId;
- [self.btnStaff setTitle:Amodel.staffName forState:UIControlStateNormal];
- }
-
- [self updateModel];
- }
- /**
- 更新model
- @param model <#model description#>
- @param indexPath <#indexPath description#>
- */
- - (void)updateCellWithModel:(SideSlipModel *__autoreleasing *)model
- indexPath:(NSIndexPath *)indexPath{
- self.regionModel = *model;
- }
- /**
- Identifier
- @return <#return value description#>
- */
- + (NSString *)cellReuseIdentifier {
- return @"SalesInStorageSearchCell";
- }
- /**
- cell
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- + (instancetype)createCellWithIndexPath:(NSIndexPath *)indexPath {
- SalesInStorageSearchCell *cell = [[NSBundle mainBundle]
- loadNibNamed:@"SalesInStorageSearchCell"
- owner:nil
- options:nil][0];
-
-
- cell.btnApprovePass.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnApprovePass.layer.borderWidth=1;
- cell.btnApprovePass.tag=0;
- cell.btnApprovePass.layer.cornerRadius=4;
- [cell.btnApprovePass setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
-
- [cell.btnApprovePass addTarget:cell action:@selector(approveStatus)
- forControlEvents:UIControlEventTouchUpInside];
-
- cell.btnCorrect.layer.borderColor=NavBarUnEnbleItemColor.CGColor;
- cell.btnCorrect.layer.borderWidth=1;
- cell.btnCorrect.tag=0;
- cell.btnCorrect.layer.cornerRadius=4;
- [cell.btnCorrect setTitleColor:NavBarUnEnbleItemColor forState:UIControlStateNormal];
- [cell.btnCorrect addTarget:cell action:@selector(correctStatus)
- forControlEvents:UIControlEventTouchUpInside];
- cell.txtInStorageNo.delegate=cell;
- cell.txtCustomerCode.delegate=cell;
- [cell configureKeyboard];
- return cell;
- }
- /**
- 触摸事件
- @param touches <#touches description#>
- @param event <#event description#>
- */
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self hideKey];
- [_txtCustomerCode resignFirstResponder];
- [_txtInStorageNo resignFirstResponder];
- }
- /**
- 长度
- @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];
- }
- /**
- 重置按钮 事件
- */
- - (void)resetData {
-
- [_txtInStorageNo setText:@""];
- [_txtCustomerCode setText:@""];
- [_btnStartDate setTitle:@"请选择开始账务日期" forState:UIControlStateNormal];
- _startDate = @"";
- [_btnEndDate setTitle:@"请选择结束账务日期" forState:UIControlStateNormal];
- _endDate = @"";
- [_btnSupplier setTitle:@"请选择供应商" forState:UIControlStateNormal];
- _supplierId=@"";
- [_btnDepartment setTitle:@"请选择业务部门" forState:UIControlStateNormal];
- [_btnStaff setTitle:@"请选择业务员" forState:UIControlStateNormal];
- _staffId=@"";
- _organizationCode=@"";
- _btnApprovePass.tag=0;
- _btnCorrect.tag=0;
- [_invoiceStatus setString:@""];
- }
- #pragma mark 私有函数
- /**
- 供应商点击函数
- @param sender <#sender description#>
- */
- - (IBAction)supplierClickAction:(id)sender {
- CustomerReportTextVC *tc=[[CustomerReportTextVC alloc] init];
- tc.delegate=self;
- tc.isPresentViewFlag=YES;
- tc.showDialogViewTag=ReportSupplier;
- if ([self.delegate respondsToSelector:@selector(sideSlipTableViewCellNeedsDismissViewController:animated:)]) {
- [self.delegate sideSlipTableViewCellNeedsDismissViewController:tc animated:YES];
- }
- }
- /**
- 键盘配置
- */
- - (void)configureKeyboard {
- UIView *keyBoardAccessoryView = [self createKeyBoardAccessoryView];
- _txtInStorageNo.inputAccessoryView = keyBoardAccessoryView;
- _txtCustomerCode.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 {
- [_txtCustomerCode resignFirstResponder];
- [_txtInStorageNo resignFirstResponder];
-
- [self hideKey];
- }
- /**
- 更新model
- */
- - (void)updateModel{
- OtherInStorageSearchModel *model = [[OtherInStorageSearchModel alloc] init];
- NSString *inStorageNoStr=[_txtInStorageNo.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.inStorageNo =inStorageNoStr;
- NSString *customerCodeStr=@"";
- customerCodeStr= [_txtCustomerCode.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- model.customerCode =customerCodeStr;
- NSString *startDateStr=@"";
- startDateStr=_btnStartDate.currentTitle;
- if([startDateStr isEqualToString:@"请选择开始账务日期"]){
- startDateStr=@"";
- }
- model.startDate =startDateStr ;
- NSString *endDateStr =@"";
- endDateStr=_btnEndDate.currentTitle;
- if([endDateStr isEqualToString:@"请选择结束账务日期"]){
- endDateStr=@"";
- }
- model.endDate=endDateStr;
-
- model.supplierId=_supplierId;
- model.organizationCode=_organizationCode;
- model.staffId=_staffId;
-
- _invoiceStatus=[[NSMutableString alloc] init];
- if(_btnApprovePass.tag==1 ){
- [_invoiceStatus appendString:@"3,"];
- }
-
-
- if(_btnCorrect.tag==1){
- [_invoiceStatus appendString:@"10,"];
- }
- if(_invoiceStatus.length>0){
- [_invoiceStatus deleteCharactersInRange:NSMakeRange(_invoiceStatus.length-1, 1)];
- }
- model.invoiceStatus=_invoiceStatus;
-
- NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:_regionModel.customDict];
- [mutDict setValue:model forKey:SALES_IN_STORAGE_SEARCH_RANGE_MODEL];
- _regionModel.customDict = [mutDict copy];
- }
- /**
- 点击开始日期事件
- @param sender <#sender description#>
- */
- - (IBAction)startDateClickAction:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempStartDate=date;
- } andCompletionBlock:^(void){
- weakself.startDate = _tempStartDate;
- [weakself.btnStartDate setTitle:weakself.startDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- /**
- 点击结束日期事件
- @param sender <#sender description#>
- */
- - (IBAction)endDateClickAction:(id)sender {
- __weak typeof(self) weakself=self;
- _dealDatePicker = [BRDatePickerView PickerAlertWithTitle:@""];
- [_dealDatePicker configureSelectionBlock:^(NSString *date){
- _tempEndDate=date;
- } andCompletionBlock:^(void){
- weakself.endDate = _tempEndDate;
- [weakself.btnEndDate setTitle:weakself.endDate forState:UIControlStateNormal];
- [self updateModel];
- } andCancelBlock:^(void){
-
- }];
- [_dealDatePicker show];
- }
- /**
- 业务部门点击事件
- @param sender <#sender description#>
- */
- - (IBAction)departmentClickAction:(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)staffClickAction:(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];
- }
- }
- /**
- 审批状态切换函数
- */
- - (void)distinguish:(UIButton *) btn{
- switch (btn.tag) {
- case 0:
- btn.tag = 1;
- btn.layer.borderColor = [[UIColor redColor] CGColor];
- [btn setTitleColor: [UIColor redColor] forState:UIControlStateNormal];
- break;
- case 1:
- btn.tag = 0;
- btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
- [btn setTitleColor: NavBarUnEnbleItemColor forState:UIControlStateNormal];
- break;
- default:
- break;
-
- }
- [self updateModel];
- }
- /**
- 审批通过点击函数
- */
- -(void)approveStatus{
- [self distinguish:_btnApprovePass];
- }
- /**
- 冲正点击函数
- */
- -(void)correctStatus{
- [self distinguish:_btnCorrect];
- }
- @end
|