123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- //
- // MyPlanVCHeader.m
- // jiaPeiC
- //
- // Created by apple on 16/8/17.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "MyPlanVCHeader.h"
- //NSInteger typeInt;
- @implementation MyPlanVCHeader
- -(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithReuseIdentifier:reuseIdentifier];
- if (self) {
-
- self.contentView.backgroundColor = [UIColor whiteColor];
-
- UILabel *label;
- UIButton *btn;
- UIImageView *iv;
-
- UIView *blackV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 15)];
- blackV.backgroundColor = lineColor;
- [self.contentView addSubview:blackV];
-
- label = [UILabel new];
- [self.contentView addSubview:label];
- _waitLabel = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- _stateLabel = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- lblDate = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- lblNum = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- titNum = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- titDate = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- titCountLabel = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- countLabel = label;
- label = [UILabel new];
- [self.contentView addSubview:label];
- moneyLabel = label;
-
-
- iv = [UIImageView new];
- [self.contentView addSubview:iv];
- imgDate = iv;
- iv = [UIImageView new];
- [self.contentView addSubview:iv];
- imgNum = iv;
-
- btn = [UIButton new];
- [self.contentView addSubview:btn];
- _btnScan = btn;
-
- btn = [UIButton new];
- [btn addTarget:self action:@selector(headerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- btn.tag = 1;
- [self.contentView addSubview:btn];
- _btnEdit = btn;
-
- btn = [UIButton new];
- [btn addTarget:self action:@selector(headerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- btn.tag = 2;
- [self.contentView addSubview:btn];
- btn.hidden = YES;
- _btnAll = btn;
-
-
- //下面要用 所以先写出来
- [titDate setText:@"练车时间:"];
- [titNum setText:@"可约人数:"];
- [titCountLabel setText:@"已约人数:"];
-
- CGFloat wid = kSize.width;
- CGFloat x,y,w,h,bd;
-
- //预约情况
- x = y = bd = 20;
- w = 180;
- h = 30;
- _waitLabel.frame = setDIYFrame;
-
- //是否计时中
- w = wid - x - 120;
- _stateLabel.frame = setDIYFrame;
-
- //展开按钮
- w = 70;
- x = wid - w - 20;
- _btnScan.frame = setDIYFrame;
- [_btnScan addViewWithRect:CGRectMake(10, y + h + 4, kSize.width - 20, 1)];
-
-
- x = 15;
- y += h + 5;
- w = h = 25;
- imgDate.frame = setDIYFrame;
- imgNum.frame = CGRectMake(x, y + h, w, h);
-
- x += w +10;
- w = [titDate.text sizeForFont:Font14].width;
- titDate.frame = setDIYFrame;
- titCountLabel.frame = CGRectMake(x, y + h, w, h);
-
- x += w;
- w = wid - 100;
- lblDate.frame = setDIYFrame;//日期值
- w = 40;
- countLabel.frame = CGRectMake(x, y + h, w, h);//已约人数
-
- x = wid - 100;
- w = 80;
- moneyLabel.frame = setDIYFrame;
-
- w = [titNum.text sizeForFont:Font14].width;
- x = wid - w - 60;
- y += h;
- titNum.frame = setDIYFrame;
- x += w;
- w = 40;
- lblNum.frame = setDIYFrame;//可约人数
-
-
- //全选按钮
- x = bd;
- y += h + 5;
- w = 80;
- h = 25;
- _btnAll.frame = setDIYFrame;
- //批量按钮
- x = wid - 100;
- w = 80;
- h = 25;
- _btnEdit.frame = CGRectMake(x, y, w, h);
-
-
-
- //字体等固定设置
- [imgNum imageName:@"send_people_num_icon.png"];
- [imgDate imageName:@"send_time_icon.png"];
-
- [_waitLabel setFont:Font14 TextColor:[UIColor orangeColor]];
- [_stateLabel setFont:Font14 TextColor:[UIColor orangeColor]];
-
- [titNum setFont:Font14 TextColor:contentTextColor];
- [titDate setFont:Font14 TextColor:contentTextColor];
- [titCountLabel setFont:Font14 TextColor:contentTextColor];
- [countLabel setFont:Font16 TextColor:contentTextColor];
- [lblNum setFont:Font16 TextColor:contentTextColor];
- [lblDate setFont:Font16 TextColor:contentTextColor];
- [moneyLabel setFont:Font16 TextColor:[UIColor redColor]];
-
- lblNum.textAlignment = NSTextAlignmentCenter;
- countLabel.textAlignment = NSTextAlignmentCenter;
- moneyLabel.textAlignment = NSTextAlignmentRight;
- _stateLabel.textAlignment = NSTextAlignmentRight;
-
- [_btnScan setTitleEdgeInsets:UIEdgeInsetsMake(0, -20, 0, 30)];
- [_btnScan setImageEdgeInsets:UIEdgeInsetsMake(3, 40, 3, -5)];
- _btnScan.backgroundColor = lineColor;
- [_btnScan borderCornorRadios:15];
-
- _btnEdit.backgroundColor = lineColor;
- [_btnEdit setTitle:@"批量操作" textColor:contentTextColor font:Font14 fotState:UIControlStateNormal];
- [_btnEdit borderCornorRadios:15];
-
- //全选与非全选
- [_btnAll setImage:[UIImage imageNamed:@"selectAll.png"] Tit:@"全选" Font:Font14 State:UIControlStateNormal];
- [_btnAll setImage:[UIImage imageNamed:@"selectedAll.png"] Tit:@"全选" Font:Font14 State:UIControlStateSelected];
- }
- return self;
- }
- -(void)setType:(NSInteger)type
- {
- _type = type;
- //计划信息
- if (_type == 1) {
- _btnEdit.hidden = NO;
- _btnAll.hidden = NO;
- }else{
- //不带编辑按钮
- _btnEdit.hidden = YES;
- _btnAll.hidden = YES;
- }
- }
- //-(void)layoutSubviews
- //{
- // [super layoutSubviews];
- // NSLog(@"_type-----><>%d",(int)_type);
- //
- //
- //
- //}
- //-(void)setHeaderStateLabel
- //{
- //
- //}
- -(void)setModel:(NSDictionary *)model
- {
- //NSLog(@"myplanVC---->%@",model);
- _model = model;
-
- NSInteger count = [_model[@"reserveInfoList"] count];
-
- NSString *waitSate = nil;
- NSInteger orderNum = 0;
-
- switch (_type) {//_type 区头样式 0已同意 1待确认 2已拒绝
- case 0:
- waitSate = [NSString stringWithFormat:@"预约成功%d人",(int)count];
- orderNum = 4;
- if (count == 0) {
- waitSate = @"暂无人成功预约";
- }
- break;
- case 1:
- waitSate = [NSString stringWithFormat:@"有%d条预约待确认",(int)count];
- orderNum = 1;
- if (count == 0) {
- waitSate = @"暂无待确认预约";
- [_btnEdit setHidden:YES];
- }else{
- [_btnEdit setHidden:NO];
- }
- break;
- case 2:
- waitSate = [NSString stringWithFormat:@"已拒绝%d条预约",(int)count];
- orderNum = 3;
- if (count == 0) {
- waitSate = @"暂无已拒绝的预约";
- }
- break;
- default:
- break;
- }
-
- if (count == 0) {
- [_waitLabel setText:waitSate];
- }else{
-
- NSInteger aLength = [[NSString stringWithFormat:@"%d",(int)count] length];
- NSMutableAttributedString * aAttributedString = [[NSMutableAttributedString alloc] initWithString:waitSate];
- //颜色
- // [aAttributedString addAttribute:NSForegroundColorAttributeName
- // value:defGreen
- // range:NSMakeRange(0, 5)];
- [aAttributedString addAttribute:NSFontAttributeName
- value:[UIFont scaleSize:22.0]
- range:NSMakeRange(orderNum, aLength)];
- [aAttributedString addAttribute:NSUnderlineStyleAttributeName
- value:@(NSUnderlineStyleSingle)
- range:NSMakeRange(orderNum, aLength)];
- _waitLabel.attributedText = aAttributedString;
- }
-
- //[lblName setText:model[@"PI_USER_NAME"]];
- [lblNum setText:[NSString stringWithFormat:@"%@人",model[@"PI_NUM"]]];
- [countLabel setText:[NSString stringWithFormat:@"%@人",model[@"PI_HAV_NUM"]]];
- [lblDate setText:[NSString stringWithFormat:@" %@",model[@"PI_TIMES"]]];
- [moneyLabel setText:[NSString stringWithFormat:@"%@元/时",model[@"PI_MONEY"]]];
- }
- -(void)click:(MyBlockType)block
- {
- clkBlock = block;
- }
- -(void)headerBtnClick:(UIButton*)sender
- {
- UIButton *btn = (UIButton *)sender;
-
- btn.selected = !btn.selected;
- if (sender.tag == 1) {
-
- if (btn.selected) {
- _btnAll.hidden = NO;
- [btn setTitle:@"取消" forState:UIControlStateNormal];
- if (clkBlock) {
- clkBlock(_aTag);
- }
- }else{
- _btnAll.hidden = YES;
- [btn setTitle:@"批量操作" forState:UIControlStateNormal];
- if (clkBlock) {
- clkBlock([NSString stringWithFormat:@"%d",[_aTag intValue] + 500]);
- }
- }
- }
- if (sender.tag == 2) {
- //这里是改变_btnAll的图片 并且要对上个页面表示全选
- if (btn.selected) {
-
- if (clkBlock) {
- clkBlock([NSString stringWithFormat:@"%d",-1]);
- }
- }else{
-
- if (clkBlock) {
- clkBlock([NSString stringWithFormat:@"%d",-2]);
- }
- }
- }
- }
- @end
|