Commit cad7fd9f authored by 陈俊俊's avatar 陈俊俊

详情界面统一修改

parent a2586fdd
...@@ -102,7 +102,8 @@ typedef enum : NSUInteger { ...@@ -102,7 +102,8 @@ typedef enum : NSUInteger {
_scrollView.showsVerticalScrollIndicator = NO; _scrollView.showsVerticalScrollIndicator = NO;
_scrollView.backgroundColor = XXFBgColor; _scrollView.backgroundColor = XXFBgColor;
[self.view addSubview:_scrollView]; [self.view addSubview:_scrollView];
[self createBtn]; // [self createBtn];
[self showBtnByPermissions];
[self createBottomView]; [self createBottomView];
[self createPurchaseView]; [self createPurchaseView];
...@@ -116,54 +117,61 @@ typedef enum : NSUInteger { ...@@ -116,54 +117,61 @@ typedef enum : NSUInteger {
[self.view addSubview:_secondBtn]; [self.view addSubview:_secondBtn];
[self showBtnByPermissions]; [self showBtnByPermissions];
} }
- (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];
}
}
//根据权限判断按钮显示 //根据权限判断按钮显示
- (void)showBtnByPermissions{ - (void)showBtnByPermissions{
//逻辑判断按钮显示不显示 //逻辑判断按钮显示不显示
if ([self.bill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {//状态已提交 未审批 if ([self.bill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {//状态已提交 未审批
if([self checkIsPermission:PURCHASE_PERMISSIONS_MANAGEAPPROVE]){ if([self checkIsPermission:PURCHASE_PERMISSIONS_MANAGEAPPROVE]){
//显示拒绝和审批 //显示拒绝和审批
[self changeBtnFrame:_firstBtn title:@"拒绝" originX:LeftMargin width:TwoWidth]; NSArray *arr = @[@"拒绝",@"审核通过"];
[self changeBtnFrame:_secondBtn title:@"审核通过" originX:CGRectGetMaxX(_firstBtn.frame) + LeftMargin width:TwoWidth]; [self createBtnWithArr:arr];
_firstBtn.tag = RejectTag;
_secondBtn.tag = PassTag;
}else{
[self hiddenTwoBtn];
} }
}else if([self.bill.state isEqualToString:PURCHASE_STATE_SHIPPING]){//状态是发运中即已审批 }else if([self.bill.state isEqualToString:PURCHASE_STATE_SHIPPING]){//状态是发运中即已审批
NSMutableArray *arr = [NSMutableArray array];
if([self checkIsPermission:PURCHASE_PERMISSIONS_VENDORAPPROVE]){//供应商审批权 if([self checkIsPermission:PURCHASE_PERMISSIONS_VENDORAPPROVE]){//供应商审批权
//显示确认按钮 //显示确认按钮
_firstBtn.hidden = YES; [arr addObject:@"确认"];
[self changeBtnFrame:_secondBtn title:@"确认" originX:LeftMargin width:OneWidth]; }
_secondBtn.tag = SureTag; if ([self checkIsPermission:PURCHASE_PERMISSIONS_FINISH]){//结束权
}else{
if ([self checkIsPermission:PURCHASE_PERMISSIONS_FINISH]&&[self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]) {
//显示结束和作废按钮
[self changeBtnFrame:_firstBtn title:@"结束" originX:LeftMargin width:TwoWidth];
[self changeBtnFrame:_secondBtn title:@"作废" originX:CGRectGetMaxX(_firstBtn.frame) + LeftMargin width:TwoWidth];
_firstBtn.tag = EndTag;
_secondBtn.tag = CancleTag;
}else{
if ([self checkIsPermission:PURCHASE_PERMISSIONS_FINISH]){//结束权
//显示结束按钮 //显示结束按钮
_firstBtn.hidden = YES; [arr addObject:@"结束"];
[self changeBtnFrame:_secondBtn title:@"结束" originX:LeftMargin width:OneWidth]; }
_secondBtn.tag = EndTag; if([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]){//作废权
}else if([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]){//作废权
//显示作废按钮 //显示作废按钮
_firstBtn.hidden = YES; [arr addObject:@"作废"];
[self changeBtnFrame:_secondBtn title:@"作废" originX:LeftMargin width:OneWidth]; }
_secondBtn.tag = CancleTag; [self createBtnWithArr:arr];
}else{ if (arr.count == 0) {
[self hiddenTwoBtn]; [self hiddenTwoBtn];
}
}
} }
}else if([self.bill.state isEqualToString:PURCHASE_STATE_FINISHED]){//完成 }else if([self.bill.state isEqualToString:PURCHASE_STATE_FINISHED]){//完成
if ([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]) {//有作废权的 if ([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]) {//有作废权的
//显示作废按钮 //显示作废按钮
_firstBtn.hidden = YES; NSArray *arr = @[@"作废"];
[self changeBtnFrame:_secondBtn title:@"作废" originX:LeftMargin width:OneWidth]; [self createBtnWithArr:arr];
_secondBtn.tag = CancleTag;
}else{ }else{
[self hiddenTwoBtn]; [self hiddenTwoBtn];
...@@ -174,8 +182,6 @@ typedef enum : NSUInteger { ...@@ -174,8 +182,6 @@ typedef enum : NSUInteger {
} }
- (void)hiddenTwoBtn{ - (void)hiddenTwoBtn{
_firstBtn.hidden = YES;
_secondBtn.hidden = YES;
CGRect scrollViewFrame = _scrollView.frame; CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64; scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame; _scrollView.frame = scrollViewFrame;
...@@ -194,7 +200,7 @@ typedef enum : NSUInteger { ...@@ -194,7 +200,7 @@ typedef enum : NSUInteger {
return YES; return YES;
} }
} }
return NO; return YES;
} }
- (void)btnClick:(UIButton *)btn{ - (void)btnClick:(UIButton *)btn{
......
...@@ -173,73 +173,61 @@ typedef enum : NSUInteger { ...@@ -173,73 +173,61 @@ typedef enum : NSUInteger {
[self createMingXiTableView];//自定义 [self createMingXiTableView];//自定义
} }
- (void)hiddenBottomBtn{ - (void)hiddenBottomBtn{
_endBtn.hidden = YES;
_rejectBtn.hidden = YES;
CGRect scrollViewFrame = _scrollView.frame; CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64; scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame; _scrollView.frame = scrollViewFrame;
} }
- (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 = EndTag;
}else if ([arr[i] isEqualToString:@"接受任务"]) {
btnTag = AcceptTag;
}else if ([arr[i] isEqualToString:@"新建采购单"]) {
btnTag = NewTag;
}
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];
}
}
- (void)createBtn{ - (void)createBtn{
_rejectBtn = [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];
[self.view addSubview:_rejectBtn];
_endBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetMaxX(_rejectBtn.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:_endBtn];
if ([self.purchaseNotice.state isEqualToString:PURCHASENOTICE_STATE_NOTACCEPTED]) { if ([self.purchaseNotice.state isEqualToString:PURCHASENOTICE_STATE_NOTACCEPTED]) {
if ([self checkIsPermission:NOTICE_PERMISSIONS_ACCEPTTASK]&& [self checkIsPermission:NOTICE_PERMISSIONS_FINISH]) { NSMutableArray *arr = [NSMutableArray array];
_rejectBtn.tag = EndTag; if([IBTCommon checkIsPermission:NOTICE_PERMISSIONS_FINISH]){
[_rejectBtn setTitle:@"结束" forState:UIControlStateNormal]; [arr addObject:@"结束"];
_endBtn.tag = AcceptTag; }
[_endBtn setTitle:@"接受任务" forState:UIControlStateNormal]; if ([IBTCommon checkIsPermission:NOTICE_PERMISSIONS_ACCEPTTASK]) {
}else{ [arr addObject:@"接受任务"];
if ([self checkIsPermission:NOTICE_PERMISSIONS_ACCEPTTASK]) { }
_rejectBtn.hidden = YES; if (arr.count == 0) {
_endBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin * 2, 40); [self hiddenBottomBtn];
_endBtn.tag = AcceptTag; }else{
[_endBtn setTitle:@"接受任务" forState:UIControlStateNormal]; [self createBtnWithArr:arr];
}else if([self checkIsPermission:NOTICE_PERMISSIONS_FINISH]){ }
_rejectBtn.hidden = YES;
_endBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin * 2, 40);
_endBtn.tag = EndTag;
[_endBtn setTitle:@"结束" forState:UIControlStateNormal];
}else{
[self hiddenBottomBtn];
}
}
}else if([self.purchaseNotice.state isEqualToString:PURCHASENOTICE_STATE_PURCHASEING]){ }else if([self.purchaseNotice.state isEqualToString:PURCHASENOTICE_STATE_PURCHASEING]){
if ([self checkIsPermission:NOTICE_PERMISSIONS_FINISH] && [self checkIsPermission:NOTICE_PERMISSIONS_CREATEBILL]) { NSMutableArray *arr = [NSMutableArray array];
_rejectBtn.tag = EndTag; if([IBTCommon checkIsPermission:NOTICE_PERMISSIONS_FINISH]){
[_rejectBtn setTitle:@"结束" forState:UIControlStateNormal]; [arr addObject:@"结束"];
_endBtn.tag = NewTag; }
[_endBtn setTitle:@"新建采购单" forState:UIControlStateNormal]; if([IBTCommon checkIsPermission:NOTICE_PERMISSIONS_CREATEBILL]){
[arr addObject:@"新建采购单"];
}
if (arr.count == 0) {
[self hiddenBottomBtn];
}else{ }else{
if([self checkIsPermission:NOTICE_PERMISSIONS_FINISH]){ [self createBtnWithArr:arr];
_rejectBtn.hidden = YES;
_endBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin * 2, 40);
_endBtn.tag = EndTag;
[_endBtn setTitle:@"结束" forState:UIControlStateNormal];
}else if([self checkIsPermission:NOTICE_PERMISSIONS_CREATEBILL]){
_rejectBtn.hidden = YES;
_endBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin * 2, 40);
_endBtn.tag = NewTag;
[_endBtn setTitle:@"新建采购单" forState:UIControlStateNormal];
}else{
[self hiddenBottomBtn];
}
} }
}else if([self.purchaseNotice.state isEqualToString:PURCHASENOTICE_STATE_FINISHED]) { }else if([self.purchaseNotice.state isEqualToString:PURCHASENOTICE_STATE_FINISHED]) {
[self hiddenBottomBtn]; [self hiddenBottomBtn];
} }
} }
- (BOOL)checkIsPermission:(NSString *)permission{
for (NSString *per in [ICRUserUtil sharedInstance].permissions) {
if ([per isEqualToString:permission]) {
return YES;
}
}
return NO;
}
- (void)btnClick:(UIButton *)btn{ - (void)btnClick:(UIButton *)btn{
NSLog(@"%ld",(long)btn.tag); NSLog(@"%ld",(long)btn.tag);
switch (btn.tag) { switch (btn.tag) {
...@@ -277,15 +265,15 @@ typedef enum : NSUInteger { ...@@ -277,15 +265,15 @@ typedef enum : NSUInteger {
NSString *message = data[@"message"]; NSString *message = data[@"message"];
if (success == 1) { if (success == 1) {
if ([action isEqualToString:@"accept"]) { if ([action isEqualToString:@"accept"]) {
#warning 有点问
[ICRUserUtil sharedInstance].needFresh = YES; [ICRUserUtil sharedInstance].needFresh = YES;
if ([IBTCommon checkIsPermission:NOTICE_PERMISSIONS_CREATEBILL]) { if ([IBTCommon checkIsPermission:NOTICE_PERMISSIONS_CREATEBILL]) {
_stateLabel.text = @"发运中"; _stateLabel.text = @"采购中";
_endBtn.hidden = YES; for (UIView *subView in self.view.subviews) {
_rejectBtn.hidden = NO; if ([subView isKindOfClass:[UIButton class]]) {
[_rejectBtn setTitle:@"新建采购单" forState:UIControlStateNormal]; [subView removeFromSuperview];
_rejectBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin * 2, 40); }
_rejectBtn.tag = NewTag; }
[self createBtnWithArr:@[@"新建采购单"]];
}else{ }else{
[self PopViewControllerAnimated:YES]; [self PopViewControllerAnimated:YES];
} }
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#define TopMargin 15 #define TopMargin 15
typedef enum : NSUInteger { typedef enum : NSUInteger {
SaveTag = 20000, SaveTag = 20000,
ReceiveTag ReceiveTag,
AbortTag
} BtnTag; } BtnTag;
@interface NewReceiveViewController ()<UIAlertViewDelegate> @interface NewReceiveViewController ()<UIAlertViewDelegate>
...@@ -154,6 +155,29 @@ typedef enum : NSUInteger { ...@@ -154,6 +155,29 @@ typedef enum : NSUInteger {
_scrollView.contentSize = CGSizeMake(ScreenSize.width, totalHeight + CGRectGetHeight(_bottomView.frame) + TopMargin*2); _scrollView.contentSize = CGSizeMake(ScreenSize.width, totalHeight + CGRectGetHeight(_bottomView.frame) + TopMargin*2);
} }
- (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 = SaveTag;
}else if ([arr[i] isEqualToString:@"收货"]) {
btnTag = ReceiveTag;
}else if([arr[i] isEqualToString:@"作废"]){
btnTag = AbortTag;
}
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];
}
}
- (void)hiddenBottom{
CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame;
}
#pragma mark - 视图初始化 #pragma mark - 视图初始化
- (void)bulifLayout{ - (void)bulifLayout{
self.defalutState = [NSMutableArray array]; self.defalutState = [NSMutableArray array];
...@@ -163,17 +187,18 @@ typedef enum : NSUInteger { ...@@ -163,17 +187,18 @@ typedef enum : NSUInteger {
_scrollView.backgroundColor = XXFBgColor; _scrollView.backgroundColor = XXFBgColor;
[self.view addSubview:_scrollView]; [self.view addSubview:_scrollView];
_firstBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, (ScreenSize.width- LeftMargin *3)/2, 40) target:self sel:@selector(btnClick:) tag:SaveTag image:nil title:@"保存" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR]; if ([self.transfer.state isEqualToString:TRANSFER_STATE_UNRECEIVED]) {
[self.view addSubview:_firstBtn]; if ([IBTCommon checkIsPermission:RECEIVE_ACTION_RECEIVE]) {
_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:ReceiveTag image:nil title:@"收货" titleColor:[UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR]; [self createBtnWithArr:@[@"保存",@"收货"]];
[self.view addSubview:_secondBtn]; }else{
[self hiddenBottom];
if ([self.transfer.state isEqualToString:TRANSFER_STATE_RECEIVED] || ![IBTCommon checkIsPermission:RECEIVE_ACTION_RECEIVE]) { }
_firstBtn.hidden = YES; }else if ([self.transfer.state isEqualToString:TRANSFER_STATE_RECEIVED]) {
_secondBtn.hidden = YES; if ([IBTCommon checkIsPermission:TRANSFER_ACTION_ABORT]) {
CGRect scrollViewFrame = _scrollView.frame; [self createBtnWithArr:@[@"作废"]];
scrollViewFrame.size.height = ScreenSize.height - 64; }else{
_scrollView.frame = scrollViewFrame; [self hiddenBottom];
}
} }
NSArray *leftArr = @[@"单号:",@"来源单据:",@"状态:",@"发货仓库:",@"收货仓库:",@"车辆:",@"司机电话:",@"创建:",@"备注"]; NSArray *leftArr = @[@"单号:",@"来源单据:",@"状态:",@"发货仓库:",@"收货仓库:",@"车辆:",@"司机电话:",@"创建:",@"备注"];
...@@ -273,14 +298,52 @@ typedef enum : NSUInteger { ...@@ -273,14 +298,52 @@ typedef enum : NSUInteger {
if ([self checkReceive]) { if ([self checkReceive]) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"收货后不能重复收货,请确认是否要收货?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil]; UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"收货后不能重复收货,请确认是否要收货?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
alertView.delegate = self; alertView.delegate = self;
alertView.tag = ReceiveTag;
[alertView show]; [alertView show];
} }
} }
break; break;
case AbortTag:
{
CLog(@"作废");
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请确认作废" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
alertView.delegate = self;
alertView.tag = AbortTag;
[alertView show];
}
break;
default: default:
break; break;
} }
} }
- (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] abortTransferWithTransferUuid:self.transfer.uuid version:self.transfer.version success:succ failure:fail];
}
- (void)getDataFromServer:(NSString *)state msg:(NSString *)msg{ - (void)getDataFromServer:(NSString *)state msg:(NSString *)msg{
//保存 //保存
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
...@@ -353,10 +416,16 @@ typedef enum : NSUInteger { ...@@ -353,10 +416,16 @@ typedef enum : NSUInteger {
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) { if (alertView.tag == AbortTag) {
//提交 if (buttonIndex == 1) {
self.state = RECEIVE_STATE_RECEIVE; [self dealByAction:TRANSFER_STATE_ABORTED];//作废
[self getDataFromServer:RECEIVE_STATE_RECEIVE msg:@"收货中..."]; }
}else if(alertView.tag == ReceiveTag){
if (buttonIndex == 1) {
//提交
self.state = RECEIVE_STATE_RECEIVE;
[self getDataFromServer:RECEIVE_STATE_RECEIVE msg:@"收货中..."];
}
} }
} }
......
...@@ -139,6 +139,23 @@ typedef enum : NSUInteger { ...@@ -139,6 +139,23 @@ typedef enum : NSUInteger {
return purchseNumber; return purchseNumber;
} }
- (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 = EndTag;
}else if ([arr[i] isEqualToString:@"作废"]) {
btnTag = AbortTag;
}
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];
}
}
#pragma mark - 视图初始化 #pragma mark - 视图初始化
- (void)bulifLayout{ - (void)bulifLayout{
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)]; _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)];
...@@ -146,14 +163,9 @@ typedef enum : NSUInteger { ...@@ -146,14 +163,9 @@ typedef enum : NSUInteger {
_scrollView.showsVerticalScrollIndicator = NO; _scrollView.showsVerticalScrollIndicator = NO;
_scrollView.backgroundColor = XXFBgColor; _scrollView.backgroundColor = XXFBgColor;
[self.view addSubview:_scrollView]; [self.view addSubview:_scrollView];
_firstBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, (ScreenSize.width- LeftMargin *2), 40) target:self sel:@selector(btnClick:) tag:AbortTag image:nil title:@"作废" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
[self.view addSubview:_firstBtn];
// _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:EndTag image:nil title:@"结束" titleColor:[UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR];
// [self.view addSubview:_secondBtn];
if ([self.transfer.state isEqualToString:TRANSFER_STATE_RECEIVED] || [self.transfer.state isEqualToString:TRANSFER_STATE_UNRECEIVED]) { if ([self.transfer.state isEqualToString:TRANSFER_STATE_RECEIVED] || [self.transfer.state isEqualToString:TRANSFER_STATE_UNRECEIVED]) {
if ([IBTCommon checkIsPermission:TRANSFER_ACTION_ABORT]) { if ([IBTCommon checkIsPermission:TRANSFER_ACTION_ABORT]) {
_firstBtn.hidden = NO; [self createBtnWithArr:@[@"作废"]];
}else{ }else{
[self hiddenBottomView]; [self hiddenBottomView];
} }
...@@ -208,7 +220,6 @@ typedef enum : NSUInteger { ...@@ -208,7 +220,6 @@ typedef enum : NSUInteger {
[self createBottomView]; [self createBottomView];
} }
- (void)hiddenBottomView{ - (void)hiddenBottomView{
_firstBtn.hidden = YES;
CGRect scrollViewFrame = _scrollView.frame; CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64; scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame; _scrollView.frame = scrollViewFrame;
......
...@@ -238,7 +238,8 @@ typedef enum : NSUInteger { ...@@ -238,7 +238,8 @@ typedef enum : NSUInteger {
} }
- (void)textChange:(UITextField *)textField{ - (void)textChange:(UITextField *)textField{
if (_actualmoneyField.text.length > 0 && _paidmoneyField.text.length > 0 ) { if (_actualmoneyField.text.length > 0 && _paidmoneyField.text.length > 0 ) {
_leftmoneyField.text = [NSString stringWithFormat:@"%.4f",[_actualmoneyField.text floatValue] - [_paidmoneyField.text floatValue]]; _leftmoneyField.text = [NSString stringWithFormat:@"%.2f",[_actualmoneyField.text floatValue] - [_paidmoneyField.text floatValue]];
} }
} }
......
...@@ -204,13 +204,27 @@ typedef enum : NSUInteger { ...@@ -204,13 +204,27 @@ typedef enum : NSUInteger {
} }
} }
- (void)hiddenAllBtn{ - (void)hiddenAllBtn{
_firstBtn.hidden = YES;
_secondBtn.hidden = YES;
CGRect scrollViewFrame = _scrollView.frame; CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64; scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame; _scrollView.frame = scrollViewFrame;
} }
- (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 = EndTag;
}else if ([arr[i] isEqualToString:@"作废"]) {
btnTag = AbortTag;
}
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];
}
}
#pragma mark - 视图初始化 #pragma mark - 视图初始化
- (void)bulifLayout{ - (void)bulifLayout{
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)]; _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)];
...@@ -218,40 +232,30 @@ typedef enum : NSUInteger { ...@@ -218,40 +232,30 @@ typedef enum : NSUInteger {
_scrollView.showsVerticalScrollIndicator = NO; _scrollView.showsVerticalScrollIndicator = NO;
_scrollView.backgroundColor = XXFBgColor; _scrollView.backgroundColor = XXFBgColor;
[self.view addSubview:_scrollView]; [self.view addSubview:_scrollView];
_firstBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, (ScreenSize.width - LeftMargin*3)/2, 40) target:self sel:@selector(btnClick:) tag:AbortTag image:nil title:@"作废" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
[self.view addSubview:_firstBtn];
_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:EndTag image:nil title:@"结束" titleColor:[UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR];
[self.view addSubview:_secondBtn];
if ([self.transport.state isEqualToString:TRANSPORT_STATE_ABORTED]) { if ([self.transport.state isEqualToString:TRANSPORT_STATE_ABORTED]) {
[self hiddenAllBtn]; [self hiddenAllBtn];
}else if([self.transport.state isEqualToString:TRANSPORT_STATE_FINISHED]){ }else if([self.transport.state isEqualToString:TRANSPORT_STATE_FINISHED]){
if ([IBTCommon checkIsPermission:TRANSPORT_ACTION_ABORT]) { if ([IBTCommon checkIsPermission:TRANSPORT_ACTION_ABORT]) {
_secondBtn.hidden = YES; NSArray *arr = @[@"作废"];
_firstBtn.hidden = NO; [self createBtnWithArr:arr];
_firstBtn.width = ScreenSize.width - LeftMargin*2;
}else{ }else{
[self hiddenAllBtn]; [self hiddenAllBtn];
} }
}else{ }else if([self.transport.state isEqualToString:TRANSPORT_STATE_RECEIVED]){
if ([IBTCommon checkIsPermission:TRANSPORT_ACTION_ABORT] && [IBTCommon checkIsPermission:TRANSPORT_ACTION_FINISH]) { NSMutableArray *arr = [NSMutableArray array];
_secondBtn.hidden = NO; if ([IBTCommon checkIsPermission:TRANSPORT_ACTION_ABORT]) {
_firstBtn.hidden = NO; [arr addObject:@"作废"];
}
if([IBTCommon checkIsPermission:TRANSPORT_ACTION_FINISH])
{
[arr addObject:@"结束"];
}
if (arr.count == 0) {
[self hiddenAllBtn];
}else{ }else{
if ([IBTCommon checkIsPermission:TRANSPORT_ACTION_ABORT]) { [self createBtnWithArr:arr];
_secondBtn.hidden = YES;
_firstBtn.hidden = NO;
_firstBtn.width = ScreenSize.width - LeftMargin*2;
}else if([IBTCommon checkIsPermission:TRANSPORT_ACTION_FINISH])
{
_secondBtn.hidden = NO;
_firstBtn.hidden = YES;
_secondBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin*2, 40);
}else{
[self hiddenAllBtn];
}
} }
} }
NSArray *leftArr = @[@"单号:",@"采购单:",@"状态:",@"发货仓库:",@"收货仓库:",@"车辆:",@"司机电话:",@"创建:",@"预计到货时间:",@"备注:"]; NSArray *leftArr = @[@"单号:",@"采购单:",@"状态:",@"发货仓库:",@"收货仓库:",@"车辆:",@"司机电话:",@"创建:",@"预计到货时间:",@"备注:"];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment