RSaleView.m 6.68 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
//
//  RSaleView.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/11/13.
//  Copyright © 2015年 Xummer. All rights reserved.
//

#import "RSaleView.h"
#define LeftWidth   50
#define ImageSize 20
#define ContentHeight 30

@interface RSaleView ()
@property (nonatomic,strong)UILabel *centerLabel;
@property (nonatomic,strong)UILabel *dateLabel;
@property (nonatomic,strong)UIButton *lastWeekLabel;
@property (nonatomic,strong)UIButton *lastYearLabel;
@property (nonatomic,strong)UILabel *rateLabel;
@property (nonatomic,strong)UILabel *averageLabel;
@property (nonatomic,strong)UIImageView *lastWeekImage;
@property (nonatomic,strong)UIImageView *lastYearImage;



@end



@implementation RSaleView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self bulidLayout];
    }
    return self;
}
- (void)bulidLayout{
    
    CGRect rect = CGRectMake(0, 30, LeftWidth, 20);
  
    rect = CGRectMake(LeftWidth, 20, ScreenSize.width - LeftWidth*2 , ContentHeight);
    self.centerLabel = [[UILabel alloc]initWithFrame:rect];
    self.centerLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.centerLabel];

    
    rect = CGRectMake(0, self.centerLabel.bottom,self.width, 20);
    self.dateLabel = [[UILabel alloc]initWithFrame:rect];
    self.dateLabel.textColor = GXF_CONTENT_COLOR;
    self.dateLabel.font =  GXF_FOURTEENTH_SIZE;
    self.dateLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.dateLabel];
    
    CGFloat bottomWidth = (ScreenSize.width - 20)/4;
    
    rect = CGRectMake(10, self.dateLabel.bottom + 5,bottomWidth, ContentHeight);
    self.lastWeekLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:ReportContentColor];
    [self addSubview:self.lastWeekLabel];
    
    rect = CGRectMake(self.lastWeekLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
    UILabel *weekLabel = [[UILabel alloc]initWithFrame:rect];
    weekLabel.textColor = [UIColor lightGrayColor];
    weekLabel.text = @"比上周同期";
    weekLabel.font = GXF_THREETEENTH_SIZE;
    weekLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:weekLabel];
    
    rect = CGRectMake(self.lastWeekLabel.right, self.lastWeekLabel.top,bottomWidth, ContentHeight);
     self.lastYearLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:GXF_NAVIGAYION_COLOR];
    [self addSubview:self.lastYearLabel];

    
    rect = CGRectMake(self.lastYearLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
    UILabel *yearLabel = [[UILabel alloc]initWithFrame:rect];
    yearLabel.textColor = [UIColor lightGrayColor];
    yearLabel.text = @"比去年同期";
    yearLabel.font = GXF_THREETEENTH_SIZE;
    yearLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:yearLabel];
    
    rect = CGRectMake(self.lastYearLabel.right,self.lastWeekLabel.top,bottomWidth, ContentHeight);
    self.rateLabel = [[UILabel alloc]initWithFrame:rect];
85
    self.rateLabel.textColor = GXF_COMMIT_COLOR;
陈俊俊's avatar
陈俊俊 committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
    self.rateLabel.font =  GXF_FIFTEENTEN_SIZE;

    self.rateLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.rateLabel];
    
    rect = CGRectMake(self.rateLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
    UILabel *raLabel = [[UILabel alloc]initWithFrame:rect];
    raLabel.textColor = [UIColor lightGrayColor];
    raLabel.text = @"销售达成率";
    raLabel.font = GXF_THREETEENTH_SIZE;
    raLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:raLabel];
    
    rect = CGRectMake(self.rateLabel.right, self.lastWeekLabel.top,bottomWidth, ContentHeight);
    self.averageLabel = [[UILabel alloc]initWithFrame:rect];
101
    self.averageLabel.textColor = GXF_COMMIT_COLOR;
陈俊俊's avatar
陈俊俊 committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    self.averageLabel.font =  GXF_FIFTEENTEN_SIZE;

    self.averageLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.averageLabel];
    
    rect = CGRectMake(self.averageLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
    UILabel *avLabel = [[UILabel alloc]initWithFrame:rect];
    avLabel.textColor = [UIColor lightGrayColor];
    avLabel.text = @"单店日均";
    avLabel.font = GXF_THREETEENTH_SIZE;
    avLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:avLabel];

}

- (void)setValueInSaleView:(Compass *)compass{
    //统计时间
119 120 121 122
//    if (!compass) {
//        return;
//    }
    self.dateLabel.text = [NSString stringWithFormat:@"%@累计销售额",compass.dataScope?compass.dataScope:@"无"];
陈俊俊's avatar
陈俊俊 committed
123 124
    //销售额
    NSMutableAttributedString *attributeStr1 = [IBTCommon setTextViewBoldFontOfString:@"$  " paragraphStyle:8 fontSize:20 color:ReportColor];
125 126
    if (compass.sales) {
       [attributeStr1 appendAttributedString:[IBTCommon setTextViewBoldFontOfString:[compass.sales stringValue] paragraphStyle:8 fontSize:30 color:ReportContentColor]];
127
    }
陈俊俊's avatar
陈俊俊 committed
128
    self.centerLabel.attributedText = attributeStr1;
129
    self.centerLabel.textAlignment = NSTextAlignmentCenter;
陈俊俊's avatar
陈俊俊 committed
130 131 132
    //销售环比变化率
    if ([compass.salesChainSign isEqualToString:ReportChainSignPlus]) {
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
133
        [self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
134 135
    }else{
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateNormal];
136
        [self.lastWeekLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
137
    }
138
    NSString *salesChainRateStr = [NSString stringWithFormat:@"%@%%",compass.salesChainRate?compass.salesChainRate:@"0"];
陈俊俊's avatar
陈俊俊 committed
139 140 141 142
    [self.lastWeekLabel setTitle:salesChainRateStr forState:UIControlStateNormal];
    //销售同比变化率
    if ([compass.salesYoYSign isEqualToString:ReportChainSignPlus]) {
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
143
         [self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
144 145
    }else{
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateNormal];
146
         [self.lastYearLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
147
    }
148
    NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",compass.salesYoYRate?compass.salesYoYRate:@"0"];
陈俊俊's avatar
陈俊俊 committed
149 150
    [self.lastYearLabel setTitle:salesYoStr forState:UIControlStateNormal];
    //销售目标达成率
151
    NSString *salesTargetStr = [NSString stringWithFormat:@"%@%%",compass.salesTargetRate?compass.salesTargetRate:@"0"];
陈俊俊's avatar
陈俊俊 committed
152 153
    self.rateLabel.text = salesTargetStr;
    //单店日均销售
154
    NSString *dailysalesPerStr = [NSString stringWithFormat:@"%@%%",compass.dailysalesPerStore?compass.dailysalesPerStore:@"0"];
陈俊俊's avatar
陈俊俊 committed
155 156 157 158 159
    self.averageLabel.text = dailysalesPerStr;
    
}

@end