| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470 |
- //
- // JLChangeClassVC.m
- // shiku_im
- //
- // Created by liyangyang-pc on 17/1/17.
- // Copyright © 2017年 Reese. All rights reserved.
- //
- #import "JLChangeClassVC.h"
- #import "JLAddSelectSettingCell.h" //显示时间日期 班次
- #import "JLClassModel.h" //自定义的
- #import "JLTimeAttendanceSettingVC.h" //考勤时间设置
- #import "JLGetWeekDayVC.h" //选择考勤星期
- #import "JLGetPersonSVC.h"//选择参与人员
- #import "JOSettingSelectDepartVC.h" //选择参与部门
- #import "JONodeModel.h"//节点模型
- #import "JOEmployeeModel.h"
- #import "MJExtension.h"
- #import "JLConflictPersonnel.h" /*冲突人员界面*/
- #import "JLCONPersonalModel.h"
- #import "JLCalendarSelectSchduleVC.h"
- #import "UITextField+extension.h"
- @interface JLChangeClassVC ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UIAlertViewDelegate>
- {
- UIButton *TJButton; //保存按钮
-
- NSMutableArray * _pushWithArray;//选择人员时带入一个部门数组
- }
- @property (strong , nonatomic) UITableView *tableView;
- @property (strong , nonatomic) UITextField *nameClassTextField;
- @property (strong , nonatomic) NSMutableArray *dataArr;
- @property (strong , nonatomic) NSMutableArray *ConPersonArr;/*冲突员工*/
- @property (strong , nonatomic) NSMutableArray *ConDepArr;/*冲突部门*/
- @property (strong , nonatomic) JLSchedulingModel *SCHModel;
- @end
- @implementation JLChangeClassVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- _ConDepArr = [NSMutableArray array];
- _ConPersonArr = [NSMutableArray array];
-
-
- _pushWithArray=[[NSMutableArray alloc]init];
-
- switch (_type) {
- case work_add_Sch:
- {
- self.title = Localized(@"UU_work_OA_PC_SchedulingSetting_addShift");
- _model = [[JLSchedulingModel alloc] init];
- _model.wd_offdutyone = @"";
- _model.wd_ondutyone = @"";
- _model.wd_day = @"";
- _model.wd_earlytime = @"";
- _model.wd_offdutythree = @"";
- _model.wd_ondutythree= @"";
- _model.wd_offdutytwo= @"";
- _model.wd_ondutytwo = @"";
- _model.id = @"";
- _model.wd_name = @"";
- _model.wd_code = @"";
- _model.emcodes = @"";
- _model.emdefaultorcodes = @"";
- _model.emdefaultors = @"";
- _model.emnames = @"";
- _model.wd_id = @"";
-
- NSArray *dateArr = @[@"",Localized(@"UU_custom_pleaseSelectMust"),Localized(@"UU_custom_pleaseSelectMust"),Localized(@"UU_custom_pleaseSelectNotMust"),Localized(@"UU_custom_pleaseSelectNotMust")];
-
-
- _dataArr = [NSMutableArray arrayWithArray:dateArr];
- }
- break;
- case work_change_Sch:{
- SLog(@"11111%@",_model.wd_code);
- SLog(@"11111%@",_model.id);
- [self getdataeaa];
- self.title = Localized(@"UU_work_OA_PC_SchedulingSetting_change");;
- _SCHModel = [[JLSchedulingModel alloc] init];
- _SCHModel.emdefaultorcodes = _model.emdefaultorcodes;
- _SCHModel.emcodes = _model.emcodes;
- }
- break;
-
- default:
- break;
- }
- [self setNavi];
- [self setTableView];
- [self setbaocun];
- }
- - (void)setbaocun
- {
- TJButton = [UIButton sureButtonWithTitle:Localized(@"UU_custom_save")];
-
- TJButton.frame =CGRectMake(20, self_height-65, SCREEN_WIDTH - 40, 35);
-
-
-
- [TJButton addTarget:self action:@selector(saveAction) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:TJButton];
-
- [TJButton mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.view).offset(20);
- make.right.equalTo(self.view).offset(-20);
- make.bottom.equalTo(self.view).offset(-30);
- make.height.mas_equalTo(40);
-
- }];
-
- }
- #pragma mark -- 保存数据之前上传冲突人员,冲突部门
- - (void)getConfitPersonAndDefaultorcode
- {
-
- SLog(@"%@",_model.emcodes);
- SLog(@"%@",_model.emdefaultorcodes);
- NSString *emcode;
- NSString *emdefaultercode;
- if (_model.emcodes.length == 0) {
- emcode = @"";
- }else{
- emcode= _model.emcodes;
- }
- if (_model.emdefaultorcodes.length == 0) {
- emdefaultercode = @"";
- }else{
- emdefaultercode = _model.emdefaultorcodes;
- }
-
-
-
-
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:FORMAT(@"%@",emcode),@"wd_emcode",
- FORMAT(@"%@",emdefaultercode),@"wd_defaultorcode",
- nil];
-
- NSString *formStore = [NSString dictionaryToJson:dic];
- NSDictionary *forms = [NSDictionary dictionaryWithObjectsAndKeys:formStore,@"formStore", nil];
-
-
- [MBProgressHUD showMessage:@"" toView:self.view];
-
- [LYHTTPRequest Post:KQin_Confilt_personDepartMent page:forms Completion:^(id ObjectData, NSError *error) {
- if (error == nil){
-
- #pragma mark -- 如果没有冲突人员
- DLog(@"%@",ObjectData);
- /*冲突员工*/
- [_ConDepArr removeAllObjects];
- [_ConPersonArr removeAllObjects];
-
- NSArray *personArr = ObjectData[@"listdata"][0][@"man"];
- if (personArr.count != 0) {
-
- for (NSDictionary *dic in personArr) {
-
- JLCONPersonalModel *model = [JLCONPersonalModel mj_objectWithKeyValues:dic];
- NSArray *arr = [_SCHModel.emcodes componentsSeparatedByString:@","];
- int a1a = 0;
- for (NSString *str in arr) {
- if ([str isEqualToString:model.ew_emcode]) {
-
- a1a++;
- }
-
- }
- if (a1a == 0) {
-
- if (model.workdatename.length != 0 && model.em_name.length != 0) {
- [_ConPersonArr addObject:model];
- }
-
- }
- }
- }
- /*冲突部门*/
-
- NSArray *depArr = ObjectData[@"listdata"][1][@"defaultor"];
- if (depArr.count != 0) {
- for (NSDictionary *dic in depArr) {
-
-
-
- JLCONPersonalModel *model = [JLCONPersonalModel mj_objectWithKeyValues:dic];
-
- NSArray *arr = [_SCHModel.emdefaultorcodes componentsSeparatedByString:@","];
- int a1a = 0;
- for (NSString *str in arr) {
- if ([str isEqualToString:model.conflictem_defaultorcode]) {
-
- a1a++;
- }
-
- }
- if (a1a == 0) {
-
- if (model.workdatesname.length != 0 && model.conflictem_defaultorname.length != 0) {
- [_ConDepArr addObject:model];
- }
-
- }
-
- }
-
- }
-
-
-
- [self getdataeaa];
-
- [self.tableView reloadData];
-
-
-
-
- [MBProgressHUD hideHUDForView:self.view];
- [MBProgressHUD hideHUD];
-
- // [self saveAction];
-
- }else{
- [self getdataeaa];
- [self.tableView reloadData];
- [MBProgressHUD hideHUDForView:self.view];
- [MBProgressHUD hideHUD];
- // if (error.code==-1009)
- // {
- // [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
- // }else if (error.code==-1001)
- // {
- // [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
- // }
- //
- // else{
- // [JOShowMessageFromNavi showDropViewWithMessage:@"获取冲突人员和部门数据失败" ToNavi:self.navigationController withColor:nil];
- //
- // }
-
-
-
-
- }
-
-
-
- }];
- }
- #pragma mark - uiAlertviewDelegate
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (alertView.tag == 9991) {
- if (buttonIndex == 0) {
- [self saveAndUpdate];
- }
- }
-
- }
- #pragma mark -- 保存更新数据
- - (void)saveAction
- {
- /* wd_id ID
- wd_code 班次编号
- wd_name 班次名称
- wd_ondutyone 开始时间1
- wd_offdutyone 结束时间1
- wd_ondutytwo 开始时间2
- wd_offdutytwo 结束时间2
- wd_ondutythree 开始时间3
- wd_offdutythree 结束时间3
- wd_earlytime 最早打卡时间-------------number
- wd_day 考勤星期
- emcodes 参与人员编号
- emdefaultorcodes 参与部门编号
-
- */
- if (_ConPersonArr.count != 0 || _ConDepArr.count != 0) {
-
-
- [UASAlertView showWithTitle:nil content:Localized(@"UU_work_OA_PC_SchedulingSetting_title9") sureTitle:Localized(@"UU_custom_sure") cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
- if (index == 2) {
- [self saveAndUpdate];
- }
-
- }];
- }else{
-
- [self saveAndUpdate];
- }
-
-
-
-
-
-
- }
- #pragma mark -- 保存或更新班次
- - (void)saveAndUpdate
- {
- NSDate *date = [NSDate date];
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
-
-
- [formatter setDateStyle:NSDateFormatterMediumStyle];
-
- [formatter setTimeStyle:NSDateFormatterShortStyle];
-
- [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
- NSString *DateTime = [formatter stringFromDate:date];
-
- #pragma mark --获取人数
-
-
- #pragma mark -- renshu
- _model.wd_pcount = FORMAT(@"%lu", (unsigned long)[_model.wd_code componentsSeparatedByString:@","].count);
- // _model.wd_pcount = @"1";
- if (_model.wd_name.length == 0)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title5") ToNavi:self.navigationController withColor:nil];
-
- return;
- }
-
- if (_model.wd_day.length==0)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title6") ToNavi:self.navigationController withColor:nil];
-
- return;
- }
-
- if (_model.wd_ondutyone.length==0)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title7") ToNavi:self.navigationController withColor:nil];
-
- return;
- }
-
- NSString *emcode = @"";
- NSString *defaultcode = @"";
-
- if (_model.emcodes.length > 0) {
- NSArray *emcodeArr = [_model.emcodes componentsSeparatedByString:@","];
- NSMutableArray *emcodeArray = [NSMutableArray array];
- for (NSInteger i = 0; i < emcodeArr.count; i ++) {
- [emcodeArray addObject:FORMAT(@"\'%@\'",emcodeArr[i])];
-
- }
- emcode = [emcodeArray componentsJoinedByString:@","];
- }
- if (_model.emdefaultorcodes.length > 0) {
- NSArray *emcodeArr = [_model.emdefaultorcodes componentsSeparatedByString:@","];
- NSMutableArray *emcodeArray = [NSMutableArray array];
- for (NSInteger i = 0; i < emcodeArr.count; i ++) {
- [emcodeArray addObject:FORMAT(@"\'%@\'",emcodeArr[i])];
-
- }
- defaultcode = [emcodeArray componentsJoinedByString:@","];
- }
- //
- _model.wd_degree = @"0";
- if (_model.wd_ondutytwo.length == 0) {
- _model.wd_degree = @"1";
- }else if (_model.wd_ondutytwo.length != 0 && _model.wd_ondutythree.length == 0 )
- {
-
- _model.wd_degree = @"2";
- }else if (_model.wd_ondutythree.length != 0)
- {
- _model.wd_degree = @"3";
-
- }
-
- SLog(@"%@ %@",_model.emcodes,_model.emnames);
- SLog(@"%@ %@",_model.emdefaultors,_model.emdefaultorcodes);
- SLog(@"%@ %@",_model.wd_earlytime,_model.wd_day);
- // NSString *idstr = @"";
- if (_model.id.length != 0) {
- _model.wd_id = _model.id;
- }
-
- if([_model.ifDefaultClass isEqualToString:@"1"])
- {
-
- emcode= @"";
- defaultcode = @"";
- _model.emnames = @"";
- _model.emdefaultors = @"";
- // _model.wd_day = @"";
- }
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:FORMAT(@"%@",_model.wd_id),@"wd_id",
- FORMAT(@"%@",_model.wd_code),@"wd_code",
- FORMAT(@"%@",_model.wd_name),@"wd_name",
- FORMAT(@"%@",_model.wd_ondutyone),@"wd_ondutyone",
- FORMAT(@"%@",_model.wd_offdutyone),@"wd_offdutyone",
- FORMAT(@"%@",_model.wd_ondutytwo),@"wd_ondutytwo",
- FORMAT(@"%@",_model.wd_offdutytwo),@"wd_offdutytwo",
- FORMAT(@"%@",_model.wd_ondutythree),@"wd_ondutythree",
- FORMAT(@"%@",_model.wd_offdutythree),@"wd_offdutythree",
- FORMAT(@"%@",_model.wd_earlytime),@"wd_earlytime",
- FORMAT(@"%@",_model.wd_day),@"wd_day",
- FORMAT(@"%@",emcode),@"wd_emcode",
- FORMAT(@"%@",DateTime),@"wd_recorddate",
- FORMAT(@"%@",defaultcode),@"wd_defaultorcode",
- FORMAT(@"%@",_model.wd_pcount),@"wd_pcount",
- FORMAT(@"%@",_model.emnames),@"wd_man",
- FORMAT(@"%@",_model.emdefaultors),@"wd_defaultor",
- FORMAT(@"%@",_model.wd_degree),@"wd_degree"
-
-
- ,nil];
-
- NSString *formStore = [NSString dictionaryToJson:dic];
- SLog(@"%@",formStore);
- NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"WorkDate",@"caller",
- g_master,@"master",
- g_sessionUser,@"sessionUser",
- g_sessionId,@"sessionId",
-
- formStore,@"formStore", nil];
-
-
- [MBProgressHUD showMessage:@"正在保存..."];
- if (self.type == work_add_Sch){//添加数据
- [LYHTTPRequest Post:KQin_schedulingSetting_save page:dic1 Completion:^(id ObjectData, NSError *error) {
- if (error == nil) {
- [MBProgressHUD hideHUDForView:self.view];
- [MBProgressHUD hideHUD];
- [self.navigationController popViewControllerAnimated:YES];
-
-
- }else{
- [MBProgressHUD hideHUDForView:self.view];
- [MBProgressHUD hideHUD];
- SLog(@"%@",error);
- if (error.code==-1009)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
- }else if (error.code==-1001)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
- }
-
- else if (error.code == -1011)
- {
- if(_nameClassTextField.text.length >20)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title1") ToNavi:self.navigationController withColor:nil];
- }else{
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title2") ToNavi:self.navigationController withColor:nil];
- }
- }
- else{
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_saveFaild") ToNavi:self.navigationController withColor:nil];
-
- }
-
- }
-
- }];
-
-
- }else{ //更新班次
- [LYHTTPRequest Post:KQin_schedulingSetting_update page:dic1 Completion:^(id ObjectData, NSError *error) {
- if (error == nil) {
- SLog(@"heihei%@",ObjectData);
- [MBProgressHUD hideHUDForView:self.view];
- [MBProgressHUD hideHUD];
- [self.navigationController popViewControllerAnimated:YES];
-
- }else{
- [MBProgressHUD hideHUDForView:self.view];
- [MBProgressHUD hideHUD];
- SLog(@"嘿嘿 %@",error);
- if (error.code==-1009)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
- }else if (error.code==-1001)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
- }
-
- else if (error.code == -1011)
- {
- if(_nameClassTextField.text.length >20)
- {
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title1") ToNavi:self.navigationController withColor:nil];
- }else{
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title2") ToNavi:self.navigationController withColor:nil];
- }
-
- }
- else{
- [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_saveFaild") ToNavi:self.navigationController withColor:nil];
-
- }
-
- }
-
- }];
-
-
-
- }
-
-
- }
- - (void)setNavi{
- UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
- btn2.frame = CGRectMake(0, 5, 22, 22);
- UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
- image.image = [UIImage imageNamed:@"icon_back_nor3"];
- [btn2 addSubview:image];
- [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
- self.navigationItem.leftBarButtonItems = @[bbi2];
- }
- - (void)backView
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)setTableView{
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 2, self_width, self_height) style:UITableViewStylePlain];
-
- _tableView.delegate=self;
- _tableView.dataSource=self;
- _tableView.backgroundColor = Color(235, 233, 233, 1.0);
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-
- [self.view addSubview:_tableView];
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- int a = 0;
- // if (_ConDepArr.count != 0) {
- // a ++;
- // }
- // if ( _ConPersonArr.count != 0) {
- // a ++;
- // }
- return 5 +a;
- }
- #pragma mark -- getData
- - (void)getdataeaa
- {
- /*进行为空操作的判断*/
- NSString *timeStr =nil;
- if ([[self getTimeString] containsString:@"0.0"]) {
-
- timeStr =Localized(@"UU_custom_pleaseSelectMust");
- }else{
-
- timeStr = [self getTimeString];
- }
- NSString *dayStr = nil;
- if ([self haveWeekDay:_model.wd_day].length == 0) {
- dayStr =Localized(@"UU_custom_pleaseSelectMust");
-
- }else{
- dayStr = [self haveWeekDay:_model.wd_day];
- }
- NSString *depStr = nil;
- if (_model.emdefaultors.length == 0) {
- depStr = Localized(@"UU_custom_pleaseSelectNotMust");
- }else{
-
- depStr = _model.emdefaultors;
- }
-
- NSString *manStr = nil;
- if (_model.emnames.length == 0) {
-
- manStr = Localized(@"UU_custom_pleaseSelectNotMust");
- }else{
- manStr = _model.emnames;
- }
- NSArray *dateArr = @[FORMAT(@"%@", _model.wd_name),FORMAT(@"%@",timeStr),FORMAT(@"%@",dayStr),FORMAT(@"%@",depStr),FORMAT(@"%@",manStr)];
- if (_dataArr.count != 0) {
- [_dataArr removeAllObjects];
- }
- _dataArr = [NSMutableArray arrayWithArray:dateArr];
- }
- - (NSString *)getAllTime
- {
- CGFloat aa = 0;
-
- if ([self getDateStartTime:_model.wd_ondutyone endTime:_model.wd_offdutyone]>=0) {
-
- aa = [self getDateStartTime:_model.wd_ondutyone endTime:_model.wd_offdutyone];
- }else{
-
- aa = 24.0 + [self getDateStartTime:_model.wd_ondutyone endTime:_model.wd_offdutyone];
- }
- CGFloat bb= 0;
- if ([self getDateStartTime:_model.wd_ondutytwo endTime:_model.wd_offdutytwo] >= 0) {
- bb = [self getDateStartTime:_model.wd_ondutytwo endTime:_model.wd_offdutytwo];
- }else{
- bb = 24.0 + [self getDateStartTime:_model.wd_ondutytwo endTime:_model.wd_offdutytwo];
-
- }
-
- CGFloat cc = 0;
-
- if ([self getDateStartTime:_model.wd_ondutythree endTime:_model.wd_offdutythree] >= 0) {
- cc = [self getDateStartTime:_model.wd_ondutythree endTime:_model.wd_offdutythree];
- }else{
-
- cc = 24 + [self getDateStartTime:_model.wd_ondutythree endTime:_model.wd_offdutythree];
- }
-
-
- return [[NSString stringWithFormat:@"%.2lf",aa+bb+cc] substringToIndex:[NSString stringWithFormat:@"%.2lf",aa+bb+cc].length-1];
-
- }
- #pragma mark --计算时间间隔
- - (CGFloat )getDateStartTime:(NSString *)startTime endTime:(NSString *)endTime
- {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"HH:mm"];
- NSDate *date1 = [formatter dateFromString:startTime];
- NSDate *date2 = [formatter dateFromString:endTime];
- NSTimeInterval aTimer = [date2 timeIntervalSinceDate:date1];
-
- int hour = (int)(aTimer/3600);
- int minute = (int)(aTimer - hour*3600)/60;
- CGFloat dural = hour + minute/60.0;
-
- return dural;
-
- }
- #pragma mark --获取时间段
- - (NSString *)getTimeString
- {
- NSString *str = nil;
- if (_model.wd_ondutytwo.length == 0) {
- str = [NSString stringWithFormat:@"%@-%@ %@小时",_model.wd_ondutyone,_model.wd_offdutyone,[self getAllTime]];
- }else if (_model.wd_ondutytwo.length != 0 && _model.wd_ondutythree.length == 0)
- {
-
- str = [NSString stringWithFormat:@"%@-%@ %@-%@ %@小时",_model.wd_ondutyone,_model.wd_offdutyone,_model.wd_ondutytwo,_model.wd_offdutytwo,[self getAllTime]];
-
- }else if (_model.wd_ondutythree.length != 0)
- {
- str = [NSString stringWithFormat:@"%@-%@ %@-%@ %@-%@ %@小时",_model.wd_ondutyone,_model.wd_offdutyone,_model.wd_ondutytwo,_model.wd_offdutytwo,_model.wd_ondutythree,_model.wd_offdutythree,[self getAllTime]];
-
- }
-
- return str;
- }
- #pragma mark -- 判断有周几
- - (NSString *)haveWeekDay:(NSString *)dateString
- {
- NSString *str = Localized(@"UU_custom_weekly");
- if(dateString.length == 0)
- {
-
- return @"";
- }
- if ([dateString containsString:@"1"]) {
- str = [str stringByAppendingFormat:@"一、"];
- }
- if ([dateString containsString:@"2"]) {
- str = [str stringByAppendingFormat:@"二、"];
- }
- if ([dateString containsString:@"3"]) {
- str = [str stringByAppendingFormat:@"三、"];
- }
- if ([dateString containsString:@"4"]) {
- str = [str stringByAppendingFormat:@"四、"];
- }
- if ([dateString containsString:@"5"]) {
- str = [str stringByAppendingFormat:@"五、"];
- }
- if ([dateString containsString:@"6"]) {
- str = [str stringByAppendingFormat:@"六、"];
- }
- if ([dateString containsString:@"7"]) {
- str = [str stringByAppendingFormat:@"日、"];
- }
-
- NSString *cccc = [str substringToIndex:[str length] - 1];
- return cccc;
-
-
- }
- - (NSString *)hadWeekDay:(NSString *)dateString
- {
- if (dateString.length == 0) {
- return @"";
- }
- NSString *str = @"";
- if ([dateString containsString:@"一"]) {
- str = [str stringByAppendingFormat:@"1,"];
- }
- if ([dateString containsString:@"二"]) {
- str = [str stringByAppendingFormat:@"2,"];
- }
- if ([dateString containsString:@"三"]) {
- str = [str stringByAppendingFormat:@"3,"];
- }
- if ([dateString containsString:@"四"]) {
- str = [str stringByAppendingFormat:@"4,"];
- }
- if ([dateString containsString:@"五"]) {
- str = [str stringByAppendingFormat:@"5,"];
- }
- if ([dateString containsString:@"六"]) {
- str = [str stringByAppendingFormat:@"6,"];
- }
- if ([dateString containsString:@"日"]) {
- str = [str stringByAppendingFormat:@"7,"];
- }
-
- NSString *cccc = [str substringToIndex:[str length] - 1];
- DLog(@"%@",cccc);
- return cccc;
-
-
- }
- #pragma mark -- 跳转到冲突人员界面
- -(void)ConPerAction
- {
-
- JLConflictPersonnel *vc = [[JLConflictPersonnel alloc] init];
-
- NSArray *arr1 = [_model.emnames componentsSeparatedByString:@","];
-
- NSArray *arr2 = [_model.emcodes componentsSeparatedByString:@","];
-
- NSMutableArray *arr11 = [NSMutableArray arrayWithArray:arr1];
- NSMutableArray *arr22 = [NSMutableArray arrayWithArray:arr2];
- NSMutableArray *arr33 = [NSMutableArray array];
- for (NSInteger i = 0; i < _ConPersonArr.count; i ++) {
- [arr33 addObject:_ConPersonArr[i]];
-
- }
-
- SLog(@"%ld",_ConPersonArr.count);
- vc.seletArr = _ConPersonArr;
- vc.type = Conflict_person;
- vc.title = Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictPerson3");
-
- [vc backname:^(NSMutableArray *arr){
-
- SLog(@"%ld",arr33.count);
- for (NSInteger i = 0; i < arr.count; i ++) {
-
- JLCONPersonalModel *model = arr[i];
- if ([arr33 containsObject:model]) {
-
- [arr33 removeObject:model];
- if ([arr11 containsObject:model.em_name]) {
- [arr11 removeObject:model.em_name];
- }
- if ([arr22 containsObject:model.ew_emcode]) {
- [arr22 removeObject:model.ew_emcode];
- }
-
-
-
- }
- [_ConPersonArr removeAllObjects];
-
-
-
- for (NSInteger i = 0; i <arr33.count; i ++) {
-
- [_ConPersonArr addObject:arr33[i]];
- }
-
- }
-
-
- _model.emnames = [arr11 componentsJoinedByString:@","];
- _model.emcodes = [arr22 componentsJoinedByString:@","];
-
-
-
- SLog(@"返回的数据 数 %ld",_ConPersonArr.count);
-
-
- [self getdataeaa];
- [_tableView reloadData];
-
- }];
-
- [self.navigationController pushViewController:vc animated:YES];
-
-
- }
- #pragma mark --跳转到冲突部门界面
- - (void)ConDepAction
- {
- JLConflictPersonnel *vc = [[JLConflictPersonnel alloc] init];
-
- NSArray *arr1 = [_model.emdefaultors componentsSeparatedByString:@","];
- NSArray *arr2 = [_model.emdefaultorcodes componentsSeparatedByString:@","];
- NSMutableArray *arr11 = [NSMutableArray arrayWithArray:arr1];
- NSMutableArray *arr22 = [NSMutableArray arrayWithArray:arr2];
- NSMutableArray *arr33 = [NSMutableArray array];
- for (NSInteger i = 0; i < _ConDepArr.count; i ++) {
- [arr33 addObject:_ConDepArr[i]];
-
- }
- vc.type = Confilct_departmet;
- vc.title = Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictDepartment3");
- vc.seletArr = _ConDepArr;
- int aa = 0;
- for (JLCONPersonalModel *model in _ConDepArr) {
-
- DLog(@" %d - %@ - %@",aa ++ ,model.conflictem_defaultorcode,model.conflictem_defaultorname);
- }
-
- [vc backname:^(NSMutableArray *arr) {
-
-
- for (NSInteger i = 0; i < arr.count; i ++) {
-
- JLCONPersonalModel *model = arr[i];
- if ([arr33 containsObject:model]) {
-
- [arr33 removeObject:model];
- if ([arr11 containsObject:model.conflictem_defaultorname]) {
- [arr11 removeObject:model.conflictem_defaultorname];
- }
- if ([arr22 containsObject:model.conflictem_defaultorcode]) {
- [arr22 removeObject:model.conflictem_defaultorcode];
- }
-
-
-
- }
- [_ConDepArr removeAllObjects];
-
-
-
- for (NSInteger i = 0; i <arr33.count; i ++) {
-
- [_ConDepArr addObject:arr33[i]];
- }
-
- }
-
-
- _model.emdefaultors = [arr11 componentsJoinedByString:@","];
- _model.emdefaultorcodes = [arr22 componentsJoinedByString:@","];
- [self getdataeaa];
-
- [_tableView reloadData];
- }];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSArray *nameArr = @[Localized(@"UU_work_OA_PC_MyAttendanceRules_ClassName"),Localized(@"UU_work_OA_PC_MyAttendanceRules_SchedulingTime"),Localized(@"UU_work_OA_PC_MyAttendanceRules_SchedulingDate"),Localized(@"UU_work_OA_PC_SchedulingSetting_ParticipatingDepartments"),Localized(@"UU_work_OA_PC_SchedulingSetting_ParticipatingPerson")];
-
-
-
- if (indexPath.row == 0) {
- static NSString *ID = @"status11";
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
- UIView *_bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 8)];
- _bgView.backgroundColor = BGB_COLOR;
- [cell.contentView addSubview:_bgView];
-
- UIView * _bgView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 45 +8 ,SCREEN_WIDTH, 8)];
-
-
- _bgView1.backgroundColor = BGB_COLOR;
- [cell.contentView addSubview:_bgView1];
-
-
- UILabel * _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 8, 150, 45)];
- _nameLabel.font =FONT_SIZE(14);
- _nameLabel.textColor = JLTEXT_COLOR;
- _nameLabel.text = nameArr[indexPath.row];
- [cell.contentView addSubview:_nameLabel];
-
-
-
-
- _nameClassTextField = [[UITextField alloc] initWithFrame:CGRectMake(self_width-190, 8, 170, 45)];
- _nameClassTextField.text =_dataArr[indexPath.row];
- _nameClassTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
- _nameClassTextField.adjustsFontSizeToFitWidth = YES;
- _nameClassTextField.textAlignment = NSTextAlignmentRight;
- _nameClassTextField.placeholder =Localized(@"UU_custom_pleaseInputMust");
- [_nameClassTextField setPlaceHolderColor:JLMOREN_TEXT_COLOR];
- _nameClassTextField.font = FONT_SIZE(10);
- _nameClassTextField.textColor = JLMOREN_TEXT_COLOR;
- _nameClassTextField.delegate = self;
-
- if ([_model.ifDefaultClass isEqualToString:@"1"]) {
-
- _nameClassTextField.enabled = NO;
- }else{
- _nameClassTextField.enabled = YES;
- }
-
- [cell.contentView addSubview:_nameClassTextField];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- cell.backgroundColor = BGKJ_COLOR;
-
- return cell;
-
-
-
-
-
-
- }else if(_ConDepArr.count != 0 && indexPath.row == 3){
- static NSString *ID = @"status1121";
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
- UILabel *_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 150, 44.2)];
- _nameLabel.font =FONT_SIZE(14);
- _nameLabel.textColor = JLTEXT_COLOR;
- [cell.contentView addSubview:_nameLabel];
-
- UILabel *_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width-200, 0, 200, 44.2)];
-
- _dateLabel.font = FONT_SIZE(10);
- _dateLabel.textAlignment = NSTextAlignmentRight;
- _dateLabel.textColor = JLMOREN_TEXT_COLOR;
- [cell.contentView addSubview:_dateLabel];
- _nameLabel.text = nameArr[indexPath.row];
- _dateLabel.text = _dataArr[indexPath.row];
-
- cell.backgroundColor = BGKJ_COLOR;
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 52, self_width, 40)];
- bgView.backgroundColor = BGB_COLOR;
- UILabel *nameLabel = [[UILabel alloc ]initWithFrame:CGRectMake(10, 3, self_width-10, 20)];
- nameLabel.textColor = Color(0, 122, 255, 1.0);
-
- nameLabel.font = FONT_SIZE(12);
- [bgView addSubview:nameLabel];
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.backgroundColor = [UIColor clearColor];
- btn.frame = CGRectMake(0, 0, self_width, 40);
- [bgView addSubview:btn];
- [cell.contentView addSubview:bgView];
- nameLabel.text = FORMAT(@"%@%lu%@",Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictDepartment1"),(unsigned long)_ConDepArr.count,Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictDepartment2"));
- [btn addTarget:self action:@selector(ConDepAction) forControlEvents:UIControlEventTouchUpInside];
-
- return cell;
-
-
- }else if (_ConPersonArr.count != 0 && indexPath.row == 4)
- {
- static NSString *ID = @"stat222";
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
- UILabel *_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 150, 44.2)];
- _nameLabel.font =FONT_SIZE(14);
- _nameLabel.textColor = JLTEXT_COLOR;
- [cell.contentView addSubview:_nameLabel];
-
- UILabel *_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width-200, 0, 170, 44.2)];
-
- _dateLabel.font = FONT_SIZE(10);
- _dateLabel.textAlignment = NSTextAlignmentRight;
- _dateLabel.textColor = JLMOREN_TEXT_COLOR;
- [cell.contentView addSubview:_dateLabel];
- _nameLabel.text = nameArr[indexPath.row];
- _dateLabel.text = _dataArr[indexPath.row];
-
- cell.backgroundColor = BGKJ_COLOR;
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 52, self_width, 40)];
- bgView.backgroundColor = BGB_COLOR;
- UILabel *nameLabel = [[UILabel alloc ]initWithFrame:CGRectMake(10, 3, self_width-10, 20)];
- nameLabel.textColor = Color(0, 122, 255, 1.0);
-
- nameLabel.font = FONT_SIZE(12);
- [bgView addSubview:nameLabel];
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.backgroundColor = [UIColor clearColor];
- btn.frame = CGRectMake(0, 0, self_width, 40);
- [bgView addSubview:btn];
- [cell.contentView addSubview:bgView];
- NSString *str = FORMAT(@"%@%lu%@",Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictPerson1"),(unsigned long)_ConPersonArr.count,Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictPerson2"));
- nameLabel.text = str;
-
- [btn addTarget:self action:@selector(ConPerAction) forControlEvents:UIControlEventTouchUpInside];
- return cell;
-
-
-
-
- }
- else{
-
- JLAddSelectSettingCell *cell = [JLAddSelectSettingCell cellWithTableView:tableView];
- cell.nameString = nameArr[indexPath.row];
- cell.dateString = _dataArr[indexPath.row];
- cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
-
-
- return cell;
-
- }
-
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.row == 0 ) {
- return 61;
- }else{
- // 存在人员 冲突
- if (_ConPersonArr.count != 0) {
-
- if (indexPath.row == 4) {
-
- return 45 +40;
- }
- }
- // 存在部门 冲突
- if (_ConDepArr.count != 0) {
-
- if (indexPath.row == 3) {
-
- return 45 +40;
- }
- }
- return 45;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:NO];
- if (indexPath.row == 0) {
-
- [_nameClassTextField becomeFirstResponder];
-
- }else{
- [_nameClassTextField resignFirstResponder];
-
- if (indexPath.row == 1) {
-
- JLTimeAttendanceSettingVC *vc = [[JLTimeAttendanceSettingVC alloc] init];
- if (self.model.wd_ondutyone.length == 0 && self.type == work_add_Sch) {
- self.model.wd_ondutyone = @"08:00";
- self.model.wd_offdutyone = @"12:00";
- self.model.wd_ondutytwo = @"13:30";
- self.model.wd_offdutytwo = @"18:00";
- }
-
- vc.model = self.model;
-
-
- [vc setBlock:^(JLSchedulingModel *model) {
-
- _model.wd_ondutyone = FORMAT(@"%@",model.wd_ondutyone);
- _model.wd_offdutyone = FORMAT(@"%@",model.wd_offdutyone);
- _model.wd_ondutytwo = FORMAT(@"%@",model.wd_ondutytwo);
- _model.wd_offdutytwo = FORMAT(@"%@",model.wd_offdutytwo);
- _model.wd_ondutythree = FORMAT(@"%@",model.wd_ondutythree);
- _model.wd_offdutythree = FORMAT(@"%@",model.wd_offdutythree);
-
- _model.wd_earlytime = FORMAT(@"%@",model.wd_earlytime);
- _model.tpye= @"";
- JLAddSelectSettingCell *cell = [tableView cellForRowAtIndexPath:indexPath];
-
- cell.dateString = [self getTimeString];
-
-
-
-
- }];
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- else if (indexPath.row == 2)
- {
- if (self.type == 0) {
- JLCalendarSelectSchduleVC *calendarVC = [[JLCalendarSelectSchduleVC alloc]initWithTitleString:@"选择日期" WithSelectTime:@"" WithType:@""];
-
- [[NSUserDefaults standardUserDefaults] setObject:@"single" forKey:@"trip"];
- calendarVC.model = self.model;
- [calendarVC setAirPlaneToDay:365 ToDateforString:nil]; //初始化
-
- [calendarVC passDate:^(NSMutableArray *array) {
-
- // [self.date1Btn setTitle:[NSString stringWithFormat:@"%@-%@",[array[0] toString],[array[0] getWeek] ] forState:UIControlStateNormal];
- //
- // [self.date2Btn setTitle:[NSString stringWithFormat:@"%@-%@",[array[1] toString],[array[1] getWeek] ] forState:UIControlStateNormal];
-
- }];
-
- [self.navigationController pushViewController:calendarVC animated:YES];
-
-
- }else{
-
-
- JLGetWeekDayVC *vc = [[JLGetWeekDayVC alloc] init];
-
- vc.weekDayString = _model.wd_day;
- [vc setBlcok:^(NSString *str){
- JLAddSelectSettingCell *cell = [tableView cellForRowAtIndexPath:indexPath];
-
- if (str.length == 0) {
- cell.dateString =Localized(@"UU_custom_pleaseSelectMust");
- }else{
- cell.dateString = str;
- }
-
-
-
-
-
- _model.wd_day = [self hadWeekDay:str];
-
-
-
- }];
-
- [self.navigationController pushViewController:vc animated:YES];
- }
-
- }
- #pragma mark -- 参加部门
- else if ( indexPath.row == 3){
-
- if ([_model.ifDefaultClass isEqualToString:@"1"]) {
-
- UIAlertView *view = [[UIAlertView alloc] initWithTitle:Localized(@"UU_custom_UU") message:Localized(@"UU_work_OA_PC_SchedulingSetting_title3") delegate:self cancelButtonTitle:Localized(@"UU_custom_sure") otherButtonTitles:nil, nil];
- view.tag =22222;
- [view show];
-
-
- }else{
- [_pushWithArray removeAllObjects];
- JOSettingSelectDepartVC *vc = [[JOSettingSelectDepartVC alloc] init];
-
-
- if (_model.emdefaultorcodes.length != 0) {
- NSArray * arr=[_model.emdefaultorcodes componentsSeparatedByString:@","];
- vc.selectedArr=[[NSMutableArray alloc]initWithArray:arr];
- }else{
- vc.selectedArr = [NSMutableArray array];
-
- }
-
-
- //DLog(@"%@",vc.selectedArr);
-
-
- vc.blcok=^(NSMutableArray * array){
-
-
- NSString *Codestr = @"";
- NSString *NameStr = @"";
- JLAddSelectSettingCell *cell = [tableView cellForRowAtIndexPath:indexPath];
-
-
- if (array.count == 0) {
-
-
-
- _model.emdefaultorcodes =@"";
- _model.emdefaultors = @"";
- //承接数组
- }else{
-
- for (int i=0; i<array.count; i++)
- {
- JONodeModel * model=array[i];
- DLog(@"%@ %@",model.nodeCode,model.selfName);
-
- NameStr = [NameStr stringByAppendingFormat:@"%@,",model.selfName];
-
- Codestr = [Codestr stringByAppendingFormat:@"%@,",model.depCode];
-
-
- }
-
-
- NSString *cccc = [NameStr substringToIndex:[NameStr length] - 1];
- NSString *bbbb = [Codestr substringToIndex:[Codestr length] - 1];
-
- SLog(@"%@",cccc);
-
- if (_ConDepArr.count == 0) {
- cell.dateString = cccc;
- }
-
- _model.emdefaultorcodes = bbbb;
- _model.emdefaultors = cccc;
- //承接数组
- [_pushWithArray removeAllObjects];
- _pushWithArray=[[NSMutableArray alloc]initWithArray:array];
-
-
-
-
- }
- __weak typeof(self) weakSelf = self;
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf getConfitPersonAndDefaultorcode];
- });
- };
-
-
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- #pragma mark -- 参加人员
- else if (indexPath.row == 4)
- {
-
- #pragma mark -- 选择冲突人员
-
-
- if ([_model.ifDefaultClass isEqualToString:@"1"]) {
-
- UIAlertView *view = [[UIAlertView alloc] initWithTitle:Localized(@"UU_custom_UU") message:Localized(@"UU_work_OA_PC_SchedulingSetting_title8") delegate:self cancelButtonTitle:Localized(@"UU_custom_sure") otherButtonTitles:nil, nil];
- view.tag =222221;
- [view show];
- }else{
-
- JLGetPersonSVC *vc = [[JLGetPersonSVC alloc] init];
- vc.title = Localized(@"UU_work_OA_PC_SS_ParticipatingPerson_selectPerson");
-
-
- vc.siftArr=_pushWithArray;
- if (_model.emcodes.length != 0) {
- vc.emcodeArr = [_model.emcodes componentsSeparatedByString:@","];
-
- }
-
-
- [vc backname:^(NSMutableArray *arr,NSMutableArray * brr) {
-
- DLog(@"拿回来的是人名嘛%@",arr);
- DLog(@"拉回来的事ID吗%@",brr);
- if (arr.count>=1)
- {
- NSString * str=@"";
- NSString * str2=@"";
- for (int i=0; i<arr.count; i++)
- {
- str=[[str stringByAppendingString:@","] stringByAppendingString:arr[i]];
-
- str2=[[str2 stringByAppendingString:@","] stringByAppendingString:brr[i]];
-
- }
- SLog(@"%@",str);
-
- str=[str substringFromIndex:1];
- str2=[str2 substringFromIndex:1];
-
-
- //
-
- _model.emcodes = str2;
- _model.emnames = str;
-
-
- DLog(@"处理过后呢%@",str2);
-
-
- }else if (arr.count==1){
-
-
- _model.emcodes = brr[0];
- _model.emnames = arr[0];
-
-
- }else{
-
- _model.emcodes = @"";
- _model.emnames = @"";
-
- }
-
- __weak typeof(self) weakSelf = self;
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf getConfitPersonAndDefaultorcode];
- });
-
-
- }];
-
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- }
-
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- [_nameClassTextField resignFirstResponder];
- }
- #pragma mark - UITextfiledDelegate
- - (void)textFieldDidEndEditing:(UITextField *)textField
- {
- _model.wd_name = _nameClassTextField.text;
-
-
- }
- - (void)textFieldDidBeginEditing:(UITextField *)textField
- {
- _model.wd_name = _nameClassTextField.text;
- }
- - (void)getNumberPersonCompleted:(void(^)(NSString *str))completed
- {
- NSString * companyName=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_function"];
- companyName=[companyName stringByReplacingOccurrencesOfString:@"(" withString:@""];
- companyName=[companyName stringByReplacingOccurrencesOfString:@")" withString:@""];
-
-
- [self selectTablewithtableName:TONGXUNLUDATA completed:^(NSArray *arr) {
-
- NSArray *arr1 = [_model.emdefaultors componentsSeparatedByString:@","];
-
- NSArray *arr2 = [_model.emcodes componentsSeparatedByString:@","];
- int ii = 0;
-
- for (NSInteger i = 0; i < arr.count ; i ++) {
-
- JOEmployeeModel *model = arr[i];
- for (NSInteger j = 0; j < arr1.count; j ++) {
-
- if ([model.EM_DEFAULTORNAME isEqualToString:arr1[j]] ) {
-
- ii += 1;
- }
- }
-
- for (NSInteger j = 0; j < arr2.count; j ++) {
-
- if ([model.EM_CODE isEqualToString:arr2[j]]) {
- ii += 1;
- }
- }
- }
-
- if (completed) {
-
- completed(FORMAT(@"%d",ii));
-
- }
-
- }];
- }
- #pragma mark --
- -(void)selectTablewithtableName:(NSString *)tableName completed:(void(^)(NSArray *arr))completed{
-
- [[TIFmdbManager shareManager] createOrOpenDatabasaWithDbName:TONGXUNLUDATA completed:^(BOOL result) {
-
- if (result) {
-
- NSMutableArray *dataArr = [NSMutableArray new];
-
- [[TIFmdbManager shareManager] executeWithDb:TONGXUNLUDATA excuteDbBlock:^(FMDatabase *db) {
-
- NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@",tableName];
- FMResultSet *rs = [db executeQuery:sql];
-
- while ([rs next])
- {
- JOEmployeeModel *model1 = [[JOEmployeeModel alloc] init];
-
- model1.EM_ID = [rs intForColumn:_em_id];
- model1.EM_IMID = [rs intForColumn:_em_imid];
- model1.FLAG=[rs stringForColumn:_em_flag];
- model1.EM_DEFAULTORID=[rs intForColumn:_em_defaultorid];
- model1.EM_CODE = [rs stringForColumn:_em_code];
- model1.EM_NAME = [rs stringForColumn:_em_name];
- model1.EM_POSITION = [rs stringForColumn:_em_position];
- model1.EM_JOBS = [rs stringForColumn:_em_jobs];
- model1.EM_LASTDATE = [rs stringForColumn:_em_lastdate];
- model1.EM_DEFAULTORNAME = [rs stringForColumn:_em_defaultorname];
- model1.EM_DEPART = [rs stringForColumn:_em_depart];
- model1.EM_TEL = [rs stringForColumn:_em_tel];
- model1.EM_MOBILE = [rs stringForColumn:_em_mobile];
- model1.EM_EMAIL = [rs stringForColumn:_em_email];
- model1.EM_UU = [rs stringForColumn:_em_uu];
- model1.EM_IMAGEID = [rs stringForColumn:_em_iamgeid];
- model1.COMPANY = [rs stringForColumn:_company];
- model1.WHICHSYS = [rs stringForColumn:_whichsys];
-
- if ([model1.EM_CODE isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"]])
- {
- NSUserDefaults * str=[NSUserDefaults standardUserDefaults];
- [str setObject:[NSString stringWithFormat:@"%ld",(long)model1.EM_ID] forKey:@"jocanhuirenyuanziji"];
- }
-
-
- [dataArr addObject:model1];
- }
-
-
- } completed:^{
-
- if (completed) {
-
- completed(dataArr);
-
- }
-
- }];
-
- }
-
- }];
-
-
- }
- @end
|