| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- //
- // ApplyCardViewController.m
- // shiku_im
- //
- // Created by on 16/11/17.
- // Copyright © 2016年 Reese. All rights reserved.
- //
- #import "ApplyCardViewController.h"
- #import "AFNetworking.h"
- #import "JOGetShenPiManVC.h"
- #import "JOTextview.h"
- @interface ApplyCardViewController ()<UITextViewDelegate,UIAlertViewDelegate,UIScrollViewDelegate>
- @property(nonatomic,strong)UIScrollView * sc;
- @property(nonatomic,strong)UIButton * btn;
- @end
- @implementation ApplyCardViewController
- {
- UITextView * _textView;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = Color(235, 233, 233, 1.0);
-
- self.title = Localized(@"UU_work_OA_PC_FillCard_Petition");
- BackView
- _sc =[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-100)];
- _sc.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-100);
- _sc.delegate = self;
- [self.view addSubview:_sc];
- [self setUI];
- [self setBottomView];
-
- }
- -(void)setUI{
- UIView * uv1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 56)];
- [_sc addSubview:uv1];
- UIView * uv2 =[[UIView alloc]initWithFrame:CGRectMake(0, 8, SCREEN_WIDTH, 40)];
- // uv2.backgroundColor =Color(235, 233, 233, 1.0);
- uv2.backgroundColor = Color(250, 249, 249, 1.0);
- [uv1 addSubview:uv2];
-
- UILabel * labl =[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 120, 40)];
- labl.text = Localized(@"UU_work_OA_PC_FillCard_PetitionSCH");
- labl.font =FONT_SIZE(14);
- [uv2 addSubview:labl];
-
- UILabel * lab2 = [[UILabel alloc]initWithFrame:CGRectMake(130, 0, SCREEN_WIDTH-140, 40)];
- lab2.font = FONT_SIZE(13);
- lab2.numberOfLines = 0;
- lab2.textColor = [UIColor grayColor];
- lab2.text = _bukaTime;
- lab2.textAlignment = NSTextAlignmentRight;
- [uv2 addSubview:lab2];
-
- // DLog(@"获取的是:%@",_myMacAddress);
-
- UIImageView * imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 56, SCREEN_WIDTH, 1)];
- imageV1.backgroundColor = [UIColor grayColor];
- // UIImageView * imageV2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, 1)];
- // imageV2.backgroundColor = [UIColor grayColor];
- // UIImageView *imageV3 = [[UIImageView alloc]initWithFrame:CGRectMake(10, 45, SCREEN_WIDTH-10, 1)];
- // imageV3.backgroundColor = [UIColor lightGrayColor];
- [uv1 addSubview:imageV1];
-
- // [_sc addSubview:imageV1];
- // [_sc addSubview:imageV2];
- // [_sc addSubview:imageV3];
-
- }
- -(void)setBottomView{
-
- UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0,56, SCREEN_WIDTH,330)];
- view.backgroundColor = Color(250, 249, 249, 1.0);
- [_sc addSubview:view];
-
- JOTextView * textView = [[JOTextView alloc]initWithFrame:CGRectMake(6,86, SCREEN_WIDTH-12,300)];
- textView.placeholder = Localized(@"UU_custom_pleaseInputMust");
- textView.limitStr= @"NO";
- textView.delegate =self;
- textView.font = FONT_SIZE(13);
- textView.textColor = [UIColor grayColor];
- textView.returnKeyType = UIReturnKeyDone;
- textView.backgroundColor = Color(250, 249, 249, 1.0);
- _textView = textView;
- [_sc addSubview:textView];
- UILabel * lab3 = [[UILabel alloc]initWithFrame:CGRectMake(10, 56,SCREEN_WIDTH , 30)];
- lab3.text = Localized(@"UU_work_OA_PC_FillCard_PetitionGrounds");
- lab3.font = FONT_SIZE(14);
- // lab3.backgroundColor = [UIColor redColor];
- lab3.backgroundColor = Color(250, 249, 249, 1.0);
- [_sc addSubview:lab3];
- _btn = [UIButton sureButtonWithTitle:@"提交"];
-
-
- [_btn addTarget:self action:@selector(saveAndSubmitMobileSignCard) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_btn];
- [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(20);
- make.right.equalTo(self.view).offset(-20);
- make.bottom.equalTo(self.view).offset(-40);
- make.height.mas_equalTo(40);
- }];
-
- }
- -(void)saveAndSubmitMobileSignCard{
-
- NSString * emcode = [[NSUserDefaults standardUserDefaults] stringForKey:@"erpaccount"];
- NSString * ipStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"ipAndPort"];
- NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
-
- NSDateFormatter * formatter=[[NSDateFormatter alloc]init];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSString * currentTime=[formatter stringFromDate:[NSDate date]];
- DLog(@"afsdgdgtr:%@",currentTime);
- NSString * a = [_textView.text stringByReplacingOccurrencesOfString:@" " withString:@""];
- a = [a stringByReplacingOccurrencesOfString:@"\r" withString:@""];
- a = [a stringByReplacingOccurrencesOfString:@"\n" withString:@""];
- if ([a isEqualToString:@""]) {
- [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlert:Localized(@"UU_work_OA_PC_FillCard_PetitionNONill")];
- }
- else{
- _btn.userInteractionEnabled = NO;
- NSDictionary * dic;NSString *url;
- NSDateFormatter * dateformatter = [[NSDateFormatter alloc]init];
- [dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate* Datestr = [dateformatter dateFromString:self.bukaTime];
- NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[Datestr timeIntervalSince1970]*1000];
- DLog(@"转换的数据是:%@",timeSp);
- if (g_B2BUser) {
- dic = @{
-
- @"mobile":[[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_LoginName],
- @"signtime":timeSp,
- @"address":self.bukaAddress!=nil?self.bukaAddress:@"",
- @"emuu":g_emcode,
- @"remark":_textView.text,
- @"uu":g_B2B_enuu,
- };
-
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
- NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- url = [NSString stringWithFormat:@"%@mobile/signapp/saveSignApp?formStore=%@&sessionId=%@",ipStr,str,g_sessionId];
- }else{
- dic = @{
- @"ms_emcode":emcode,
- @"ms_emname":[[NSUserDefaults standardUserDefaults] stringForKey:@"personName"],
- @"ms_address":self.bukaAddress!=nil?self.bukaAddress:@"",
- @"ms_remark":_textView.text,
- @"ms_mobile":[[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_LoginName],
- @"ms_signtime":self.bukaTime,
- @"ms_status":@"在录入",
- @"ms_statuscode":@"ENTERING",
- };
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
- NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
- url = [NSString stringWithFormat:@"%@mobile/oa/saveAndSubmitMobileSignCard.action?caller=MobileSignCard&formStore=%@&master=%@&sessionUser=%@&sessionId=%@",ipStr,str,g_master,g_sessionUser,sessionId];
- }
- DLog(@"保存的url是:%@",url);
-
- url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- UASNetworkManager *mannage = [UASNetworkManager shareManager];
- //拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //设置cookie
- if (g_ERPUser) {
- [mannage.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
- [mannage.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
- }
- mannage.responseSerializer = [AFJSONResponseSerializer serializer];
- [mannage request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- _btn.userInteractionEnabled = YES;
- // DLog(@"%@",responseObject);
- [MBProgressHUD showSuccess:Localized(@"UU_work_OA_PC_FillCard_PetitionUpdateSucess")];
- if (g_ERPUser) {
- NSString * seqCode =responseObject[@"ms_id"];
- NSString * caller =@"MobileSignCard";
- [self getTheSelectShenpiRenDataSeq:seqCode andcaller:caller andsessionId:sessionId andips:ipStr];
- }
- else{
- [self.navigationController popViewControllerAnimated:YES];
- }
-
-
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
-
-
- DLog(@"错误信息的详细信息是:%@",error);
- _btn.userInteractionEnabled = YES;
- NSData *returnData = [[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
- if (returnData)
- {
- NSDictionary *content = [NSJSONSerialization JSONObjectWithData:returnData options:NSJSONReadingMutableContainers error:nil];//转换数据格式
-
- NSString *errorStr = [NSString stringWithFormat:@"%@",[content objectForKey:@"exceptionInfo"]];
- DLog(@"错误信息是:%@",errorStr);
- DLog(@"返回失败");
- NSString * times=[NSString getLongCurrenTime];
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
- times,@"aa_date",
- @"打卡申诉失败",@"aa_type",
- @"errorStr",@"aa_remark",
- FORMAT(@"%@",url),@"aa_location",
- [[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_LoginName],@"aa_telephone",
-
- nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"saveMonitorLogALLL" object:@"monitorLog" userInfo:dic];
- [JOShowMessageFromNavi showDropViewWithMessage:errorStr ToNavi:self.navigationController withColor:[UIColor grayColor]];
-
- }
-
- }];
- }
-
-
- }
- -(void)getTheSelectShenpiRenDataSeq:(NSString * )seqCode andcaller:(NSString * )caller andsessionId:(NSString * )sessionId andips:(NSString * )ips{
- /*
- 获取审批人列表
- */
- //1,创建一个网络请求管理对象
- UASNetworkManager *manager1 = [UASNetworkManager shareManager];
- manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
- //3.拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //4.设置cookie
- [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
- //5,接口
- NSString * urlAddress1=@"/common/getMultiNodeAssigns.action";
- //6,Caller
- // NSString * caller=@"MeetingDoc";
-
- //url
- NSString * url2=[@"" stringByAppendingFormat:@"%@%@?caller=%@&id=%@&sessionId=%@&master=%@&sessionUser=%@",ips,urlAddress1,caller,seqCode,sessionId,g_master,g_sessionUser];
-
- // DLog(@"获取审批人Url=%@",url2);
-
- [manager1 request:url2 method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- NSData *data=responseObject;
-
-
- //1,系统自带的nsjson解析数据
- id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
- // DLog(@"获取的数据是什么啊:%@",rootDic);
- if ([rootDic count] == 0) {
- [self.navigationController popViewControllerAnimated:YES];
- }else{
- JOGetShenPiManVC * vc=[[JOGetShenPiManVC alloc]init];
- vc.seqCode=seqCode;
- vc.caller =caller;
-
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- DLog(@"什么错误呀==%@",error);
- [MBProgressHUD showError:@"提交失败"];
- }];
-
-
- }
- - (void)backAction
- {
- //[self dismissViewControllerAnimated:YES completion:nil];
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma -mark TextviewDelegate
- //return键响应键盘时间
- -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- if ([text isEqualToString:@"\n"])//判断输入的字是否是回车,即按下return
- {
- [textView resignFirstResponder];//在这里做你响应return键的代码
- return NO; //这里返回NO,就代表return键值失效,即页面上按下return,不会出现换行,如果为yes,则输入页面会换行
- }
- return YES;
- }
- - (void)textViewDidChange:(UITextView *)textView{
- // numberlines用来控制输入的行数
- if (textView.text.length > 100)
- {
- textView.text = [textView.text substringToIndex:30];
- // [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlert:@"不能超过50个字"];
- [self.view endEditing:YES];
- [KPromptBox showKPromptBoxWithMassage:Localized(@"UU_work_OA_PC_FillCard_PetitionNOHad100Size")];
- }
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
-
- [self.view endEditing:YES];
-
- }
- @end
|