Commit 6f8b9b12 authored by Sandy's avatar Sandy

销售录入上传图片

parent 40d85842
......@@ -28,8 +28,16 @@
1912FCE51CCDF1F6004CF976 /* SalesInputCommitView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1912FCE41CCDF1F6004CF976 /* SalesInputCommitView.xib */; };
1912FCE81CCDF20F004CF976 /* SalesInputCommitView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1912FCE71CCDF20F004CF976 /* SalesInputCommitView.m */; };
1912FCF41CCF1493004CF976 /* ChooseProjectTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1912FCF31CCF1493004CF976 /* ChooseProjectTableViewController.m */; };
196F0F3D1D339D8C0047300A /* ReportViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 196F0F3B1D339D8C0047300A /* ReportViewController.m */; };
196F0F3E1D339D8C0047300A /* ReportViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 196F0F3C1D339D8C0047300A /* ReportViewController.xib */; };
19994DA61D34D7D60089A129 /* SaleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DA51D34D7D60089A129 /* SaleViewController.m */; };
19994DA91D34D96F0089A129 /* Compass.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DA81D34D96F0089A129 /* Compass.m */; };
19994DAC1D34D99F0089A129 /* SaleViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DAB1D34D99F0089A129 /* SaleViewCell.m */; };
19994DAF1D34D9B10089A129 /* SaleHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DAE1D34D9B10089A129 /* SaleHeaderView.m */; };
19994DB21D34D9D40089A129 /* RSaleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DB11D34D9D30089A129 /* RSaleView.m */; };
19994DB61D34F9490089A129 /* ReportViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DB51D34F9490089A129 /* ReportViewController.m */; };
19994DB91D34F9A40089A129 /* CustomSegView.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DB81D34F9A40089A129 /* CustomSegView.m */; };
19994DBC1D34FFB70089A129 /* FinishTimeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DBB1D34FFB70089A129 /* FinishTimeView.m */; };
19994DBF1D3500030089A129 /* QueryOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = 19994DBE1D3500030089A129 /* QueryOrder.m */; };
19D76A881D265A1B006245D6 /* TZAssetCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 19D76A761D265A1B006245D6 /* TZAssetCell.m */; };
19D76A891D265A1B006245D6 /* TZAssetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 19D76A781D265A1B006245D6 /* TZAssetModel.m */; };
19D76A8A1D265A1B006245D6 /* TZImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 19D76A7A1D265A1B006245D6 /* TZImageManager.m */; };
......@@ -781,9 +789,26 @@
1912FCE71CCDF20F004CF976 /* SalesInputCommitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SalesInputCommitView.m; sourceTree = "<group>"; };
1912FCF21CCF1493004CF976 /* ChooseProjectTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChooseProjectTableViewController.h; sourceTree = "<group>"; };
1912FCF31CCF1493004CF976 /* ChooseProjectTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChooseProjectTableViewController.m; sourceTree = "<group>"; };
196F0F3A1D339D8C0047300A /* ReportViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReportViewController.h; sourceTree = "<group>"; };
196F0F3B1D339D8C0047300A /* ReportViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReportViewController.m; sourceTree = "<group>"; };
196F0F3C1D339D8C0047300A /* ReportViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReportViewController.xib; sourceTree = "<group>"; };
19994DA41D34D7D60089A129 /* SaleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaleViewController.h; sourceTree = "<group>"; };
19994DA51D34D7D60089A129 /* SaleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaleViewController.m; sourceTree = "<group>"; };
19994DA71D34D96F0089A129 /* Compass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compass.h; sourceTree = "<group>"; };
19994DA81D34D96F0089A129 /* Compass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Compass.m; sourceTree = "<group>"; };
19994DAA1D34D99F0089A129 /* SaleViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaleViewCell.h; sourceTree = "<group>"; };
19994DAB1D34D99F0089A129 /* SaleViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaleViewCell.m; sourceTree = "<group>"; };
19994DAD1D34D9B10089A129 /* SaleHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaleHeaderView.h; sourceTree = "<group>"; };
19994DAE1D34D9B10089A129 /* SaleHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaleHeaderView.m; sourceTree = "<group>"; };
19994DB01D34D9D30089A129 /* RSaleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RSaleView.h; sourceTree = "<group>"; };
19994DB11D34D9D30089A129 /* RSaleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RSaleView.m; sourceTree = "<group>"; };
19994DB31D34ED160089A129 /* OtherHeaders.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OtherHeaders.h; sourceTree = "<group>"; };
19994DB41D34F9490089A129 /* ReportViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReportViewController.h; sourceTree = "<group>"; };
19994DB51D34F9490089A129 /* ReportViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReportViewController.m; sourceTree = "<group>"; };
19994DB71D34F9A40089A129 /* CustomSegView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomSegView.h; sourceTree = "<group>"; };
19994DB81D34F9A40089A129 /* CustomSegView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomSegView.m; sourceTree = "<group>"; };
19994DBA1D34FFB70089A129 /* FinishTimeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FinishTimeView.h; sourceTree = "<group>"; };
19994DBB1D34FFB70089A129 /* FinishTimeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FinishTimeView.m; sourceTree = "<group>"; };
19994DBD1D3500030089A129 /* QueryOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueryOrder.h; sourceTree = "<group>"; };
19994DBE1D3500030089A129 /* QueryOrder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueryOrder.m; sourceTree = "<group>"; };
19D76A751D265A1B006245D6 /* TZAssetCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZAssetCell.h; sourceTree = "<group>"; };
19D76A761D265A1B006245D6 /* TZAssetCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZAssetCell.m; sourceTree = "<group>"; };
19D76A771D265A1B006245D6 /* TZAssetModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZAssetModel.h; sourceTree = "<group>"; };
......@@ -2111,8 +2136,10 @@
196F0F391D339D140047300A /* report(报表) */ = {
isa = PBXGroup;
children = (
196F0F3A1D339D8C0047300A /* ReportViewController.h */,
196F0F3B1D339D8C0047300A /* ReportViewController.m */,
19994DB41D34F9490089A129 /* ReportViewController.h */,
19994DB51D34F9490089A129 /* ReportViewController.m */,
19994DA41D34D7D60089A129 /* SaleViewController.h */,
19994DA51D34D7D60089A129 /* SaleViewController.m */,
196F0F3C1D339D8C0047300A /* ReportViewController.xib */,
196F0F3F1D339DB60047300A /* Model */,
196F0F401D339DB60047300A /* Views */,
......@@ -2124,6 +2151,8 @@
196F0F3F1D339DB60047300A /* Model */ = {
isa = PBXGroup;
children = (
19994DA71D34D96F0089A129 /* Compass.h */,
19994DA81D34D96F0089A129 /* Compass.m */,
);
path = Model;
sourceTree = "<group>";
......@@ -2131,6 +2160,18 @@
196F0F401D339DB60047300A /* Views */ = {
isa = PBXGroup;
children = (
19994DBD1D3500030089A129 /* QueryOrder.h */,
19994DBE1D3500030089A129 /* QueryOrder.m */,
19994DBA1D34FFB70089A129 /* FinishTimeView.h */,
19994DBB1D34FFB70089A129 /* FinishTimeView.m */,
19994DB71D34F9A40089A129 /* CustomSegView.h */,
19994DB81D34F9A40089A129 /* CustomSegView.m */,
19994DAA1D34D99F0089A129 /* SaleViewCell.h */,
19994DAB1D34D99F0089A129 /* SaleViewCell.m */,
19994DAD1D34D9B10089A129 /* SaleHeaderView.h */,
19994DAE1D34D9B10089A129 /* SaleHeaderView.m */,
19994DB01D34D9D30089A129 /* RSaleView.h */,
19994DB11D34D9D30089A129 /* RSaleView.m */,
);
path = Views;
sourceTree = "<group>";
......@@ -2860,6 +2901,7 @@
C10F18531BF8AAC90065F18C /* zh-Hans.lproj */,
C1D58B331BB1BC9200D297FE /* main.m */,
C1D58B381BB1BC9200D297FE /* vanke.pch */,
19994DB31D34ED160089A129 /* OtherHeaders.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
......@@ -4771,6 +4813,7 @@
C10F183F1BF7ACA80065F18C /* IBTSegmentedControl.m in Sources */,
C1D599711BB44B2100D297FE /* ASIAuthenticationDialog.m in Sources */,
C10F18451BF7ACA80065F18C /* IBTUILabel.m in Sources */,
19994DAC1D34D99F0089A129 /* SaleViewCell.m in Sources */,
C1A026241C12C9B400737937 /* VankeSettlementSubjectListAPI.m in Sources */,
C1D598941BB44B2000D297FE /* Bee_UICapability.m in Sources */,
C1D599721BB44B2100D297FE /* ASIDataCompressor.m in Sources */,
......@@ -4840,7 +4883,6 @@
C1D598901BB44B2000D297FE /* UILabel+UIDataBinding.m in Sources */,
C1D598761BB44B2000D297FE /* UICheck+BeeUIStyle.m in Sources */,
C1D5994A1BB44B2100D297FE /* NSObject+BeeTimer.mm in Sources */,
196F0F3D1D339D8C0047300A /* ReportViewController.m in Sources */,
C10F18361BF7ACA80065F18C /* IBTTableViewInfo.m in Sources */,
C1D599051BB44B2000D297FE /* BeeViewModel+BeeUISignal.m in Sources */,
C1D598861BB44B2000D297FE /* Bee_UIAnimation.m in Sources */,
......@@ -4850,8 +4892,10 @@
C1D598411BB44B2000D297FE /* Bee_Package.mm in Sources */,
C1D598BF1BB44B2000D297FE /* UIView+PinchGesture.m in Sources */,
C1D599891BB44B2100D297FE /* CXMLNamespaceNode.m in Sources */,
19994DBF1D3500030089A129 /* QueryOrder.m in Sources */,
19000E871CC6215000DF8D71 /* HistoryViewController.m in Sources */,
C18A952E1C01E84E00429BF7 /* ICRAnnouncement.m in Sources */,
19994DB91D34F9A40089A129 /* CustomSegView.m in Sources */,
C1D599471BB44B2100D297FE /* NSObject+BeeNotification.mm in Sources */,
C18A953B1C01E8E100429BF7 /* ICRAttachmentCellContentView.m in Sources */,
C1D5996D1BB44B2100D297FE /* Bee_Socket.m in Sources */,
......@@ -4969,6 +5013,7 @@
C1D598421BB44B2000D297FE /* Bee_Version.mm in Sources */,
C1D598E01BB44B2000D297FE /* UIImageView+BeeUILayout.m in Sources */,
C1D599341BB44B2100D297FE /* Bee_Foundation.mm in Sources */,
19994DA61D34D7D60089A129 /* SaleViewController.m in Sources */,
C10F18431BF7ACA80065F18C /* IBTUIButton.m in Sources */,
C10F18311BF7ACA80065F18C /* ICRSyncCellContentView.m in Sources */,
C19ADE381BC80DD400206213 /* VankeSaleVolumeAPI.m in Sources */,
......@@ -5028,9 +5073,11 @@
C1D5996E1BB44B2100D297FE /* Bee_Resource.mm in Sources */,
C1D5984B1BB44B2000D297FE /* BeeMessage+BeeActiveRecord.mm in Sources */,
C1D599011BB44B2000D297FE /* UIView+Transition.m in Sources */,
19994DAF1D34D9B10089A129 /* SaleHeaderView.m in Sources */,
C1D598A21BB44B2000D297FE /* Bee_UIImagePickerController.m in Sources */,
C1D5994E1BB44B2100D297FE /* NSString+BeeExtension.mm in Sources */,
C1D598641BB44B2000D297FE /* BeeUIStack+BackwardCompatible.m in Sources */,
19994DB21D34D9D40089A129 /* RSaleView.m in Sources */,
C1D598A51BB44B2000D297FE /* Bee_UILabel.m in Sources */,
C1D5997F1BB44B2100D297FE /* OpenUDID.m in Sources */,
19000E8D1CC6215000DF8D71 /* SalesInputTopView.m in Sources */,
......@@ -5076,6 +5123,7 @@
C1D598DD1BB44B2000D297FE /* Bee_UILayoutContainer.m in Sources */,
C1D598871BB44B2000D297FE /* Bee_UIAnimationAlpha.m in Sources */,
C1D5986F1BB44B2000D297FE /* Bee_UIStyle.m in Sources */,
19994DA91D34D96F0089A129 /* Compass.m in Sources */,
C1D5989D1BB44B2000D297FE /* Bee_UIButton.m in Sources */,
C1D599281BB44B2100D297FE /* Bee_ActiveObject.m in Sources */,
C1D5994D1BB44B2100D297FE /* NSString+BeeEmoji.m in Sources */,
......@@ -5227,6 +5275,7 @@
C16BA6231BD393B7001ACB26 /* VankePassengerDetailBoard_iPhone.m in Sources */,
C1D598CE1BB44B2000D297FE /* Bee_UIZoomView.m in Sources */,
C10F18321BF7ACA80065F18C /* ICRSystemHeaderView.m in Sources */,
19994DBC1D34FFB70089A129 /* FinishTimeView.m in Sources */,
C1D598801BB44B2000D297FE /* CSSRuleSet.m in Sources */,
C1D598441BB44B2000D297FE /* Bee_MVC.mm in Sources */,
C10F18171BF7ACA80065F18C /* UIColor+Helper.m in Sources */,
......@@ -5242,6 +5291,7 @@
C1D598771BB44B2000D297FE /* UIImageView+BeeUIStyle.m in Sources */,
C17ABD521BFCD92200908573 /* VankeStatementDetailMonthCell_iPhone.m in Sources */,
C10F18281BF7ACA80065F18C /* ICRAttachmentView.m in Sources */,
19994DB61D34F9490089A129 /* ReportViewController.m in Sources */,
C1D5992B1BB44B2100D297FE /* Bee_Database.mm in Sources */,
C1D599021BB44B2000D297FE /* UIViewController+Transition.m in Sources */,
C1D598AE1BB44B2000D297FE /* Bee_UISegmentedControl.m in Sources */,
......
......@@ -20,5 +20,6 @@
@returns color from rgbValue
*/
+ (UIColor *)colorFromHex:(int32_t)rgbValue;
+ (UIColor *)colorWithHexString: (NSString *)color;
@end
......@@ -24,4 +24,47 @@
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0];
}
+ (UIColor *)colorWithHexString: (NSString *)color
{
NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
// String should be 6 or 8 characters
if ([cString length] < 6) {
return [UIColor clearColor];
}
// strip 0X if it appears
if ([cString hasPrefix:@"0X"])
cString = [cString substringFromIndex:2];
if ([cString hasPrefix:@"#"])
cString = [cString substringFromIndex:1];
if ([cString length] != 6)
return [UIColor clearColor];
// Separate into r, g, b substrings
NSRange range;
range.location = 0;
range.length = 2;
//r
NSString *rString = [cString substringWithRange:range];
//g
range.location = 2;
NSString *gString = [cString substringWithRange:range];
//b
range.location = 4;
NSString *bString = [cString substringWithRange:range];
// Scan values
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
//NSLog(@"%d,%d,%d",r,g,b);
return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];
}
@end
......@@ -761,5 +761,39 @@ acceptTypeJson:YES
}
#pragma mark - 报表首页,数据罗盘
- (void)queryHomepageWith:(id)data
success:(void (^)(id))succ
failure:(void (^)(id))fail{
if (!data) {
if (fail) {
fail( [[self class] ErrorWithMsg:ERROR_PARAMETER code:0] );
}
return;
}
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject);
if (succ) {
succ( responseObject );
}
};
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
CLog(@"%@", error);
if (fail) {
fail( error );
}
};
NSDictionary *dict = data;
NSString *urlStr = [[self class] UrlForPluginHTTPAction:@"salesdata/query"];
[self POST:urlStr
parameters:dict
needToken:NO
acceptTypeJson:YES
success:success
failure:failure];
}
@end
......@@ -32,4 +32,30 @@
+ (IBTFileData *)saveImageToLocal:(UIImage *)imageToSave;
+ (NSDate *)convertToDateFrom:(NSString *)dateString;
+ (NSString *)stringFromDate:(NSDate*)aDate;
+ (NSString *)stringFromDateWithFormat:(NSDate*)aDate format:(NSString *)format;
+ (NSDate *)dateFromStringWithFormat:(NSString*)aStr format:(NSString *)format;
+ (NSString*)dictionaryToJson:(id)dic;
+ (NSString *)checkString:(NSString *)str;
+ (NSString *)checkNull: (id)data;
+ (BOOL)checkStringIsNilOrSpance: (NSString *)str;
+ (NSMutableAttributedString *)setTextViewFontOfString:(NSString *)string paragraphStyle:(NSInteger)lineHeight fontSize:(float)size color:(UIColor *)color;
+ (NSMutableAttributedString *)setTextViewBoldFontOfString:(NSString *)string paragraphStyle:(NSInteger)lineHeight fontSize:(float)size color:(UIColor *)color;
+ (NSString *)trimmingCharacters:(NSString *)str;
+ (int)compareDate:(NSString*)oneDate withDate:(NSString*)twoDate;
+(UILabel *)labelWithTitle:(NSString *)title frame:(CGRect)frame textFont:(UIFont *)titleFont;
+ (UIButton *)buttonWithTitle:(NSString *)title Image:(UIImage *)image frame:(CGRect)frame fontSize:(float)fontSize fontColor:(UIColor *)color;
+ (UIButton *)buttonWithImage:(UIImage *)image frame:(CGRect)frame;
+ (NSString *)getWeekFromDate;
+ (NSString *)getWeekFromDateWithDate: (NSDate *)date;
+ (NSInteger)getWeeks:(NSInteger)year;
+ (NSString*)weekdayStringFromDate:(NSDate*)inputDate;
+(NSString *)countNumAndChangeformat:(NSString *)num;
+ (NSString *)getWeekFromDateStr:(NSString *)dataStr;
+(NSString *)stringDisposeWithFloat:(float)floatValue;
@end
......@@ -172,4 +172,261 @@
}
}
+ (NSDate *)convertToDateFrom:(NSString *)dateString{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy.MM.dd"];
return [formatter dateFromString:dateString];
}
+ (NSDate *)convertToDateFromStr:(NSString *)dateString{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
return [formatter dateFromString:dateString];
}
+ (NSString *)stringFromDate:(NSDate*)aDate{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd "];
NSString *dateString = [formatter stringFromDate:aDate];
return dateString;
}
+ (NSString *)stringFromDateWithFormat:(NSDate*)aDate format:(NSString *)format {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:format];
NSString *dateString = [formatter stringFromDate:aDate];
return dateString;
}
+ (NSDate *)dateFromStringWithFormat:(NSString*)aStr format:(NSString *)format {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:format];
NSDate *date = [formatter dateFromString:aStr];
return date;
}
+ (NSString*)dictionaryToJson:(id)dic
{
NSError *parseError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
+ (NSString *)checkString:(NSString *)str
{
return (str)?str:@"";
}
+ (NSString *)checkNull:(id)data {
return data == [NSNull null] ? @"" : data;
}
+ (BOOL)checkStringIsNilOrSpance:(NSString *)str {
if (!str || [str isEqualToString:@"" ] || [str isEqual:[NSNull null]]) {
return YES;
} else {
return NO;
}
}
+ (NSMutableAttributedString *)setTextViewFontOfString:(NSString *)string paragraphStyle:(NSInteger)lineHeight fontSize:(float)size color:(UIColor *)color {
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.lineSpacing = lineHeight;
NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:size],NSForegroundColorAttributeName :color, NSParagraphStyleAttributeName:paragraphStyle};
NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:string attributes:attributes];
return attributeStr;
}
+ (NSMutableAttributedString *)setTextViewBoldFontOfString:(NSString *)string paragraphStyle:(NSInteger)lineHeight fontSize:(float)size color:(UIColor *)color {
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.lineSpacing = lineHeight;
NSDictionary *attributes = @{ NSFontAttributeName:[UIFont boldSystemFontOfSize:size],NSForegroundColorAttributeName :color, NSParagraphStyleAttributeName:paragraphStyle};
NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:string attributes:attributes];
return attributeStr;
}
+ (NSString *)trimmingCharacters:(NSString *)str{
NSString *newStr = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
return newStr;
}
+ (int)compareDate:(NSString*)oneDate withDate:(NSString*)twoDate{
int ci;
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *dt1 = [[NSDate alloc] init];
NSDate *dt2 = [[NSDate alloc] init];
dt1 = [df dateFromString:oneDate];
dt2 = [df dateFromString:twoDate];
NSComparisonResult result = [dt1 compare:dt2];
switch (result)
{
//date02比date01大
case NSOrderedAscending: ci=1; break;
//date02比date01小
case NSOrderedDescending: ci=-1; break;
//date02=date01
case NSOrderedSame: ci=0; break;
default: NSLog(@"erorr dates %@, %@", dt2, dt1); break;
}
return ci;
}
+(UILabel *)labelWithTitle:(NSString *)title frame:(CGRect)frame textFont:(UIFont *)titleFont
{
UILabel * titleLabel = [[UILabel alloc] initWithFrame:frame];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = titleFont;
titleLabel.textColor = [UIColor blackColor];
titleLabel.numberOfLines = 1;
//设置文字过长时的显示格式,截去尾部...
titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
titleLabel.text=title;
return titleLabel;
}
+ (UIButton *)buttonWithTitle:(NSString *)title Image:(UIImage *)image frame:(CGRect)frame fontSize:(float)fontSize fontColor:(UIColor *)color
{
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:title forState:UIControlStateNormal];
button.frame = frame;
button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
if (image) {
[button setImage:image forState:UIControlStateNormal];
}
[button setTitleColor:color forState:UIControlStateNormal];
return button;
}
+ (UIButton *)buttonWithImage:(UIImage *)image frame:(CGRect)frame
{
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = frame;
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[button setImage:image forState:UIControlStateNormal];
return button;
}
+ (NSString *)getWeekFromDate{
NSString *yearWeek = @"";
NSCalendar *greCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [greCalendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSWeekOfMonthCalendarUnit | NSWeekOfYearCalendarUnit fromDate:[NSDate date]];
NSString *yearStr = [IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM-dd"];
NSString *year = [yearStr substringToIndex:4];
NSString *month = [yearStr substringWithRange:NSMakeRange(5,2)];
if (dateComponents.weekOfYear == 1 && [month isEqualToString:@"12"]) {
yearWeek = [NSString stringWithFormat:@"%ld-%ld", [year integerValue]+1
,(long)dateComponents.weekOfYear];
}else{
yearWeek = [NSString stringWithFormat:@"%ld-%ld", (long)[year integerValue]
,(long)dateComponents.weekOfYear];
}
return yearWeek;
}
+ (NSString *)getWeekFromDateWithDate: (NSDate *)date{
NSString *yearWeek = @"";
NSCalendar *greCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [greCalendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSWeekOfMonthCalendarUnit | NSWeekOfYearCalendarUnit fromDate:date];
NSString *yearStr = [IBTCommon stringFromDateWithFormat:date format:@"yyyy-MM-dd"];
NSString *year = [yearStr substringToIndex:4];
NSString *month = [yearStr substringWithRange:NSMakeRange(5,2)];
if (dateComponents.weekOfYear == 1 && [month isEqualToString:@"12"]) {
yearWeek = [NSString stringWithFormat:@"%ld-%ld", [year integerValue]+1
,(long)dateComponents.weekOfYear];
}else{
yearWeek = [NSString stringWithFormat:@"%ld-%ld", (long)[year integerValue]
,(long)dateComponents.weekOfYear];
}
return yearWeek;
}
+ (NSInteger)getWeeks:(NSInteger)year{
NSInteger weeks = 0;
NSString *dateStr = [NSString stringWithFormat:@"%ld-12-31 00:00:00",(long)year];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSWeekOfMonthCalendarUnit | NSWeekOfYearCalendarUnit ;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:dateStr];
NSDateComponents *comps = [calendar components:unitFlags fromDate:date];
weeks = [comps weekOfYear];
if (weeks==1) {
return 52;
}else{
return 53;
}
}
+ (NSString*)weekdayStringFromDate:(NSDate *)inputDate{
NSArray *weekdays = [NSArray arrayWithObjects: [NSNull null], @"星期日", @"星期一", @"星期二", @"星期三", @"星期四", @"星期五", @"星期六", nil];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
[calendar setTimeZone: timeZone];
NSCalendarUnit calendarUnit = NSCalendarUnitWeekday;
NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:inputDate];
return [weekdays objectAtIndex:theComponents.weekday];
}
+(NSString *)countNumAndChangeformat:(NSString *)num{
int count = 0;
long long int a = num.longLongValue;
while (a != 0)
{
count++;
a /= 10;
}
NSMutableString *string = [NSMutableString stringWithString:num];
NSMutableString *newstring = [NSMutableString string];
while (count > 3) {
count -= 3;
NSRange rang = NSMakeRange(string.length - 3, 3);
NSString *str = [string substringWithRange:rang];
[newstring insertString:str atIndex:0];
[newstring insertString:@"," atIndex:0];
[string deleteCharactersInRange:rang];
}
[newstring insertString:string atIndex:0];
return newstring;
}
+ (NSString *)stringDisposeWithFloat:(float)floatValue
{
NSString *str = [NSString stringWithFormat:@"%.2f",floatValue];
NSInteger len = str.length;
for (int i = 0; i < len; i++)
{
if (![str hasSuffix:@"0"])
break;
else
str = [str substringToIndex:[str length]-1];
}
if ([str hasSuffix:@"."])//避免像2.0000这样的被解析成2.
{
return [str substringToIndex:[str length]-1];//s.substring(0, len - i - 1);
}
else
{
return str;
}
}
@end
......@@ -23,5 +23,15 @@
color:(UIColor *)color
target:(id)target
action:(SEL)selector;
+ (UIButton *)creatButtonWithFrame:(CGRect)frame target:(id)target sel:(SEL)sel tag:(NSInteger)tag image:(NSString *)name title:(NSString *)title titleColor:(UIColor *)titleCorlor isCorner:(BOOL)isCornor corner:(CGFloat)corner bgColor:(UIColor *)bgcolor;
#pragma mark - border
- (void)addTopBorderWithHeight:(CGFloat)height color:(UIColor *)color;
- (void)addBottomBorderWithHeight:(CGFloat)height color:(UIColor *)color;
- (void)addLeftBorderWithWidth:(CGFloat)width color:(UIColor *)color;
- (void)addRightBorderWithWidth:(CGFloat)width color:(UIColor *)color;
@end
......@@ -65,4 +65,65 @@
return button;
}
+ (UIButton *)creatButtonWithFrame:(CGRect)frame target:(id)target sel:(SEL)sel tag:(NSInteger)tag image:(NSString *)name title:(NSString *)title titleColor:(UIColor *)titleCorlor isCorner:(BOOL)isCornor corner:(CGFloat)corner bgColor:(UIColor *)bgcolor{
UIButton *button = nil;
button = [UIButton buttonWithType:UIButtonTypeCustom];
if (name) {//创建图片按钮
[button setImage:[UIImage imageNamed:name] forState:UIControlStateNormal];
if (title) {
//创建 图片 和 标题按钮
[button setTitle:title forState:UIControlStateNormal];
[button setTitleColor:titleCorlor forState:UIControlStateNormal];
}
}else if(title){//创建标题按钮
[button setBackgroundColor:bgcolor];
[button setTitle:title forState:UIControlStateNormal];
[button setTitleColor:titleCorlor forState:UIControlStateNormal];
}
button.frame = frame;
button.tag = tag;
if (isCornor) {
button.layer.cornerRadius = corner;
button.layer.masksToBounds = YES;
}
[button addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
return button;
}
#pragma mark - border
- (void)addTopBorderWithHeight:(CGFloat)height color:(UIColor *)color
{
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, 0, self.frame.size.width, height);
layer.backgroundColor = color.CGColor;
[self.layer addSublayer:layer];
}
- (void)addBottomBorderWithHeight:(CGFloat)height color:(UIColor *)color
{
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, self.frame.size.height - height, self.frame.size.width, height);
layer.backgroundColor = color.CGColor;
[self.layer addSublayer:layer];
}
- (void)addLeftBorderWithWidth:(CGFloat)width color:(UIColor *)color
{
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, 0, width, self.frame.size.height);
layer.backgroundColor = color.CGColor;
[self.layer addSublayer:layer];
}
- (void)addRightBorderWithWidth:(CGFloat)width color:(UIColor *)color
{
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(self.frame.size.width - width, 0, width, self.frame.size.height);
layer.backgroundColor = color.CGColor;
[self.layer addSublayer:layer];
}
@end
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "sale_1@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "sale_1@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "salebg_1@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "salebg_1@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// XFFruiteHeaders.h
// vanke
//
// Created by Z on 16/7/12.
// Copyright © 2016年 gomore. All rights reserved.
//
#ifndef OtherHeaders_h
#define OtherHeaders_h
#import "IBTCommon.h"
#import "UIColor+Helper.h"
#import "IBTCustomButtom.h"
#import "VankeCommonModel.h"
#import "ICRHTTPController.h"
#define KNOTIFICATION_GetNextDetailData @"KNOTIFICATION_GetNextDetailData"
#define KNOTIFICATION_GoReportDetail @"KNOTIFICATION_GoReportDetail"
#define HexColor(colorStr) [UIColor colorWithHexString:colorStr]
#define GXF_NAVIGAYION_COLOR HexColor(@"7ebf74")
#define GXF_SAVE_COLOR HexColor(@"50bd62")
#define GXF_COMMIT_COLOR HexColor(@"f69100")
#define GXF_PLACEHOLDER_COLOR HexColor(@"bbbbbb")
#define GXF_CONTENT_COLOR HexColor(@"444444")
#define GXF_CELL_COLOR HexColor(@"aaaaaa")
#define GXF_LINE_COLOR HexColor(@"e5e5e5")
#define GXF_DETAIL_COLOR HexColor(@"888888")
#define GXF_LEFTSIX_COLOR HexColor(@"666666")
//报表统一颜色
#define ReportColor GXF_NAVIGAYION_COLOR
#define ReportContentColor HexColor(@"f4422e")
#define ReportTitleColor GXF_PLACEHOLDER_COLOR
#define ReportBgColor RGBA(219,219,219,1)
#define ReportTwoColor HexColor(@"A3A3A3")
#define ReportChainSignPlus @"plus"
#define ReportChainSignMinus @"minus"
#define ReportChainPlusImage @"goSale"
#define ReportChainMinusImage @"downSale"
//销售
#define SaleDay @"日"
#define SaleWeek @"周"
#define SaleMonth @"月"
#define SaleEnDay @"day"
#define SaleEnWeek @"week"
#define SaleEnMonth @"month"
#define OrderLastWeak @"比上周同期"
#define OrderLastMonth @"比上月同期"
#define LastWeak @"比上周"
#define LastMonth @"比上月"
#define AvgLabelDay @"单店日均"
#define AvgLabelWeek @"单店周均"
#define AvgLabelMonth @"单店月均"
#define FontSize(num) [UIFont systemFontOfSize:num]
#define AppWindow [[UIApplication sharedApplication].delegate window]
#define GXF_ELEVTEEN_SIZE FontSize(11)
#define GXF_TWELVETEEN_SIZE FontSize(12)
#define GXF_THREETEENTH_SIZE FontSize(13)
#define GXF_FOURTEENTH_SIZE FontSize(14)
#define GXF_FIFTEENTEN_SIZE FontSize(15)
#define GXF_SIXTEENTEH_SIZE FontSize(16)
#define GXF_SEVENTEENTH_SIZE FontSize(17)
/*
* Clog
*/
#ifdef DEBUG
#define CLog(format, ...) NSLog((@"[Line %d] %s " format), __LINE__, __PRETTY_FUNCTION__, ## __VA_ARGS__)
#else
#define CLog(format, ...)
#endif
#endif /* OtherHeaders_h */
......@@ -84,7 +84,7 @@ extern NSString *const USER_POSITION_TENANT; // 用户职位: 商户用户
//@property (nonatomic, strong) User *user;
//// 所属企业
//@property (nonatomic, strong) Enterpirse *enterprise;
@property (nonatomic, strong) NSString *org_uuid;
// 用户标识
@property (nonatomic, strong) NSString *user_uuid;
// 用户代码
......
......@@ -5,6 +5,7 @@
//
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import "Bee.h"
#import <UIKit/UIKit.h>
#import "Bee.h"
#import "OtherHeaders.h"
#endif
\ No newline at end of file
//
// Compass.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/18.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "IBTModel.h"
@interface Compass : IBTModel
@property (nonatomic,strong)NSString *dataScopeType;
// 统计时间类型 否 String 100 day(日),week(周),month(月)
@property (nonatomic,strong)NSString *dataScope;
// 统计时间 否 String 100 日:2015-10-10周:37,表示今年第几周月:2015-10
@property (nonatomic,strong)NSString *orgUuid;
//组织标识 否 String
@property (nonatomic,strong)NSString *orgCode;
//组织代码 否 String
@property (nonatomic,strong)NSString *orgName;
//组织名称 否 Integer
@property (nonatomic,assign)NSInteger level;
//等级 否 String
@property (nonatomic,strong)NSString *upperUuid;
//上级组织uuid 否 String
@property (nonatomic,strong)NSNumber *sales;
// 销售额 是 String 100
@property (nonatomic,strong)NSString *salesChainSign;
// 销售环比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *salesChainRate;
//销售环比变化率 是 Double  30,表示30%
@property (nonatomic,strong)NSString *salesYoYSign;
//销售同比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *salesYoYRate;
//销售同比变化率 是 Double
@property (nonatomic,strong)NSNumber *salesTargetRate;
//销售目标达成率 是 Double
@property (nonatomic,strong)NSNumber *dailysalesPerStore;
//单店日均销售 是 String 100
@property (nonatomic,strong)NSString *passengerdate;
//客流统计时间 是 String 100
@property (nonatomic,strong)NSNumber *passenger;
// 客流数 是 String 100
@property (nonatomic,strong)NSString *passengerChainSign;
// 客流数环比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *passengerChainRate;
//客流数环比变化率 是 Double
@property (nonatomic,strong)NSString *passengerYoYSign;
//客流数同比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *passengerYoYRate;
// 客流数同比变化率 是 Double
@property (nonatomic,strong)NSString *persalesdate;
//客单价统计时间 是 String 100
@property (nonatomic,strong)NSNumber *persales;
//客单价 是 String 100
@property (nonatomic,strong)NSString *persalesChainSign;
//客单价环比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *persalesChainRate;
//客单价环比增减率 是 Double
@property (nonatomic,strong)NSString *persalesYoYSign;
//客单价同比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *persalesYoYRate;
//客单价同比增减率 是 Double
@property (nonatomic,strong)NSString *grossprofitdate;
//毛利率统计时间 是 String 100
@property (nonatomic,strong)NSNumber *grossprofit;
//毛利率 是 String 100
@property (nonatomic,strong)NSString *grossprofitChainSign;
//毛利率环比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *grossprofitChainRate;
//毛利率环比增减率 是 Double
@property (nonatomic,strong)NSString *grossprofitYoYSign;
//毛利率同比增减标志 是 String 30 枚举值为:plus(增),minus(减)
@property (nonatomic,strong)NSNumber *grossprofitYoYRate;
//毛利率同比增减率 是 Double
@property (nonatomic , assign) BOOL expand;//该节点是否处于展开状态
@property (nonatomic , assign) BOOL isLeaf;
@end
//
// Compass.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/18.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "Compass.h"
@implementation Compass
@end
//
// ReportViewController.h
// vanke
// XFFruit
//
// Created by Z on 16/7/11.
// Copyright © 2016年 gomore. All rights reserved.
// Created by 陈俊俊 on 15/11/6.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ICRBaseViewController.h"
@interface ReportViewController : ICRBaseViewController
@end
//
// ReportViewController.m
// vanke
//
// Created by Z on 16/7/11.
// Copyright © 2016年 gomore. All rights reserved.
// XFFruit
//
// Created by 陈俊俊 on 15/11/6.
// Copyright © 2015年 Xummer. All rights reserved.
// 报表
#import "ReportViewController.h"
#import "UIColor+Helper.h"
@interface ReportViewController ()
#import "SaleViewController.h"
//#import "PassengerViewController.h"
//#import "PassgerPriceViewController.h"
//#import "GrossRateViewController.h"
#import "CustomSegView.h"
#import "FinishTimeView.h"
//#import "SearchReportViewController.h"
#import "QueryOrder.h"
//#import "ReportDetailViewController.h"
@interface ReportViewController ()<UIScrollViewDelegate,CustomSegViewDelegate,FinishTimeViewDelegate>
{
SaleViewController *svc;
// PassengerViewController *pvc;
// PassgerPriceViewController *ppvc;
// GrossRateViewController *gvc;
NSInteger _currentView;
NSInteger _oldView;
CGRect _currentRect;
}
@property (nonatomic,strong)UIScrollView *scrollView;
@property (nonatomic,assign)NSInteger currentPage;
@property (nonatomic,strong)CustomSegView *segView;
@property (nonatomic,strong)NSString *dayType;
@property (nonatomic,strong)FinishTimeView *startTimeView;
@property (nonatomic,strong)NSString *scopeType;
@property (nonatomic,strong)NSString *selectDay;
@property (nonatomic,strong)NSString *selectMonth;
@property (nonatomic,strong)NSString *selectWeek;
//组织范围
@property (nonatomic,strong)NSString *orgScope;
//数据源数组
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,strong)NSMutableArray *totalArr;
@property (nonatomic,strong)Compass *compass;
@property (nonatomic,assign)NSInteger storeCount;
@property (nonatomic,strong)NSIndexPath *currentIndex;
@property (nonatomic,strong)NSMutableArray *selectArr;
@end
......@@ -17,35 +54,573 @@
ON_CREATE_VIEWS( signal )
{
self.navigationBarShown = YES;
self.navigationBarTitle = @"报表";
self.navigationBarTitle = @"";
self.navigationBarLeft = nil;
//添加通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getNextDetailData:) name:KNOTIFICATION_GetNextDetailData object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(goReoprtDetail:) name:KNOTIFICATION_GoReportDetail object:nil];
UIColor *color = [UIColor colorWithR:63 g:134 b:244 a:1];
if ( IOS7_OR_LATER ) {
self.navigationController.navigationBar.barTintColor = color;
} else {
self.navigationController.navigationBar.tintColor = color;
}
}
- (instancetype)init{
self = [super init];
if (self) {
//添加通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getNextDetailData:) name:KNOTIFICATION_GetNextDetailData object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(goReoprtDetail:) name:KNOTIFICATION_GoReportDetail object:nil];
}
return self;
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//布局
#if 1
self.dataArr = [NSMutableArray array];
self.totalArr = [NSMutableArray array];
self.selectArr = [NSMutableArray array];
[self bulidLayout];
UIBarButtonItem *searchItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"search"] style:UIBarButtonItemStylePlain target:self action:@selector(searchClick)];
self.navigationItem.rightBarButtonItem = searchItem;
self.dayType = @"day";
self.scopeType = [IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM-dd"];
[self getDataFromServer];
#else
CGRect rect = CGRectMake(0, 200, self.view.width, 30);
IBTUILabel *lbl = [[IBTUILabel alloc]initWithFrame:rect];
lbl.text = @"哎呦,功能还没实现呢,下次再来看看吧。";
lbl.textAlignment = NSTextAlignmentCenter;
lbl.font = [UIFont systemFontOfSize:15];
lbl.textColor = GXF_NAVIGAYION_COLOR;
[self.view addSubview:lbl];
#endif
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
- (void)searchClick{
if (self.startTimeView) {
[self.startTimeView removeFromSuperview];
self.startTimeView = nil;
}
// SearchReportViewController *srvc = [SearchReportViewController new];
// [self PushViewController:srvc animated:YES];
}
- (void)getWeekbydayFromServer {
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
//赋值
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
[IBTLoadingView hideHUDWithText:nil];
self.scopeType = data[@"data"];
[self getDataFromServer];
}else{
[IBTLoadingView hideHUDWithText:message];
[IBTLoadingView showTips:data];
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
// [IBTLoadingView showProgressLabel:@"正在加载..."];
NSDate *date ;
if (!_selectDay) {
self.selectDay = [[NSDate date]localYMDString];
}
date = [IBTCommon dateFromStringWithFormat:_selectDay format:@"yyyy-MM-dd" ];
// [[ICRHTTPController sharedController] getWeekbydayWithStringDate:[date localYMDString] success:succ failure:fail];
}
#pragma mark - 获取上部数据
- (void)getDataFromServer{
__weak typeof(self)weakSelf = self;
[IBTLoadingView showProgressLabel:@"正在加载..."];
NSMutableArray *orderArr =[NSMutableArray array];
if (orderArr.count == 0) {
QueryOrder *order = [QueryOrder new];
order.field = @"orgCode";
order.direction = @"desc";
[orderArr addObject:[order dictForCommit]];
}
LoginResponseData *loginInfo = [[VankeCommonModel sharedInstance] getLoginInfo];
NSArray *arr = [[VankeCommonModel sharedInstance] getAuthOrgs];
NSMutableArray *arrAutnOrdCode = [NSMutableArray array];
for (AuthorizedOrg *org in arr) {
[arrAutnOrdCode addObject:org.code];
}
NSDictionary *dict = @{
@"dataScopeType":self.dayType,
@"dataType":@"floor",
@"orgCodes":arrAutnOrdCode,
@"dataScope":self.scopeType,
@"orgUuid":loginInfo.org_uuid,
@"queryOrders":orderArr,
@"pageNumber":@0,
@"pageSize":@100
};
NSString *json = [dict JSONString];
[[ICRHTTPController sharedController] postUrl:@"salesdata/query" params:dict success:^(id data) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
//赋值
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
[strongSelf prepareDataInScrollView:data];
[strongSelf getBottomData:nil];
}else{
[IBTLoadingView hideHUDWithText:message];
[IBTLoadingView showTips:data];
}
} failure:^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
}];
}
- (void)prepareDataInScrollView:(id)data{
if (data) {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
NSDictionary *compassDict = data[ @"data" ][@"salesData"];
NSArray *arr = compassDict[@"records"];
if (arr.count > 0) {
for (NSDictionary *comDict in arr) {
Compass *com = [[Compass alloc]init];
[com setValuesForKeysWithDictionary:comDict];
self.compass = com;
}
}
[self setValueInScrollView];
}else{
[IBTLoadingView showTips:message];
}
}else{
[IBTLoadingView showTips:@" 无记录 "];
}
}
- (void)setValueInScrollView{
[svc setValueInSale:self.compass withType:self.dayType];
// [pvc setValueInPassenger:self.compass withType:self.dayType];
// [ppvc setValueInPassgerPrice:self.compass withType:self.dayType];
// [gvc setValueInGrossRate:self.compass withType:self.dayType];
}
//获取底部详情数据
- (void)getBottomData:(NSIndexPath *)indexPath{
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
//赋值
[IBTLoadingView hideHUDWithText:nil];
[strongSelf downLoadData:data indexPath:indexPath];
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
LoginResponseData *loginInfo = [[VankeCommonModel sharedInstance] getLoginInfo];
if (!self.orgScope) {
self.orgScope = loginInfo.org_uuid;
}
NSMutableArray *orderArr =[NSMutableArray array];
if (orderArr.count == 0) {
QueryOrder *order = [QueryOrder new];
order.field = @"orgCode";
order.direction = @"desc";
[orderArr addObject:[order dictForCommit]];
}
if (indexPath) {
// [IBTLoadingView showProgressLabel:@"正在加载..."];
}
NSDictionary *dict = @{
@"dataScopeType":self.dayType,
@"dataScope":self.scopeType,
@"orgUuid":self.orgScope,
@"fetchScope":@"childs",
@"queryOrders":orderArr,
@"pageNumber":@0,
@"pageSize":@100
};
CLog(@"%@", dict);
// [[ICRHTTPController sharedController] queryHomepageWith:dict success:succ failure:fail];
}
- (void)downLoadData:(id)data indexPath:(NSIndexPath *)indexPath{
if (data) {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
NSDictionary *recodesDict = data[ @"data" ][ @"salesData" ];
NSArray *recodesArr = recodesDict[@"records"];
if (!indexPath) {
self.storeCount =[data[ @"data" ][ @"stores" ] integerValue];
if (self.dataArr.count > 0) {
[self.dataArr removeAllObjects];
}
if (self.totalArr.count > 0) {
[self.totalArr removeAllObjects];
}
if (self.selectArr.count > 0) {
[self.selectArr removeAllObjects];
}
}
for (NSDictionary *orgDict in recodesArr) {
Compass *orgCompass = [[Compass alloc]init];
[orgCompass setValuesForKeysWithDictionary:orgDict];
if (!indexPath) {
[self.dataArr addObject:orgCompass];
}
[self.totalArr addObject:orgCompass];
}
//刷新tableView
[self refreshAllTable];
if (indexPath) {
[self actionTableView:indexPath];
}
}else{
[IBTLoadingView showTips:message];
}
}else{
[IBTLoadingView showTips:@" 无记录 "];
}
}
#pragma mark - 刷新所有的tableView
- (void)refreshAllTable{
svc.count = self.storeCount;
svc.typeStr = self.dayType;
// pvc.count = self.storeCount;
// pvc.typeStr = self.dayType;
// ppvc.count = self.storeCount;
// ppvc.typeStr = self.dayType;
// gvc.count = self.storeCount;
// gvc.typeStr = self.dayType;
svc.dataArr = self.dataArr;
// pvc.dataArr = self.dataArr;
// ppvc.dataArr = self.dataArr;
// gvc.dataArr = self.dataArr;
[svc.tableView reloadData];
// [pvc.tableView reloadData];
// [ppvc.tableView reloadData];
// [gvc.tableView reloadData];
}
#pragma mark - 布局
- (void)bulidLayout{
self.view.backgroundColor = [UIColor whiteColor];
CGRect rect = CGRectMake(10, 10 + 64, SCREEN_WIDTH - 10*2, 30);
NSArray *arr = @[SaleDay,SaleWeek,SaleMonth];
self.segView = [[CustomSegView alloc]initWithFrame:rect withArr:arr];
self.segView.delegate = self;
[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.delegate = self;
self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.showsVerticalScrollIndicator = NO;
self.scrollView.pagingEnabled = YES;
[self.view addSubview:self.scrollView];
svc = [SaleViewController new];
[self addChildViewController:svc];
// pvc = [PassengerViewController new];
// [self addChildViewController:pvc];
//
// ppvc = [PassgerPriceViewController new];
// [self addChildViewController:ppvc];
//
// gvc = [GrossRateViewController new];
// [self addChildViewController:gvc];
rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64- self.segView.bottom);
svc.view.frame = rect;
[self.scrollView addSubview:svc.view];
// rect = CGRectMake(self.scrollView.width,0 , SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64- self.segView.bottom);
// pvc.view.frame = rect;
// [self.scrollView addSubview:pvc.view];
//
// rect = CGRectMake(self.scrollView.width*2, 0, SCREEN_WIDTH, self.scrollView.height);
// ppvc.view.frame = rect;
// [self.scrollView addSubview:ppvc.view];
//
// rect = CGRectMake(self.scrollView.width*3, 0, SCREEN_WIDTH, self.scrollView.height);
// gvc.view.frame = rect;
// [self.scrollView addSubview:gvc.view];
self.scrollView.contentSize = CGSizeMake(self.scrollView.width * 4, self.scrollView.height);
}
#pragma mark - segViewDelegate
- (void)customSegOneClick:(NSString *)title{
NSDate *date ;
if (!_selectDay) {
self.selectDay = [[NSDate date]localYMDString];
//
}
date = [IBTCommon dateFromStringWithFormat:_selectDay format:@"yyyy-MM-dd" ];
// NSString *strDate = [_selectDay substringToIndex:_selectDay.length - 3];
//日周年切换
NSString *dayType = @"";
if ([title isEqualToString:SaleWeek]) {
dayType = @"week";
self.dayType = dayType;
self.orgScope = nil;
[self getWeekbydayFromServer];
return;
}
if ([title isEqualToString:SaleDay]) {
dayType = @"day";
self.scopeType = _selectDay;//[IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM-dd"];
// }else if ([title isEqualToString:SaleWeek]) {
// dayType = @"week";
// self.scopeType = [IBTCommon getWeekFromDateWithDate:date];
}else if ([title isEqualToString:SaleMonth]) {
dayType = @"month";
// date = [IBTCommon dateFromStringWithFormat:strDate format:@"yyyy-MM" ];
self.scopeType = [IBTCommon stringFromDateWithFormat:date format:@"yyyy-MM"];
} else {
return;
}
CLog(@"-------%@",self.scopeType);
self.dayType = dayType;
self.orgScope = nil;
[self getDataFromServer];
}
- (void)customSegTwoClick:(NSString *)title{
//选择历史查看
if ([title isEqualToString:SaleDay]) {
[self startDatePickView:SaleEnDay];
}else if ([title isEqualToString:SaleWeek]) {
[self startDatePickView:SaleEnWeek];
}else if ([title isEqualToString:SaleMonth]) {
[self startDatePickView:SaleEnMonth];
}
}
/*
#pragma mark - Navigation
- (void)startDatePickView:(NSString *)type{
if (!self.startTimeView) {
NSString *currentStr = @"";
if ([type isEqualToString:SaleEnDay]) {
if (self.selectDay) {
currentStr = self.selectDay;
}else{
currentStr = [IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM-dd"];
}
}else if([type isEqualToString:SaleEnMonth]){
if (self.selectMonth) {
currentStr = self.selectMonth;
}else{
currentStr = [IBTCommon stringFromDateWithFormat:[NSDate date] format:@"yyyy-MM"];
}
}else{
if (self.selectWeek) {
currentStr = self.selectWeek;
}else{
currentStr = [IBTCommon getWeekFromDate];
}
}
self.startTimeView = [[FinishTimeView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - 64) withDate:currentStr type:type];
self.startTimeView.delegate = self;
self.startTimeView.backgroundColor = RGBA(0, 0, 0 ,0.5);
[AppWindow addSubview:self.startTimeView];
[UIView animateWithDuration:0.15 animations:^{
CGRect startFrame = self.startTimeView.frame;
startFrame.origin.y = 64;
self.startTimeView.frame = startFrame;
} completion:^(BOOL finished) {
// 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.
}];
}
}
- (void)cancelTimeView{
[self clearDatePickView];
}
- (void)okTimeView:(NSString *)time withType:(NSString *)type{
CLog(@"--------%@",time);
// 关闭选择器
[self clearDatePickView];
if ([type isEqualToString:SaleEnDay]) {
self.selectDay = time;
}else if ([type isEqualToString:SaleEnWeek]) {
self.selectWeek = time;
}else if ([type isEqualToString:SaleEnMonth]) {
self.selectMonth = time;
}
self.scopeType = time;
self.orgScope = nil;
[self getDataFromServer];
}
#pragma mark - 取消
- (void)clearDatePickView{
[UIView animateWithDuration:0.15 animations:^{
CGRect startFrame = self.startTimeView.frame;
startFrame.origin.y = SCREEN_HEIGHT;
self.startTimeView.frame = startFrame;
} completion:^(BOOL finished) {
[self.startTimeView removeFromSuperview];
self.startTimeView = nil;
}];
}
- (void)getNextDetailData:(NSNotification *)fication{
NSDictionary *dict = fication.userInfo;
NSIndexPath *indexPath = dict[@"indexPath"];
Compass *parentCompass = [self.dataArr objectAtIndex:indexPath.row];
//如果当前点击的不是删除,则要先获取数据在进行插入
if (![self isHaveIndexPath:parentCompass.orgUuid]) {
if (parentCompass.isLeaf) {
//如果是子节点就不用进行网络请求
return;
}//不是子节点进行网络请求
self.orgScope = parentCompass.orgUuid;
[self getBottomData:indexPath];
return;
}
[self actionTableView:indexPath];
}
- (void)actionTableView:(NSIndexPath *)indexPath{
Compass *parentCompass = [self.dataArr objectAtIndex:indexPath.row];
NSInteger startPosition = indexPath.row+1;
NSInteger endPosition = startPosition;
BOOL expand = NO;
for (int i=0; i<self.totalArr.count; i++) {
Compass *node = [self.totalArr objectAtIndex:i];
if ([node.upperUuid isEqualToString:parentCompass.orgUuid]) {
//修改二级节点的属性为为原属性相反属性
node.expand = !node.expand;
if (node.expand) {
[self.dataArr insertObject:node atIndex:endPosition];
expand = YES;
endPosition++;
}else{
expand = NO;
endPosition = [self removeAllNodesAtParentNode:parentCompass];
break;
}
}
}
//获得需要修正的indexPath
NSMutableArray *indexPathArray = [NSMutableArray array];
for (NSInteger i=startPosition; i<endPosition; i++) {
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
[indexPathArray addObject:tempIndexPath];
}
//插入或者删除相关节点
if (expand) {
[self.selectArr addObject:parentCompass.orgUuid];
[self insertDataWithTable:svc.tableView arr:indexPathArray];
// [self insertDataWithTable:ppvc.tableView arr:indexPathArray];
// [self insertDataWithTable:pvc.tableView arr:indexPathArray];
// [self insertDataWithTable:gvc.tableView arr:indexPathArray];
}else{
[self.selectArr removeObject:parentCompass.orgUuid];
[self deleteDataWithTable:svc.tableView arr:indexPathArray];
// [self deleteDataWithTable:pvc.tableView arr:indexPathArray];
// [self deleteDataWithTable:ppvc.tableView arr:indexPathArray];
// [self deleteDataWithTable:gvc.tableView arr:indexPathArray];
}
[self refreshAllTable];
}
- (void)insertDataWithTable:(UITableView *)tableView arr:(NSMutableArray *)arr{
[tableView insertRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationFade];
}
- (void)deleteDataWithTable:(UITableView *)tableView arr:(NSMutableArray *)arr{
[tableView deleteRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationFade];
}
/**
* 删除该父节点下的所有子节点(包括孙子节点)
*
* @param parentNode 父节点
*
* @return 该父节点下一个相邻的统一级别的节点的位置
*/
-(NSUInteger)removeAllNodesAtParentNode : (Compass *)parentNode{
NSUInteger startPosition = [self.dataArr indexOfObject:parentNode];
NSUInteger endPosition = startPosition;
for (NSUInteger i=startPosition+1; i<self.dataArr.count; i++) {
Compass *node = [self.dataArr objectAtIndex:i];
endPosition++;
if (node.level <= parentNode.level) {
break;
}
if(endPosition == self.dataArr.count-1){
endPosition++;
node.expand = NO;
break;
}
node.expand = NO;
}
if (endPosition>startPosition) {
for (NSInteger i = startPosition+1; i < endPosition; i++) {
Compass *parentCompass = self.dataArr[i];
for (Compass *orgCompass in self.totalArr) {
if (parentCompass.orgUuid == orgCompass.orgUuid) {
[self.totalArr removeObject:orgCompass];
break;
}
}
}
[self.dataArr removeObjectsInRange:NSMakeRange(startPosition+1, endPosition-startPosition-1)];
}
return endPosition;
}
- (BOOL)isHaveIndexPath:(NSString *)orgUuid{
for (NSString *selectoUuid in self.selectArr) {
if ([selectoUuid isEqualToString:orgUuid]) {
return YES;
}
}
return NO;
}
#pragma mark - 详情页面跳转
- (void)goReoprtDetail:(NSNotification *)finication{
// NSDictionary *dict = finication.userInfo;
// Compass *compass = dict[@"compass"];
// ReportDetailViewController *rvc = [ReportDetailViewController new];
// rvc.compass = compass;
// rvc.title = compass.orgName;
// [self PushViewController:rvc animated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
*/
@end
//
// SaleViewController.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/6.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Compass.h"
@interface SaleViewController : UIViewController
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic,assign)NSInteger count;
@property (nonatomic,strong)NSString *typeStr;
- (void)setValueInSale:(Compass *)compass withType:(NSString *)type;
@end
//
// SaleViewController.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/6.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "SaleViewController.h"
#import "SaleViewCell.h"
#import "SaleHeaderView.h"
//#import "ReportDetailViewController.h"
#import "RSaleView.h"
#import "Compass.h"
static NSString *saleCellIdentify = @"saleCellIdentify";
static NSString *saleHeaderIdentify = @"saleHeaderIdentify";
@interface SaleViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)RSaleView *rsaleView;
@property (nonatomic,strong)Compass *compass;
@property (nonatomic,strong)NSIndexPath *currentIndex;
@end
@implementation SaleViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initData];
[self bulidLayout];
}
#pragma mark - 初始化数据
- (void)initData{
if(!self.dataArr){
self.dataArr = [NSMutableArray array];
}
}
#pragma mark - 布局
- (void)bulidLayout{
self.view .backgroundColor = [UIColor whiteColor];
CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, 145);
self.rsaleView = [[RSaleView alloc]initWithFrame:rect];
self.rsaleView.bgImage.image = [UIImage imageNamed:@"salebg_1"];
self.rsaleView.cenImage.image = [UIImage imageNamed:@"sale_1"];
[self.view addSubview:self.rsaleView];
NSLog(@"%f---------",self.view.height);
rect = CGRectMake(0, 0, self.view.width, self.view.height- 158);
self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView registerClass:[SaleViewCell class] forCellReuseIdentifier:saleCellIdentify];
[self.tableView registerClass:[SaleHeaderView class] forHeaderFooterViewReuseIdentifier:saleHeaderIdentify];
self.tableView.tableHeaderView = self.rsaleView;
[self.view addSubview:self.tableView];
}
- (void)setValueInSale:(Compass *)compass withType:(NSString *)type{
self.compass = compass;
self.rsaleView.weekLabelStr = type;
[self.rsaleView setValueInSaleView:compass];
}
#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
SaleViewCell *cell = (SaleViewCell *)[tableView dequeueReusableCellWithIdentifier:saleCellIdentify forIndexPath:indexPath];
if(cell == nil) {
cell = [[SaleViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:saleCellIdentify];
}
//没有选中风格
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//取消分割线
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Compass *test = _dataArr[indexPath.row];
if(test != nil) {
[cell updateCellWith:test index:indexPath];
}
cell.detailBtn.tag = indexPath.row;
[cell.detailBtn addTarget:self action:@selector(detailClick:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [SaleViewCell cellHeight];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[[NSNotificationCenter defaultCenter]postNotificationName:KNOTIFICATION_GetNextDetailData object:nil userInfo:@{@"indexPath":indexPath}];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
SaleHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:saleHeaderIdentify];
if (headerView == nil) {
headerView = [[SaleHeaderView alloc] initWithReuseIdentifier:saleHeaderIdentify];
}
[headerView buildLayout];
headerView.totalLabel.text = [NSString stringWithFormat:@"共%ld家",(long)self.count];
[headerView changeTypeName:self.typeStr];
return headerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return [SaleHeaderView viewHeight];
}
- (void)detailClick:(UIButton *)btn{
Compass *com = self.dataArr[btn.tag];
NSObject *comObj = [NSNull null];
if (com) {
comObj = com;
}
[[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_GoReportDetail object:nil userInfo:@{@"compass":comObj}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// CustomSegView.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/6.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol CustomSegViewDelegate <NSObject>
- (void)customSegOneClick:(NSString *)title;
- (void)customSegTwoClick:(NSString *)title;
@end
@interface CustomSegView : UIView
@property (nonatomic,weak)id<CustomSegViewDelegate>delegate;
- (instancetype)initWithFrame:(CGRect)frame withArr:(NSArray *)arr;
@end
//
// CustomSegView.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/6.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "CustomSegView.h"
#define BeginBtnTag 2000000
@interface CustomSegView ()
{
UIView *_bgView;
NSInteger _currentBtnTag;
}
@property (nonatomic,copy)NSArray *segArr;
@end
@implementation CustomSegView
- (instancetype)initWithFrame:(CGRect)frame withArr:(NSArray *)arr{
self = [super initWithFrame:frame];
if (self) {
self.segArr = arr;
[self bulidLayout];
}
return self;
}
- (void)bulidLayout{
_bgView = [[UIView alloc]initWithFrame:self.bounds];
_bgView.layer.borderWidth = 1;
_bgView.layer.borderColor = ReportColor.CGColor;
_bgView.layer.cornerRadius = 5;
_bgView.layer.masksToBounds = YES;
[self addSubview:_bgView];
_bgView.clipsToBounds = YES;
_currentBtnTag = 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.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 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_currentBtnTag = i+ BeginBtnTag;
}
if (i < self.segArr.count - 1) {
[segBtn addRightBorderWithWidth:1 color:ReportColor];
}
}
}
- (void)segClick:(UIButton *)btn{
if (btn.tag != _currentBtnTag) {
//获取上一个Btn
IBTCustomButtom *beforeBtn = (IBTCustomButtom *)[_bgView viewWithTag:_currentBtnTag];
if ([beforeBtn isKindOfClass:[UIButton class]] && beforeBtn) {
beforeBtn.backgroundColor = RGBA(1, 1, 1, 0);
[beforeBtn setTitleColor:ReportColor forState:UIControlStateNormal];
}
btn.backgroundColor = ReportColor;
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_currentBtnTag = btn.tag;
if ([self.delegate respondsToSelector:@selector(customSegOneClick:)]) {
[self.delegate customSegOneClick:btn.titleLabel.text];
}
}else{
if ([self.delegate respondsToSelector:@selector(customSegTwoClick:)]) {
[self.delegate customSegTwoClick:btn.titleLabel.text];
}
}
}
@end
//
// FinishTimeView.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/2.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol FinishTimeViewDelegate <NSObject>
- (void)cancelTimeView;
- (void)okTimeView:(NSString *)time withType:(NSString *)type;
@end
@interface FinishTimeView : UIView<UIPickerViewDataSource,UIPickerViewDelegate>
@property (nonatomic,weak)id<FinishTimeViewDelegate>delegate;
- (instancetype)initWithFrame:(CGRect)frame withDate:(NSString *)dateStr;
- (instancetype)initWithFrame:(CGRect)frame withDate:(NSString *)dateStr type:(NSString *)type;
@end
//
// FinishTimeView.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/2.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "FinishTimeView.h"
// 起始年数
#define kStartYear 1980
// 总年数
#define kYearCount 200
#define DateViewHeight 246
@interface FinishTimeView ()
{
UIView *_bgView;
}
// 定义数据属性
// 1. 年数组
@property (strong, nonatomic) NSArray *yearList;
// 2. 月数组
@property (strong, nonatomic) NSMutableArray *monthList;
// 3. 日数组
@property (strong, nonatomic) NSMutableArray *dayList;
// 时
@property (strong,nonatomic) NSArray *hourList;
// 分
@property (strong,nonatomic) NSArray *minuteList;
// 4. 选中的年数
@property (assign, nonatomic) NSInteger selectedYear;
// 5. 选中的月数
@property (assign, nonatomic) NSInteger selectedMonth;
@property (assign,nonatomic) NSInteger currentYear;
@property (assign,nonatomic) NSInteger currentMonth;
@property (assign,nonatomic) NSInteger currentDay;
@property (assign,nonatomic) NSInteger currentHour;
@property (assign,nonatomic) NSInteger currentMinute;
@property (nonatomic,strong) UIPickerView *pickerView;
@property (nonatomic,strong) NSString *dateStr;
@property (nonatomic,strong) NSString *typeStr;
@end
@implementation FinishTimeView
- (instancetype)initWithFrame:(CGRect)frame withDate:(NSString *)dateStr
{
self = [super initWithFrame:frame];
if (self) {
self.dateStr = dateStr;
self.typeStr = @"all";
[self buildLayout];
}
self.backgroundColor = [UIColor whiteColor];
return self;
}
- (instancetype)initWithFrame:(CGRect)frame withDate:(NSString *)dateStr type:(NSString *)type{
self = [super initWithFrame:frame];
if (self) {
self.dateStr = dateStr;
self.typeStr = type;
[self buildLayout];
}
self.backgroundColor = [UIColor whiteColor];
return self;
}
- (void)buildLayout
{
_bgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - DateViewHeight, SCREEN_WIDTH, DateViewHeight)];
_bgView.backgroundColor = RGBA(239, 239, 239 ,1);
[self addSubview:_bgView];
UIButton *okBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(SCREEN_WIDTH - 62, 0, 62, 28) target:self sel:@selector(okClick) tag:0 image:nil title:@"确定" titleColor:[UIColor blackColor] isCorner:NO corner:0 bgColor:RGBA(239, 239, 239 ,1)];
[_bgView addSubview:okBtn];
UIButton *cancelBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(0, 0, 62, 28) target:self sel:@selector(cancelClick) tag:0 image:nil title:@"取消" titleColor:[UIColor blackColor] isCorner:NO corner:0 bgColor:RGBA(239, 239, 239 ,1)];
[_bgView addSubview:cancelBtn];
UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0, 30,SCREEN_WIDTH, DateViewHeight - 30)];
pickerView.backgroundColor = [UIColor whiteColor];
// 指定数据源
[pickerView setDataSource:self];
// 指定代理
[pickerView setDelegate:self];
// PickerView默认是没有选中标示的
[pickerView setShowsSelectionIndicator:YES];
self.pickerView = pickerView;
[_bgView addSubview:pickerView];
CLog(@"====%@",self.dateStr);
if ([self.typeStr isEqualToString:@"all"]) {
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
self.currentDay = [[self.dateStr substringWithRange:NSMakeRange(8,2)] intValue];
self.currentHour = [[self.dateStr substringWithRange:NSMakeRange(11,2)] intValue];
self.currentMinute = [[self.dateStr substringWithRange:NSMakeRange(14,2)] intValue];
// 3. 初始化数据
// 1) 年数据
NSMutableArray *yearArray = [NSMutableArray arrayWithCapacity:kYearCount];
for (int i = 0; i < kYearCount; i++) {
NSString *str = [NSString stringWithFormat:@"%d年", i + kStartYear];
[yearArray addObject:str];
}
self.yearList = yearArray;
// 2) 月数据
NSMutableArray *monthArray = [NSMutableArray arrayWithCapacity:12];
for (int i = 1; i <= 12; i++) {
NSString *str = [NSString stringWithFormat:@"%d月", i];
[monthArray addObject:str];
}
self.monthList = monthArray;
// 时
NSMutableArray *hourArray = [NSMutableArray arrayWithCapacity:24];
for (int i = 0; i < 24; i++) {
NSString *str = [NSString stringWithFormat:@"%d时",i];
[hourArray addObject:str];
}
self.hourList = hourArray;
// 分
NSMutableArray *minuteArray = [NSMutableArray arrayWithCapacity:60];
for (int i = 0; i < 60; i++) {
NSString *str = [NSString stringWithFormat:@"%d分",i];
[minuteArray addObject:str];
}
self.minuteList = minuteArray;
// 初始化选中年、月
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
self.currentDay = [[self.dateStr substringWithRange:NSMakeRange(8,2)] intValue];
self.currentHour = [[self.dateStr substringWithRange:NSMakeRange(11,2)] intValue];
[pickerView selectRow:(self.currentYear - kStartYear) inComponent:0 animated:YES];
[pickerView selectRow:(self.currentMonth - 1) inComponent:1 animated:YES];
[pickerView selectRow:(self.currentDay - 1) inComponent:2 animated:YES];
[pickerView selectRow:self.currentHour inComponent:3 animated:YES];
[pickerView selectRow:(self.currentMinute) inComponent:4 animated:YES];
[self pickerView:pickerView didSelectRow:self.currentYear - kStartYear inComponent:0];
[self pickerView:pickerView didSelectRow:(self.currentMonth - 1) inComponent:1];
[self pickerView:pickerView didSelectRow:(self.currentDay - 1) inComponent:2];
[self pickerView:pickerView didSelectRow:(self.currentHour - 1) inComponent:3];
[self pickerView:pickerView didSelectRow:(self.currentMinute -1) inComponent:4];
}else if([self.typeStr isEqualToString:@"month"]){
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
NSMutableArray *yearArray = [NSMutableArray arrayWithCapacity:kYearCount];
for (int i = 0; i < kYearCount; i++) {
NSString *str = [NSString stringWithFormat:@"%d年", i + kStartYear];
[yearArray addObject:str];
}
self.yearList = yearArray;
// 2) 月数据
NSMutableArray *monthArray = [NSMutableArray arrayWithCapacity:12];
for (int i = 1; i <= 12; i++) {
NSString *str = [NSString stringWithFormat:@"%d月", i];
[monthArray addObject:str];
}
self.monthList = monthArray;
// 初始化选中年、月
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
[pickerView selectRow:(self.currentYear - kStartYear) inComponent:0 animated:YES];
[pickerView selectRow:(self.currentMonth - 1) inComponent:1 animated:YES];
[self pickerView:pickerView didSelectRow:self.currentYear - kStartYear inComponent:0];
[self pickerView:pickerView didSelectRow:(self.currentMonth - 1) inComponent:1];
}else if([self.typeStr isEqualToString:@"day"]){
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
self.currentDay = [[self.dateStr substringWithRange:NSMakeRange(8,2)] intValue];
NSMutableArray *yearArray = [NSMutableArray arrayWithCapacity:kYearCount];
for (int i = 0; i < kYearCount; i++) {
NSString *str = [NSString stringWithFormat:@"%d年", i + kStartYear];
[yearArray addObject:str];
}
self.yearList = yearArray;
// 2) 月数据
NSMutableArray *monthArray = [NSMutableArray arrayWithCapacity:12];
for (int i = 1; i <= 12; i++) {
NSString *str = [NSString stringWithFormat:@"%d月", i];
[monthArray addObject:str];
}
self.monthList = monthArray;
// 初始化选中年、月
// 初始化选中年、月
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
self.currentDay = [[self.dateStr substringWithRange:NSMakeRange(8,2)] intValue];
[pickerView selectRow:(self.currentYear - kStartYear) inComponent:0 animated:YES];
[pickerView selectRow:(self.currentMonth - 1) inComponent:1 animated:YES];
[pickerView selectRow:(self.currentDay - 1) inComponent:2 animated:YES];
[self pickerView:pickerView didSelectRow:self.currentYear - kStartYear inComponent:0];
[self pickerView:pickerView didSelectRow:(self.currentMonth - 1) inComponent:1];
[self pickerView:pickerView didSelectRow:(self.currentDay - 1) inComponent:2];
}else if ([self.typeStr isEqualToString:@"week"]){
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
NSMutableArray *yearArray = [NSMutableArray arrayWithCapacity:kYearCount];
for (int i = 0; i < kYearCount; i++) {
NSString *str = [NSString stringWithFormat:@"%d年", i + kStartYear];
[yearArray addObject:str];
}
self.yearList = yearArray;
self.currentYear = [[self.dateStr substringWithRange:NSMakeRange(0,4)] intValue];
self.selectedYear = self.currentYear;
if (self.dateStr.length <= 6) {
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,1)] intValue];
}else{
self.currentMonth = [[self.dateStr substringWithRange:NSMakeRange(5,2)] intValue];
}
[pickerView selectRow:(self.currentYear - kStartYear) inComponent:0 animated:YES];
[pickerView selectRow:(self.currentMonth - 1) inComponent:1 animated:YES];
[self pickerView:pickerView didSelectRow:self.currentYear - kStartYear inComponent:0];
[self pickerView:pickerView didSelectRow:(self.currentMonth - 1) inComponent:1];
}
}
#pragma mark - 私有方法
#pragma mark 判断闰年
- (BOOL)isLeapYear:(NSInteger)year
{
// 如果年数能被4整除,同时不能被100整除
// 能被400整除的是闰年
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
#pragma mark 创建日数组
// 此方法的返回值是void,是为了不改变dayList的指针
- (void)createDayListWithYear:(NSInteger)year month:(NSInteger)month
{
// 日数组是懒加载,需要时在创建
if (self.dayList == nil) {
// 在开发时尽可能要去控制NSMutableArray的容量
self.dayList = [NSMutableArray arrayWithCapacity:31];
} else {
[self.dayList removeAllObjects];
}
// 初始化日数组
/**
年:是否是闰年
月:大月,小月
*/
NSInteger days = 31;
if ([self isLeapYear:year] && month == 2) {
// 闰年的2月
days = 29;
} else if (2 == month) {
// 非闰年的2月
days = 28;
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
// 小月
days = 30;
}
for (int i = 1; i <= days; i++) {
NSString *str = [NSString stringWithFormat:@"%d日", i];
[self.dayList addObject:str];
}
}
- (void)getWeekByYear:(NSInteger)year{
// 日数组是懒加载,需要时在创建
if (self.monthList == nil) {
// 在开发时尽可能要去控制NSMutableArray的容量
self.monthList = [NSMutableArray arrayWithCapacity:53];
} else {
[self.monthList removeAllObjects];
}
NSInteger weeks = [IBTCommon getWeeks:year];
for (int i = 1; i <= weeks; i++) {
NSString *str = [NSString stringWithFormat:@"第%d周", i];
[self.monthList addObject:str];
}
}
#pragma mark - PickerView的数据源方法
#pragma mark 指定列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if([self.typeStr isEqualToString:@"all"]){
return 5;
}else if([self.typeStr isEqualToString:SaleEnMonth]|| [self.typeStr isEqualToString:SaleEnWeek]){
return 2;
}else{
return 3;
}
}
#pragma mark 指定行数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if ([self.typeStr isEqualToString:@"all"]) {
if (0 == component) {
// 年
return self.yearList.count;
} else if (1 == component) {
// 月
return self.monthList.count;
} else if (2 == component) {
// 日
// 需要创建日数组-懒加载
[self createDayListWithYear:self.selectedYear month:self.selectedMonth];
return self.dayList.count;
}
else if (3 == component) {
// 时
return self.hourList.count;
} else // 分
{
return self.minuteList.count;
}
}else if([self.typeStr isEqualToString:SaleEnMonth]){
if (component == 0) {
// 年
return self.yearList.count;
} else {
// 月
return self.monthList.count;
}
}else if([self.typeStr isEqualToString:SaleEnDay]){
if (0 == component) {
// 年
return self.yearList.count;
} else if (1 == component) {
// 月
return self.monthList.count;
} else{
// 日
// 需要创建日数组-懒加载
[self createDayListWithYear:self.selectedYear month:self.selectedMonth];
return self.dayList.count;
}
}else{
if (0 == component) {
// 年
return self.yearList.count;
} else{
// 月
[self getWeekByYear:self.selectedYear];
return self.monthList.count;
}
}
}
#pragma mark - UIPickerViewDelegate
#pragma mark 指定component列row行的内容
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if ([self.typeStr isEqualToString:@"all"]) {
if (0 == component) {
return self.yearList[row];
} else if (1 == component) {
return self.monthList[row];
} else if (2 == component){
return self.dayList[row];
}
else if (3 == component) {
return self.hourList[row];
} else {
return self.minuteList[row];
}
}else if([self.typeStr isEqualToString:SaleEnMonth]|| [self.typeStr isEqualToString:SaleEnWeek] ){
if (0 == component) {
return self.yearList[row];
}else{
return self.monthList[row];
}
}else{
if (0 == component) {
return self.yearList[row];
} else if (1 == component) {
return self.monthList[row];
} else{
return self.dayList[row];
}
}
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
if (component == 0) {
return 80;
}
return 50;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if ([self.typeStr isEqualToString:@"all"] || [self.typeStr isEqualToString:@"day"]) {
// 当用户在月份列选择数值时,需要刷新日期的数组
self.selectedYear = [pickerView selectedRowInComponent:0] + kStartYear;
self.selectedMonth = [pickerView selectedRowInComponent:1] + 1;
NSInteger resetRow = [pickerView selectedRowInComponent:2];
if (component == 1) {
[pickerView reloadComponent:2];
[self pickerView:pickerView didSelectRow:resetRow inComponent:2];
} else if (component == 0 && self.selectedMonth == 2) {
// 如果用户是在年列选择的数值,同时月份中的当前数值是2月,需要刷新数据
[pickerView reloadComponent:2];
[self pickerView:pickerView didSelectRow:resetRow inComponent:2];
}
}else if ([self.typeStr isEqualToString:SaleEnWeek]) {
// 当用户在月份列选择数值时,需要刷新日期的数组
self.selectedYear = [pickerView selectedRowInComponent:0] + kStartYear;
NSInteger resetRow = [pickerView selectedRowInComponent:1];
if (component == 0) {
[pickerView reloadComponent:1];
[self pickerView:pickerView didSelectRow:resetRow inComponent:1];
}
}
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *myView = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 330, 30)];
myView.textAlignment = NSTextAlignmentCenter;
myView.font = [UIFont systemFontOfSize:16];
switch (component) {
case 0:
myView.text = self.yearList[row];
break;
case 1:
myView.text = self.monthList[row];
break;
case 2:
myView.text = self.dayList[row];
break;
case 3:
myView.text = self.hourList[row];
break;
case 4:
myView.text = self.minuteList[row];
break;
default:
break;
}
return myView;
}
- (NSString *)getDate
{
NSInteger yearRow = [_pickerView selectedRowInComponent:0];
NSString *year = [self.yearList[yearRow] stringByReplacingOccurrencesOfString:@"年" withString:@""];
NSInteger monthRow = [_pickerView selectedRowInComponent:1];
NSString *month = [self.monthList[monthRow] stringByReplacingOccurrencesOfString:@"月" withString:@""];
NSInteger dayRow = [_pickerView selectedRowInComponent:2];
NSString *day = [self.dayList[dayRow] stringByReplacingOccurrencesOfString:@"日" withString:@""];
NSInteger hourRow = [_pickerView selectedRowInComponent:3];
NSString *hour = [self.hourList[hourRow] stringByReplacingOccurrencesOfString:@"时" withString:@""];
NSInteger minuteRow = [_pickerView selectedRowInComponent:4];
NSString *minute = [self.minuteList[minuteRow] stringByReplacingOccurrencesOfString:@"分" withString:@""];
NSArray *array1 = [NSArray arrayWithObjects:year,month,day, nil];
NSArray *array2 = [NSArray arrayWithObjects:hour,minute, nil];
NSString *date1 = [array1 componentsJoinedByString:@"-"];
NSString *date2 = [array2 componentsJoinedByString:@":"];
NSString *date = [NSString stringWithFormat:@"%@ %@:00",date1,date2];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
return [formatter stringFromDate:[formatter dateFromString:date]];
}
- (void)okClick{
if ([self.typeStr isEqualToString:@"all"]) {
NSString *dateStr = [self getDate];
[self.delegate okTimeView:dateStr withType:@"all"];
}else if([self.typeStr isEqualToString:SaleEnMonth]){
NSString *dateStr = [self getDateByMonth];
[self.delegate okTimeView:dateStr withType:SaleEnMonth];
}else if([self.typeStr isEqualToString:SaleEnDay]){
NSString *dateStr = [self getDateByDay];
[self.delegate okTimeView:dateStr withType:SaleEnDay];
}else if([self.typeStr isEqualToString:SaleEnWeek]){
NSString *dateStr = [self getDateByWeek];
[self.delegate okTimeView:dateStr withType:SaleEnWeek];
}
}
- (NSString *)getDateByMonth{
NSInteger yearRow = [_pickerView selectedRowInComponent:0];
NSString *year = [self.yearList[yearRow] stringByReplacingOccurrencesOfString:@"年" withString:@""];
NSInteger monthRow = [_pickerView selectedRowInComponent:1];
NSString *month = [self.monthList[monthRow] stringByReplacingOccurrencesOfString:@"月" withString:@""];
NSArray *array1 = [NSArray arrayWithObjects:year,month, nil];
NSString *date1 = [array1 componentsJoinedByString:@"-"];
NSString *date = [NSString stringWithFormat:@"%@",date1];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @"yyyy-MM";
return [formatter stringFromDate:[formatter dateFromString:date]];
}
- (NSString *)getDateByDay{
NSInteger yearRow = [_pickerView selectedRowInComponent:0];
NSString *year = [self.yearList[yearRow] stringByReplacingOccurrencesOfString:@"年" withString:@""];
NSInteger monthRow = [_pickerView selectedRowInComponent:1];
NSString *month = [self.monthList[monthRow] stringByReplacingOccurrencesOfString:@"月" withString:@""];
NSInteger dayRow = [_pickerView selectedRowInComponent:2];
NSString *day = [self.dayList[dayRow] stringByReplacingOccurrencesOfString:@"日" withString:@""];
NSArray *array1 = [NSArray arrayWithObjects:year,month,day, nil];
NSString *date1 = [array1 componentsJoinedByString:@"-"];
NSString *date = [NSString stringWithFormat:@"%@",date1];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @"yyyy-MM-dd";
return [formatter stringFromDate:[formatter dateFromString:date]];
}
- (NSString *)getDateByWeek{
NSInteger yearRow = [_pickerView selectedRowInComponent:0];
NSString *year = [self.yearList[yearRow] stringByReplacingOccurrencesOfString:@"年" withString:@""];
NSInteger monthRow = [_pickerView selectedRowInComponent:1];
NSString *month = [[self.monthList[monthRow] stringByReplacingOccurrencesOfString:@"第" withString:@""] stringByReplacingOccurrencesOfString:@"周" withString:@""];
NSArray *array1 = [NSArray arrayWithObjects:year,month.length == 1 ?[NSString stringWithFormat:@"0%@",month]:month, nil];
NSString *date1 = [array1 componentsJoinedByString:@"-"];
return date1;
}
- (void)cancelClick{
[self.delegate cancelTimeView];
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.delegate cancelTimeView];
}
@end
//
// QueryOrder.h
// XFFruit
//
// Created by n22 on 15/8/20.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTModel.h"
@interface QueryOrder : IBTModel
@property (nonatomic,strong)NSString *field;
@property (nonatomic,strong)NSString *direction;//升序
@end
//
// QueryOrder.m
// XFFruit
//
// Created by n22 on 15/8/20.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "QueryOrder.h"
@implementation QueryOrder
@end
//
// RSaleView.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/13.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Compass.h"
@interface RSaleView : UIView
- (instancetype)initWithFrame:(CGRect)frame withPage:(NSInteger)currentPage;
@property (nonatomic,strong)UIImageView *bgImage;
@property (nonatomic,strong)UIImageView *cenImage;
@property (nonatomic,strong)NSString *weekLabelStr;
@property (nonatomic,strong)UILabel *weekLabel;
@property (nonatomic,strong)UILabel *avgLabel;
- (void)setValueInSaleView:(Compass *)compass;
@end
//
// RSaleView.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/13.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "RSaleView.h"
//#import "SMPageControl.h"
#define LeftWidth 50
#define ImageSize 20
#define ContentHeight 25
#define CenImageSize 40
@interface RSaleView ()
@property (nonatomic,strong)UILabel *centerLabel;
@property (nonatomic,strong)UILabel *dateLabel;
@property (nonatomic,strong)UIButton *lastWeekLabel;
@property (nonatomic,strong)UIButton *lastYearLabel;
@property (nonatomic,strong)UILabel *rateLabel;
@property (nonatomic,strong)UILabel *averageLabel;
@property (nonatomic,strong)UIImageView *lastWeekImage;
@property (nonatomic,strong)UIImageView *lastYearImage;
//@property (nonatomic,strong)SMPageControl *pageControl;
@property (nonatomic,assign)NSInteger currentPage;
@end
@implementation RSaleView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self bulidLayout];
self.currentPage = 0;
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame withPage:(NSInteger)currentPage{
self = [super initWithFrame:frame];
if (self) {
self.currentPage = currentPage;
[self bulidLayout];
}
return self;
}
- (void)bulidLayout{
CGRect rect = CGRectMake(0, 0, self.width, self.height);
self.bgImage = [[UIImageView alloc]initWithFrame:rect];
[self addSubview:self.bgImage];
rect = CGRectMake(self.width/4, 20, CenImageSize, CenImageSize);
self.cenImage = [[UIImageView alloc]initWithFrame:rect];
self.cenImage.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:self.cenImage];
rect = CGRectMake(self.cenImage.right+5, 20, SCREEN_WIDTH - self.cenImage.right, ContentHeight);
self.centerLabel = [[UILabel alloc]initWithFrame:rect];
self.centerLabel.textColor = ReportContentColor;
self.centerLabel.font = FontSize(28);
[self addSubview:self.centerLabel];
rect = CGRectMake(self.centerLabel.left, self.centerLabel.bottom,self.width-self.centerLabel.left, ContentHeight);
self.dateLabel = [[UILabel alloc]initWithFrame:rect];
self.dateLabel.textColor = [UIColor lightGrayColor];
self.dateLabel.font = GXF_THREETEENTH_SIZE;
self.dateLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:self.dateLabel];
CGFloat bottomWidth = (SCREEN_WIDTH - 20)/4;
rect = CGRectMake(10, self.dateLabel.bottom + 5,bottomWidth, ContentHeight);
self.lastWeekLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:[UIColor lightGrayColor]];
[self addSubview:self.lastWeekLabel];
rect = CGRectMake(self.lastWeekLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
UILabel *weekLabel = [[UILabel alloc]initWithFrame:rect];
weekLabel.textColor = [UIColor lightGrayColor];
weekLabel.text = @"比上周同期";
weekLabel.font = GXF_THREETEENTH_SIZE;
weekLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:weekLabel];
self.weekLabel = weekLabel;
rect = CGRectMake(self.lastWeekLabel.right, self.lastWeekLabel.top,bottomWidth, ContentHeight);
self.lastYearLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:[UIColor lightGrayColor]];
[self addSubview:self.lastYearLabel];
rect = CGRectMake(self.lastYearLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
UILabel *yearLabel = [[UILabel alloc]initWithFrame:rect];
yearLabel.textColor = [UIColor lightGrayColor];
yearLabel.text = @"比去年同期";
yearLabel.font = GXF_THREETEENTH_SIZE;
yearLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:yearLabel];
rect = CGRectMake(self.lastYearLabel.right,self.lastWeekLabel.top,bottomWidth, ContentHeight);
self.rateLabel = [[UILabel alloc]initWithFrame:rect];
self.rateLabel.textColor = GXF_COMMIT_COLOR;
self.rateLabel.font = GXF_FIFTEENTEN_SIZE;
self.rateLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.rateLabel];
rect = CGRectMake(self.rateLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
UILabel *raLabel = [[UILabel alloc]initWithFrame:rect];
raLabel.textColor = [UIColor lightGrayColor];
raLabel.text = @"销售达成率";
raLabel.font = GXF_THREETEENTH_SIZE;
raLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:raLabel];
rect = CGRectMake(self.rateLabel.right, self.lastWeekLabel.top,bottomWidth, ContentHeight);
self.averageLabel = [[UILabel alloc]initWithFrame:rect];
self.averageLabel.textColor = GXF_COMMIT_COLOR;
self.averageLabel.font = GXF_FIFTEENTEN_SIZE;
self.averageLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.averageLabel];
rect = CGRectMake(self.averageLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
UILabel *avLabel = [[UILabel alloc]initWithFrame:rect];
avLabel.textColor = [UIColor lightGrayColor];
avLabel.text = @"单店日均";
avLabel.font = GXF_THREETEENTH_SIZE;
avLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:avLabel];
self.avgLabel = avLabel;
// self.pageControl = [[SMPageControl alloc]initWithFrame:CGRectMake(0, avLabel.bottom+5, SCREEN_WIDTH, 10)];
// self.pageControl.numberOfPages = 4;
// self.pageControl.currentPage = self.currentPage;
// self.pageControl.pageIndicatorImage = [UIImage imageNamed:@"white_point"];
// self.pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"yellow_point"];
// self.pageControl.indicatorMargin = 5.0f;
// self.pageControl.indicatorDiameter = 10.0f;
// [self addSubview:self.pageControl];
}
- (void)setWeekLabelStr:(NSString *)weekLabelStr{
NSString *typeStr = @"";
NSString *avStr = @"";
if ([weekLabelStr isEqualToString:SaleEnDay]) {
typeStr = OrderLastWeak;
avStr = AvgLabelDay;
}else if([weekLabelStr isEqualToString:SaleEnWeek]){
typeStr = OrderLastWeak;
avStr = AvgLabelWeek;
}else if([weekLabelStr isEqualToString:SaleEnMonth]){
typeStr = OrderLastMonth;
avStr = AvgLabelMonth;
}
self.weekLabel.text = typeStr;
self.avgLabel.text = avStr;
}
- (void)setValueInSaleView:(Compass *)compass{
//统计时间
NSString *weekday = @"";
if ([IBTCommon convertToDateFrom:compass.dataScope]) {
weekday = [IBTCommon weekdayStringFromDate:[IBTCommon convertToDateFrom:compass.dataScope]];
}
self.dateLabel.text = compass.dataScope?[NSString stringWithFormat:@"%@%@累计销售额",compass.dataScope,weekday]:@"无";
//销售额
self.centerLabel.text = compass.sales?[IBTCommon countNumAndChangeformat:[IBTCommon stringDisposeWithFloat:[compass.sales floatValue]]]:@"---" ;
//销售环比变化率
if ([compass.salesChainSign isEqualToString:ReportChainSignPlus]) {
[self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
[self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
}else if ([compass.salesChainSign isEqualToString:ReportChainSignMinus]){
[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]) {
[self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateNormal];
[self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
}else if ([compass.salesYoYSign isEqualToString:ReportChainSignMinus]){
[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;
}
@end
//
// SaleHeaderView.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/8.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SaleHeaderView : UITableViewHeaderFooterView
@property (nonatomic,strong)UILabel *totalLabel;
+ (CGFloat)viewHeight;
- (void)buildLayout;
- (void)changeTypeName:(NSString *)name;
@end
//
// SaleHeaderView.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/8.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "SaleHeaderView.h"
#define Sale_Header_Height 35
@interface SaleHeaderView ()
{
BOOL hasBuildLayout; // default, NO;
}
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIFont *textFont;
@property (nonatomic, strong) UILabel *bszLabel;
@end
@implementation SaleHeaderView
+ (CGFloat)viewHeight
{
return Sale_Header_Height;
}
- (void)buildLayout
{
if(hasBuildLayout) {
return;
}
if(self.textFont == nil) {
self.textFont = [UIFont systemFontOfSize:13];
}
hasBuildLayout = YES;
self.contentView.backgroundColor = [UIColor colorWithWhite:0.965 alpha:1.000];
CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, 1);
UILabel *lineLabel = [[UILabel alloc]initWithFrame:rect];
lineLabel.backgroundColor = GXF_LINE_COLOR;
[self.contentView addSubview:lineLabel];
rect = CGRectMake(10, 0, 105, Sale_Header_Height);
UILabel *searLabel = [IBTCommon labelWithTitle:@"共280家" frame:rect textFont:self.textFont];
searLabel.textColor = ReportTitleColor;
[self.contentView addSubview:searLabel];
self.totalLabel = searLabel;
CGFloat width = (SCREEN_WIDTH - searLabel.right - 25)/3;
rect = CGRectMake(searLabel.right, 0, width + 20, Sale_Header_Height);
UILabel * xsBtn = [IBTCommon labelWithTitle:@"销售额" frame:rect textFont:self.textFont];
xsBtn.textColor = ReportTitleColor;
[self.contentView addSubview:xsBtn];
rect = CGRectMake(xsBtn.right , 0, width, Sale_Header_Height);
UILabel * bszLabel = [IBTCommon labelWithTitle:@"比上周" frame:rect textFont:self.textFont];
bszLabel.textColor = ReportTitleColor;
[self.contentView addSubview:bszLabel];
self.bszLabel = bszLabel;
rect = CGRectMake(bszLabel.right , 0, width-20, Sale_Header_Height);
UILabel * sclLabel = [IBTCommon labelWithTitle:@"达成率" frame:rect textFont:self.textFont];
sclLabel.textColor = ReportTitleColor;
[self.contentView addSubview:sclLabel];
rect = CGRectMake(0, Sale_Header_Height-1, SCREEN_WIDTH, 1);
UILabel *lineTLabel = [[UILabel alloc]initWithFrame:rect];
lineTLabel.backgroundColor = GXF_LINE_COLOR;
[self.contentView addSubview:lineTLabel];
}
- (void)changeTypeName:(NSString *)name{
NSString *typeStr = @"";
if ([name isEqualToString:SaleEnMonth]) {
typeStr = LastMonth;
}else{
typeStr = LastWeak;
}
self.bszLabel.text = typeStr;
}
@end
//
// SaleViewCell.h
// XFFruit
//
// Created by 陈俊俊 on 15/11/8.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Compass.h"
@interface SaleViewCell : UITableViewCell
@property (nonatomic,strong)UIButton *detailBtn;
@property (nonatomic, strong) UILabel *dqLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *saleLabel;
@property (nonatomic, strong) UIButton *lastWeekLabel;
@property (nonatomic, strong) UILabel *rateLabel;
@property (nonatomic, strong) UILabel *lineLabel;
+ (CGFloat)cellHeight;
- (void)updateCellWith:(Compass *)obj index:(NSIndexPath *)indexPath;
- (void)setColorAndFont:(NSInteger)level;
@end
//
// SaleViewCell.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/8.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "SaleViewCell.h"
#define Sale_Cell_Height 50
#define Left_Width 110
#define Left_margin 5
@interface SaleViewCell ()
{
BOOL hasBuildLayout; // default, NO;
}
@property (nonatomic, strong) UIFont *textFont;
@property (nonatomic, strong) UIFont *titleFont;
@property (nonatomic, strong) NSIndexPath *indexPath;
@end
@implementation SaleViewCell
+ (CGFloat)cellHeight
{
return Sale_Cell_Height;
}
#pragma mark - build view
- (void)buildLayout
{
if(hasBuildLayout) {
return;
}
hasBuildLayout = YES;
if(self.textFont == nil) {
self.textFont = [UIFont systemFontOfSize:15];
}
if(self.titleFont == nil) {
self.titleFont = [UIFont systemFontOfSize:17];
}
//页面布局
[self createView];
}
//创建视图
- (void)createView
{
CGRect rect = CGRectMake(Left_margin,5, Left_Width, Sale_Cell_Height/2);
self.nameLabel = [IBTCommon labelWithTitle:@"第一片区" frame:rect textFont:self.textFont];
[self.contentView addSubview:self.nameLabel];
rect = CGRectMake(Left_margin,self.nameLabel.bottom, Left_Width, Sale_Cell_Height/2-10);
self.dqLabel = [IBTCommon labelWithTitle:@"0101" frame:rect textFont:self.textFont];
[self.contentView addSubview:self.dqLabel];
CGFloat width = (SCREEN_WIDTH - self.dqLabel.right - 25)/3;
rect = CGRectMake(self.dqLabel.right , 0, width+20, Sale_Cell_Height);
self.saleLabel = [IBTCommon labelWithTitle:@"56,080" frame:rect textFont:self.textFont];
[self.contentView addSubview:self.saleLabel];
rect = CGRectMake(self.saleLabel.right, 0, width, Sale_Cell_Height);
self.lastWeekLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:ReportContentColor];
self.lastWeekLabel.enabled = NO;
self.lastWeekLabel.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft ;
[self.contentView addSubview:self.lastWeekLabel];
rect = CGRectMake(self.lastWeekLabel.right, 0, width-20, Sale_Cell_Height);
self.rateLabel = [IBTCommon labelWithTitle:@"60%" frame:rect textFont:self.textFont];
self.rateLabel.textColor = GXF_COMMIT_COLOR;
[self.contentView addSubview:self.rateLabel];
rect = CGRectMake(self.rateLabel.right, 0, 25, Sale_Cell_Height);
self.detailBtn = [IBTCommon buttonWithTitle:@"" Image:[UIImage imageNamed:@"more_detail"] frame:rect fontSize:20 fontColor:ReportBgColor];
self.detailBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
[self.contentView addSubview:self.detailBtn];
self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, Sale_Cell_Height - 1, SCREEN_WIDTH, 1))];
self.lineLabel.backgroundColor = GXF_LINE_COLOR;
[self.contentView addSubview:self.lineLabel];
}
#pragma mark - update view
- (void)updateCellWith:(Compass *)sale index:(NSIndexPath *)indexPath
{
self.indexPath = indexPath;
[self buildLayout];
//组织name
self.dqLabel.text = sale.orgCode;
self.nameLabel.text = sale.orgName;
//销售环比变化率
if ([sale.salesChainSign isEqualToString:ReportChainSignPlus]) {
[self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
[self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateNormal];
self.saleLabel.textColor = ReportContentColor;
}else{
[self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
[self.lastWeekLabel setTitleColor:GXF_NAVIGAYION_COLOR forState:UIControlStateNormal];
self.saleLabel.textColor = GXF_NAVIGAYION_COLOR;
}
//销售额
self.saleLabel.text = sale.sales?[IBTCommon countNumAndChangeformat:[IBTCommon stringDisposeWithFloat:[sale.sales floatValue]]] : @"0";
NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[sale.salesChainRate floatValue]]];
[self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];
//销售目标达成率
NSString *salesTargetRateStr = [NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[sale.salesTargetRate floatValue]]];
self.rateLabel.text = salesTargetRateStr;
[self setColorAndFont:sale.level];
}
- (void)setColorAndFont:(NSInteger)level{
if (level == 0) {
self.dqLabel.textColor = GXF_CONTENT_COLOR;
self.nameLabel.textColor = GXF_CONTENT_COLOR;
self.lineLabel.hidden = NO;
[self setFontLabel:17];
[self setWidthDQ:0];
self.contentView.backgroundColor = [UIColor whiteColor];
}else if (level == 1) {
self.dqLabel.textColor = [UIColor blackColor];
self.nameLabel.textColor = [UIColor blackColor];
self.lineLabel.hidden = NO;
[self setFontLabel:15];
[self setWidthDQ:0];
self.contentView.backgroundColor = [UIColor whiteColor];
}else if(level == 2){
self.lineLabel.hidden = NO;
self.dqLabel.textColor = GXF_LEFTSIX_COLOR;
self.nameLabel.textColor = GXF_LEFTSIX_COLOR;
[self setWidthDQ:5];
[self setFontLabel:13];
self.contentView.backgroundColor = [UIColor whiteColor];
}else {
self.lineLabel.hidden = YES;
self.dqLabel.textColor = ReportTwoColor;
self.nameLabel.textColor = ReportTwoColor;
[self setFontLabel:12];
[self setWidthDQ:10];
self.contentView.backgroundColor = [UIColor colorWithWhite:0.965 alpha:1.000];
}
}
- (void)setFontLabel:(NSInteger)fontSize{
self.dqLabel.font = FontSize(fontSize-2);
self.nameLabel.font = FontSize(fontSize);
self.saleLabel.font = FontSize(fontSize);
self.lastWeekLabel.titleLabel.font = FontSize(fontSize);
self.rateLabel.font = FontSize(fontSize);
}
- (void)setWidthDQ:(NSInteger)width{
self.lineLabel.left = width;
self.lineLabel.width = SCREEN_WIDTH - width;
if (width > 0) {
self.nameLabel.left = width + 5;
self.nameLabel.width = SCREEN_WIDTH - width - 5;
self.dqLabel.left = width + 5;
self.dqLabel.width = SCREEN_WIDTH - width - 5;
}else{
self.nameLabel.left = 5;
self.nameLabel.width = SCREEN_WIDTH - 5;
self.dqLabel.left = 5;
self.dqLabel.width = SCREEN_WIDTH - 5;
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
......@@ -428,6 +428,7 @@ ON_WILL_APPEAR( signal )
ICRHTTPController *httpCtrl = [ICRHTTPController sharedController];
NSString *string = [NSString stringWithFormat:@"attachment/upload_by_file?entity_type=%@&entity_uuid=%@",@"salesInput",@"860576037625827160708160529115460847"];
WS(weakSelf);
[self.arrPics removeLastObject];
[httpCtrl POST:string pictures:self.arrPics param:nil complete:^(id responseObject, NSError *error) {
NSMutableArray *arrUuid = [NSMutableArray array];
for (NSDictionary *data in responseObject[@"data"]) {
......@@ -441,7 +442,10 @@ ON_WILL_APPEAR( signal )
NSString *utf8String = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
WS(weakSelf)
[httpCtrl postUrl:utf8String params:params success:^(id data) {
weakSelf.arrPics = nil;
[weakSelf.selectedAssets removeAllObjects];
[weakSelf.cellDataDic removeAllObjects];
[weakSelf.tableView reloadData];
[weakSelf goToHistory];
} failure:^(id data) {
......@@ -482,6 +486,10 @@ ON_WILL_APPEAR( signal )
_arrPics = [NSMutableArray array];
[_arrPics addObject:[UIImage imageNamed:@"add-photo_icon"]];
}
if (_arrPics.count == 0) {
[_arrPics addObject:[UIImage imageNamed:@"add-photo_icon"]];
}
return _arrPics;
}
......
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