15下
//
// WaitFollowController.m
// Patient
//
// Created by gzz on 16/11/9.
// Copyright © 2016年 ShangYu. All rights reserved.
//
#import "WaitFollowController.h"
#import "WaitReviewM.h"
@interface WaitFollowController ()<UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>{
UIImageView *imagershujuE;
UILabel *tiwuxianLabE;
NSInteger indexSuoyin;
NSString *reportUuid;
}
@property (nonatomic,strong)UITableView *waitTableview;
@property (nonatomic,strong)NSMutableArray *dataMurt;
@end
@implementation WaitFollowController
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
//TODO...
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"待审核申请";
[self navBarWait];
[self dataOpens];
[self makeUIWait];
[self dataRequesWaitList];
[self zanwuDataWait];
[self DownFreshWait];
[self upFreshWait];
}
//下拉刷新
-(void)DownFreshWait{
__weak WaitFollowController *puad = self;
[puad.waitTableview addHeaderWithCallback:^{
[puad.dataMurt removeAllObjects];
[_dataMurt removeAllObjects];
[puad dataRequesWaitList];
[puad.waitTableview headerEndRefreshing];
}];
}
//上拉加载
-(void)upFreshWait{
__weak WaitFollowController *pudb = self;
[pudb.waitTableview addFooterWithCallback:^{
[pudb.waitTableview footerEndRefreshing];
}];
}
-(void)zanwuDataWait{
imagershujuE = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-ImagerWuWidth/2, SCREEN_HEIGHT/2-ImagerWuheight/2-22, ImagerWuWidth, ImagerWuheight)];
imagershujuE.image = [UIImage imageNamed:@"zanwushuju2"];
[self.view addSubview:imagershujuE];
tiwuxianLabE = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-300/2, CGRectGetMaxY(imagershujuE.frame), 300, 30)];
tiwuxianLabE.text = @"暂时没有待申请审核专家";
tiwuxianLabE.textAlignment = YES;
tiwuxianLabE.textColor = RGB(188, 188, 188);
tiwuxianLabE.font = SYSTEMFONT(TishiLabFont);
[self.view addSubview:tiwuxianLabE];
}
#pragma mark 数据的初始化
-(void)dataOpens{
indexSuoyin = 0;
_dataMurt = [NSMutableArray array];
}
#pragma mark dataRequestInterface 数据请求的接口
-(void)dataRequesWaitList{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *Srurl = [NSString stringWithFormat:@"%@findPatientApplyUnAudit",Public_URL];
NSMutableDictionary *dicm = [NSMutableDictionary dictionary];
Dlpontlerexple *dlpo = [Dlpontlerexple shareIndence];
dicm[@"patientUuid"] = dlpo.uuidstring;
[manager POST: Srurl parameters:dicm progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];
if ([coder isEqualToString:@"1"]) {
NSMutableArray * arr = [dic objectForKey:@"patientApplys"];
if (arr.count>0) {
// [_dataMurt addObjectsFromArray:arr];
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *dict in arr) {
WaitReviewM *appViewModel = [[WaitReviewM alloc]initWithDict:dict];
[tempArray addObject:appViewModel];
}
[_dataMurt addObject:tempArray];
[_waitTableview reloadData];
}
}else{
[self showHint:[dic objectForKey:@"message"]];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (_dataMurt.count>0) {
imagershujuE.hidden = YES;
tiwuxianLabE.hidden = YES;
}else{
imagershujuE.hidden = NO;
tiwuxianLabE.hidden = NO;
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
#pragma mark 界面
-(void)makeUIWait{
_waitTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
_waitTableview.backgroundColor = [UIColor clearColor];
[self.view addSubview:_waitTableview];
_waitTableview.dataSource = self;
_waitTableview.delegate = self;
_waitTableview.showsVerticalScrollIndicator = NO;
_waitTableview.tableFooterView = [[UIView alloc]init];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 68;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _dataMurt.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIn=@"cellWaitFollow";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIn ];
if (!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIn];
}
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (_dataMurt.count>0) {
NSDictionary *dicel = [DicRemove clearErrorData11a:[_dataMurt objectAtIndex:indexPath.row]];
WaitReviewM *appViewModel = [_dataMurt objectAtIndex:indexPath.row];
//gzz1116
// NSString *hearImagecell = [NSString stringWithFormat:@"%@%@",ImageUrl,dicel[@"expertPhoto"]];
NSString *hearImagecell = [NSString stringWithFormat:@"%@%@",ImageUrl,appViewModel.expertName];
UIImageView *lifimageherar = [[UIImageView alloc]initWithFrame:CGRectMake(14, 7, 54, 54)];
[lifimageherar sd_setImageWithURL:[NSURL URLWithString:hearImagecell] placeholderImage:[UIImage imageNamed:@"patientMoren"]];
lifimageherar.layer.masksToBounds = YES;
lifimageherar.layer.cornerRadius = 27;
[cell.contentView addSubview:lifimageherar];
UILabel *laname = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lifimageherar.frame)+10, 26, SCREEN_WIDTH-165, 20)];
// NSString *steee= [NSString stringWithFormat:@"%@",[dicel objectForKey:@"expertName"]];
NSString *steee= [NSString stringWithFormat:@"%@",appViewModel.expertName];
laname.text = steee;
laname.centerY = lifimageherar.centerY;
laname.font = SYSTEMFONT(16);
laname.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:laname];
UILabel *cheLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-84, 12, 70, 20)];
cheLabel.centerY = lifimageherar.centerY;
cheLabel.text = @"撤销申请";
cheLabel.font = SYSTEMFONT(16);
cheLabel.textColor = JISECOLOR;
cheLabel.textAlignment = NSTextAlignmentRight;
cheLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:cheLabel];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MCLog(@"点击的cell----%zd",indexPath.row);
UIAlertView *alrt = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您是否确定取消该随访申请" delegate:self cancelButtonTitle:@"确认" otherButtonTitles:@"取消", nil];
[alrt show];
reportUuid = [NSString stringWithFormat:@"%@",[[_dataMurt objectAtIndex:indexPath.row] objectForKey:@"uuid"]];
indexSuoyin = indexPath.row;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) {
MCLog(@"确定按钮---tag%zd",indexSuoyin);
[self cancelFollowRequest];
//调用接口
}else{
MCLog(@"quxiao按钮---tag%zd",indexSuoyin);
}
}
#pragma mark 取消随访的接口
-(void)cancelFollowRequest{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *Srurl = [NSString stringWithFormat:@"%@concelApply",Public_URL];
NSMutableDictionary *dicm = [NSMutableDictionary dictionary];
Dlpontlerexple *dlpo = [Dlpontlerexple shareIndence];
dicm[@"patientUuid"] = dlpo.uuidstring;
dicm[@"uuid"] =[NSString stringWithFormat:@"%@",reportUuid];
[manager POST: Srurl parameters:dicm progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];
if ([coder isEqualToString:@"1"]) {
[_dataMurt removeObjectAtIndex:indexSuoyin];
[_waitTableview reloadData];//返回的剩下的专家的列表信息
}else{
[self showHint:[dic objectForKey:@"message"]];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (_dataMurt.count>0) {
imagershujuE.hidden = YES;
tiwuxianLabE.hidden = YES;
}else{
imagershujuE.hidden = NO;
tiwuxianLabE.hidden = NO;
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
#pragma mark navbar及返回
-(void)navBarWait{
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClickWait)];
self.navigationItem.leftBarButtonItem=backItem;
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
-(void)backClickWait{
[self.navigationController popViewControllerAnimated:YES];
}
@end