diff --git a/YHB_Prj/YHB_Prj.xcodeproj/project.pbxproj b/YHB_Prj/YHB_Prj.xcodeproj/project.pbxproj index e4439b4..0c42e97 100644 --- a/YHB_Prj/YHB_Prj.xcodeproj/project.pbxproj +++ b/YHB_Prj/YHB_Prj.xcodeproj/project.pbxproj @@ -45,6 +45,13 @@ AB25793F1B8F02010015039A /* IQToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = AB25792E1B8F02010015039A /* IQToolbar.m */; }; AB2579401B8F02010015039A /* IQUIView+IQKeyboardToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = AB2579301B8F02010015039A /* IQUIView+IQKeyboardToolbar.m */; }; AB2579411B8F02010015039A /* IQKeyboardManager.bundle in Resources */ = {isa = PBXBuildFile; fileRef = AB2579331B8F02010015039A /* IQKeyboardManager.bundle */; }; + AB311F8C1B9BDBFE0070784E /* ProblemGoodsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB311F8B1B9BDBFE0070784E /* ProblemGoodsViewController.m */; }; + AB311F901B9BDC260070784E /* ProblemGoodsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = AB311F8E1B9BDC260070784E /* ProblemGoodsCell.m */; }; + AB311F911B9BDC260070784E /* ProblemGoodsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB311F8F1B9BDC260070784E /* ProblemGoodsCell.xib */; }; + AB311F941B9BE0100070784E /* ProblemGoodsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = AB311F931B9BE0100070784E /* ProblemGoodsManager.m */; }; + AB311F9C1B9BFCEE0070784E /* PGPicList.m in Sources */ = {isa = PBXBuildFile; fileRef = AB311F971B9BFCEE0070784E /* PGPicList.m */; }; + AB311F9D1B9BFCEE0070784E /* PGResult.m in Sources */ = {isa = PBXBuildFile; fileRef = AB311F991B9BFCEE0070784E /* PGResult.m */; }; + AB311F9E1B9BFCEE0070784E /* PGRows.m in Sources */ = {isa = PBXBuildFile; fileRef = AB311F9B1B9BFCEE0070784E /* PGRows.m */; }; AB358E431B99855C007D62E9 /* YDCXDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB358E421B99855C007D62E9 /* YDCXDetailViewController.m */; }; AB358E471B99B47B007D62E9 /* YDCXDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = AB358E451B99B47B007D62E9 /* YDCXDetailCell.m */; }; AB358E481B99B47B007D62E9 /* YDCXDetailCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB358E461B99B47B007D62E9 /* YDCXDetailCell.xib */; }; @@ -307,6 +314,19 @@ AB2579301B8F02010015039A /* IQUIView+IQKeyboardToolbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "IQUIView+IQKeyboardToolbar.m"; sourceTree = ""; }; AB2579311B8F02010015039A /* KeyboardManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyboardManager.h; sourceTree = ""; }; AB2579331B8F02010015039A /* IQKeyboardManager.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = IQKeyboardManager.bundle; sourceTree = ""; }; + AB311F8A1B9BDBFE0070784E /* ProblemGoodsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProblemGoodsViewController.h; sourceTree = ""; }; + AB311F8B1B9BDBFE0070784E /* ProblemGoodsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProblemGoodsViewController.m; sourceTree = ""; }; + AB311F8D1B9BDC260070784E /* ProblemGoodsCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProblemGoodsCell.h; sourceTree = ""; }; + AB311F8E1B9BDC260070784E /* ProblemGoodsCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProblemGoodsCell.m; sourceTree = ""; }; + AB311F8F1B9BDC260070784E /* ProblemGoodsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ProblemGoodsCell.xib; sourceTree = ""; }; + AB311F921B9BE0100070784E /* ProblemGoodsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProblemGoodsManager.h; sourceTree = ""; }; + AB311F931B9BE0100070784E /* ProblemGoodsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProblemGoodsManager.m; sourceTree = ""; }; + AB311F961B9BFCEE0070784E /* PGPicList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PGPicList.h; sourceTree = ""; }; + AB311F971B9BFCEE0070784E /* PGPicList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PGPicList.m; sourceTree = ""; }; + AB311F981B9BFCEE0070784E /* PGResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PGResult.h; sourceTree = ""; }; + AB311F991B9BFCEE0070784E /* PGResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PGResult.m; sourceTree = ""; }; + AB311F9A1B9BFCEE0070784E /* PGRows.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PGRows.h; sourceTree = ""; }; + AB311F9B1B9BFCEE0070784E /* PGRows.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PGRows.m; sourceTree = ""; }; AB358E411B99855C007D62E9 /* YDCXDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YDCXDetailViewController.h; sourceTree = ""; }; AB358E421B99855C007D62E9 /* YDCXDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YDCXDetailViewController.m; sourceTree = ""; }; AB358E441B99B47B007D62E9 /* YDCXDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YDCXDetailCell.h; sourceTree = ""; }; @@ -870,6 +890,34 @@ path = Resources; sourceTree = ""; }; + AB311F891B9BDBEA0070784E /* ProblemGoods */ = { + isa = PBXGroup; + children = ( + AB311F951B9BFCE60070784E /* PGModel */, + AB311F8A1B9BDBFE0070784E /* ProblemGoodsViewController.h */, + AB311F8B1B9BDBFE0070784E /* ProblemGoodsViewController.m */, + AB311F8D1B9BDC260070784E /* ProblemGoodsCell.h */, + AB311F8E1B9BDC260070784E /* ProblemGoodsCell.m */, + AB311F8F1B9BDC260070784E /* ProblemGoodsCell.xib */, + AB311F921B9BE0100070784E /* ProblemGoodsManager.h */, + AB311F931B9BE0100070784E /* ProblemGoodsManager.m */, + ); + path = ProblemGoods; + sourceTree = ""; + }; + AB311F951B9BFCE60070784E /* PGModel */ = { + isa = PBXGroup; + children = ( + AB311F961B9BFCEE0070784E /* PGPicList.h */, + AB311F971B9BFCEE0070784E /* PGPicList.m */, + AB311F981B9BFCEE0070784E /* PGResult.h */, + AB311F991B9BFCEE0070784E /* PGResult.m */, + AB311F9A1B9BFCEE0070784E /* PGRows.h */, + AB311F9B1B9BFCEE0070784E /* PGRows.m */, + ); + path = PGModel; + sourceTree = ""; + }; AB3877A31B97D06E00DD7468 /* Yudanchaxun */ = { isa = PBXGroup; children = ( @@ -1276,6 +1324,7 @@ FF2A6C8D1A0F3CC9001607AC /* FourthViewController */ = { isa = PBXGroup; children = ( + AB311F891B9BDBEA0070784E /* ProblemGoods */, AB9F43E61B92E45000914C85 /* SettingVC */, ABEF1DAC1B92AD1800C1C2EA /* Tenant */, AB8844181B913DA500FA526D /* ChooseLocaVC */, @@ -1735,6 +1784,7 @@ FFD26CEB1B8C1B3B0003F491 /* KCYJViewController.xib in Resources */, FF5CC7101B9420E000F55713 /* JCCXCell.xib in Resources */, FF5CC7011B93EE5300F55713 /* RukuDetailViewController.xib in Resources */, + AB311F911B9BDC260070784E /* ProblemGoodsCell.xib in Resources */, FFD26CF51B8C546F0003F491 /* ZCBCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1818,6 +1868,7 @@ AB25793B1B8F02010015039A /* IQSegmentedNextPrevious.m in Sources */, AB88441E1B914D0F00FA526D /* CLTableViewCell.m in Sources */, FFD26CF41B8C546F0003F491 /* ZCBCell.m in Sources */, + AB311F901B9BDC260070784E /* ProblemGoodsCell.m in Sources */, FF2A6C0C1A0F3A01001607AC /* UIImage+ImageEffects.m in Sources */, FF2A6C791A0F3B7B001607AC /* UIImageView+WebCache.m in Sources */, FF5CC7021B93EE5300F55713 /* RuKushenpinVC.m in Sources */, @@ -1834,6 +1885,7 @@ AB3877AE1B97DF8200DD7468 /* YDCXManager.m in Sources */, FF2A6C781A0F3B7B001607AC /* UIImageView+HighlightedWebCache.m in Sources */, FFD26CE11B8B10970003F491 /* KCYJMode.m in Sources */, + AB311F9C1B9BFCEE0070784E /* PGPicList.m in Sources */, AB8071C51B96C7AA002114C9 /* EmpManage.m in Sources */, ABEF1DA71B929D5400C1C2EA /* SupplierDetailViewController.m in Sources */, 5B1F7FA01B90A9C000763059 /* DJProductCheckListCell.m in Sources */, @@ -1882,6 +1934,7 @@ FF5CC7001B93EE5300F55713 /* RukuDetailViewController.m in Sources */, AB2579401B8F02010015039A /* IQUIView+IQKeyboardToolbar.m in Sources */, 5B1F7F921B8F690400763059 /* DJProductCheckVC.m in Sources */, + AB311F9D1B9BFCEE0070784E /* PGResult.m in Sources */, FF5C86F81B81B72400F79EC1 /* MASCompositeConstraint.m in Sources */, FF2A6C441A0F3B6D001607AC /* SVProgressHUD.m in Sources */, FF5C871C1B83024C00F79EC1 /* FMDatabase.m in Sources */, @@ -1898,6 +1951,7 @@ ABAACA0A1B95BE7600305080 /* SupplierMode.m in Sources */, FF4DFD0B1B85CBFA00617660 /* StoreListView.m in Sources */, 5B54BA421B9336C7002098A4 /* DJCheckCartCell.m in Sources */, + AB311F9E1B9BFCEE0070784E /* PGRows.m in Sources */, FF2A6C711A0F3B7B001607AC /* SDWebImageDownloaderOperation.m in Sources */, 5B54BA3B1B92B0BC002098A4 /* DJCheckCartNetService.m in Sources */, 5B1F7F991B8F73C000763059 /* CALayer+CCAddition.m in Sources */, @@ -1914,8 +1968,10 @@ FF2A6C891A0F3B8A001607AC /* UIScrollView+SVPullToRefresh.m in Sources */, FFD26CEA1B8C1B3B0003F491 /* KCYJViewController.m in Sources */, AB8844161B913D6300FA526D /* UITableView+DataSourceBlocks.m in Sources */, + AB311F941B9BE0100070784E /* ProblemGoodsManager.m in Sources */, FF2A6C991A0F3D1C001607AC /* ThirdViewController.m in Sources */, FF5CC70A1B93FA0B00F55713 /* JCCXViewController.m in Sources */, + AB311F8C1B9BDBFE0070784E /* ProblemGoodsViewController.m in Sources */, ABAAFB6F1B996B250012D1C6 /* DJYDCXRows.m in Sources */, AB42ACD01B8B4140001FB93A /* FourthTableViewCell.m in Sources */, FFF391971B846F58007DC652 /* AFNetworkReachabilityManager.m in Sources */, diff --git a/YHB_Prj/YHB_Prj/FourthViewController/FourthViewController.m b/YHB_Prj/YHB_Prj/FourthViewController/FourthViewController.m index 09d4183..308504f 100644 --- a/YHB_Prj/YHB_Prj/FourthViewController/FourthViewController.m +++ b/YHB_Prj/YHB_Prj/FourthViewController/FourthViewController.m @@ -17,6 +17,7 @@ #import "LoginManager.h" #import "SDWebImageManager.h" #import "NetManager.h" +#import "ProblemGoodsViewController.h" #define userFace @"userFace" @@ -235,7 +236,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath break; case cellTypeMatter: - + { + ProblemGoodsViewController *vc = [[ProblemGoodsViewController alloc] init]; + vc.hidesBottomBarWhenPushed = YES; + [self.navigationController pushViewController:vc animated:YES]; + break; + } break; default: break; diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGPicList.h b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGPicList.h new file mode 100644 index 0000000..02f6e45 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGPicList.h @@ -0,0 +1,24 @@ +// +// PGPicList.h +// +// Created by Johnny on 15/9/6 +// Copyright (c) 2015 __MyCompanyName__. All rights reserved. +// + +#import + + + +@interface PGPicList : NSObject + +@property (nonatomic, assign) double picListIdentifier; +@property (nonatomic, strong) NSString *picUrl; +@property (nonatomic, assign) double uid; +@property (nonatomic, assign) double pid; +@property (nonatomic, strong) NSString *picDomain; + ++ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict; +- (instancetype)initWithDictionary:(NSDictionary *)dict; +- (NSDictionary *)dictionaryRepresentation; + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGPicList.m b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGPicList.m new file mode 100644 index 0000000..4e18563 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGPicList.m @@ -0,0 +1,123 @@ +// +// PGPicList.m +// +// Created by Johnny on 15/9/6 +// Copyright (c) 2015 __MyCompanyName__. All rights reserved. +// + +#import "PGPicList.h" + + +NSString *const kPGPicListId = @"id"; +NSString *const kPGPicListPicUrl = @"pic_url"; +NSString *const kPGPicListUid = @"uid"; +NSString *const kPGPicListPid = @"pid"; +NSString *const kPGPicListPicDomain = @"pic_domain"; + + +@interface PGPicList () + +- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict; + +@end + +@implementation PGPicList + +@synthesize picListIdentifier = _picListIdentifier; +@synthesize picUrl = _picUrl; +@synthesize uid = _uid; +@synthesize pid = _pid; +@synthesize picDomain = _picDomain; + + ++ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict +{ + return [[self alloc] initWithDictionary:dict]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)dict +{ + self = [super init]; + + // This check serves to make sure that a non-NSDictionary object + // passed into the model class doesn't break the parsing. + if(self && [dict isKindOfClass:[NSDictionary class]]) { + self.picListIdentifier = [[self objectOrNilForKey:kPGPicListId fromDictionary:dict] doubleValue]; + self.picUrl = [self objectOrNilForKey:kPGPicListPicUrl fromDictionary:dict]; + self.uid = [[self objectOrNilForKey:kPGPicListUid fromDictionary:dict] doubleValue]; + self.pid = [[self objectOrNilForKey:kPGPicListPid fromDictionary:dict] doubleValue]; + self.picDomain = [self objectOrNilForKey:kPGPicListPicDomain fromDictionary:dict]; + + } + + return self; + +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary]; + [mutableDict setValue:[NSNumber numberWithDouble:self.picListIdentifier] forKey:kPGPicListId]; + [mutableDict setValue:self.picUrl forKey:kPGPicListPicUrl]; + [mutableDict setValue:[NSNumber numberWithDouble:self.uid] forKey:kPGPicListUid]; + [mutableDict setValue:[NSNumber numberWithDouble:self.pid] forKey:kPGPicListPid]; + [mutableDict setValue:self.picDomain forKey:kPGPicListPicDomain]; + + return [NSDictionary dictionaryWithDictionary:mutableDict]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]]; +} + +#pragma mark - Helper Method +- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict +{ + id object = [dict objectForKey:aKey]; + return [object isEqual:[NSNull null]] ? nil : object; +} + + +#pragma mark - NSCoding Methods + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super init]; + + self.picListIdentifier = [aDecoder decodeDoubleForKey:kPGPicListId]; + self.picUrl = [aDecoder decodeObjectForKey:kPGPicListPicUrl]; + self.uid = [aDecoder decodeDoubleForKey:kPGPicListUid]; + self.pid = [aDecoder decodeDoubleForKey:kPGPicListPid]; + self.picDomain = [aDecoder decodeObjectForKey:kPGPicListPicDomain]; + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + + [aCoder encodeDouble:_picListIdentifier forKey:kPGPicListId]; + [aCoder encodeObject:_picUrl forKey:kPGPicListPicUrl]; + [aCoder encodeDouble:_uid forKey:kPGPicListUid]; + [aCoder encodeDouble:_pid forKey:kPGPicListPid]; + [aCoder encodeObject:_picDomain forKey:kPGPicListPicDomain]; +} + +- (id)copyWithZone:(NSZone *)zone +{ + PGPicList *copy = [[PGPicList alloc] init]; + + if (copy) { + + copy.picListIdentifier = self.picListIdentifier; + copy.picUrl = [self.picUrl copyWithZone:zone]; + copy.uid = self.uid; + copy.pid = self.pid; + copy.picDomain = [self.picDomain copyWithZone:zone]; + } + + return copy; +} + + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGResult.h b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGResult.h new file mode 100644 index 0000000..e92081b --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGResult.h @@ -0,0 +1,24 @@ +// +// PGResult.h +// +// Created by Johnny on 15/9/6 +// Copyright (c) 2015 __MyCompanyName__. All rights reserved. +// + +#import + + + +@interface PGResult : NSObject + +@property (nonatomic, assign) double autoCount; +@property (nonatomic, assign) double needPage; +@property (nonatomic, strong) NSArray *rows; +@property (nonatomic, assign) double pageSize; +@property (nonatomic, assign) double pageNo; + ++ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict; +- (instancetype)initWithDictionary:(NSDictionary *)dict; +- (NSDictionary *)dictionaryRepresentation; + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGResult.m b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGResult.m new file mode 100644 index 0000000..5239784 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGResult.m @@ -0,0 +1,146 @@ +// +// PGResult.m +// +// Created by Johnny on 15/9/6 +// Copyright (c) 2015 __MyCompanyName__. All rights reserved. +// + +#import "PGResult.h" +#import "PGRows.h" + + +NSString *const kPGResultAutoCount = @"autoCount"; +NSString *const kPGResultNeedPage = @"needPage"; +NSString *const kPGResultRows = @"rows"; +NSString *const kPGResultPageSize = @"pageSize"; +NSString *const kPGResultPageNo = @"pageNo"; + + +@interface PGResult () + +- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict; + +@end + +@implementation PGResult + +@synthesize autoCount = _autoCount; +@synthesize needPage = _needPage; +@synthesize rows = _rows; +@synthesize pageSize = _pageSize; +@synthesize pageNo = _pageNo; + + ++ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict +{ + return [[self alloc] initWithDictionary:dict]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)dict +{ + self = [super init]; + + // This check serves to make sure that a non-NSDictionary object + // passed into the model class doesn't break the parsing. + if(self && [dict isKindOfClass:[NSDictionary class]]) { + self.autoCount = [[self objectOrNilForKey:kPGResultAutoCount fromDictionary:dict] doubleValue]; + self.needPage = [[self objectOrNilForKey:kPGResultNeedPage fromDictionary:dict] doubleValue]; + NSObject *receivedPGRows = [dict objectForKey:kPGResultRows]; + NSMutableArray *parsedPGRows = [NSMutableArray array]; + if ([receivedPGRows isKindOfClass:[NSArray class]]) { + for (NSDictionary *item in (NSArray *)receivedPGRows) { + if ([item isKindOfClass:[NSDictionary class]]) { + [parsedPGRows addObject:[PGRows modelObjectWithDictionary:item]]; + } + } + } else if ([receivedPGRows isKindOfClass:[NSDictionary class]]) { + [parsedPGRows addObject:[PGRows modelObjectWithDictionary:(NSDictionary *)receivedPGRows]]; + } + + self.rows = [NSArray arrayWithArray:parsedPGRows]; + self.pageSize = [[self objectOrNilForKey:kPGResultPageSize fromDictionary:dict] doubleValue]; + self.pageNo = [[self objectOrNilForKey:kPGResultPageNo fromDictionary:dict] doubleValue]; + + } + + return self; + +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary]; + [mutableDict setValue:[NSNumber numberWithDouble:self.autoCount] forKey:kPGResultAutoCount]; + [mutableDict setValue:[NSNumber numberWithDouble:self.needPage] forKey:kPGResultNeedPage]; + NSMutableArray *tempArrayForRows = [NSMutableArray array]; + for (NSObject *subArrayObject in self.rows) { + if([subArrayObject respondsToSelector:@selector(dictionaryRepresentation)]) { + // This class is a model object + [tempArrayForRows addObject:[subArrayObject performSelector:@selector(dictionaryRepresentation)]]; + } else { + // Generic object + [tempArrayForRows addObject:subArrayObject]; + } + } + [mutableDict setValue:[NSArray arrayWithArray:tempArrayForRows] forKey:kPGResultRows]; + [mutableDict setValue:[NSNumber numberWithDouble:self.pageSize] forKey:kPGResultPageSize]; + [mutableDict setValue:[NSNumber numberWithDouble:self.pageNo] forKey:kPGResultPageNo]; + + return [NSDictionary dictionaryWithDictionary:mutableDict]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]]; +} + +#pragma mark - Helper Method +- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict +{ + id object = [dict objectForKey:aKey]; + return [object isEqual:[NSNull null]] ? nil : object; +} + + +#pragma mark - NSCoding Methods + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super init]; + + self.autoCount = [aDecoder decodeDoubleForKey:kPGResultAutoCount]; + self.needPage = [aDecoder decodeDoubleForKey:kPGResultNeedPage]; + self.rows = [aDecoder decodeObjectForKey:kPGResultRows]; + self.pageSize = [aDecoder decodeDoubleForKey:kPGResultPageSize]; + self.pageNo = [aDecoder decodeDoubleForKey:kPGResultPageNo]; + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + + [aCoder encodeDouble:_autoCount forKey:kPGResultAutoCount]; + [aCoder encodeDouble:_needPage forKey:kPGResultNeedPage]; + [aCoder encodeObject:_rows forKey:kPGResultRows]; + [aCoder encodeDouble:_pageSize forKey:kPGResultPageSize]; + [aCoder encodeDouble:_pageNo forKey:kPGResultPageNo]; +} + +- (id)copyWithZone:(NSZone *)zone +{ + PGResult *copy = [[PGResult alloc] init]; + + if (copy) { + + copy.autoCount = self.autoCount; + copy.needPage = self.needPage; + copy.rows = [self.rows copyWithZone:zone]; + copy.pageSize = self.pageSize; + copy.pageNo = self.pageNo; + } + + return copy; +} + + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGRows.h b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGRows.h new file mode 100644 index 0000000..25a40fb --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGRows.h @@ -0,0 +1,37 @@ +// +// PGRows.h +// +// Created by Johnny on 15/9/6 +// Copyright (c) 2015 __MyCompanyName__. All rights reserved. +// + +#import + + + +@interface PGRows : NSObject + +@property (nonatomic, assign) double rowsIdentifier; +@property (nonatomic, assign) double stayQty; +@property (nonatomic, assign) double sysPid; +@property (nonatomic, assign) double uid; +@property (nonatomic, strong) NSString *productName; +@property (nonatomic, strong) NSString *clsName; +@property (nonatomic, assign) double stockQty; +@property (nonatomic, strong) NSString *checkLastTime; +@property (nonatomic, assign) double actValue; +@property (nonatomic, assign) double buyingPrice; +@property (nonatomic, assign) double cid; +@property (nonatomic, assign) double hasPic; +@property (nonatomic, assign) double salePrice; +@property (nonatomic, strong) NSArray *picList; +@property (nonatomic, assign) double isScore; +@property (nonatomic, assign) double productCode; +@property (nonatomic, assign) double actEnabled; +@property (nonatomic, strong) NSString *saleUnit; + ++ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict; +- (instancetype)initWithDictionary:(NSDictionary *)dict; +- (NSDictionary *)dictionaryRepresentation; + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGRows.m b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGRows.m new file mode 100644 index 0000000..56478f4 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/PGModel/PGRows.m @@ -0,0 +1,237 @@ +// +// PGRows.m +// +// Created by Johnny on 15/9/6 +// Copyright (c) 2015 __MyCompanyName__. All rights reserved. +// + +#import "PGRows.h" +#import "PGPicList.h" + + +NSString *const kPGRowsId = @"id"; +NSString *const kPGRowsStayQty = @"stay_qty"; +NSString *const kPGRowsSysPid = @"sysPid"; +NSString *const kPGRowsUid = @"uid"; +NSString *const kPGRowsProductName = @"product_name"; +NSString *const kPGRowsClsName = @"cls_name"; +NSString *const kPGRowsStockQty = @"stockQty"; +NSString *const kPGRowsCheckLastTime = @"check_last_time"; +NSString *const kPGRowsActValue = @"act_value"; +NSString *const kPGRowsBuyingPrice = @"buying_price"; +NSString *const kPGRowsCid = @"cid"; +NSString *const kPGRowsHasPic = @"has_pic"; +NSString *const kPGRowsSalePrice = @"sale_price"; +NSString *const kPGRowsPicList = @"picList"; +NSString *const kPGRowsIsScore = @"is_score"; +NSString *const kPGRowsProductCode = @"product_code"; +NSString *const kPGRowsActEnabled = @"act_enabled"; +NSString *const kPGRowsSaleUnit = @"sale_unit"; + + +@interface PGRows () + +- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict; + +@end + +@implementation PGRows + +@synthesize rowsIdentifier = _rowsIdentifier; +@synthesize stayQty = _stayQty; +@synthesize sysPid = _sysPid; +@synthesize uid = _uid; +@synthesize productName = _productName; +@synthesize clsName = _clsName; +@synthesize stockQty = _stockQty; +@synthesize checkLastTime = _checkLastTime; +@synthesize actValue = _actValue; +@synthesize buyingPrice = _buyingPrice; +@synthesize cid = _cid; +@synthesize hasPic = _hasPic; +@synthesize salePrice = _salePrice; +@synthesize picList = _picList; +@synthesize isScore = _isScore; +@synthesize productCode = _productCode; +@synthesize actEnabled = _actEnabled; +@synthesize saleUnit = _saleUnit; + + ++ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict +{ + return [[self alloc] initWithDictionary:dict]; +} + +- (instancetype)initWithDictionary:(NSDictionary *)dict +{ + self = [super init]; + + // This check serves to make sure that a non-NSDictionary object + // passed into the model class doesn't break the parsing. + if(self && [dict isKindOfClass:[NSDictionary class]]) { + self.rowsIdentifier = [[self objectOrNilForKey:kPGRowsId fromDictionary:dict] doubleValue]; + self.stayQty = [[self objectOrNilForKey:kPGRowsStayQty fromDictionary:dict] doubleValue]; + self.sysPid = [[self objectOrNilForKey:kPGRowsSysPid fromDictionary:dict] doubleValue]; + self.uid = [[self objectOrNilForKey:kPGRowsUid fromDictionary:dict] doubleValue]; + self.productName = [self objectOrNilForKey:kPGRowsProductName fromDictionary:dict]; + self.clsName = [self objectOrNilForKey:kPGRowsClsName fromDictionary:dict]; + self.stockQty = [[self objectOrNilForKey:kPGRowsStockQty fromDictionary:dict] doubleValue]; + self.checkLastTime = [self objectOrNilForKey:kPGRowsCheckLastTime fromDictionary:dict]; + self.actValue = [[self objectOrNilForKey:kPGRowsActValue fromDictionary:dict] doubleValue]; + self.buyingPrice = [[self objectOrNilForKey:kPGRowsBuyingPrice fromDictionary:dict] doubleValue]; + self.cid = [[self objectOrNilForKey:kPGRowsCid fromDictionary:dict] doubleValue]; + self.hasPic = [[self objectOrNilForKey:kPGRowsHasPic fromDictionary:dict] doubleValue]; + self.salePrice = [[self objectOrNilForKey:kPGRowsSalePrice fromDictionary:dict] doubleValue]; + NSObject *receivedPGPicList = [dict objectForKey:kPGRowsPicList]; + NSMutableArray *parsedPGPicList = [NSMutableArray array]; + if ([receivedPGPicList isKindOfClass:[NSArray class]]) { + for (NSDictionary *item in (NSArray *)receivedPGPicList) { + if ([item isKindOfClass:[NSDictionary class]]) { + [parsedPGPicList addObject:[PGPicList modelObjectWithDictionary:item]]; + } + } + } else if ([receivedPGPicList isKindOfClass:[NSDictionary class]]) { + [parsedPGPicList addObject:[PGPicList modelObjectWithDictionary:(NSDictionary *)receivedPGPicList]]; + } + + self.picList = [NSArray arrayWithArray:parsedPGPicList]; + self.isScore = [[self objectOrNilForKey:kPGRowsIsScore fromDictionary:dict] doubleValue]; + self.productCode = [[self objectOrNilForKey:kPGRowsProductCode fromDictionary:dict] doubleValue]; + self.actEnabled = [[self objectOrNilForKey:kPGRowsActEnabled fromDictionary:dict] doubleValue]; + self.saleUnit = [self objectOrNilForKey:kPGRowsSaleUnit fromDictionary:dict]; + + } + + return self; + +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary]; + [mutableDict setValue:[NSNumber numberWithDouble:self.rowsIdentifier] forKey:kPGRowsId]; + [mutableDict setValue:[NSNumber numberWithDouble:self.stayQty] forKey:kPGRowsStayQty]; + [mutableDict setValue:[NSNumber numberWithDouble:self.sysPid] forKey:kPGRowsSysPid]; + [mutableDict setValue:[NSNumber numberWithDouble:self.uid] forKey:kPGRowsUid]; + [mutableDict setValue:self.productName forKey:kPGRowsProductName]; + [mutableDict setValue:self.clsName forKey:kPGRowsClsName]; + [mutableDict setValue:[NSNumber numberWithDouble:self.stockQty] forKey:kPGRowsStockQty]; + [mutableDict setValue:self.checkLastTime forKey:kPGRowsCheckLastTime]; + [mutableDict setValue:[NSNumber numberWithDouble:self.actValue] forKey:kPGRowsActValue]; + [mutableDict setValue:[NSNumber numberWithDouble:self.buyingPrice] forKey:kPGRowsBuyingPrice]; + [mutableDict setValue:[NSNumber numberWithDouble:self.cid] forKey:kPGRowsCid]; + [mutableDict setValue:[NSNumber numberWithDouble:self.hasPic] forKey:kPGRowsHasPic]; + [mutableDict setValue:[NSNumber numberWithDouble:self.salePrice] forKey:kPGRowsSalePrice]; + NSMutableArray *tempArrayForPicList = [NSMutableArray array]; + for (NSObject *subArrayObject in self.picList) { + if([subArrayObject respondsToSelector:@selector(dictionaryRepresentation)]) { + // This class is a model object + [tempArrayForPicList addObject:[subArrayObject performSelector:@selector(dictionaryRepresentation)]]; + } else { + // Generic object + [tempArrayForPicList addObject:subArrayObject]; + } + } + [mutableDict setValue:[NSArray arrayWithArray:tempArrayForPicList] forKey:kPGRowsPicList]; + [mutableDict setValue:[NSNumber numberWithDouble:self.isScore] forKey:kPGRowsIsScore]; + [mutableDict setValue:[NSNumber numberWithDouble:self.productCode] forKey:kPGRowsProductCode]; + [mutableDict setValue:[NSNumber numberWithDouble:self.actEnabled] forKey:kPGRowsActEnabled]; + [mutableDict setValue:self.saleUnit forKey:kPGRowsSaleUnit]; + + return [NSDictionary dictionaryWithDictionary:mutableDict]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]]; +} + +#pragma mark - Helper Method +- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict +{ + id object = [dict objectForKey:aKey]; + return [object isEqual:[NSNull null]] ? nil : object; +} + + +#pragma mark - NSCoding Methods + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super init]; + + self.rowsIdentifier = [aDecoder decodeDoubleForKey:kPGRowsId]; + self.stayQty = [aDecoder decodeDoubleForKey:kPGRowsStayQty]; + self.sysPid = [aDecoder decodeDoubleForKey:kPGRowsSysPid]; + self.uid = [aDecoder decodeDoubleForKey:kPGRowsUid]; + self.productName = [aDecoder decodeObjectForKey:kPGRowsProductName]; + self.clsName = [aDecoder decodeObjectForKey:kPGRowsClsName]; + self.stockQty = [aDecoder decodeDoubleForKey:kPGRowsStockQty]; + self.checkLastTime = [aDecoder decodeObjectForKey:kPGRowsCheckLastTime]; + self.actValue = [aDecoder decodeDoubleForKey:kPGRowsActValue]; + self.buyingPrice = [aDecoder decodeDoubleForKey:kPGRowsBuyingPrice]; + self.cid = [aDecoder decodeDoubleForKey:kPGRowsCid]; + self.hasPic = [aDecoder decodeDoubleForKey:kPGRowsHasPic]; + self.salePrice = [aDecoder decodeDoubleForKey:kPGRowsSalePrice]; + self.picList = [aDecoder decodeObjectForKey:kPGRowsPicList]; + self.isScore = [aDecoder decodeDoubleForKey:kPGRowsIsScore]; + self.productCode = [aDecoder decodeDoubleForKey:kPGRowsProductCode]; + self.actEnabled = [aDecoder decodeDoubleForKey:kPGRowsActEnabled]; + self.saleUnit = [aDecoder decodeObjectForKey:kPGRowsSaleUnit]; + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + + [aCoder encodeDouble:_rowsIdentifier forKey:kPGRowsId]; + [aCoder encodeDouble:_stayQty forKey:kPGRowsStayQty]; + [aCoder encodeDouble:_sysPid forKey:kPGRowsSysPid]; + [aCoder encodeDouble:_uid forKey:kPGRowsUid]; + [aCoder encodeObject:_productName forKey:kPGRowsProductName]; + [aCoder encodeObject:_clsName forKey:kPGRowsClsName]; + [aCoder encodeDouble:_stockQty forKey:kPGRowsStockQty]; + [aCoder encodeObject:_checkLastTime forKey:kPGRowsCheckLastTime]; + [aCoder encodeDouble:_actValue forKey:kPGRowsActValue]; + [aCoder encodeDouble:_buyingPrice forKey:kPGRowsBuyingPrice]; + [aCoder encodeDouble:_cid forKey:kPGRowsCid]; + [aCoder encodeDouble:_hasPic forKey:kPGRowsHasPic]; + [aCoder encodeDouble:_salePrice forKey:kPGRowsSalePrice]; + [aCoder encodeObject:_picList forKey:kPGRowsPicList]; + [aCoder encodeDouble:_isScore forKey:kPGRowsIsScore]; + [aCoder encodeDouble:_productCode forKey:kPGRowsProductCode]; + [aCoder encodeDouble:_actEnabled forKey:kPGRowsActEnabled]; + [aCoder encodeObject:_saleUnit forKey:kPGRowsSaleUnit]; +} + +- (id)copyWithZone:(NSZone *)zone +{ + PGRows *copy = [[PGRows alloc] init]; + + if (copy) { + + copy.rowsIdentifier = self.rowsIdentifier; + copy.stayQty = self.stayQty; + copy.sysPid = self.sysPid; + copy.uid = self.uid; + copy.productName = [self.productName copyWithZone:zone]; + copy.clsName = [self.clsName copyWithZone:zone]; + copy.stockQty = self.stockQty; + copy.checkLastTime = [self.checkLastTime copyWithZone:zone]; + copy.actValue = self.actValue; + copy.buyingPrice = self.buyingPrice; + copy.cid = self.cid; + copy.hasPic = self.hasPic; + copy.salePrice = self.salePrice; + copy.picList = [self.picList copyWithZone:zone]; + copy.isScore = self.isScore; + copy.productCode = self.productCode; + copy.actEnabled = self.actEnabled; + copy.saleUnit = [self.saleUnit copyWithZone:zone]; + } + + return copy; +} + + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.h b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.h new file mode 100644 index 0000000..90b6ff4 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.h @@ -0,0 +1,23 @@ +// +// ProblemGoodsCell.h +// YHB_Prj +// +// Created by Johnny's on 15/9/6. +// Copyright (c) 2015年 striveliu. All rights reserved. +// + +#import +@class PGRows; +@interface ProblemGoodsCell : UITableViewCell +@property (strong, nonatomic) IBOutlet UILabel *labelOdd; +@property (strong, nonatomic) IBOutlet UILabel *labelStatus; +@property (strong, nonatomic) IBOutlet UILabel *labelName; +@property (strong, nonatomic) IBOutlet UILabel *labelInPrice; +@property (strong, nonatomic) IBOutlet UILabel *labelOutPrice; +@property (strong, nonatomic) IBOutlet UILabel *labelNum; +@property (strong, nonatomic) IBOutlet UILabel *labelType; + ++ (CGFloat)heightForCell; +- (void)resetCell; +- (void)setCellWithMode:(PGRows *)aMode; +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.m b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.m new file mode 100644 index 0000000..22a4a3a --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.m @@ -0,0 +1,52 @@ +// +// ProblemGoodsCell.m +// YHB_Prj +// +// Created by Johnny's on 15/9/6. +// Copyright (c) 2015年 striveliu. All rights reserved. +// + +#import "ProblemGoodsCell.h" +#import "PGRows.h" + +@implementation ProblemGoodsCell + +- (void)awakeFromNib { + // Initialization code +} + ++(CGFloat)heightForCell +{ + return 110; +} + +- (void)setCellWithMode:(PGRows *)aMode +{ + [self resetCell]; + self.labelInPrice.text=[NSString stringWithFormat:@"%.2f",aMode.buyingPrice]; + self.labelName.text=aMode.productName; + self.labelNum.text=[NSString stringWithFormat:@"%.f",aMode.stockQty]; + self.labelOdd.text=[NSString stringWithFormat:@"%.f",aMode.productCode]; + self.labelOutPrice.text=[NSString stringWithFormat:@"%.2f",aMode.salePrice]; +// self.labelStatus.text=@""; + self.labelType.text=aMode.clsName; +} + +- (void)resetCell +{ + self.labelInPrice.text=@""; + self.labelName.text=@""; + self.labelNum.text=@""; + self.labelOdd.text=@""; + self.labelOutPrice.text=@""; + self.labelStatus.text=@"未完成"; + self.labelType.text=@""; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.xib b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.xib new file mode 100644 index 0000000..1790e15 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsCell.xib @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsManager.h b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsManager.h new file mode 100644 index 0000000..f293540 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsManager.h @@ -0,0 +1,14 @@ +// +// ProblemGoodsManager.h +// YHB_Prj +// +// Created by Johnny's on 15/9/6. +// Copyright (c) 2015年 striveliu. All rights reserved. +// + +#import + +@interface ProblemGoodsManager : NSObject + +-(void)getProblemGoodsListWithFinishBlock:(void (^)(NSArray *))FBlock isRefresh:(BOOL)isRefresh; +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsManager.m b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsManager.m new file mode 100644 index 0000000..60da946 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsManager.m @@ -0,0 +1,50 @@ +// +// ProblemGoodsManager.m +// YHB_Prj +// +// Created by Johnny's on 15/9/6. +// Copyright (c) 2015年 striveliu. All rights reserved. +// + +#import "ProblemGoodsManager.h" +#import "NetManager.h" +#import "PGResult.h" + +@interface ProblemGoodsManager() +{ + int _currentPage; +} + +@end + +@implementation ProblemGoodsManager + +-(void)getProblemGoodsListWithFinishBlock:(void (^)(NSArray *))FBlock isRefresh:(BOOL)isRefresh +{ + if (isRefresh==YES) _currentPage=0; + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:0]; + [dict setValue:@20 forKey:@"pageSize"]; + [dict setValue:[NSNumber numberWithInt:_currentPage] forKey:@"pageNo"]; + [dict setValue:@"true" forKey:@"needPage"]; + + + [NetManager requestWith:dict apiName:@"getProblemProductList" method:@"POST" succ:^(NSDictionary *successDict) { +// MLOG(@"%@", successDict); + NSString *str = successDict[@"message"]; + if ([str isEqualToString:@"success"]) + { + NSDictionary *resultDict = successDict[@"result"]; + PGResult *result = [PGResult modelObjectWithDictionary:resultDict]; + _currentPage++; + FBlock(result.rows); + } + else + { + FBlock(nil); + } + } failure:^(NSDictionary *failDict, NSError *error) { + FBlock(nil); + }]; +} + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsViewController.h b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsViewController.h new file mode 100644 index 0000000..c4bba21 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsViewController.h @@ -0,0 +1,13 @@ +// +// ProblemGoodsViewController.h +// YHB_Prj +// +// Created by Johnny's on 15/9/6. +// Copyright (c) 2015年 striveliu. All rights reserved. +// + +#import "BaseViewController.h" + +@interface ProblemGoodsViewController : BaseViewController + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsViewController.m b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsViewController.m new file mode 100644 index 0000000..6323429 --- /dev/null +++ b/YHB_Prj/YHB_Prj/FourthViewController/ProblemGoods/ProblemGoodsViewController.m @@ -0,0 +1,127 @@ +// +// ProblemGoodsViewController.m +// YHB_Prj +// +// Created by Johnny's on 15/9/6. +// Copyright (c) 2015年 striveliu. All rights reserved. +// + +#import "ProblemGoodsViewController.h" +#import "ProblemGoodsManager.h" +#import "ProblemGoodsCell.h" +#import "PGRows.h" +#import "SVPullToRefresh.h" + +@interface ProblemGoodsViewController () + +@property(nonatomic,strong) ProblemGoodsManager *manager; +@property(nonatomic,strong) UITableView *tvGood; +@property(nonatomic,strong) NSMutableArray *arrData; +@end + +@implementation ProblemGoodsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = @"问题商品"; + self.view.backgroundColor = [UIColor whiteColor]; + + [self createView]; + + _arrData = [NSMutableArray arrayWithCapacity:0]; + + self.manager = [[ProblemGoodsManager alloc] init]; + + [self addTableViewTrag]; + [_tvGood triggerPullToRefresh]; +} + +- (void)createView +{ + _tvGood = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, kMainScreenHeight-64)]; + _tvGood.delegate = self; + _tvGood.dataSource = self; + _tvGood.separatorStyle = UITableViewCellSeparatorStyleNone; + [self.view addSubview:_tvGood]; +} + +#pragma mark 增加上拉下拉 +- (void)addTableViewTrag +{ + __weak ProblemGoodsViewController *weakself = self; + [weakself.tvGood addPullToRefreshWithActionHandler:^{ + [self.manager getProblemGoodsListWithFinishBlock:^(NSArray *resultArr) { + if (resultArr && resultArr.count>0) + { + _arrData = [resultArr mutableCopy]; + [_tvGood reloadData]; + } + else [SVProgressHUD showErrorWithStatus:@"无数据" cover:YES offsetY:kMainScreenHeight/2.0]; + [weakself.tvGood.pullToRefreshView stopAnimating]; + } isRefresh:YES]; + }]; + + + [weakself.tvGood addInfiniteScrollingWithActionHandler:^{ + if (_arrData.count%20==0 && _arrData.count!=0) + { + [self.manager getProblemGoodsListWithFinishBlock:^(NSArray *resultArr) { + if (resultArr && resultArr.count>0) + { + [_arrData addObjectsFromArray:resultArr]; + [_tvGood reloadData]; + } + else [SVProgressHUD showErrorWithStatus:@"无数据" cover:YES offsetY:kMainScreenHeight/2.0]; + [weakself.tvGood.infiniteScrollingView stopAnimating]; + } isRefresh:NO]; + } + else [weakself.tvGood.infiniteScrollingView stopAnimating]; + }]; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return _arrData.count; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return [ProblemGoodsCell heightForCell]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *cellId = @"ProblemGoodsCell"; + ProblemGoodsCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId]; + if (!cell) + { + [tableView registerNib:[UINib nibWithNibName:@"ProblemGoodsCell" bundle:nil] forCellReuseIdentifier:cellId]; + cell = [tableView dequeueReusableCellWithIdentifier:cellId]; + } + + return cell; +} + +- (void)tableView:(UITableView *)tableView willDisplayCell:(ProblemGoodsCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath +{ + cell.selectionStyle = UITableViewCellSelectionStyleNone; + PGRows *mode = _arrData[indexPath.row]; + [cell setCellWithMode:mode]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/YHB_Prj/YHB_Prj/FourthViewController/SupplierVC/SupplierViewController.m b/YHB_Prj/YHB_Prj/FourthViewController/SupplierVC/SupplierViewController.m index da90b28..391ade9 100644 --- a/YHB_Prj/YHB_Prj/FourthViewController/SupplierVC/SupplierViewController.m +++ b/YHB_Prj/YHB_Prj/FourthViewController/SupplierVC/SupplierViewController.m @@ -84,15 +84,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N [tableView registerNib:[UINib nibWithNibName:@"SupplierTableViewCell" bundle:nil] forCellReuseIdentifier:cellId]; cell = [tableView dequeueReusableCellWithIdentifier:cellId]; } - SupplierMode *mode = [self.dataArray objectAtIndex:indexPath.row]; - [cell setCellWithSupplierMode:mode]; + return cell; } - (void)tableView:(UITableView *)tableView willDisplayCell:(SupplierTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { - // cell.cellImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"mine_menu_%d", (int)indexPath.row]]; - // cell.cellTitleLabel.text = _cellTitleArray[indexPath.row]; + SupplierMode *mode = [self.dataArray objectAtIndex:indexPath.row]; + [cell setCellWithSupplierMode:mode]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXCell.m b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXCell.m index 1c72b96..23584ec 100644 --- a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXCell.m +++ b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXCell.m @@ -23,7 +23,7 @@ +(CGFloat)heightForCell - (void)setCellWithMode:(DJYDCXRows *)aMode { self.labelMoney.text = [NSString stringWithFormat:@"%.2f", aMode.realMoney]; - self.labelNum.text = [NSString stringWithFormat:@"%d", (int)aMode.rowsIdentifier]; + self.labelNum.text = [NSString stringWithFormat:@"%.f", aMode.rowsIdentifier]; self.labelOdd.text = aMode.srl; NSString *proStr; if ([aMode.profitMoney isKindOfClass:[NSString class]]) proStr = aMode.profitMoney; diff --git a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailCell.m b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailCell.m index 2c19003..0567f66 100644 --- a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailCell.m +++ b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailCell.m @@ -24,7 +24,7 @@ - (void)setCellWithMode:(DJYDCXDetailList *)aMode { [self resetCell]; self.labelName.text = aMode.productName; - self.labelNum.text = [NSString stringWithFormat:@"%d", (int)aMode.saleNum]; + self.labelNum.text = [NSString stringWithFormat:@"%.f", aMode.saleNum]; self.labelPri.text = [NSString stringWithFormat:@"%.2f", aMode.salePrice]; self.labelSum.text = [NSString stringWithFormat:@"%.2f", aMode.payableMoney]; self.labelZhe.text = [NSString stringWithFormat:@"%.2f%%", aMode.discountRate]; diff --git a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailViewController.m b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailViewController.m index 89b58f6..1c92500 100644 --- a/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailViewController.m +++ b/YHB_Prj/YHB_Prj/Yudanchaxun/YDCXDetailViewController.m @@ -75,7 +75,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N { [tableView registerNib:[UINib nibWithNibName:@"YDCXDetailCell" bundle:nil] forCellReuseIdentifier:cellId]; cell = [tableView dequeueReusableCellWithIdentifier:cellId]; - cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; @@ -83,6 +82,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)tableView:(UITableView *)tableView willDisplayCell:(YDCXDetailCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { + cell.selectionStyle = UITableViewCellSelectionStyleNone; DJYDCXDetailList *mode = _arrData[indexPath.row]; [cell setCellWithMode:mode]; }