//
//  SATaskPartView.m
//  Macalline
//
//  Created by qianjun_work on 15-7-1.
//  Copyright (c) 2015年 JianjiYuan. All rights reserved.
//

#import "TaskListView.h"
#import "TaskListViewController.h"
#import <UIImageView+WebCache.h>

@interface PartTaskListCell : BaseTableViewCell

@property (nonatomic, strong) UIImageView *imageVContent;
@property (nonatomic, strong) UILabel *lblTitle;
@property (nonatomic, strong) UILabel *lblDueTime;
@property (nonatomic, strong) UILabel *lblDueTimeEnd;
@property (nonatomic, strong) UILabel *lblCheckPointStatus;
@property (nonatomic, strong) UILabel *lblStatus;
@property (nonatomic, strong) UIView *viewLine;
@property (nonatomic, strong) UIView *viewProcess;
@property (nonatomic, strong) UIView *viewProcessBG;
@property (nonatomic, strong) UIImageView *imageVUser;

@end

@implementation TaskListView
{
    UIDatePicker* startDatePicker;
    UIDatePicker* endDatePicker;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self initCommonView];
    }
    return self;
}

-(id) initWithFrame:(CGRect)frame andArray:(NSArray*)arr;
{
    if (self = [super initWithFrame:frame]) {
        self.arrContent = arr;
        [self initCommonView];
    }
    return self;
}
-(id) initWithFrame:(CGRect)frame andHistoryArray:(NSArray*)arr
{
    if (self = [super initWithFrame:frame]) {
        self.arrContent = arr;
        [self initHistoryCommonView];
    }
   
    return self;
}
-(id) initWithFrame:(CGRect)frame andHistoryArray1:(NSArray*)arr
{
    if (self = [super initWithFrame:frame]) {
        self.arrContent = arr;
        [self initHistoryCommonView1];
    }
  
    
    return self;
}
- (void)initCommonView
{
    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    
    UITableView* tableView = [[UITableView alloc] init];
    tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    tableView.dataSource = self;
    tableView.delegate = self;
    [self addSubview:tableView];
    [tableView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
    [tableView autoPinEdgeToSuperviewEdge:ALEdgeRight];
    [tableView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
    [tableView autoSetDimension:ALDimensionHeight toSize:375];

}
- (void)initHistoryCommonView
{
    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    if (self.arrContent.count == 0) {
        UIView * view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        [self addSubview:view];
        [view autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(20, 0, 0, 0) excludingEdge:ALEdgeTop];
        [view autoSetDimension:ALDimensionHeight toSize:280];
        
        UIImageView* image = [[UIImageView alloc] init];
        image.image = [UIImage imageNamed:@"pic_zanwushuju.png"];
        [view addSubview:image];
        [image autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(20, 50, 20, 50) excludingEdge:ALEdgeTop];
        [image autoSetDimension:ALDimensionHeight toSize:220];
    }
    else
    {
        UITableView* tableView = [[UITableView alloc] init];
        tableView.dataSource = self;
        tableView.delegate = self;
        tableView.tag = 101;
        tableView.separatorStyle = UITableViewCellSelectionStyleNone;
        [self addSubview:tableView];
        [tableView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
        [tableView autoPinEdgeToSuperviewEdge:ALEdgeRight];
        [tableView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
        [tableView autoSetDimension:ALDimensionHeight toSize:280];
        
        UIView * headView = [[UIView alloc] init];
        headView.backgroundColor = [UIColor whiteColor];
        [self addSubview:headView];
        [headView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
        [headView autoPinEdgeToSuperviewEdge:ALEdgeRight];
        [headView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:tableView];
        [headView autoSetDimension:ALDimensionHeight toSize:37];
        
        UILabel* lblTitle = [[UILabel alloc] init];
        lblTitle.text = @"审核历史记录";
        lblTitle.font = [UIFont systemFontOfSize:15];
        [headView addSubview:lblTitle];
        [lblTitle autoAlignAxis:ALAxisVertical toSameAxisOfView:headView];
        [lblTitle autoAlignAxis:ALAxisHorizontal toSameAxisOfView:headView];
        
        UIView*lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor lightGrayColor];
        [headView addSubview:lineView];
        [lineView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 5, 1, 5) excludingEdge:ALEdgeTop];
        [lineView autoSetDimension:ALDimensionHeight toSize:1];
        
        UIButton *btnclose=[[UIButton alloc] init];
        
    
        
        btnclose = [UIButton buttonWithType:UIButtonTypeCustom];
        btnclose.translatesAutoresizingMaskIntoConstraints = NO;
        [btnclose setTitle:@"关闭" forState:UIControlStateNormal];
        btnclose.titleLabel.font= [UIFont boldSystemFontOfSize:15];
        [btnclose setTitleColor:RGBColor(153, 153, 153, 1) forState:UIControlStateNormal];
        [headView addSubview:btnclose];
        [btnclose autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:headView];
        [btnclose autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:headView];
        [btnclose autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:headView];
        [btnclose autoSetDimension:ALDimensionWidth toSize:50];
        
        [btnclose addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
        
    }

}

- (void)initHistoryCommonView1
{
    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    if (self.arrContent.count == 0) {
        UIView * view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        [self addSubview:view];
        [view autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(20, 0, 0, 0) excludingEdge:ALEdgeTop];
        [view autoSetDimension:ALDimensionHeight toSize:280];
        
        UIImageView* image = [[UIImageView alloc] init];
        image.image = [UIImage imageNamed:@"pic_zanwushuju.png"];
        [view addSubview:image];
        [image autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(20, 50, 20, 50) excludingEdge:ALEdgeTop];
        [image autoSetDimension:ALDimensionHeight toSize:220];
    }
    else
    {
        UITableView* tableView = [[UITableView alloc] init];
        tableView.dataSource = self;
        tableView.delegate = self;
        tableView.tag = 102;
        tableView.separatorStyle = UITableViewCellSelectionStyleNone;
        [self addSubview:tableView];
        [tableView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
        [tableView autoPinEdgeToSuperviewEdge:ALEdgeRight];
        [tableView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
        [tableView autoSetDimension:ALDimensionHeight toSize:280];
        
        UIView * headView = [[UIView alloc] init];
        headView.backgroundColor = [UIColor whiteColor];
        [self addSubview:headView];
        [headView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
        [headView autoPinEdgeToSuperviewEdge:ALEdgeRight];
        [headView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:tableView];
        [headView autoSetDimension:ALDimensionHeight toSize:37];
        
        UILabel* lblTitle = [[UILabel alloc] init];
        lblTitle.text = @"审核历史记录";
        lblTitle.font = [UIFont systemFontOfSize:15];
        [headView addSubview:lblTitle];
        [lblTitle autoAlignAxis:ALAxisVertical toSameAxisOfView:headView];
        [lblTitle autoAlignAxis:ALAxisHorizontal toSameAxisOfView:headView];
        
        UIView*lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor lightGrayColor];
        [headView addSubview:lineView];
        [lineView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 5, 1, 5) excludingEdge:ALEdgeTop];
        [lineView autoSetDimension:ALDimensionHeight toSize:1];
        
        UIButton *btnclose=[[UIButton alloc] init];
        
        
        
        btnclose = [UIButton buttonWithType:UIButtonTypeCustom];
        btnclose.translatesAutoresizingMaskIntoConstraints = NO;
        [btnclose setTitle:@"关闭" forState:UIControlStateNormal];
        btnclose.titleLabel.font= [UIFont boldSystemFontOfSize:15];
        [btnclose setTitleColor:RGBColor(153, 153, 153, 1) forState:UIControlStateNormal];
        [headView addSubview:btnclose];
        [btnclose autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:headView];
        [btnclose autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:headView];
        [btnclose autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:headView];
        [btnclose autoSetDimension:ALDimensionWidth toSize:50];
        
        [btnclose addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
}



-(void)closeView
{
    [self removeFromSuperview];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 101) {
        static NSString *cellIndentity = @"TaskCheckHistoryCell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentity];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentity];
        }
        NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
        [inputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDateFormatter *inputFormatter1 = [[NSDateFormatter alloc] init];
        [inputFormatter1 setDateFormat:@"yyyy-MM-dd"];
        NSDate* date = [inputFormatter dateFromString:_arrContent[indexPath.row][@"reviewTime"]];
        
        UILabel* lblReviewTime = [[UILabel alloc] init];
        lblReviewTime.backgroundColor = [UIColor whiteColor];
        lblReviewTime.font = [UIFont systemFontOfSize:14];
        lblReviewTime.textColor = [UIColor darkGrayColor];
        lblReviewTime.text = [NSString stringWithFormat:@"审核日期:%@",[inputFormatter1 stringFromDate:date]];
        [cell.contentView addSubview:lblReviewTime];
        [lblReviewTime autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
        [lblReviewTime autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [lblReviewTime autoSetDimensionsToSize:CGSizeMake(260, 15)];
        
        UILabel* lblReviewPeople = [[UILabel alloc] init];
        lblReviewPeople.backgroundColor = [UIColor whiteColor];
        lblReviewPeople.text = [NSString stringWithFormat:@"审核人:%@",_arrContent[indexPath.row][@"reviewUserName"]];
        lblReviewPeople.font = [UIFont systemFontOfSize:14];
        lblReviewPeople.textColor = [UIColor darkGrayColor];
        [cell.contentView addSubview:lblReviewPeople];
        [lblReviewPeople autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
        [lblReviewPeople autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
        
        UILabel* lblReviewResultPro = [[UILabel alloc] init];
        lblReviewResultPro.text = @"审核结果:";
        lblReviewResultPro.backgroundColor = [UIColor whiteColor];
        lblReviewResultPro.font = [UIFont systemFontOfSize:14];
        lblReviewResultPro.textColor = [UIColor darkGrayColor];
        [cell.contentView addSubview:lblReviewResultPro];
        [lblReviewResultPro autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:lblReviewTime withOffset:12];
        [lblReviewResultPro autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
        [lblReviewResultPro autoSetDimensionsToSize:CGSizeMake(65, 15)];
        
        NSString *isPass = _arrContent[indexPath.row][@"status"];
        
        UILabel* lblReviewResult = [[UILabel alloc] init];
        if ([isPass isEqualToString:@"0"]) {
            lblReviewResult.text = @"未通过";
            lblReviewResult.textColor = RGBColor(253, 180, 83, 1);
            
        }
        else
        {
            lblReviewResult.text = @"通过";
            lblReviewResult.textColor = RGBColor(147, 191, 124, 1);
        }
        lblReviewResult.backgroundColor = [UIColor whiteColor];
        lblReviewResult.font = [UIFont systemFontOfSize:14];
        [cell.contentView addSubview:lblReviewResult];
        [lblReviewResult autoAlignAxis:ALAxisHorizontal toSameAxisOfView:lblReviewResultPro];
        [lblReviewResult autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:lblReviewResultPro];
        [lblReviewResult autoSetDimension:ALDimensionWidth toSize:250];
        
        UIView* messageView = [[UIView alloc] init];
        [cell.contentView addSubview:messageView];
        [messageView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeTop];
        [messageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:lblReviewResultPro withOffset:5];
        
        UILabel* lblReviewMessagePro = [[UILabel alloc] init];
        lblReviewMessagePro.backgroundColor = [UIColor whiteColor];
        lblReviewMessagePro.text = [NSString stringWithFormat:@"审核备注:%@",_arrContent[indexPath.row][@"content"]];
        lblReviewMessagePro.font = [UIFont systemFontOfSize:14];
        lblReviewMessagePro.textColor = [UIColor darkGrayColor];
        lblReviewMessagePro.numberOfLines = 0;
        [messageView addSubview:lblReviewMessagePro];
        [lblReviewMessagePro autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(2, 10, 2, 10)];
        
        
        UIView*lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor lightGrayColor];
        [cell.contentView addSubview:lineView];
        [lineView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 5, 1, 5) excludingEdge:ALEdgeTop];
        [lineView autoSetDimension:ALDimensionHeight toSize:1];
        
        return cell;
    }
    else  if (tableView.tag == 102)
    {
        {
       
            static NSString *cellIndentity = @"TaskCheckHistoryCell";
            
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentity];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentity];
            }
            NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
            [inputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SS"];
            NSDateFormatter *inputFormatter1 = [[NSDateFormatter alloc] init];
            [inputFormatter1 setDateFormat:@"yyyy-MM-dd"];
            NSDate* date = [inputFormatter dateFromString:_arrContent[indexPath.row][@"createTime"]];
            
            UILabel* lblReviewTime = [[UILabel alloc] init];
            lblReviewTime.backgroundColor = [UIColor whiteColor];
            lblReviewTime.font = [UIFont systemFontOfSize:14];
            lblReviewTime.textColor = [UIColor darkGrayColor];
            lblReviewTime.text = [NSString stringWithFormat:@"审核日期:%@",[inputFormatter1 stringFromDate:date]];
            [cell.contentView addSubview:lblReviewTime];
            [lblReviewTime autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
            [lblReviewTime autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
            [lblReviewTime autoSetDimensionsToSize:CGSizeMake(260, 15)];
            
            UILabel* lblReviewPeople = [[UILabel alloc] init];
            lblReviewPeople.backgroundColor = [UIColor whiteColor];
            lblReviewPeople.text = [NSString stringWithFormat:@"审核人:%@",_arrContent[indexPath.row][@"reviewName"]];
            lblReviewPeople.font = [UIFont systemFontOfSize:14];
            lblReviewPeople.textColor = [UIColor darkGrayColor];
            [cell.contentView addSubview:lblReviewPeople];
            [lblReviewPeople autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10];
            [lblReviewPeople autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
            
            UILabel* lblReviewResultPro = [[UILabel alloc] init];
            lblReviewResultPro.text = @"审核结果:";
            lblReviewResultPro.backgroundColor = [UIColor whiteColor];
            lblReviewResultPro.font = [UIFont systemFontOfSize:14];
            lblReviewResultPro.textColor = [UIColor darkGrayColor];
            [cell.contentView addSubview:lblReviewResultPro];
            [lblReviewResultPro autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:lblReviewTime withOffset:12];
            [lblReviewResultPro autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10];
            [lblReviewResultPro autoSetDimensionsToSize:CGSizeMake(65, 15)];
            
            NSString *isPass = _arrContent[indexPath.row][@"isPass"];
            
            UILabel* lblReviewResult = [[UILabel alloc] init];
            if ([isPass isEqualToString:@"0"]) {
                lblReviewResult.text = @"未通过";
                lblReviewResult.textColor = RGBColor(253, 180, 83, 1);
                
            }
            else
            {
                lblReviewResult.text = @"通过";
                lblReviewResult.textColor = RGBColor(147, 191, 124, 1);
            }
            lblReviewResult.backgroundColor = [UIColor whiteColor];
            lblReviewResult.font = [UIFont systemFontOfSize:14];
            [cell.contentView addSubview:lblReviewResult];
            [lblReviewResult autoAlignAxis:ALAxisHorizontal toSameAxisOfView:lblReviewResultPro];
            [lblReviewResult autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:lblReviewResultPro];
            [lblReviewResult autoSetDimension:ALDimensionWidth toSize:250];
            
            UIView* messageView = [[UIView alloc] init];
            [cell.contentView addSubview:messageView];
            [messageView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeTop];
            [messageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:lblReviewResultPro withOffset:5];
            
            UILabel* lblReviewMessagePro = [[UILabel alloc] init];
            lblReviewMessagePro.backgroundColor = [UIColor whiteColor];
            lblReviewMessagePro.text = [NSString stringWithFormat:@"审核备注:%@",_arrContent[indexPath.row][@"content"]];
            lblReviewMessagePro.font = [UIFont systemFontOfSize:14];
            lblReviewMessagePro.textColor = [UIColor darkGrayColor];
            lblReviewMessagePro.numberOfLines = 0;
            [messageView addSubview:lblReviewMessagePro];
            [lblReviewMessagePro autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(2, 10, 2, 10)];
            
            messageView.hidden=YES;
            
            
            UIView*lineView = [[UIView alloc] init];
            lineView.backgroundColor = [UIColor lightGrayColor];
            [cell.contentView addSubview:lineView];
            [lineView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 5, 1, 5) excludingEdge:ALEdgeTop];
            [lineView autoSetDimension:ALDimensionHeight toSize:1];
            
            return cell;
        }

    }
    else
    {
        NSString *cellIdentifier = @"TaskListCell";
        PartTaskListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        if (!cell) {
            cell = [[PartTaskListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        }
        if ([DataMgr getInstance].lastIndexOfItemNum) {
            NSLog(@"1");
        }
        else
        {
            NSLog(@"0");
        }
        cell.lblTitle.text = _arrContent[indexPath.row][@"activityName"];
        cell.lblDueTime.text = [NSString stringWithFormat:@"%@", _arrContent[indexPath.row][@"reportEndDate"]];
        cell.lblDueTimeEnd.text = @"上报截止";
        cell.lblCheckPointStatus.text = [NSString stringWithFormat:@"%@个检查点 | %@%@",_arrContent[indexPath.row][@"checkPointCount"],_arrContent[indexPath.row][@"progress"],@"%"];
        
        NSString* num = _arrContent[indexPath.row][@"progress"];
        
        CGFloat f = [num floatValue]/100;
        
        [cell.viewProcessBG autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeRight];
        [cell.viewProcessBG autoSetDimension:ALDimensionWidth toSize:100*f];
        
        NSString*status = _arrContent[indexPath.row][@"reviewStatus"];
        if ([status isEqualToString:kWeitijiaocode]) {
            cell.lblStatus.text = @"未提交";
        }
        if ([status isEqualToString:kWeishenhecode]) {
            cell.lblStatus.text = @"未审核";
            cell.lblStatus.backgroundColor = RGBColor(63, 182, 239, 1);
            
        }
        if ([status isEqualToString:kShenhetongguocode]) {
            cell.lblStatus.text = @"审核通过";
            cell.lblStatus.backgroundColor = RGBColor(129, 209, 53, 1);
            cell.lblCheckPointStatus.text = [NSString stringWithFormat:@"评分:%@",_arrContent[indexPath.row][@"score"]];
            cell.viewProcess.hidden = YES;
            cell.viewProcessBG.hidden = YES;
        }
        if ([status isEqualToString:kDaizhenggaicode]) {
            cell.lblStatus.text = @"待整改";
            cell.lblStatus.backgroundColor = RGBColor(253, 172, 57, 1);
        }
        if ([status isEqualToString:kYizhenggaicode]) {
            cell.lblStatus.text = @"已整改";
            cell.lblStatus.backgroundColor = RGBColor(63, 182, 239, 1);
            cell.lblCheckPointStatus.text = [NSString stringWithFormat:@"评分:%@",_arrContent[indexPath.row][@"score"]];
            cell.viewProcess.hidden = YES;
            cell.viewProcessBG.hidden = YES;
        }
        if ([status isEqualToString:kZhenggaishenhetongguocode]) {
            cell.lblStatus.text = @"整改审核通过";
            cell.lblStatus.backgroundColor = RGBColor(129, 209, 53, 1);
            cell.lblCheckPointStatus.text = [NSString stringWithFormat:@"评分:%@",_arrContent[indexPath.row][@"score"]];
            cell.viewProcess.hidden = YES;
            cell.viewProcessBG.hidden = YES;
        }
        //cell.lblStatus.text = @"未完成";
        [cell.imageVContent sd_setImageWithURL:[NSURL URLWithString:_arrContent[indexPath.row][@"pictureURL"]]
                              placeholderImage:[UIImage imageNamed:@"pic_jiazaizhogn.png"]
                                     completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){
                                         if (!image) {
                                             [cell.imageVContent setImage:[UIImage imageNamed:@"pic_jiazaishibai.png"]];
                                         }
                                     }];
        if ([[DataMgr getInstance].roleId isEqualToString:@"2"]) {
            cell.imageVUser.image = [UIImage imageNamed:@"icon_jiancha.png"];
        }else {
            cell.imageVUser.image = [UIImage imageNamed:@"icon_hecha.png"];
        }
        
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 101) {
        NSString *introduce = [NSString stringWithFormat:@"审核备注:%@",_arrContent[indexPath.row][@"content"]];
        CGFloat h = [introduce boundingRectWithSize:CGSizeMake(CGRectGetWidth(tableView.frame)-20, CGFLOAT_MAX)
                                       options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin
                                    attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}
                                       context:nil].size.height+71;
        return h;
    }
    if(tableView.tag==102)
        return 75;
    else
    return 90;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _arrContent.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (tableView.tag == 101 ||tableView.tag == 102) {
        return 0.01;
    }
    return 30;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (tableView.tag == 101 || tableView.tag == 102) {
        return nil;
    }
    UIView *viewHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 35)];
    //viewHeader.backgroundColor = [UIColor colorWithRed:0.2431 green:0.7137 blue:0.9373 alpha:1];
    viewHeader.backgroundColor = [UIColor whiteColor];
    
    UILabel *lblPoint = [[UILabel alloc] initWithFrame:viewHeader.frame];
    lblPoint.textColor = [UIColor darkGrayColor];
    lblPoint.backgroundColor = [UIColor clearColor];
    lblPoint.font = [UIFont boldSystemFontOfSize:13];
    lblPoint.textAlignment = NSTextAlignmentCenter;
    lblPoint.text = @"查看其它任务";
    [viewHeader addSubview:lblPoint];
    
    UIButton *btnclose=[[UIButton alloc] init];
    [btnclose setTitle:@"关闭" forState:UIControlStateNormal];
    [btnclose setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    btnclose.titleLabel.font=[UIFont boldSystemFontOfSize:13];
    btnclose.titleLabel.textAlignment=NSTextAlignmentRight;
    btnclose.backgroundColor=[UIColor clearColor];
    
    [viewHeader addSubview:btnclose];
    
    [btnclose autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:lblPoint];
    [btnclose autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:lblPoint];
    [btnclose autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:lblPoint];
    [btnclose autoSetDimension:ALDimensionWidth toSize:60];
    
    [btnclose addTarget:self action:@selector(btnCloseView) forControlEvents:UIControlEventTouchUpInside];
    
 
    UIView *viewline = [[UIView alloc] initWithFrame:CGRectMake(0, 35, self.bounds.size.width, 0.5)];
    viewline.backgroundColor = [UIColor lightGrayColor];
    [viewHeader addSubview:viewline];
    return viewHeader;
}
-(void)btnCloseView
{
    NSLog(@"~~~~~~j");
    [self removeFromSuperview];
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag != 101 &&  tableView.tag != 102) {
        if (self.BtnClickBlock) {//回调
            self.BtnClickBlock(_arrContent[indexPath.row][@"id"]);
        }
    }
}

@end
@implementation PartTaskListCell

- (void)dealloc
{
    self.imageVContent = nil;
    self.lblTitle = nil;
    self.lblDueTime = nil;
    self.lblDueTimeEnd = nil;
    self.lblCheckPointStatus = nil;
    self.lblStatus = nil;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.imageVContent autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(10, 10, 10, 0) excludingEdge:ALEdgeRight];
        [self.imageVContent autoSetDimension:ALDimensionWidth toSize:80];
        
        [self.lblTitle autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.imageVContent withOffset:10];
        [self.lblTitle autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.imageVContent];
        [self.lblTitle autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
        //[arrTitles autoDistributeViewsAlongAxis:ALAxisVertical alignedTo:ALAttributeRight withFixedSize:20 insetSpacing:YES];
        
        [self.lblDueTime autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.lblDueTime autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblTitle withOffset:5];
        
        [self.lblDueTimeEnd autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblDueTime withOffset:10];
        [self.lblDueTimeEnd autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.lblDueTime];
        
        [self.lblCheckPointStatus autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.lblCheckPointStatus autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblDueTimeEnd withOffset:5];
        
        [self.viewProcess autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.viewProcess autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblCheckPointStatus withOffset:5];
        [self.viewProcess autoSetDimensionsToSize:CGSizeMake(100, 6)];
        
        
        [self.lblStatus autoPinEdgeToSuperviewEdge:ALEdgeRight];
        [self.lblStatus autoPinEdgeToSuperviewEdge:ALEdgeBottom];
        [self.lblStatus autoSetDimensionsToSize:CGSizeMake(90, 20)];
        
        UIView *viewline = [[UIView alloc] initWithFrame:CGRectMake(0, 89.5, self.bounds.size.width, 0.5)];
        viewline.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:viewline];
        
    }
    return self;
}

#pragma mark =============  LazyLoad Properties  =============

- (UIImageView *)imageVContent
{
    if (!_imageVContent) {
        self.imageVContent = [UIImageView newAutoLayoutView];
        self.imageVContent.layer.cornerRadius = 5;
        self.imageVContent.clipsToBounds = YES;
        [self.contentView addSubview:_imageVContent];
    }
    return _imageVContent;
}

- (UIImageView *)imageVUser
{
    if (!_imageVUser) {
        self.imageVUser = [UIImageView newAutoLayoutView];
        //[self.contentView addSubview:_imageVUser];
    }
    return _imageVUser;
}

- (UIView *)viewProcess
{
    if (!_viewProcess) {
        self.viewProcess = [UIView newAutoLayoutView];
        _viewProcess.backgroundColor = [UIColor clearColor];
        _viewProcess.layer.borderWidth =1.5;
        _viewProcess.layer.borderColor = RGBColor(16, 133, 201, 1).CGColor;
        _viewProcess.layer.cornerRadius = 3;
        [self.contentView addSubview:_viewProcess];
    }
    return _viewProcess;
}

- (UIView *)viewProcessBG
{
    if (!_viewProcessBG) {
        self.viewProcessBG = [UIView newAutoLayoutView];
        _viewProcessBG.backgroundColor = RGBColor(16, 133, 201, 1);
        _viewProcessBG.layer.cornerRadius = 3;
        [self.viewProcess addSubview:_viewProcessBG];
    }
    return _viewProcessBG;
}


- (UILabel *)lblTitle
{
    if (!_lblTitle) {
        self.lblTitle = [self getAutoLayoutLabel];
        _lblTitle.font = [UIFont boldSystemFontOfSize:15];
        _lblTitle.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_lblTitle];
    }
    return _lblTitle;
}

- (UILabel *)lblStatus
{
    if (!_lblStatus) {
        self.lblStatus = [self getAutoLayoutLabel];
        _lblStatus.font = [UIFont boldSystemFontOfSize:12];
        _lblStatus.backgroundColor = [UIColor lightGrayColor];
        _lblStatus.textColor = [UIColor whiteColor];
        _lblStatus.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_lblStatus];
    }
    return _lblStatus;
}

- (UILabel *)lblDueTime
{
    if (!_lblDueTime) {
        self.lblDueTime = [self getAutoLayoutLabel];
        _lblDueTime.font = [UIFont systemFontOfSize:12];
        _lblDueTime.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_lblDueTime];
    }
    return _lblDueTime;
}

- (UILabel *)lblDueTimeEnd
{
    if (!_lblDueTimeEnd) {
        self.lblDueTimeEnd = [self getAutoLayoutLabel];
        _lblDueTimeEnd.textColor = RGBColor(253, 172, 57, 1);
        _lblDueTimeEnd.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_lblDueTimeEnd];
    }
    return _lblDueTimeEnd;
}

- (UILabel *)lblCheckPointStatus
{
    if (!_lblCheckPointStatus) {
        self.lblCheckPointStatus = [self getAutoLayoutLabel];
        _lblCheckPointStatus.textColor = [UIColor darkGrayColor];
        _lblCheckPointStatus.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_lblCheckPointStatus];
    }
    return _lblCheckPointStatus;
}

- (UILabel *)getAutoLayoutLabel
{
    UILabel *lblTemp = [UILabel newAutoLayoutView];
    lblTemp.textAlignment = NSTextAlignmentLeft;
    lblTemp.backgroundColor = [UIColor clearColor];
    lblTemp.textColor = [UIColor blackColor];
    lblTemp.font = [UIFont systemFontOfSize:13];
    lblTemp.numberOfLines = 1;
    return lblTemp;
}


@end