Commit 448e593b authored by Sandy's avatar Sandy

销售录入新建接口调试/查询接口调试

parent c32525ec
......@@ -101,6 +101,7 @@
8FEF5EAE1F28612B001496E3 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FEF5E981F28612B001496E3 /* BaseViewController.m */; };
8FEF5EB01F28612B001496E3 /* ZJBaseFileModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FEF5E9A1F28612B001496E3 /* ZJBaseFileModel.m */; };
8FEF5EB21F28612B001496E3 /* ZJBaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FEF5E9C1F28612B001496E3 /* ZJBaseModel.m */; };
8FF9F6DE1F3450AC006B0EC0 /* SaleInputDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FF9F6DD1F3450AC006B0EC0 /* SaleInputDetailViewController.m */; };
B3A759A50113DA2AD3E85C40 /* libPods-hdmall_base-HDMall_TEST.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3784BD616CA8AF0775D5526F /* libPods-hdmall_base-HDMall_TEST.a */; };
/* End PBXBuildFile section */
......@@ -293,6 +294,8 @@
8FEF5E9A1F28612B001496E3 /* ZJBaseFileModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZJBaseFileModel.m; sourceTree = "<group>"; };
8FEF5E9B1F28612B001496E3 /* ZJBaseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZJBaseModel.h; sourceTree = "<group>"; };
8FEF5E9C1F28612B001496E3 /* ZJBaseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZJBaseModel.m; sourceTree = "<group>"; };
8FF9F6DC1F3450AC006B0EC0 /* SaleInputDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaleInputDetailViewController.h; sourceTree = "<group>"; };
8FF9F6DD1F3450AC006B0EC0 /* SaleInputDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaleInputDetailViewController.m; sourceTree = "<group>"; };
B7647FC31ADEF96A4D33BB34 /* Pods-hdmall_base-HDMall.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hdmall_base-HDMall.release.xcconfig"; path = "Pods/Target Support Files/Pods-hdmall_base-HDMall/Pods-hdmall_base-HDMall.release.xcconfig"; sourceTree = "<group>"; };
D3A3D2FD83D7ADD6AC921E3B /* Pods-hdmall_base-HDMall_TEST.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hdmall_base-HDMall_TEST.debug.xcconfig"; path = "Pods/Target Support Files/Pods-hdmall_base-HDMall_TEST/Pods-hdmall_base-HDMall_TEST.debug.xcconfig"; sourceTree = "<group>"; };
DE3C94E5EBEB6D5CCA6E7916 /* Pods-hdmall_base-HDMall.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hdmall_base-HDMall.debug.xcconfig"; path = "Pods/Target Support Files/Pods-hdmall_base-HDMall/Pods-hdmall_base-HDMall.debug.xcconfig"; sourceTree = "<group>"; };
......@@ -618,6 +621,8 @@
8F4BFCD21F2EF543003EA16B /* SaleInputListViewController.m */,
8F4BFCDD1F2F0279003EA16B /* SaleInputAddViewController.h */,
8F4BFCDE1F2F0279003EA16B /* SaleInputAddViewController.m */,
8FF9F6DC1F3450AC006B0EC0 /* SaleInputDetailViewController.h */,
8FF9F6DD1F3450AC006B0EC0 /* SaleInputDetailViewController.m */,
);
path = ViewControllers;
sourceTree = "<group>";
......@@ -1158,6 +1163,7 @@
8F4BFD0D1F3019AC003EA16B /* SalesInputTotalVIew.m in Sources */,
8F4BFCFA1F2F32D5003EA16B /* InspectRepairAddPicTableViewCell.m in Sources */,
8F250D841F29C14F0031B4BC /* LoginViewModel.m in Sources */,
8FF9F6DE1F3450AC006B0EC0 /* SaleInputDetailViewController.m in Sources */,
8FEF5E7E1F285E56001496E3 /* UIViewController+Additions.m in Sources */,
8F250D3B1F297DA80031B4BC /* XWCoolAnimator+XWPageFlip.m in Sources */,
8F250D4D1F297DA80031B4BC /* XWFilterAnimator+XWMask.m in Sources */,
......
......@@ -78,7 +78,8 @@
@property (nonatomic, strong) NSString <Optional> * receiver;
@property (nonatomic, strong) NSNumber <Optional> * balance;
@property (nonatomic, strong) NSString <Optional> * billNumber;
@property (nonatomic, assign) BOOL balance;
@property (nonatomic, strong) HMSaleInputDetail_tenant <Optional> * tenant;
......
......@@ -7,7 +7,18 @@
//
#import "BaseViewController.h"
#import "SaleInputViewModel.h"
#import "SaleInputAmountCollectionViewCell.h"
#import "SaleInputAddAmountCell.h"
#import "InspectRepairAddPicTableViewCell.h"
#import "CalculateHelper.h"
#import "SalesInputTotalVIew.h"
#import "SaleInputTopView.h"
@interface SaleInputAddViewController : BaseViewController
@property (weak, nonatomic) IBOutlet UITableView *tableView;
/** 计算本单合计、输入总笔数 */
@property (nonatomic, weak) IBOutlet SalesInputTotalVIew *totalView;
@property (weak, nonatomic) IBOutlet UIButton *btnBottom;
@property (strong, nonatomic) SaleInputViewModel *viewModel;
@property (weak, nonatomic) IBOutlet SaleInputTopView *topView;
@end
......@@ -7,31 +7,19 @@
//
#import "SaleInputAddViewController.h"
#import "SaleInputViewModel.h"
#import "SaleInputAmountCollectionViewCell.h"
#import "SaleInputAddAmountCell.h"
#import "InspectRepairAddPicTableViewCell.h"
#import "CalculateHelper.h"
#import "SalesInputTotalVIew.h"
@interface SaleInputAddViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
/** 计算本单合计、输入总笔数 */
@property (nonatomic, weak) IBOutlet SalesInputTotalVIew *totalView;
@property (weak, nonatomic) IBOutlet UIButton *btnBottom;
@property (strong, nonatomic) SaleInputViewModel *viewModel;
@property (strong, nonatomic) NSMutableArray *arrData;
@end
@implementation SaleInputAddViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
WS(weakSelf);
[self.viewModel httpAllPayments:^(NSMutableArray<HMSaleInputDetail_payments_payment *> *arrPayments) {
weakSelf.arrData = arrPayments;
[self.viewModel httpAllPayments:^(BOOL isSuccess) {
[weakSelf.tableView reloadData];
CLog(@"%@", arrPayments);
}];
}
......@@ -41,7 +29,7 @@
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return self.arrData.count;
return self.viewModel.arrPayments.count;
}else{
return 1;
}
......@@ -73,7 +61,7 @@
//输入各种支付方式的金额
SaleInputAddAmountCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SaleInputAddAmountCell" forIndexPath:indexPath];
cell.isEdit = self.viewModel.type != SaleInputTypeReadOnly;
[cell configCellWithArray:self.arrData indexPath:indexPath];
[cell configCellWithArray:self.viewModel.arrPayments indexPath:indexPath];
WS(weakSelf);
cell.blockNumberChanged = ^{
[weakSelf allInputMoney];
......@@ -95,7 +83,7 @@
- (void)allInputMoney {
NSDecimalNumber *allInputMoney = nil;
for (HMSaleInputDetail_payments *cellModel in self.arrData) {
for (HMSaleInputDetail_payments *cellModel in self.viewModel.arrPayments) {
allInputMoney = [CalculateHelper calculateNum1:allInputMoney num2:cellModel.total type:CalculateTypeAdd];
}
//本单合计
......@@ -109,10 +97,15 @@
#pragma mark - actions
- (IBAction)actionSubmit:(id)sender {
[self.viewModel httpUpload];
self.viewModel.request.saleCount = @(self.totalView.textFieldBillCount.text.integerValue);
self.viewModel.request.contract = self.topView.contract;
WS(weakSelf);
[self.viewModel httpSubmit:^(BOOL isSuccess) {
if (isSuccess) {
[weakSelf.navigationController popViewControllerAnimated:YES];
}
}];
}
ZJLazy(SaleInputViewModel, viewModel);
ZJLazy(NSMutableArray, arrData);
@end
//
// SaleInputDetailViewController.h
// HDMall
//
// Created by Javen on 2017/8/4.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "SaleInputAddViewController.h"
#import "HMSaleInputDetail.h"
@interface SaleInputDetailViewController : SaleInputAddViewController
@property (strong, nonatomic) HMSaleInputDetail *listModel;
@end
//
// SaleInputDetailViewController.m
// HDMall
//
// Created by Javen on 2017/8/4.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "SaleInputDetailViewController.h"
@interface SaleInputDetailViewController ()
@end
@implementation SaleInputDetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.viewModel httpDetailWithUuid:self.listModel.billNumber callBack:^(BOOL isSuccess) {
}];
}
- (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,11 +9,12 @@
#import "SaleInputListViewController.h"
#import "SaleInputAddViewController.h"
#import "SaleInputListTableViewCell.h"
//#import "SaleInputDetailModel.h"
//#import "SaleInputDetailViewController.h"
#import "HMSaleInputDetail.h"
#import "SaleInputDetailViewController.h"
#import "HMSaleInputQuery.h"
@interface SaleInputListViewController ()
@property (strong, nonatomic) HMSaleInputQuery *query;
@end
@implementation SaleInputListViewController
......@@ -37,10 +38,16 @@
self.query.pageSize = @(self.pageSize);
self.query.dateRange = [HMSaleInputQuery_dateRange new];
self.query.dateRange.beginDate = @"2016-07-12";
self.query.dateRange.endDate = @"2017-07-13";
self.query.dateRange.endDate = [NSDate date].yearMonthDayString;
WS(weakSelf);
[ZJHttpManager POST:@"hdmall/salesinput/query" parameters:self.query.toDictionary complete:^(id responseObject, NSError *error) {
if (kIsResponse) {
if (weakSelf.page == 0) {
[weakSelf.arrData removeAllObjects];
}
NSMutableArray *arr = [HMSaleInputDetail modelsFromArray:responseObject[@"data"][@"records"]];
[weakSelf.arrData addObjectsFromArray:arr];
}else{
kFalseHttpTips;
......@@ -59,11 +66,10 @@
}
- (void)listDidSelect:(id)model {
// SaleInputDetailModel *listModel = model;
// SaleInputDetailViewController *detailVC = [SaleInputDetailViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];
// detailVC.detailType = SaleInputDetailTypeReadOnly;
// detailVC.listModel = listModel;
// [self.navigationController pushViewController:detailVC animated:YES];
HMSaleInputDetail *listModel = model;
SaleInputDetailViewController *detailVC = [SaleInputDetailViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];
detailVC.listModel = listModel;
[self.navigationController pushViewController:detailVC animated:YES];
}
- (void)actionAdd:(UIButton *)sender {
......
......@@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import "HMSaleInputDetail.h"
#import "PicViewModel.h"
typedef void (^blockCallBack)(BOOL isSuccess);
typedef NS_ENUM(NSInteger, SaleInputType) {
SaleInputTypeCreate,
SaleInputTypeEdit,
......@@ -18,13 +18,23 @@ typedef NS_ENUM(NSInteger, SaleInputType) {
@interface SaleInputViewModel : NSObject
@property (assign, nonatomic) SaleInputType type;
@property (strong, nonatomic) PicViewModel *picVM;
@property (strong, nonatomic) NSMutableArray *arrPayments;
/** 创建销售录入单的请求体 */
@property (strong, nonatomic) HMSaleInputDetail *request;
/** 获取销售录入单详情 */
@property (strong, nonatomic) HMSaleInputDetail *detail;
/**
获取全部支付方式
@param callBack 获取到支付方式的回调(如果arrPayments = nil, 则代表请求失败)
*/
- (void)httpAllPayments:(void (^)(NSMutableArray<HMSaleInputDetail_payments *> *arrPayments))callBack;
- (void)httpAllPayments:(blockCallBack)callBack;
- (void)httpUpload;
- (void)httpSubmit:(blockCallBack)callBack;
- (void)httpDetailWithUuid:(NSString *)uuid callBack:(blockCallBack)callBack;
@end
......@@ -7,7 +7,7 @@
//
#import "SaleInputViewModel.h"
#import "CalculateHelper.h"
@implementation SaleInputViewModel
/**
......@@ -15,7 +15,7 @@
@param callBack 获取到支付方式的回调(如果arrPayments = nil, 则代表请求失败)
*/
- (void)httpAllPayments:(void (^)(NSMutableArray<HMSaleInputDetail_payments *> *arrPayments))callBack {
- (void)httpAllPayments:(blockCallBack)callBack {
[ZJHttpManager GET:@"hdmall/salesinput/getAllPayments" parameters:nil complete:^(id responseObject, NSError *error) {
if (kIsResponse) {
NSMutableArray *arrData = [HMSaleInputDetail_payments_payment modelsFromArray:responseObject[@"data"]];
......@@ -27,15 +27,41 @@
payments.payment = pay;
[arrPayments addObject:payments];
}
callBack(arrPayments);
self.arrPayments = arrPayments;
callBack(true);
}else{
callBack(nil);
callBack(false);
kFalseHttpTips;
}
}];
}
- (void)httpUpload {
- (void)httpUpload:(void (^)(void))complete {
}
- (void)httpSubmit:(blockCallBack)callBack {
//赋值
if (self.request.contract == nil) {
[MBProgressHUD j_error:@"请选择合同" complete:nil];
return;
}
self.request.oper = AppGlobal.user.code;
self.request.store = [HMSaleInputDetail_store modelWithDic:AppGlobal.user.store.toDictionary];
// self.request.tenant = [HMSaleInputDetail_tenant modelWithDic:AppGlobal.user.tenant.toDictionary];
self.request.receiver = @"contract";
self.request.balance = false;
self.request.saleDate = [[NSDate date] httpParameterString];
self.request.payments = (id)[NSMutableArray array];
for (HMSaleInputDetail_payments *payments in self.arrPayments) {
HMSaleInputDetail_payments *paymentsCopy = [HMSaleInputDetail_payments modelWithDic:payments.toDictionary];
if (paymentsCopy.total == nil) {
paymentsCopy.total = @(0);
}
[self.request.payments addObject:paymentsCopy];
}
//上传附件
NSMutableArray *arrImage = [NSMutableArray array];
for (UIImage *img in self.picVM.arrPics) {
ZJBaseFileModel *file = [ZJBaseFileModel new];
......@@ -46,10 +72,36 @@
[arrImage addObject:file];
}
[MBProgressHUD j_loading:@"上传中…"];
[ZJHttpManager upLoadFiles:arrImage params:nil commplete:^(NSMutableArray *attachments) {
self.request.mediaFiles = attachments;
[MBProgressHUD j_loading:@"提交中…"];
[ZJHttpManager POST:@"hdmall/salesinput/save" parameters:self.request.toDictionary complete:^(id responseObject, NSError *error) {
if (kIsResponse) {
[MBProgressHUD j_hideLoadingView];
callBack(true);
}else{
callBack(false);
kFalseHttpTips;
}
}];
}];
}
- (void)httpDetailWithUuid:(NSString *)uuid callBack:(blockCallBack)callBack {
NSString *url = [@"hdmall/salesinput/" stringByAppendingString:uuid];
[ZJHttpManager GET:url parameters:nil complete:^(id responseObject, NSError *error) {
if (kIsResponse) {
}else{
kFalseHttpTips;
}
}];
}
ZJLazy(PicViewModel, picVM);
ZJLazy(NSMutableArray, arrPayments);
ZJLazy(HMSaleInputDetail, request);
@end
......@@ -7,13 +7,13 @@
//
#import <UIKit/UIKit.h>
//#import "SaleInputDetailModel.h"
#import "HMSaleInputDetail.h"
@interface SaleInputListTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *labelTItle;
@property (weak, nonatomic) IBOutlet UILabel *labelBillCount;
@property (weak, nonatomic) IBOutlet UILabel *labelTime;
@property (weak, nonatomic) IBOutlet UILabel *labelBillNumber;
//@property (nonatomic, strong) SaleInputDetailModel *model;
@property (nonatomic, strong) HMSaleInputDetail *model;
@property (weak, nonatomic) IBOutlet UIImageView *imgState;
......
......@@ -16,12 +16,12 @@
}
- (void)configCellWithArray:(NSMutableArray *)array indexPath:(NSIndexPath *)indexPath {
// self.model = array[indexPath.row];
// self.labelTItle.text = self.model.contract.name;
// self.labelBillCount.text = [NSString stringWithFormat:@"%.0f",self.model.saleCount];
// self.labelTime.text = self.model.saleDate;
self.model = array[indexPath.row];
self.labelTItle.text = self.model.contract.name;
self.labelBillCount.text = [NSString stringWithFormat:@"%ld",self.model.saleCount.integerValue];
self.labelTime.text = self.model.saleDate;
// self.imgState.image = [UIImage imageNamed:self.model.stateImageName];
// self.labelBillNumber.text = self.model.billNumber;
self.labelBillNumber.text = self.model.billNumber;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
......
......@@ -7,7 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "HMSaleInputDetail.h"
@interface SaleInputTopView : UIView
/** 选择商铺 */
@property (weak, nonatomic) IBOutlet UIButton *btnStore;
......@@ -18,5 +18,6 @@
//两个三角
@property (weak, nonatomic) IBOutlet UIImageView *right1;
@property (weak, nonatomic) IBOutlet UIImageView *right2;
@property (strong, nonatomic) HMSaleInputDetail_contract *contract;
@property (nonatomic, copy) void (^blockDidChooseDate)(void);
@end
......@@ -32,12 +32,28 @@
self.blockDidChooseDate();
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
- (IBAction)actionContract:(id)sender {
if (AppGlobal.user.contracts.count == 1) {
UserInfo_contracts *contract = AppGlobal.user.contracts[0];
self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary];
[self.btnStore setTitle:contract.name forState:UIControlStateNormal];
}else{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择合同" message:nil preferredStyle:(UIAlertControllerStyleAlert)];
for (UserInfo_contracts *contract in AppGlobal.user.contracts) {
UIAlertAction *action = [UIAlertAction actionWithTitle:contract.name style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary];
[self.btnStore setTitle:contract.name forState:UIControlStateNormal];
}];
[alert addAction:action];
}
UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:action];
[self.viewController.navigationController presentViewController:alert animated:YES completion:nil];
}
}
*/
@end
......@@ -11,6 +11,7 @@
#define ZJHttpManager [ZJBaseHttpManager shareCilent]
@interface ZJBaseHttpManager : NSObject
@property (assign, nonatomic) BOOL debugLogEnabled;
+ (ZJBaseHttpManager *)shareCilent;
- (void)POST:(NSString *)URLString
......
......@@ -165,7 +165,7 @@
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
if (kIsResponse) {
complete(responseObject[@"data"]);
} else {
kFalseHttpTips;
......
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