Commit 5310677b authored by Achilles's avatar Achilles

提交查询接口。

parent 5959242c
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
C10F18701BF8EE600065F18C /* VankeStatementListBoard_iPhone.xml in Resources */ = {isa = PBXBuildFile; fileRef = C10F186E1BF8EE600065F18C /* VankeStatementListBoard_iPhone.xml */; }; C10F18701BF8EE600065F18C /* VankeStatementListBoard_iPhone.xml in Resources */ = {isa = PBXBuildFile; fileRef = C10F186E1BF8EE600065F18C /* VankeStatementListBoard_iPhone.xml */; };
C10F18731BF8F1830065F18C /* VankeStatementListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C10F18721BF8F1830065F18C /* VankeStatementListModel.m */; }; C10F18731BF8F1830065F18C /* VankeStatementListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C10F18721BF8F1830065F18C /* VankeStatementListModel.m */; };
C10F18761BF8F33B0065F18C /* VankeSettlementListAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = C10F18751BF8F33B0065F18C /* VankeSettlementListAPI.m */; }; C10F18761BF8F33B0065F18C /* VankeSettlementListAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = C10F18751BF8F33B0065F18C /* VankeSettlementListAPI.m */; };
C11DD0611C060A9E00DD11E3 /* CDatePickerViewEx.m in Sources */ = {isa = PBXBuildFile; fileRef = C11DD0601C060A9E00DD11E3 /* CDatePickerViewEx.m */; };
C12804D71BC124A3001ECBAA /* VankeWeatherModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C12804D61BC124A3001ECBAA /* VankeWeatherModel.m */; }; C12804D71BC124A3001ECBAA /* VankeWeatherModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C12804D61BC124A3001ECBAA /* VankeWeatherModel.m */; };
C12804DA1BC12A67001ECBAA /* VankeWeatherController.m in Sources */ = {isa = PBXBuildFile; fileRef = C12804D91BC12A67001ECBAA /* VankeWeatherController.m */; }; C12804DA1BC12A67001ECBAA /* VankeWeatherController.m in Sources */ = {isa = PBXBuildFile; fileRef = C12804D91BC12A67001ECBAA /* VankeWeatherController.m */; };
C12804E01BC2D0BD001ECBAA /* VankeUserModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C12804DF1BC2D0BD001ECBAA /* VankeUserModel.m */; }; C12804E01BC2D0BD001ECBAA /* VankeUserModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C12804DF1BC2D0BD001ECBAA /* VankeUserModel.m */; };
...@@ -810,6 +811,8 @@ ...@@ -810,6 +811,8 @@
C10F18721BF8F1830065F18C /* VankeStatementListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VankeStatementListModel.m; sourceTree = "<group>"; }; C10F18721BF8F1830065F18C /* VankeStatementListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VankeStatementListModel.m; sourceTree = "<group>"; };
C10F18741BF8F33B0065F18C /* VankeSettlementListAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VankeSettlementListAPI.h; sourceTree = "<group>"; }; C10F18741BF8F33B0065F18C /* VankeSettlementListAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VankeSettlementListAPI.h; sourceTree = "<group>"; };
C10F18751BF8F33B0065F18C /* VankeSettlementListAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VankeSettlementListAPI.m; sourceTree = "<group>"; }; C10F18751BF8F33B0065F18C /* VankeSettlementListAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VankeSettlementListAPI.m; sourceTree = "<group>"; };
C11DD05F1C060A9E00DD11E3 /* CDatePickerViewEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDatePickerViewEx.h; sourceTree = "<group>"; };
C11DD0601C060A9E00DD11E3 /* CDatePickerViewEx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDatePickerViewEx.m; sourceTree = "<group>"; };
C12804D51BC124A3001ECBAA /* VankeWeatherModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VankeWeatherModel.h; sourceTree = "<group>"; }; C12804D51BC124A3001ECBAA /* VankeWeatherModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VankeWeatherModel.h; sourceTree = "<group>"; };
C12804D61BC124A3001ECBAA /* VankeWeatherModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VankeWeatherModel.m; sourceTree = "<group>"; }; C12804D61BC124A3001ECBAA /* VankeWeatherModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VankeWeatherModel.m; sourceTree = "<group>"; };
C12804D81BC12A67001ECBAA /* VankeWeatherController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VankeWeatherController.h; sourceTree = "<group>"; }; C12804D81BC12A67001ECBAA /* VankeWeatherController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VankeWeatherController.h; sourceTree = "<group>"; };
...@@ -1832,6 +1835,7 @@ ...@@ -1832,6 +1835,7 @@
C10F180A1BF7ACA80065F18C /* ImagePreview */, C10F180A1BF7ACA80065F18C /* ImagePreview */,
C18A95461C01F64500429BF7 /* LBorderView */, C18A95461C01F64500429BF7 /* LBorderView */,
C10F180D1BF7ACA80065F18C /* Macro */, C10F180D1BF7ACA80065F18C /* Macro */,
C11DD05E1C060A9E00DD11E3 /* MonthYearDatePicker */,
C1555F981C04D39600C80B55 /* UIPopoverList */, C1555F981C04D39600C80B55 /* UIPopoverList */,
); );
path = 3rd; path = 3rd;
...@@ -2119,6 +2123,15 @@ ...@@ -2119,6 +2123,15 @@
name = statement; name = statement;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
C11DD05E1C060A9E00DD11E3 /* MonthYearDatePicker */ = {
isa = PBXGroup;
children = (
C11DD05F1C060A9E00DD11E3 /* CDatePickerViewEx.h */,
C11DD0601C060A9E00DD11E3 /* CDatePickerViewEx.m */,
);
path = MonthYearDatePicker;
sourceTree = "<group>";
};
C12804F11BC40CE7001ECBAA /* util */ = { C12804F11BC40CE7001ECBAA /* util */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -4295,6 +4308,7 @@ ...@@ -4295,6 +4308,7 @@
C1D598A61BB44B2000D297FE /* Bee_UIMenuController.m in Sources */, C1D598A61BB44B2000D297FE /* Bee_UIMenuController.m in Sources */,
C10F161C1BF77CA00065F18C /* ICRConfigurationViewController.m in Sources */, C10F161C1BF77CA00065F18C /* ICRConfigurationViewController.m in Sources */,
C1D598B31BB44B2000D297FE /* Bee_UITextField.m in Sources */, C1D598B31BB44B2000D297FE /* Bee_UITextField.m in Sources */,
C11DD0611C060A9E00DD11E3 /* CDatePickerViewEx.m in Sources */,
C19BBC191BBE865400831290 /* VankeFloorListBoard_iPhone.m in Sources */, C19BBC191BBE865400831290 /* VankeFloorListBoard_iPhone.m in Sources */,
C1D598B81BB44B2000D297FE /* Bee_UIWebView.m in Sources */, C1D598B81BB44B2000D297FE /* Bee_UIWebView.m in Sources */,
C12804FD1BC417A6001ECBAA /* VankeProjectSummaryModel.m in Sources */, C12804FD1BC417A6001ECBAA /* VankeProjectSummaryModel.m in Sources */,
......
//
// CDatePickerViewEx.h
// MonthYearDatePicker
//
// Created by Igor on 18.03.13.
// Copyright (c) 2013 Igor. All rights reserved.
//
@interface CDatePickerViewEx : UIPickerView <UIPickerViewDelegate, UIPickerViewDataSource>
@property (nonatomic, strong) UIColor *monthSelectedTextColor;
@property (nonatomic, strong) UIColor *monthTextColor;
@property (nonatomic, strong) UIColor *yearSelectedTextColor;
@property (nonatomic, strong) UIColor *yearTextColor;
@property (nonatomic, strong) UIFont *monthSelectedFont;
@property (nonatomic, strong) UIFont *monthFont;
@property (nonatomic, strong) UIFont *yearSelectedFont;
@property (nonatomic, strong) UIFont *yearFont;
@property (nonatomic, assign) NSInteger rowHeight;
@property (nonatomic, strong, readonly) NSDate *date;
-(void)setupMinYear:(NSInteger)minYear maxYear:(NSInteger)maxYear;
-(void)selectToday;
@end
\ No newline at end of file
//
// CDatePickerViewEx.m
// MonthYearDatePicker
//
// Created by Igor on 18.03.13.
// Copyright (c) 2013 Igor. All rights reserved.
//
#import "CDatePickerViewEx.h"
// Identifiers of components
#define MONTH ( 1 )
#define YEAR ( 0 )
// Identifies for component views
#define LABEL_TAG 43
@interface CDatePickerViewEx()
@property (nonatomic, strong) NSIndexPath *todayIndexPath;
@property (nonatomic, strong) NSArray *months;
@property (nonatomic, strong) NSArray *years;
@property (nonatomic, assign) NSInteger minYear;
@property (nonatomic, assign) NSInteger maxYear;
@end
@implementation CDatePickerViewEx
const NSInteger bigRowCount = 1000;
const NSInteger numberOfComponents = 2;
#pragma mark - Properties
-(void)setMonthFont:(UIFont *)monthFont
{
if (monthFont)
{
_monthFont = monthFont;
}
}
-(void)setMonthSelectedFont:(UIFont *)monthSelectedFont
{
if (monthSelectedFont)
{
_monthSelectedFont = monthSelectedFont;
}
}
-(void)setYearFont:(UIFont *)yearFont
{
if (yearFont)
{
_yearFont = yearFont;
}
}
-(void)setYearSelectedFont:(UIFont *)yearSelectedFont
{
if (yearSelectedFont)
{
_yearSelectedFont = yearSelectedFont;
}
}
#pragma mark - Init
-(instancetype)init
{
if (self = [super init])
{
[self loadDefaultsParameters];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
[self loadDefaultsParameters];
}
return self;
}
-(void)awakeFromNib
{
[super awakeFromNib];
[self loadDefaultsParameters];
}
#pragma mark - Open methods
-(NSDate *)date
{
NSInteger monthCount = self.months.count;
NSString *month = [self.months objectAtIndex:([self selectedRowInComponent:MONTH] % monthCount)];
NSInteger yearCount = self.years.count;
NSString *year = [self.years objectAtIndex:([self selectedRowInComponent:YEAR] % yearCount)];
NSDateFormatter *formatter = [NSDateFormatter new];
[formatter setDateFormat:@"MMMM:yyyy"];
NSDate *date = [formatter dateFromString:[NSString stringWithFormat:@"%@:%@", month, year]];
return date;
}
- (void)setupMinYear:(NSInteger)minYear maxYear:(NSInteger)maxYear
{
self.minYear = minYear;
if (maxYear > minYear)
{
self.maxYear = maxYear;
}
else
{
self.maxYear = minYear + 10;
}
self.years = [self nameOfYears];
self.todayIndexPath = [self todayPath];
}
-(void)selectToday
{
[self selectRow: self.todayIndexPath.row
inComponent: MONTH
animated: NO];
[self selectRow: self.todayIndexPath.section
inComponent: YEAR
animated: NO];
}
#pragma mark - UIPickerViewDelegate
-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
return [self componentWidth];
}
-(UIView *)pickerView: (UIPickerView *)pickerView viewForRow: (NSInteger)row forComponent: (NSInteger)component reusingView: (UIView *)view
{
BOOL selected = NO;
if(component == MONTH)
{
NSInteger monthCount = self.months.count;
NSString *monthName = [self.months objectAtIndex:(row % monthCount)];
NSString *currentMonthName = [self currentMonthName];
if([monthName isEqualToString:currentMonthName] == YES)
{
selected = YES;
}
}
else
{
NSInteger yearCount = self.years.count;
NSString *yearName = [self.years objectAtIndex:(row % yearCount)];
NSString *currenrYearName = [self currentYearName];
if([yearName isEqualToString:currenrYearName] == YES)
{
selected = YES;
}
}
UILabel *returnView = nil;
if(view.tag == LABEL_TAG)
{
returnView = (UILabel *)view;
}
else
{
returnView = [self labelForComponent:component];
}
returnView.font = selected ? [self selectedFontForComponent:component] : [self fontForComponent:component];
returnView.textColor = selected ? [self selectedColorForComponent:component] : [self colorForComponent:component];
returnView.text = [self titleForRow:row forComponent:component];
return returnView;
}
-(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return self.rowHeight;
}
#pragma mark - UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return numberOfComponents;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if(component == MONTH)
{
return [self bigRowMonthCount];
}
return [self bigRowYearCount];
}
#pragma mark - Util
-(NSInteger)bigRowMonthCount
{
return self.months.count * bigRowCount;
}
-(NSInteger)bigRowYearCount
{
return self.years.count * bigRowCount;
}
-(CGFloat)componentWidth
{
// return (self.bounds.size.width - 100) / numberOfComponents;
return 100.0f;
}
-(NSString *)titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if(component == MONTH)
{
NSInteger monthCount = self.months.count;
return [self.months objectAtIndex:(row % monthCount)];
}
NSInteger yearCount = self.years.count;
return [self.years objectAtIndex:(row % yearCount)];
}
-(UILabel *)labelForComponent:(NSInteger)component
{
CGRect frame = CGRectMake(0, 0, [self componentWidth], self.rowHeight);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.userInteractionEnabled = NO;
label.tag = LABEL_TAG;
return label;
}
-(NSArray *)nameOfMonths
{
return @[@"1月", @"2月", @"3月", @"4月", @"5月", @"6月", @"7月", @"8月", @"9月", @"10月", @"11月", @"12月"];
}
-(NSArray *)nameOfYears
{
NSMutableArray *years = [NSMutableArray array];
for(NSInteger year = self.minYear; year <= self.maxYear; year++)
{
NSString *yearStr = [NSString stringWithFormat:@"%li年", (long)year];
[years addObject:yearStr];
}
return years;
}
-(NSIndexPath *)todayPath // row - month ; section - year
{
CGFloat row = 0.f;
CGFloat section = 0.f;
NSString *month = [self currentMonthName];
NSString *year = [self currentYearName];
//set table on the middle
for(NSString *cellMonth in self.months)
{
if([cellMonth isEqualToString:month])
{
row = [self.months indexOfObject:cellMonth];
row = row + [self bigRowMonthCount] / 2;
break;
}
}
for(NSString *cellYear in self.years)
{
if([cellYear isEqualToString:year])
{
section = [self.years indexOfObject:cellYear];
section = section + [self bigRowYearCount] / 2;
break;
}
}
return [NSIndexPath indexPathForRow:row inSection:section];
}
-(NSString *)currentMonthName
{
NSDateFormatter *formatter = [NSDateFormatter new];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_Hans_CN"];
[formatter setLocale:usLocale];
[formatter setDateFormat:@"MMMM"];
return [formatter stringFromDate:[NSDate date]];
}
-(NSString *)currentYearName
{
NSDateFormatter *formatter = [NSDateFormatter new];
[formatter setDateFormat:@"yyyy"];
return [formatter stringFromDate:[NSDate date]];
}
- (UIColor *)selectedColorForComponent:(NSInteger)component
{
if (component == 0)
{
return self.monthSelectedTextColor;
}
return self.yearSelectedTextColor;
}
- (UIColor *)colorForComponent:(NSInteger)component
{
if (component == 0)
{
return self.monthTextColor;
}
return self.yearTextColor;
}
- (UIFont *)selectedFontForComponent:(NSInteger)component
{
if (component == 0)
{
return self.monthSelectedFont;
}
return self.yearSelectedFont;
}
- (UIFont *)fontForComponent:(NSInteger)component
{
if (component == 0)
{
return self.monthFont;
}
return self.yearFont;
}
-(void)loadDefaultsParameters
{
self.minYear = 2008;
self.maxYear = 2030;
self.rowHeight = 44;
self.months = [self nameOfMonths];
self.years = [self nameOfYears];
self.todayIndexPath = [self todayPath];
self.delegate = self;
self.dataSource = self;
self.monthSelectedTextColor = [UIColor blueColor];
self.monthTextColor = [UIColor blackColor];
self.yearSelectedTextColor = [UIColor blueColor];
self.yearTextColor = [UIColor blackColor];
self.monthSelectedFont = [UIFont boldSystemFontOfSize:17];
self.monthFont = [UIFont boldSystemFontOfSize:17];
self.yearSelectedFont = [UIFont boldSystemFontOfSize:17];
self.yearFont = [UIFont boldSystemFontOfSize:17];
}
@end
\ No newline at end of file
...@@ -30,14 +30,14 @@ ...@@ -30,14 +30,14 @@
-(BeeHTTPRequest*) http_post: (NSString*) url { -(BeeHTTPRequest*) http_post: (NSString*) url {
NSString *absUrl = [NSString stringWithFormat:@"%@%@", VANKE_SERVER_BASE_URL, url]; NSString *absUrl = [NSString stringWithFormat:@"%@%@", VANKE_SERVER_BASE_URL, url];
BeeHTTPRequest *req = self.HTTP_POST(absUrl); BeeHTTPRequest *req = self.HTTP_POST(absUrl);
[[[self addAuthorizationToHeader:req] addJsonContentTypeToHeader:req] addEnterpriseIdToHeader:req]; [self addHeaders:req];;
return req; return req;
} }
-(BeeHTTPRequest*) http_get: (NSString*) url { -(BeeHTTPRequest*) http_get: (NSString*) url {
NSString *absUrl = [NSString stringWithFormat:@"%@/%@", VANKE_SERVER_BASE_URL, url]; NSString *absUrl = [NSString stringWithFormat:@"%@/%@", VANKE_SERVER_BASE_URL, url];
BeeHTTPRequest *req = self.HTTP_GET(absUrl); BeeHTTPRequest *req = self.HTTP_GET(absUrl);
[[[self addAuthorizationToHeader:req] addJsonContentTypeToHeader:req] addEnterpriseIdToHeader:req]; [self addHeaders:req];
return req; return req;
} }
...@@ -46,22 +46,20 @@ ...@@ -46,22 +46,20 @@
[self setLastError:-1 domain:BeeMessage.ERROR_DOMAIN_CLIENT desc:error]; [self setLastError:-1 domain:BeeMessage.ERROR_DOMAIN_CLIENT desc:error];
} }
-(VankeBaseAPI*) addAuthorizationToHeader: (BeeHTTPRequest*) req { -(VankeBaseAPI*) addHeaders: (BeeHTTPRequest*) req {
NSString *src = [NSString stringWithFormat:@"%@:%@", VANKE_SERVER_USER_NAME, VANKE_SERVER_PASSWORD]; req.HEADER(@"Content-Type", @"application/json;charset=utf-8");
req.HEADER(@"Authorization", [NSString stringWithFormat:@"Basic %@", [VankeUtil base64:src]]); req.HEADER(@"Accept", @"application/json;charset=utf-8");
return self;
}
-(VankeBaseAPI*) addJsonContentTypeToHeader: (BeeHTTPRequest*) req {
req.HEADER(@"Content-Type", @"application/json");
return self;
}
-(VankeBaseAPI*) addEnterpriseIdToHeader: (BeeHTTPRequest*) req {
Enterpirse *ent = [[VankeCommonModel sharedInstance] currentEnt]; Enterpirse *ent = [[VankeCommonModel sharedInstance] currentEnt];
if (nil != ent && ![VankeUtil isBlankString:ent.uuid]) { if (nil != ent && ![VankeUtil isBlankString:ent.uuid]) {
req.HEADER(@"enterprise", ent.uuid); req.HEADER(@"enterprise", ent.uuid);
} }
NSString *src = [NSString stringWithFormat:@"%@:%@", VANKE_SERVER_USER_NAME, VANKE_SERVER_PASSWORD];
NSString *auth = [NSString stringWithFormat:@"Basic %@", [VankeUtil base64:src]];
INFO(auth);
req.HEADER(@"Authorization", auth);
return self; return self;
} }
......
...@@ -12,21 +12,21 @@ ...@@ -12,21 +12,21 @@
@class Paging; @class Paging;
@class SubjectItem; @class SubjectItem;
@class StatementSummary; @class StatementShop;
@class StatementListResponse; @class StatementListResponse;
/* /*
* 查询对账单列表 * 查询对账单列表
* http://.../wanke-server/rest/project/queryprojectsby?classificationEquals={classificationEquals}&nameLike={nameLike}&salesDateEquals={salesDateEquals}& passengerDateEquals={passengerDateEquals}&trafficDateEquals={trafficDateEquals} * http://.../wanke-server/rest/statement/query?settleEquals={settleEquals}&confirmed={confirmed}&authorizedOrgIn={authorizedOrgIn}&shopLike={shopLike}&pageNumber={pageNumber}&pageSize={pageSize}
*/ */
@interface VankeSettlementListAPI : VankeBaseAPI @interface VankeSettlementListAPI : VankeBaseAPI
// 账期等于 // 账期等于
@property (nonatomic, strong) NSDate *settleEquals; @property (nonatomic, strong) NSDate *settleEquals;
// 是否已确认 // 状态: unconfirmed, confirmed, rejected
@property (nonatomic, assign) BOOL confirmed; @property (nonatomic, strong) NSString *billState;
// 项目列表 // 项目列表
@property (nonatomic, strong) NSArray *projectsIn; @property (nonatomic, strong) NSArray *projectsIn;
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
// 商铺名称或代码类似于 // 商铺名称或代码类似于
@property (nonatomic, strong) NSString *shopLike; @property (nonatomic, strong) NSString *shopLike;
@property (nonatomic, assign) NSInteger pageNumber;
@property (nonatomic, assign) NSInteger pageSize;
@end @end
// 分页信息 // 分页信息
...@@ -65,7 +68,7 @@ ...@@ -65,7 +68,7 @@
@property (nonatomic, strong) NSString *shopCode; @property (nonatomic, strong) NSString *shopCode;
@property (nonatomic, strong) NSString *shopName; @property (nonatomic, strong) NSString *shopName;
@property (nonatomic, strong) NSString *picture; @property (nonatomic, strong) NSString *picture;
@property (nonatomic, strong) NSDate *settle; @property (nonatomic, strong) NSString *settle;
@property (nonatomic, strong) NSNumber *amount; @property (nonatomic, strong) NSNumber *amount;
@property (nonatomic, strong) NSString *state; @property (nonatomic, strong) NSString *state;
@property (nonatomic, strong) NSArray *items; // SubjectItem @property (nonatomic, strong) NSArray *items; // SubjectItem
...@@ -76,16 +79,20 @@ ...@@ -76,16 +79,20 @@
@end @end
@interface StatementListResponseData : BeeActiveObject
@property (nonatomic, strong) NSNumber *amount;
@property (nonatomic, strong) Paging *paging;
@property (nonatomic, strong) NSArray *records; // StatementShop
@end
// 对账单返回 // 对账单返回
@interface StatementListResponse : VankeResponse @interface StatementListResponse : VankeResponse
@property (nonatomic, strong) NSDate *settle; @property (nonatomic, strong) NSDate *settle;
@property (nonatomic, strong) NSNumber *amount; @property (nonatomic, strong) StatementListResponseData *data;
@property (nonatomic, strong) Paging *paging;
@property (nonatomic, strong) NSArray *records; // StatementSummary
-(BOOL) hasMore; -(BOOL) hasMore;
+(instancetype) fakeData;
@end @end
\ No newline at end of file
...@@ -13,34 +13,42 @@ ...@@ -13,34 +13,42 @@
@implementation VankeSettlementListAPI @implementation VankeSettlementListAPI
@synthesize settleEquals = _settleEquals; @synthesize settleEquals = _settleEquals;
@synthesize confirmed = _confirmed; @synthesize billState = _billState;
@synthesize projectsIn = _projectsIn; @synthesize projectsIn = _projectsIn;
@synthesize shopLike = _shopLike; @synthesize shopLike = _shopLike;
@synthesize pageNumber = _pageNumber;
@synthesize pageSize = _pageSize;
-(void) route:(BeeMessage *)msg { -(void) route:(BeeMessage *)msg {
if (self.sending) if (self.sending)
{ {
// if (![self checkToQuery]) { if (![self checkToQuery]) {
// return; return;
// } }
// [self http_get:@"/statement/query"].PARAM(@"settleEquals", self.settleEquals).PARAM(@"prjectsIn", [self.projectsIn componentsJoinedByString:@";"]).TIMEOUT(10); BeeHTTPRequest *request = [self http_get:@"/statement/query"].PARAM(@"settleEquals", [self getSettleStr]).PARAM(@"authorizedOrgIn", [self.projectsIn componentsJoinedByString:@";"])
[self HTTP_GET:@"http://www.baidu.com"].TIMEOUT(10); .PARAM(@"pageNumber", [NSString stringWithFormat:@"%lu", _pageNumber - 1]).PARAM(@"pageSize", [NSString stringWithFormat:@"%lu", _pageSize]);
if (![VankeUtil isBlankString:_billState]) {
request.PARAMS(@"state", _billState);
}
if (![VankeUtil isBlankString:_shopLike]) {
request.PARAM(@"shopLike", _shopLike);
}
request.TIMEOUT(10);
} }
else if (self.succeed) else if (self.succeed)
{ {
NSLog(@"response: %@", self.responseString); NSLog(@"response: %@", self.responseString);
// self.serverResp = [StatementListResponse objectFromDictionary: self.responseJSONDictionary]; StatementListResponse *resp = [StatementListResponse objectFromDictionary: self.responseJSONDictionary];
// if (nil == self.serverResp)
// {
// self.failed = YES;
// return;
// }
StatementListResponse *resp = [StatementListResponse fakeData];
resp.settle = self.settleEquals; resp.settle = self.settleEquals;
self.serverResp = resp; self.serverResp = resp;
if (nil == self.serverResp)
{
self.failed = YES;
return;
}
} else if (self.failed) { } else if (self.failed) {
NSLog(@"response: %@", self.responseString); NSLog(@"response: %@", self.responseString);
self.serverResp = [StatementListResponse objectFromDictionary: self.responseJSONDictionary]; self.serverResp = [StatementListResponse objectFromDictionary: self.responseJSONDictionary];
...@@ -48,9 +56,7 @@ ...@@ -48,9 +56,7 @@
} }
-(BOOL) checkToQuery { -(BOOL) checkToQuery {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; if (nil == _settleEquals) {
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
if ([VankeUtil isBlankString:[dateFormatter stringFromDate:self.settleEquals]]) {
[self setClientError: @"账期不能为空"]; [self setClientError: @"账期不能为空"];
return NO; return NO;
} }
...@@ -63,6 +69,16 @@ ...@@ -63,6 +69,16 @@
return YES; return YES;
} }
-(NSString*) getSettleStr {
if (nil == _settleEquals) {
return @"";
}
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyyMM"];
return [dateFormatter stringFromDate:_settleEquals];
}
@end @end
#pragma Paging #pragma Paging
...@@ -123,89 +139,30 @@ CONVERT_PROPERTY_CLASS(items, SubjectItem) ...@@ -123,89 +139,30 @@ CONVERT_PROPERTY_CLASS(items, SubjectItem)
@end @end
#pragma StatementListResponse #pragma StatementListResponseData
@implementation StatementListResponse @implementation StatementListResponseData
@synthesize settle = _settle;
@synthesize amount = _amount; @synthesize amount = _amount;
@synthesize paging = _paging; @synthesize paging = _paging;
@synthesize records = _records; @synthesize records = _records;
CONVERT_PROPERTY_CLASS(records, StatementShop) CONVERT_PROPERTY_CLASS(records, StatementShop)
-(BOOL) hasMore { @end
return _paging && _paging.pageSize <= _paging.recordCount;
}
#define ARC4RANDOM_MAX 0x100000000 #pragma StatementListResponse
+(NSNumber*) randomDouble { @implementation StatementListResponse
double val = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10000.0f);
return [NSNumber numberWithDouble:val];
}
+(NSNumber*) randomInt { @synthesize settle = _settle;
double val = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10000.0f); @synthesize data = _data;
return [NSNumber numberWithInt:val];
}
+(instancetype) fakeData { -(BOOL) hasMore {
StatementListResponse *resp = [[StatementListResponse alloc] init]; return _data && _data.paging && (_data.paging.pageSize <= _data.paging.recordCount);
resp.amount = [self randomDouble];
Paging *paging = [[Paging alloc] init];
paging.page = [NSNumber numberWithInt:1];
paging.pageSize = [NSNumber numberWithInt:10];
paging.pageCount = [NSNumber numberWithInt:10];
paging.recordCount = [NSNumber numberWithInt:11];
resp.paging = paging;
NSMutableArray *shops = [[NSMutableArray alloc] initWithCapacity:10];
for (int i = 0; i < [paging.pageSize intValue]; ++i) {
StatementShop *summary = [[StatementShop alloc] init];
summary.contract = @"112233";
summary.shopCode = [NSString stringWithFormat:@"%03d", i];
summary.shopName = @"肯得起";
// summary.picture = @"";
summary.settle = [NSDate date];
double val = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10000.0f);
summary.amount = [NSNumber numberWithDouble:val];
val = arc4random() % 3;
if (val == 0) {
summary.state = @"confirmed";
} if (val == 1) {
summary.state = @"unconfirmed";
} else if (val == 2){
summary.state = @"rejected";
}
NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:10];
for( int i = 0; i < 100; ++i) {
SubjectItem *item = [[SubjectItem alloc] init];
item.subject = @"月固定租金";
item.beginDate = @"2015-12-01";
item.endDate = @"2015-12-30";
item.direction = [NSNumber numberWithInt:1];
val = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10000.0f);
if (arc4random() % 100 > 50) {
val = -val;
item.direction = [NSNumber numberWithInt:-1];
}
item.amount = [NSNumber numberWithDouble:val];
item.remark = @"有意见,不同意";
[items addObject:item];
}
summary.items = items;
[shops addObject:summary];
}
resp.records = shops;
return resp;
} }
@end @end
...@@ -60,23 +60,23 @@ DEF_SINGLETON(VankeCommonModel) ...@@ -60,23 +60,23 @@ DEF_SINGLETON(VankeCommonModel)
} }
-(NSArray*) getAuthOrgs { -(NSArray*) getAuthOrgs {
// LoginResponseData *data = [self getLoginInfo]; LoginResponseData *data = [self getLoginInfo];
// if (nil != data) { if (nil != data) {
// return data.authorizedOrgs; return data.authorizedOrgs;
// } else { } else {
// return nil; return nil;
// }
// TODO FOR TEST
NSMutableArray *ary = [[NSMutableArray alloc] initWithCapacity:20];
for( int i = 0; i < 20; ++i) {
AuthorizedOrg *org = [[AuthorizedOrg alloc] init];
org.uuid = [NSString stringWithFormat:@"%d", i];
org.code = [NSString stringWithFormat:@"CODE%d", i];
org.name = [NSString stringWithFormat:@"项目%d", i];
org.picture = [NSString stringWithFormat:@"PICTURE%d", i];
[ary addObject:org];
} }
return ary; // TODO FOR TEST
// NSMutableArray *ary = [[NSMutableArray alloc] initWithCapacity:20];
// for( int i = 0; i < 20; ++i) {
// AuthorizedOrg *org = [[AuthorizedOrg alloc] init];
// org.uuid = [NSString stringWithFormat:@"%d", i];
// org.code = [NSString stringWithFormat:@"CODE%d", i];
// org.name = [NSString stringWithFormat:@"项目%d", i];
// org.picture = [NSString stringWithFormat:@"PICTURE%d", i];
// [ary addObject:org];
// }
// return ary;
} }
- (NSString*) currentUserPwd { - (NSString*) currentUserPwd {
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
// 账期等于 // 账期等于
@property (nonatomic, strong) NSDate *settleEquals; @property (nonatomic, strong) NSDate *settleEquals;
// 是否已确认 // 状态:unconfirmed, confirmed, rejected
@property (nonatomic, assign) BOOL confirmed; @property (nonatomic, strong) NSString *billState;
// 项目列表 // 项目列表
@property (nonatomic, strong) NSArray *projectsIn; @property (nonatomic, strong) NSArray *projectsIn;
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
// 最后一次响应结果 // 最后一次响应结果
@property (nonatomic, strong) StatementListResponse *lastResp; @property (nonatomic, strong) StatementListResponse *lastResp;
-(NSInteger) count;
@end @end
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
#import "VankeStatementListModel.h" #import "VankeStatementListModel.h"
#undef PER_PAGE #undef PAGE_SIZE
#define PER_PAGE (10) #define PAGE_SIZE (20)
@implementation VankeStatementListModel @implementation VankeStatementListModel
@synthesize settleEquals = _settleEquals; @synthesize settleEquals = _settleEquals;
@synthesize confirmed = _confirmed; @synthesize billState = _billState;
@synthesize projectsIn = _projectsIn; @synthesize projectsIn = _projectsIn;
@synthesize shopLike = _shopLike; @synthesize shopLike = _shopLike;
@synthesize shops = _shops; @synthesize shops = _shops;
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- (void)unload - (void)unload
{ {
self.settleEquals = nil; self.settleEquals = nil;
self.confirmed = nil; self.billState = nil;
self.projectsIn = nil; self.projectsIn = nil;
self.shopLike = nil; self.shopLike = nil;
self.shops = nil; self.shops = nil;
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
{ {
if ( self.shops.count ) if ( self.shops.count )
{ {
[self gotoPage:(self.shops.count / PER_PAGE + 1)]; [self gotoPage:(self.shops.count / PAGE_SIZE + 1)];
} }
} }
...@@ -60,9 +60,11 @@ ...@@ -60,9 +60,11 @@
@weakify(self); @weakify(self);
api.settleEquals = self.settleEquals; api.settleEquals = self.settleEquals;
api.confirmed = self.confirmed; api.billState = self.billState;
api.projectsIn = self.projectsIn; api.projectsIn = self.projectsIn;
api.shopLike = self.shopLike; api.shopLike = self.shopLike;
api.pageNumber = page;
api.pageSize = PAGE_SIZE;
api.whenUpdate = ^ api.whenUpdate = ^
{ {
...@@ -79,7 +81,7 @@ ...@@ -79,7 +81,7 @@
{ {
StatementListResponse *resp = (StatementListResponse*) api.serverResp; StatementListResponse *resp = (StatementListResponse*) api.serverResp;
self.lastResp = resp; self.lastResp = resp;
if ( nil == resp || nil == resp.records ) if ( nil == resp || nil == resp.data || nil == resp.data.records )
{ {
api.failed = YES; api.failed = YES;
} }
...@@ -88,11 +90,11 @@ ...@@ -88,11 +90,11 @@
if ( page <= 1 ) if ( page <= 1 )
{ {
[self.shops removeAllObjects]; [self.shops removeAllObjects];
[self.shops addObjectsFromArray:resp.records]; [self.shops addObjectsFromArray:resp.data.records];
} }
else else
{ {
[self.shops addObjectsFromArray:resp.records]; [self.shops addObjectsFromArray:resp.data.records];
[self.shops unique:^NSComparisonResult(id left, id right) { [self.shops unique:^NSComparisonResult(id left, id right) {
return [((StatementShop*)left).shopCode compare:((StatementShop*)right).shopCode]; return [((StatementShop*)left).shopCode compare:((StatementShop*)right).shopCode];
}]; }];
......
...@@ -148,7 +148,6 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnServiceApply, signal) { ...@@ -148,7 +148,6 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnServiceApply, signal) {
- (void)popoverListView:(UIPopoverListView *)popoverListView - (void)popoverListView:(UIPopoverListView *)popoverListView
didSelectIndexPath:(NSIndexPath *)indexPath didSelectIndexPath:(NSIndexPath *)indexPath
{ {
NSLog(@"%s : %d", __func__, indexPath.row);
AuthorizedOrg *org = [authorizedOrgs objectAtIndex:indexPath.row]; AuthorizedOrg *org = [authorizedOrgs objectAtIndex:indexPath.row];
[self showStatementList:org]; [self showStatementList:org];
} }
...@@ -160,8 +159,14 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnServiceApply, signal) { ...@@ -160,8 +159,14 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnServiceApply, signal) {
} }
-(void) showStatementList: (AuthorizedOrg*) org { -(void) showStatementList: (AuthorizedOrg*) org {
if (nil == org) {
ERROR(@"Authorized Org cannot be null.");
return;
}
[[VankeAppBoard_iPhone sharedInstance] hideMenu]; [[VankeAppBoard_iPhone sharedInstance] hideMenu];
VankeStatementListBoard_iPhone *board = [VankeStatementListBoard_iPhone board]; VankeStatementListBoard_iPhone *board = [VankeStatementListBoard_iPhone board];
board.authorizedOrgUuidEquals = org.uuid;
[self.stack pushBoard:board animated:YES]; [self.stack pushBoard:board animated:YES];
} }
......
...@@ -29,6 +29,8 @@ AS_OUTLET( BeeUIScrollView, list ) ...@@ -29,6 +29,8 @@ AS_OUTLET( BeeUIScrollView, list )
AS_OUTLET( VankeStatementDetailMonthCell_iPhone, settlementBar) AS_OUTLET( VankeStatementDetailMonthCell_iPhone, settlementBar)
AS_OUTLET( BeeUIImageView, imgState) AS_OUTLET( BeeUIImageView, imgState)
@property (nonatomic, strong) NSString *authorizedOrgUuidEquals;
@property (nonatomic, strong) NSDate *settleEquals;
@property (nonatomic, strong) StatementShop *data; @property (nonatomic, strong) StatementShop *data;
@end @end
...@@ -38,6 +38,8 @@ SUPPORT_AUTOMATIC_LAYOUT( YES ) ...@@ -38,6 +38,8 @@ SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES ) SUPPORT_RESOURCE_LOADING( YES )
@synthesize data = _data; @synthesize data = _data;
@synthesize settleEquals = _settleEquals;
@synthesize authorizedOrgUuidEquals = _authorizedOrgUuidEquals;
DEF_MODEL( VankeStatementListModel, model ) DEF_MODEL( VankeStatementListModel, model )
DEF_OUTLET( BeeUIScrollView, list ) DEF_OUTLET( BeeUIScrollView, list )
...@@ -65,72 +67,7 @@ ON_CREATE_VIEWS( signal ) ...@@ -65,72 +67,7 @@ ON_CREATE_VIEWS( signal )
self.title = [_data codeName]; self.title = [_data codeName];
[self showOperButtons: [_data unconfirmed]]; [self showOperButtons: [_data unconfirmed]];
self.list.headerClass = [PullLoader class]; [self initListAndModel];
self.list.headerShown = YES;
self.list.footerClass = [FootLoader class];
self.list.footerShown = YES;
self.list.lineCount = 1;
self.list.animationDuration = 0.2f;
self.list.baseInsets = bee.ui.config.baseInsets;
self.list.whenReloading = ^
{
self.list.total = self.model.shops.count;
INFO(@"total = %d", self.model.shops.count);
if (self.model.loaded && self.list.total <= 0) {
self.list.total = 1;
BeeUIScrollItem * item = self.list.items[0];
item.size = CGSizeMake( self.list.width, 50);
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [NoDataCell_iPhoneCell class];
item.data = @"没有数据,请稍后重试!";
} else {
for ( BeeUIScrollItem *item in self.list.items )
{
item.size = CGSizeMake( self.list.width / self.list.lineCount, 80 );
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [VankeStatementDetailListCell_iPhone class];
SubjectItem *subject = [_data.items safeObjectAtIndex:item.index];
item.data = subject;
}
}
};
self.list.whenReloaded = ^
{
};
self.list.whenAnimated = ^
{
};
self.list.whenScrolling = ^
{
};
self.list.whenStop = ^
{
};
self.list.whenHeaderRefresh = ^
{
[self.model firstPage];
};
self.list.whenFooterRefresh = ^
{
[self.model nextPage];
};
// TODO
// self.model.classificationEquals = _projectCategory;
// self.model.nameLike = _projectNameLike;
// self.model.salesDateEquals = _salesDate;
// _searchBar.text = _projectNameLike;
//TODO 这里要求重新查询明细
_model.settleEquals = [NSDate date];
} }
...@@ -217,7 +154,8 @@ ON_SIGNAL3(VankeStatementDetailMonthCell_iPhone, pickerMask, signal) { ...@@ -217,7 +154,8 @@ ON_SIGNAL3(VankeStatementDetailMonthCell_iPhone, pickerMask, signal) {
[alertController addAction:({ [alertController addAction:({
UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// 立即设置账期 // 立即设置账期
self.model.settleEquals = picker.date; self.settleEquals = picker.date;
self.model.settleEquals = self.settleEquals;
[self.model firstPage]; [self.model firstPage];
}]; }];
action; action;
...@@ -279,4 +217,82 @@ ON_SIGNAL3(VankeStatementDetailListBoard_iPhone, btnConfirm, signal) { ...@@ -279,4 +217,82 @@ ON_SIGNAL3(VankeStatementDetailListBoard_iPhone, btnConfirm, signal) {
} }
} }
-(void) initListAndModel {
self.list.headerClass = [PullLoader class];
self.list.headerShown = YES;
self.list.footerClass = [FootLoader class];
self.list.footerShown = YES;
self.list.lineCount = 1;
self.list.animationDuration = 0.2f;
self.list.baseInsets = bee.ui.config.baseInsets;
self.list.whenReloading = ^
{
[self initCurrentData];
self.list.total = _data.items.count;
INFO(@"total = %d", _data.items.count);
if (self.list.total <= 0) {
self.list.total = 1;
BeeUIScrollItem * item = self.list.items[0];
item.size = CGSizeMake( self.list.width, 50);
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [NoDataCell_iPhoneCell class];
item.data = @"没有数据,请稍后重试!";
} else {
for ( BeeUIScrollItem *item in self.list.items )
{
item.size = CGSizeMake( self.list.width / self.list.lineCount, 80 );
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [VankeStatementDetailListCell_iPhone class];
SubjectItem *subject = [_data.items safeObjectAtIndex:item.index];
item.data = subject;
}
}
};
self.list.whenReloaded = ^
{
};
self.list.whenAnimated = ^
{
};
self.list.whenScrolling = ^
{
};
self.list.whenStop = ^
{
};
self.list.whenHeaderRefresh = ^
{
[self.model firstPage];
};
self.list.whenFooterRefresh = ^
{
[self.model nextPage];
};
if (![VankeUtil isBlankString:_data.shopCode]) {
_model.shopLike = _data.shopCode;
}
_model.projectsIn = [[NSArray alloc] initWithObjects:_authorizedOrgUuidEquals, nil];
_model.settleEquals = _settleEquals;
}
-(void) initCurrentData {
for (StatementShop *shop in _model.shops) {
if (nil != _data && nil != _data.shopCode && [_data.shopCode eq:shop.shopCode]) {
_data = shop;
break;
}
}
}
@end @end
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
AS_OUTLET(BeeUIImageView, imgPhoto) AS_OUTLET(BeeUIImageView, imgPhoto)
AS_OUTLET(BeeUILabel, lblName) AS_OUTLET(BeeUILabel, lblName)
AS_OUTLET(BeeUIImageView, lblState)
AS_OUTLET(BeeUILabel, lblAmount) AS_OUTLET(BeeUILabel, lblAmount)
AS_OUTLET(BeeUILabel, lblDateRange) AS_OUTLET(BeeUILabel, lblDateRange)
......
...@@ -27,7 +27,6 @@ SUPPORT_RESOURCE_LOADING( YES ) ...@@ -27,7 +27,6 @@ SUPPORT_RESOURCE_LOADING( YES )
DEF_OUTLET(BeeUIImageView, imgPhoto) DEF_OUTLET(BeeUIImageView, imgPhoto)
DEF_OUTLET(BeeUILabel, lblName) DEF_OUTLET(BeeUILabel, lblName)
DEF_OUTLET(BeeUIImageView, lblState)
DEF_OUTLET(BeeUILabel, lblAmount) DEF_OUTLET(BeeUILabel, lblAmount)
DEF_OUTLET(BeeUILabel, lblDateRange) DEF_OUTLET(BeeUILabel, lblDateRange)
...@@ -53,10 +52,21 @@ DEF_OUTLET(BeeUILabel, lblDateRange) ...@@ -53,10 +52,21 @@ DEF_OUTLET(BeeUILabel, lblDateRange)
} }
$(self.lblName).DATA(item.subject); $(self.lblName).DATA(item.subject);
$(self.lblState).DATA(@"已确认");
$(self.lblAmount).DATA(item.amount.description); $(self.lblAmount).DATA(item.amount.description);
$(self.lblDateRange).DATA([NSString stringWithFormat:@"%@ 至 %@", item.beginDate, item.endDate]);
NSString *beginDate = [self trancateToDateString: item.beginDate];
NSString *endDate = [self trancateToDateString: item.endDate];
$(self.lblDateRange).DATA([NSString stringWithFormat:@"%@ 至 %@", beginDate, endDate]);
}
-(NSString*) trancateToDateString: (NSString*) dateTimeStr {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:dateTimeStr];
NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];
[dateFormatter2 setDateFormat:@"yyyy-MM-dd"];
return [dateFormatter2 stringFromDate:date];
} }
- (void)layoutDidFinish - (void)layoutDidFinish
......
...@@ -46,7 +46,10 @@ DEF_OUTLET( BeeUILabel, lblTotalPrefix ) ...@@ -46,7 +46,10 @@ DEF_OUTLET( BeeUILabel, lblTotalPrefix )
return; return;
} }
[self setSettleDate:shop.settle]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyyMM"];
NSDate *settleDate = [dateFormatter dateFromString:shop.settle];
[self setSettleDate:settleDate];
$(self.lblAmount).DATA(shop.amount.description); $(self.lblAmount).DATA(shop.amount.description);
} }
......
...@@ -24,8 +24,12 @@ ...@@ -24,8 +24,12 @@
@interface VankeStatementListBoard_iPhone : VankeBaseBoard @interface VankeStatementListBoard_iPhone : VankeBaseBoard
AS_MODEL( VankeStatementListModel, model ) // 授权组织标识,非空
@property (nonatomic, strong) NSString *authorizedOrgUuidEquals;
// 商铺名称类似,可空
@property (nonatomic, strong) NSString *shopLike;
AS_MODEL( VankeStatementListModel, model )
AS_OUTLET( BeeUIScrollView, list ) AS_OUTLET( BeeUIScrollView, list )
AS_OUTLET( BeeUISearchBar, searchBar) AS_OUTLET( BeeUISearchBar, searchBar)
AS_OUTLET( VankeStatementMonthCell_iPhone, settlementBar) AS_OUTLET( VankeStatementMonthCell_iPhone, settlementBar)
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#import "FootLoader.h" #import "FootLoader.h"
#import "VankeUtil.h" #import "VankeUtil.h"
#import "GEToast.h" #import "GEToast.h"
#import "CDatePickerViewEx.h"
#import "NoDataCell_iPhoneCell.h" #import "NoDataCell_iPhoneCell.h"
#import "VankeStatementListItemCell_iPhone.h" #import "VankeStatementListItemCell_iPhone.h"
#import "VankeStatementDetailListBoard_iPhone.h" #import "VankeStatementDetailListBoard_iPhone.h"
...@@ -37,6 +38,9 @@ ...@@ -37,6 +38,9 @@
SUPPORT_AUTOMATIC_LAYOUT( YES ) SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES ) SUPPORT_RESOURCE_LOADING( YES )
@synthesize shopLike = _shopLike;
@synthesize authorizedOrgUuidEquals = _authorizedOrgUuidEquals;
DEF_MODEL( VankeStatementListModel, model ) DEF_MODEL( VankeStatementListModel, model )
DEF_OUTLET( BeeUIScrollView, list ) DEF_OUTLET( BeeUIScrollView, list )
DEF_OUTLET( BeeUISearchBar, searchBar) DEF_OUTLET( BeeUISearchBar, searchBar)
...@@ -57,76 +61,10 @@ DEF_OUTLET( VankeStatementMonthCell_iPhone, settlementBar) ...@@ -57,76 +61,10 @@ DEF_OUTLET( VankeStatementMonthCell_iPhone, settlementBar)
ON_CREATE_VIEWS( signal ) ON_CREATE_VIEWS( signal )
{ {
[UIApplication sharedApplication].statusBarHidden = NO; [UIApplication sharedApplication].statusBarHidden = NO;
self.navigationBarShown = YES; self.navigationBarShown = YES;
self.allowedSwipeToBack = YES; self.allowedSwipeToBack = YES;
self.title = @"对账单"; self.title = @"对账单";
[self initListAndModel];
self.list.headerClass = [PullLoader class];
self.list.headerShown = YES;
self.list.footerClass = [FootLoader class];
self.list.footerShown = YES;
self.list.lineCount = 1;
self.list.animationDuration = 0.2f;
self.list.baseInsets = bee.ui.config.baseInsets;
self.list.whenReloading = ^
{
self.list.total = self.model.shops.count;
INFO(@"total = %d", self.model.shops.count);
if (self.model.loaded && self.list.total <= 0) {
self.list.total = 1;
BeeUIScrollItem * item = self.list.items[0];
item.size = CGSizeMake( self.list.width, 50);
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [NoDataCell_iPhoneCell class];
item.data = @"没有数据,请稍后重试!";
} else {
for ( BeeUIScrollItem *item in self.list.items )
{
item.size = CGSizeMake( self.list.width / self.list.lineCount, 70 );
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [VankeStatementListItemCell_iPhone class];
StatementShop *shop = [self.model.shops safeObjectAtIndex:item.index];
item.data = shop;
}
}
};
self.list.whenReloaded = ^
{
};
self.list.whenAnimated = ^
{
};
self.list.whenScrolling = ^
{
};
self.list.whenStop = ^
{
};
self.list.whenHeaderRefresh = ^
{
[self.model firstPage];
};
self.list.whenFooterRefresh = ^
{
[self.model nextPage];
};
// TODO
// self.model.classificationEquals = _projectCategory;
// self.model.nameLike = _projectNameLike;
// self.model.salesDateEquals = _salesDate;
// _searchBar.text = _projectNameLike;
_model.settleEquals = [NSDate date];
} }
ON_DELETE_VIEWS( signal ) ON_DELETE_VIEWS( signal )
...@@ -140,8 +78,6 @@ ON_LAYOUT_VIEWS( signal ) ...@@ -140,8 +78,6 @@ ON_LAYOUT_VIEWS( signal )
ON_WILL_APPEAR( signal ) ON_WILL_APPEAR( signal )
{ {
self.navigationBarShown = YES; self.navigationBarShown = YES;
// [self.list reloadData];
if ( NO == self.model.loaded ) if ( NO == self.model.loaded )
{ {
[self.model firstPage]; [self.model firstPage];
...@@ -153,7 +89,6 @@ ON_WILL_APPEAR( signal ) ...@@ -153,7 +89,6 @@ ON_WILL_APPEAR( signal )
} else { } else {
self.navigationController.navigationBar.tintColor = color; self.navigationController.navigationBar.tintColor = color;
} }
[BeeUIRouter sharedInstance].view.pannable = YES; [BeeUIRouter sharedInstance].view.pannable = YES;
} }
...@@ -202,15 +137,20 @@ ON_SIGNAL3( VankeStatementListModel, RELOADED, signal ) ...@@ -202,15 +137,20 @@ ON_SIGNAL3( VankeStatementListModel, RELOADED, signal )
ON_SIGNAL3(VankeStatementMonthCell_iPhone, pickerMask, signal) { ON_SIGNAL3(VankeStatementMonthCell_iPhone, pickerMask, signal) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIDatePicker *picker = [[UIDatePicker alloc] init]; // CDatePickerViewEx *picker = [[CDatePickerViewEx alloc] init];
UIDatePicker *picker = [[UIDatePicker alloc]init];
[picker setDatePickerMode:UIDatePickerModeDate]; [picker setDatePickerMode:UIDatePickerModeDate];
[picker setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_Hans_CN"]]; [picker setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_Hans_CN"]];
if (nil != _settlementBar.settleDate) {
[picker setDate:_settlementBar.settleDate];
}
[alertController.view addSubview:picker]; [alertController.view addSubview:picker];
[alertController addAction:({ [alertController addAction:({
UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// 立即设置账期 // 立即设置账期
self.model.settleEquals = picker.date; self.model.settleEquals = picker.date;
[self.model firstPage]; [self.model firstPage];
}]; }];
action; action;
})]; })];
...@@ -231,7 +171,76 @@ ON_SIGNAL3(VankeStatementListItemCell_iPhone, mask, signal) { ...@@ -231,7 +171,76 @@ ON_SIGNAL3(VankeStatementListItemCell_iPhone, mask, signal) {
StatementShop *cellValue = signal.sourceCell.data; StatementShop *cellValue = signal.sourceCell.data;
VankeStatementDetailListBoard_iPhone *board = [VankeStatementDetailListBoard_iPhone board]; VankeStatementDetailListBoard_iPhone *board = [VankeStatementDetailListBoard_iPhone board];
board.data = cellValue; board.data = cellValue;
board.settleEquals = _model.settleEquals;
board.authorizedOrgUuidEquals = _authorizedOrgUuidEquals;
[self.stack pushBoard:board animated:YES]; [self.stack pushBoard:board animated:YES];
} }
#pragma private methods
-(void) initListAndModel {
self.list.headerClass = [PullLoader class];
self.list.headerShown = YES;
self.list.footerClass = [FootLoader class];
self.list.footerShown = YES;
self.list.lineCount = 1;
self.list.animationDuration = 0.2f;
self.list.baseInsets = bee.ui.config.baseInsets;
self.list.whenReloading = ^
{
self.list.total = self.model.shops.count;
INFO(@"total = %d", self.model.shops.count);
if (self.list.total <= 0) {
self.list.total = 1;
BeeUIScrollItem * item = self.list.items[0];
item.size = CGSizeMake( self.list.width, 50);
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [NoDataCell_iPhoneCell class];
item.data = @"没有数据,请稍后重试!";
} else {
for ( BeeUIScrollItem *item in self.list.items )
{
item.size = CGSizeMake( self.list.width / self.list.lineCount, 70 );
item.order = 0;
item.rule = BeeUIScrollLayoutRule_Fall;
item.clazz = [VankeStatementListItemCell_iPhone class];
StatementShop *shop = [self.model.shops safeObjectAtIndex:item.index];
item.data = shop;
}
}
};
self.list.whenReloaded = ^
{
};
self.list.whenAnimated = ^
{
};
self.list.whenScrolling = ^
{
};
self.list.whenStop = ^
{
};
self.list.whenHeaderRefresh = ^
{
[self.model firstPage];
};
self.list.whenFooterRefresh = ^
{
[self.model nextPage];
};
_model.shopLike = _shopLike;
_model.projectsIn = [[NSArray alloc] initWithObjects:_authorizedOrgUuidEquals, nil];
_model.settleEquals = [NSDate date];
}
@end @end
...@@ -29,7 +29,7 @@ AS_OUTLET( BeeUILabel, lblCount ) ...@@ -29,7 +29,7 @@ AS_OUTLET( BeeUILabel, lblCount )
AS_OUTLET( BeeUILabel, lblAmount ) AS_OUTLET( BeeUILabel, lblAmount )
AS_OUTLET( BeeUILabel, lblTotalPrefix ) AS_OUTLET( BeeUILabel, lblTotalPrefix )
-(void) setSettleDate: (NSDate*) date; @property (nonatomic, strong) NSDate *settleDate;
@end @end
...@@ -31,6 +31,8 @@ DEF_OUTLET( BeeUILabel, lblCount ) ...@@ -31,6 +31,8 @@ DEF_OUTLET( BeeUILabel, lblCount )
DEF_OUTLET( BeeUILabel, lblAmount ) DEF_OUTLET( BeeUILabel, lblAmount )
DEF_OUTLET( BeeUILabel, lblTotalPrefix ) DEF_OUTLET( BeeUILabel, lblTotalPrefix )
@synthesize settleDate = _settleDate;
- (void)load - (void)load
{ {
...@@ -44,12 +46,15 @@ DEF_OUTLET( BeeUILabel, lblTotalPrefix ) ...@@ -44,12 +46,15 @@ DEF_OUTLET( BeeUILabel, lblTotalPrefix )
{ {
StatementListResponse *resp = (StatementListResponse*) self.data; StatementListResponse *resp = (StatementListResponse*) self.data;
if (nil == resp) { if (nil == resp) {
[self setSettleDate:[NSDate date]];
$(self.lblCount).DATA(@"0");
$(self.lblAmount).DATA(@"0");
return; return;
} }
[self setSettleDate:resp.settle]; [self setSettleDate:resp.settle];
$(self.lblCount).DATA([NSString stringWithFormat:@"%d", [resp.paging.recordCount intValue]]); $(self.lblCount).DATA([NSString stringWithFormat:@"%d", [resp.data.paging.recordCount intValue]]);
$(self.lblAmount).DATA(resp.amount.description); $(self.lblAmount).DATA(nil == resp.data.amount? @"0": resp.data.amount.description);
} }
- (void)layoutDidFinish - (void)layoutDidFinish
...@@ -58,6 +63,8 @@ DEF_OUTLET( BeeUILabel, lblTotalPrefix ) ...@@ -58,6 +63,8 @@ DEF_OUTLET( BeeUILabel, lblTotalPrefix )
} }
-(void) setSettleDate: (NSDate*) date { -(void) setSettleDate: (NSDate*) date {
_settleDate = date;
if (nil == date) { if (nil == date) {
$(self.lblYear).DATA(@""); $(self.lblYear).DATA(@"");
$(self.lblMonth).DATA(@""); $(self.lblMonth).DATA(@"");
......
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