Commit 990cc969 authored by Sandy's avatar Sandy

修复bug

parent 6de087fe
...@@ -36,12 +36,19 @@ typedef NS_ENUM(NSInteger, CalculateType) { ...@@ -36,12 +36,19 @@ typedef NS_ENUM(NSInteger, CalculateType) {
* @return 结算结果 * @return 结算结果
*/ */
+ (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type roundingType:(NSRoundingMode)roundingType cutLenth:(NSInteger)coutLenth; + (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type roundingType:(NSRoundingMode)roundingType cutLenth:(NSInteger)coutLenth;
+ (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type;
/** 一百倍 */ /** 一百倍 */
+ (NSDecimalNumber *)oneHundredTimes:(id)num; + (NSDecimalNumber *)oneHundredTimes:(id)num;
/** 计算百分比 */ /** 计算百分比 */
+ (NSString *)getPercent:(id)num1 num:(id)num2; + (NSString *)getPercent:(id)num1 num:(id)num2;
/** 获取金额 */ /** 获取金额 */
+ (NSString *)getMoneyStringFrom:(id)num; + (NSString *)getMoneyStringFrom:(id)num;
/** 获取金额 */
+ (NSString *)getMoneyStringFrom:(id)num Lenth:(NSInteger)cutLenth isSeparate:(BOOL)isSeparate;
+ (NSString *)getMoneyStringFromString:(NSString *)originString; + (NSString *)getMoneyStringFromString:(NSString *)originString;
+ (NSString *)getABSValue:(NSString *)string;
+ (NSString *)separateMoney:(NSDecimalNumber *)num;
@end @end
...@@ -13,17 +13,11 @@ ...@@ -13,17 +13,11 @@
+ (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type roundingType:(NSRoundingMode)roundingType cutLenth:(NSInteger)coutLenth { + (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type roundingType:(NSRoundingMode)roundingType cutLenth:(NSInteger)coutLenth {
NSDecimalNumberHandler *roundUp = [NSDecimalNumberHandler NSDecimalNumberHandler *roundUp = [NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode:roundingType decimalNumberHandlerWithRoundingMode:roundingType
scale:coutLenth scale:coutLenth
raiseOnExactness:NO raiseOnExactness:NO
raiseOnOverflow:NO raiseOnOverflow:NO
raiseOnUnderflow:NO raiseOnUnderflow:NO
raiseOnDivideByZero:YES]; raiseOnDivideByZero:YES];
NSDecimalNumber *decimalNum1 = [self changeType:num1]; NSDecimalNumber *decimalNum1 = [self changeType:num1];
NSDecimalNumber *decimalNum2 = [self changeType:num2]; NSDecimalNumber *decimalNum2 = [self changeType:num2];
...@@ -34,6 +28,7 @@ ...@@ -34,6 +28,7 @@
NSDecimalNumber *decimalResult; NSDecimalNumber *decimalResult;
NSString *result; NSString *result;
switch (type) { switch (type) {
case CalculateTypeAdd: { case CalculateTypeAdd: {
decimalResult = [decimalNum1 decimalNumberByAdding:decimalNum2 withBehavior:roundUp]; decimalResult = [decimalNum1 decimalNumberByAdding:decimalNum2 withBehavior:roundUp];
...@@ -66,17 +61,64 @@ ...@@ -66,17 +61,64 @@
return decimalResult; return decimalResult;
} }
+ (NSDecimalNumber *)calculateNum1:(id)num1 num2:(id)num2 type:(CalculateType)type {
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];
result = [decimalResult stringValue];
break;
}
case CalculateTypeSub: {
decimalResult = [decimalNum1 decimalNumberBySubtracting:decimalNum2 ];
result = [decimalResult stringValue];
break;
}
case CalculateTypeMul: {
decimalResult = [decimalNum1 decimalNumberByMultiplyingBy:decimalNum2];
result = [decimalResult stringValue];
break;
}
case CalculateTypeDiv: {
if ([decimalNum2 isEqualToNumber:@0]) {
decimalResult = [NSDecimalNumber decimalNumberWithString:@"0"];
}else{
decimalResult = [decimalNum1 decimalNumberByDividingBy:decimalNum2];
result = [decimalResult stringValue];
}
break;
}
}
return decimalResult;
}
//把传入的类型变成NSDecimalNumber //把传入的类型变成NSDecimalNumber
+ (NSDecimalNumber *)changeType:(id)num1 { + (NSDecimalNumber *)changeType:(id)num1 {
NSDecimalNumber *decimalNum1; NSDecimalNumber *decimalNum1;
if ([num1 isKindOfClass:[NSDecimalNumber class]]) { if ([num1 isKindOfClass:[NSDecimalNumber class]]) {
decimalNum1 = num1; decimalNum1 = num1;
}else if([num1 isKindOfClass:[NSString class]]){ }else if([num1 isKindOfClass:[NSString class]]){
decimalNum1 = [NSDecimalNumber decimalNumberWithString:num1]; if([num1 isEqualToString:@""]){
decimalNum1 = [NSDecimalNumber decimalNumberWithString:@"0"];
}else{
decimalNum1 = [NSDecimalNumber decimalNumberWithString:num1];
}
}else if ([num1 isKindOfClass:[NSNumber class]]){ }else if ([num1 isKindOfClass:[NSNumber class]]){
decimalNum1 = [NSDecimalNumber decimalNumberWithDecimal:[num1 decimalValue]]; decimalNum1 = [NSDecimalNumber decimalNumberWithDecimal:[num1 decimalValue]];
}else{ }else if(num1 == nil){
return nil; decimalNum1 = [NSDecimalNumber decimalNumberWithString:@"0"];
} }
return decimalNum1; return decimalNum1;
} }
...@@ -91,21 +133,27 @@ ...@@ -91,21 +133,27 @@
return [NSString stringWithFormat:@"%@%%",[self getMoneyStringFromString:result.stringValue]]; return [NSString stringWithFormat:@"%@%%",[self getMoneyStringFromString:result.stringValue]];
} }
+ (NSString *)getMoneyStringFrom:(id)num Lenth:(NSInteger)cutLenth { + (NSString *)getMoneyStringFrom:(id)num Lenth:(NSInteger)cutLenth isSeparate:(BOOL)isSeparate {
NSDecimalNumberHandler *roundUp = [NSDecimalNumberHandler NSDecimalNumberHandler *roundUp = [NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode:NSRoundBankers decimalNumberHandlerWithRoundingMode:NSRoundBankers
scale:cutLenth ? cutLenth : 2 scale:cutLenth
raiseOnExactness:NO raiseOnExactness:NO
raiseOnOverflow:NO raiseOnOverflow:NO
raiseOnUnderflow:NO raiseOnUnderflow:NO
raiseOnDivideByZero:YES]; raiseOnDivideByZero:YES];
NSDecimalNumber *decimal = [self changeType:num]; NSDecimalNumber *decimal = [self changeType:num];
NSDecimalNumber *result = [decimal decimalNumberByAdding:[NSDecimalNumber decimalNumberWithString:@"0"] withBehavior:roundUp]; NSDecimalNumber *result = [decimal decimalNumberByAdding:[NSDecimalNumber decimalNumberWithString:@"0"] withBehavior:roundUp];
return [result stringValue];
if (isSeparate) {
return [self separateMoney:result];
}else{
return [result stringValue];
}
} }
+ (NSString *)getMoneyStringFrom:(id)num{ + (NSString *)getMoneyStringFrom:(id)num{
NSString *originString = [self getMoneyStringFrom:num Lenth:2]; NSString *originString = [self getMoneyStringFrom:num Lenth:2 isSeparate:NO];
return [self getMoneyStringFromString:originString]; return [self getMoneyStringFromString:originString];
} }
...@@ -128,6 +176,25 @@ ...@@ -128,6 +176,25 @@
} }
} }
return result; return result;
}
+ (NSString *)getABSValue:(NSString *)string {
if ([string hasPrefix:@"-"] && ![string hasPrefix:@"--"]) {
NSString *absString = [string substringWithRange:NSMakeRange(1, string.length - 1)];
return absString;
}else{
return string;
}
}
+ (NSString *)separateMoney:(NSDecimalNumber *)num {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc]init];
numberFormatter.locale = [NSLocale currentLocale];// this ensure the right separator behavior
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
numberFormatter.usesGroupingSeparator = YES;
// example for writing the number object into a label
NSString *string = [numberFormatter stringFromNumber:num];
return string;
} }
@end @end
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.3.4</string> <string>1.4.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -21,15 +21,15 @@ ...@@ -21,15 +21,15 @@
// 百度天气服务地址 // 百度天气服务地址
#define VANKE_BAIDU_WEATHER_SERVER_URL @"http://api.map.baidu.com/telematics/v3/weather" #define VANKE_BAIDU_WEATHER_SERVER_URL @"http://api.map.baidu.com/telematics/v3/weather"
// //正式环境 //正式环境
//#define VANKE_SERVER_BASE_URL @"http://140.206.62.178:8080/wanke-server/rest" //正式 #define VANKE_SERVER_BASE_URL @"http://140.206.62.178:8080/wanke-server/rest" //正式
// //后台多媒体文件基准地址 //后台多媒体文件基准地址
//#define VANKE_SERVER_MEDIA_BASE_URL @"http://140.206.62.178:8080" //正式 #define VANKE_SERVER_MEDIA_BASE_URL @"http://140.206.62.178:8080" //正式
// 测试环境 // 测试环境
#define VANKE_SERVER_BASE_URL @"http://139.196.39.77:8080/wanke-server/rest" //#define VANKE_SERVER_BASE_URL @"http://139.196.39.77:8080/wanke-server/rest"
#define VANKE_SERVER_MEDIA_BASE_URL @"http://139.196.39.77:8080" //#define VANKE_SERVER_MEDIA_BASE_URL @"http://139.196.39.77:8080"
// 后台服务企业认证码 // 后台服务企业认证码
......
...@@ -95,7 +95,7 @@ ON_CREATE_VIEWS( signal ) ...@@ -95,7 +95,7 @@ ON_CREATE_VIEWS( signal )
[self bulidLayout]; [self bulidLayout];
UIBarButtonItem *searchItem = [[UIBarButtonItem alloc]initWithTitle:@"历史" style:UIBarButtonItemStyleDone target:self action:@selector(customSegTwoClick:)]; UIBarButtonItem *searchItem = [[UIBarButtonItem alloc]initWithTitle:@"历史" style:UIBarButtonItemStyleDone target:self action:@selector(customSegTwoClick:)];
self.navigationItem.rightBarButtonItem = searchItem; self.navigationItem.rightBarButtonItem = searchItem;
self.automaticallyAdjustsScrollViewInsets = NO;
self.dayType = @"day"; self.dayType = @"day";
self.scopeType = [IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM-dd"]; self.scopeType = [IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM-dd"];
...@@ -292,6 +292,11 @@ ON_CREATE_VIEWS( signal ) ...@@ -292,6 +292,11 @@ ON_CREATE_VIEWS( signal )
if (indexPath) { if (indexPath) {
[self actionTableView:indexPath]; [self actionTableView:indexPath];
} }
if (indexPath == nil && self.dataArr.count > 0) {
NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
[[NSNotificationCenter defaultCenter]postNotificationName:KNOTIFICATION_GetNextDetailData object:nil userInfo:@{@"indexPath":index}];
}
}else{ }else{
[IBTLoadingView showTips:message]; [IBTLoadingView showTips:message];
} }
...@@ -329,7 +334,7 @@ ON_CREATE_VIEWS( signal ) ...@@ -329,7 +334,7 @@ ON_CREATE_VIEWS( signal )
self.segView.delegate = self; self.segView.delegate = self;
[self.view addSubview:self.segView]; [self.view addSubview:self.segView];
self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, self.segView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64- self.segView.bottom)]; self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, self.segView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT- self.segView.bottom)];
self.scrollView.delegate = self; self.scrollView.delegate = self;
self.scrollView.showsHorizontalScrollIndicator = NO; self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.showsVerticalScrollIndicator = NO; self.scrollView.showsVerticalScrollIndicator = NO;
...@@ -348,7 +353,7 @@ ON_CREATE_VIEWS( signal ) ...@@ -348,7 +353,7 @@ ON_CREATE_VIEWS( signal )
// gvc = [GrossRateViewController new]; // gvc = [GrossRateViewController new];
// [self addChildViewController:gvc]; // [self addChildViewController:gvc];
rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64- self.segView.bottom); rect = CGRectMake(0, 0, SCREEN_WIDTH, self.scrollView.height + 64);
svc.view.frame = rect; svc.view.frame = rect;
[self.scrollView addSubview:svc.view]; [self.scrollView addSubview:svc.view];
......
...@@ -49,14 +49,13 @@ static NSString *saleHeaderIdentify = @"saleHeaderIdentify"; ...@@ -49,14 +49,13 @@ static NSString *saleHeaderIdentify = @"saleHeaderIdentify";
NSLog(@"%f---------",self.view.height); NSLog(@"%f---------",self.view.height);
rect = CGRectMake(0, 0, self.view.width, self.view.height- 158); rect = CGRectMake(0, 0, self.view.width, self.view.height - 49 - 64);
self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain]; self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
self.tableView.delegate = self; self.tableView.delegate = self;
self.tableView.dataSource = self; self.tableView.dataSource = self;
[self.tableView registerClass:[SaleViewCell class] forCellReuseIdentifier:saleCellIdentify]; [self.tableView registerClass:[SaleViewCell class] forCellReuseIdentifier:saleCellIdentify];
[self.tableView registerClass:[SaleHeaderView class] forHeaderFooterViewReuseIdentifier:saleHeaderIdentify]; [self.tableView registerClass:[SaleHeaderView class] forHeaderFooterViewReuseIdentifier:saleHeaderIdentify];
self.tableView.tableHeaderView = self.rsaleView; self.tableView.tableHeaderView = self.rsaleView;
[self.view addSubview:self.tableView]; [self.view addSubview:self.tableView];
} }
......
...@@ -168,14 +168,21 @@ ...@@ -168,14 +168,21 @@
self.dateLabel.text = compass.dataScope?[NSString stringWithFormat:@"%@%@累计销售额",compass.dataScope,weekday]:@"无"; self.dateLabel.text = compass.dataScope?[NSString stringWithFormat:@"%@%@累计销售额",compass.dataScope,weekday]:@"无";
//销售额 //销售额
NSString *strSale = [IBTCommon countNumAndChangeformat:[IBTCommon stringDisposeWithFloat:[compass.sales floatValue]]]; NSString *strSales = [CalculateHelper getMoneyStringFrom:compass.sales Lenth:0 isSeparate:YES];
self.centerLabel.text = compass.sales?[CalculateHelper getMoneyStringFromString:strSale] :@"---"; self.centerLabel.text = compass.sales?strSales :@"---";
//销售环比变化率 比上周 //销售环比变化率 比上周
NSDecimalNumber *saleDifference = [CalculateHelper calculateNum1:compass.sales num2:compass.salesChain type:CalculateTypeSub roundingType:NSRoundBankers cutLenth:4]; 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]; NSDecimalNumber *decimalSaleRate = [CalculateHelper calculateNum1:saleDifference num2:compass.salesChain type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:4];
decimalSaleRate = [CalculateHelper oneHundredTimes:decimalSaleRate]; decimalSaleRate = [CalculateHelper oneHundredTimes:decimalSaleRate];
NSString *salesChainRateStr = decimalSaleRate?[NSString stringWithFormat:@"%@%%", [CalculateHelper getMoneyStringFromString:[decimalSaleRate stringValue]]]:@"---"; NSString *salesChainRateStr = decimalSaleRate?[NSString stringWithFormat:@"%@%%", [CalculateHelper getMoneyStringFromString:[decimalSaleRate stringValue]]]:@"---";
if (!compass) {
salesChainRateStr = @"---";
}
if ([compass.salesChain isEqualToNumber:@0]) {
salesChainRateStr = @"---";
}
if (![salesChainRateStr hasPrefix:@"-"] && ![salesChainRateStr isEqualToString:@"0"] && ![salesChainRateStr hasPrefix:@"--"]) { if (![salesChainRateStr hasPrefix:@"-"] && ![salesChainRateStr isEqualToString:@"0"] && ![salesChainRateStr hasPrefix:@"--"]) {
[self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal]; [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
...@@ -187,7 +194,7 @@ ...@@ -187,7 +194,7 @@
[self.lastWeekLabel setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [self.lastWeekLabel setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[self.lastWeekLabel setImage:nil forState:UIControlStateNormal]; [self.lastWeekLabel setImage:nil forState:UIControlStateNormal];
} }
[self.lastWeekLabel setTitle:salesChainRateStr forState:UIControlStateNormal]; [self.lastWeekLabel setTitle:[CalculateHelper getABSValue:salesChainRateStr] forState:UIControlStateNormal];
//销售同比变化率 比上年 //销售同比变化率 比上年
NSDecimalNumber *decimalSalesYoYDifference = [CalculateHelper calculateNum1:compass.sales num2:compass.salesYoY type:CalculateTypeSub roundingType:NSRoundBankers cutLenth:4]; NSDecimalNumber *decimalSalesYoYDifference = [CalculateHelper calculateNum1:compass.sales num2:compass.salesYoY type:CalculateTypeSub roundingType:NSRoundBankers cutLenth:4];
...@@ -195,7 +202,13 @@ ...@@ -195,7 +202,13 @@
decimalSalesYoY = [CalculateHelper oneHundredTimes:decimalSalesYoY]; decimalSalesYoY = [CalculateHelper oneHundredTimes:decimalSalesYoY];
NSString *salesYoStr = decimalSalesYoY?[NSString stringWithFormat:@"%@%%",[decimalSalesYoY stringValue ]]:@"---"; NSString *salesYoStr = decimalSalesYoY?[NSString stringWithFormat:@"%@%%",[decimalSalesYoY stringValue ]]:@"---";
if ([compass.salesYoY isEqualToNumber:@0]) {
salesYoStr = @"---";
}
if (!compass) {
salesYoStr = @"---";
}
if (![salesYoStr hasPrefix:@"-"] && ![salesYoStr isEqualToString:@"0"] && ![salesYoStr hasPrefix:@"--"]) { if (![salesYoStr hasPrefix:@"-"] && ![salesYoStr isEqualToString:@"0"] && ![salesYoStr hasPrefix:@"--"]) {
[self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal]; [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
[self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateNormal]; [self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
...@@ -207,7 +220,7 @@ ...@@ -207,7 +220,7 @@
[self.lastYearLabel setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [self.lastYearLabel setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
} }
[self.lastYearLabel setTitle:salesYoStr forState:UIControlStateNormal]; [self.lastYearLabel setTitle:[CalculateHelper getABSValue:salesYoStr] forState:UIControlStateNormal];
//坪效 //坪效
NSDecimalNumber *groundEffect = [CalculateHelper calculateNum1:compass.sales num2:compass.area type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:2]; NSDecimalNumber *groundEffect = [CalculateHelper calculateNum1:compass.sales num2:compass.area type:CalculateTypeDiv roundingType:NSRoundBankers cutLenth:2];
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
//右侧共几家 jv //右侧共几家 jv
rect = CGRectMake(10, 0, 110, Sale_Header_Height); rect = CGRectMake(10, 0, 115, Sale_Header_Height);
UILabel *searLabel = [IBTCommon labelWithTitle:@"共280家" frame:rect textFont:self.textFont]; UILabel *searLabel = [IBTCommon labelWithTitle:@"共280家" frame:rect textFont:self.textFont];
searLabel.textColor = ReportTitleColor; searLabel.textColor = ReportTitleColor;
[self.contentView addSubview:searLabel]; [self.contentView addSubview:searLabel];
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
CGFloat width = (SCREEN_WIDTH - searLabel.right - 4)/4; CGFloat width = (SCREEN_WIDTH - searLabel.right - 4)/4;
rect = CGRectMake(searLabel.right, 0, width, Sale_Header_Height); rect = CGRectMake(searLabel.right, 0, width + 15, Sale_Header_Height);
UILabel * xsBtn = [IBTCommon labelWithTitle:@"销售额" frame:rect textFont:self.textFont]; UILabel * xsBtn = [IBTCommon labelWithTitle:@"销售额" frame:rect textFont:self.textFont];
xsBtn.textColor = ReportTitleColor; xsBtn.textColor = ReportTitleColor;
[self.contentView addSubview:xsBtn]; [self.contentView addSubview:xsBtn];
......
...@@ -70,7 +70,8 @@ ...@@ -70,7 +70,8 @@
CGFloat width = (SCREEN_WIDTH - self.dqLabel.right - 4)/4; CGFloat width = (SCREEN_WIDTH - self.dqLabel.right - 4)/4;
rect = CGRectMake(self.dqLabel.right , 0, width, Sale_Cell_Height); //销售额
rect = CGRectMake(self.dqLabel.right , 0, width + 15, Sale_Cell_Height);
self.saleLabel = [IBTCommon labelWithTitle:@"56,080" frame:rect textFont:self.textFont]; self.saleLabel = [IBTCommon labelWithTitle:@"56,080" frame:rect textFont:self.textFont];
[self.contentView addSubview:self.saleLabel]; [self.contentView addSubview:self.saleLabel];
...@@ -90,7 +91,7 @@ ...@@ -90,7 +91,7 @@
[self.contentView addSubview:self.rateLabel]; [self.contentView addSubview:self.rateLabel];
//日均销售 //日均销售
self.dailySaleLabel = [IBTCommon labelWithTitle:@"23" frame:CGRectMake(self.rateLabel.right+10, 0, width, Sale_Cell_Height) textFont:self.textFont]; self.dailySaleLabel = [IBTCommon labelWithTitle:@"23" frame:CGRectMake(self.rateLabel.right+10, 0, width - 15, Sale_Cell_Height) textFont:self.textFont];
self.dailySaleLabel.textColor = GXF_COMMIT_COLOR; self.dailySaleLabel.textColor = GXF_COMMIT_COLOR;
[self.contentView addSubview:self.dailySaleLabel]; [self.contentView addSubview:self.dailySaleLabel];
...@@ -133,7 +134,7 @@ ...@@ -133,7 +134,7 @@
self.saleLabel.textColor = GXF_NAVIGAYION_COLOR; self.saleLabel.textColor = GXF_NAVIGAYION_COLOR;
} }
//销售额 //销售额
self.saleLabel.text = sale.sales?[CalculateHelper getMoneyStringFrom:sale.sales] : @"0"; self.saleLabel.text = sale.sales?[CalculateHelper getMoneyStringFrom:sale.sales Lenth:0 isSeparate:NO] : @"0";
NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",[CalculateHelper getMoneyStringFrom:sale.salesChainRate]]; NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",[CalculateHelper getMoneyStringFrom:sale.salesChainRate]];
[self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal]; [self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];
...@@ -142,7 +143,7 @@ ...@@ -142,7 +143,7 @@
self.rateLabel.text = salesTargetRateStr; self.rateLabel.text = salesTargetRateStr;
//日均销售 //日均销售
self.dailySaleLabel.text = [NSString stringWithFormat:@"%@", [CalculateHelper getMoneyStringFrom:sale.dailysalesPerStore]]; self.dailySaleLabel.text = [NSString stringWithFormat:@"%@", [CalculateHelper getMoneyStringFrom:sale.dailysalesPerStore Lenth:0 isSeparate:NO]];
[self setColorAndFont:sale.level]; [self setColorAndFont:sale.level];
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
@property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) HistoryTopView *topView; @property (nonatomic, strong) HistoryTopView *topView;
@property (nonatomic, strong) NSArray *arrRecords; @property (nonatomic, strong) NSArray *arrRecords;
@property (nonatomic, strong) UIImageView *imageNoData;
@end @end
@implementation HistoryViewController @implementation HistoryViewController
...@@ -50,14 +50,20 @@ ...@@ -50,14 +50,20 @@
self.topView.labelShopName.text = [NSString stringWithFormat:@"%@【%@】", self.shop.name, self.shop.code]; self.topView.labelShopName.text = [NSString stringWithFormat:@"%@【%@】", self.shop.name, self.shop.code];
if (self.shop == nil) { if (self.shop == nil) {
self.topView.labelShopName.text = @""; self.topView.labelShopName.text = @"请选择店铺";
}else{ }else{
self.topView.labelShopName.text = [NSString stringWithFormat:@"%@【%@】", self.shop.name, self.shop.code]; self.topView.labelShopName.text = [NSString stringWithFormat:@"%@【%@】", self.shop.name, self.shop.code];
} }
} }
- (void)dealloc { - (UIImageView *)imageNoData {
if (!_imageNoData) {
_imageNoData = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
_imageNoData.center = self.view.center;
_imageNoData.contentMode = UIViewContentModeScaleToFill;
_imageNoData.image = [UIImage imageNamed:@"no_data@3x"];
}
return _imageNoData;
} }
- (void)chooseShopAction { - (void)chooseShopAction {
...@@ -78,6 +84,7 @@ ...@@ -78,6 +84,7 @@
[self.view addSubview:self.scrollView]; [self.view addSubview:self.scrollView];
} }
- (void)setUpScrollViewWithDataArr:(NSArray *)array bottomArr:(NSArray *)bottomArr{ - (void)setUpScrollViewWithDataArr:(NSArray *)array bottomArr:(NSArray *)bottomArr{
[self.scrollView removeAllSubviews]; [self.scrollView removeAllSubviews];
self.scrollView.contentOffset = CGPointMake(0, 0); self.scrollView.contentOffset = CGPointMake(0, 0);
...@@ -153,6 +160,10 @@ ...@@ -153,6 +160,10 @@
} }
picVC.title = self.arrRecords[row][@"salesDate"]; picVC.title = self.arrRecords[row][@"salesDate"];
picVC.attachmentUuid = self.arrRecords[row][@"attachmentUuid"]; picVC.attachmentUuid = self.arrRecords[row][@"attachmentUuid"];
NSArray *attachments = self.arrRecords[row][@"attachments"];
// if (attachments.count == 0) {
// picVC.attachmentUuid = nil;
// }
[self.navigationController pushViewController:picVC animated:YES]; [self.navigationController pushViewController:picVC animated:YES];
} }
...@@ -356,6 +367,7 @@ ...@@ -356,6 +367,7 @@
[weakSelf setUpScrollViewWithDataArr:arrData bottomArr:arrBottom]; [weakSelf setUpScrollViewWithDataArr:arrData bottomArr:arrBottom];
[hud hide:YES]; [hud hide:YES];
NSLog(@"d"); NSLog(@"d");
} failure:^(id data) { } failure:^(id data) {
[hud hide:YES]; [hud hide:YES];
}]; }];
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#import "ICRHTTPController.h" #import "ICRHTTPController.h"
#import "AttachmentModel.h" #import "AttachmentModel.h"
#import "GalleryViewController.h" #import "GalleryViewController.h"
@interface SaleInputPicCollectionViewController () #import "UIScrollView+EmptyDataSet.h"
@interface SaleInputPicCollectionViewController ()<DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout; @property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout;
@end @end
...@@ -25,12 +26,32 @@ static NSString * const reuseIdentifier = @"saleInputCollection"; ...@@ -25,12 +26,32 @@ static NSString * const reuseIdentifier = @"saleInputCollection";
self.flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 20) / 3, 110.0 / 375 * SCREEN_WIDTH); self.flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 20) / 3, 110.0 / 375 * SCREEN_WIDTH);
self.flowLayout.minimumLineSpacing = 5; self.flowLayout.minimumLineSpacing = 5;
self.flowLayout.minimumInteritemSpacing = 5; self.flowLayout.minimumInteritemSpacing = 5;
self.collectionView.emptyDataSetSource = self;
self.collectionView.emptyDataSetDelegate = self;
[self setUpData]; [self setUpData];
} }
#pragma mark - empty state
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
return [UIImage imageNamed:@"no_data"];
}
- (CAAnimation *)imageAnimationForEmptyDataSet:(UIScrollView *)scrollView {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath: @"transform"];
animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2, 0.0, 0.0, 1.0)];
animation.duration = 1;
animation.cumulative = YES;
animation.repeatCount = MAXFLOAT;
return animation;
}
- (void)setUpData { - (void)setUpData {
NSString *url = [NSString stringWithFormat:@"attachment/get_urls?entity_type=salesInput&entity_uuid=%@",self.attachmentUuid]; NSString *url = [NSString stringWithFormat:@"attachment/get_urls?entity_type=salesInput&entity_uuid=%@", [self.attachmentUuid isKindOfClass:[NSString class]] ? self.attachmentUuid : nil];
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
[[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) { [[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="jdx-se-vyN"> <collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="jdx-se-vyN">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.91719922220000005" green="0.95656324439999996" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Trd-2Q-pij"> <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Trd-2Q-pij">
<size key="itemSize" width="152" height="111"/> <size key="itemSize" width="152" height="111"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/> <size key="headerReferenceSize" width="0.0" height="0.0"/>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</subviews> </subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view> </view>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.90196079019999997" green="0.90196079019999997" blue="0.90196079019999997" alpha="1" colorSpace="calibratedRGB"/>
<constraints> <constraints>
<constraint firstAttribute="bottom" secondItem="joQ-K1-fla" secondAttribute="bottom" id="6vL-nq-IUF"/> <constraint firstAttribute="bottom" secondItem="joQ-K1-fla" secondAttribute="bottom" id="6vL-nq-IUF"/>
<constraint firstAttribute="trailing" secondItem="joQ-K1-fla" secondAttribute="trailing" id="JEP-Mb-Shp"/> <constraint firstAttribute="trailing" secondItem="joQ-K1-fla" secondAttribute="trailing" id="JEP-Mb-Shp"/>
......
...@@ -25,24 +25,13 @@ ...@@ -25,24 +25,13 @@
#import "TZImagePickerController.h" #import "TZImagePickerController.h"
#import "UIImage+Helper.h" #import "UIImage+Helper.h"
#import "NSDate+FormatterAdditions.h" #import "NSDate+FormatterAdditions.h"
#import "CalculateHelper.h"
#define kCellCount 20 #define kCellCount 20
#define kCellID @"SalesInputTableViewCell.h" #define kCellID @"SalesInputTableViewCell.h"
#define kPicCellId @"SaleInputPictureTableViewCell.h" #define kPicCellId @"SaleInputPictureTableViewCell.h"
#define kAutoValue(value) (float)value / 375 * self.view.frame.size.width #define kAutoValue(value) (float)value / 375 * self.view.frame.size.width
/**
* colors
*/
#define kSysWhite [UIColor whiteColor]
//红 #ED1B23
#define kMainRedColor [UIColor colorWithRed:0.929 green:0.106 blue:0.137 alpha:1.000];
//蓝 #478FF1
#define kMainBlueColor [UIColor colorWithRed:0.278 green:0.561 blue:0.945 alpha:1.000];
//橙 #EA6402
#define kMainOrangeColor [UIColor colorWithRed:0.918 green:0.392 blue:0.008 alpha:1.000];
//紫 #5435AD
#define kMainPurpleColor [UIColor colorWithRed:0.329 green:0.208 blue:0.678 alpha:1.000];
#define kTabbarColor [UIColor colorWithWhite:0.973 alpha:1.000];
@interface SalesInputViewController ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> @interface SalesInputViewController ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
...@@ -93,7 +82,7 @@ ...@@ -93,7 +82,7 @@
} }
if (self.shop == nil) { if (self.shop == nil) {
[self.topView setShopName:@""]; [self.topView setShopName:@"请选择店铺"];
}else{ }else{
[self.topView setShopName:[NSString stringWithFormat:@"%@【%@】", self.shop.name, self.shop.code]]; [self.topView setShopName:[NSString stringWithFormat:@"%@【%@】", self.shop.name, self.shop.code]];
} }
...@@ -347,21 +336,17 @@ ON_WILL_APPEAR( signal ) ...@@ -347,21 +336,17 @@ ON_WILL_APPEAR( signal )
} }
- (void)countTotalMonney { - (void)countTotalMonney {
CGFloat count = 0; NSDecimalNumber *count = [NSDecimalNumber decimalNumberWithString:@"0"];
for (NSIndexPath *obj in self.cellDataDic.allKeys) { for (NSIndexPath *obj in self.cellDataDic.allKeys) {
NSArray *array = [self.cellDataDic objectForKey:obj]; NSArray *array = [self.cellDataDic objectForKey:obj];
CGFloat monney = [array[0] floatValue]; count = [CalculateHelper calculateNum1:count num2:array[0] type:CalculateTypeAdd roundingType:NSRoundBankers cutLenth:2];
count = count + monney;
} }
self.totalView.labelTotal.text = [NSString stringWithFormat:@"%.0f",count]; self.totalView.labelTotal.text = [count stringValue];
self.totalView.labelTotalAmount.text = [NSString stringWithFormat:@"%.0f", count + [self.todayTotalAmount floatValue]]; self.totalView.labelTotalAmount.text = [[CalculateHelper calculateNum1:count num2:self.todayTotalAmount type:CalculateTypeAdd roundingType:NSRoundBankers cutLenth:2] stringValue];
} }
- (id)viewWithNibName:(NSString *)viewName { - (id)viewWithNibName:(NSString *)viewName {
NSArray* nibView = [[NSBundle mainBundle] loadNibNamed:viewName owner:nil options:nil]; NSArray* nibView = [[NSBundle mainBundle] loadNibNamed:viewName owner:nil options:nil];
return [nibView objectAtIndex:0]; return [nibView objectAtIndex:0];
...@@ -430,15 +415,16 @@ ON_WILL_APPEAR( signal ) ...@@ -430,15 +415,16 @@ ON_WILL_APPEAR( signal )
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController]; ICRHTTPController *httpCtrl = [ICRHTTPController sharedController];
NSString *string = [NSString stringWithFormat:@"attachment/upload_by_file?entity_type=%@&entity_uuid=%@",@"salesInput",[NSString stringWithFormat:@"%@%@",self.shop.code, self.topView.textfieldDate.text]]; NSString *string = [NSString stringWithFormat:@"attachment/upload_by_file?entity_type=%@&entity_uuid=%@",@"salesInput",[NSString stringWithFormat:@"%@%@",self.shop.code, self.topView.textfieldDate.text]];
WS(weakSelf); WS(weakSelf);
[self.arrPics removeLastObject]; NSMutableArray *pics = [self.arrPics mutableCopy];
[httpCtrl POST:string pictures:self.arrPics param:nil complete:^(id responseObject, NSError *error) { [pics removeLastObject];
[httpCtrl POST:string pictures:pics param:nil complete:^(id responseObject, NSError *error) {
NSMutableArray *arrUuid = [NSMutableArray array]; NSMutableArray *arrUuid = [NSMutableArray array];
for (NSDictionary *data in responseObject[@"data"]) { for (NSDictionary *data in responseObject[@"data"]) {
[arrUuid addObject:data[@"uuid"]]; [arrUuid addObject:data[@"uuid"]];
} }
NSString *entityUuid = responseObject[@"data"][0][@"entityUuid"]; NSString *entityUuid = responseObject[@"data"][0][@"entityUuid"];
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController]; ICRHTTPController *httpCtrl = [ICRHTTPController sharedController];
NSDictionary *params = [weakSelf getParamsAttachmentUuid:entityUuid pictureUuids:arrUuid]; NSDictionary *params = [weakSelf getParamsAttachmentUuid:[NSString stringWithFormat:@"%@%@",weakSelf.shop.code, weakSelf.topView.textfieldDate.text] pictureUuids:arrUuid];
NSString *url = [NSString stringWithFormat:@"salesinput/submit?time=%@&operId=%@&operName=%@",[[NSDate date] httpParameterString], [[[VankeCommonModel sharedInstance] getLoginInfo] user_uuid], [[[VankeCommonModel sharedInstance] getLoginInfo] user_name]]; NSString *url = [NSString stringWithFormat:@"salesinput/submit?time=%@&operId=%@&operName=%@",[[NSDate date] httpParameterString], [[[VankeCommonModel sharedInstance] getLoginInfo] user_uuid], [[[VankeCommonModel sharedInstance] getLoginInfo] user_name]];
NSString *utf8String = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *utf8String = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
...@@ -468,19 +454,29 @@ ON_WILL_APPEAR( signal ) ...@@ -468,19 +454,29 @@ ON_WILL_APPEAR( signal )
PaymentTypeModel *model = self.arrPaymentType[i]; PaymentTypeModel *model = self.arrPaymentType[i];
NSDictionary *pay = @{@"payment" : model.name, NSDictionary *pay = @{@"payment" : model.name,
@"sortNumber" : model.sortNumber, @"sortNumber" : model.sortNumber,
@"transactions" : [NSNumber numberWithFloat: [bill floatValue]], @"transactions" : [NSDecimalNumber decimalNumberWithString:bill],
@"amount" : [NSNumber numberWithFloat: [amount floatValue]]}; @"amount" : [NSDecimalNumber decimalNumberWithString:amount]};
[lines addObject:pay]; [lines addObject:pay];
} }
NSDictionary *myDictionary = @{@"projectId" : self.authorizedOrg.code, NSDictionary *myDictionary;
@"shopCode" : self.shop.code, if (attachmentUuid) {
@"shopName" : self.shop.name, myDictionary = @{@"projectId" : self.authorizedOrg.code,
@"salesDate" : self.topView.textfieldDate.text, @"shopCode" : self.shop.code,
@"attachments" : pictures ? pictures : [NSNull null], @"shopName" : self.shop.name,
@"attachmentUuid" : attachmentUuid ? attachmentUuid : [NSNull null], @"salesDate" : self.topView.textfieldDate.text,
@"lines" : lines}; @"attachments" : pictures,
@"attachmentUuid" : attachmentUuid ? attachmentUuid : [NSNull null],
@"lines" : lines};
}else{
myDictionary = @{@"projectId" : self.authorizedOrg.code,
@"shopCode" : self.shop.code,
@"shopName" : self.shop.name,
@"salesDate" : self.topView.textfieldDate.text,
@"lines" : lines};
}
return myDictionary; return myDictionary;
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
- (void)setUpCellWithModel:(AttachmentModel *)model { - (void)setUpCellWithModel:(AttachmentModel *)model {
NSString *imageUrl; NSString *imageUrl;
if (model.fileUrl.length < 3) { if (model.fileUrl.length < 3) {
imageUrl = @"inspect_result_noupload"; imageUrl = @"floor-def";
}else{ }else{
imageUrl = [NSString stringWithFormat:@"%@%@",VANKE_SERVER_MEDIA_BASE_URL, model.fileUrl]; imageUrl = [NSString stringWithFormat:@"%@%@",VANKE_SERVER_MEDIA_BASE_URL, model.fileUrl];
} }
......
...@@ -43,12 +43,16 @@ ...@@ -43,12 +43,16 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.title = self.record.shopName;
NSDate *selectStart = [self getDateFromString:self.startDate]; NSDate *selectStart = [self getDateFromString:self.startDate];
NSDate *selectEnd = [self getDateFromString:self.endDate]; NSDate *selectEnd = [self getDateFromString:self.endDate];
[self setStart:selectStart]; [self setStart:selectStart];
[self setEnd:selectEnd]; [self setEnd:selectEnd];
self.textFieldStart.delegate = self; self.textFieldStart.delegate = self;
self.textFieldEnd.delegate = self; self.textFieldEnd.delegate = self;
self.tableView.emptyDataSetSource = self;
self.tableView.emptyDataSetDelegate = self;
self.tableView.tableFooterView = [UIView new];
[self setUpDatePicker]; [self setUpDatePicker];
[self setUpData]; [self setUpData];
} }
...@@ -99,10 +103,10 @@ ...@@ -99,10 +103,10 @@
[[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) { [[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) {
NSDictionary *dic = data; NSDictionary *dic = data;
weakSelf.detailModel = [StatementDetailModel modelObjectWithDictionary:dic[@"data"]]; weakSelf.detailModel = [StatementDetailModel modelObjectWithDictionary:dic[@"data"]];
weakSelf.title = weakSelf.detailModel.shopName;
weakSelf.labelShoudPay.text = [NSString stringWithFormat:@"应缴:%.2f", weakSelf.detailModel.amount]; weakSelf.labelShoudPay.text = [NSString stringWithFormat:@"%.2f", weakSelf.detailModel.amount];
weakSelf.labelPaid.text = [NSString stringWithFormat:@"已缴:%.2f",weakSelf.detailModel.paid]; weakSelf.labelPaid.text = [NSString stringWithFormat:@"%.2f",weakSelf.detailModel.paid];
weakSelf.labelUnpaid.text = [NSString stringWithFormat:@"未缴:%.2f",weakSelf.detailModel.unpaid]; weakSelf.labelUnpaid.text = [NSString stringWithFormat:@"%.2f",weakSelf.detailModel.unpaid];
//缴款率 //缴款率
NSString *paidRate = [CalculateHelper getPercent:[NSNumber numberWithDouble:weakSelf.detailModel.paid] num:[NSNumber numberWithDouble:weakSelf.detailModel.amount]]; NSString *paidRate = [CalculateHelper getPercent:[NSNumber numberWithDouble:weakSelf.detailModel.paid] num:[NSNumber numberWithDouble:weakSelf.detailModel.amount]];
...@@ -155,6 +159,9 @@ ...@@ -155,6 +159,9 @@
return animation; return animation;
} }
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
return -100;
}
#pragma mark - textfield delegate #pragma mark - textfield delegate
- (void)textFieldDidEndEditing:(UITextField *)textField { - (void)textFieldDidEndEditing:(UITextField *)textField {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
@property (weak, nonatomic) IBOutlet UILabel *labelFinishMonth; @property (weak, nonatomic) IBOutlet UILabel *labelFinishMonth;
@property (weak, nonatomic) IBOutlet UISearchBar *searchBar; @property (weak, nonatomic) IBOutlet UISearchBar *searchBar;
@property (nonatomic, strong) NSArray *arrFilter; @property (nonatomic, strong) NSArray *arrFilter;
@property (nonatomic, strong) NSMutableArray *arrClear; @property (nonatomic, strong) NSMutableArray *arrUnClear;
@property (weak, nonatomic) IBOutlet UIButton *btnIsClear; @property (weak, nonatomic) IBOutlet UIButton *btnIsClear;
...@@ -62,13 +62,15 @@ ...@@ -62,13 +62,15 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[[VankeAppBoard_iPhone sharedInstance] hideMenu]; [[VankeAppBoard_iPhone sharedInstance] hideMenu];
self.btnIsClear.selected = YES;
[self setDefaults]; [self setDefaults];
[self setUpDatePicker]; [self setUpDatePicker];
self.paramModel = [[StatementListParamModel alloc] init]; self.paramModel = [[StatementListParamModel alloc] init];
self.title = @"商铺对账单"; self.title = @"商铺对账单";
self.tableView.emptyDataSetSource = self; self.tableView.emptyDataSetSource = self;
self.tableView.emptyDataSetDelegate = self; self.tableView.emptyDataSetDelegate = self;
self.paramModel.pageSize = 999; self.tableView.tableFooterView = [UIView new];
self.paramModel.pageSize = 9999;
self.paramModel.pageNumber = 0; self.paramModel.pageNumber = 0;
[self setUpData]; [self setUpData];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
...@@ -102,8 +104,48 @@ ...@@ -102,8 +104,48 @@
- (IBAction)showSettleShop:(UIButton *)sender { - (IBAction)showSettleShop:(UIButton *)sender {
sender.selected = !sender.isSelected; sender.selected = !sender.isSelected;
[self.tableView reloadData]; [self.tableView reloadData];
[self calculateTop];
} }
/** 计算顶部 */
- (void)calculateTop {
NSDecimalNumber *totalPaid = nil;
NSDecimalNumber *totalUpPaid = nil;
NSDecimalNumber *totalAmount = nil;
if (self.searchBar.text.length > 0) {
for (int i = 0; i < self.arrFilter.count; i++) {
StatementRecords *record = self.arrFilter[i];
totalPaid = [CalculateHelper calculateNum1:totalPaid num2:[NSNumber numberWithDouble:record.paid] type:CalculateTypeAdd];
totalUpPaid = [CalculateHelper calculateNum1:totalUpPaid num2:[NSNumber numberWithDouble:record.unpaid] type:CalculateTypeAdd];
totalAmount = [CalculateHelper calculateNum1:totalAmount num2:[NSNumber numberWithDouble:record.amount] type:CalculateTypeAdd];
}
}else if(!self.btnIsClear.isSelected){
for (int i = 0; i < self.arrUnClear.count; i++) {
StatementRecords *record = self.arrUnClear[i];
totalPaid = [CalculateHelper calculateNum1:totalPaid num2:[NSNumber numberWithDouble:record.unpaid] type:CalculateTypeAdd];
totalUpPaid = [CalculateHelper calculateNum1:totalUpPaid num2:[NSNumber numberWithDouble:record.unpaid] type:CalculateTypeAdd];
totalAmount = [CalculateHelper calculateNum1:totalAmount num2:[NSNumber numberWithDouble:record.amount] type:CalculateTypeAdd];
}
}else{
self.labelTotalShouldPay.text = [CalculateHelper getMoneyStringFrom:[NSNumber numberWithDouble:self.statementModel.amount]];
self.labelTotalPaidIn.text = [CalculateHelper getMoneyStringFrom:[NSNumber numberWithDouble:self.statementModel.paidTotal]];
self.labelTotalUnPaid.text = [CalculateHelper getMoneyStringFrom:[NSNumber numberWithDouble:self.statementModel.unpaidTotal]];
self.labelTotalPaidPercent.text = [CalculateHelper getPercent:[NSNumber numberWithDouble:self.statementModel.paidTotal] num:[NSNumber numberWithDouble:self.statementModel.amount]];
return;
}
self.labelTotalShouldPay.text = [CalculateHelper getMoneyStringFrom:totalAmount];
self.labelTotalPaidIn.text = [CalculateHelper getMoneyStringFrom:totalPaid];
self.labelTotalUnPaid.text = [CalculateHelper getMoneyStringFrom:totalUpPaid];
self.labelTotalPaidPercent.text = [CalculateHelper getPercent:totalPaid num:totalAmount];
}
#pragma mark - SRMonthPickerDelegate #pragma mark - SRMonthPickerDelegate
- (void)monthPickerDidChangeDate:(SRMonthPicker *)monthPicker { - (void)monthPickerDidChangeDate:(SRMonthPicker *)monthPicker {
NSString *strDate = [monthPicker.date stringWithFormatter:@"%Y%m"]; NSString *strDate = [monthPicker.date stringWithFormatter:@"%Y%m"];
...@@ -131,12 +173,14 @@ ...@@ -131,12 +173,14 @@
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
NSPredicate *pred = [NSPredicate predicateWithFormat:@"shopName contains [cd] %@ OR shopCode contains [cd] %@", searchText, searchText]; NSPredicate *pred = [NSPredicate predicateWithFormat:@"shopName contains [cd] %@ OR shopCode contains [cd] %@", searchText, searchText];
self.arrFilter = [self.statementModel.records filteredArrayUsingPredicate:pred]; self.arrFilter = [self.statementModel.records filteredArrayUsingPredicate:pred];
[self calculateTop];
[self.tableView reloadData]; [self.tableView reloadData];
} }
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar { - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
searchBar.showsCancelButton = NO; searchBar.showsCancelButton = NO;
searchBar.text = nil; searchBar.text = nil;
[self calculateTop];
[self.tableView reloadData]; [self.tableView reloadData];
HIDE_KEYBOARD; HIDE_KEYBOARD;
} }
...@@ -149,25 +193,25 @@ ...@@ -149,25 +193,25 @@
/** 网络请求 */ /** 网络请求 */
- (void)setUpData { - (void)setUpData {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSString *url = [NSString stringWithFormat:@"statement/query/%@~%@?authorizedOrgIn=%@&pageNumber=%@&pageSize=%@", self.startDate, self.endDate, self.org.code, @0, @999]; NSString *url = [NSString stringWithFormat:@"statement/query/%@~%@?authorizedOrgIn=%@&pageNumber=%@&pageSize=%@", self.startDate, self.endDate, self.org.code, @0, @9999];
WS(weakSelf); WS(weakSelf);
[[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) { [[ICRHTTPController sharedController] getUrl:url params:nil success:^(id data) {
NSDictionary *dict = data; NSDictionary *dict = data;
CLog(@"%@", dict.JSONString); CLog(@"%@", dict.JSONString);
[IBTLoadingView showTips:data[@"message"]];
weakSelf.statementModel = [StatementModel modelObjectWithDictionary:dict[@"data"]]; weakSelf.statementModel = [StatementModel modelObjectWithDictionary:dict[@"data"]];
weakSelf.labelTotalShop.text = [NSString stringWithFormat:@"共%@家",[NSNumber numberWithDouble:weakSelf.statementModel.paging.recordCount]]; // weakSelf.labelTotalShop.text = [NSString stringWithFormat:@"共%@家",[NSNumber numberWithDouble:weakSelf.statementModel.paging.recordCount]];
weakSelf.labelTotalShouldPay.text = [NSString stringWithFormat:@"应缴:%@",[CalculateHelper getMoneyStringFrom:[NSNumber numberWithDouble:weakSelf.statementModel.amount]]];
weakSelf.labelTotalPaidIn.text = [NSString stringWithFormat:@"已缴:%@",[CalculateHelper getMoneyStringFrom:[NSNumber numberWithDouble:weakSelf.statementModel.paidTotal]]]; [weakSelf calculateTop];
weakSelf.labelTotalUnPaid.text = [NSString stringWithFormat:@"未缴:%@",[CalculateHelper getMoneyStringFrom:[NSNumber numberWithDouble:weakSelf.statementModel.unpaidTotal]]];
weakSelf.labelTotalPaidPercent.text = [CalculateHelper getPercent:[NSNumber numberWithDouble:weakSelf.statementModel.paidTotal] num:[NSNumber numberWithDouble:weakSelf.statementModel.amount]];
[weakSelf.tableView reloadData]; [weakSelf.tableView reloadData];
[weakSelf.arrUnClear removeAllObjects];
for (StatementRecords *records in weakSelf.statementModel.records) { for (StatementRecords *records in weakSelf.statementModel.records) {
if (records.unpaid == 0) { if (records.unpaid != 0) {
[weakSelf.arrClear addObject:records]; [weakSelf.arrUnClear addObject:records];
} }
} }
[hud hide:YES]; [hud hide:YES];
} failure:^(id data) { } failure:^(id data) {
[hud hide:YES]; [hud hide:YES];
...@@ -175,25 +219,25 @@ ...@@ -175,25 +219,25 @@
} }
#pragma mark - tableView DataSource #pragma mark - tableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (self.searchBar.isFirstResponder) { if (self.searchBar.text.length > 0) {
return self.arrFilter.count; return self.arrFilter.count;
}else if(self.btnIsClear.isSelected){ }else if(!self.btnIsClear.isSelected){
return self.arrClear.count; return self.arrUnClear.count;
}else{ }else{
return self.statementModel.records.count; return self.statementModel.records.count;
} }
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
StatementTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StatementCell" forIndexPath:indexPath]; StatementTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StatementCell" forIndexPath:indexPath];
if (self.searchBar.isFirstResponder) { if (self.searchBar.text.length > 0) {
[cell setUpCellWithArray:self.arrFilter index:indexPath]; [cell setUpCellWithArray:self.arrFilter index:indexPath];
}else if(self.btnIsClear.isSelected){ }else if(!self.btnIsClear.isSelected){
[cell setUpCellWithArray:self.arrClear index:indexPath]; [cell setUpCellWithArray:self.arrUnClear index:indexPath];
}else{ }else{
[cell setUpCellWithArray:self.statementModel.records index:indexPath]; [cell setUpCellWithArray:self.statementModel.records index:indexPath];
} }
...@@ -208,13 +252,14 @@ ...@@ -208,13 +252,14 @@
StatementDetailViewController *detailVC = [self controllerWithIdentifier:@"StatementDetailViewController"]; StatementDetailViewController *detailVC = [self controllerWithIdentifier:@"StatementDetailViewController"];
detailVC.startDate = self.startDate; detailVC.startDate = self.startDate;
detailVC.endDate = self.endDate; detailVC.endDate = self.endDate;
if (self.searchBar.isFirstResponder) { if (self.searchBar.text.length > 0) {
detailVC.record = self.arrFilter[indexPath.row]; detailVC.record = self.arrFilter[indexPath.row];
}else if(self.btnIsClear.isSelected){ }else if(!self.btnIsClear.isSelected){
detailVC.record = self.arrClear[indexPath.row]; detailVC.record = self.arrUnClear[indexPath.row];
}else{ }else{
detailVC.record = self.statementModel.records[indexPath.row]; detailVC.record = self.statementModel.records[indexPath.row];
} }
[self.navigationController pushViewController:detailVC animated:YES]; [self.navigationController pushViewController:detailVC animated:YES];
} }
...@@ -234,7 +279,7 @@ ...@@ -234,7 +279,7 @@
animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2, 0.0, 0.0, 1.0)]; animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2, 0.0, 0.0, 1.0)];
animation.duration = 0.25; animation.duration = 1;
animation.cumulative = YES; animation.cumulative = YES;
animation.repeatCount = MAXFLOAT; animation.repeatCount = MAXFLOAT;
...@@ -247,11 +292,11 @@ ...@@ -247,11 +292,11 @@
#pragma mark - lazyloading #pragma mark - lazyloading
- (NSMutableArray *)arrClear { - (NSMutableArray *)arrUnClear {
if (!_arrClear) { if (!_arrUnClear) {
_arrClear = [NSMutableArray array]; _arrUnClear = [NSMutableArray array];
} }
return _arrClear; return _arrUnClear;
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
......
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