| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- //
- // OrderSaleViewController.m
- // IBOSS
- //
- // Created by apple on 2017/5/15.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:订单销售单控制器
- //
- #import "OrderSaleViewController.h"
- #import "OrderSaleTotalModel.h"
- #import "DateFormat.h"
- #import "OrderSaleListModel.h"
- #import "OrderSalesTableViewCell.h"
- #import "SideSlipModel.h"
- #import "OrderSalesSearchModel.h"
- #import "OrderSalesDetailViewController.h"
- @interface OrderSaleViewController ()
- @end
- @implementation OrderSaleViewController
- #pragma mark - 公共函数
- /**
- viewDidLoad函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self showTitle:@"销售单订单"];
- // _mEndDate= [DateFormat getCurrentDate];
- // _mStartDate = [DateFormat getDateBefore:31];
- [self loadNavStyle];
- [self initUI];
- [self initSlideSlip];
- _arrStock = [[NSMutableArray alloc]init];
- _arrModels = [[NSMutableArray alloc]init];
- _correctStatus = @"1";
- UIView *view = [self backGroundPromptViewByFrame:_vCustomTableView.bounds promptStr:@"请筛选后查询"];
- _vCustomTableView.backgroundView = view;
- //[self reloadData];
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- _vCustomTableView.frame = self.view.safeAreaLayoutGuide.layoutFrame;
- [super viewSafeAreaInsetsDidChange];
- }
- /**
- 抽屉初始化
- */
- - (void)initSlideSlip{
- // 抽屉对象
- __weak typeof(self) weakself=self;
- self.filterController = [[SideSlipFilterController alloc] initWithSponsor:self resetBlock:^(NSArray *dataList) {
- for (SideSlipModel *model in dataList) {
- model.selectedItemList = nil;
- model.customDict = nil;
- }
- } commitBlock:^(NSArray *dataList) {
- // 查询条件
- SideSlipModel *model = dataList[0];
- OrderSalesSearchModel *m = [model.customDict objectForKey:SEARCH_RANGE_MODEL];
- weakself.mStartDate=m.startDate;
- weakself.mEndDate=m.endDate;
- weakself.mCustomerName=m.customerName;
- weakself.mTelephone=m.contactTelephone;
- weakself.mInvoiceType=m.invoiceTypeId;
- weakself.correctStatus=m.correctStatus;
- weakself.mCustomerAddress=m.customerAddress;
- weakself.mOrganizationCode=m.departmentCode;
- weakself.staffId = m.staffId;
- if(_mStartDate == nil){
- [self showAlertViewText:@"请选择开始日期"];
- return;
- }
- if(_mEndDate == nil){
- [self showAlertViewText:@"请选择结束日期"];
- return;
- }
- NSUInteger result= [DateFormat compareDate:_mStartDate withDate:_mEndDate];
- if(result == -1){
- [self showAlertViewText:@"开始日期不能大于结束日期"];
- return;
- }
-
-
- // NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
- // [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式,这里可以设置成自己需要的格式
- //
- // NSDate *startD = [dateFormat dateFromString:_mStartDate];
- // NSDate *endD = [dateFormat dateFromString:_mEndDate];
- // NSInteger days= [DateFormat calculateDaysFromBegin:startD end:endD];
- //
- // if(days > 31){
- // [self showAlertViewText:@"日期间隔天数不能大于31天"];
- // return;
- // }
- [weakself.filterController dismiss];
- [self reloadData];
- }];
- _filterController.animationDuration = AnimationDuration;
- _filterController.hasHeadView = YES;
- _filterController.sideSlipLeading = UIScreenSideSlipLeading*[UIScreen mainScreen].bounds.size.width;
- _filterController.dataList = [self packageDataList];
- }
- /**
- 数据源
-
- @return <#return value description#>
- */
- - (NSArray *)packageDataList {
- NSMutableArray *dataArray = [NSMutableArray array];
- SideSlipModel *model = [[SideSlipModel alloc] init];
- model.containerCellClass = @"OrderSalesSearchTableViewCell";
- model.regionTitle = @"查询条件";
-
- [dataArray addObject:model];
- return [dataArray mutableCopy];
- }
- #pragma mark - 代理函数
- /**
- Sections
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 头高
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 10;
- }
- /**
- 列表个数
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return _arrModels.count;
- }
- /**
- 行高
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 235;
- }
- /**
- cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *CellIdentifier = @"OrderSalesTableViewCell";
- OrderSalesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (!cell) {
- cell = [[OrderSalesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- else
- //当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免
- {
- while ([cell.contentView.subviews lastObject] != nil) {
- [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
- }
- }
- // 单元格ui布局
- OrderSaleListModel *model=_arrModels[indexPath.row];
- [cell parseOrderSalesInfo:model];
-
- return cell;
- }
- /**
- 单元格点击事件
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- self.hidesBottomBarWhenPushed=YES;
- OrderSalesDetailViewController *detailvc = [[OrderSalesDetailViewController alloc] init];
- OrderSaleListModel *m = _arrModels[indexPath.row];
- detailvc.invoiceNo = m.invoiceNo;
- [self.navigationController pushViewController:detailvc animated:YES];
- }
- #pragma mark - 私有函数
- /**
- 初始化ui
- */
- - (void)initUI{
- self.navigationItem.title = @"订单销售单列表";
- self.view.backgroundColor = [UIColor whiteColor];
- _vCustomTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height )];
- _vCustomTableView.rowHeight = UITableViewAutomaticDimension;
- _vCustomTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _vCustomTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vCustomTableView.backgroundColor = [UIColor whiteColor];
- _vCustomTableView.delegate = self;
- _vCustomTableView.dataSource=self;
- [self.view addSubview:_vCustomTableView];
-
-
- }
- -(void)initHeadView:(NSString*)invoiceType
- {
- // 合计
- _headView = [[UIView alloc]initWithFrame:CGRectZero];
- CGFloat lblx = 20;
- CGFloat lblwidth = 130;
- CGFloat valuey = 10;
- CGFloat valuewidth = 200;
- CGFloat valueheight = 25;
- CGFloat heightLine =1;
- UILabel *lbtotal = [UILabel new];
- lbtotal.frame=CGRectMake(lblx, valuey, lblwidth, valueheight);
- lbtotal.font = reportTextFont;
- lbtotal.text = @"合计";
- [_headView addSubview:lbtotal];
- UIView *topSeparator = [UIView new];
- topSeparator.frame = CGRectMake(0, CGRectGetMaxY(lbtotal.frame)+valuey, Screen_Width, heightLine);
- topSeparator.backgroundColor = LineBackgroundColor;
- [_headView addSubview:topSeparator];
- UIImageView *goodsimgview = [UIImageView new];
- UIImage *goodsImg= [UIImage imageNamed:@"goods_amount"];
- goodsimgview.frame=CGRectMake(lblx,CGRectGetMaxY(topSeparator.frame)+valuey,goodsImg.size.width,goodsImg.size.height);
- [goodsimgview setImage:goodsImg];
- [_headView addSubview:goodsimgview];
-
- //货款总额
- UILabel *lblTitleGoodsAmount = [UILabel new];
- lblTitleGoodsAmount.frame=CGRectMake(CGRectGetMaxX(goodsimgview.frame)+5, CGRectGetMaxY(topSeparator.frame)+valuey-3, lblwidth, valueheight);
- lblTitleGoodsAmount.font = reportTextFont;
- lblTitleGoodsAmount.text = @"货款总额";
- [_headView addSubview:lblTitleGoodsAmount];
- _lblGoodsAmount = [UILabel new];
- _lblGoodsAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(topSeparator.frame)+valuey-3, valuewidth, valueheight);
- _lblGoodsAmount.font = reportTextFont;
- _lblGoodsAmount.textAlignment = NSTextAlignmentRight;
- [_headView addSubview:_lblGoodsAmount];
-
- UIView *goodsSeparator = [UIView new];
- goodsSeparator.frame = CGRectMake(CGRectGetMaxX(goodsimgview.frame)+5, CGRectGetMaxY(goodsimgview.frame)+valuey, Screen_Width, heightLine);
- goodsSeparator.backgroundColor = LineBackgroundColor;
- [_headView addSubview:goodsSeparator];
-
- UIImageView *discountimgview = [UIImageView new];
- UIImage *discountAmountImg= [UIImage imageNamed:@"discount_amount"];
- discountimgview.frame=CGRectMake(lblx,CGRectGetMaxY(goodsSeparator.frame)+valuey,discountAmountImg.size.width,discountAmountImg.size.height);
- [discountimgview setImage:discountAmountImg];
- [_headView addSubview:discountimgview];
-
- // 舍零金额
- UILabel *lblTitleDiscountAmount = [UILabel new];
- lblTitleDiscountAmount.frame=CGRectMake(CGRectGetMaxX(discountimgview.frame)+5, CGRectGetMaxY(goodsSeparator.frame)+valuey, lblwidth, valueheight);
- lblTitleDiscountAmount.font = reportTextFont;
- lblTitleDiscountAmount.text = @"舍零金额";
- [_headView addSubview:lblTitleDiscountAmount];
-
- _lblDiscountAmount = [UILabel new];
- _lblDiscountAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(goodsSeparator.frame)+valuey, valuewidth, valueheight);
- _lblDiscountAmount.font = reportTextFont;
- _lblDiscountAmount.textAlignment = NSTextAlignmentRight;
- [_headView addSubview:_lblDiscountAmount];
-
- UIView *discountSeparator = [UIView new];
- discountSeparator.frame = CGRectMake(CGRectGetMaxX(discountimgview.frame)+5, CGRectGetMaxY(discountimgview.frame)+valuey, Screen_Width, heightLine);
- discountSeparator.backgroundColor = LineBackgroundColor;
- [_headView addSubview:discountSeparator];
-
- //合计金额
- UIImageView *totalimgview = [UIImageView new];
- UIImage *totalImg= [UIImage imageNamed:@"total_amount"];
- totalimgview.frame=CGRectMake(lblx,CGRectGetMaxY(discountSeparator.frame)+valuey,totalImg.size.width,totalImg.size.height);
- [totalimgview setImage:totalImg];
- [_headView addSubview:totalimgview];
- UILabel *lblTitleTotalAmount = [UILabel new];
- lblTitleTotalAmount.frame=CGRectMake(CGRectGetMaxX(totalimgview.frame)+5, CGRectGetMaxY(discountSeparator.frame)+valuey-3, lblwidth, valueheight);
- lblTitleTotalAmount.font = reportTextFont;
- lblTitleTotalAmount.text = @"合计金额";
- [_headView addSubview:lblTitleTotalAmount];
- _lblTotalAmount = [UILabel new];
- _lblTotalAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(discountSeparator.frame)+valuey-3, valuewidth, valueheight);
- _lblTotalAmount.font = reportTextFont;
- _lblTotalAmount.textAlignment = NSTextAlignmentRight;
- [_headView addSubview:_lblTotalAmount];
-
-
-
- if([invoiceType isEqualToString:@"2"]||[invoiceType isEqualToString:@"0"]){
- UIView *totalSeparator = [UIView new];
- totalSeparator.frame = CGRectMake(CGRectGetMaxX(totalimgview.frame)+5, CGRectGetMaxY(totalimgview.frame)+valuey, Screen_Width, heightLine);
- totalSeparator.backgroundColor = LineBackgroundColor;
- [_headView addSubview:totalSeparator];
- //出库额
- UIImageView *outamountimgview = [UIImageView new];
- UIImage *outAmountImg= [UIImage imageNamed:@"outamount"];
- outamountimgview.frame=CGRectMake(lblx,CGRectGetMaxY(totalSeparator.frame)+valuey,outAmountImg.size.width,outAmountImg.size.height);
- [outamountimgview setImage:outAmountImg];
- [_headView addSubview:outamountimgview];
- UILabel *lblTitleOutAmount = [UILabel new];
-
- lblTitleOutAmount.frame=CGRectMake(CGRectGetMaxX(outamountimgview.frame)+5, CGRectGetMaxY(totalSeparator.frame)+valuey-3, lblwidth, valueheight);
- lblTitleOutAmount.font = reportTextFont;
- lblTitleOutAmount.text = @"出库金额";
- [_headView addSubview:lblTitleOutAmount];
- _lblOutAmount = [UILabel new];
- _lblOutAmount.frame=CGRectMake(Screen_Width - valuewidth - lblx, CGRectGetMaxY(totalSeparator.frame)+valuey-3, valuewidth, valueheight);
- _lblOutAmount.font = reportTextFont;
- _lblOutAmount.textAlignment = NSTextAlignmentRight;
- [_headView addSubview:_lblOutAmount];
-
-
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_lblOutAmount.frame)+5, SCREENWIDTH, 10)];
- line.backgroundColor = LineBackgroundColor;
- [_headView addSubview:line];
- _headView.frame=CGRectMake(0,0, Screen_Width, CGRectGetMaxY(line.frame));
- }
-
- else{
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_lblTotalAmount.frame)+5, SCREENWIDTH, 10)];
- line.backgroundColor = LineBackgroundColor;
- [_headView addSubview:line];
- _headView.frame=CGRectMake(0,0, Screen_Width, CGRectGetMaxY(line.frame));
- }
-
-
- }
- /**
- 导航菜单
- */
- - (void)loadNavStyle
- {
- // 右边
- UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 42, 12)];
-
- UIButton *btnfilter = [UIButton buttonWithType:UIButtonTypeCustom];
- [btnfilter addTarget:self action:@selector(search)
- forControlEvents:UIControlEventTouchUpInside];
- btnfilter.frame = CGRectMake(0, 0,16, 16);
- [btnfilter setTitleColor:NavBarItemColor forState:UIControlStateNormal];
- [btnfilter setBackgroundImage:[UIImage imageNamed:@"icon_filter_white"]
- forState:UIControlStateNormal];
- [v addSubview:btnfilter];
- UIButton *filterLbl = [[UIButton alloc]init];
- filterLbl.frame=CGRectMake(CGRectGetMaxX(btnfilter.frame)+3,0,28, 16);
- [filterLbl setTitle:@"筛选" forState:UIControlStateNormal];
- [filterLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- filterLbl.titleLabel.font = [UIFont systemFontOfSize:ButtonFontOfSize];
- [filterLbl addTarget:self action:@selector(search)
- forControlEvents:UIControlEventTouchUpInside];
- [v addSubview:filterLbl];
- UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:v];
- self.navigationItem.rightBarButtonItem = menubtnAdd;
-
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- }
- /**
- 抽屉弹出
- */
- - (void)search{
- [_filterController show];
- }
- /**
- 头数据
-
- @param md md description
- */
- - (void)initUIData:(OrderSaleTotalModel *)model{
- _lblGoodsAmount.text = [NSString stringWithFormat:@"¥%@",model.goodsAmount];
- _lblDiscountAmount.text = [NSString stringWithFormat:@"¥%@",model.discountAmount];
- _lblTotalAmount.text = [NSString stringWithFormat:@"¥%@",model.totalAmount];
- if([model.invoiceType isEqualToString:@"2"]||[model.invoiceType isEqualToString:@"0"]){
- _lblOutAmount.text = [NSString stringWithFormat:@"¥%@",model.outAmount];
- }
- // 加载数据
- [self loadDetailData];
- }
- /**
- 加载数据
- */
- - (void)loadDetailData{
- [self startLoading];
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetOrderSalesReportListIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- // 参数
- if(_mStartDate == nil){
- [dict setObject:@"" forKeyedSubscript:@"BeginTime"];
- }
- else{
- [dict setObject:_mStartDate forKeyedSubscript:@"BeginTime"];
- }
-
- if(_mEndDate == nil){
- [dict setObject:@"" forKeyedSubscript:@"EndTime"];
- }
- else{
- [dict setObject:_mEndDate forKeyedSubscript:@"EndTime"];
- }
-
- if(_mCustomerAddress==nil){
- [dict setObject:@"" forKeyedSubscript:@"Address"];
- }
- else{
- [dict setObject:_mCustomerAddress forKeyedSubscript:@"Address"];
- }
-
- if(_mCustomerName == nil){
- [dict setObject:@"" forKeyedSubscript:@"CustomerName"];
- }
- else{
- [dict setObject:_mCustomerName forKeyedSubscript:@"CustomerName"];
- }
-
- if(_mOrganizationCode == nil){
- [dict setObject:@"" forKeyedSubscript:@"OrganizationCode"];
- }
- else{
- [dict setObject:_mOrganizationCode forKeyedSubscript:@"OrganizationCode"];
- }
-
- if(_mInvoiceType == nil){
- [dict setObject:@"0" forKeyedSubscript:@"InvoiceType"];
- }
- else{
- [dict setObject:_mInvoiceType forKeyedSubscript:@"InvoiceType"];
- }
-
- if(_mTelephone == nil){
- [dict setObject:@"" forKeyedSubscript:@"Telephone"];
-
- }
- else{
- [dict setObject:_mTelephone forKeyedSubscript:@"Telephone"];
- }
- if (_staffId == nil) {
- [dict setObject:@"" forKeyedSubscript:@"staffID"];
- }else{
- [dict setObject:_staffId forKeyedSubscript:@"staffID"];
- }
-
- [dict setObject:@"1" forKeyedSubscript:@"IsTotalFlg"];
- int correctStatus;
-
- if (_correctStatus) {
- correctStatus=1;
- }
- else{
- correctStatus=0;
- }
- [dict setObject:[NSString stringWithFormat:@"%@",_correctStatus] forKeyedSubscript:@"Status"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadDetailFinish:);
- _downManager.onRequestFail = @selector(onLoadDetailFail:);
- [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- /**
- 加载合集数据
- */
- - (void)reloadData
- {
- [self startLoading];
- NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetOrderSalesReportTotalIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- if(_mOrganizationCode == nil){
- [dict setObject:@"" forKeyedSubscript:@"OrganizationCode"];
- }else{
- [dict setObject:_mOrganizationCode forKeyedSubscript:@"OrganizationCode"];
- }
- if(_mStartDate == nil){
- [dict setObject:@"" forKeyedSubscript:@"BeginTime"];
- }
- else{
- [dict setObject:_mStartDate forKeyedSubscript:@"BeginTime"];
- }
-
- if(_mEndDate == nil){
- [dict setObject:@"" forKeyedSubscript:@"EndTime"];
- }
- else{
- [dict setObject:_mEndDate forKeyedSubscript:@"EndTime"];
- }
- if(_mTelephone == nil){
- [dict setObject:@"" forKeyedSubscript:@"Telephone"];
-
- }
- else{
- [dict setObject:_mTelephone forKeyedSubscript:@"Telephone"];
- }
-
- if(_mInvoiceType == nil){
- [dict setObject:@"0" forKeyedSubscript:@"InvoiceType"];
- }
- else{
- [dict setObject:_mInvoiceType forKeyedSubscript:@"InvoiceType"];
- }
- if(_mCustomerName == nil){
- [dict setObject:@"" forKeyedSubscript:@"CustomerName"];
- }
- else{
- [dict setObject:_mCustomerName forKeyedSubscript:@"CustomerName"];
- }
- if(_mCustomerAddress == nil){
- [dict setObject:@"" forKeyedSubscript:@"Address"];
- }
- else{
- [dict setObject:_mCustomerAddress forKeyedSubscript:@"Address"];
- }
- if (_staffId == nil) {
- [dict setObject:@"" forKey:@"staffID"];
- }else{
- [dict setObject:_staffId forKey:@"staffID"];
- }
-
- [dict setObject:@"0" forKeyedSubscript:@"IsTotalFlg"];
-
- [dict setObject:[NSString stringWithFormat:@"%@",_correctStatus] forKeyedSubscript:@"Status"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onLoadFinish:);
- _downManager.onRequestFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
- }
- #pragma mark - 代理函数
- /**
- * 查询正常数据
- *
- * @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
- // 取消进度条
- [self cancel];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- // 服务器返回数据状态值正确
- if (iStatus == 0)
- {
- _vCustomTableView.tableHeaderView = nil;
- _vCustomTableView.backgroundView= nil;
- NSArray * approvArr = (NSArray *)resultModel.result;
- // 是否有数据
- if(approvArr != nil && approvArr.count > 0)
- {
- [_arrStock removeAllObjects];
- _vCustomTableView.tableHeaderView = nil;
- [_arrStock addObjectsFromArray:approvArr];
- [_arrModels removeAllObjects];
- [_vCustomTableView reloadData];
- NSDictionary *dic;
- if(_arrStock.count==1){
- dic =_arrStock[0];
- }
- else if(_arrStock.count>1){
- dic =_arrStock[1];
- }
-
- NSInteger recount = [[dic objectForKey:@"RecCount"]integerValue];
- // 是否有数据
- if(recount > 0){
-
- OrderSaleTotalModel *md = [OrderSaleTotalModel orderSaleWithDict:dic];
- [self initHeadView:md.invoiceType];
- _vCustomTableView.tableHeaderView=_headView;
- [self initUIData:md];
- }
- else{
- // 无数据的view
- UIView *noDataView = [self noDataViewByFrame:_vCustomTableView.bounds];
- _vCustomTableView.backgroundView=noDataView;
- [self showAlertViewText:@"未找到匹配结果"];
- return;
- }
- }
- }
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
- [self showReLoginDialog:message];
- return;
- }
-
- else {
- [_arrModels removeAllObjects];
- [_vCustomTableView reloadData];
- [self showAlertViewText:message];
- }
- }
- /**
- * 异常数据
- *
- * @param sender <#sender description#>
- */
- - (void)onLoadFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- * 列表数据
- *
- * @param sender <#sender description#>
- */
- - (void)onLoadDetailFinish:(ASIDownManager *)sender {
-
- // 取消进度条
- [self cancel];
- // 服务器返回数据
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- // 服务器返回数据状态值
- int iStatus = resultModel.status;
- // 服务器返回数据消息
- NSString *message = resultModel.message;
- // 服务器返回数据状态值正确
- if (iStatus == 0)
- {
- // 返回结果
- NSArray * approvArr = (NSArray *)resultModel.result;
- if(approvArr != nil)
- {
- [_arrModels removeAllObjects];
- if(approvArr.count == 0){
- [self showAlertViewText:@"未找到匹配结果"];
- }
- else
- {
- NSMutableArray *arr = [NSMutableArray array];
- for (NSDictionary *dic in approvArr)
- {
- OrderSaleListModel *md = [OrderSaleListModel orderSaleDetailWithDict:dic];
- [arr addObject:md];
- }
- _arrModels = arr;
- [_vCustomTableView reloadData];
-
- }
- }
- }
- // 服务器返回数据状态值异常
- else if(iStatus == ActionResultStatusAuthError
- ||iStatus == ActionResultStatusNoLogin
- ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue)
- {
- [self showReLoginDialog:message];
- return;
- }
- else
- {
- [self showAlertViewText:message];
- }
- }
- /**
- 加载失败
-
- @param sender <#sender description#>
- */
- - (void)onLoadDetailFail:(ASIDownManager *)sender {
- [self cancel];
- [self showAlertViewText:@"网络异常"];
- }
- /**
- * 隐藏进度条
- */
- - (void)cancel {
- [self stopLoading];
- }
- @end
|