
//
//  SecondPersonInformationViewController.m
//  Open
//
//  Created by 看看智能 on 2018/1/6.
//  Copyright © 2018年 黄江涛 . All rights reserved.
//

#import "SecondPersonInformationViewController.h"

@interface SecondPersonInformationViewController ()<UITextFieldDelegate,UIScrollViewDelegate,chooseAddressViewcontrollerDelegate>
{
    int cityKK ;//城市
    int socialKK ;//社保
    int jobInKK ;//工作
    
    //单选和多选
    int employeeFamilyRelation_;
    int EmployeePliticsStatus_;

    int employeeGraducationInstitution_;
    int employeeOccupationQualificationDeGrade_;
    int employeePorfessionalQualification_;
    //其他
    int employeeOther_;
}

@property(nonatomic,strong)CLMarkButton *cityButton;
@property(nonatomic,strong)CLMarkButton *socialButton;
@property(nonatomic,strong)CLMarkButton *jobButton;

//单选
@property(nonatomic,strong)addressGatherModel *addressModel;

@property(nonatomic,strong)ljhCheckbox *ljhCheck;
@property(nonatomic,strong)NSMutableArray *workTypeArray;
@end

@implementation SecondPersonInformationViewController
//多选初始化
-(ljhCheckbox *)ljhCheck
{
    if (!_ljhCheck) {
        _ljhCheck = [[ljhCheckbox alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 100)];
             _ljhCheck.backgroundColor = [UIColor clearColor];
     
    }
    return _ljhCheck;
    
}

//单选初始化
-(addressGatherModel *)addressModel
{
    if(!_addressModel){
        _addressModel =[[addressGatherModel alloc]initWithViewController:self];
    }
    return _addressModel;
    
}
//所有选择数据
-(NSMutableArray *)dataArr
{
    if (!_dataArr) {
        _dataArr =[NSMutableArray array];
        NSArray *result = [CWSqliteModelTool queryAllModels:[PersonJob class]];
        if (result.count > 0) {
            _dataArr = [NSMutableArray arrayWithArray:result];
        }


    }
    return _dataArr;
}
-(NSMutableArray *)workTypeArray
{
    if (!_workTypeArray) {
        _workTypeArray =[NSMutableArray array];
        NSArray *result = [CWSqliteModelTool queryAllModels:[workTypeSelectionNSObject class]];
        if (result.count > 0) {
            _workTypeArray = [NSMutableArray arrayWithArray:result];
        }
        
    }
    return _workTypeArray;
}


+ (SecondPersonInformationViewController *)sharedInstance{
    static SecondPersonInformationViewController *p = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        p=[sb instantiateViewControllerWithIdentifier:@"SecondPersonInformationViewController"];
    });
    return p;
}
#pragma mark - View
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    //调用接口最后写
    self.haveJob.selected = YES;
    self.lostJobYEs.selected = NO;
    self.qitaJob.selected = NO;
    jobInKK =1;
    self.otherTextfield.text =nil;
    self.employeeOccupationQualification.text = nil;
    self.employeeOccupationQualificationDeGrade.text = nil;
    self.employeeProfessionTechnicalPosts.text = nil;
    self.employeePorfessionalQualification.text = nil;
    self.employeeGraducationInstitution.text = nil;
    self.employeeStandCultureTextField.text =@"";
    self.employeeMajor_ =@"-1";
    self.employeeTimeOfGraducation.text=@"";
    self.employeeCard.text =nil;
     self.employeeFamily.text =nil;
     self.employeeFamilyId.text =nil;
     self.employeeFamilyRelation.text =nil;
    self.viewHide_1.hidden =NO;
    self.viewHide_2.hidden =NO;
    self.viewHide_3.hidden =NO;
    self.viewChangeHeight.constant =261;
    self.employeeheight.constant =1688 +48;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    //键盘弹起
    [self jiantingKeyBoard];

    //设置高度
    self.employeeScroll.bounces = NO;
    //设置所有为空
    [self makeAllZERO];
    self.title =@"基本信息";
    //设置空白和代理
     [self delegate];
    SVProgressHUD.minimumDismissTimeInterval =1.0;
    //点击事件
    UITapGestureRecognizer *get =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(asdasd)];
    [self.employeeHeightView addGestureRecognizer:get];
    
    //设置按钮点击事件
    [self Citybutt];
    [self SocialButt];
    [self WorkButt];
    //初始化
     cityKK  = 1;//城市
     socialKK = 1;//社保
     jobInKK  = 1;//工作
    employeeFamilyRelation_ = 0;
   EmployeePliticsStatus_ = 1;
   self.employeeGroup_ = @"1";
   employeeGraducationInstitution_ = 1;
   employeeOccupationQualificationDeGrade_ = 0;
   employeePorfessionalQualification_ = 1;
    employeeOther_=1;
    self.employeeMajor_ =@"-1";
    self.employeeOccupationQualification_ = @"-1" ;
    self.employeeProfessionTechnicalPosts_ = @"-1";
    
    
    
    //多选控件初始化
    __weak typeof(self) wself = self;
    self.muchChooseArr = [NSMutableArray array];
    if (self.dataArr.count >0) {
        for (PersonJob *model in self.dataArr) {
            if ([model.nameJob isEqualToString:@"focusGroups"]) {
                [self.ljhCheck mybuttonwithArr:model.politicalStatus andTitle:@"多选"andMessage:nil];
                [self.ljhCheck setFinishBlock:^(NSString *choice) {
                    NSLog(@"result-->\n%@",choice);
                    //赋值
                    wself.employeeGroupTextField.text =choice;
   //转化 "1,2"格式
                wself.employeeGroup_ =    [JobUtil chooseMoreEmployee:[model.politicalStatus copy] andSelectedString:wself.employeeGroupTextField.text];
                    //设置无数据时为1
                    if ([wself.employeeGroup_ isEqualToString:@""] || wself.employeeGroup_ == nil ) {
                        wself.employeeGroup_ = @"1";
                    }
                    //拨开代码单独写方法
                    NSArray  *array_ = [wself.employeeGroupTextField.text componentsSeparatedByString:@","];
                    
                    
                    
                    if (array_.count >0) {
                        for (NSString * asdasd  in array_) {
                            if ([asdasd isEqualToString:@"残疾人__（伤残等级）"]) {
                                            [wself downTownLogic:array_];
                            }
                        }
            
                     
                    }
                }];
                  [_employeeGroupTextField addSubview:_ljhCheck];
            }
        }
    }
    
 

    
}





- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.employeeHeightView;
}
//scrollDelegate
- (void)updateViewConstraints {
    [super updateViewConstraints];
    
//    self.employeeheight.constant =self.frame.origin.y+self.nextPage.bounds.size.height;
        self.employeeheight.constant = 1688 +48;;
}


-(void)makeAllZERO{

    self.employeeCard.text =nil;    //社保卡号
    self.employeeFamily.text =nil;    //户主
    self.employeeFamilyId.text =nil;    //户主身份证
    self.employeeFamilyRelation.text =nil;//与户主关系
    self.employeeAddress.text =nil;//户主常住地址
    self.EmployeePliticsStatusTextField.text =nil;   //政治面貌
    self.employeeGroupTextField.text =nil;//重点群体
    self.employeeStandCultureTextField.text =nil; //毕业院校
    self.employeeGraducationInstitution.text =nil;//文化程度
    self.employeeMajor.text =nil;//所学专业
    self.employeeTimeOfGraducation.text =nil; //毕业时间
    self.employeeOccupationQualification.text =nil;//职业资格
    self.employeeOccupationQualificationDeGrade.text =nil;//职业资格等级(选)
    self.employeeProfessionTechnicalPosts.text =nil;//专业技术职务
    self.employeePorfessionalQualification.text =nil;//职称等级(选)
    self.otherTextfield.text = nil;
    self.employeeFamilyRelation.placeholder =@"请选择(单选)  >";
    self.employeeAddress.placeholder =@"请选择(单选)  >";
    self.EmployeePliticsStatusTextField.placeholder =@"请选择(单选)  >";
    self.employeeGroupTextField.placeholder =@"请选择(多选)  >";
    self.employeeGraducationInstitution.placeholder =@"请选择(单选)  >";
    self.employeeTimeOfGraducation.placeholder =@"请选择(单选)  >";
    self.employeeOccupationQualificationDeGrade.placeholder =@"请选择(单选)  >";
    self.employeePorfessionalQualification.placeholder =@"请选择(单选)  >";
self.otherTextfield.placeholder =@"请选择(单选)  >";
    self.employeeOccupationQualification.placeholder =@"请选择(单选)  >";
    self.employeeMajor.placeholder=@"请选择(单选)  >";
    self.employeeProfessionTechnicalPosts.placeholder=@"请选择(单选)  >";
    
    
}
-(void)delegate{

    self.employeeCard.delegate =self;    //社保卡号
    self.employeeFamily.delegate =self;    //户主
    self.employeeFamilyId.delegate =self;    //户主身份证
    self.employeeFamilyRelation.delegate =self;//与户主关系
    self.employeeAddress.delegate =nil;//户主常住地址
    self.EmployeePliticsStatusTextField.delegate =self;   //政治面貌
    self.employeeGroupTextField.delegate =self;//重点群体
    self.employeeStandCultureTextField.delegate =self; //毕业院校
    self.employeeGraducationInstitution.delegate =self;//文化程度
    self.employeeMajor.delegate =self;//所学专业
    self.employeeTimeOfGraducation.delegate =self; //毕业时间
    self.employeeOccupationQualification.delegate =self;//职业资格
    self.employeeOccupationQualificationDeGrade.delegate =self;//职业资格等级(选)
    self.employeeProfessionTechnicalPosts.delegate =self;//专业技术职务
    self.employeePorfessionalQualification.delegate =self;//职称等级(选)
    self.otherTextfield.delegate =self;
    
    
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeCard];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeFamily];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeFamilyId];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeFamilyRelation];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeAddress];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.EmployeePliticsStatusTextField];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeGroupTextField];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeStandCultureTextField];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeGraducationInstitution];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeMajor];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeTimeOfGraducation];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeOccupationQualification];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeOccupationQualificationDeGrade];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeeProfessionTechnicalPosts];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.employeePorfessionalQualification];
    [self textFieldAddTwoBlackPlaceinTextFiled:self.otherTextfield];
}
#pragma mark - 工作交互的三个按钮
-(void)Citybutt{
    //1=城市 和 2 =农业
    NSArray *arr = @[_cityHouseHold,_argocultureHouseHold];
 [self  buttonUse:arr andID:11007];
    __weak __typeof(self)weakSelf = self;
    
    self.buttonA = ^(CLMarkButton *buttonName_A) {
        weakSelf.cityButton = buttonName_A;
        if (weakSelf.cityButton == weakSelf.cityHouseHold) {
            cityKK = 1;
        }else{
            cityKK = 2;
        }
    };
    
    
    

}
-(void)SocialButt{
    // 是否参保 1 = 是 2 = 否
    NSArray *arr = @[_employeeInsuredToYesButton,_employeeInsureToNoButton];
 [self  buttonUse:arr andID:12007];
    __weak __typeof(self)weakSelf = self;
    
    self.buttonB = ^(CLMarkButton *buttonName_B) {
        weakSelf.socialButton = buttonName_B;
        if (weakSelf.socialButton == weakSelf.employeeInsuredToYesButton) {
            socialKK = 1;
        }else{
            socialKK = 2;
        }
    };
    
}

-(void)WorkButt{
    //1 代表就
    NSArray *arr = @[_lostJobYEs,_haveJob,_qitaJob];
  [self  buttonUse:arr andID:13007];
       self.otherTextfield.hidden =YES;
    __weak __typeof(self)weakSelf = self;
    self.buttonS = ^(CLMarkButton *buttonName) {
        weakSelf.jobButton = buttonName;
        if (weakSelf.jobButton == weakSelf.lostJobYEs) {
            jobInKK = 2;
             weakSelf.otherTextfield.text =@"";
               weakSelf.otherTextfield.hidden =YES;
        }else if((weakSelf.jobButton == weakSelf.haveJob)){
            jobInKK = 1;
            weakSelf.otherTextfield.text =@"";
               weakSelf.otherTextfield.hidden =YES;
        }else{
             jobInKK = 3;
            
        
            if (weakSelf.dataArr.count >0) {
                for (PersonJob *model in weakSelf.dataArr) {
                    if ([model.nameJob isEqualToString:@"quitlabarreason"]) {
                        [weakSelf.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                            employeeOther_ =  (int)[JobUtil chooseEmployeeFamilyRelation:[model.politicalStatus copy] andSelectedString:str1];
                              weakSelf.otherTextfield.hidden =NO;
                            weakSelf.otherTextfield.text =str1;
                        }];
                    }
                }
            }
    
        }
        
    };

}

#pragma mark - 收起按钮
-(void)asdasd{
    [self.view endEditing:YES];
    
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.view endEditing:YES];
    return YES;
}
#pragma mark - textfieldDelegate
-(BOOL)textFieldShouldBeginEditing:(UITextField*)textField{
    
    

    
    
    
    
    if (textField ==  self.employeeAddress ||
        textField ==  self.employeeFamilyRelation ||
        textField ==  self.EmployeePliticsStatusTextField ||
        textField ==  self.employeeGroupTextField ||
        textField ==  self.employeeGraducationInstitution ||
        textField ==  self.employeeTimeOfGraducation ||
        textField ==  self.employeeOccupationQualificationDeGrade ||
        textField ==  self.employeePorfessionalQualification ||
        textField == self.otherTextfield ||
        textField == self.employeeMajor ||
        textField == self.employeeOccupationQualification ||
        textField == self.employeeProfessionTechnicalPosts

        ){
        [self NotUseButton:textField];
        [textField resignFirstResponder];
        return NO;
    }else{
        return YES;
    }
    
}

#pragma mark - 所有不能手输的按钮
- (IBAction)NotUseButton:(UITextField *)sender {
     [self.view endEditing:YES];
    //self.employeePorfessionalQualification.placeholder =@"请选择(单选)  >";
    if (sender == self.employeeFamilyRelation ) {//与户主关系

        __block NSArray *   array = @[@"本人",@"配偶",@"子女",@"父母",@"兄弟",@"叔",@"孙子",@"姐妹"];

            __weak typeof(self) wself = self;
        [self.addressModel onlySelect:array Handle:^(NSString *str1, NSString *str2, NSError *error) {
        //employeeFamilyRelation_ =  (int)[JobUtil chooseEmployeeFamilyRelation:[array copy] andSelectedString:str1]; 
            if (str1) {
             employeeFamilyRelation_  = (int)[array indexOfObject:str1]  +1;
            }
             wself.employeeFamilyRelation.text = str1;
                
            
            
        }];
        
    }else if (sender == self.employeeAddress){
        //常住地址
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        chooseAddressViewController*once  = [sb instantiateViewControllerWithIdentifier:@"chooseAddressViewController"];
        once.delegate =self;
        [self presentViewController:once animated:YES completion:^{
            once.stringChoose =@"stringChoose";
        }];
        
    }else if (sender == self.EmployeePliticsStatusTextField){
        //政治面貌
        
        __weak typeof(self) wself = self;
        if (self.dataArr.count >0) {
            for (PersonJob *model in self.dataArr) {
                if ([model.nameJob isEqualToString:@"politicalStatus"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        EmployeePliticsStatus_ =  (int)[JobUtil chooseEmployeeFamilyRelation:[model.politicalStatus copy] andSelectedString:str1];
                        wself.EmployeePliticsStatusTextField.text =str1;
                    }];
                }
            }
        }
        
    }else if (sender == self.employeeGroupTextField){
        //重点群体

    }else if (sender == self.employeeGraducationInstitution){
        //文化程度
         __weak typeof(self) wself = self;
        if (self.dataArr.count >0) {
            for (PersonJob *model in self.dataArr) {
                if ([model.nameJob isEqualToString:@"standard"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        employeeGraducationInstitution_ =  (int)[JobUtil chooseEmployeeFamilyRelation:[model.politicalStatus copy] andSelectedString:str1];
                        wself.employeeGraducationInstitution.text =str1;
                        //
                        wself.viewHide_1.hidden =YES;
                        wself.viewHide_2.hidden =YES;
                        wself.viewHide_3.hidden =YES;
                        wself.viewChangeHeight.constant =15;
                         wself.employeeheight.constant =1442 +48;
                        //不对
                        self.employeeStandCultureTextField.text =@"";
                        self.employeeMajor_ =@"-1";
                  
                        self.employeeTimeOfGraducation.text=@"";
                        if ([str1 isEqualToString:@"本科"]  || [str1 isEqualToString:@"硕士"]  ||  [str1 isEqualToString:@"博士"] || [str1 isEqualToString:@"大专"]) {

                            wself.viewHide_1.hidden =NO;
                            wself.viewHide_2.hidden =NO;
                            wself.viewHide_3.hidden =NO;
                            wself.viewChangeHeight.constant =261;
                             wself.employeeheight.constant =1688 +48;
                     
                        }

                            
                          
                    
                        
                        
                        
                    //
                    }];
                }
            }
        }
        
    }else if (sender == self.employeeTimeOfGraducation){
 
        
        //毕业时间
         __weak typeof(self) wself = self;
        [LYLDatePicker showDateDetermineChooseInView:self.view determineChoose:^(NSString *dateString) {
            dispatch_async(dispatch_get_main_queue(), ^{
                wself.employeeTimeOfGraducation.text = dateString;
            });
        }];
        
        
        
    }else if (sender == self.employeeOccupationQualificationDeGrade){
        //职业资格等级
  __weak typeof(self) wself = self;
        if (self.dataArr.count >0) {
            for (PersonJob *model in self.dataArr) {
                if ([model.nameJob isEqualToString:@"zhiyezige"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        employeeOccupationQualificationDeGrade_ =  (int)[JobUtil chooseEmployeeFamilyRelation:[model.politicalStatus copy] andSelectedString:str1];
                        wself.employeeOccupationQualificationDeGrade.text = str1;
                    }];
                }
            }
        }
        
        
    }else if (sender == self. employeePorfessionalQualification){
        if (self.dataArr.count >0) {
             __weak typeof(self) wself = self;
            for (PersonJob *model in self.dataArr) {
                if ([model.nameJob isEqualToString:@"zicheng_lv"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        employeePorfessionalQualification_ =  (int)[JobUtil chooseEmployeeFamilyRelation:[model.politicalStatus copy] andSelectedString:str1];
                         wself.employeePorfessionalQualification.text = str1;
                    }];
                }
            }
        }
        
    }else if (sender == self.  employeeMajor){

        __weak typeof(self) wself = self;
        if (self.dataArr.count >0) {
            for (PersonJob *model in self.dataArr) {
                if ([model.nameJob isEqualToString:@"education_major"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        wself.employeeMajor_ =  [JobUtil chooseEmployeeFamilyRelation_2:[model.politicalStatus copy] andSelectedString:str1];
                        wself.employeeMajor.text =str1;
                    }];
                }
            }
        }
        
    }else if (sender == self.  employeeOccupationQualification){
        __weak typeof(self) wself = self;
//        if (self.dataArr.count >0) {
//            for (PersonJob *model in self.dataArr) {
//                if ([model.nameJob isEqualToString:@"workertype"]) {
//                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
//                        wself.employeeOccupationQualification_ =  [JobUtil chooseEmployeeFamilyRelation_2:[model.politicalStatus copy] andSelectedString:str1];
//                        wself.employeeOccupationQualification.text =str1;
//                    }];
//                }
//            }
//        }
        if (self.workTypeArray.count >0) {
            for (workTypeSelectionNSObject *model in self.workTypeArray) {
                if ([model.nameJob isEqualToString:@"type_work"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        if (str2) {
                            dispatch_async(dispatch_get_main_queue(), ^{
                                //看一下 name和province 和strg有没有值周一看一下
                                if (str1) {
                                    [wself downTownLogic_2:str1 andStringProvince:str1];
                                }
                            });
                        }
                    }];
                }
            }
        }
        
        
        
    }else if(sender == self.employeeProfessionTechnicalPosts){
        __weak typeof(self) wself = self;
        if (self.dataArr.count >0) {
            for (PersonJob *model in self.dataArr) {
                if ([model.nameJob isEqualToString:@"major_tachnology"]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        wself.employeeProfessionTechnicalPosts_ =  [JobUtil chooseEmployeeFamilyRelation_2:[model.politicalStatus copy] andSelectedString:str1];
                        wself.employeeProfessionTechnicalPosts.text =str1;
                    }];
                }
            }
        }
        
        
    }
    
    
    


}



-(void)downTownLogic_2:(NSString*)canshu andStringProvince:(NSString*)str{
    if (!canshu ) {
        return;    }
    __weak typeof(self) wself = self;
    __block NSString *blockCanshu  = canshu;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (self.workTypeArray.count >0) {
            for (workTypeSelectionNSObject *model in self.workTypeArray) {
                if ([model.nameJob isEqualToString:canshu]) {
                    [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                        
                        
                        //看一下 name和province 和strg有没有值周一看一下
                        if (self.dataArr.count > 0) {
                            for (PersonJob *model in self.dataArr) {
                                if ([model.nameJob isEqualToString:@"workertype"]) {     
                                    if (str1) {
                                        dispatch_async(dispatch_get_main_queue(), ^{
                                            wself.employeeOccupationQualification_ =  [JobUtil chooseEmployeeFamilyRelation_2:[model.politicalStatus copy] andSelectedString:str1];
                                            if (str1)
                                                wself.employeeOccupationQualification.text =  [NSString stringWithFormat:@"%@,%@",blockCanshu,str1];
                                        });
                                    }
                                    
                                }
                            }
                        }
                    }];
                    
                }
            }
            
        }
    });
}





//双次选择
-(void)downTownLogic:(NSArray*)strARRAY{

    if (self.dataArr.count >0) {
        __weak typeof(self) wself = self;
        for (PersonJob *model in self.dataArr) {
            if ([model.nameJob isEqualToString:@"shangcandengji"]) {
                [self.addressModel onlySelect:model.politicalStatus  Handle:^(NSString *str1, NSString *str2, NSError *error) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        if (strARRAY.count >0) {
                      NSString *str = [strARRAY componentsJoinedByString:@","];
                        wself.employeeGroupTextField.text = [str  stringByAppendingString:[NSString stringWithFormat:@",%@",str1]];
                        
                            NSString *mustTrueStr=    [JobUtil chooseEmployeeFamilyRelation_2:[model.politicalStatus copy] andSelectedString:str1];
                            if (mustTrueStr) {
                                wself.employeeGroup_ =[wself.employeeGroup_  stringByAppendingString:[NSString stringWithFormat:@":%@",mustTrueStr]];
                            }
                        }
                        
                      
 });
                }];
            }
        }
    }
}









#pragma mark - logicRun


-(void)sendCityToFirstInfornation:(chooseAddressViewController *)avc senderProvince:(NSString *)province senderDownTown:(NSString *)downTown senderArea:(NSString *)area senderVillage:(NSString *)village senderVillageCommit:(NSString *)villageCommite senderDoor:(NSString *)door
{
    if (![villageCommite isEqualToString:@""]) {
        self.employeeAddress.text =[NSString stringWithFormat:@"%@%@%@%@%@%@",province,downTown,area,village,villageCommite,door];
    }
    
    
}


-(void)dealloc
{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    
    
}
-(void)jiantingKeyBoard
{
 
    
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
    
}

#pragma mark ---- 根据键盘高度将当前视图向上滚动同样高度
///键盘显示事件
- (void)keyboardWillShow:(NSNotification *)notification {
    //获取键盘高度，在不同设备上，以及中英文下是不同的
    CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
    
    //计算出键盘顶端到inputTextView panel底端的距离(加上自定义的缓冲距离INTERVAL_KEYBOARD)
    CGFloat offset = kbHeight;
    
    // 取得键盘的动画时间，这样可以在视图上移的时候更连贯
    double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    
    //将视图上移计算好的偏移
    if(offset > 0) {
        [UIView animateWithDuration:duration animations:^{
            self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
        }];
    }
}

#pragma mark ---- 当键盘消失后，视图需要恢复原状
///键盘消失事件
- (void)keyboardWillHide:(NSNotification *)notify {
    // 键盘动画时间
    double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    //视图下沉恢复原状
    [UIView animateWithDuration:duration animations:^{
        self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    }];
}
#pragma mark - 最后一步访问下一个页面
- (IBAction)nextPageNext:(id)sender {
        if ([self.employeeAddress.text isEqualToString:@""]) {
            [SVProgressHUD showErrorWithStatus:@"信息没有填写完整"];
            return ;
            
        }
    if ([self.EmployeePliticsStatusTextField.text isEqualToString:@""]) {
        [SVProgressHUD showErrorWithStatus:@"信息没有填写完整"];
        return ;
        
    }
    if ([self.employeeGroupTextField.text isEqualToString:@""]) {
        [SVProgressHUD showErrorWithStatus:@"信息没有填写完整"];
        return ;
        
    }
    if ([self.employeeGraducationInstitution.text isEqualToString:@""]) {
        [SVProgressHUD showErrorWithStatus:@"信息没有填写完整"];
        return ;
        
    }
    if ([self.employeeGraducationInstitution.text isEqualToString:@"本科"]  || [self.employeeGraducationInstitution.text isEqualToString:@"硕士"]  ||  [self.employeeGraducationInstitution.text isEqualToString:@"博士"] || [self.employeeGraducationInstitution.text isEqualToString:@"大专"]) {
            if ([self.employeeMajor.text isEqualToString:@""]) {
                [SVProgressHUD showErrorWithStatus:@"请填写毕业院校、所学专业、毕业时间"];
                return ;
        
            }
            if ([self.employeeTimeOfGraducation.text isEqualToString:@""]) {
            [SVProgressHUD showErrorWithStatus:@"请填写毕业院校、所学专业、毕业时间"];
                return ;
        
            }
        if ([self.employeeStandCultureTextField.text isEqualToString:@""]) {
            [SVProgressHUD showErrorWithStatus:@"请填写毕业院校、所学专业、毕业时间"];
            return ;
            
        }
    }
    
    
    //两个时间不是必须填写
    

    
    NSLog(@"%@",(NSString*)self.employeeGroup_);
   
    JobUtil *jobUtil =[[JobUtil alloc]init];
    [SVProgressHUD show];
    [PersonGatherJobNetManager  getUserAdddBaseId:[[NSUserDefaults standardUserDefaults] integerForKey:@"jobBaseID"]
                                        andIDCard:[[NSUserDefaults standardUserDefaults] objectForKey:@"jobPersonID"]
                              andIsSocialSecurity:socialKK
                            andsocialSecurityCard:[jobUtil netStrNull:self.employeeCard]
                                 andIscardPicPure:@"asd"//没有用
                                     andEducation:employeeGraducationInstitution_
                               andgradudctionTime:[JobUtil onlyNumber:self.employeeTimeOfGraducation.text]
                              andgraduationSchool:[jobUtil netStrNull:self.employeeStandCultureTextField]
                                         andMajor: [JobUtil netStrNull_2:self.employeeMajor_]
                                        andHoster:self.employeeFamily.text
                                    andHostIdcard:[jobUtil netStrNull:self.employeeFamilyId]
                              andrelateHosterType:employeeFamilyRelation_
                              andPoliticalOutLook:EmployeePliticsStatus_
                             andRegisterResidence:cityKK
                             andhouseholdRegister:[jobUtil netStrNull:self.employeeAddress]
                                     andGroupType:self.employeeGroup_
                                         andSkill:[JobUtil netStrNull_2:self.employeeOccupationQualification_]//[jobUtil netStrNull:self.employeeOccupationQualification]
                                    andSkillGrade:employeeOccupationQualificationDeGrade_
                                    andTechnology:[JobUtil netStrNull_2:self.employeeProfessionTechnicalPosts_] //[jobUtil netStrNull:self.employeeProfessionTechnicalPosts]
                                andTechnongyGrade:employeePorfessionalQualification_
                                      andProvonce:@"上海市"
                                          andCity:@"市辖区"
                                       andCountry:@"浦东新区"
                                          andTown:@"张江镇"
                                 anddetailAddress:@"田园"
                                 andNeverEmployedtype:employeeOther_
                                       andJobInKK:jobInKK
                                 completionHandle:^(PersonJob *model, NSError *error) {
                                     [SVProgressHUD dismiss];
                                     
                                     if (error) {
                                         [SVProgressHUD showErrorWithStatus:@"网络状态不佳"];
                                         return;
                                     }
                                     if (model.state == 9999) {
                                         [SVProgressHUD showErrorWithStatus:@"此地区暂未开通"];
                                         return;
                                     }
                                     
                                     
                                     
                                     if (model.state == 0 ) {
                                         
                                         
                                         if (jobInKK == 1) {
                                             //就业中...
                                             ThirdPersonInformationViewController *secondVC =   [ThirdPersonInformationViewController sharedInstance];
                                             
                                             if(![self.navigationController.topViewController isKindOfClass:[secondVC class]]) {
                                                 
                                                 [self.navigationController pushViewController:secondVC animated:YES];
                                             }
                                             
                                             
                                         }else if(jobInKK == 2){
                                //失业中...
                                             FourthlyViewController *secondVC =   [FourthlyViewController sharedInstance];
                                             if(![self.navigationController.topViewController isKindOfClass:[secondVC class]]) {
                                                 
                                                 [self.navigationController pushViewController:secondVC animated:YES];
                                             }
                                         }else{
                                    //其他...->替换成需求信息
//                                             FourthlyViewController *secondVC =   [FourthlyViewController sharedInstance];
//                                             if(![self.navigationController.topViewController isKindOfClass:[secondVC class]]) {
//
//                                                 [self.navigationController pushViewController:secondVC animated:YES];
//                                             }
                                             
                                             
                                             
//                                             UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
//                                             signatureNameViewController *name =[sb instantiateViewControllerWithIdentifier:@"signatureNameViewController"];
//                                             name.selfSignation =@"本人签字";
//                                             name.shiye =@"其他";
//                                             name.asdasdasfdsg=employeeOther_;
//                                             if(![self.navigationController.topViewController isKindOfClass:[name class]]) {
//                                                 [self.navigationController  pushViewController:name animated:YES];
//                                             }
                                             
                                             FirthlyViewController*secondVC =   [FirthlyViewController sharedInstance];
                                             secondVC.employeeOther_ = employeeOther_;
                                             secondVC.chooseThreeDifferent =@"";
                                             if(![self.navigationController.topViewController isKindOfClass:[secondVC class]]) {
                                                 
                                                 [self.navigationController pushViewController:secondVC animated:YES];
                                             }
                                             
                                             
                                             
                                         }
                                     }else{
                                         codeSelected *code = [codeSelected MustTakeReturn:model.state];
                                         [code returnCodeMethod];
                                         return;
                                     }
                                 }];
    

}


@end
