JLChangeClassVC.m 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. //
  2. // JLChangeClassVC.m
  3. // shiku_im
  4. //
  5. // Created by liyangyang-pc on 17/1/17.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JLChangeClassVC.h"
  9. #import "JLAddSelectSettingCell.h" //显示时间日期 班次
  10. #import "JLClassModel.h" //自定义的
  11. #import "JLTimeAttendanceSettingVC.h" //考勤时间设置
  12. #import "JLGetWeekDayVC.h" //选择考勤星期
  13. #import "JLGetPersonSVC.h"//选择参与人员
  14. #import "JOSettingSelectDepartVC.h" //选择参与部门
  15. #import "JONodeModel.h"//节点模型
  16. #import "JOEmployeeModel.h"
  17. #import "MJExtension.h"
  18. #import "JLConflictPersonnel.h" /*冲突人员界面*/
  19. #import "JLCONPersonalModel.h"
  20. #import "JLCalendarSelectSchduleVC.h"
  21. #import "UITextField+extension.h"
  22. @interface JLChangeClassVC ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UIAlertViewDelegate>
  23. {
  24. UIButton *TJButton; //保存按钮
  25. NSMutableArray * _pushWithArray;//选择人员时带入一个部门数组
  26. }
  27. @property (strong , nonatomic) UITableView *tableView;
  28. @property (strong , nonatomic) UITextField *nameClassTextField;
  29. @property (strong , nonatomic) NSMutableArray *dataArr;
  30. @property (strong , nonatomic) NSMutableArray *ConPersonArr;/*冲突员工*/
  31. @property (strong , nonatomic) NSMutableArray *ConDepArr;/*冲突部门*/
  32. @property (strong , nonatomic) JLSchedulingModel *SCHModel;
  33. @end
  34. @implementation JLChangeClassVC
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. _ConDepArr = [NSMutableArray array];
  38. _ConPersonArr = [NSMutableArray array];
  39. _pushWithArray=[[NSMutableArray alloc]init];
  40. switch (_type) {
  41. case work_add_Sch:
  42. {
  43. self.title = Localized(@"UU_work_OA_PC_SchedulingSetting_addShift");
  44. _model = [[JLSchedulingModel alloc] init];
  45. _model.wd_offdutyone = @"";
  46. _model.wd_ondutyone = @"";
  47. _model.wd_day = @"";
  48. _model.wd_earlytime = @"";
  49. _model.wd_offdutythree = @"";
  50. _model.wd_ondutythree= @"";
  51. _model.wd_offdutytwo= @"";
  52. _model.wd_ondutytwo = @"";
  53. _model.id = @"";
  54. _model.wd_name = @"";
  55. _model.wd_code = @"";
  56. _model.emcodes = @"";
  57. _model.emdefaultorcodes = @"";
  58. _model.emdefaultors = @"";
  59. _model.emnames = @"";
  60. _model.wd_id = @"";
  61. NSArray *dateArr = @[@"",Localized(@"UU_custom_pleaseSelectMust"),Localized(@"UU_custom_pleaseSelectMust"),Localized(@"UU_custom_pleaseSelectNotMust"),Localized(@"UU_custom_pleaseSelectNotMust")];
  62. _dataArr = [NSMutableArray arrayWithArray:dateArr];
  63. }
  64. break;
  65. case work_change_Sch:{
  66. SLog(@"11111%@",_model.wd_code);
  67. SLog(@"11111%@",_model.id);
  68. [self getdataeaa];
  69. self.title = Localized(@"UU_work_OA_PC_SchedulingSetting_change");;
  70. _SCHModel = [[JLSchedulingModel alloc] init];
  71. _SCHModel.emdefaultorcodes = _model.emdefaultorcodes;
  72. _SCHModel.emcodes = _model.emcodes;
  73. }
  74. break;
  75. default:
  76. break;
  77. }
  78. [self setNavi];
  79. [self setTableView];
  80. [self setbaocun];
  81. }
  82. - (void)setbaocun
  83. {
  84. TJButton = [UIButton sureButtonWithTitle:Localized(@"UU_custom_save")];
  85. TJButton.frame =CGRectMake(20, self_height-65, SCREEN_WIDTH - 40, 35);
  86. [TJButton addTarget:self action:@selector(saveAction) forControlEvents:UIControlEventTouchUpInside];
  87. [self.view addSubview:TJButton];
  88. [TJButton mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.equalTo(self.view).offset(20);
  90. make.right.equalTo(self.view).offset(-20);
  91. make.bottom.equalTo(self.view).offset(-30);
  92. make.height.mas_equalTo(40);
  93. }];
  94. }
  95. #pragma mark -- 保存数据之前上传冲突人员,冲突部门
  96. - (void)getConfitPersonAndDefaultorcode
  97. {
  98. SLog(@"%@",_model.emcodes);
  99. SLog(@"%@",_model.emdefaultorcodes);
  100. NSString *emcode;
  101. NSString *emdefaultercode;
  102. if (_model.emcodes.length == 0) {
  103. emcode = @"";
  104. }else{
  105. emcode= _model.emcodes;
  106. }
  107. if (_model.emdefaultorcodes.length == 0) {
  108. emdefaultercode = @"";
  109. }else{
  110. emdefaultercode = _model.emdefaultorcodes;
  111. }
  112. NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:FORMAT(@"%@",emcode),@"wd_emcode",
  113. FORMAT(@"%@",emdefaultercode),@"wd_defaultorcode",
  114. nil];
  115. NSString *formStore = [NSString dictionaryToJson:dic];
  116. NSDictionary *forms = [NSDictionary dictionaryWithObjectsAndKeys:formStore,@"formStore", nil];
  117. [MBProgressHUD showMessage:@"" toView:self.view];
  118. [LYHTTPRequest Post:KQin_Confilt_personDepartMent page:forms Completion:^(id ObjectData, NSError *error) {
  119. if (error == nil){
  120. #pragma mark -- 如果没有冲突人员
  121. DLog(@"%@",ObjectData);
  122. /*冲突员工*/
  123. [_ConDepArr removeAllObjects];
  124. [_ConPersonArr removeAllObjects];
  125. NSArray *personArr = ObjectData[@"listdata"][0][@"man"];
  126. if (personArr.count != 0) {
  127. for (NSDictionary *dic in personArr) {
  128. JLCONPersonalModel *model = [JLCONPersonalModel mj_objectWithKeyValues:dic];
  129. NSArray *arr = [_SCHModel.emcodes componentsSeparatedByString:@","];
  130. int a1a = 0;
  131. for (NSString *str in arr) {
  132. if ([str isEqualToString:model.ew_emcode]) {
  133. a1a++;
  134. }
  135. }
  136. if (a1a == 0) {
  137. if (model.workdatename.length != 0 && model.em_name.length != 0) {
  138. [_ConPersonArr addObject:model];
  139. }
  140. }
  141. }
  142. }
  143. /*冲突部门*/
  144. NSArray *depArr = ObjectData[@"listdata"][1][@"defaultor"];
  145. if (depArr.count != 0) {
  146. for (NSDictionary *dic in depArr) {
  147. JLCONPersonalModel *model = [JLCONPersonalModel mj_objectWithKeyValues:dic];
  148. NSArray *arr = [_SCHModel.emdefaultorcodes componentsSeparatedByString:@","];
  149. int a1a = 0;
  150. for (NSString *str in arr) {
  151. if ([str isEqualToString:model.conflictem_defaultorcode]) {
  152. a1a++;
  153. }
  154. }
  155. if (a1a == 0) {
  156. if (model.workdatesname.length != 0 && model.conflictem_defaultorname.length != 0) {
  157. [_ConDepArr addObject:model];
  158. }
  159. }
  160. }
  161. }
  162. [self getdataeaa];
  163. [self.tableView reloadData];
  164. [MBProgressHUD hideHUDForView:self.view];
  165. [MBProgressHUD hideHUD];
  166. // [self saveAction];
  167. }else{
  168. [self getdataeaa];
  169. [self.tableView reloadData];
  170. [MBProgressHUD hideHUDForView:self.view];
  171. [MBProgressHUD hideHUD];
  172. // if (error.code==-1009)
  173. // {
  174. // [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  175. // }else if (error.code==-1001)
  176. // {
  177. // [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  178. // }
  179. //
  180. // else{
  181. // [JOShowMessageFromNavi showDropViewWithMessage:@"获取冲突人员和部门数据失败" ToNavi:self.navigationController withColor:nil];
  182. //
  183. // }
  184. }
  185. }];
  186. }
  187. #pragma mark - uiAlertviewDelegate
  188. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  189. {
  190. if (alertView.tag == 9991) {
  191. if (buttonIndex == 0) {
  192. [self saveAndUpdate];
  193. }
  194. }
  195. }
  196. #pragma mark -- 保存更新数据
  197. - (void)saveAction
  198. {
  199. /* wd_id ID
  200. wd_code 班次编号
  201. wd_name 班次名称
  202. wd_ondutyone 开始时间1
  203. wd_offdutyone 结束时间1
  204. wd_ondutytwo 开始时间2
  205. wd_offdutytwo 结束时间2
  206. wd_ondutythree 开始时间3
  207. wd_offdutythree 结束时间3
  208. wd_earlytime 最早打卡时间-------------number
  209. wd_day 考勤星期
  210. emcodes 参与人员编号
  211. emdefaultorcodes 参与部门编号
  212. */
  213. if (_ConPersonArr.count != 0 || _ConDepArr.count != 0) {
  214. [UASAlertView showWithTitle:nil content:Localized(@"UU_work_OA_PC_SchedulingSetting_title9") sureTitle:Localized(@"UU_custom_sure") cancelTitle:Localized(@"UU_custom_cancle") click:^(NSInteger index) {
  215. if (index == 2) {
  216. [self saveAndUpdate];
  217. }
  218. }];
  219. }else{
  220. [self saveAndUpdate];
  221. }
  222. }
  223. #pragma mark -- 保存或更新班次
  224. - (void)saveAndUpdate
  225. {
  226. NSDate *date = [NSDate date];
  227. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  228. [formatter setDateStyle:NSDateFormatterMediumStyle];
  229. [formatter setTimeStyle:NSDateFormatterShortStyle];
  230. [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
  231. NSString *DateTime = [formatter stringFromDate:date];
  232. #pragma mark --获取人数
  233. #pragma mark -- renshu
  234. _model.wd_pcount = FORMAT(@"%lu", (unsigned long)[_model.wd_code componentsSeparatedByString:@","].count);
  235. // _model.wd_pcount = @"1";
  236. if (_model.wd_name.length == 0)
  237. {
  238. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title5") ToNavi:self.navigationController withColor:nil];
  239. return;
  240. }
  241. if (_model.wd_day.length==0)
  242. {
  243. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title6") ToNavi:self.navigationController withColor:nil];
  244. return;
  245. }
  246. if (_model.wd_ondutyone.length==0)
  247. {
  248. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title7") ToNavi:self.navigationController withColor:nil];
  249. return;
  250. }
  251. NSString *emcode = @"";
  252. NSString *defaultcode = @"";
  253. if (_model.emcodes.length > 0) {
  254. NSArray *emcodeArr = [_model.emcodes componentsSeparatedByString:@","];
  255. NSMutableArray *emcodeArray = [NSMutableArray array];
  256. for (NSInteger i = 0; i < emcodeArr.count; i ++) {
  257. [emcodeArray addObject:FORMAT(@"\'%@\'",emcodeArr[i])];
  258. }
  259. emcode = [emcodeArray componentsJoinedByString:@","];
  260. }
  261. if (_model.emdefaultorcodes.length > 0) {
  262. NSArray *emcodeArr = [_model.emdefaultorcodes componentsSeparatedByString:@","];
  263. NSMutableArray *emcodeArray = [NSMutableArray array];
  264. for (NSInteger i = 0; i < emcodeArr.count; i ++) {
  265. [emcodeArray addObject:FORMAT(@"\'%@\'",emcodeArr[i])];
  266. }
  267. defaultcode = [emcodeArray componentsJoinedByString:@","];
  268. }
  269. //
  270. _model.wd_degree = @"0";
  271. if (_model.wd_ondutytwo.length == 0) {
  272. _model.wd_degree = @"1";
  273. }else if (_model.wd_ondutytwo.length != 0 && _model.wd_ondutythree.length == 0 )
  274. {
  275. _model.wd_degree = @"2";
  276. }else if (_model.wd_ondutythree.length != 0)
  277. {
  278. _model.wd_degree = @"3";
  279. }
  280. SLog(@"%@ %@",_model.emcodes,_model.emnames);
  281. SLog(@"%@ %@",_model.emdefaultors,_model.emdefaultorcodes);
  282. SLog(@"%@ %@",_model.wd_earlytime,_model.wd_day);
  283. // NSString *idstr = @"";
  284. if (_model.id.length != 0) {
  285. _model.wd_id = _model.id;
  286. }
  287. if([_model.ifDefaultClass isEqualToString:@"1"])
  288. {
  289. emcode= @"";
  290. defaultcode = @"";
  291. _model.emnames = @"";
  292. _model.emdefaultors = @"";
  293. // _model.wd_day = @"";
  294. }
  295. NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:FORMAT(@"%@",_model.wd_id),@"wd_id",
  296. FORMAT(@"%@",_model.wd_code),@"wd_code",
  297. FORMAT(@"%@",_model.wd_name),@"wd_name",
  298. FORMAT(@"%@",_model.wd_ondutyone),@"wd_ondutyone",
  299. FORMAT(@"%@",_model.wd_offdutyone),@"wd_offdutyone",
  300. FORMAT(@"%@",_model.wd_ondutytwo),@"wd_ondutytwo",
  301. FORMAT(@"%@",_model.wd_offdutytwo),@"wd_offdutytwo",
  302. FORMAT(@"%@",_model.wd_ondutythree),@"wd_ondutythree",
  303. FORMAT(@"%@",_model.wd_offdutythree),@"wd_offdutythree",
  304. FORMAT(@"%@",_model.wd_earlytime),@"wd_earlytime",
  305. FORMAT(@"%@",_model.wd_day),@"wd_day",
  306. FORMAT(@"%@",emcode),@"wd_emcode",
  307. FORMAT(@"%@",DateTime),@"wd_recorddate",
  308. FORMAT(@"%@",defaultcode),@"wd_defaultorcode",
  309. FORMAT(@"%@",_model.wd_pcount),@"wd_pcount",
  310. FORMAT(@"%@",_model.emnames),@"wd_man",
  311. FORMAT(@"%@",_model.emdefaultors),@"wd_defaultor",
  312. FORMAT(@"%@",_model.wd_degree),@"wd_degree"
  313. ,nil];
  314. NSString *formStore = [NSString dictionaryToJson:dic];
  315. SLog(@"%@",formStore);
  316. NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"WorkDate",@"caller",
  317. g_master,@"master",
  318. g_sessionUser,@"sessionUser",
  319. g_sessionId,@"sessionId",
  320. formStore,@"formStore", nil];
  321. [MBProgressHUD showMessage:@"正在保存..."];
  322. if (self.type == work_add_Sch){//添加数据
  323. [LYHTTPRequest Post:KQin_schedulingSetting_save page:dic1 Completion:^(id ObjectData, NSError *error) {
  324. if (error == nil) {
  325. [MBProgressHUD hideHUDForView:self.view];
  326. [MBProgressHUD hideHUD];
  327. [self.navigationController popViewControllerAnimated:YES];
  328. }else{
  329. [MBProgressHUD hideHUDForView:self.view];
  330. [MBProgressHUD hideHUD];
  331. SLog(@"%@",error);
  332. if (error.code==-1009)
  333. {
  334. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  335. }else if (error.code==-1001)
  336. {
  337. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  338. }
  339. else if (error.code == -1011)
  340. {
  341. if(_nameClassTextField.text.length >20)
  342. {
  343. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title1") ToNavi:self.navigationController withColor:nil];
  344. }else{
  345. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title2") ToNavi:self.navigationController withColor:nil];
  346. }
  347. }
  348. else{
  349. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_saveFaild") ToNavi:self.navigationController withColor:nil];
  350. }
  351. }
  352. }];
  353. }else{ //更新班次
  354. [LYHTTPRequest Post:KQin_schedulingSetting_update page:dic1 Completion:^(id ObjectData, NSError *error) {
  355. if (error == nil) {
  356. SLog(@"heihei%@",ObjectData);
  357. [MBProgressHUD hideHUDForView:self.view];
  358. [MBProgressHUD hideHUD];
  359. [self.navigationController popViewControllerAnimated:YES];
  360. }else{
  361. [MBProgressHUD hideHUDForView:self.view];
  362. [MBProgressHUD hideHUD];
  363. SLog(@"嘿嘿 %@",error);
  364. if (error.code==-1009)
  365. {
  366. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkDisconnect") ToNavi:self.navigationController withColor:nil];
  367. }else if (error.code==-1001)
  368. {
  369. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_networkTimeOut") ToNavi:self.navigationController withColor:nil];
  370. }
  371. else if (error.code == -1011)
  372. {
  373. if(_nameClassTextField.text.length >20)
  374. {
  375. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title1") ToNavi:self.navigationController withColor:nil];
  376. }else{
  377. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_work_OA_PC_SchedulingSetting_title2") ToNavi:self.navigationController withColor:nil];
  378. }
  379. }
  380. else{
  381. [JOShowMessageFromNavi showDropViewWithMessage:Localized(@"UU_custom_saveFaild") ToNavi:self.navigationController withColor:nil];
  382. }
  383. }
  384. }];
  385. }
  386. }
  387. - (void)setNavi{
  388. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  389. btn2.frame = CGRectMake(0, 5, 22, 22);
  390. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
  391. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  392. [btn2 addSubview:image];
  393. [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
  394. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  395. self.navigationItem.leftBarButtonItems = @[bbi2];
  396. }
  397. - (void)backView
  398. {
  399. [self.navigationController popViewControllerAnimated:YES];
  400. }
  401. - (void)setTableView{
  402. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 2, self_width, self_height) style:UITableViewStylePlain];
  403. _tableView.delegate=self;
  404. _tableView.dataSource=self;
  405. _tableView.backgroundColor = Color(235, 233, 233, 1.0);
  406. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  407. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  408. [self.view addSubview:_tableView];
  409. }
  410. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  411. {
  412. int a = 0;
  413. // if (_ConDepArr.count != 0) {
  414. // a ++;
  415. // }
  416. // if ( _ConPersonArr.count != 0) {
  417. // a ++;
  418. // }
  419. return 5 +a;
  420. }
  421. #pragma mark -- getData
  422. - (void)getdataeaa
  423. {
  424. /*进行为空操作的判断*/
  425. NSString *timeStr =nil;
  426. if ([[self getTimeString] containsString:@"0.0"]) {
  427. timeStr =Localized(@"UU_custom_pleaseSelectMust");
  428. }else{
  429. timeStr = [self getTimeString];
  430. }
  431. NSString *dayStr = nil;
  432. if ([self haveWeekDay:_model.wd_day].length == 0) {
  433. dayStr =Localized(@"UU_custom_pleaseSelectMust");
  434. }else{
  435. dayStr = [self haveWeekDay:_model.wd_day];
  436. }
  437. NSString *depStr = nil;
  438. if (_model.emdefaultors.length == 0) {
  439. depStr = Localized(@"UU_custom_pleaseSelectNotMust");
  440. }else{
  441. depStr = _model.emdefaultors;
  442. }
  443. NSString *manStr = nil;
  444. if (_model.emnames.length == 0) {
  445. manStr = Localized(@"UU_custom_pleaseSelectNotMust");
  446. }else{
  447. manStr = _model.emnames;
  448. }
  449. NSArray *dateArr = @[FORMAT(@"%@", _model.wd_name),FORMAT(@"%@",timeStr),FORMAT(@"%@",dayStr),FORMAT(@"%@",depStr),FORMAT(@"%@",manStr)];
  450. if (_dataArr.count != 0) {
  451. [_dataArr removeAllObjects];
  452. }
  453. _dataArr = [NSMutableArray arrayWithArray:dateArr];
  454. }
  455. - (NSString *)getAllTime
  456. {
  457. CGFloat aa = 0;
  458. if ([self getDateStartTime:_model.wd_ondutyone endTime:_model.wd_offdutyone]>=0) {
  459. aa = [self getDateStartTime:_model.wd_ondutyone endTime:_model.wd_offdutyone];
  460. }else{
  461. aa = 24.0 + [self getDateStartTime:_model.wd_ondutyone endTime:_model.wd_offdutyone];
  462. }
  463. CGFloat bb= 0;
  464. if ([self getDateStartTime:_model.wd_ondutytwo endTime:_model.wd_offdutytwo] >= 0) {
  465. bb = [self getDateStartTime:_model.wd_ondutytwo endTime:_model.wd_offdutytwo];
  466. }else{
  467. bb = 24.0 + [self getDateStartTime:_model.wd_ondutytwo endTime:_model.wd_offdutytwo];
  468. }
  469. CGFloat cc = 0;
  470. if ([self getDateStartTime:_model.wd_ondutythree endTime:_model.wd_offdutythree] >= 0) {
  471. cc = [self getDateStartTime:_model.wd_ondutythree endTime:_model.wd_offdutythree];
  472. }else{
  473. cc = 24 + [self getDateStartTime:_model.wd_ondutythree endTime:_model.wd_offdutythree];
  474. }
  475. return [[NSString stringWithFormat:@"%.2lf",aa+bb+cc] substringToIndex:[NSString stringWithFormat:@"%.2lf",aa+bb+cc].length-1];
  476. }
  477. #pragma mark --计算时间间隔
  478. - (CGFloat )getDateStartTime:(NSString *)startTime endTime:(NSString *)endTime
  479. {
  480. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  481. [formatter setDateFormat:@"HH:mm"];
  482. NSDate *date1 = [formatter dateFromString:startTime];
  483. NSDate *date2 = [formatter dateFromString:endTime];
  484. NSTimeInterval aTimer = [date2 timeIntervalSinceDate:date1];
  485. int hour = (int)(aTimer/3600);
  486. int minute = (int)(aTimer - hour*3600)/60;
  487. CGFloat dural = hour + minute/60.0;
  488. return dural;
  489. }
  490. #pragma mark --获取时间段
  491. - (NSString *)getTimeString
  492. {
  493. NSString *str = nil;
  494. if (_model.wd_ondutytwo.length == 0) {
  495. str = [NSString stringWithFormat:@"%@-%@ %@小时",_model.wd_ondutyone,_model.wd_offdutyone,[self getAllTime]];
  496. }else if (_model.wd_ondutytwo.length != 0 && _model.wd_ondutythree.length == 0)
  497. {
  498. str = [NSString stringWithFormat:@"%@-%@ %@-%@ %@小时",_model.wd_ondutyone,_model.wd_offdutyone,_model.wd_ondutytwo,_model.wd_offdutytwo,[self getAllTime]];
  499. }else if (_model.wd_ondutythree.length != 0)
  500. {
  501. str = [NSString stringWithFormat:@"%@-%@ %@-%@ %@-%@ %@小时",_model.wd_ondutyone,_model.wd_offdutyone,_model.wd_ondutytwo,_model.wd_offdutytwo,_model.wd_ondutythree,_model.wd_offdutythree,[self getAllTime]];
  502. }
  503. return str;
  504. }
  505. #pragma mark -- 判断有周几
  506. - (NSString *)haveWeekDay:(NSString *)dateString
  507. {
  508. NSString *str = Localized(@"UU_custom_weekly");
  509. if(dateString.length == 0)
  510. {
  511. return @"";
  512. }
  513. if ([dateString containsString:@"1"]) {
  514. str = [str stringByAppendingFormat:@"一、"];
  515. }
  516. if ([dateString containsString:@"2"]) {
  517. str = [str stringByAppendingFormat:@"二、"];
  518. }
  519. if ([dateString containsString:@"3"]) {
  520. str = [str stringByAppendingFormat:@"三、"];
  521. }
  522. if ([dateString containsString:@"4"]) {
  523. str = [str stringByAppendingFormat:@"四、"];
  524. }
  525. if ([dateString containsString:@"5"]) {
  526. str = [str stringByAppendingFormat:@"五、"];
  527. }
  528. if ([dateString containsString:@"6"]) {
  529. str = [str stringByAppendingFormat:@"六、"];
  530. }
  531. if ([dateString containsString:@"7"]) {
  532. str = [str stringByAppendingFormat:@"日、"];
  533. }
  534. NSString *cccc = [str substringToIndex:[str length] - 1];
  535. return cccc;
  536. }
  537. - (NSString *)hadWeekDay:(NSString *)dateString
  538. {
  539. if (dateString.length == 0) {
  540. return @"";
  541. }
  542. NSString *str = @"";
  543. if ([dateString containsString:@"一"]) {
  544. str = [str stringByAppendingFormat:@"1,"];
  545. }
  546. if ([dateString containsString:@"二"]) {
  547. str = [str stringByAppendingFormat:@"2,"];
  548. }
  549. if ([dateString containsString:@"三"]) {
  550. str = [str stringByAppendingFormat:@"3,"];
  551. }
  552. if ([dateString containsString:@"四"]) {
  553. str = [str stringByAppendingFormat:@"4,"];
  554. }
  555. if ([dateString containsString:@"五"]) {
  556. str = [str stringByAppendingFormat:@"5,"];
  557. }
  558. if ([dateString containsString:@"六"]) {
  559. str = [str stringByAppendingFormat:@"6,"];
  560. }
  561. if ([dateString containsString:@"日"]) {
  562. str = [str stringByAppendingFormat:@"7,"];
  563. }
  564. NSString *cccc = [str substringToIndex:[str length] - 1];
  565. DLog(@"%@",cccc);
  566. return cccc;
  567. }
  568. #pragma mark -- 跳转到冲突人员界面
  569. -(void)ConPerAction
  570. {
  571. JLConflictPersonnel *vc = [[JLConflictPersonnel alloc] init];
  572. NSArray *arr1 = [_model.emnames componentsSeparatedByString:@","];
  573. NSArray *arr2 = [_model.emcodes componentsSeparatedByString:@","];
  574. NSMutableArray *arr11 = [NSMutableArray arrayWithArray:arr1];
  575. NSMutableArray *arr22 = [NSMutableArray arrayWithArray:arr2];
  576. NSMutableArray *arr33 = [NSMutableArray array];
  577. for (NSInteger i = 0; i < _ConPersonArr.count; i ++) {
  578. [arr33 addObject:_ConPersonArr[i]];
  579. }
  580. SLog(@"%ld",_ConPersonArr.count);
  581. vc.seletArr = _ConPersonArr;
  582. vc.type = Conflict_person;
  583. vc.title = Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictPerson3");
  584. [vc backname:^(NSMutableArray *arr){
  585. SLog(@"%ld",arr33.count);
  586. for (NSInteger i = 0; i < arr.count; i ++) {
  587. JLCONPersonalModel *model = arr[i];
  588. if ([arr33 containsObject:model]) {
  589. [arr33 removeObject:model];
  590. if ([arr11 containsObject:model.em_name]) {
  591. [arr11 removeObject:model.em_name];
  592. }
  593. if ([arr22 containsObject:model.ew_emcode]) {
  594. [arr22 removeObject:model.ew_emcode];
  595. }
  596. }
  597. [_ConPersonArr removeAllObjects];
  598. for (NSInteger i = 0; i <arr33.count; i ++) {
  599. [_ConPersonArr addObject:arr33[i]];
  600. }
  601. }
  602. _model.emnames = [arr11 componentsJoinedByString:@","];
  603. _model.emcodes = [arr22 componentsJoinedByString:@","];
  604. SLog(@"返回的数据 数 %ld",_ConPersonArr.count);
  605. [self getdataeaa];
  606. [_tableView reloadData];
  607. }];
  608. [self.navigationController pushViewController:vc animated:YES];
  609. }
  610. #pragma mark --跳转到冲突部门界面
  611. - (void)ConDepAction
  612. {
  613. JLConflictPersonnel *vc = [[JLConflictPersonnel alloc] init];
  614. NSArray *arr1 = [_model.emdefaultors componentsSeparatedByString:@","];
  615. NSArray *arr2 = [_model.emdefaultorcodes componentsSeparatedByString:@","];
  616. NSMutableArray *arr11 = [NSMutableArray arrayWithArray:arr1];
  617. NSMutableArray *arr22 = [NSMutableArray arrayWithArray:arr2];
  618. NSMutableArray *arr33 = [NSMutableArray array];
  619. for (NSInteger i = 0; i < _ConDepArr.count; i ++) {
  620. [arr33 addObject:_ConDepArr[i]];
  621. }
  622. vc.type = Confilct_departmet;
  623. vc.title = Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictDepartment3");
  624. vc.seletArr = _ConDepArr;
  625. int aa = 0;
  626. for (JLCONPersonalModel *model in _ConDepArr) {
  627. DLog(@" %d - %@ - %@",aa ++ ,model.conflictem_defaultorcode,model.conflictem_defaultorname);
  628. }
  629. [vc backname:^(NSMutableArray *arr) {
  630. for (NSInteger i = 0; i < arr.count; i ++) {
  631. JLCONPersonalModel *model = arr[i];
  632. if ([arr33 containsObject:model]) {
  633. [arr33 removeObject:model];
  634. if ([arr11 containsObject:model.conflictem_defaultorname]) {
  635. [arr11 removeObject:model.conflictem_defaultorname];
  636. }
  637. if ([arr22 containsObject:model.conflictem_defaultorcode]) {
  638. [arr22 removeObject:model.conflictem_defaultorcode];
  639. }
  640. }
  641. [_ConDepArr removeAllObjects];
  642. for (NSInteger i = 0; i <arr33.count; i ++) {
  643. [_ConDepArr addObject:arr33[i]];
  644. }
  645. }
  646. _model.emdefaultors = [arr11 componentsJoinedByString:@","];
  647. _model.emdefaultorcodes = [arr22 componentsJoinedByString:@","];
  648. [self getdataeaa];
  649. [_tableView reloadData];
  650. }];
  651. [self.navigationController pushViewController:vc animated:YES];
  652. }
  653. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  654. {
  655. 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")];
  656. if (indexPath.row == 0) {
  657. static NSString *ID = @"status11";
  658. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  659. cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  660. UIView *_bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 8)];
  661. _bgView.backgroundColor = BGB_COLOR;
  662. [cell.contentView addSubview:_bgView];
  663. UIView * _bgView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 45 +8 ,SCREEN_WIDTH, 8)];
  664. _bgView1.backgroundColor = BGB_COLOR;
  665. [cell.contentView addSubview:_bgView1];
  666. UILabel * _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 8, 150, 45)];
  667. _nameLabel.font =FONT_SIZE(14);
  668. _nameLabel.textColor = JLTEXT_COLOR;
  669. _nameLabel.text = nameArr[indexPath.row];
  670. [cell.contentView addSubview:_nameLabel];
  671. _nameClassTextField = [[UITextField alloc] initWithFrame:CGRectMake(self_width-190, 8, 170, 45)];
  672. _nameClassTextField.text =_dataArr[indexPath.row];
  673. _nameClassTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
  674. _nameClassTextField.adjustsFontSizeToFitWidth = YES;
  675. _nameClassTextField.textAlignment = NSTextAlignmentRight;
  676. _nameClassTextField.placeholder =Localized(@"UU_custom_pleaseInputMust");
  677. [_nameClassTextField setPlaceHolderColor:JLMOREN_TEXT_COLOR];
  678. _nameClassTextField.font = FONT_SIZE(10);
  679. _nameClassTextField.textColor = JLMOREN_TEXT_COLOR;
  680. _nameClassTextField.delegate = self;
  681. if ([_model.ifDefaultClass isEqualToString:@"1"]) {
  682. _nameClassTextField.enabled = NO;
  683. }else{
  684. _nameClassTextField.enabled = YES;
  685. }
  686. [cell.contentView addSubview:_nameClassTextField];
  687. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  688. cell.backgroundColor = BGKJ_COLOR;
  689. return cell;
  690. }else if(_ConDepArr.count != 0 && indexPath.row == 3){
  691. static NSString *ID = @"status1121";
  692. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  693. cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  694. UILabel *_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 150, 44.2)];
  695. _nameLabel.font =FONT_SIZE(14);
  696. _nameLabel.textColor = JLTEXT_COLOR;
  697. [cell.contentView addSubview:_nameLabel];
  698. UILabel *_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width-200, 0, 200, 44.2)];
  699. _dateLabel.font = FONT_SIZE(10);
  700. _dateLabel.textAlignment = NSTextAlignmentRight;
  701. _dateLabel.textColor = JLMOREN_TEXT_COLOR;
  702. [cell.contentView addSubview:_dateLabel];
  703. _nameLabel.text = nameArr[indexPath.row];
  704. _dateLabel.text = _dataArr[indexPath.row];
  705. cell.backgroundColor = BGKJ_COLOR;
  706. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 52, self_width, 40)];
  707. bgView.backgroundColor = BGB_COLOR;
  708. UILabel *nameLabel = [[UILabel alloc ]initWithFrame:CGRectMake(10, 3, self_width-10, 20)];
  709. nameLabel.textColor = Color(0, 122, 255, 1.0);
  710. nameLabel.font = FONT_SIZE(12);
  711. [bgView addSubview:nameLabel];
  712. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  713. btn.backgroundColor = [UIColor clearColor];
  714. btn.frame = CGRectMake(0, 0, self_width, 40);
  715. [bgView addSubview:btn];
  716. [cell.contentView addSubview:bgView];
  717. nameLabel.text = FORMAT(@"%@%lu%@",Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictDepartment1"),(unsigned long)_ConDepArr.count,Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictDepartment2"));
  718. [btn addTarget:self action:@selector(ConDepAction) forControlEvents:UIControlEventTouchUpInside];
  719. return cell;
  720. }else if (_ConPersonArr.count != 0 && indexPath.row == 4)
  721. {
  722. static NSString *ID = @"stat222";
  723. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  724. cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  725. UILabel *_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 150, 44.2)];
  726. _nameLabel.font =FONT_SIZE(14);
  727. _nameLabel.textColor = JLTEXT_COLOR;
  728. [cell.contentView addSubview:_nameLabel];
  729. UILabel *_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width-200, 0, 170, 44.2)];
  730. _dateLabel.font = FONT_SIZE(10);
  731. _dateLabel.textAlignment = NSTextAlignmentRight;
  732. _dateLabel.textColor = JLMOREN_TEXT_COLOR;
  733. [cell.contentView addSubview:_dateLabel];
  734. _nameLabel.text = nameArr[indexPath.row];
  735. _dateLabel.text = _dataArr[indexPath.row];
  736. cell.backgroundColor = BGKJ_COLOR;
  737. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 52, self_width, 40)];
  738. bgView.backgroundColor = BGB_COLOR;
  739. UILabel *nameLabel = [[UILabel alloc ]initWithFrame:CGRectMake(10, 3, self_width-10, 20)];
  740. nameLabel.textColor = Color(0, 122, 255, 1.0);
  741. nameLabel.font = FONT_SIZE(12);
  742. [bgView addSubview:nameLabel];
  743. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  744. btn.backgroundColor = [UIColor clearColor];
  745. btn.frame = CGRectMake(0, 0, self_width, 40);
  746. [bgView addSubview:btn];
  747. [cell.contentView addSubview:bgView];
  748. NSString *str = FORMAT(@"%@%lu%@",Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictPerson1"),(unsigned long)_ConPersonArr.count,Localized(@"UU_work_OA_PC_SchedulingSetting_ConflictPerson2"));
  749. nameLabel.text = str;
  750. [btn addTarget:self action:@selector(ConPerAction) forControlEvents:UIControlEventTouchUpInside];
  751. return cell;
  752. }
  753. else{
  754. JLAddSelectSettingCell *cell = [JLAddSelectSettingCell cellWithTableView:tableView];
  755. cell.nameString = nameArr[indexPath.row];
  756. cell.dateString = _dataArr[indexPath.row];
  757. cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
  758. return cell;
  759. }
  760. }
  761. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  762. {
  763. if (indexPath.row == 0 ) {
  764. return 61;
  765. }else{
  766. // 存在人员 冲突
  767. if (_ConPersonArr.count != 0) {
  768. if (indexPath.row == 4) {
  769. return 45 +40;
  770. }
  771. }
  772. // 存在部门 冲突
  773. if (_ConDepArr.count != 0) {
  774. if (indexPath.row == 3) {
  775. return 45 +40;
  776. }
  777. }
  778. return 45;
  779. }
  780. }
  781. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  782. {
  783. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  784. if (indexPath.row == 0) {
  785. [_nameClassTextField becomeFirstResponder];
  786. }else{
  787. [_nameClassTextField resignFirstResponder];
  788. if (indexPath.row == 1) {
  789. JLTimeAttendanceSettingVC *vc = [[JLTimeAttendanceSettingVC alloc] init];
  790. if (self.model.wd_ondutyone.length == 0 && self.type == work_add_Sch) {
  791. self.model.wd_ondutyone = @"08:00";
  792. self.model.wd_offdutyone = @"12:00";
  793. self.model.wd_ondutytwo = @"13:30";
  794. self.model.wd_offdutytwo = @"18:00";
  795. }
  796. vc.model = self.model;
  797. [vc setBlock:^(JLSchedulingModel *model) {
  798. _model.wd_ondutyone = FORMAT(@"%@",model.wd_ondutyone);
  799. _model.wd_offdutyone = FORMAT(@"%@",model.wd_offdutyone);
  800. _model.wd_ondutytwo = FORMAT(@"%@",model.wd_ondutytwo);
  801. _model.wd_offdutytwo = FORMAT(@"%@",model.wd_offdutytwo);
  802. _model.wd_ondutythree = FORMAT(@"%@",model.wd_ondutythree);
  803. _model.wd_offdutythree = FORMAT(@"%@",model.wd_offdutythree);
  804. _model.wd_earlytime = FORMAT(@"%@",model.wd_earlytime);
  805. _model.tpye= @"";
  806. JLAddSelectSettingCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  807. cell.dateString = [self getTimeString];
  808. }];
  809. [self.navigationController pushViewController:vc animated:YES];
  810. }
  811. else if (indexPath.row == 2)
  812. {
  813. if (self.type == 0) {
  814. JLCalendarSelectSchduleVC *calendarVC = [[JLCalendarSelectSchduleVC alloc]initWithTitleString:@"选择日期" WithSelectTime:@"" WithType:@""];
  815. [[NSUserDefaults standardUserDefaults] setObject:@"single" forKey:@"trip"];
  816. calendarVC.model = self.model;
  817. [calendarVC setAirPlaneToDay:365 ToDateforString:nil]; //初始化
  818. [calendarVC passDate:^(NSMutableArray *array) {
  819. // [self.date1Btn setTitle:[NSString stringWithFormat:@"%@-%@",[array[0] toString],[array[0] getWeek] ] forState:UIControlStateNormal];
  820. //
  821. // [self.date2Btn setTitle:[NSString stringWithFormat:@"%@-%@",[array[1] toString],[array[1] getWeek] ] forState:UIControlStateNormal];
  822. }];
  823. [self.navigationController pushViewController:calendarVC animated:YES];
  824. }else{
  825. JLGetWeekDayVC *vc = [[JLGetWeekDayVC alloc] init];
  826. vc.weekDayString = _model.wd_day;
  827. [vc setBlcok:^(NSString *str){
  828. JLAddSelectSettingCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  829. if (str.length == 0) {
  830. cell.dateString =Localized(@"UU_custom_pleaseSelectMust");
  831. }else{
  832. cell.dateString = str;
  833. }
  834. _model.wd_day = [self hadWeekDay:str];
  835. }];
  836. [self.navigationController pushViewController:vc animated:YES];
  837. }
  838. }
  839. #pragma mark -- 参加部门
  840. else if ( indexPath.row == 3){
  841. if ([_model.ifDefaultClass isEqualToString:@"1"]) {
  842. 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];
  843. view.tag =22222;
  844. [view show];
  845. }else{
  846. [_pushWithArray removeAllObjects];
  847. JOSettingSelectDepartVC *vc = [[JOSettingSelectDepartVC alloc] init];
  848. if (_model.emdefaultorcodes.length != 0) {
  849. NSArray * arr=[_model.emdefaultorcodes componentsSeparatedByString:@","];
  850. vc.selectedArr=[[NSMutableArray alloc]initWithArray:arr];
  851. }else{
  852. vc.selectedArr = [NSMutableArray array];
  853. }
  854. //DLog(@"%@",vc.selectedArr);
  855. vc.blcok=^(NSMutableArray * array){
  856. NSString *Codestr = @"";
  857. NSString *NameStr = @"";
  858. JLAddSelectSettingCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  859. if (array.count == 0) {
  860. _model.emdefaultorcodes =@"";
  861. _model.emdefaultors = @"";
  862. //承接数组
  863. }else{
  864. for (int i=0; i<array.count; i++)
  865. {
  866. JONodeModel * model=array[i];
  867. DLog(@"%@ %@",model.nodeCode,model.selfName);
  868. NameStr = [NameStr stringByAppendingFormat:@"%@,",model.selfName];
  869. Codestr = [Codestr stringByAppendingFormat:@"%@,",model.depCode];
  870. }
  871. NSString *cccc = [NameStr substringToIndex:[NameStr length] - 1];
  872. NSString *bbbb = [Codestr substringToIndex:[Codestr length] - 1];
  873. SLog(@"%@",cccc);
  874. if (_ConDepArr.count == 0) {
  875. cell.dateString = cccc;
  876. }
  877. _model.emdefaultorcodes = bbbb;
  878. _model.emdefaultors = cccc;
  879. //承接数组
  880. [_pushWithArray removeAllObjects];
  881. _pushWithArray=[[NSMutableArray alloc]initWithArray:array];
  882. }
  883. __weak typeof(self) weakSelf = self;
  884. dispatch_async(dispatch_get_main_queue(), ^{
  885. [weakSelf getConfitPersonAndDefaultorcode];
  886. });
  887. };
  888. [self.navigationController pushViewController:vc animated:YES];
  889. }
  890. }
  891. #pragma mark -- 参加人员
  892. else if (indexPath.row == 4)
  893. {
  894. #pragma mark -- 选择冲突人员
  895. if ([_model.ifDefaultClass isEqualToString:@"1"]) {
  896. 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];
  897. view.tag =222221;
  898. [view show];
  899. }else{
  900. JLGetPersonSVC *vc = [[JLGetPersonSVC alloc] init];
  901. vc.title = Localized(@"UU_work_OA_PC_SS_ParticipatingPerson_selectPerson");
  902. vc.siftArr=_pushWithArray;
  903. if (_model.emcodes.length != 0) {
  904. vc.emcodeArr = [_model.emcodes componentsSeparatedByString:@","];
  905. }
  906. [vc backname:^(NSMutableArray *arr,NSMutableArray * brr) {
  907. DLog(@"拿回来的是人名嘛%@",arr);
  908. DLog(@"拉回来的事ID吗%@",brr);
  909. if (arr.count>=1)
  910. {
  911. NSString * str=@"";
  912. NSString * str2=@"";
  913. for (int i=0; i<arr.count; i++)
  914. {
  915. str=[[str stringByAppendingString:@","] stringByAppendingString:arr[i]];
  916. str2=[[str2 stringByAppendingString:@","] stringByAppendingString:brr[i]];
  917. }
  918. SLog(@"%@",str);
  919. str=[str substringFromIndex:1];
  920. str2=[str2 substringFromIndex:1];
  921. //
  922. _model.emcodes = str2;
  923. _model.emnames = str;
  924. DLog(@"处理过后呢%@",str2);
  925. }else if (arr.count==1){
  926. _model.emcodes = brr[0];
  927. _model.emnames = arr[0];
  928. }else{
  929. _model.emcodes = @"";
  930. _model.emnames = @"";
  931. }
  932. __weak typeof(self) weakSelf = self;
  933. dispatch_async(dispatch_get_main_queue(), ^{
  934. [weakSelf getConfitPersonAndDefaultorcode];
  935. });
  936. }];
  937. [self.navigationController pushViewController:vc animated:YES];
  938. }
  939. }
  940. }
  941. }
  942. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  943. {
  944. [_nameClassTextField resignFirstResponder];
  945. }
  946. #pragma mark - UITextfiledDelegate
  947. - (void)textFieldDidEndEditing:(UITextField *)textField
  948. {
  949. _model.wd_name = _nameClassTextField.text;
  950. }
  951. - (void)textFieldDidBeginEditing:(UITextField *)textField
  952. {
  953. _model.wd_name = _nameClassTextField.text;
  954. }
  955. - (void)getNumberPersonCompleted:(void(^)(NSString *str))completed
  956. {
  957. NSString * companyName=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_function"];
  958. companyName=[companyName stringByReplacingOccurrencesOfString:@"(" withString:@""];
  959. companyName=[companyName stringByReplacingOccurrencesOfString:@")" withString:@""];
  960. [self selectTablewithtableName:TONGXUNLUDATA completed:^(NSArray *arr) {
  961. NSArray *arr1 = [_model.emdefaultors componentsSeparatedByString:@","];
  962. NSArray *arr2 = [_model.emcodes componentsSeparatedByString:@","];
  963. int ii = 0;
  964. for (NSInteger i = 0; i < arr.count ; i ++) {
  965. JOEmployeeModel *model = arr[i];
  966. for (NSInteger j = 0; j < arr1.count; j ++) {
  967. if ([model.EM_DEFAULTORNAME isEqualToString:arr1[j]] ) {
  968. ii += 1;
  969. }
  970. }
  971. for (NSInteger j = 0; j < arr2.count; j ++) {
  972. if ([model.EM_CODE isEqualToString:arr2[j]]) {
  973. ii += 1;
  974. }
  975. }
  976. }
  977. if (completed) {
  978. completed(FORMAT(@"%d",ii));
  979. }
  980. }];
  981. }
  982. #pragma mark --
  983. -(void)selectTablewithtableName:(NSString *)tableName completed:(void(^)(NSArray *arr))completed{
  984. [[TIFmdbManager shareManager] createOrOpenDatabasaWithDbName:TONGXUNLUDATA completed:^(BOOL result) {
  985. if (result) {
  986. NSMutableArray *dataArr = [NSMutableArray new];
  987. [[TIFmdbManager shareManager] executeWithDb:TONGXUNLUDATA excuteDbBlock:^(FMDatabase *db) {
  988. NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@",tableName];
  989. FMResultSet *rs = [db executeQuery:sql];
  990. while ([rs next])
  991. {
  992. JOEmployeeModel *model1 = [[JOEmployeeModel alloc] init];
  993. model1.EM_ID = [rs intForColumn:_em_id];
  994. model1.EM_IMID = [rs intForColumn:_em_imid];
  995. model1.FLAG=[rs stringForColumn:_em_flag];
  996. model1.EM_DEFAULTORID=[rs intForColumn:_em_defaultorid];
  997. model1.EM_CODE = [rs stringForColumn:_em_code];
  998. model1.EM_NAME = [rs stringForColumn:_em_name];
  999. model1.EM_POSITION = [rs stringForColumn:_em_position];
  1000. model1.EM_JOBS = [rs stringForColumn:_em_jobs];
  1001. model1.EM_LASTDATE = [rs stringForColumn:_em_lastdate];
  1002. model1.EM_DEFAULTORNAME = [rs stringForColumn:_em_defaultorname];
  1003. model1.EM_DEPART = [rs stringForColumn:_em_depart];
  1004. model1.EM_TEL = [rs stringForColumn:_em_tel];
  1005. model1.EM_MOBILE = [rs stringForColumn:_em_mobile];
  1006. model1.EM_EMAIL = [rs stringForColumn:_em_email];
  1007. model1.EM_UU = [rs stringForColumn:_em_uu];
  1008. model1.EM_IMAGEID = [rs stringForColumn:_em_iamgeid];
  1009. model1.COMPANY = [rs stringForColumn:_company];
  1010. model1.WHICHSYS = [rs stringForColumn:_whichsys];
  1011. if ([model1.EM_CODE isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"]])
  1012. {
  1013. NSUserDefaults * str=[NSUserDefaults standardUserDefaults];
  1014. [str setObject:[NSString stringWithFormat:@"%ld",(long)model1.EM_ID] forKey:@"jocanhuirenyuanziji"];
  1015. }
  1016. [dataArr addObject:model1];
  1017. }
  1018. } completed:^{
  1019. if (completed) {
  1020. completed(dataArr);
  1021. }
  1022. }];
  1023. }
  1024. }];
  1025. }
  1026. @end