Commit 739d52c3 authored by 陈俊俊's avatar 陈俊俊

采购单

parent 0c02d72c
......@@ -363,7 +363,6 @@
C1FE50531AE024FA00C18080 /* UIAlertView+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = C1FE504D1AE024FA00C18080 /* UIAlertView+Blocks.m */; };
C1FE50561AE3587F00C18080 /* ICRAttachmentUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = C1FE50551AE3587F00C18080 /* ICRAttachmentUnit.m */; };
C1FE50571AE3587F00C18080 /* ICRAttachmentUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = C1FE50551AE3587F00C18080 /* ICRAttachmentUnit.m */; };
FE0C652C1B8EAB3400580183 /* AddProductViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FE0C652B1B8EAB3400580183 /* AddProductViewController.m */; };
FE0C9B091B7C543D00335B39 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = FE0C9B081B7C543D00335B39 /* User.m */; };
FE17F6791B85847D0078CE96 /* QueryOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FE17F6781B85847D0078CE96 /* QueryOrder.m */; };
FE17F6831B85CA5B0078CE96 /* NewPurchaseNoticeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FE17F67C1B85CA5B0078CE96 /* NewPurchaseNoticeViewController.m */; };
......@@ -812,8 +811,6 @@
C1FE504D1AE024FA00C18080 /* UIAlertView+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertView+Blocks.m"; sourceTree = "<group>"; };
C1FE50541AE3587F00C18080 /* ICRAttachmentUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ICRAttachmentUnit.h; sourceTree = "<group>"; };
C1FE50551AE3587F00C18080 /* ICRAttachmentUnit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ICRAttachmentUnit.m; sourceTree = "<group>"; };
FE0C652A1B8EAB3400580183 /* AddProductViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddProductViewController.h; sourceTree = "<group>"; };
FE0C652B1B8EAB3400580183 /* AddProductViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddProductViewController.m; sourceTree = "<group>"; };
FE0C9B071B7C543D00335B39 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = User.h; path = ../Views/User.h; sourceTree = "<group>"; };
FE0C9B081B7C543D00335B39 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = User.m; path = ../Views/User.m; sourceTree = "<group>"; };
FE17F6771B85847D0078CE96 /* QueryOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueryOrder.h; sourceTree = "<group>"; };
......@@ -1069,8 +1066,6 @@
FE4678A91B8D60F900B5EDA3 /* ChooseTypeViewController.m */,
FE4678AB1B8D636300B5EDA3 /* ChooseWarehouseViewController.h */,
FE4678AC1B8D636300B5EDA3 /* ChooseWarehouseViewController.m */,
FE0C652A1B8EAB3400580183 /* AddProductViewController.h */,
FE0C652B1B8EAB3400580183 /* AddProductViewController.m */,
);
path = Controllers;
sourceTree = "<group>";
......@@ -2208,7 +2203,6 @@
C15295CE1B24741400DF60D1 /* ASValuePopUpView.m in Sources */,
C159184D1AC062460013B391 /* IBTTableView.m in Sources */,
30D1859C1ADBB91000327997 /* ICRAnnouncement.m in Sources */,
FE0C652C1B8EAB3400580183 /* AddProductViewController.m in Sources */,
C142D2AE1AC3A155000109A7 /* NSString+TrimmingAdditions.m in Sources */,
C15918471AC062460013B391 /* IBTCommon.m in Sources */,
C1FE502D1ADD887400C18080 /* LBorderView.m in Sources */,
......
......@@ -135,6 +135,19 @@
#define PURCHASE_STATE_SHIPPING @"shipping"
#define PURCHASE_STATE_FINISHED @"finished"
//采购单操作
#define PURCHASE_ACTION_REJECT @"reject"
#define PURCHASE_ACTION_APPROVE @"approve"
#define PURCHASE_ACTION_VENDORCONFIRM @"vendorConfirm"
#define PURCHASE_ACTION_FINISH @"finish"
#define PURCHASE_ACTION_ABORT @"abort"
//权限列表vendorapprove
#define PURCHASE_PERMISSIONS_MANAGEAPPROVE @"500405"
#define PURCHASE_PERMISSIONS_VENDORAPPROVE @"500406"
#define PURCHASE_PERMISSIONS_FINISH @"500407"
#define PURCHASE_PERMISSIONS_ABORT @"500408"
#define ShowMessage(msg) [[[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil] show]
......
//
// AddProductViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/8/27.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
#import "HPGrowingTextView.h"
@protocol AddProductViewDelegate <NSObject>
- (void)dissmiss;
- (void)pushViewController:(id)cvc;
@end
@interface AddProductViewController : ICRBaseViewController
@property (nonatomic,assign)CGRect viewFrame;
@property (nonatomic,strong)UILabel *productNameLabel;//商品
@property (nonatomic,strong)UILabel *productTypeLabel;//单位
@property (nonatomic,strong)UITextField *productStandFiled;//规格
@property (nonatomic,strong)UITextField *productCountFiled;//包装数量
@property (nonatomic,strong)UITextField *baseCountFiled;//基础数量
@property (nonatomic,strong)UITextField *basePriceFiled;//基础单价
@property (nonatomic,strong)UITextField *productPriceFiled;//包装单价
@property (nonatomic,strong)UITextField *totalPriceFiled;//总价格
@property (nonatomic,strong)HPGrowingTextView *remarkTextView;//备注
@property (nonatomic,weak)id<AddProductViewDelegate>delegate;
@end
//
// AddProductViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/8/27.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "AddProductViewController.h"
#import "SurveyCell.h"
#import "ChooseProductViewController.h"
#import "ChooseTypeViewController.h"
#define LeftMargin 15
#define BtnHeight 44
#define TableHeight 46
#define TopHeight 50
#define TotalHeight 508
#define KeyboardHeight 258
typedef enum : NSUInteger {
DelTag = 9000,
CommitTag,
DissTag
} BtnTag;
@interface AddProductViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate,HPGrowingTextViewDelegate>
{
UIView *_bgView;
UITableView *_tableView;
NSMutableArray *_dataArr;
CGRect _tableFrame;
}
@end
@implementation AddProductViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initData];
[self bulidLayout];
}
- (void)initData{
_dataArr = [NSMutableArray array];
[_dataArr addObject:@"商品"];
[_dataArr addObject:@"包装单位"];
[_dataArr addObject:@"包装规格"];
[_dataArr addObject:@"包装数量"];
[_dataArr addObject:@"基础数量"];
[_dataArr addObject:@"基础单价"];
[_dataArr addObject:@"包装单价"];
[_dataArr addObject:@"总金额"];
[_dataArr addObject:@"备注"];
}
- (void)setViewFrame:(CGRect)viewFrame{
_tableFrame = viewFrame;
}
- (void)bulidLayout{
_bgView = [[UIView alloc]initWithFrame:CGRectMake(LeftMargin, (self.view.frame.size.height - TotalHeight)/2, self.view.frame.size.width - LeftMargin*2, TotalHeight)];
_bgView.layer.cornerRadius = 5;
_bgView.layer.masksToBounds = YES;
[self.view addSubview:_bgView];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0,CGRectGetWidth(_bgView.frame), TopHeight)];
label.text = @"新增商品明细";
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = XXFBgColor;
label.textColor = GXF_CONTENT_COLOR;
label.font = GXF_FIFTEENTEN_SIZE;
[_bgView addSubview:label];
UIButton *dissBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetWidth(_bgView.frame) - TopHeight, 0, TopHeight, TopHeight) target:self sel:@selector(btnClick:) tag:DissTag image:nil title:@"关闭" titleColor:GXF_CONTENT_COLOR isCorner:NO corner:0 bgColor:nil];
dissBtn.titleLabel.font = GXF_FIFTEENTEN_SIZE;
[_bgView addSubview:dissBtn];
_tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, TopHeight,CGRectGetWidth(_bgView.frame), CGRectGetHeight(_bgView.frame)-TopHeight)) style:(UITableViewStylePlain)];
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.bounces = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 50)];
UIButton *delBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, 10, (CGRectGetWidth(_bgView.frame) - LeftMargin*3)/2, BtnHeight) target:self sel:@selector(btnClick:) tag:6001 image:nil title:@"删除" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
[footView addSubview:delBtn];
UIButton *commitBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(delBtn.frame.origin.x + delBtn.frame.size.width + LeftMargin, 10, (CGRectGetWidth(_bgView.frame) - LeftMargin*3)/2, BtnHeight) target:self sel:@selector(btnClick:) tag:1001 image:nil title:@"提交" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_COMMIT_COLOR];
[footView addSubview:commitBtn];
// [self.view addSubview:footView];
_tableView.tableFooterView = footView;
[_bgView addSubview:_tableView];
}
- (void)btnClick:(UIButton *)btn{
switch (btn.tag) {
case DissTag:
{
if ([self.delegate respondsToSelector:@selector(dissmiss)]) {
[self.delegate dissmiss];
}
}
break;
default:
break;
}
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"cellID";
SurveyCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[SurveyCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.row ==0 || indexPath.row == 1) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
[self createViewInCell:cell indexPath:indexPath];
}
[cell setTitleStr:_dataArr[indexPath.row]];
return cell;
}
- (void)createViewInCell:(SurveyCell *)cell indexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0 || indexPath.row == 1 ) {
UILabel *contentLabel = [[UILabel alloc]initWithFrame:(CGRectMake(100+LeftMargin, 0, CGRectGetWidth(_bgView.frame) - 100 - LeftMargin*2-10, TableHeight))];
contentLabel.textAlignment= NSTextAlignmentRight;
contentLabel.textColor = GXF_PLACEHOLDER_COLOR;
contentLabel.font = GXF_FIFTEENTEN_SIZE;
[cell.contentView addSubview:contentLabel];
if (indexPath.row == 0) {
contentLabel.text = @"选择商品";
self.productNameLabel = contentLabel;
}else if(indexPath.row == 1){
contentLabel.text = @"选择包装单位";
self.productTypeLabel = contentLabel;
}
}else if (indexPath.row == _dataArr.count -1){
self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, CGRectGetWidth(_bgView.frame) - 100 - LeftMargin*2-10, TableHeight)];
self.remarkTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0);
self.remarkTextView.minNumberOfLines = 1;
self.remarkTextView.maxNumberOfLines = 2;
self.remarkTextView.font = GXF_FIFTEENTEN_SIZE;
self.remarkTextView.textAlignment = NSTextAlignmentRight;
self.remarkTextView.delegate = self;
self.remarkTextView.returnKeyType = UIReturnKeyDone;
self.remarkTextView.placeholder = @"输入备注内容";
[cell.contentView addSubview:self.remarkTextView];
}else{
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, CGRectGetWidth(_bgView.frame) - 100 - LeftMargin*2-30, TableHeight)];
textField.textAlignment = NSTextAlignmentRight;
textField.textColor = GXF_CONTENT_COLOR;
textField.font = GXF_FIFTEENTEN_SIZE;
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
textField.returnKeyType = UIReturnKeyDone;
textField.delegate = self;
[cell.contentView addSubview:textField];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(textField.frame) + 5, 0, 20, TableHeight)];
label.textColor = GXF_CONTENT_COLOR;
label.font = GXF_FIFTEENTEN_SIZE;
[cell.contentView addSubview:label];
if (indexPath.row == 2) {
label.text = @"斤";
textField.placeholder = @"包装规格";
self.productStandFiled = textField;
}else if (indexPath.row == 3) {
label.text = @"框";
textField.placeholder = @"包装数量";
self.productCountFiled = textField;
}else if (indexPath.row == 4) {
label.text = @"斤";
textField.placeholder = @"基础数量";
self.baseCountFiled = textField;
}else if (indexPath.row == 5) {
label.text = @"元";
textField.placeholder = @"基础单价";
self.basePriceFiled = textField;
}else if (indexPath.row == 6) {
label.text = @"元";
textField.placeholder = @"包装单价";
self.productPriceFiled = textField;
}else if (indexPath.row == 7) {
label.text = @"元";
textField.placeholder = @"总金额";
self.totalPriceFiled = textField;
}
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row == 0){
ChooseProductViewController *cvc = [ChooseProductViewController new];
cvc.choseProduct = ^(Product *product){
self.productNameLabel.text = [NSString stringWithFormat:@"%@[%@]",product.name,product.code];
self.productNameLabel.textColor = GXF_CONTENT_COLOR;
};
cvc.isMoreChose = NO;
[self.delegate pushViewController:cvc];
}else if (indexPath.row == 1){
ChooseTypeViewController *tvc = [[ChooseTypeViewController alloc]init];
tvc.title = @"类型";
tvc.dataArr = @[@"筐",@"斤"];
tvc.choseType = ^(NSString *type){
self.productTypeLabel.text = type;
self.productTypeLabel.textColor = GXF_CONTENT_COLOR;
};
[self.delegate pushViewController:tvc];
}
}
#pragma mark delegate
- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView{
[self.remarkTextView resignFirstResponder];
[self setTableFrame:TopHeight];
return YES;
}
- (void)growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView{
CGFloat offset = ScreenSize.height - TotalHeight - KeyboardHeight;
if (offset < 0) {//上移
[self setTableFrame:TopHeight+offset];
}
}
- (void)setTableFrame:(CGFloat)tabelH{
[UIView animateWithDuration:0.25 animations:^{
CGRect tableFrame = _tableView.frame;
tableFrame.origin.y = tabelH;
_tableView.frame = tableFrame;
}];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
if (textField == self.basePriceFiled || textField == self.productPriceFiled || textField == self.totalPriceFiled) {
CGFloat offset = ScreenSize.height - TotalHeight - KeyboardHeight;
if (offset < 0) {//上移
[self setTableFrame:TopHeight+offset];
}
}
}
- (void)keyboardHidden{
[self.productStandFiled resignFirstResponder];
[self.productPriceFiled resignFirstResponder];
[self.productCountFiled resignFirstResponder];
[self.basePriceFiled resignFirstResponder];
[self.baseCountFiled resignFirstResponder];
[self.totalPriceFiled resignFirstResponder];
[self setTableFrame:TopHeight];
}
- (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
......@@ -9,7 +9,6 @@
#import "NewPurchaseViewController.h"
#import "TopPurchaseView.h"
#import "ProductBillViewController.h"
#import "AddProductViewController.h"
#import "PurchaseBillProduct.h"
#import "PurchaseViewController.h"
#define TopHeight 328
......@@ -54,8 +53,50 @@ typedef enum : NSUInteger {
uuidObject = [NSNull null];
billNumberObject = [NSNull null];
versionObject = [NSNumber numberWithInteger:0];
if (self.purchaseBill) {
[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.purchaseBill = bill;
[strongSelf prepareDataInCell];
}else{
[IBTLoadingView showTips:message];
}
}else{
[IBTLoadingView showTips:@" 无记录 "];
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getPurchaseResultWithPurchaseUuid:@"5a7417014f926eb5014f9ce2988a004d" success:succ failure:fail];
}
//赋值
- (void)prepareDataInCell{
_purchaseView.bill = self.purchaseBill;
NSMutableArray *arr = [NSMutableArray array];
for (NSDictionary *productDict in self.purchaseBill.products) {
PurchaseBillProduct *billProduct = [[PurchaseBillProduct alloc]init];
[billProduct setValuesForKeysWithDictionary:productDict];
[arr addObject:billProduct];
}
_pvc.productArr = arr;
[_pvc.tableView reloadData];
}
#pragma mark - 布局
- (void)bulidLayout
......
......@@ -35,22 +35,22 @@
if (!self.productArr) {
self.productArr = [NSMutableArray array];
}
// PurchaseBillProduct *billProduct = [PurchaseBillProduct new];
//
// billProduct.product_name = @"dd";
// billProduct.product_uuid = @"402880e64e287fe2014e28895b8a0032";
// billProduct.product_code = @"农夫山泉";
// billProduct.qpc = [NSNumber numberWithFloat:22];
// billProduct.unit = @"筐";
// billProduct.qty = [NSNumber numberWithFloat:23];
// billProduct.price = [NSNumber numberWithFloat:333];
// billProduct.baseQty = [NSNumber numberWithFloat:333];
// billProduct.basePrice = [NSNumber numberWithFloat:33];
// billProduct.total = [NSNumber numberWithFloat:25];
// billProduct.remark = @"hshshshsh";
// billProduct.qpcStr = @"fdsfdsfdsa";
// [self.productArr addObject:billProduct];
// [self.productArr addObject:billProduct];
PurchaseBillProduct *billProduct = [PurchaseBillProduct new];
billProduct.product_name = @"dd";
billProduct.product_uuid = @"402880e64e287fe2014e28895b8a0032";
billProduct.product_code = @"农夫山泉";
billProduct.qpc = [NSNumber numberWithFloat:22];
billProduct.unit = @"筐";
billProduct.qty = [NSNumber numberWithFloat:23];
billProduct.price = [NSNumber numberWithFloat:333];
billProduct.baseQty = [NSNumber numberWithFloat:333];
billProduct.basePrice = [NSNumber numberWithFloat:33];
billProduct.total = [NSNumber numberWithFloat:40];
billProduct.remark = @"hshshshsh";
billProduct.qpcStr = @"fdsfdsfdsa";
[self.productArr addObject:billProduct];
[self.productArr addObject:billProduct];
if (self.productArr.count > 0) {
[[NSNotificationCenter defaultCenter] postNotificationName:SetProductTotalPrice object:nil];
}
......
......@@ -11,7 +11,8 @@
@interface PurchaseDetailViewController : ICRBaseViewController
@property (nonatomic,strong)PurchaseBill *bill;
//模拟三个人员
@property (nonatomic,assign)NSInteger indexPerson;//0.1.2
//显示样式
@property (nonatomic,assign)NSInteger indexStyle;//0.1.2
@end
......@@ -9,19 +9,20 @@
#import "PurchaseDetailViewController.h"
#import "ProductBillViewController.h"
#import "PurchaseBillProduct.h"
#define BottomHeight 50
#define LeftMargin 15
#define LeftWidth 100
#define LeftHeight 30
#define TopMargin 15
#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)
typedef enum : NSUInteger {
CancleTag = 3500,
EndTag,
RejectTag,
PassTag,
SureTag
CancleTag = 3500,//作废
EndTag, //结束
RejectTag, //拒绝
PassTag, //审核
SureTag, //确定
} BtnTag;
@interface PurchaseDetailViewController ()
......@@ -31,8 +32,9 @@ typedef enum : NSUInteger {
UIView *_bottomView;
ProductBillViewController *_pvc;
NSArray *_leftArr;
UIButton *_endBtn;
UIButton *_rejectBtn;
UIButton *_firstBtn;
UIButton *_secondBtn;
}
@property (nonatomic,strong)UILabel *billNumberLabel;
@property (nonatomic,strong)UILabel *noticeNumberLabel;
......@@ -47,11 +49,11 @@ typedef enum : NSUInteger {
@property (nonatomic,strong)UILabel *warehouseLabel;
@property (nonatomic,strong)UILabel *otherPriceLabel;
@property (nonatomic,strong)UILabel *totalPriceLabel;
@property (nonatomic,strong)UILabel *noteLabel;
@property (nonatomic,strong)NSString *rejectCause;//拒接原因
@end
@implementation PurchaseDetailViewController
......@@ -99,11 +101,12 @@ typedef enum : NSUInteger {
_scrollView.backgroundColor = XXFBgColor;
[self.view addSubview:_scrollView];
[self createBtn];
[self createPurchaseView];
[self createBottomView];
[self createPurchaseView];
if ([self.bill.state isEqualToString:@"finished"]) {
_endBtn.hidden = YES;
_rejectBtn.hidden = YES;
_secondBtn.hidden = YES;
_firstBtn.hidden = YES;
CGRect scrollViewFrame = _scrollView.frame;
scrollViewFrame.size.height = ScreenSize.height - 64;
_scrollView.frame = scrollViewFrame;
......@@ -111,67 +114,153 @@ typedef enum : NSUInteger {
}
- (void)createBtn{
_rejectBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, (ScreenSize.width - LeftMargin*3)/2, 40) target:self sel:@selector(btnClick:) tag:RejectTag image:nil title:@"" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
[self.view addSubview:_rejectBtn];
_firstBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, (ScreenSize.width - LeftMargin*3)/2, 40) target:self sel:@selector(btnClick:) tag:RejectTag image:nil title:@"" titleColor: [UIColor whiteColor] isCorner:YES corner:5 bgColor:GXF_SAVE_COLOR];
[self.view addSubview:_firstBtn];
_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.indexPerson == 0) {
_rejectBtn.hidden = NO;
_rejectBtn.tag = CancleTag;
[_rejectBtn setTitle:@"作废" forState:UIControlStateNormal];
_endBtn.tag = EndTag;
[_endBtn setTitle:@"结束" forState:UIControlStateNormal];
}else if(self.indexPerson == 1){
_rejectBtn.hidden = NO;
_rejectBtn.tag = RejectTag;
[_rejectBtn setTitle:@"拒绝" forState:UIControlStateNormal];
[_endBtn setTitle:@"审核通过" forState:UIControlStateNormal];
_endBtn.tag = PassTag;
}else{
_rejectBtn.hidden = YES;
_endBtn.frame = CGRectMake(LeftMargin, ScreenSize.height - 64 - BottomHeight +5, ScreenSize.width - LeftMargin * 2, 40);
_endBtn.tag = SureTag;
[_endBtn setTitle:@"确认" forState:UIControlStateNormal];
_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];
}
//根据权限判断按钮显示
- (void)showBtnByPermissions{
//逻辑判断按钮显示不显示
if ([self.bill.state isEqualToString:PURCHASE_STATE_SUBMITTED]) {//状态已提交
if ([self checkIsPermission:PURCHASE_PERMISSIONS_VENDORAPPROVE]) {//供应商审批权
//显示确认按钮
_firstBtn.hidden = YES;
[self changeBtnFrame:_secondBtn title:@"确认" originX:LeftMargin width:OneWidth];
_secondBtn.tag = SureTag;
self.indexStyle = 2;
}else if([self checkIsPermission:PURCHASE_PERMISSIONS_MANAGEAPPROVE]){
//显示拒绝和审批
[self changeBtnFrame:_firstBtn title:@"拒绝" originX:LeftMargin width:TwoWidth];
[self changeBtnFrame:_secondBtn title:@"审核通过" originX:CGRectGetMaxX(_firstBtn.frame) + LeftMargin width:TwoWidth];
_firstBtn.tag = RejectTag;
_secondBtn.tag = PassTag;
self.indexStyle = 1;
}
}else if([self.bill.state isEqualToString:PURCHASE_STATE_SHIPPING]){//状态是发运中
if([self checkIsPermission:PURCHASE_PERMISSIONS_VENDORAPPROVE]){//供应商审批权
//显示确认按钮
_firstBtn.hidden = YES;
[self changeBtnFrame:_secondBtn title:@"确认" originX:LeftMargin width:OneWidth];
_secondBtn.tag = SureTag;
self.indexStyle = 2;
}else{
self.indexStyle = 0;
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;
[self changeBtnFrame:_secondBtn title:@"结束" originX:LeftMargin width:OneWidth];
_secondBtn.tag = EndTag;
}else if([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]){//作废权
//显示作废按钮
_firstBtn.hidden = YES;
[self changeBtnFrame:_secondBtn title:@"作废" originX:LeftMargin width:OneWidth];
_secondBtn.tag = CancleTag;
}
}
}
}else if([self.bill.state isEqualToString:PURCHASE_STATE_FINISHED]){//完成
if ([self checkIsPermission:PURCHASE_PERMISSIONS_ABORT]) {//有作废权的
//显示作废按钮
_firstBtn.hidden = YES;
[self changeBtnFrame:_secondBtn title:@"作废" originX:LeftMargin width:OneWidth];
_secondBtn.tag = CancleTag;
self.indexStyle = 0;
}else{//不显示任何按钮
_firstBtn.hidden = YES;
_secondBtn.hidden = YES;
self.indexStyle = 1;
}
}
}
//改变按钮的位置
- (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;
}
}
return NO;
}
- (void)btnClick:(UIButton *)btn{
NSLog(@"%ld",(long)btn.tag);
CLog(@"%ld",(long)btn.tag);
switch (btn.tag) {
case CancleTag:
{
NSLog(@"作废");
CLog(@"作废");
[self dealByAction:PURCHASE_ACTION_ABORT];
}
break;
case EndTag:
{
NSLog(@"结束");
CLog(@"结束");
[self dealByAction:PURCHASE_ACTION_FINISH];
}
break;
case RejectTag:
{
NSLog(@"拒绝");
CLog(@"拒绝");
[self dealByAction:PURCHASE_ACTION_REJECT];
}
break;
case PassTag:
{
NSLog(@"审核通过");
CLog(@"审核通过");
[self dealByAction:PURCHASE_ACTION_APPROVE];
}
break;
case SureTag:
{
NSLog(@"确定");
CLog(@"确认");
[self dealByAction:PURCHASE_ACTION_VENDORCONFIRM];
}
break;
default:
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]dealByActionWithPurchaseUuid:self.bill.uuid action:action remark:[IBTCommon checkString:self.rejectCause] version:self.bill.version success:succ failure:fail];
}
- (void)createBottomView{
_bottomView= [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_purchaseView.frame) + TopMargin, ScreenSize.width, 200)];
......@@ -187,9 +276,9 @@ typedef enum : NSUInteger {
}
- (void)createPurchaseView{
if (self.indexPerson == 0) {
if (self.indexStyle == 0) {
_leftArr = @[@"单号:",@"采购通知单:",@"创建人:",@"最后修改人:",@"状态:",@"类型:",@"供应商:",@"供应商确认:",@"收货仓库:",@"其他费用:",@"总金额:",@"备注:"];
}else if (self.indexPerson == 1) {
}else if (self.indexStyle == 1) {
_leftArr = @[@"单号:",@"采购通知单:",@"创建人:",@"审核人:",@"状态:",@"类型:",@"供应商:",@"供应商确认:",@"收货仓库:",@"其他费用:",@"总金额:",@"备注:"];
}else{
_leftArr = @[@"单号:",@"采购通知单:",@"创建人:",@"审核人:",@"状态:",@"供应商:",@"其他费用:",@"总金额:",@"备注:"];
......@@ -223,8 +312,8 @@ typedef enum : NSUInteger {
rightLabel.numberOfLines = 0;
self.noteLabel = rightLabel;
}
if (self.indexPerson == 0 || self.indexPerson == 1) {
if (self.indexPerson == 0) {
if (self.indexStyle == 0 || self.indexStyle == 1) {
if (self.indexStyle == 0) {
if (i == 3) {
self.lastModifyNameLabel = rightLabel;
}
......
......@@ -7,6 +7,7 @@
//
#import "PurchaseViewController.h"
#import "NewPurchaseViewController.h"
#import "PurchaseCell.h"
#import "PurchaseBill.h"
#import "PurchaseDetailViewController.h"
......@@ -54,6 +55,7 @@ typedef enum : NSUInteger {
[super viewDidLoad];
self.view.backgroundColor = XXFBgColor;
[self initData];
[self createBackBtn];
[self createTableView];
[self createRefresh];
[self getData];
......@@ -63,15 +65,17 @@ typedef enum : NSUInteger {
self.dataArr = [NSMutableArray array];
for (NSInteger i = 0; i < 6; i++) {
PurchaseBill *bill = [PurchaseBill new];
bill.billNumber = @"222222222";
bill.billNumber = @"150903000013";
bill.noticeNumber = @"134594059654";
bill.create_operName = @"创建人";
bill.create_time = @"2013-03-04";
bill.vendor_name = @"供应商";
bill.total = [NSNumber numberWithFloat:22];
bill.charge = [NSNumber numberWithFloat:333];
bill.remark = @"备注";
bill.lastModify_operName = @"最后修改人";
bill.vendorConfirmTime = @"否";
if (i == 0) {
bill.state = @"initial";
}else if(i == 1){
......@@ -436,25 +440,43 @@ typedef enum : NSUInteger {
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
PurchaseDetailViewController *pvc = [PurchaseDetailViewController new];
pvc.title = @"查看采购单";
pvc.bill = _dataArr[indexPath.row];
if(indexPath.row == 0){
pvc.indexPerson = 0;
}else if(indexPath.row == 1){
pvc.indexPerson = 1;
}else if(indexPath.row == 2){
pvc.indexPerson = 2;
if (_dataArr.count > 0) {
PurchaseBill *bill = _dataArr[indexPath.row];
if ([bill.state isEqualToString:PURCHASE_STATE_INITIAL] || [bill.state isEqualToString:PURCHASE_STATE_REJECTED]) {
NewPurchaseViewController *nvc = [NewPurchaseViewController new];
nvc.purchaseBill = bill;
[self PushViewController:nvc animated:YES];
}else{
PurchaseDetailViewController *pvc = [PurchaseDetailViewController new];
pvc.title = @"查看采购单";
pvc.bill = bill;
[self PushViewController:pvc animated:YES];
}
}
[self PushViewController:pvc animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return TableHeight;
}
- (void)createBackBtn{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
btn.frame = CGRectMake(0, 0, 12, 20);
[btn addTarget:self action:@selector(backRV) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *back = [[UIBarButtonItem alloc]initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = back;
}
- (void)backRV{
[self PopToRootViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
if ([ICRUserUtil sharedInstance].needFresh && self.tableView != nil) {
[self.tableView.header beginRefreshing];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
......
......@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import "HPGrowingTextView.h"
#import "PurchaseBill.h"
@protocol TopPurchaseViewDelegate <NSObject>
- (void)hiddenKeyBoard;
......@@ -37,7 +37,7 @@
@property (nonatomic,strong)NSNumber *total;
@property (nonatomic,strong)NSNumber *chargePurchase;
@property (nonatomic,strong)NSString *remark;
@property (nonatomic,strong)PurchaseBill *bill;
@property (nonatomic,weak)id <TopPurchaseViewDelegate>delegate;
......
......@@ -93,13 +93,14 @@
[cell.contentView addSubview:label];
}else if (indexPath.row == _dataArr.count -1){
self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight)];
self.remarkTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(100+LeftMargin, 0, ScreenSize.width - 100 - LeftMargin*2-15, TableHeight/2)];
self.remarkTextView.backgroundColor = [UIColor redColor];
self.remarkTextView.contentInset = UIEdgeInsetsMake(5, 5, 5, 0);
self.remarkTextView.minNumberOfLines = 1;
self.remarkTextView.maxNumberOfLines = 2;
self.remarkTextView.maxNumberOfLines = 1;
self.remarkTextView.font = GXF_FIFTEENTEN_SIZE;
self.remarkTextView.textAlignment = NSTextAlignmentRight;
self.remarkTextView.delegate = self;
self.remarkTextView.delegate = self;
self.remarkTextView.returnKeyType = UIReturnKeyDone;
self.remarkTextView.placeholder = @"输入备注内容";
[cell.contentView addSubview:self.remarkTextView];
......@@ -139,7 +140,49 @@
}
[self prepareDataInCell];
}
//赋值
- (void)setBill:(PurchaseBill *)bill{
if (bill) {
if (bill.noticeUuid.length > 0) {
self.purchaseNoticeLabel.text = bill.noticeNumber;
self.purchaseNoticeLabel.textColor = GXF_CONTENT_COLOR;
}
if (bill.type.length > 0) {
NSString *type = [bill.type isEqualToString:GXF_Critical] ? @"紧急" : @"普通";
self.purchaseTypeLabel.text = type;
self.purchaseTypeLabel.textColor = GXF_CONTENT_COLOR;
self.type = bill.type;
}
if (bill.vendor_name.length > 0) {
self.purchaseSupplierLabel.text = [NSString stringWithFormat:@"%@[%@]",bill.vendor_name,bill.vendor_code];
self.purchaseSupplierLabel.textColor = GXF_CONTENT_COLOR;
self.vendor_uuid = bill.uuid;
self.vendor_code = bill.vendor_code;
self.vendor_name = bill.vendor_name;
}
if (bill.receiveWrh_name.length > 0) {
self.purchaseStoreLabel.text = [NSString stringWithFormat:@"%@[%@]",bill.receiveWrh_name,bill.receiveWrh_code];
self.purchaseStoreLabel.textColor = GXF_CONTENT_COLOR;
self.receiveWrh_uuid = bill.receiveWrh_uuid;
self.receiveWrh_code = bill.receiveWrh_code;
self.receiveWrh_name = bill.receiveWrh_name;
}
if (bill.charge) {
self.otherPriceFiled.text = [bill.charge stringValue];
self.chargePurchase = bill.charge;
}
if (bill.total) {
self.purchasePriceLabel.text = [bill.total stringValue];
self.total = bill.total;
}
if (bill.remark.length > 0) {
self.remarkTextView.text = bill.remark;
self.remark = bill.remark;
}
}
}
- (void)prepareDataInCell{
if (self.total) {
......
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