PurchaseDetailViewController.m 19.1 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9
//
//  PurchaseDetailViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/8/23.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "PurchaseDetailViewController.h"
陈俊俊's avatar
陈俊俊 committed
10 11
#import "ProductBillViewController.h"
#import "PurchaseBillProduct.h"
12
#import "BottomPurchaseView.h"
陈俊俊's avatar
陈俊俊 committed
13
//#import "RejectView.h"
陈俊俊's avatar
陈俊俊 committed
14 15 16 17 18 19 20
#define BottomHeight                                50
#define LeftMargin                                  15
#define LeftWidth                                   100
#define LeftHeight                                  30
#define TopMargin                                   15
#define OneWidth                                    (ScreenSize.width - LeftMargin * 2)
#define TwoWidth                                    ((ScreenSize.width - LeftMargin*3)/2)
n22's avatar
n22 committed
21
typedef enum : NSUInteger {
陈俊俊's avatar
陈俊俊 committed
22 23 24 25 26 27
    CancleTag = 3500,//作废
    EndTag,          //结束
    RejectTag,       //拒绝
    PassTag,         //审核
    SureTag,         //确定

n22's avatar
n22 committed
28 29
} BtnTag;

陈俊俊's avatar
陈俊俊 committed
30
@interface PurchaseDetailViewController ()<UIAlertViewDelegate>
陈俊俊's avatar
陈俊俊 committed
31 32 33
{
    UIScrollView *_scrollView;
    UIView *_purchaseView;
34 35
    //UIView *_bottomView;
    //ProductBillViewController *_pvc;
n22's avatar
n22 committed
36
    NSArray *_leftArr;
陈俊俊's avatar
陈俊俊 committed
37 38
    UIButton *_firstBtn;
    UIButton *_secondBtn;
39
    BottomPurchaseView *_aBottomView;
陈俊俊's avatar
陈俊俊 committed
40

陈俊俊's avatar
陈俊俊 committed
41 42 43 44 45 46
}
@property (nonatomic,strong)UILabel *billNumberLabel;
@property (nonatomic,strong)UILabel *noticeNumberLabel;
@property (nonatomic,strong)UILabel *createOperNameLabel;
@property (nonatomic,strong)UILabel *checkNameLabel;
@property (nonatomic,strong)UILabel *stateLabel;
n22's avatar
n22 committed
47
@property (nonatomic,strong)UILabel *lastModifyNameLabel;
48
@property (nonatomic, strong) UILabel *purchaserLabel;
n22's avatar
n22 committed
49
@property (nonatomic,strong)UILabel *typeLabel;
陈俊俊's avatar
陈俊俊 committed
50
@property (nonatomic,strong)UILabel *vendorNameLabel;
n22's avatar
n22 committed
51 52 53 54
@property (nonatomic,strong)UILabel *vendorIsSureLabel;
@property (nonatomic,strong)UILabel *warehouseLabel;
@property (nonatomic,strong)UILabel *otherPriceLabel;

陈俊俊's avatar
陈俊俊 committed
55 56
@property (nonatomic,strong)UILabel *totalPriceLabel;
@property (nonatomic,strong)UILabel *noteLabel;
n22's avatar
n22 committed
57

陈俊俊's avatar
陈俊俊 committed
58
//@property (nonatomic,strong)RejectView *rejectView;
陈俊俊's avatar
陈俊俊 committed
59 60

@property (nonatomic,strong)NSString *rejectCause;//拒接原因
陈俊俊's avatar
陈俊俊 committed
61 62 63 64 65 66 67
@end

@implementation PurchaseDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self bulidLayout];
陈俊俊's avatar
陈俊俊 committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    [self getDataFromServer];
}
- (void)getDataFromServer{
    __weak typeof(self)weakSelf = self;
    void(^succ)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        if (data) {
            NSInteger success = [data[@"success"] integerValue];
            NSString *message  = data[@"message"] ;
            if (success == 1) {
                NSDictionary *dictData = data[@"data"];
                PurchaseBill *bill = [[PurchaseBill alloc]init];
                [bill setValuesForKeysWithDictionary:dictData];
                self.bill = bill;
83
                [_aBottomView refreshCost:dictData[@"accountDetails"]];
陈俊俊's avatar
陈俊俊 committed
84 85 86 87 88 89 90 91 92 93 94 95 96
                [strongSelf fetchtPurchaseDetail];
            }else{
                [IBTLoadingView showTips:message];
            }
        }else{
            [IBTLoadingView showTips:@"     无记录     "];
        }
    };
    void(^fail)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        [IBTLoadingView showTips:data];
    };
    [IBTLoadingView showProgressLabel:@"正在加载..."];
陈俊俊's avatar
陈俊俊 committed
97
    [[ICRHTTPController sharedController] getPurchaseResultWithPurchaseUuid:self.bill.uuid success:succ failure:fail];
陈俊俊's avatar
陈俊俊 committed
98 99 100 101 102 103 104 105
}


#pragma mark - 视图初始化
- (void)bulidLayout{
    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)];
    _scrollView.showsHorizontalScrollIndicator  = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
陈俊俊's avatar
陈俊俊 committed
106
    _scrollView.backgroundColor = XXFBgColor;
陈俊俊's avatar
陈俊俊 committed
107
    [self.view addSubview:_scrollView];
陈俊俊's avatar
陈俊俊 committed
108 109
//    [self createBtn];
    [self showBtnByPermissions];
n22's avatar
n22 committed
110
    [self createBottomView];
陈俊俊's avatar
陈俊俊 committed
111
    [self createPurchaseView];
陈俊俊's avatar
陈俊俊 committed
112
    
n22's avatar
n22 committed
113 114 115
}

- (void)createBtn{
陈俊俊's avatar
陈俊俊 committed
116
    _firstBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height  - 64 - BottomHeight +5, (ScreenSize.width - LeftMargin*3)/2, 40) target:self sel:@selector(btnClick:) tag:0 image:nil title:@"" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
陈俊俊's avatar
陈俊俊 committed
117
    [self.view addSubview:_firstBtn];
陈俊俊's avatar
陈俊俊 committed
118
    
陈俊俊's avatar
陈俊俊 committed
119 120 121 122
    _secondBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetMaxX(_firstBtn.frame)+ LeftMargin, ScreenSize.height  - 64 - BottomHeight +5, (ScreenSize.width - LeftMargin*3)/2, 40) target:self sel:@selector(btnClick:) tag:0 image:nil title:@"" titleColor:[UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR];
    [self.view addSubview:_secondBtn];
    [self showBtnByPermissions];
}
陈俊俊's avatar
陈俊俊 committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144

- (void)createBtnWithArr:(NSArray *)arr{
    CGFloat btnWidth = (ScreenSize.width - LeftMargin * (arr.count+1))/arr.count;
    for (NSInteger i = 0; i < arr.count; i++) {
        NSInteger btnTag = 0;
        if ([arr[i] isEqualToString:@"拒绝"]) {
            btnTag = RejectTag;
        }else if ([arr[i] isEqualToString:@"审核通过"]) {
            btnTag = PassTag;
        }else if ([arr[i] isEqualToString:@"确认"]) {
            btnTag = SureTag;
        }else if ([arr[i] isEqualToString:@"结束"]) {
            btnTag = EndTag;
        }else if ([arr[i] isEqualToString:@"作废"]) {
            btnTag = CancleTag;
        }
        CGRect btnFrame = CGRectMake(LeftMargin + (LeftMargin + btnWidth)*i,  ScreenSize.height  - 64 - BottomHeight +5, btnWidth, 40);
        UIButton *perBtn = [IBTCustomButtom creatButtonWithFrame:btnFrame target:self sel:@selector(btnClick:) tag:btnTag image:nil title:arr[i] titleColor:[UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR];
        [self.view addSubview:perBtn];
    }
}

陈俊俊's avatar
陈俊俊 committed
145 146 147
//根据权限判断按钮显示
- (void)showBtnByPermissions{
    //逻辑判断按钮显示不显示
陈俊俊's avatar
陈俊俊 committed
148 149
    if ([self.bill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {//状态已提交 未审批
        if([self checkIsPermission:PURCHASE_PERMISSIONS_MANAGEAPPROVE]){
陈俊俊's avatar
陈俊俊 committed
150
            //显示拒绝和审批
陈俊俊's avatar
陈俊俊 committed
151 152 153
            NSArray *arr = @[@"拒绝",@"审核通过"];
            [self createBtnWithArr:arr];
            
陈俊俊's avatar
陈俊俊 committed
154
        }
155
    }else if([self.bill.state isEqualToString:PURCHASE_STATE_SHIPPING]){//状态是发运中即已审批
陈俊俊's avatar
陈俊俊 committed
156
        NSMutableArray *arr = [NSMutableArray array];
157
        if([self checkIsPermission:PURCHASE_PERMISSIONS_VENDORAPPROVE] && (!self.bill.vendorConfirmTime || self.bill.vendorConfirmTime.length < 1)){//供应商审批权
陈俊俊's avatar
陈俊俊 committed
158
            //显示确认按钮
陈俊俊's avatar
陈俊俊 committed
159 160 161
            [arr addObject:@"确认"];
        }
        if ([self checkIsPermission:PURCHASE_PERMISSIONS_FINISH]){//结束权
陈俊俊's avatar
陈俊俊 committed
162
                    //显示结束按钮
陈俊俊's avatar
陈俊俊 committed
163 164 165
            [arr addObject:@"结束"];
        }
        if([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]){//作废权
陈俊俊's avatar
陈俊俊 committed
166
                    //显示作废按钮
陈俊俊's avatar
陈俊俊 committed
167 168 169 170 171
            [arr addObject:@"作废"];
        }
        [self createBtnWithArr:arr];
        if (arr.count == 0) {
            [self hiddenTwoBtn];
陈俊俊's avatar
陈俊俊 committed
172 173 174 175
        }
    }else if([self.bill.state isEqualToString:PURCHASE_STATE_FINISHED]){//完成
        if ([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]) {//有作废权的
            //显示作废按钮
陈俊俊's avatar
陈俊俊 committed
176 177
            NSArray *arr = @[@"作废"];
            [self createBtnWithArr:arr];
陈俊俊's avatar
陈俊俊 committed
178

179 180 181 182 183 184 185 186 187
        }else{
            [self hiddenTwoBtn];
        }
    }else if([self.bill.state isEqualToString:PURCHASE_STATE_PROCESSFAIL]){//系统处理失败的
        if ([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]) {//有作废权的
            //显示作废按钮
            NSArray *arr = @[@"作废"];
            [self createBtnWithArr:arr];
            
陈俊俊's avatar
陈俊俊 committed
188 189
        }else{
            [self hiddenTwoBtn];
陈俊俊's avatar
陈俊俊 committed
190
        }
陈俊俊's avatar
陈俊俊 committed
191
    }else if([self.bill.state isEqualToString:PURCHASE_STATE_ABORTED]){//已作废
陈俊俊's avatar
陈俊俊 committed
192
        [self hiddenTwoBtn];
193 194
    }else{
         [self hiddenTwoBtn];
陈俊俊's avatar
陈俊俊 committed
195 196
    }
}
陈俊俊's avatar
陈俊俊 committed
197 198 199 200 201 202

- (void)hiddenTwoBtn{
    CGRect scrollViewFrame = _scrollView.frame;
    scrollViewFrame.size.height = ScreenSize.height - 64;
    _scrollView.frame = scrollViewFrame;
}
陈俊俊's avatar
陈俊俊 committed
203 204 205 206 207 208 209 210 211 212 213 214 215
//改变按钮的位置
- (void)changeBtnFrame:(UIButton *)btn title:(NSString *)title originX:(CGFloat)originX width:(CGFloat)width{
    CGRect btnFrame = btn.frame;
    btnFrame.origin.x = originX;
    btnFrame.size.width = width;
    btn.frame = btnFrame;
    [btn setTitle:title forState:UIControlStateNormal];
}
- (BOOL)checkIsPermission:(NSString *)permission{
    for (NSString *per in [ICRUserUtil sharedInstance].permissions) {
        if ([per isEqualToString:permission]) {
            return YES;
        }
n22's avatar
n22 committed
216
    }
陈俊俊's avatar
陈俊俊 committed
217
    return YES;
陈俊俊's avatar
陈俊俊 committed
218
}
n22's avatar
n22 committed
219

陈俊俊's avatar
陈俊俊 committed
220
- (void)btnClick:(UIButton *)btn{
陈俊俊's avatar
陈俊俊 committed
221
    CLog(@"%ld",(long)btn.tag);
陈俊俊's avatar
陈俊俊 committed
222 223 224
    switch (btn.tag) {
        case CancleTag:
        {
陈俊俊's avatar
陈俊俊 committed
225
            CLog(@"作废");
陈俊俊's avatar
陈俊俊 committed
226 227 228 229
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认作废" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
            alertView.delegate = self;
            alertView.tag = CancleTag;
            [alertView show];
陈俊俊's avatar
陈俊俊 committed
230 231 232 233
        }
            break;
        case EndTag:
        {
陈俊俊's avatar
陈俊俊 committed
234
            CLog(@"结束");
陈俊俊's avatar
陈俊俊 committed
235 236 237 238
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认结束" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
            alertView.delegate = self;
            alertView.tag = EndTag;
            [alertView show];
陈俊俊's avatar
陈俊俊 committed
239 240 241 242
        }
            break;
        case RejectTag:
        {
陈俊俊's avatar
陈俊俊 committed
243
            CLog(@"拒绝");
陈俊俊's avatar
陈俊俊 committed
244 245 246 247
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认拒绝" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
            alertView.delegate = self;
            alertView.tag = RejectTag;
            [alertView show];
陈俊俊's avatar
陈俊俊 committed
248 249 250 251
        }
            break;
        case PassTag:
        {
陈俊俊's avatar
陈俊俊 committed
252
            CLog(@"审核通过");
陈俊俊's avatar
陈俊俊 committed
253 254 255 256
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认通过" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
            alertView.delegate = self;
            alertView.tag = PassTag;
            [alertView show];
陈俊俊's avatar
陈俊俊 committed
257 258 259 260
        }
            break;
        case SureTag:
        {
陈俊俊's avatar
陈俊俊 committed
261 262
            CLog(@"确认");
            [self dealByAction:PURCHASE_ACTION_VENDORCONFIRM];
陈俊俊's avatar
陈俊俊 committed
263 264 265 266 267
        }
            break;
        default:
            break;
    }
n22's avatar
n22 committed
268
}
陈俊俊's avatar
陈俊俊 committed
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
- (void)dealByAction:(NSString *)action{
    //保存
    void(^succ)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        if (data) {
            NSInteger success = [data[@"success"] integerValue];
            NSString *message = data[@"message"];
            if (success == 1) {
                [ICRUserUtil sharedInstance].needFresh = YES;
                [self PopViewControllerAnimated:YES];
            }else{
                [IBTLoadingView showTips:message];
            }
        }else{
            [IBTLoadingView showTips:@"操作异常"];
        }
    };
    void(^fail)(id) = ^(id data) {
        [IBTLoadingView hideHUDWithText:nil];
        [IBTLoadingView showTips:data];
    };
    [IBTLoadingView showProgressLabel:@"正在加载..."];
    [[ICRHTTPController sharedController]dealByActionWithPurchaseUuid:self.bill.uuid action:action remark:[IBTCommon checkString:self.rejectCause] version:self.bill.version success:succ failure:fail];
}
n22's avatar
n22 committed
293 294

- (void)createBottomView{
295 296 297 298 299 300 301 302 303 304
//    _bottomView= [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_purchaseView.frame) + TopMargin, ScreenSize.width, 300)];
//    _bottomView.backgroundColor = [UIColor whiteColor];
//    [_scrollView addSubview:_bottomView];
//    
//    _pvc = [[ProductBillViewController alloc]init];
//    [self addChildViewController:_pvc];
//    
//    _pvc.viewFrame = _bottomView.bounds;
//    _pvc.isHiddenEdit = YES;
//    [_bottomView addSubview:_pvc.view];
陈俊俊's avatar
陈俊俊 committed
305
    
306 307 308
    _aBottomView = [[BottomPurchaseView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_purchaseView.frame) + TopMargin, ScreenSize.width,300) withHidden:YES];
    _aBottomView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_aBottomView];
n22's avatar
n22 committed
309 310 311
}

- (void)createPurchaseView{
312
    _leftArr = @[@"单号:",@"采购通知单:",@"创建人:",@"最后修改人:",@"采购员:",@"状态:",@"类型:",@"供应商:",@"供应商确认:",@"收货仓库:",@"其他费用:",@"总金额:",@"备注:"];
陈俊俊's avatar
陈俊俊 committed
313

n22's avatar
n22 committed
314
    _purchaseView= [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, LeftHeight*_leftArr.count +LeftMargin)];
陈俊俊's avatar
陈俊俊 committed
315 316 317
    _purchaseView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_purchaseView];
    
n22's avatar
n22 committed
318
    for (NSInteger i = 0 ; i < _leftArr.count; i++) {
陈俊俊's avatar
陈俊俊 committed
319
        UILabel *leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin, 10 + LeftHeight *i, LeftWidth, LeftHeight)];
陈俊俊's avatar
陈俊俊 committed
320
        leftLabel.font = GXF_SEVENTEENTH_SIZE;
n22's avatar
n22 committed
321
        leftLabel.text = _leftArr[i];
陈俊俊's avatar
陈俊俊 committed
322
        leftLabel.textColor = GXF_DETAIL_COLOR;
陈俊俊's avatar
陈俊俊 committed
323 324 325
        [_purchaseView addSubview:leftLabel];
        
        UILabel *rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(leftLabel.frame), 10 + LeftHeight *i, _purchaseView.frame.size.width - LeftMargin - LeftWidth, LeftHeight)];
陈俊俊's avatar
陈俊俊 committed
326 327
        rightLabel.font = GXF_SEVENTEENTH_SIZE;
        rightLabel.textColor = GXF_DETAIL_COLOR;
n22's avatar
n22 committed
328
        
陈俊俊's avatar
陈俊俊 committed
329 330 331 332 333 334
        if (i == 0) {
            self.billNumberLabel = rightLabel;
        }else if (i == 1) {
            self.noticeNumberLabel = rightLabel;
        }else if(i == 2){
            self.createOperNameLabel = rightLabel;
335
        }else if (i == 3){
336
            self.lastModifyNameLabel = rightLabel;
337
        }
338 339
        else if (i == 4){
            self.purchaserLabel = rightLabel;
陈俊俊's avatar
陈俊俊 committed
340
        }else if(i == 5){
341
            self.stateLabel = rightLabel;
陈俊俊's avatar
陈俊俊 committed
342
        }else if(i == 6){
343
            self.typeLabel = rightLabel;
陈俊俊's avatar
陈俊俊 committed
344
        }else if(i == 7){
345
            self.vendorNameLabel = rightLabel;
346
        }else if(i == 8){
347 348
            self.vendorIsSureLabel = rightLabel;
        }else if(i == 9){
陈俊俊's avatar
陈俊俊 committed
349
            self.warehouseLabel = rightLabel;
n22's avatar
n22 committed
350 351 352
        }else if(i == _leftArr.count - 3){
            self.otherPriceLabel = rightLabel;
        }else if(i == _leftArr.count - 2){
陈俊俊's avatar
陈俊俊 committed
353
            self.totalPriceLabel = rightLabel;
n22's avatar
n22 committed
354
        }else if(i == _leftArr.count - 1){
陈俊俊's avatar
陈俊俊 committed
355 356
            rightLabel.numberOfLines = 0;
            self.noteLabel = rightLabel;
357
            //rightLabel.backgroundColor = [UIColor redColor];
陈俊俊's avatar
陈俊俊 committed
358 359 360 361 362 363 364
        }
        [_purchaseView addSubview:rightLabel];
    }
}

- (void)fetchtPurchaseDetail{
    self.billNumberLabel.text = [IBTCommon checkString:self.bill.billNumber];
n22's avatar
n22 committed
365
    if ([self.bill.state isEqualToString:PURCHASE_STATE_INITIAL]) {
陈俊俊's avatar
陈俊俊 committed
366 367
        self.stateLabel.textColor = [UIColor redColor];
        self.stateLabel.text = @"未提交";
n22's avatar
n22 committed
368
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {
陈俊俊's avatar
陈俊俊 committed
369
        self.stateLabel.textColor = [UIColor greenColor];
陈俊俊's avatar
陈俊俊 committed
370
        self.stateLabel.text = @"未审批";
n22's avatar
n22 committed
371
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_REJECTED]) {
陈俊俊's avatar
陈俊俊 committed
372 373
        self.stateLabel.textColor = [UIColor grayColor];
        self.stateLabel.text = @"已拒绝";
n22's avatar
n22 committed
374
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_SHIPPING]) {
陈俊俊's avatar
陈俊俊 committed
375 376
        self.stateLabel.textColor = [UIColor grayColor];
        self.stateLabel.text = @"发运中";
陈俊俊's avatar
陈俊俊 committed
377
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_ABORTED]) {
378 379
        self.stateLabel.textColor = [UIColor grayColor];
        self.stateLabel.text = @"已作废";
n22's avatar
n22 committed
380
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_FINISHED]) {
陈俊俊's avatar
陈俊俊 committed
381 382
        self.stateLabel.textColor = [UIColor blackColor];
        self.stateLabel.text = @"已完成";
383
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_PROCESS]) {
陈俊俊's avatar
陈俊俊 committed
384
        self.stateLabel.textColor = [UIColor greenColor];
385 386 387 388
        self.stateLabel.text = @"提交系统处理";
    }else if ([self.bill.state isEqualToString:PURCHASE_STATE_PROCESSFAIL]) {
        self.stateLabel.textColor = [UIColor blackColor];
        self.stateLabel.text = @"系统处理失败";
陈俊俊's avatar
陈俊俊 committed
389
    }
陈俊俊's avatar
陈俊俊 committed
390
    self.noticeNumberLabel.text = (self.bill.noticeNumber.length == 0) ? @"无":(self.bill.noticeNumber);
陈俊俊's avatar
陈俊俊 committed
391 392 393
    self.createOperNameLabel.text = [IBTCommon checkString:self.bill.create_operName];
    self.checkNameLabel.text = [IBTCommon checkString:self.bill.vendor_name];
    self.vendorNameLabel.text = [IBTCommon checkString:self.bill.vendor_name];
n22's avatar
n22 committed
394
    self.totalPriceLabel.text = [IBTCommon checkString:[self.bill.total stringValue]];
陈俊俊's avatar
陈俊俊 committed
395
    self.noteLabel.text = [NSString stringWithFormat:@"%@",self.bill.remark?self.bill.remark:@"无"];
陈俊俊's avatar
陈俊俊 committed
396 397 398
    self.lastModifyNameLabel.text = [IBTCommon checkString:self.bill.lastModify_operName];
    NSString *type = [self.bill.type isEqualToString:GXF_Critical] ? @"紧急" : @"普通";
    self.typeLabel.text = type;
399
    self.purchaserLabel.text = [NSString stringWithFormat:@"%@[%@]",self.bill.purchaserName, self.bill.purchaserCode];
400
    self.vendorIsSureLabel.text = (self.bill.vendorConfirmTime.length > 0 && self.bill.vendorConfirmTime)? @"是":@"否";
陈俊俊's avatar
陈俊俊 committed
401 402 403 404 405 406 407 408
    self.warehouseLabel.text = [IBTCommon checkString:self.bill.receiveWrh_name];
    self.otherPriceLabel.text = [self.bill.charge stringValue];
    NSMutableArray *productArr = [NSMutableArray array];
    for (NSDictionary *billDict in self.bill.products) {
        PurchaseBillProduct *billProbuct = [PurchaseBillProduct new];
        [billProbuct setValuesForKeysWithDictionary:billDict];
        [productArr addObject:billProbuct];
    }
409 410
    _aBottomView.productVC.productArr = productArr;
    [_aBottomView.productVC.tableView reloadData];
n22's avatar
n22 committed
411
    
陈俊俊's avatar
陈俊俊 committed
412 413 414 415 416 417 418 419 420 421 422
    [self setNoteHeight];
}

- (void)setNoteHeight
{
    CGFloat height =  [self.noteLabel calculateHeight];
    
    CGRect noteFrame = self.noteLabel.frame;
    noteFrame.size.height = height;
    self.noteLabel.frame = noteFrame;
    
423
    CGFloat totalHeight = height + LeftHeight*_leftArr.count + LeftMargin;
陈俊俊's avatar
陈俊俊 committed
424 425 426 427 428
    CGRect purchaseFrame = _purchaseView.frame;
    purchaseFrame.size.height = totalHeight;
    _purchaseView.frame = purchaseFrame;
    
    
429
    CGRect bottomFrame = _aBottomView.frame;
陈俊俊's avatar
陈俊俊 committed
430
    bottomFrame.origin.y = CGRectGetMaxY(_purchaseView.frame) + TopMargin;
431
    _aBottomView.frame = bottomFrame;
陈俊俊's avatar
陈俊俊 committed
432
    
433
    _scrollView.contentSize = CGSizeMake(ScreenSize.width, totalHeight + CGRectGetHeight(_aBottomView.frame) + TopMargin*2);
陈俊俊's avatar
陈俊俊 committed
434 435
}

陈俊俊's avatar
陈俊俊 committed
436 437 438 439
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag == CancleTag) {
        if (buttonIndex == 1) {
            [self dealByAction:PURCHASE_ACTION_ABORT];//作废
陈俊俊's avatar
陈俊俊 committed
440

陈俊俊's avatar
陈俊俊 committed
441 442 443 444 445
        }
    }else if (alertView.tag == EndTag){
        if (buttonIndex == 1) {
            [self dealByAction:PURCHASE_ACTION_FINISH];//结束
        }
陈俊俊's avatar
陈俊俊 committed
446 447 448 449 450 451 452 453
    }else if(alertView.tag == RejectTag){
        if (buttonIndex == 1) {
            [self dealByAction:PURCHASE_ACTION_REJECT];
        }
    }else if(alertView.tag == PassTag){
        if (buttonIndex == 1) {
            [self dealByAction:PURCHASE_ACTION_APPROVE];
        }
陈俊俊's avatar
陈俊俊 committed
454 455
    }
}
陈俊俊's avatar
陈俊俊 committed
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end