Commit a8d95938 authored by Sandy's avatar Sandy

销售录入对账单附件查看、

parent e3151944
This diff is collapsed.
//
// CalculateHelper.h
// XFFruit
//
// Created by Z on 16/7/14.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, CalculateType) {
CalculateTypeAdd = 0, //加
CalculateTypeSub, //减
CalculateTypeMul, //乘
CalculateTypeDiv //除
};
@interface CalculateHelper : NSObject
/*
NSRoundPlain, // Round up on a tie //貌似取整
NSRoundDown, // Always down == truncate //只舍不入
NSRoundUp, // Always up // 只入不舍
NSRoundBankers // on a tie round so last digit is even 貌似四舍五入
*/
/**
* 计算
*
* @param num1 第一个数字
* @param num2 第二个数字
* @param type 计算类型(加减乘除)
* @param roundingType 四舍五入类型
* @param coutLenth 小数点后面保留几位
*
* @return 结算结果
*/
+ (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type roundingType:(NSRoundingMode)roundingType cutLenth:(NSInteger)coutLenth;
/** 一百倍 */
+ (NSDecimalNumber *)oneHundredTimes:(id)num;
@end
//
// CalculateHelper.m
// XFFruit
//
// Created by Z on 16/7/14.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import "CalculateHelper.h"
@implementation CalculateHelper
+ (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type roundingType:(NSRoundingMode)roundingType cutLenth:(NSInteger)coutLenth {
NSDecimalNumberHandler *roundUp = [NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode:roundingType
scale:coutLenth
raiseOnExactness:NO
raiseOnOverflow:NO
raiseOnUnderflow:NO
raiseOnDivideByZero:YES];
NSDecimalNumber *decimalNum1 = [self changeType:num1];
NSDecimalNumber *decimalNum2 = [self changeType:num2];
if (decimalNum1 == nil || decimalNum2 == nil) {
return nil;
}
NSDecimalNumber *decimalResult;
NSString *result;
switch (type) {
case CalculateTypeAdd: {
decimalResult = [decimalNum1 decimalNumberByAdding:decimalNum2 withBehavior:roundUp];
result = [decimalResult stringValue];
break;
}
case CalculateTypeSub: {
decimalResult = [decimalNum1 decimalNumberBySubtracting:decimalNum2 withBehavior:roundUp];
result = [decimalResult stringValue];
break;
}
case CalculateTypeMul: {
decimalResult = [decimalNum1 decimalNumberByMultiplyingBy:decimalNum2 withBehavior:roundUp];
result = [decimalResult stringValue];
break;
}
case CalculateTypeDiv: {
decimalResult = [decimalNum1 decimalNumberByDividingBy:decimalNum2 withBehavior:roundUp];
result = [decimalResult stringValue];
break;
}
}
return decimalResult;
}
+ (NSDecimalNumber *)changeType:(id)num1 {
NSDecimalNumber *decimalNum1;
if ([num1 isKindOfClass:[NSDecimalNumber class]]) {
decimalNum1 = num1;
}else if([num1 isKindOfClass:[NSString class]]){
decimalNum1 = [NSDecimalNumber decimalNumberWithString:num1];
}else if ([num1 isKindOfClass:[NSNumber class]]){
decimalNum1 = [NSDecimalNumber decimalNumberWithDecimal:[num1 decimalValue]];
}else{
return nil;
}
return decimalNum1;
}
+ (NSDecimalNumber *)oneHundredTimes:(id)num {
return [self calculateNum1:num num2:@100 type:CalculateTypeMul roundingType:NSRoundBankers cutLenth:10];
}
@end
......@@ -114,7 +114,8 @@
@see timeInWordsIncludingSeconds:
*/
+ (NSString *)timeInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds includingSeconds:(BOOL)includeSeconds;
/** 该日期是该年的第几周 */
- (NSInteger)getWeekOfYear;
@end
@interface NSDate (DateFormatterAdditions)
......
......@@ -360,6 +360,54 @@
return [[self class] timeInWordsFromTimeInterval:fabs([self timeIntervalSinceNow]) includingSeconds:includeSeconds];
}
/** 该日期是该年的第几周 */
- (NSInteger)getWeekOfYear
{
NSInteger i;
NSInteger year = [self getYear];
NSDate *date = [self endOfWeek];
for (i = 1;[[date dateAfterDay:-7 * i] getYear] == year;i++)
{
}
return i;
}
//获取年
- (NSUInteger)getYear
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dayComponents = [calendar components:(NSYearCalendarUnit) fromDate:self];
return [dayComponents year];
}
//返回当前周的周末
- (NSDate *)endOfWeek {
NSCalendar *calendar = [NSCalendar currentCalendar];
// Get the weekday component of the current date
NSDateComponents *weekdayComponents = [calendar components:NSWeekdayCalendarUnit fromDate:self];
NSDateComponents *componentsToAdd = [[NSDateComponents alloc] init];
// to get the end of week for a particular date, add (7 - weekday) days
[componentsToAdd setDay:(7 - [weekdayComponents weekday])];
NSDate *endOfWeek = [calendar dateByAddingComponents:componentsToAdd toDate:self options:0];
// [componentsToAdd release];
return endOfWeek;
}
//返回day天后的日期(若day为负数,则为|day|天前的日期)
- (NSDate *)dateAfterDay:(NSInteger)day
{
NSCalendar *calendar = [NSCalendar currentCalendar];
// Get the weekday component of the current date
// NSDateComponents *weekdayComponents = [calendar components:NSWeekdayCalendarUnit fromDate:self];
NSDateComponents *componentsToAdd = [[NSDateComponents alloc] init];
// to get the end of week for a particular date, add (7 - weekday) days
[componentsToAdd setDay:day];
NSDate *dateAfterDay = [calendar dateByAddingComponents:componentsToAdd toDate:self options:0];
return dateAfterDay;
}
@end
@implementation NSDate (DateFormatterAdditions)
......
......@@ -13,7 +13,7 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
kAttachmentBoard = 0,
kAttachmentAnswer,
kAttachmentTask,
kAttachmentSaleInput,
// Insert enum here
kAttachmentTypeCount,
};
......
......@@ -124,6 +124,7 @@ static NSString * const ICRHTTPInterface[] = {
static NSString * const ICRAttachmentTypeValue[] = {
[ kAttachmentBoard ] = @"board",
[ kAttachmentAnswer ] = @"answer",
[ kAttachmentSaleInput ] = @"salesInput",
[ kAttachmentTask ] = @"task",
};
......
......@@ -15,9 +15,11 @@
#import "IBTCustomButtom.h"
#import "VankeCommonModel.h"
#import "ICRHTTPController.h"
#import "VankeConfig.h"
#define KNOTIFICATION_GetNextDetailData @"KNOTIFICATION_GetNextDetailData"
#define KNOTIFICATION_GoReportDetail @"KNOTIFICATION_GoReportDetail"
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self
#define HexColor(colorStr) [UIColor colorWithHexString:colorStr]
#define GXF_NAVIGAYION_COLOR HexColor(@"7ebf74")
......@@ -29,6 +31,8 @@
#define GXF_LINE_COLOR HexColor(@"e5e5e5")
#define GXF_DETAIL_COLOR HexColor(@"888888")
#define GXF_LEFTSIX_COLOR HexColor(@"666666")
#define kMainBlueColor [UIColor colorWithRed:0.278 green:0.561 blue:0.945 alpha:1.000]
//报表统一颜色
#define ReportColor GXF_NAVIGAYION_COLOR
#define ReportContentColor HexColor(@"f4422e")
......@@ -67,6 +71,9 @@
#define GXF_SIXTEENTEH_SIZE FontSize(16)
#define GXF_SEVENTEENTH_SIZE FontSize(17)
//查看报表
#define REPORT_TYPE_FLOOR @"floor" //楼层销售
#define REPORT_TYPE_BIZ @"biz" //业态销售
/*
* Clog
*/
......
......@@ -9,6 +9,8 @@
#import "IBTModel.h"
@interface Compass : IBTModel
@property (nonatomic,strong)NSString *dataScopeType;
// 统计时间类型 否 String 100 day(日),week(周),month(月)
@property (nonatomic,strong)NSString *dataScope;
......@@ -75,4 +77,31 @@
//毛利率同比增减率 是 Double
@property (nonatomic , assign) BOOL expand;//该节点是否处于展开状态
@property (nonatomic , assign) BOOL isLeaf;
@property (nonatomic, copy) NSString *create_time;
/** 坪效 */
@property (nonatomic, strong) NSNumber * groundEffect;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *lastModify_operName;
@property (nonatomic, strong) NSNumber * version;
@property (nonatomic, copy) NSString *dateScopeType;
/** 销售同比历史数值 */
@property (nonatomic, strong) NSNumber * salesYoY;
@property (nonatomic, copy) NSString *create_operName;
@property (nonatomic, copy) NSString *create_id;
@property (nonatomic, copy) NSString *lastModify_time;
/** 销售环比历史数值 */
@property (nonatomic, strong) NSNumber * salesChain;
@property (nonatomic, copy) NSString *enterprise;
@property (nonatomic, copy) NSString *lastModify_id;
@end
......@@ -10,6 +10,7 @@
#import "ReportBoardTableViewCell.h"
#import "ReportViewController.h"
static NSString *const cellId = @"cellId";
@interface ReportBoardsViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *arrTitles;
......@@ -59,18 +60,28 @@ ON_DID_APPEAR( signal )
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
ReportViewController *reportVC = [[ReportViewController alloc] init];
reportVC.hidesBottomBarWhenPushed = YES;
switch (indexPath.row) {
case 0:
{
ReportViewController *reportVC = [[ReportViewController alloc] init];
reportVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:reportVC animated:YES];
reportVC.title = @"楼层销售报表";
reportVC.reportType = REPORT_TYPE_FLOOR;
}
break;
case 1:
{
reportVC.title = @"业态销售报表";
reportVC.reportType = REPORT_TYPE_BIZ;
}
break;
default:
break;
}
[self.navigationController pushViewController:reportVC animated:YES];
}
#pragma mark - tableView dataSource
......
......@@ -9,5 +9,6 @@
#import "ICRBaseViewController.h"
@interface ReportViewController : ICRBaseViewController
@property (nonatomic, copy) NSString *reportType;
@end
......@@ -20,6 +20,7 @@
@interface CustomSegView : UIView
@property (nonatomic,weak)id<CustomSegViewDelegate>delegate;
@property (nonatomic, copy) NSString *currentTitle;
- (instancetype)initWithFrame:(CGRect)frame withArr:(NSArray *)arr;
......
......@@ -32,31 +32,32 @@
- (void)bulidLayout{
_bgView = [[UIView alloc]initWithFrame:self.bounds];
_bgView.layer.borderWidth = 1;
_bgView.layer.borderColor = ReportColor.CGColor;
_bgView.layer.borderColor = kMainBlueColor.CGColor;
_bgView.layer.cornerRadius = 5;
_bgView.layer.masksToBounds = YES;
[self addSubview:_bgView];
_bgView.clipsToBounds = YES;
_currentBtnTag = 0;
self.currentTitle = self.segArr[0];
CLog(@"%f",_bgView.width);
CGFloat width = _bgView.width/self.segArr.count;
for (NSInteger i = 0; i < self.segArr.count; i++) {
IBTCustomButtom *segBtn = [IBTCustomButtom buttonWithType:UIButtonTypeCustom];
segBtn.frame = CGRectMake(width*i, 0, width, _bgView.height);
segBtn.titleLabel.font = GXF_FIFTEENTEN_SIZE;
[segBtn setTitleColor:ReportColor forState:UIControlStateNormal];
[segBtn setTitleColor:kMainBlueColor forState:UIControlStateNormal];
segBtn.tag = BeginBtnTag + i;
[segBtn setTitle:self.segArr[i] forState:UIControlStateNormal];
[segBtn addTarget:self action:@selector(segClick:) forControlEvents:UIControlEventTouchUpInside];
[_bgView addSubview:segBtn];
if (i == 0) {
segBtn.backgroundColor = ReportColor;
segBtn.backgroundColor = kMainBlueColor;
[segBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_currentBtnTag = i+ BeginBtnTag;
}
if (i < self.segArr.count - 1) {
[segBtn addRightBorderWithWidth:1 color:ReportColor];
[segBtn addRightBorderWithWidth:1 color:kMainBlueColor];
}
}
}
......@@ -66,13 +67,14 @@
IBTCustomButtom *beforeBtn = (IBTCustomButtom *)[_bgView viewWithTag:_currentBtnTag];
if ([beforeBtn isKindOfClass:[UIButton class]] && beforeBtn) {
beforeBtn.backgroundColor = RGBA(1, 1, 1, 0);
[beforeBtn setTitleColor:ReportColor forState:UIControlStateNormal];
[beforeBtn setTitleColor:kMainBlueColor forState:UIControlStateNormal];
}
btn.backgroundColor = ReportColor;
btn.backgroundColor = kMainBlueColor;
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_currentBtnTag = btn.tag;
if ([self.delegate respondsToSelector:@selector(customSegOneClick:)]) {
[self.delegate customSegOneClick:btn.titleLabel.text];
self.currentTitle = btn.titleLabel.text;
}
}else{
if ([self.delegate respondsToSelector:@selector(customSegTwoClick:)]) {
......
......@@ -7,6 +7,7 @@
//
#import "RSaleView.h"
#import "CalculateHelper.h"
//#import "SMPageControl.h"
#define LeftWidth 50
#define ImageSize 20
......@@ -168,32 +169,43 @@
//销售额
self.centerLabel.text = compass.sales?[IBTCommon countNumAndChangeformat:[IBTCommon stringDisposeWithFloat:[compass.sales floatValue]]]:@"---" ;
//销售环比变化率
if ([compass.salesChainSign isEqualToString:ReportChainSignPlus]) {
//销售环比变化率 比上周
NSDecimalNumber *saleDifference = [CalculateHelper calculateNum1:compass.sales num2:compass.salesChain type:CalculateTypeSub roundingType:NSRoundBankers cutLenth:4];
NSDecimalNumber *decimalSaleRate = [CalculateHelper calculateNum1:saleDifference num2:compass.salesChain type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:4];
decimalSaleRate = [CalculateHelper oneHundredTimes:decimalSaleRate];
NSString *salesChainRateStr = decimalSaleRate?[NSString stringWithFormat:@"%@%%", [decimalSaleRate stringValue]]:@"---";
if (![salesChainRateStr hasPrefix:@"-"] && ![salesChainRateStr isEqualToString:@"0"] && ![salesChainRateStr hasPrefix:@"--"]) {
[self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
[self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
}else if ([compass.salesChainSign isEqualToString:ReportChainSignMinus]){
}else if ([salesChainRateStr hasPrefix:@"-"] && ![salesChainRateStr isEqualToString:@"0"] && ![salesChainRateStr hasPrefix:@"--"]){
[self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateNormal];
[self.lastWeekLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateNormal];
}
NSString *salesChainRateStr = compass.salesChainRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.salesChainRate floatValue]]]:@"---";
[self.lastWeekLabel setTitle:salesChainRateStr forState:UIControlStateNormal];
//销售同比变化率
if ([compass.salesYoYSign isEqualToString:ReportChainSignPlus]) {
//销售同比变化率 比上年
NSDecimalNumber *decimalSalesYoYDifference = [CalculateHelper calculateNum1:compass.sales num2:compass.salesYoY type:CalculateTypeSub roundingType:NSRoundBankers cutLenth:4];
NSDecimalNumber *decimalSalesYoY = [CalculateHelper calculateNum1:decimalSalesYoYDifference num2:compass.salesYoY type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:4];
decimalSalesYoY = [CalculateHelper oneHundredTimes:decimalSalesYoY];
NSString *salesYoStr = decimalSalesYoY?[NSString stringWithFormat:@"%@%%",[decimalSalesYoY stringValue ]]:@"---";
if (![salesYoStr hasPrefix:@"-"] && ![salesYoStr isEqualToString:@"0"] && ![salesYoStr hasPrefix:@"--"]) {
[self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
[self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
}else if ([compass.salesYoYSign isEqualToString:ReportChainSignMinus]){
}else if ([salesYoStr hasPrefix:@"-"] && ![salesYoStr isEqualToString:@"0"] && ![salesYoStr hasPrefix:@"--"]){
[self.lastYearLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateNormal];
[self.lastYearLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateNormal];
}
NSString *salesYoStr = compass.salesYoYRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.salesYoYRate floatValue]]]:@"---";
[self.lastYearLabel setTitle:salesYoStr forState:UIControlStateNormal];
//销售目标达成率
NSString *salesTargetStr = compass.salesTargetRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.salesTargetRate floatValue]]]:@"---";
self.rateLabel.text = salesTargetStr;
//单店日均销售
NSString *dailysalesPerStr = compass.dailysalesPerStore?[NSString stringWithFormat:@"%@",[IBTCommon stringDisposeWithFloat:[compass.dailysalesPerStore floatValue]]]:@"---";
self.averageLabel.text = dailysalesPerStr;
// //单店日均销售
// NSString *dailysalesPerStr = compass.dailysalesPerStore?[NSString stringWithFormat:@"%@",[IBTCommon stringDisposeWithFloat:[compass.dailysalesPerStore floatValue]]]:@"---";
// self.averageLabel.text = dailysalesPerStr;
}
......
......@@ -49,14 +49,14 @@
//右侧共几家 jv
rect = CGRectMake(10, 0, 90, Sale_Header_Height);
rect = CGRectMake(10, 0, 110, Sale_Header_Height);
UILabel *searLabel = [IBTCommon labelWithTitle:@"共280家" frame:rect textFont:self.textFont];
searLabel.textColor = ReportTitleColor;
[self.contentView addSubview:searLabel];
searLabel.alpha = 0;
self.totalLabel = searLabel;
CGFloat width = (SCREEN_WIDTH - searLabel.right - 15)/4;
CGFloat width = (SCREEN_WIDTH - searLabel.right - 4)/4;
rect = CGRectMake(searLabel.right, 0, width, Sale_Header_Height);
UILabel * xsBtn = [IBTCommon labelWithTitle:@"销售额" frame:rect textFont:self.textFont];
......
......@@ -9,7 +9,7 @@
#import "SaleViewCell.h"
#define Sale_Cell_Height 50
#define Left_Width 95
#define Left_Width 120
#define Left_margin 5
@interface SaleViewCell ()
{
......@@ -68,7 +68,7 @@
self.dqLabel = [IBTCommon labelWithTitle:@"0101" frame:rect textFont:self.textFont];
[self.contentView addSubview:self.dqLabel];
CGFloat width = (SCREEN_WIDTH - self.dqLabel.right - 15)/4;
CGFloat width = (SCREEN_WIDTH - self.dqLabel.right - 4)/4;
rect = CGRectMake(self.dqLabel.right , 0, width, Sale_Cell_Height);
self.saleLabel = [IBTCommon labelWithTitle:@"56,080" frame:rect textFont:self.textFont];
......@@ -138,9 +138,14 @@
NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[sale.salesChainRate floatValue]]];
[self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];
//坪效
NSString *salesTargetRateStr = [NSString stringWithFormat:@"%@",[IBTCommon stringDisposeWithFloat:[sale.salesTargetRate floatValue]]];
NSString *salesTargetRateStr = [NSString stringWithFormat:@"%@",[IBTCommon stringDisposeWithFloat:[sale.groundEffect floatValue]]];
self.rateLabel.text = salesTargetRateStr;
//日均销售
self.dailySaleLabel.text = [NSString stringWithFormat:@"%@", [sale.dailysalesPerStore stringValue]];
[self setColorAndFont:sale.level];
}
- (void)setColorAndFont:(NSInteger)level{
if (level == 99) {
......
//
// GalleryViewController.h
// vanke
//
// Created by Z on 16/7/18.
// Copyright © 2016年 gomore. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface GalleryViewController : UIViewController
@property (nonatomic, strong) NSMutableArray *arrData;
@property (nonatomic, assign) NSInteger page;
@end
//
// GalleryViewController.m
// vanke
//
// Created by Z on 16/7/18.
// Copyright © 2016年 gomore. All rights reserved.
//
#import "GalleryViewController.h"
#import "GalleryCollectionViewCell.h"
#import "AttachmentModel.h"
@interface GalleryViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout;
@end
@implementation GalleryViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);
self.flowLayout.minimumLineSpacing = 0;
self.flowLayout.minimumInteritemSpacing = 0;
self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
// Do any additional setup after loading the view.
}
- (void)viewDidLayoutSubviews {
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.page inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.arrData.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
GalleryCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GalleryCollectionViewCell" forIndexPath:indexPath];
AttachmentModel *model = self.arrData[indexPath.row];
[cell setUpCellWithModel:model];
// Configure the cell
self.title = [NSString stringWithFormat:@"(%ld/%.0lu)", indexPath.row + 1, (unsigned long)self.arrData.count];
return cell;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
self.title = [NSString stringWithFormat:@"(%.0f/%.0lu)", scrollView.contentOffset.x / SCREEN_WIDTH + 1, (unsigned long)self.arrData.count];
}
- (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
......@@ -12,7 +12,7 @@
#import "VankeConfig.h"
#import "ICRAppMacro.h"
#import "ChooseShopViewController.h"
#import "SaleInputPicCollectionViewController.h"
#define klineCount 19 //列数
#define kListWidth 100 //一个表格的宽度
......@@ -24,6 +24,8 @@
@property (nonatomic, strong) NSArray *bottomTitles;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) HistoryTopView *topView;
@property (nonatomic, strong) NSArray *arrRecords;
@end
@implementation HistoryViewController
......@@ -88,7 +90,10 @@
label.text = array[i][j];
[self.scrollView insertSubview:label atIndex:0];//防止前面的别挡住
label.backgroundColor = [UIColor colorWithRed:1.000 green:0.976 blue:0.953 alpha:1.000];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
label.userInteractionEnabled = YES;
[label addGestureRecognizer:tap];
label.tag = j - 1;
if (i == 0) {
label.tag = 3000 + j;
}else if(i == 1){//金额
......@@ -135,6 +140,22 @@
}
}
- (void)tap:(UITapGestureRecognizer *)tap {
CLog(@"%d",tap.view.tag);
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"SalesInPut" bundle:nil];
SaleInputPicCollectionViewController *picVC = [storyBoard instantiateViewControllerWithIdentifier:@"SaleInputPicCollectionViewController"];
NSInteger row ;
if (tap.view.tag > 2999) {
row = tap.view.tag - 3001;
}else{
row = tap.view.tag;
}
picVC.attachmentUuid = self.arrRecords[row][@"attachmentUuid"];
[self.navigationController pushViewController:picVC animated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
......@@ -253,18 +274,18 @@
@"endDateEquals" : self.topView.endDate.text,
@"pageNumber" : @0,
@"pageSize" : @0};
CLog(@"》》%@",params.JSONString);
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController];
[httpCtrl getUrl:@"salesinput/query" params:params success:^(id data) {
NSDictionary *dic = data;
CLog(@"》》%@",dic.JSONString);
NSMutableArray *arrData = [NSMutableArray array];
NSMutableArray *arrDate = [NSMutableArray array];//日期
[arrDate addObject:@"日期"];
NSMutableArray *arrAmount = [NSMutableArray array];//金额
[arrAmount addObject:@"金额(元)"];
weakSelf.arrRecords = dic[@"data"][@"records"];
NSMutableArray *payment = [NSMutableArray array];
for (NSDictionary *obj in dic[@"data"][@"records"]) {
[arrDate addObject:obj[@"salesDate"]];
......
//
// SaleInputPicCollectionViewController.h
// vanke
//
// Created by Z on 16/7/17.
// Copyright © 2016年 gomore. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SaleInputPicCollectionViewController : UICollectionViewController
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, copy) NSString *attachmentUuid;
@end
//
// SaleInputPicCollectionViewController.m
// vanke
//
// Created by Z on 16/7/17.
// Copyright © 2016年 gomore. All rights reserved.
//
#import "SaleInputPicCollectionViewController.h"
#import "SaleInputPicCollectionViewCell.h"
#import "ICRHTTPController.h"
#import "AttachmentModel.h"
#import "GalleryViewController.h"
@interface SaleInputPicCollectionViewController ()
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout;
@end
@implementation SaleInputPicCollectionViewController
static NSString * const reuseIdentifier = @"saleInputCollection";
- (void)viewDidLoad {
[super viewDidLoad];
self.flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 20) / 3, 110.0 / 375 * SCREEN_WIDTH);
self.flowLayout.minimumLineSpacing = 5;
self.flowLayout.minimumInteritemSpacing = 5;
[self setUpData];
}
- (void)setUpData {
NSString *url = [NSString stringWithFormat:@"attachment/get_urls?entity_type=salesInput&entity_uuid=%@",self.attachmentUuid];
__weak typeof(self)weakSelf = self;
[[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) {
NSDictionary *dic = data;
CLog(@"%@", dic.JSONString);
for (NSDictionary *dict in data[@"data"]) {
AttachmentModel *model = [[AttachmentModel alloc] init];
[model setValuesForKeysWithDictionary:dict];
[weakSelf.dataArr addObject:model];
}
[weakSelf.collectionView reloadData];
} failure:^(id data) {
}];
}
- (NSMutableArray *)dataArr {
if (!_dataArr) {
_dataArr = [NSMutableArray array];
}
return _dataArr;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.dataArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
SaleInputPicCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
[cell setCellWith:self.dataArr index:indexPath];
// Configure the cell
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"SalesInPut" bundle:nil];
GalleryViewController *seePicVC = [storyBoard instantiateViewControllerWithIdentifier:@"GalleryViewController"];
seePicVC.arrData = self.dataArr;
seePicVC.page = indexPath.row;
[self.navigationController pushViewController:seePicVC animated:YES];
}
/*
#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.
}
*/
#pragma mark <UICollectionViewDelegate>
/*
// Uncomment this method to specify if the specified item should be highlighted during tracking
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
*/
/*
// Uncomment this method to specify if the specified item should be selected
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
*/
/*
// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
return NO;
}
- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
}
*/
@end
......@@ -426,7 +426,7 @@ ON_WILL_APPEAR( signal )
- (void)httpPostAttachments {
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController];
NSString *string = [NSString stringWithFormat:@"attachment/upload_by_file?entity_type=%@&entity_uuid=%@",@"salesInput",@"860576037625827160708160529115460847"];
NSString *string = [NSString stringWithFormat:@"attachment/upload_by_file?entity_type=%@&entity_uuid=%@",@"salesInput",self.shop.uuid];
WS(weakSelf);
[self.arrPics removeLastObject];
[httpCtrl POST:string pictures:self.arrPics param:nil complete:^(id responseObject, NSError *error) {
......
//
// AttachmentModel.h
// vanke
//
// Created by Z on 16/7/18.
// Copyright © 2016年 gomore. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AttachmentModel : NSObject
@property (nonatomic, copy) NSString *fileUrl;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *fileName;
@end
//
// AttachmentModel.m
// vanke
//
// Created by Z on 16/7/18.
// Copyright © 2016年 gomore. All rights reserved.
//
#import "AttachmentModel.h"
@implementation AttachmentModel
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
}
@end
//
// GalleryCollectionViewCell.h
// CapitalChamberlain
//
// Created by 张杰 on 15/12/3.
// Copyright © 2015年 SunShine. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "SingleScrollView.h"
#import "AttachmentModel.h"
@interface GalleryCollectionViewCell : UICollectionViewCell
@property (nonatomic, strong) UIImageView *imgView;
- (void)setUpCellWithModel:(AttachmentModel *)model;
- (void)cellWithImgName:(NSString *)imgUrl;
@end
//
// GalleryCollectionViewCell.m
// CapitalChamberlain
//
// Created by 张杰 on 15/12/3.
// Copyright © 2015年 SunShine. All rights reserved.
//
#import "GalleryCollectionViewCell.h"
@interface GalleryCollectionViewCell ()
@property (nonatomic, strong) SingleScrollView *imageScrollView;
@end
@implementation GalleryCollectionViewCell
- (void)awakeFromNib {
CLog(@"%f",self.width);
self.imageScrollView = [[SingleScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
self.backgroundColor = [UIColor blackColor];
[self.contentView addSubview:self.imageScrollView];
}
- (void)setUpCellWithModel:(AttachmentModel *)model {
NSString *imageUrl;
if (model.fileUrl.length < 3) {
imageUrl = @"inspect_result_noupload";
}else{
imageUrl = [NSString stringWithFormat:@"%@%@",VANKE_SERVER_MEDIA_BASE_URL, model.fileUrl];
}
[self cellWithImgName:imageUrl];
}
- (void)cellWithImgName:(NSString *)imgUrl {
[self.imageScrollView setImage:imgUrl placeHolder:[UIImage imageNamed:@"no_picture"]];
}
@end
//
// SaleInputPicCollectionViewCell.h
// vanke
//
// Created by Z on 16/7/17.
// Copyright © 2016年 gomore. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AttachmentModel.h"
@interface SaleInputPicCollectionViewCell : UICollectionViewCell
- (void)setCellWith:(NSArray *)array index:(NSIndexPath *)indexPath;
@end
//
// SaleInputPicCollectionViewCell.m
// vanke
//
// Created by Z on 16/7/17.
// Copyright © 2016年 gomore. All rights reserved.
//
#import "SaleInputPicCollectionViewCell.h"
#import "UIImageView+AFNetworking.h"
#import "VankeConfig.h"
@interface SaleInputPicCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *img;
@end
@implementation SaleInputPicCollectionViewCell
- (void)setCellWith:(NSArray *)array index:(NSIndexPath *)indexPath {
AttachmentModel *model = array[indexPath.row];
[self.img setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",VANKE_SERVER_MEDIA_BASE_URL, model.fileUrl]] placeholderImage:[UIImage imageNamed:@"floor-def"]];
}
@end
......@@ -29,15 +29,14 @@
[self.btnRight setImage:arrPic[indexPath.row * 2 + 1] forState:UIControlStateNormal];
self.btnRight.tag = indexPath.row * 2 + 1;
self.btnRight.hidden = NO;
}
[self.btnLeft addTarget:self action:@selector(actionSeePic:) forControlEvents:UIControlEventTouchUpInside];
[self.btnRight addTarget:self action:@selector(actionSeePic:) forControlEvents:UIControlEventTouchUpInside];
[self.btnLeft addTarget:self action:@selector(actionPic:) forControlEvents:UIControlEventTouchUpInside];
[self.btnRight addTarget:self action:@selector(actionPic:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)actionSeePic:(UIButton *)btn {
- (void)actionPic:(UIButton *)btn {
// CLog(@"%ld", btn.tag);
if (btn.tag == self.arrPictures.count - 1) {
self.addPicBlock(0);
......
//
// SingleScrollView.h
// PhotoWallDemo
//
// Created by LZXuan on 14-8-18.
// Copyright (c) 2014年 LZXuan. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SingleScrollView : UIScrollView
//
- (SingleScrollView *)initWithFrame:(CGRect)frame image:(NSString *)image;
- (void)setImage:(NSString *)image placeHolder:(UIImage *)placeHolder;
@end
//
// SingleScrollView.m
// PhotoWallDemo
//
// Created by LZXuan on 14-8-18.
// Copyright (c) 2014年 LZXuan. All rights reserved.
//
#import "SingleScrollView.h"
#import "UIImageView+WebCache.h"
#define SW 1
@interface SingleScrollView()<UIScrollViewDelegate>
@end
@implementation SingleScrollView {
UIImageView *_imageView;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setUpViews];
}
return self;
}
- (SingleScrollView *)initWithFrame:(CGRect)frame image:(NSString *)image{
if (self = [super initWithFrame:frame]) {
[self setUpViews];
[self setImage:image placeHolder:nil];
}
return self;
}
- (void)setUpViews {
self.delegate = self;
self.showsHorizontalScrollIndicator = NO;
self.showsVerticalScrollIndicator = NO;
//设置最大放大倍数
self.minimumZoomScale = 1.0;
self.maximumZoomScale = 2.0;
//粘贴一张图片
_imageView = [[UIImageView alloc] init];
_imageView.frame = CGRectMake(0, 0, self.frame.size.width - 10*2, self.frame.size.height);
_imageView.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
_imageView.contentMode = UIViewContentModeScaleAspectFit;
UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTapGesture setNumberOfTapsRequired:2];
[_imageView addGestureRecognizer:doubleTapGesture];
_imageView.userInteractionEnabled = YES;
[self addSubview:_imageView];
}
- (void)setImage:(NSString *)image placeHolder:(UIImage *)placeHolder{
//每次重新设置图片的时候设置缩放比例(场景是在做相册的时候)
self.zoomScale = 1.0;
if ([image hasPrefix:@"http://"]) {
NSURL *url = [NSURL URLWithString:image];
[_imageView sd_setImageWithURL:url placeholderImage:placeHolder];
}else{
_imageView.image=[UIImage imageNamed:image];
}
}
//双击定点缩放
- (void)handleDoubleTap:(UIGestureRecognizer *)gesture {
CGFloat zoomScale = self.zoomScale;
zoomScale = (zoomScale == 1.0) ? 2.0 : 1.0;
CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:[gesture locationInView:gesture.view]];
[self zoomToRect:zoomRect animated:YES];
}
- (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center {
CGRect zoomRect;
zoomRect.size.height = self.frame.size.height / scale;
zoomRect.size.width = self.frame.size.width / scale;
zoomRect.origin.x = center.x - (zoomRect.size.width /2.0);
zoomRect.origin.y = center.y - (zoomRect.size.height /2.0);
return zoomRect;
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return _imageView;
}
@end
//
// Items.h
//
// Created by 杰 张 on 16/7/18
// Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Items : NSObject <NSCoding, NSCopying>
@property (nonatomic, assign) double amount;
@property (nonatomic, strong) NSString *remark;
@property (nonatomic, assign) double endDate;
@property (nonatomic, assign) double unpaid;
@property (nonatomic, strong) NSString *subject;
@property (nonatomic, assign) double beginDate;
@property (nonatomic, assign) double direction;
@property (nonatomic, assign) double paid;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (NSDictionary *)dictionaryRepresentation;
@end
//
// Items.m
//
// Created by 杰 张 on 16/7/18
// Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//
#import "Items.h"
NSString *const kItemsAmount = @"amount";
NSString *const kItemsRemark = @"remark";
NSString *const kItemsEndDate = @"endDate";
NSString *const kItemsUnpaid = @"unpaid";
NSString *const kItemsSubject = @"subject";
NSString *const kItemsBeginDate = @"beginDate";
NSString *const kItemsDirection = @"direction";
NSString *const kItemsPaid = @"paid";
@interface Items ()
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
@end
@implementation Items
@synthesize amount = _amount;
@synthesize remark = _remark;
@synthesize endDate = _endDate;
@synthesize unpaid = _unpaid;
@synthesize subject = _subject;
@synthesize beginDate = _beginDate;
@synthesize direction = _direction;
@synthesize paid = _paid;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
return [[self alloc] initWithDictionary:dict];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
self = [super init];
// This check serves to make sure that a non-NSDictionary object
// passed into the model class doesn't break the parsing.
if(self && [dict isKindOfClass:[NSDictionary class]]) {
self.amount = [[self objectOrNilForKey:kItemsAmount fromDictionary:dict] doubleValue];
self.remark = [self objectOrNilForKey:kItemsRemark fromDictionary:dict];
self.endDate = [[self objectOrNilForKey:kItemsEndDate fromDictionary:dict] doubleValue];
self.unpaid = [[self objectOrNilForKey:kItemsUnpaid fromDictionary:dict] doubleValue];
self.subject = [self objectOrNilForKey:kItemsSubject fromDictionary:dict];
self.beginDate = [[self objectOrNilForKey:kItemsBeginDate fromDictionary:dict] doubleValue];
self.direction = [[self objectOrNilForKey:kItemsDirection fromDictionary:dict] doubleValue];
self.paid = [[self objectOrNilForKey:kItemsPaid fromDictionary:dict] doubleValue];
}
return self;
}
- (NSDictionary *)dictionaryRepresentation
{
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
[mutableDict setValue:[NSNumber numberWithDouble:self.amount] forKey:kItemsAmount];
[mutableDict setValue:self.remark forKey:kItemsRemark];
[mutableDict setValue:[NSNumber numberWithDouble:self.endDate] forKey:kItemsEndDate];
[mutableDict setValue:[NSNumber numberWithDouble:self.unpaid] forKey:kItemsUnpaid];
[mutableDict setValue:self.subject forKey:kItemsSubject];
[mutableDict setValue:[NSNumber numberWithDouble:self.beginDate] forKey:kItemsBeginDate];
[mutableDict setValue:[NSNumber numberWithDouble:self.direction] forKey:kItemsDirection];
[mutableDict setValue:[NSNumber numberWithDouble:self.paid] forKey:kItemsPaid];
return [NSDictionary dictionaryWithDictionary:mutableDict];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}
#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
id object = [dict objectForKey:aKey];
return [object isEqual:[NSNull null]] ? nil : object;
}
#pragma mark - NSCoding Methods
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
self.amount = [aDecoder decodeDoubleForKey:kItemsAmount];
self.remark = [aDecoder decodeObjectForKey:kItemsRemark];
self.endDate = [aDecoder decodeDoubleForKey:kItemsEndDate];
self.unpaid = [aDecoder decodeDoubleForKey:kItemsUnpaid];
self.subject = [aDecoder decodeObjectForKey:kItemsSubject];
self.beginDate = [aDecoder decodeDoubleForKey:kItemsBeginDate];
self.direction = [aDecoder decodeDoubleForKey:kItemsDirection];
self.paid = [aDecoder decodeDoubleForKey:kItemsPaid];
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeDouble:_amount forKey:kItemsAmount];
[aCoder encodeObject:_remark forKey:kItemsRemark];
[aCoder encodeDouble:_endDate forKey:kItemsEndDate];
[aCoder encodeDouble:_unpaid forKey:kItemsUnpaid];
[aCoder encodeObject:_subject forKey:kItemsSubject];
[aCoder encodeDouble:_beginDate forKey:kItemsBeginDate];
[aCoder encodeDouble:_direction forKey:kItemsDirection];
[aCoder encodeDouble:_paid forKey:kItemsPaid];
}
- (id)copyWithZone:(NSZone *)zone
{
Items *copy = [[Items alloc] init];
if (copy) {
copy.amount = self.amount;
copy.remark = [self.remark copyWithZone:zone];
copy.endDate = self.endDate;
copy.unpaid = self.unpaid;
copy.subject = [self.subject copyWithZone:zone];
copy.beginDate = self.beginDate;
copy.direction = self.direction;
copy.paid = self.paid;
}
return copy;
}
@end
//
// StatementModel.h
//
// Created by 杰 张 on 16/7/18
// Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface StatementModel : NSObject <NSCoding, NSCopying>
@property (nonatomic, assign) double amount;
@property (nonatomic, strong) NSString *settle;
@property (nonatomic, assign) double unpaid;
@property (nonatomic, strong) NSString *picture;
@property (nonatomic, strong) NSString *contract;
@property (nonatomic, strong) NSString *shopName;
@property (nonatomic, strong) NSString *shopCode;
@property (nonatomic, assign) double paid;
@property (nonatomic, strong) NSString *state;
@property (nonatomic, strong) NSArray *items;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (NSDictionary *)dictionaryRepresentation;
@end
//
// StatementModel.m
//
// Created by 杰 张 on 16/7/18
// Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//
#import "StatementModel.h"
#import "Items.h"
NSString *const kStatementModelAmount = @"amount";
NSString *const kStatementModelSettle = @"settle";
NSString *const kStatementModelUnpaid = @"unpaid";
NSString *const kStatementModelPicture = @"picture";
NSString *const kStatementModelContract = @"contract";
NSString *const kStatementModelShopName = @"shopName";
NSString *const kStatementModelShopCode = @"shopCode";
NSString *const kStatementModelPaid = @"paid";
NSString *const kStatementModelState = @"state";
NSString *const kStatementModelItems = @"items";
@interface StatementModel ()
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
@end
@implementation StatementModel
@synthesize amount = _amount;
@synthesize settle = _settle;
@synthesize unpaid = _unpaid;
@synthesize picture = _picture;
@synthesize contract = _contract;
@synthesize shopName = _shopName;
@synthesize shopCode = _shopCode;
@synthesize paid = _paid;
@synthesize state = _state;
@synthesize items = _items;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
return [[self alloc] initWithDictionary:dict];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
self = [super init];
// This check serves to make sure that a non-NSDictionary object
// passed into the model class doesn't break the parsing.
if(self && [dict isKindOfClass:[NSDictionary class]]) {
self.amount = [[self objectOrNilForKey:kStatementModelAmount fromDictionary:dict] doubleValue];
self.settle = [self objectOrNilForKey:kStatementModelSettle fromDictionary:dict];
self.unpaid = [[self objectOrNilForKey:kStatementModelUnpaid fromDictionary:dict] doubleValue];
self.picture = [self objectOrNilForKey:kStatementModelPicture fromDictionary:dict];
self.contract = [self objectOrNilForKey:kStatementModelContract fromDictionary:dict];
self.shopName = [self objectOrNilForKey:kStatementModelShopName fromDictionary:dict];
self.shopCode = [self objectOrNilForKey:kStatementModelShopCode fromDictionary:dict];
self.paid = [[self objectOrNilForKey:kStatementModelPaid fromDictionary:dict] doubleValue];
self.state = [self objectOrNilForKey:kStatementModelState fromDictionary:dict];
NSObject *receivedItems = [dict objectForKey:kStatementModelItems];
NSMutableArray *parsedItems = [NSMutableArray array];
if ([receivedItems isKindOfClass:[NSArray class]]) {
for (NSDictionary *item in (NSArray *)receivedItems) {
if ([item isKindOfClass:[NSDictionary class]]) {
[parsedItems addObject:[Items modelObjectWithDictionary:item]];
}
}
} else if ([receivedItems isKindOfClass:[NSDictionary class]]) {
[parsedItems addObject:[Items modelObjectWithDictionary:(NSDictionary *)receivedItems]];
}
self.items = [NSArray arrayWithArray:parsedItems];
}
return self;
}
- (NSDictionary *)dictionaryRepresentation
{
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
[mutableDict setValue:[NSNumber numberWithDouble:self.amount] forKey:kStatementModelAmount];
[mutableDict setValue:self.settle forKey:kStatementModelSettle];
[mutableDict setValue:[NSNumber numberWithDouble:self.unpaid] forKey:kStatementModelUnpaid];
[mutableDict setValue:self.picture forKey:kStatementModelPicture];
[mutableDict setValue:self.contract forKey:kStatementModelContract];
[mutableDict setValue:self.shopName forKey:kStatementModelShopName];
[mutableDict setValue:self.shopCode forKey:kStatementModelShopCode];
[mutableDict setValue:[NSNumber numberWithDouble:self.paid] forKey:kStatementModelPaid];
[mutableDict setValue:self.state forKey:kStatementModelState];
NSMutableArray *tempArrayForItems = [NSMutableArray array];
for (NSObject *subArrayObject in self.items) {
if([subArrayObject respondsToSelector:@selector(dictionaryRepresentation)]) {
// This class is a model object
[tempArrayForItems addObject:[subArrayObject performSelector:@selector(dictionaryRepresentation)]];
} else {
// Generic object
[tempArrayForItems addObject:subArrayObject];
}
}
[mutableDict setValue:[NSArray arrayWithArray:tempArrayForItems] forKey:kStatementModelItems];
return [NSDictionary dictionaryWithDictionary:mutableDict];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}
#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
id object = [dict objectForKey:aKey];
return [object isEqual:[NSNull null]] ? nil : object;
}
#pragma mark - NSCoding Methods
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
self.amount = [aDecoder decodeDoubleForKey:kStatementModelAmount];
self.settle = [aDecoder decodeObjectForKey:kStatementModelSettle];
self.unpaid = [aDecoder decodeDoubleForKey:kStatementModelUnpaid];
self.picture = [aDecoder decodeObjectForKey:kStatementModelPicture];
self.contract = [aDecoder decodeObjectForKey:kStatementModelContract];
self.shopName = [aDecoder decodeObjectForKey:kStatementModelShopName];
self.shopCode = [aDecoder decodeObjectForKey:kStatementModelShopCode];
self.paid = [aDecoder decodeDoubleForKey:kStatementModelPaid];
self.state = [aDecoder decodeObjectForKey:kStatementModelState];
self.items = [aDecoder decodeObjectForKey:kStatementModelItems];
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeDouble:_amount forKey:kStatementModelAmount];
[aCoder encodeObject:_settle forKey:kStatementModelSettle];
[aCoder encodeDouble:_unpaid forKey:kStatementModelUnpaid];
[aCoder encodeObject:_picture forKey:kStatementModelPicture];
[aCoder encodeObject:_contract forKey:kStatementModelContract];
[aCoder encodeObject:_shopName forKey:kStatementModelShopName];
[aCoder encodeObject:_shopCode forKey:kStatementModelShopCode];
[aCoder encodeDouble:_paid forKey:kStatementModelPaid];
[aCoder encodeObject:_state forKey:kStatementModelState];
[aCoder encodeObject:_items forKey:kStatementModelItems];
}
- (id)copyWithZone:(NSZone *)zone
{
StatementModel *copy = [[StatementModel alloc] init];
if (copy) {
copy.amount = self.amount;
copy.settle = [self.settle copyWithZone:zone];
copy.unpaid = self.unpaid;
copy.picture = [self.picture copyWithZone:zone];
copy.contract = [self.contract copyWithZone:zone];
copy.shopName = [self.shopName copyWithZone:zone];
copy.shopCode = [self.shopCode copyWithZone:zone];
copy.paid = self.paid;
copy.state = [self.state copyWithZone:zone];
copy.items = [self.items copyWithZone:zone];
}
return copy;
}
@end
......@@ -446,7 +446,7 @@
<connections>
<outlet property="imgShop" destination="Gmk-Kr-RRS" id="vDH-1a-sNj"/>
<outlet property="labelPaidIn" destination="ZxP-vP-jg0" id="8ud-Fi-tUp"/>
<outlet property="labelShouldPay" destination="tYe-gT-7Ke" id="SuL-Ln-JUC"/>
<outlet property="labelShouldPay" destination="om4-cp-cn3" id="jHf-qU-nui"/>
<outlet property="labelTitle" destination="eoV-ug-BwJ" id="PbZ-u0-Zr3"/>
<outlet property="labelUnPaid" destination="bZD-Rx-SkM" id="2UC-TE-oi7"/>
</connections>
......@@ -485,6 +485,7 @@
<outlet property="labelTotalUnPaid" destination="xYD-uh-jS6" id="gZY-Mu-IrG"/>
<outlet property="labelYear" destination="v9Q-me-Myt" id="IxQ-on-B9S"/>
<outlet property="searchBar" destination="GLM-IL-sNq" id="dmh-ye-uCU"/>
<outlet property="tableView" destination="nAN-KY-uuU" id="YZW-rn-ch7"/>
<outlet property="textFieldSelectDate" destination="zvp-Uj-Jhu" id="mss-5d-day"/>
</connections>
</viewController>
......
......@@ -11,7 +11,11 @@
#import "NSDate+FormatterAdditions.h"
#import "SRMonthPicker.h"
#import "StatementListParamModel.h"
#import "StatementModel.h"
#import "VankeAppBoard_iPhone.h"
@interface StatementViewController ()<UITableViewDelegate, UITableViewDataSource, SRMonthPickerDelegate, UISearchBarDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
/** 共?家商铺 */
@property (weak, nonatomic) IBOutlet UILabel *labelTotalShop;
/** 应缴合计 */
......@@ -40,13 +44,14 @@
/** 网络请求参数 */
@property (nonatomic, strong) StatementListParamModel *paramModel;
@property (nonatomic, strong) NSMutableArray *arrData;
@end
@implementation StatementViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[VankeAppBoard_iPhone sharedInstance] hideMenu];
[self setDefaults];
[self setUpDatePicker];
self.paramModel = [[StatementListParamModel alloc] init];
......@@ -60,13 +65,14 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// self.navigationController.navigationBar.barTintColor = kMainPurpleColor;
}
- (void)setDefaults {
NSDate *currentDate = [NSDate date];
self.startDate = currentDate.yearMonthString;
self.endDate = currentDate.yearMonthString;
self.endDate = [currentDate stringWithFormatter:@"%Y%m"];
self.labelYear.text = currentDate.yearString;
self.labelMonth.text = currentDate.monthString;
self.labelFinishYear.text = currentDate.yearString;
......@@ -123,20 +129,33 @@
/** 网络请求 */
- (void)setUpData {
// NSString *url = [NSString stringWithFormat:@"statement/query/%@~%@?authorizedOrgIn=%@&pageNumber=%@&pageSize=%@", @"2016-06", self.endDate, self.org.uuid, @0, @999];
NSString *url = [NSString stringWithFormat:@"statement/query/%@~%@?authorizedOrgIn=%@&pageNumber=%@&pageSize=%@", @"201509", self.endDate, self.org.code, @0, @999];
WS(weakSelf);
[[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) {
NSDictionary *dict = data;
CLog(@"%@", dict.JSONString);
NSInteger count = dict[@"paging"][@"recordCount"];
weakSelf.labelTotalShop.text = [NSString stringWithFormat:@"%ld",(long)count];
for (NSDictionary *dic in data[@"data"][@"records"]) {
[self.arrData addObject:[StatementModel modelObjectWithDictionary:dic]];
}
[self.tableView reloadData];
} failure:^(id data) {
}];
// [[HTTPCilent shareCilent] GET:url parameters:nil complete:^(id responseObject, NSError *error) {
// error;
// }];
}
#pragma mark - tableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
return self.arrData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
StatementTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StatementCell" forIndexPath:indexPath];
[cell setUpCellWithArray:self.arrData index:indexPath];
return cell;
}
......@@ -148,6 +167,13 @@
[self PushToStoryBoardVCWithIdentifier:@"StatementDetailViewController" isHideTabbar:YES animate:YES];
}
- (NSMutableArray *)arrData {
if (!_arrData) {
_arrData = [NSMutableArray array];
}
return _arrData;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......
......@@ -7,7 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "StatementModel.h"
@interface StatementTableViewCell : UITableViewCell
- (void)setUpCellWithArray:(NSArray *)array index:(NSIndexPath *)indexPath;
@end
......@@ -25,6 +25,14 @@
// Initialization code
}
- (void)setUpCellWithArray:(NSArray *)array index:(NSIndexPath *)indexPath {
StatementModel *model = array[indexPath.row];
self.labelTitle.text = model.shopName;
self.labelShouldPay.text = [NSString stringWithFormat:@"%.2f",model.amount];
self.labelPaidIn.text = [NSString stringWithFormat:@"[已缴]%.2f",model.paid];
self.labelUnPaid.text = [NSString stringWithFormat:@"[未缴]%.2f",model.unpaid];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
......
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