//
//  TaskCheckViewController.m
//  Macalline
//
//  Created by JianjiYuan on 14-12-4.
//  Copyright (c) 2014年 JianjiYuan. All rights reserved.
//

#import "SATaskCheckViewController.h"
#import "TaskUploadViewController.h"
#import "ImageBrowserViewController.h"
#import "UIScrollView+Customized.h"

@interface SATaskCheckHeader : UIView
@property (nonatomic, strong) UIView *viewDone;

@property (nonatomic, strong) UIButton *StatusImage;


@property (nonatomic, strong) UILabel *lblPointPre;
@property (nonatomic, strong) UILabel *lblPoint;
@property (nonatomic, strong) UILabel *lblRemarkPre;
@property (nonatomic, strong) UILabel *lblRemark;
@property (nonatomic, strong) UILabel *lblCheckAreaPre;
@property (nonatomic, strong) UILabel *lblCheckArea;
@property (nonatomic, strong) UILabel *lblImageNumPre;
@property (nonatomic, strong) UILabel *lblImageNum;
@property (nonatomic, strong) UILabel *lblStandardPre;
@property (nonatomic, strong) UILabel *lblStandard;

@end
@interface SATaskCheckHeader1 : UIView
@property (nonatomic, strong) UIView *viewDone;

@property (nonatomic, strong) UIButton *StatusImage;


@property (nonatomic, strong) UILabel *lblPointPre;
@property (nonatomic, strong) UILabel *lblPoint;
@property (nonatomic, strong) UILabel *lblRemarkPre;
@property (nonatomic, strong) UILabel *lblRemark;
@property (nonatomic, strong) UILabel *lblCheckAreaPre;
@property (nonatomic, strong) UILabel *lblCheckArea;
@property (nonatomic, strong) UILabel *lblImageNumPre;
@property (nonatomic, strong) UILabel *lblImageNum;
@property (nonatomic, strong) UILabel *lblStandardPre;
@property (nonatomic, strong) UILabel *lblStandard;

@end
@interface SATaskCheckViewController () < ImageBrowserDelegate ,UIGestureRecognizerDelegate>
{
    UIView *viewExample;
    NSLayoutConstraint *layoutCtScrollBottm;
    int checkpointIndex;
    
    
}
@property (nonatomic,strong)TaskListView *view1;
@property (nonatomic,strong)TaskPointReview *taskPointView;
@property (nonatomic, strong) SATaskCheckHeader *headerView;
@property (nonatomic, strong) SATaskCheckHeader1 *headerView1;
@property (nonatomic, strong) UILabel *lblExample;

@property (nonatomic, strong) UILabel *lblExampleNum;

@property (nonatomic, strong) UILabel *lblExampleNoPic;
@property (nonatomic, strong) ImageBrowserViewController *vcImageBExample;

@property (nonatomic, strong) UILabel *lblCheckRemarkPre;
@property (nonatomic, strong) UILabel *lblCheckRemarkNum;

@property (nonatomic, strong) UILabel *lblCheckRemark;
@property (nonatomic, strong) ImageBrowserViewController *vcImageBReal;

@property (nonatomic, strong) UILabel *lblCheck;
@property (nonatomic, strong) ImageBrowserViewController *vcImageBCheck;

@property (nonatomic, strong) UIScrollView *scrollVContainer;

@property (nonatomic, strong) NSDictionary *dictDetails;
@property (nonatomic, strong) NSMutableArray *hitoryArr;
@property (nonatomic, strong) NSString *picNum;

@property (nonatomic, strong) UILabel *lblBeizhuPre;
@property (nonatomic, strong) UILabel *lblBeizhu;
@property (nonatomic,strong) UIButton* btnCheckTask;
@property (nonatomic,strong) UIButton* btnCheckHist;
@end

@implementation SATaskCheckViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view
    
    UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnBack setBackgroundImage:[UIImage imageNamed:@"NavBar/btn_nav_back.png"] forState:UIControlStateNormal];
    [btnBack sizeToFit];
    [btnBack addTarget:self action:@selector(btnBack) forControlEvents:UIControlEventTouchUpInside];
    
    [self.navigationController navbarLeftItemCustomized:@[btnBack] onwer:self.navigationItem];
    
    checkpointIndex = [self.checkPointIdArr indexOfObject:self.checkPointRecordId];
    
    viewExample = [UIView newAutoLayoutView];
    viewExample.backgroundColor = [UIColor whiteColor];
    [self.scrollVContainer addSubview:viewExample];
   
    
    [viewExample addSubview:self.lblExampleNoPic];
    [viewExample addSubview:self.vcImageBExample.view];
    [self addChildViewController:_vcImageBExample];
    [self.scrollVContainer autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeBottom];
    
    [self.headerView autoPinEdgeToSuperviewEdge:ALEdgeTop];
    [self.headerView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
    [self.headerView autoSetDimension:ALDimensionWidth toSize:320];
    [self.headerView autoSetDimension:ALDimensionHeight toSize:130];
   // [self setViewLayoutConstraint];
    [self.headerView1 autoPinEdgeToSuperviewEdge:ALEdgeTop];
    [self.headerView1 autoPinEdgeToSuperviewEdge:ALEdgeLeft];
    [self.headerView1 autoSetDimension:ALDimensionWidth toSize:320];
    [self.headerView1 autoSetDimension:ALDimensionHeight toSize:130];
    [self requestDatas];
    
    
}
- (void)btnBack
{
    for (UIViewController *controller in self.navigationController.viewControllers) {
        if ([controller isKindOfClass:NSClassFromString(@"SATaskDetailViewController")]) {
            [self.navigationController popToViewController:controller animated:YES];
        }
    }
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    if ([[UIApplication getObjectType:Number key:kShouldRequestDataWhenBack] boolValue]) {
        [self requestDatas];
    }
}

#pragma ---------------------   页面布局   -----------------------
- (void)setViewLayoutConstraint
{

   
    [viewExample autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.headerView.viewDone];
    [viewExample autoPinEdgeToSuperviewEdge:ALEdgeLeft];
    [viewExample autoPinEdgeToSuperviewEdge:ALEdgeRight];
    [viewExample autoSetDimension:ALDimensionHeight toSize:320];
    
    
    [self.lblExample autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:5];
    [self.lblExample autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
    [self.lblExample autoSetDimensionsToSize:CGSizeMake(65, 21)];
    
  
//
//    [self.lblExampleNum autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblExample];
//    [self.lblExampleNum autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.lblExample];
//    [self.lblExampleNum autoSetDimension:ALDimensionWidth toSize:21];
//    [self.lblExampleNum autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblExample withOffset:5];
//    
//    
    
    
    
    
    [self.vcImageBExample.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblExample withOffset:5];
    [self.lblExampleNoPic autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblExample];
    [self.lblExampleNoPic autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
    [self.lblExampleNoPic autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblExample withOffset:0];
    
    [self.vcImageBExample.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblExample withOffset:0];
    [self.vcImageBExample.view autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeTop];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma ---------------------   请求数据   -----------------------
- (void)requestDatas
{
    [UIApplication showLoadingView:kTextShowInProgress];
    NSString *interface = @"queryCheckPointDetailsEX";
    NSDictionary *dicParam = @{@"checkPointRecordId":self.checkPointRecordId};
    NSOperation *operation = [self.networkMgr operationWithURL:kBaseEXURL(interface)
                                                     interface:interface
                                                        params:dicParam
                                                      dataType:BRNetMgrDataTypeJSON
                                                        method:BRNetMgrMethodPost];
    [self.networkMgr startOperation:operation];
}

-(void)reviewHistory
{
    
    NSDictionary *dicParam = @{@"checkPointRecordId":self.checkPointRecordId};
    
    [UIApplication showLoadingView:kTextShowInProgress];
    NSString *interface = @"queryCPReviewRecordEX";
    NSOperation *operation = [self.networkMgr operationWithURL:kBaseEXURL(interface)
                                                     interface:interface
                                                        params:dicParam
                                                      dataType:BRNetMgrDataTypeJSON
                                                        method:BRNetMgrMethodPost];
    [self.networkMgr startOperation:operation];
    
    
    
}


-(void)checkClick:(NSString*)str andContent:(NSString*)content
{
//    checkpointIndex++;
//    int m = self.checkPointIdArr.count;
//    if (checkpointIndex >= m) {
//        checkpointIndex = self.checkPointIdArr.count-1;
//        [self.navigationController popViewControllerAnimated:YES];
//    }
//    else
//    {
//        NSString* str = [self.statusArr objectAtIndex:checkpointIndex];
//        if ([str isEqualToString:kWeishenhecode]||[str isEqualToString:kYizhenggaicode]) {
//            self.checkPointRecordId = [self.checkPointIdArr objectAtIndex:checkpointIndex];
//            [self requestDatas];
//        }
//        else
//        {
//            [self.navigationController popViewControllerAnimated:YES];
//        }
//        
//    }
    
    NSDictionary *dicParam = @{@"checkpointRecordId":self.checkPointRecordId,@"content":content,@"status":str};
    
    [UIApplication showLoadingView:kTextShowInProgress];
    NSString *interface = @"reviewCheckPointEX";
    NSOperation *operation = [self.networkMgr operationWithURL:kBaseEXURL(interface)
                                                     interface:interface
                                                        params:dicParam
                                                      dataType:BRNetMgrDataTypeJSON
                                                        method:BRNetMgrMethodPost];
    [self.networkMgr startOperation:operation];
}
#pragma mark =============  BRNetworkMgr Delegate  =============
- (void)httpOperationSuccess:(AFHTTPRequestOperation *)operation
                      result:(NSDictionary *)result
{
    if ([operation.userInfo[@"interface"] isEqualToString:@"reviewCheckPointEX"])
    {
        [UIApplication saveObject:@YES type:Number key:kShouldRequestDataWhenBack];
        [_taskPointView removeFromSuperview];
//        [self.navigationController popViewControllerAnimated:YES];

        checkpointIndex++;
        int m = self.checkPointIdArr.count;
        if (checkpointIndex >= m) {
            checkpointIndex = self.checkPointIdArr.count-1;
            for (UIViewController *controller in self.navigationController.viewControllers) {
                if ([controller isKindOfClass:NSClassFromString(@"SATaskDetailViewController")]) {
                    [self.navigationController popToViewController:controller animated:YES];
                }
            }
        }
        else
        {
            NSString* str = [self.statusArr objectAtIndex:checkpointIndex];
            if ([str isEqualToString:kWeishenhecode]||[str isEqualToString:kYizhenggaicode]) {
                    self.checkPointRecordId = [self.checkPointIdArr objectAtIndex:checkpointIndex];
                    [self requestDatas];
//                SATaskCheckViewController *detailVC = [[SATaskCheckViewController alloc] initWithNibName:nil bundle:nil];
//                detailVC.isEnuogh = self.arrContents[indexPath.row][@"isNumEnough"];
//                detailVC.checkPointRecordId = self.arrContents[indexPath.row][@"id"];
//                detailVC.checkPointIdArr = idArr;
//                detailVC.checkPointIsEnoughArr = isEnuoghArr;
//                detailVC.statusArr = statusArr;
//                detailVC.taskStatus = _taskStatus;
//                detailVC.isRequire =self.arrContents[indexPath.row][@"isRequire"];
                
                SATaskCheckViewController* vc = [[SATaskCheckViewController alloc] init];
                vc.isEnuogh = self.checkPointIsEnoughArr[checkpointIndex];
                vc.checkPointRecordId = self.checkPointRecordId;
                vc.checkPointIsEnoughArr = self.checkPointIsEnoughArr;
                vc.checkPointIdArr = self.checkPointIdArr;
                vc.taskStatus = self.taskStatus;
                vc.statusArr = self.statusArr;
                vc.checkPointIdArr = self.checkPointIdArr;;
                CATransition *transition = [CATransition animation];
                transition.duration = 0.5;
                transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                transition.type = kCATransitionPush;
                transition.subtype = kCATransitionFromRight;
                transition.delegate = self;
                [self.navigationController.view.layer addAnimation:transition forKey:nil];
                self.navigationController.navigationBarHidden = NO;
                
                [self.navigationController pushViewController:vc animated:YES];
            }
            else
            {
                for (UIViewController *controller in self.navigationController.viewControllers) {
                    if ([controller isKindOfClass:NSClassFromString(@"SATaskDetailViewController")]) {
                        [self.navigationController popToViewController:controller animated:YES];
                    }
                }
            }
            
        }
    }
    if ([operation.userInfo[@"interface"] isEqualToString:@"queryCPReviewRecordEX"])
    {
        self.hitoryArr = [result[@"recordList"] validDataOfClass:[NSArray class]];
        if (self.hitoryArr.count==0) {
            [UIApplication showToastViewMessage:@"该任务没有审核记录"];
        }
        else
        {
            [self addTaskHistoryListView];
        }
    }
    if ([operation.userInfo[@"interface"] isEqualToString:@"queryCheckPointDetailsEX"]) {
    
        self.dictDetails = result[@"checkPointDetails"];
        
        if([[NSString stringWithFormat:@"%@",_dictDetails[@"picRequireMode"]] isEqualToString:@"1"])
        {
            _headerView.lblStandard.hidden=YES;
            _headerView.lblStandardPre.hidden=YES;
            _headerView1.lblStandard.hidden=NO;
            _headerView1.lblStandardPre.hidden=NO;
            _headerView=(SATaskCheckHeader *)_headerView1;
        }
        else
            
        {
            _headerView1.hidden=YES;
            
        }
        
        
        self.title = [NSString stringWithFormat:@"%@ %d/%d",_dictDetails[@"name"],checkpointIndex+1, self.checkPointIdArr.count];
//        self.title = _dictDetails[@"name"]?:@"";
        if ([self.isRequire isEqualToString:@"1"]) {
            _headerView.lblPoint.text = [NSString stringWithFormat:@"%@(%@)",_dictDetails[@"name"],@"必选"];
        }
        else
        {
            _headerView.lblPoint.text = [NSString stringWithFormat:@"%@(%@)",_dictDetails[@"name"],@"可选"];
        }
        _headerView.lblRemark.text = _dictDetails[@"remark"];
        _headerView.lblStandard.text = _dictDetails[@"scoreDescription"];
        
        if([[NSString stringWithFormat:@"%@", _dictDetails[@"picRequireMode"]] isEqualToString:@"1"])
        {
            _picNum=[[NSString alloc] initWithFormat:@"%d",0];
            
        }
        else
            if([[NSString stringWithFormat:@"%@", _dictDetails[@"picRequireMode"]] isEqualToString:@"2"])
            {
                _picNum=[[NSString alloc] initWithFormat:@"%@",_dictDetails[@"reportPicNum"]];
               
                
            }
            else
            {
                _picNum=@"自定义";
            }
        
        
        
        _headerView.lblImageNum.text = _picNum;
        
        
        CGFloat hight = [_headerView.lblRemark.text boundingRectWithSize:CGSizeMake(CGRectGetWidth(_headerView.frame)-110, CGFLOAT_MAX)
                                                                 options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin
                                                              attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]}
                                                                 context:nil].size.height;
        
        [_headerView.lblRemark setFrame:CGRectMake(0, 0, CGRectGetWidth(_headerView.frame)-21, hight)];
        
        CGFloat hight1 = [_headerView.lblStandard.text boundingRectWithSize:CGSizeMake(CGRectGetWidth(_headerView.frame)-110, CGFLOAT_MAX)
                                                                 options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin
                                                              attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]}
                                                                 context:nil].size.height;
        
        [_headerView.lblStandard setFrame:CGRectMake(0, 0, CGRectGetWidth(_headerView.frame)-21, hight1)];
        
   
        if([[NSString stringWithFormat:@"%@",_dictDetails[@"picRequireMode"]] isEqualToString:@"1"])
        {
            if (hight > 20 || hight1 > 20) {
                [_headerView.viewDone setFrame:CGRectMake(0, 0, 320, 75+hight+hight1)];
                [_headerView.viewDone autoSetDimension:ALDimensionHeight toSize:75+hight+hight1];
                
            }
            else
            {
                [_headerView.viewDone setFrame:CGRectMake(0, 0, 320, 105)];
                [_headerView.viewDone autoSetDimension:ALDimensionHeight toSize:105];
            }
            
        }
        else
        {
            
            if (hight > 20 || hight1 > 20) {
                [_headerView.viewDone setFrame:CGRectMake(0, 0, 320, 101+hight+hight1)];
                
                [_headerView.viewDone autoSetDimension:ALDimensionHeight toSize:101+hight+hight1];
            }
            else
            {
                [_headerView.viewDone setFrame:CGRectMake(0, 0, 320, 130)];
                
                [_headerView.viewDone autoSetDimension:ALDimensionHeight toSize:130];
            }
            
        }
        
        
        
        [self setViewLayoutConstraint];
        
        NSString* checkPointStatus = _dictDetails[@"reviewStatus"];
        
        if ([checkPointStatus isEqualToString:kZhenggaishenhetongguocode]) {
            _headerView.StatusImage.titleLabel.font = [UIFont systemFontOfSize:12];
            _headerView.StatusImage.titleLabel.numberOfLines = 2;
            _headerView.StatusImage.contentEdgeInsets = UIEdgeInsetsMake(0, 3, 0, 3);
        }
        [_headerView.StatusImage setTitle:_dictDetails[@"reviewStatusDesc"] forState:UIControlStateNormal];
        
      
        _headerView.lblCheckArea.text = _dictDetails[@"typeDesc"];
        
        int numberOfPicItems = 2;
        
        if ([_dictDetails[@"status"] isEqualToString:@"14001"]) {//未上传
            numberOfPicItems = 2;
            
        }else
        {//已上传
        
            numberOfPicItems = 2;
            
            [self.lblCheckRemarkPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:viewExample withOffset:5];
            [self.lblCheckRemarkPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
            [self.lblCheckRemarkPre autoSetDimension:ALDimensionHeight toSize:21];
            [self.lblCheckRemarkPre autoSetDimension:ALDimensionWidth toSize:65];
            [self.lblCheckRemarkNum autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblCheckRemarkPre];
            [self.lblCheckRemarkNum autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.lblCheckRemarkPre];
            [self.lblCheckRemarkNum autoSetDimension:ALDimensionWidth toSize:21];
            [self.lblCheckRemarkNum autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblCheckRemarkPre];
        
     
        
                        
            [self.lblCheckRemark autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblCheckRemarkPre];
            [self.lblCheckRemark autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblCheckRemarkPre];
            [self.lblCheckRemark sizeToFit];
            [self.vcImageBReal.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblCheckRemark withOffset:10];
            [self.vcImageBReal.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblCheckRemark withOffset:6];
            [self.vcImageBReal.view autoPinEdgeToSuperviewEdge:ALEdgeLeft];
            [self.vcImageBReal.view autoPinEdgeToSuperviewEdge:ALEdgeRight];
            
            [self.lblBeizhuPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:_vcImageBReal.view withOffset:5];
            [self.lblBeizhuPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
            [self.lblBeizhuPre autoSetDimension:ALDimensionHeight toSize:21];
            [self.lblBeizhuPre autoSetDimension:ALDimensionWidth toSize:155];
            
            [self.lblBeizhu autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:20];
            [self.lblBeizhu autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblBeizhuPre];
            
            self.lblBeizhu.text=_dictDetails[@"realPicRemark"];
            
            [self.lblBeizhu sizeToFit];
        }

        NSArray *arrImages = [result[@"pictureList"] validDataOfClass:[NSArray class]];
        
        if (numberOfPicItems >= 1) {
            
            NSMutableArray *arrStandardImages = [NSMutableArray array];
            for (NSDictionary *dictImage in arrImages) {
                if ([dictImage[@"type"] isEqualToString:@"1"]) {
                    ImageBrowserObj *obj = [[ImageBrowserObj alloc] init];
                    obj.imageURL = dictImage[@"url"];
                    obj.sourceType = ImageSourceTypeWebURL;
                    obj.imageId = dictImage[@"id"];
                    [arrStandardImages addObject:obj];
                }
                
            }
            
            if (arrStandardImages.count == 0) {
                self.lblExampleNum.hidden=NO;
                
                self.lblExampleNoPic.hidden = NO;
                [viewExample autoSetDimensionsToSize:CGSizeMake(320,25)];
                [_vcImageBExample reloadImageDatas];
            }
            else
            {
                self.lblExampleNoPic.hidden = YES;
                _vcImageBExample.selectedImages = arrStandardImages;
                int count = (int)arrStandardImages.count;
                int row = count/2+(count%2?1:0);
                CGFloat height = row * (_vcImageBExample.itemSize.height+_vcImageBExample.edgeInset.top+ _vcImageBExample.edgeInset.bottom);
                [viewExample autoSetDimensionsToSize:CGSizeMake(320, height+21)];
                [_vcImageBExample reloadImageDatas];
            }

            _vcImageBExample.selectedImages = arrStandardImages;
            int count = (int)arrStandardImages.count;
            int row = count/2+(count%2?1:0);
            CGFloat height = row * (_vcImageBExample.itemSize.height+_vcImageBExample.edgeInset.top+ _vcImageBExample.edgeInset.bottom);
            [viewExample autoSetDimensionsToSize:CGSizeMake(320, height+21)];
            
            
            
            [_vcImageBExample reloadImageDatas];

        }
        
        if (numberOfPicItems >= 2) {
            NSMutableArray *arrRealImages = [NSMutableArray array];
            for (NSDictionary *dictImage in arrImages) {
                if ([dictImage[@"type"] isEqualToString:@"2"]) {
                    ImageBrowserObj *obj = [[ImageBrowserObj alloc] init];
                    obj.isBGGray = YES;
                    obj.imageURL = dictImage[@"url"];
                    obj.sourceType = ImageSourceTypeWebURL;
                    obj.imageId = dictImage[@"id"];
                    [arrRealImages addObject:obj];
                }
                
            }
            if (arrRealImages.count == 0 &&[[NSString stringWithFormat:@"%@", _dictDetails[@"picRequireMode"]] isEqualToString:@"1"]) {
                self.lblCheckRemarkNum.hidden=NO;
                
                
                [_vcImageBReal.view autoSetDimensionsToSize:CGSizeMake(320, 0)];
                [_vcImageBReal reloadImageDatas];
                //1不限 2固定值 3开放定义
                if([[NSString stringWithFormat:@"%@", _dictDetails[@"picRequireMode"]] isEqualToString:@"1"])
                {
                    _lblCheckRemark.text = @"无";
                    
                }
                else if([[NSString stringWithFormat:@"%@", _dictDetails[@"picRequireMode"]] isEqualToString:@"2"])
                {
                    _lblCheckRemark.text = [NSString stringWithFormat:@"上报数量不达标,要求不少于%@张",_dictDetails[@"reportPicNum"]];
                    
                }
                else
                {
                    _lblCheckRemark.text = [NSString stringWithFormat:@"上报数量不达标,要求不少于%@张",_dictDetails[@"reportPicNum"]];
                }
            }
            else
            {
                self.lblCheckRemarkNum.hidden=YES;
                
            }
            
            _vcImageBReal.selectedImages = arrRealImages;
            int count = (int)arrRealImages.count;
            int row = count/2+(count%2?1:0);
            CGFloat height = row * (_vcImageBExample.itemSize.height+_vcImageBExample.edgeInset.top+ _vcImageBExample.edgeInset.bottom);
            [_vcImageBReal.view autoSetDimensionsToSize:CGSizeMake(320, height)];
            [_vcImageBReal reloadImageDatas];
            
            
            
            
            if ([self.isEnuogh isEqualToString:@"0"]) {
                _lblCheckRemark.text = [NSString stringWithFormat:@"上报数量不达标,要求不少于%@张",_dictDetails[@"reportPicNum"]];
            }
            else
            {
                _lblCheckRemark.hidden=YES;

                if(![[NSString stringWithFormat:@"%@", _dictDetails[@"picRequireMode"]] isEqualToString:@"1"])
                {
                    if ([self.isEnuogh isEqualToString:@"0"]) {
                        _lblCheckRemark.text = [NSString stringWithFormat:@"上报数量不达标,要求不少于%@张",_dictDetails[@"reportPicNum"]];
                    }
                    else
                    {
                        _lblCheckRemark.text = @"  ";
                    }
                }
                
            
                _vcImageBReal.selectedImages = arrRealImages;
                int count = (int)arrRealImages.count;
                int row = count/2+(count%2?1:0);
                CGFloat height = row * (_vcImageBExample.itemSize.height+_vcImageBExample.edgeInset.top+ _vcImageBExample.edgeInset.bottom);
                [_vcImageBReal.view autoSetDimensionsToSize:CGSizeMake(320, height)];
                [_vcImageBReal reloadImageDatas];
            }
            
            
            _lblBeizhu.text = _dictDetails[@"realPicRemark"];
        }
        
        NSString *introduce = self.dictDetails[@"realPicRemark"];
        CGFloat h = [introduce boundingRectWithSize:CGSizeMake(CGRectGetWidth(self.view.frame)-20, CGFLOAT_MAX)
                                            options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin
                                         attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}
                                            context:nil].size.height+15;
        
        
        _btnCheckTask = [[UIButton alloc] init];
        [_btnCheckTask setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_btnCheckTask setTitle:@"审核" forState:UIControlStateNormal];
        [_btnCheckTask setBackgroundColor:RGBColor(0, 171, 202, 1)];
        [_btnCheckTask addTarget:self action:@selector(taskPointReviewClick) forControlEvents:UIControlEventTouchUpInside];
        _btnCheckTask.titleLabel.font = [UIFont systemFontOfSize:16];
        _btnCheckTask.layer.cornerRadius = 3;
        [self.scrollVContainer addSubview:_btnCheckTask];
        
        
        [_btnCheckTask autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblBeizhu withOffset:10];
        
        [_btnCheckTask autoSetDimensionsToSize:CGSizeMake(130, 35)];
        [_btnCheckTask autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:7];
        [_btnCheckTask autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:20];
        
        _btnCheckHist = [[UIButton alloc] init];
        [_btnCheckHist setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_btnCheckHist setTitle:@"查看审核历史" forState:UIControlStateNormal];
        [_btnCheckHist setBackgroundColor:RGBColor(0, 171, 202, 1)];
        [_btnCheckHist addTarget:self action:@selector(reviewHistory) forControlEvents:UIControlEventTouchUpInside];
        _btnCheckHist.titleLabel.font = [UIFont systemFontOfSize:16];
        _btnCheckHist.layer.cornerRadius = 3;
        [self.scrollVContainer addSubview:_btnCheckHist];
        [_btnCheckHist autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblBeizhu withOffset:10];
        
        [_btnCheckHist autoSetDimensionsToSize:CGSizeMake(130, 35)];
        [_btnCheckHist autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:7];
        [_btnCheckHist autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:20];
        [_btnCheckHist autoAlignAxis:ALAxisHorizontal toSameAxisOfView:_btnCheckTask];
        
   
        
        if (numberOfPicItems == 1) {
            [viewExample autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:10 relation:NSLayoutRelationGreaterThanOrEqual];
            _btnCheckTask.hidden=YES;
            _btnCheckHist.hidden=YES;
            
            
        }else if (numberOfPicItems == 2) {
            [self.vcImageBReal.view autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:h+65 relation:NSLayoutRelationGreaterThanOrEqual];
        }else if (numberOfPicItems == 3) {
            [self.vcImageBCheck.view autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:h+65 relation:NSLayoutRelationGreaterThanOrEqual];
        }
        
 
        
        [self.scrollVContainer removeConstraint:layoutCtScrollBottm];
        layoutCtScrollBottm = [self.scrollVContainer autoPinEdgeToSuperviewEdge:ALEdgeBottom];
        
        if ([checkPointStatus isEqualToString:kWeitijiaocode]) {
            _btnCheckTask.hidden = YES;
            _btnCheckHist.hidden = YES;
        }
        else
        {
            _btnCheckTask.hidden = NO;
            _btnCheckHist.hidden = NO;
        }
        
    }
    
}
-(void)taskPointReviewClick
{
    if ([self.taskStatus isEqualToString:kWeishenhecode]||[self.taskStatus isEqualToString:kYizhenggaicode]) {
        if ([_dictDetails[@"reviewStatus"] isEqualToString:@"14002"]||[_dictDetails[@"reviewStatus"] isEqualToString:@"14005"]) {
            
            _taskPointView=[[TaskPointReview alloc] initWithFrame:self.navigationController.view.bounds];
            
            __weak typeof(SATaskCheckViewController) *weakSelf = self;
            _taskPointView.CheckClickAtIndex = ^(NSString* tag,NSString* content) {
                [weakSelf checkClick:tag andContent:content];
            };
            
            [self.navigationController.view addSubview:_taskPointView];
            
            UITapGestureRecognizer* tapGesture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Actiondo:)];
            
            tapGesture1.delegate = self;
            [_taskPointView addGestureRecognizer:tapGesture1];
            [self.navigationController.view addSubview:_taskPointView];
        }
    }
    else
    {
       [UIApplication showToastViewMessage:@"当前状态不能审核!"];
    }
}



-(void)addTaskHistoryListView
{
    _view1=[[TaskListView alloc] initWithFrame:self.navigationController.view.bounds andHistoryArray:self.hitoryArr];

    UITapGestureRecognizer* tapGesture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Actiondo:)];
    
    tapGesture1.delegate = self;
    [_view1 addGestureRecognizer:tapGesture1];
    [self.navigationController.view addSubview:_view1];
}
-(void)Actiondo:(UITapGestureRecognizer*)sender
{
    CGPoint point = [sender locationInView:self.view];
    
    NSLog(@"handleSingleTap!pointx:%f,y:%f",point.x,point.y);
    [_view1 removeFromSuperview];
    [_taskPointView removeFromSuperview];
}


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if (touch.view == _view1  || touch.view==_taskPointView)
    {
        return YES;
        
    }
    return NO;
}



- (void)httpOperationFailed:(AFHTTPRequestOperation *)operation
                      error:(NSError *)error
{
    [self.scrollVContainer autoPinEdgeToSuperviewEdge:ALEdgeBottom];
}

#pragma mark ====== UISwipeGestureRecognizer 左右滑动手势 ======
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
    
    if(recognizer.direction==UISwipeGestureRecognizerDirectionDown) {
        
        NSLog(@"swipe down");
        //执行程序
    }
    if(recognizer.direction==UISwipeGestureRecognizerDirectionUp) {
        
        NSLog(@"swipe up");
        //执行程序
    }
    
    if(recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {
        checkpointIndex++;
        int m = self.checkPointIdArr.count;
        if (checkpointIndex >= m) {
            checkpointIndex = self.checkPointIdArr.count-1;
        }
        else
        {
            self.checkPointRecordId = [self.checkPointIdArr objectAtIndex:checkpointIndex];
            SATaskCheckViewController* vc = [[SATaskCheckViewController alloc] init];
            vc.isEnuogh = self.checkPointIsEnoughArr[checkpointIndex];
            vc.checkPointRecordId = self.checkPointRecordId;
            vc.checkPointIsEnoughArr = self.checkPointIsEnoughArr;
            vc.checkPointIdArr = self.checkPointIdArr;
            
            CATransition *transition = [CATransition animation];
            transition.duration = 0.5;
            transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            transition.type = kCATransitionPush;
            transition.subtype = kCATransitionFromRight;
            transition.delegate = self;
            [self.navigationController.view.layer addAnimation:transition forKey:nil];
            self.navigationController.navigationBarHidden = NO;
            
            [self.navigationController pushViewController:vc animated:YES];
//            [self removeFromParentViewController];
        }
        
    }
    
    if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
        checkpointIndex--;
        if (checkpointIndex < 0) {
            checkpointIndex = 0;
        }
        else
        {
            self.checkPointRecordId = [self.checkPointIdArr objectAtIndex:checkpointIndex];
            SATaskCheckViewController* vc = [[SATaskCheckViewController alloc] init];
            vc.isEnuogh = self.checkPointIsEnoughArr[checkpointIndex];
            vc.checkPointRecordId = self.checkPointRecordId;
            vc.checkPointIsEnoughArr = self.checkPointIsEnoughArr;
            vc.checkPointIdArr = self.checkPointIdArr;
            
            CATransition *transition = [CATransition animation];
            transition.duration = 0.5;
            transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            transition.type = kCATransitionPush;
            transition.subtype = kCATransitionFromLeft;
            transition.delegate = self;
            [self.navigationController.view.layer addAnimation:transition forKey:nil];
            self.navigationController.navigationBarHidden = NO;
//            [self.navigationController pushViewController:viewController animated:NO];
            
            [self.navigationController pushViewController:vc animated:NO];
            //[self removeFromParentViewController];
        }
        
    }
    
}

#pragma mark =============  ImageBrowserViewController Delegate  =============

- (void)imageBrowser:(ImageBrowserViewController *)imageBrowser didSelectImages:(NSArray *)images
{
    
}

#pragma mark =============  Propertise LazyLoad  =============

- (UIScrollView *)scrollVContainer
{
    if (!_scrollVContainer) {
        self.scrollVContainer = [UIScrollView newAutoLayoutView];
        _scrollVContainer.showsHorizontalScrollIndicator = NO;
        _scrollVContainer.showsVerticalScrollIndicator = YES;
        _scrollVContainer.backgroundColor = [UIColor clearColor];
        [self.view addSubview:_scrollVContainer];
    }
    return _scrollVContainer;
}

- (UILabel *)lblExampleNoPic
{
    if (!_lblExampleNoPic) {
        self.lblExampleNoPic = [UILabel newAutoLayoutView];
        _lblExampleNoPic.text = @"无";
        _lblExampleNoPic.hidden = YES;
        _lblExampleNoPic.textColor = RGBColor(253, 176, 69, 1);
        _lblExampleNoPic.font=[UIFont systemFontOfSize:16];
        _lblExampleNoPic.backgroundColor = [UIColor clearColor];
        _lblExampleNoPic.textAlignment = NSTextAlignmentLeft;
    }
    return _lblExampleNoPic;
}

- (UILabel *)lblExample
{
    if (!_lblExample) {
        self.lblExample = [UILabel newAutoLayoutView];
        _lblExample.text = @"标准图：";
        _lblExample.textColor = RGBColor(153, 153, 153, 1);
        _lblExample.font=[UIFont systemFontOfSize:16];
        _lblExample.backgroundColor = [UIColor clearColor];
        _lblExample.textAlignment = NSTextAlignmentLeft;
        [viewExample addSubview:_lblExample];
    }
    return _lblExample;
}
- (UILabel *)lblExampleNum
{
    if (!_lblExampleNum) {
        self.lblExampleNum = [UILabel newAutoLayoutView];
        _lblExampleNum.text = @"无";
        _lblExampleNum.textColor = RGBColor(244, 160, 0, 1);
        _lblExampleNum.backgroundColor = [UIColor clearColor];
        _lblExampleNum.textAlignment = NSTextAlignmentLeft;
        _lblExampleNum.font=[UIFont systemFontOfSize:16];
        [viewExample addSubview:_lblExampleNum];
        
    }
    return _lblExampleNum;
}

- (UILabel *)lblCheckRemarkPre
{
    if (!_lblCheckRemarkPre) {
        self.lblCheckRemarkPre = [UILabel newAutoLayoutView];
        _lblCheckRemarkPre.text = @"上报图:";
        _lblCheckRemarkPre.backgroundColor = [UIColor clearColor];
        _lblCheckRemarkPre.textColor=RGBColor(153, 153, 153, 1);
    
        _lblCheckRemarkPre.font = [UIFont systemFontOfSize:16];
        _lblCheckRemarkPre.textAlignment = NSTextAlignmentLeft;
        [self.scrollVContainer addSubview:_lblCheckRemarkPre];
    }
    return _lblCheckRemarkPre;
}

- (UILabel *)lblCheckRemarkNum
{
    if (!_lblCheckRemarkNum) {
        self.lblCheckRemarkNum = [UILabel newAutoLayoutView];
        _lblCheckRemarkNum.text = @"无";
        _lblCheckRemarkNum.textColor = RGBColor(244, 160, 0, 1);
        
        _lblCheckRemarkNum.font = [UIFont systemFontOfSize:15];
        _lblCheckRemarkNum.backgroundColor = [UIColor clearColor];
        _lblCheckRemarkNum.textAlignment = NSTextAlignmentLeft;
        [self.scrollVContainer addSubview:_lblCheckRemarkNum];
    }
    return _lblCheckRemarkNum;
}




- (UILabel *)lblCheckRemark
{
    if (!_lblCheckRemark) {
        self.lblCheckRemark = [UILabel newAutoLayoutView];
        _lblCheckRemark.textColor = RGBColor(253, 176, 69, 1);
        _lblCheckRemark.backgroundColor = [UIColor clearColor];
        _lblCheckRemark.textAlignment = NSTextAlignmentLeft;
        _lblCheckRemark.font = [UIFont systemFontOfSize:16];
        [self.scrollVContainer addSubview:_lblCheckRemark];
    }
    return _lblCheckRemark;
}

- (UILabel *)lblCheck
{
    if (!_lblCheck) {
        self.lblCheck = [UILabel newAutoLayoutView];
        _lblCheck.text = @"检查人员上传：";
        _lblCheck.textColor = RGBColor(153, 153, 153, 1);
        _lblCheck.backgroundColor = [UIColor clearColor];
        _lblCheck.textAlignment = NSTextAlignmentLeft;
        [self.scrollVContainer addSubview:_lblCheck];
    }
    return _lblCheck;
}

- (UILabel *)lblBeizhuPre
{
    if (!_lblBeizhuPre) {
        self.lblBeizhuPre = [UILabel newAutoLayoutView];
        _lblBeizhuPre.text = @"上报备注：";
        _lblBeizhuPre.font = [UIFont systemFontOfSize:16];
        _lblBeizhuPre.textColor = RGBColor(153, 153, 153, 1);
        _lblBeizhuPre.backgroundColor = [UIColor clearColor];
        _lblBeizhuPre.textAlignment = NSTextAlignmentLeft;
        [self.scrollVContainer addSubview:_lblBeizhuPre];
    }
    return _lblBeizhuPre;
}

- (UILabel *)lblBeizhu
{
    if (!_lblBeizhu) {
        self.lblBeizhu = [UILabel newAutoLayoutView];
        _lblBeizhu.font = [UIFont systemFontOfSize:16];
        _lblBeizhu.textColor = RGBColor(153, 153, 153, 1);
        _lblBeizhu.backgroundColor = [UIColor clearColor];
        _lblBeizhu.textAlignment = NSTextAlignmentLeft;
        [self.scrollVContainer addSubview:_lblBeizhu];
    }
    return _lblBeizhu;
}

- (SATaskCheckHeader *)headerView
{
    if (!_headerView) {
        self.headerView = [[SATaskCheckHeader alloc] initWithFrame:CGRectZero];
        _headerView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.scrollVContainer addSubview:_headerView];
    }
    return _headerView;
}
- (SATaskCheckHeader1 *)headerView1
{
    if (!_headerView1) {
        self.headerView1 = [[SATaskCheckHeader1 alloc] initWithFrame:CGRectZero];
        _headerView1.translatesAutoresizingMaskIntoConstraints = NO;
        [self.scrollVContainer addSubview:_headerView1];
    }
    return _headerView1;
}
- (ImageBrowserViewController *)vcImageBExample
{
    if (!_vcImageBExample) {
        self.vcImageBExample = [[ImageBrowserViewController alloc] initWithNibName:nil bundle:nil];
        _vcImageBExample.showAddPicsButton = NO;
        _vcImageBExample.delegate = self;
        _vcImageBExample.collectionView.scrollEnabled = NO;
        _vcImageBExample.vcImagePickerPrensentFrom = self.navigationController;
    }
    return _vcImageBExample;
}

- (ImageBrowserViewController *)vcImageBReal
{
    if (!_vcImageBReal) {
        self.vcImageBReal = [[ImageBrowserViewController alloc] initWithNibName:nil bundle:nil];
        _vcImageBReal.delegate = self;
        _vcImageBReal.showAddPicsButton = NO;
        _vcImageBReal.collectionView.scrollEnabled = NO;
        _vcImageBReal.vcImagePickerPrensentFrom = self.navigationController;
        [self addChildViewController:_vcImageBReal];
        [self.scrollVContainer addSubview:_vcImageBReal.view];
    }
    return _vcImageBReal;
}

- (ImageBrowserViewController *)vcImageBCheck
{
    if (!_vcImageBCheck) {
        self.vcImageBCheck = [[ImageBrowserViewController alloc] initWithNibName:nil bundle:nil];
        _vcImageBCheck.delegate = self;
        _vcImageBCheck.showAddPicsButton = NO;
        _vcImageBCheck.collectionView.scrollEnabled = NO;
        _vcImageBCheck.vcImagePickerPrensentFrom = self.navigationController;
        [self addChildViewController:_vcImageBCheck];
        [self.scrollVContainer addSubview:_vcImageBCheck.view];
    }
    return _vcImageBCheck;
}



@end

#pragma ---------------------   自定义View   -----------------------
@implementation SATaskCheckHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
  
        
        [self.viewDone autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeBottom];
        [self.viewDone autoPinEdgeToSuperviewEdge:ALEdgeLeft];
        [self.viewDone autoPinEdgeToSuperviewEdge:ALEdgeRight];
        
        [self.viewDone addSubview:self.lblPointPre];
        [self.viewDone addSubview:self.lblPoint];
        [self.viewDone addSubview:self.lblRemarkPre];
        [self.viewDone addSubview:self.lblRemark];
        [self.viewDone addSubview:self.lblCheckAreaPre];
        [self.viewDone addSubview:self.lblCheckArea];
        [self.viewDone addSubview:self.lblStandardPre];
        [self.viewDone addSubview:self.lblStandard];
        [self.viewDone addSubview:self.StatusImage];
        [self.viewDone addSubview:self.lblImageNumPre];
        [self.viewDone addSubview:self.lblImageNum];
        
        [self.lblPointPre autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:4];
        [self.lblPointPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblPointPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        
        [self.lblPoint autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblPointPre];
        [self.lblPoint autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblPointPre];
        [self.lblPoint autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblPoint autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        [self.lblPoint sizeToFit];
        
        
        [self.lblCheckAreaPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblPoint withOffset:5];
        [self.lblCheckAreaPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblCheckAreaPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        [self.lblCheckArea autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblCheckAreaPre];
        [self.lblCheckArea autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblCheckAreaPre];
        [self.lblCheckArea autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblCheckArea sizeToFit];
        [self.lblCheckArea autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
        
        [self.lblImageNumPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblCheckArea withOffset:5];
        [self.lblImageNumPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblImageNumPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        [self.lblImageNum autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblImageNumPre];
        [self.lblImageNum autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblImageNumPre];
        [self.lblImageNum autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblImageNum sizeToFit];
        [self.lblImageNum autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
        
        [self.lblRemarkPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblImageNum withOffset:5];
        [self.lblRemarkPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblRemarkPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        [self.lblRemark autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblRemarkPre];
        [self.lblRemark autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblRemarkPre];
        [self.lblRemark autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblRemark sizeToFit];
        [self.lblRemark autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
        
        
        [self.lblStandardPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblRemark withOffset:5];
        [self.lblStandardPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblStandardPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        
        [self.lblStandard autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblStandardPre];
        [self.lblStandard autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblStandardPre];
        [self.lblStandard autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblStandard sizeToFit];
        [self.lblStandard autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
        [self.StatusImage autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:4];
        [self.StatusImage autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:15];
        [self.StatusImage autoSetDimensionsToSize:CGSizeMake(50, 50)];
        
    }
    return self;
}

- (UIView *)viewDone
{
    if (!_viewDone) {
        self.viewDone = [UIView newAutoLayoutView];
        _viewDone.backgroundColor = [UIColor colorWithRed:0.8667 green:0.8667 blue:0.8667 alpha:1];
        [self addSubview:_viewDone];
    }
    return _viewDone;
}



- (UIButton *)StatusImage
{
    if (!_StatusImage) {
        self.StatusImage = [UIButton newAutoLayoutView];
        [self.StatusImage setBackgroundImage:[UIImage imageNamed:@"Task/icon_bg_no_report.png"] forState:UIControlStateNormal];
        [self.StatusImage setTitle:@"已上报" forState:UIControlStateNormal];
        self.StatusImage.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _StatusImage;
}



- (UILabel *)lblPointPre
{
    if (!_lblPointPre) {
        self.lblPointPre = [UILabel newAutoLayoutView];
        _lblPointPre.text = @"检 查 点 ：";
        _lblPointPre.textColor = RGBColor(102, 102, 102, 1);
        _lblPointPre.backgroundColor = [UIColor clearColor];
        _lblPointPre.textAlignment = NSTextAlignmentLeft;
        _lblPointPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblPointPre;
}

- (UILabel *)lblPoint
{
    if (!_lblPoint) {
        self.lblPoint = [UILabel newAutoLayoutView];
        _lblPoint.textColor = RGBColor(102, 102, 102, 1);
        _lblPoint.backgroundColor = [UIColor clearColor];
        _lblPoint.textAlignment = NSTextAlignmentLeft;
        _lblPoint.font = [UIFont systemFontOfSize:16];
    }
    return _lblPoint;
}

- (UILabel *)lblRemarkPre
{
    if (!_lblRemarkPre) {
        self.lblRemarkPre = [UILabel newAutoLayoutView];
        _lblRemarkPre.text = @"检查要求：";
        _lblRemarkPre.textColor = RGBColor(102, 102, 102, 1);
        _lblRemarkPre.backgroundColor = [UIColor clearColor];
        _lblRemarkPre.textAlignment = NSTextAlignmentLeft;
        _lblRemarkPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblRemarkPre;
}

- (UILabel *)lblRemark
{
    if (!_lblRemark) {
        self.lblRemark = [UILabel newAutoLayoutView];
        _lblRemark.textColor = RGBColor(102, 102, 102, 1);
        _lblRemark.backgroundColor = [UIColor clearColor];
        _lblRemark.textAlignment = NSTextAlignmentLeft;
        _lblRemark.font = [UIFont systemFontOfSize:16];
        _lblRemark.numberOfLines = 0;
    }
    return _lblRemark;
}

- (UILabel *)lblCheckAreaPre
{
    if (!_lblCheckAreaPre) {
        self.lblCheckAreaPre = [UILabel newAutoLayoutView];
        _lblCheckAreaPre.text = @"所属区域：";
        _lblCheckAreaPre.textColor = RGBColor(102, 102, 102, 1);
        _lblCheckAreaPre.backgroundColor = [UIColor clearColor];
        _lblCheckAreaPre.textAlignment = NSTextAlignmentLeft;
        _lblCheckAreaPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblCheckAreaPre;
}

- (UILabel *)lblImageNum
{
    if (!_lblImageNum) {
        self.lblImageNum = [UILabel newAutoLayoutView];
        _lblImageNum.textColor = RGBColor(102, 102, 102, 1);
        _lblImageNum.backgroundColor = [UIColor clearColor];
        _lblImageNum.textAlignment = NSTextAlignmentLeft;
        _lblImageNum.font = [UIFont systemFontOfSize:16];
    }
    return _lblImageNum;
}

- (UILabel *)lblImageNumPre
{
    if (!_lblImageNumPre) {
        self.lblImageNumPre = [UILabel newAutoLayoutView];
        _lblImageNumPre.text = @"图片要求：";
        _lblImageNumPre.textColor = RGBColor(102, 102, 102, 1);
        _lblImageNumPre.backgroundColor = [UIColor clearColor];
        _lblImageNumPre.textAlignment = NSTextAlignmentLeft;
        _lblImageNumPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblImageNumPre;
}

- (UILabel *)lblCheckArea
{
    if (!_lblCheckArea) {
        self.lblCheckArea = [UILabel newAutoLayoutView];
        _lblCheckArea.textColor = RGBColor(102, 102, 102, 1);
        _lblCheckArea.backgroundColor = [UIColor clearColor];
        _lblCheckArea.textAlignment = NSTextAlignmentLeft;
        _lblCheckArea.font = [UIFont systemFontOfSize:16];
    }
    return _lblCheckArea;
}

- (UILabel *)lblStandardPre
{
    if (!_lblStandardPre) {
        self.lblStandardPre = [UILabel newAutoLayoutView];
        _lblStandardPre.text = @"评分标准：";
        _lblStandardPre.textColor = RGBColor(102, 102, 102, 1);
        _lblStandardPre.backgroundColor = [UIColor clearColor];
        _lblStandardPre.textAlignment = NSTextAlignmentLeft;
        _lblStandardPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblStandardPre;
}

- (UILabel *)lblStandard
{
    if (!_lblStandard) {
        self.lblStandard = [UILabel newAutoLayoutView];
        _lblStandard.textColor = RGBColor(102, 102, 102, 1);
        _lblStandard.backgroundColor = [UIColor clearColor];
        _lblStandard.textAlignment = NSTextAlignmentLeft;
        _lblStandard.font = [UIFont systemFontOfSize:16];
        _lblStandard.numberOfLines = 0;
    }
    return _lblStandard;
}


@end



@implementation SATaskCheckHeader1

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        
        [self.viewDone autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeBottom];
        [self.viewDone autoPinEdgeToSuperviewEdge:ALEdgeLeft];
        [self.viewDone autoPinEdgeToSuperviewEdge:ALEdgeRight];
        
        [self.viewDone addSubview:self.lblPointPre];
        [self.viewDone addSubview:self.lblPoint];
        [self.viewDone addSubview:self.lblRemarkPre];
        [self.viewDone addSubview:self.lblRemark];
        [self.viewDone addSubview:self.lblCheckAreaPre];
        [self.viewDone addSubview:self.lblCheckArea];
        [self.viewDone addSubview:self.lblStandardPre];
        [self.viewDone addSubview:self.lblStandard];
        [self.viewDone addSubview:self.StatusImage];
        [self.viewDone addSubview:self.lblImageNumPre];
        [self.viewDone addSubview:self.lblImageNum];
        
        [self.lblPointPre autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:4];
        [self.lblPointPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblPointPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        
        [self.lblPoint autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblPointPre];
        [self.lblPoint autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblPointPre];
        [self.lblPoint autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblPoint autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        [self.lblPoint sizeToFit];
        
        
        [self.lblCheckAreaPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblPoint withOffset:5];
        [self.lblCheckAreaPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblCheckAreaPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        [self.lblCheckArea autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblCheckAreaPre];
        [self.lblCheckArea autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblCheckAreaPre];
        [self.lblCheckArea autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblCheckArea sizeToFit];
        [self.lblCheckArea autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
     
        
        [self.lblRemarkPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblCheckArea withOffset:5];
        [self.lblRemarkPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblRemarkPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        [self.lblRemark autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblRemarkPre];
        [self.lblRemark autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblRemarkPre];
        [self.lblRemark autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblRemark sizeToFit];
        [self.lblRemark autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
        
        
        [self.lblStandardPre autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblRemark withOffset:5];
        [self.lblStandardPre autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [self.lblStandardPre autoSetDimensionsToSize:CGSizeMake(80, 21)];
        
        [self.lblStandard autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblStandardPre];
        [self.lblStandard autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblStandardPre];
        [self.lblStandard autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:8];
        [self.lblStandard sizeToFit];
        [self.lblStandard autoSetDimension:ALDimensionHeight toSize:21 relation:NSLayoutRelationGreaterThanOrEqual];
        
        [self.StatusImage autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:4];
        [self.StatusImage autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:15];
        [self.StatusImage autoSetDimensionsToSize:CGSizeMake(50, 50)];
        
    }
    return self;
}

- (UIView *)viewDone
{
    if (!_viewDone) {
        self.viewDone = [UIView newAutoLayoutView];
        _viewDone.backgroundColor = [UIColor colorWithRed:0.8667 green:0.8667 blue:0.8667 alpha:1];
        [self addSubview:_viewDone];
    }
    return _viewDone;
}



- (UIButton *)StatusImage
{
    if (!_StatusImage) {
        self.StatusImage = [UIButton newAutoLayoutView];
        [self.StatusImage setBackgroundImage:[UIImage imageNamed:@"Task/icon_bg_no_report.png"] forState:UIControlStateNormal];
        [self.StatusImage setTitle:@"已上报" forState:UIControlStateNormal];
        self.StatusImage.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _StatusImage;
}



- (UILabel *)lblPointPre
{
    if (!_lblPointPre) {
        self.lblPointPre = [UILabel newAutoLayoutView];
        _lblPointPre.text = @"检 查 点 ：";
        _lblPointPre.textColor = RGBColor(102, 102, 102, 1);
        _lblPointPre.backgroundColor = [UIColor clearColor];
        _lblPointPre.textAlignment = NSTextAlignmentLeft;
        _lblPointPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblPointPre;
}

- (UILabel *)lblPoint
{
    if (!_lblPoint) {
        self.lblPoint = [UILabel newAutoLayoutView];
        _lblPoint.textColor = RGBColor(102, 102, 102, 1);
        _lblPoint.backgroundColor = [UIColor clearColor];
        _lblPoint.textAlignment = NSTextAlignmentLeft;
        _lblPoint.font = [UIFont systemFontOfSize:16];
    }
    return _lblPoint;
}

- (UILabel *)lblRemarkPre
{
    if (!_lblRemarkPre) {
        self.lblRemarkPre = [UILabel newAutoLayoutView];
        _lblRemarkPre.text = @"检查要求：";
        _lblRemarkPre.textColor = RGBColor(102, 102, 102, 1);
        _lblRemarkPre.backgroundColor = [UIColor clearColor];
        _lblRemarkPre.textAlignment = NSTextAlignmentLeft;
        _lblRemarkPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblRemarkPre;
}

- (UILabel *)lblRemark
{
    if (!_lblRemark) {
        self.lblRemark = [UILabel newAutoLayoutView];
        _lblRemark.textColor = RGBColor(102, 102, 102, 1);
        _lblRemark.backgroundColor = [UIColor clearColor];
        _lblRemark.textAlignment = NSTextAlignmentLeft;
        _lblRemark.font = [UIFont systemFontOfSize:16];
        _lblRemark.numberOfLines = 0;
    }
    return _lblRemark;
}

- (UILabel *)lblCheckAreaPre
{
    if (!_lblCheckAreaPre) {
        self.lblCheckAreaPre = [UILabel newAutoLayoutView];
        _lblCheckAreaPre.text = @"所属区域：";
        _lblCheckAreaPre.textColor = RGBColor(102, 102, 102, 1);
        _lblCheckAreaPre.backgroundColor = [UIColor clearColor];
        _lblCheckAreaPre.textAlignment = NSTextAlignmentLeft;
        _lblCheckAreaPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblCheckAreaPre;
}



- (UILabel *)lblCheckArea
{
    if (!_lblCheckArea) {
        self.lblCheckArea = [UILabel newAutoLayoutView];
        _lblCheckArea.textColor = RGBColor(102, 102, 102, 1);
        _lblCheckArea.backgroundColor = [UIColor clearColor];
        _lblCheckArea.textAlignment = NSTextAlignmentLeft;
        _lblCheckArea.font = [UIFont systemFontOfSize:16];
    }
    return _lblCheckArea;
}

- (UILabel *)lblStandardPre
{
    if (!_lblStandardPre) {
        self.lblStandardPre = [UILabel newAutoLayoutView];
        _lblStandardPre.text = @"评分标准：";
        _lblStandardPre.textColor = RGBColor(102, 102, 102, 1);
        _lblStandardPre.backgroundColor = [UIColor clearColor];
        _lblStandardPre.textAlignment = NSTextAlignmentLeft;
        _lblStandardPre.font = [UIFont systemFontOfSize:16];
    }
    return _lblStandardPre;
}

- (UILabel *)lblStandard
{
    if (!_lblStandard) {
        self.lblStandard = [UILabel newAutoLayoutView];
        _lblStandard.textColor = RGBColor(102, 102, 102, 1);
        _lblStandard.backgroundColor = [UIColor clearColor];
        _lblStandard.textAlignment = NSTextAlignmentLeft;
        _lblStandard.font = [UIFont systemFontOfSize:16];
        _lblStandard.numberOfLines = 0;
    }
    return _lblStandard;
}
@end



