Skip to content

Commit

Permalink
我要进货的搜索框点击 以及 上传底单
Browse files Browse the repository at this point in the history
  • Loading branch information
woaomo committed Sep 24, 2015
1 parent 0dad3ba commit ccfc1e3
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 102 deletions.
11 changes: 3 additions & 8 deletions YHB_Prj/YHB_Prj/Woyaodinghuo/WYJHDetailCell.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -11,7 +11,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="109"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="108.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="品名:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3uR-Qo-WYN">
Expand Down Expand Up @@ -90,9 +90,4 @@
<point key="canvasLocation" x="262" y="146.5"/>
</tableViewCell>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
267 changes: 239 additions & 28 deletions YHB_Prj/YHB_Prj/Woyaodinghuo/WYJHDetailVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#import "WYJHEditViewController.h"
#import "NetManager.h"

@interface WYJHDetailVC ()
@interface WYJHDetailVC ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate,UIActionSheetDelegate>
{
CGRect oldframe;
}
@property (strong, nonatomic) IBOutlet UIView *tvHeadView;
@property (strong, nonatomic) IBOutlet UITableView *tableview;
@property (strong, nonatomic) IBOutlet UILabel *jinhuodanhaoLabel;
Expand All @@ -32,12 +35,27 @@ @interface WYJHDetailVC ()
@property (strong, nonatomic) WYJHManager *manager;
//@property (strong, nonatomic) NSMutableArray *modeArry;

@property (strong, nonatomic) UIImage *didanImage;

@property(assign,nonatomic) BOOL isEdit;

@property(nonatomic,strong) UIView *tempTopView;
@end

@implementation WYJHDetailVC
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if(self=[super initWithNibName:nibNameOrNil bundle:nil])
Expand All @@ -57,14 +75,8 @@ - (void)viewDidLoad {
self.zongshuliangLabel.text = _modeList.strStockNum;
self.zongjineLabel.text = [NSString stringWithFormat:@"%.2f", [_modeList.strTotalRealPay floatValue]];

if([self.modeList.strAccountType intValue] == 1)//未计算
{
self.jieqingBT.hidden = NO;
}
else if([self.modeList.strAccountType intValue] == 2)
{
self.jieqingBT.hidden = YES;
}
[self changejieqingBT];

if([self.modeList.strStatus intValue] == 0)//未入库
{
self.xiugaiBT.hidden = NO;
Expand All @@ -78,6 +90,7 @@ - (void)viewDidLoad {
[self.jieqingBT addTarget:self action:@selector(jieqingBTItem) forControlEvents:UIControlEventTouchUpInside];
[self.shouhuoBT addTarget:self action:@selector(shouhuoBTItem) forControlEvents:UIControlEventTouchUpInside];
[self.xiugaiBT addTarget:self action:@selector(modifyBTItem) forControlEvents:UIControlEventTouchUpInside];
[self.didanBT addTarget:self action:@selector(didanBTItem) forControlEvents:UIControlEventTouchUpInside];

//self.tableview.tableHeaderView = [self getTVHeadView];
self.tableview.delegate = self;
Expand All @@ -86,6 +99,27 @@ - (void)viewDidLoad {
_isEdit = NO;
}

- (void)changejieqingBT
{
if (_isEdit==NO)
{
[self.jieqingBT setTitle:@"结清" forState:UIControlStateNormal];
if([self.modeList.strAccountType intValue] == 1)//未计算
{
self.jieqingBT.hidden = NO;
}
else if([self.modeList.strAccountType intValue] == 2)
{
self.jieqingBT.hidden = YES;
}
}
else
{
self.jieqingBT.hidden = NO;
[self.jieqingBT setTitle:@"上传底单" forState:UIControlStateNormal];
}
}

#pragma mark 初始化数据
- (void)setInitData:(WYJHManager *)aManager mode:(WYJHMode *)aMode modeList:(WYJHModeList *)aList
{
Expand All @@ -107,24 +141,40 @@ - (void)setInitData:(WYJHManager *)aManager mode:(WYJHMode *)aMode modeList:(WYJ
#pragma mark 结清
- (void)jieqingBTItem
{
UIAlertView *alertview = [[UIAlertView alloc] initWithMessage:@"确认结清货物?" cancelButtonTitle:@"取消" otherButtonTitle:@"确定"];
[alertview showUsingBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
if(buttonIndex == 1)
{
[SVProgressHUD show:NO offsetY:0];
[self.manager appAccountSupplierStorage:self.modeList.strId finishBlock:^(BOOL ret) {
if(ret)
{
[SVProgressHUD showWithStatus:@"结算完成" cover:NO offsetY:0];
[SVProgressHUD dissmissAfter];
}
else
{
[SVProgressHUD dismiss];
}
}];
}
}];
if (_isEdit==NO)
{
UIAlertView *alertview = [[UIAlertView alloc] initWithMessage:@"确认结清货物?" cancelButtonTitle:@"取消" otherButtonTitle:@"确定"];
[alertview showUsingBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
if(buttonIndex == 1)
{
[SVProgressHUD show:NO offsetY:0];
[self.manager appAccountSupplierStorage:self.modeList.strId finishBlock:^(BOOL ret) {
if(ret)
{
[SVProgressHUD showWithStatus:@"结算完成" cover:NO offsetY:0];
[SVProgressHUD dissmissAfter];
}
else
{
[SVProgressHUD dismiss];
}
}];
}
}];
}
else
{
[self plusImageClicked];
}
}

#pragma mark 底单
- (void)didanBTItem
{
if (self.didanImage)
{
[self showImage:self.didanImage];
}
}

#pragma mark 收货
Expand Down Expand Up @@ -183,13 +233,28 @@ - (void)modifyBTItem
[tiaomaBt setImage:[UIImage imageNamed:@"icon_2_saoma"] forState:UIControlStateNormal];
[_tempTopView addSubview:tiaomaBt];

[searchBt addTarget:self action:@selector(touchSearch) forControlEvents:UIControlEventTouchUpInside];
[tiaomaBt addTarget:self action:@selector(touchSearch) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:_tempTopView];

[self.tableview setEditing:YES animated:NO];
[_xiugaiBT setTitle:@"完成" forState:UIControlStateNormal];
}

_isEdit = !_isEdit;
[self changejieqingBT];
}

- (void)touchSearch
{
void(^changeBlock)(WYJHModeList *) = ^(WYJHModeList *modelList){
_modeList = modelList;
[self.tableview reloadData];
self.zongshuliangLabel.text = _modeList.strStockNum;
self.zongjineLabel.text = [NSString stringWithFormat:@"%.2f", [_modeList.strTotalRealPay floatValue]];
};
[self pushXIBName:@"ShangpinguanliVC" animated:YES selector:@"setModeList:andChangeBlock:" param:_modeList,changeBlock,nil];
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
Expand Down Expand Up @@ -240,7 +305,7 @@ - (void)configureCell:(WYJHDetailCell *)cell
MLOG(@"%@, %@", mode, _modeList);
self.zongshuliangLabel.text = _modeList.strStockNum;
self.zongjineLabel.text = [NSString stringWithFormat:@"%.2f", [_modeList.strTotalRealPay floatValue]];
}];
} canNull:NO];
[self.navigationController pushViewController:vc animated:YES];
}
}];
Expand Down Expand Up @@ -315,6 +380,152 @@ - (NSMutableDictionary *)getDictfromMode:(WYJHMode *)aMode
return dict;
}

#pragma mark 调用相机
- (void)plusImageClicked
{
UIActionSheet *sheet;

// 判断是否支持相机
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
sheet = [[UIActionSheet alloc] initWithTitle:@"选择图像" delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"取消" otherButtonTitles:@"拍照", @"从相册选择", nil];
}
else {
sheet = [[UIActionSheet alloc] initWithTitle:@"选择图像" delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"取消" otherButtonTitles:@"从相册选择", nil];
}

sheet.tag = 255;

[sheet showInView:self.view];
}

#pragma mark - action sheet delegte
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (actionSheet.tag == 255) {
NSUInteger sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// 判断是否支持相机
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
switch (buttonIndex) {
case 0:
return;
case 1: //相机
sourceType = UIImagePickerControllerSourceTypeCamera;
break;
case 2: //相册
sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
break;
}
}
else {
if (buttonIndex == 0) {
return;
} else {
sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
}

if (sourceType == UIImagePickerControllerSourceTypePhotoLibrary) { // 从相册选择
// if ([UIImagePickerController isPhotoLibraryAvailable]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
picker.allowsEditing=YES;
if (kSystemVersion>7) {
picker.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
}
// 设置导航默认标题的颜色及字体大小
picker.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],
NSFontAttributeName : [UIFont boldSystemFontOfSize:18]};
[self presentViewController:picker animated:YES completion:nil];
// }
} else if (buttonIndex == UIImagePickerControllerSourceTypeCamera) { // 拍照
// if ([UIImagePickerController canTakePhoto]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// NSString *requiredMediaType = (__bridge NSString *)kUTTypeMovie;
// picker.mediaTypes = [[NSArray alloc] initWithObjects:requiredMediaType, nil];
picker.delegate = self;
picker.allowsEditing=YES;

if (kSystemVersion>7) {
picker.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
}
// 设置导航默认标题的颜色及字体大小
picker.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],
NSFontAttributeName : [UIFont boldSystemFontOfSize:18]};
[self presentViewController:picker animated:YES completion:nil];
// }
}
}

}

#pragma mark - image picker delegte
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImage * oriImage = [info objectForKey:UIImagePickerControllerOriginalImage];
// 保存图片到相册中
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
UIImageWriteToSavedPhotosAlbum(oriImage, self,selectorToCall, NULL);
}
self.didanImage = image;
[picker dismissViewControllerAnimated:YES completion:^{
[self.didanBT setTitle:@"查看底单" forState:UIControlStateNormal];
// [self.didanBT setImage:self.didanImage forState:UIControlStateNormal];
}];
}

- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
if (paramError == nil){
NSLog(@"Image was saved successfully.");
paramImage = nil;
} else {
NSLog(@"An error happened while saving the image.");
NSLog(@"Error = %@", paramError);
}
}

-(void)showImage:(UIImage *)aImage{
UIImage *image=aImage;
UIWindow *window=[UIApplication sharedApplication].keyWindow;
UIView *backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
oldframe=CGRectMake(-1, kMainScreenHeight, 1, 1);
backgroundView.backgroundColor=[UIColor blackColor];
backgroundView.alpha=0;
UIImageView *imageView=[[UIImageView alloc]initWithFrame:oldframe];
imageView.image=image;
imageView.tag=1;
[backgroundView addSubview:imageView];
[window addSubview:backgroundView];

UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideImage:)];
[backgroundView addGestureRecognizer: tap];

[UIView animateWithDuration:0.3 animations:^{
imageView.frame=CGRectMake(0,([UIScreen mainScreen].bounds.size.height-image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width)/2, [UIScreen mainScreen].bounds.size.width, image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width);
backgroundView.alpha=1;
} completion:^(BOOL finished) {

}];
}

-(void)hideImage:(UITapGestureRecognizer*)tap{
UIView *backgroundView=tap.view;
UIImageView *imageView=(UIImageView*)[tap.view viewWithTag:1];
[UIView animateWithDuration:0.3 animations:^{
imageView.frame=oldframe;
backgroundView.alpha=0;
} completion:^(BOOL finished) {
[backgroundView removeFromSuperview];
}];
}


//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//
Expand Down
2 changes: 1 addition & 1 deletion YHB_Prj/YHB_Prj/Woyaodinghuo/WYJHDetailVC.xib
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</tableView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Pyc-qO-bBm">
<rect key="frame" x="17" y="436" width="65" height="50"/>
<state key="normal" title="底单" backgroundImage="gy_bt_style1">
<state key="normal" title="无底单" backgroundImage="gy_bt_style1">
<color key="titleColor" red="1" green="0.63615492220000003" blue="0.17634948959999999" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
Expand Down
2 changes: 1 addition & 1 deletion YHB_Prj/YHB_Prj/Woyaodinghuo/WYJHEditViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
@class WYJHModeList;
@interface WYJHEditViewController : BaseViewController

- (instancetype)initWithMode:(WYJHMode *)aMode modeList:(WYJHModeList *)aList andChangeBlock:(void(^)(void))aBlock;
- (instancetype)initWithMode:(WYJHMode *)aMode modeList:(WYJHModeList *)aList andChangeBlock:(void(^)(void))aBlock canNull:(BOOL)aBool;

@end
Loading

0 comments on commit ccfc1e3

Please sign in to comment.