| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- //
- // JOHYRWLBViewController.m
- // shiku_im
- //
- // Created by 周兵 on 16/8/29.
- // Copyright © 2016年 Reese. All rights reserved.
- //
- #import "JOHYRWLBViewController.h"
- #import "MJExtension.h"
- #import "JOXZHYRWViewController.h"
- #import "JOHYRWLBTableViewCell.h"
- #import "HandleTaskViewController.h"
- #import "UITableView+WFEmpty.h"
- @interface JOHYRWLBViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
- UITableView * _tableview;
- UIView * _manbottomView;
- NSMutableArray * _dataArray;
- }
- @end
- @implementation JOHYRWLBViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor=[UIColor whiteColor];
- _manbottomView=[[UIView alloc]initWithFrame:self.view.bounds];
- _manbottomView.backgroundColor=Color(160,160,160,0.1);
- [self.view addSubview:_manbottomView];
- [_manbottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.bottom.equalTo(self.view);
- }];
-
- [self setNavi];
-
- // [self getHYDataFromSever];
-
- _tableview=[[UITableView alloc]initWithFrame:CGRectMake(0,0,self_width, self_height) style:UITableViewStylePlain];
- _tableview.delegate=self;
- _tableview.dataSource=self;
- _tableview.backgroundColor = BGKJ_COLOR;
- //这句代码可以去掉tableview多余分割线
- _tableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
- [_manbottomView addSubview:_tableview];
- [_tableview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.bottom.equalTo(_manbottomView);
- }];
-
- _dataArray=[[NSMutableArray alloc]init];
-
-
- }
- - (void)setNavi
- {
- //1设置title
- UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0,80,30)];
- titleLabel.text = Localized(@"UU_work_OA_MM_MeetingDetail_MeetingTask");
- titleLabel.textColor = [UIColor whiteColor];
- titleLabel.font = FONT_SIZE(18);
-
- self.navigationItem.titleView=titleLabel;
-
- // UIBarButtonItem * left=[[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"oa_backView2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleBordered target:self action:@selector(backView)];
- // self.navigationItem.leftBarButtonItem=left;
-
- 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];
-
-
-
- UIButton *rigntBtn = [UIButton buttonWithType:UIButtonTypeSystem];
- rigntBtn.frame = CGRectMake(0, 10, 20, 20);
- UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"crm_main_add"]];
- imageView.frame = CGRectMake(0, 5, 20, 20);
- [rigntBtn addSubview:imageView];
- [rigntBtn addTarget:self action:@selector(createHYRW) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *creatBtn = [[UIBarButtonItem alloc]initWithCustomView:rigntBtn];
- [self.navigationItem setRightBarButtonItem:creatBtn];
-
-
- self.navigationController.navigationBar.barTintColor = NB_COLOR;
-
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [self getHYDataFromSever];
-
- }
- - (void)backView
- {
-
- [self.navigationController popViewControllerAnimated:YES];
-
-
- }
- - (void)createHYRW
- {
- JOXZHYRWViewController * vc=[[JOXZHYRWViewController alloc]init];
- vc.huiyiName=self.huiyiName;
- vc.huiyiCode= self.huiyiCode;
- [self presentViewController:vc animated:YES completion:nil];
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
-
-
- return _dataArray.count;
-
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
-
-
- JOHYRWLBTableViewCell * cell=[JOHYRWLBTableViewCell cellWithTableView:tableView];
- cell.hyrwModel=_dataArray[indexPath.row];
-
- return cell;
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
-
- return 140;
-
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- JOHYRWModel * model=[[JOHYRWModel alloc]init];
- model=_dataArray[indexPath.row];
-
- HandleTaskViewController *handleTaskViewController=[[HandleTaskViewController alloc] init];
- handleTaskViewController.hidesBottomBarWhenPushed=YES;
-
- /*
- handleTaskViewController.launchPerson=model.recorder;
- handleTaskViewController.acceptPerson=model.handler;
- handleTaskViewController.taskName=model.name;
- handleTaskViewController.status=model.status;
- handleTaskViewController.startDate=model.startdate;
- handleTaskViewController.endDate=model.enddate;
- handleTaskViewController.describ=model.descriptions;
- handleTaskViewController.taskcode=model.taskcode;
- handleTaskViewController.ra_id=model.ra_id;
- handleTaskViewController.taskid=model.ra_taskid;
- handleTaskViewController.audioIdArrayStr=@"";
- */
- handleTaskViewController.launchPerson=model.recorder;
- handleTaskViewController.acceptPerson=model.ra_resourcename;
- handleTaskViewController.taskName=model.ra_taskname;
- handleTaskViewController.status=model.ra_status;
- handleTaskViewController.startDate=model.ra_startdate;
- handleTaskViewController.endDate=model.ra_enddate;
- handleTaskViewController.describ=model.descriptions;
- handleTaskViewController.taskcode=model.taskcode;
- handleTaskViewController.ra_id=model.ra_id;
- handleTaskViewController.taskid=model.ra_taskid;
- handleTaskViewController.audioIdArrayStr=@"";
-
-
- //先判断是不是执行人
- NSString * myName = [[NSUserDefaults standardUserDefaults] stringForKey:@"personName"];
-
- if([model.resourcename rangeOfString:myName].location == NSNotFound)
- {
- //不包含
-
- handleTaskViewController.type=HandleTaskTypeForFinish1;
- }else{
- //包含
-
- handleTaskViewController.type=HandleTaskTypeForStart1;//执行人回复界面
- }
- if ([model.ra_status isEqualToString:@"待确认"])
- {
- handleTaskViewController.type=HandleTaskTypeForWaitVerify1;//提出人回复界面
- }
-
- if ([model.ra_status isEqualToString:@"已完成"]||[model.ra_status isEqualToString:@"已审核"])
- {
- handleTaskViewController.type=HandleTaskTypeForFinish1;
- }
-
-
- [self.navigationController pushViewController:handleTaskViewController
- animated:NO];
-
-
-
- }
- /**
- 获得会议任务列表
- */
- - (void)getHYDataFromSever
- {
-
-
- [_dataArray removeAllObjects];
- //1,创建一个网络请求管理对象
- UASNetworkManager *manager1 = [UASNetworkManager shareManager];
- manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
-
-
- //2,取出sessionID和IP和员工编号
- NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
-
- NSString *sessionId=[userDefault stringForKey:@"sessionId"];
-
- NSString * ips=[UASUserInfo shareManager].urlIp;
-
-
-
- //NSString * myName=[userDefault objectForKey:MY_USER_ID];
- NSString * myName = [[NSUserDefaults standardUserDefaults] stringForKey:@"personName"];
-
-
-
- NSString * userID=[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
- NSString *master=[[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
-
- // DLog(@"userID=%@",userID);
-
- //3.拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //4.设置cookie
- [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
-
-
- //5,接口
- NSString * urlAddress=@"common/datalist/data.action";
- //6,Caller
- NSString * caller=@"ResourceAssignment";
- //7,condition
- //MA_STATUSCODE='AUDITED' //1=1
- //NSString * condition=@"";
-
- // int page=1;
- // int pagesize=100;
-
- NSString *currentMaster=[[userDefault objectForKey:@"masterDic"] objectForKey:@"ma_user"];
-
-
- NSString *url=[@"" stringByAppendingFormat:@"%@%@",ips,urlAddress];
- NSDictionary * dic11 = @{
- @"emcode":userID,
- @"condition":[NSString stringWithFormat:@"(ra_resourcecode='%@' or recorder='%@') and (taskorschedule='MTask') and ra_taskname='%@%@'",userID,myName,self.huiyiName,self.huiyiCode],
- @"sessionId":sessionId,
- @"page":@"1",
- @"pageSize":@"100",
- @"caller":caller,
- @"currentMaster":currentMaster,
- @"master":master,
- @"sessionUser":userID,
-
- };
-
- DLog(@"url=%@",url);
-
-
- //7.二进制数据转换
- NSString *urlStringUTF8 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- [manager1 request:urlStringUTF8 method:GET parameters:dic11 progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- NSData *data=responseObject;
- //1,系统自带的nsjson解析数据
-
- id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
-
- // NSDictionary *rootDic = responseObject;
- SLog(@"请求成功%@",rootDic);
-
- if ([[rootDic allKeys] containsObject:@"sessionId"]==YES)
- {
- NSString * sessionId=[NSString stringWithFormat:@"%@",[rootDic objectForKey:@"sessionId"]];
- [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
- }
-
- NSDictionary * dict=[NSDictionary changeType:rootDic];
- NSMutableArray * arr=[dict objectForKey:@"data"];
-
- for (int i=0; i<arr.count; i++)
- {
-
- NSString * str=[arr[i] objectForKey:@"description"];
- DLog(@"%@",str);
- JOHYRWModel * model=[JOHYRWModel mj_objectWithKeyValues:arr[i]];
- model.descriptions=str;
- [_dataArray addObject:model];
- }
-
- if (_dataArray.count == 0) {
-
- [_tableview addEmptyViewWithImageName:@"crm_all_noData" title:@""];
- }
- [_tableview reloadData];
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- DLog(@"请求失败%@",error);
- // [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlertController:self withMessage:@"会议任务列表获取失败,请联系管理员"];
- 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:Localized(@"UU_custom_getDataFaild") ToNavi:self.navigationController withColor:nil];
-
- }
- }];
- }
- @end
|