InventoryDetailViewController.m 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. //
  2. // InventoryDetailViewController.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/5/16.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:库存明细表详细控制器
  9. //
  10. #import "InventoryDetailViewController.h"
  11. #import "AlbumPhotoCollectionViewCell.h"
  12. @interface InventoryDetailViewController ()
  13. @end
  14. @implementation InventoryDetailViewController
  15. /**
  16. viewDidLoad函数
  17. */
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self showTitle:@""];
  21. _detailImgList=[[NSMutableArray alloc]init];
  22. [self loadData];
  23. }
  24. /**
  25. 安全区视图发生变化
  26. */
  27. -(void)viewSafeAreaInsetsDidChange{
  28. _scroll.frame = self.view.safeAreaLayoutGuide.layoutFrame;
  29. [super viewSafeAreaInsetsDidChange];
  30. }
  31. /**
  32. didReceiveMemoryWarning函数
  33. */
  34. - (void)didReceiveMemoryWarning {
  35. [super didReceiveMemoryWarning];
  36. }
  37. #pragma mark - 私有函数
  38. -(void)loadData
  39. {
  40. [self startLoading];
  41. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  42. [dict setObject:@"GetNewInventoryDetailIphone" forKey:@"Action"];
  43. [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
  44. [dict setObject:kkUserCode forKey:@"UserCode"];
  45. [dict setObject:kkUserPwd forKey:@"UserPassword"];
  46. [dict setObject:kkSessionKey forKey:@"SessionKey"];
  47. [dict setObject:_inventoryId forKeyedSubscript:@"InventoryID"];
  48. _downManager = [[ASIDownManager alloc] init];
  49. _downManager.delegate = self;
  50. _downManager.onRequestSuccess = @selector(onLoadFinish:);
  51. _downManager.onRequestFail = @selector(onLoadFail:);
  52. [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
  53. }
  54. /**
  55. 加载列表数据失败回调
  56. @param sender <#sender description#>
  57. */
  58. - (void)onLoadFail:(ASIDownManager *)sender {
  59. [self cancel];
  60. [self showAlertViewText:@"网络异常"];
  61. }
  62. /**
  63. 隐藏进度条
  64. */
  65. - (void)cancel {
  66. [self stopLoading];
  67. }
  68. /**
  69. 加载列表数据成功回调
  70. @param sender <#sender description#>
  71. */
  72. - (void)onLoadFinish:(ASIDownManager *)sender {
  73. // 取消进度条
  74. [self cancel];
  75. // 服务器返回数据
  76. RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
  77. // 服务器返回数据状态值
  78. int iStatus = resultModel.status;
  79. // 服务器返回数据消息
  80. NSString *message = resultModel.message;
  81. // 服务器返回数据状态值正确
  82. if (iStatus == 0) {
  83. NSDictionary * infoDic = (NSDictionary *)resultModel.result;
  84. if(infoDic != nil)
  85. {
  86. NSArray *infoArray=[infoDic objectForKey:@"Table"];
  87. if(infoArray!=nil&&infoArray.count>0){
  88. NSDictionary *dic=[infoArray objectAtIndex:0];
  89. _detailModel = [InventoryDetailModel dk_modelWithDictionary:dic];
  90. _detailModel.costPrice=[NSString stringWithFormat:@"%.2f", [_detailModel.costPrice doubleValue]];
  91. if(_detailModel.canSaleQuantity != nil && ![_detailModel.canSaleQuantity isEqualToString:@""]){
  92. if(_detailModel.circulateType != nil && ![_detailModel.circulateType isEqualToString:@""]){
  93. _detailModel.boxPieceFlag = YES;
  94. if(_detailModel.package != nil && ![_detailModel.package isEqualToString:@""]){
  95. int circulateType= [_detailModel.circulateType intValue];
  96. double acreage=[_detailModel.acreage doubleValue];
  97. if(circulateType==1)
  98. {
  99. if([_detailModel.canSaleQuantity doubleValue]>=0)
  100. {
  101. _detailModel.box = [NSString stringWithFormat:@"%ld",(long)floor([_detailModel.canSaleQuantity doubleValue]/[_detailModel.package doubleValue])];
  102. }
  103. else
  104. {
  105. _detailModel.box = [NSString stringWithFormat:@"%ld",(long)ceil([_detailModel.canSaleQuantity doubleValue]/[_detailModel.package doubleValue])];
  106. }
  107. _detailModel.piece = [NSString stringWithFormat:@"%ld",(long)[_detailModel.canSaleQuantity intValue]%[_detailModel.package intValue]];
  108. }
  109. else
  110. {
  111. if([_detailModel.package intValue]>0&&acreage>0)
  112. {
  113. long canSalesPieces=0;
  114. int canSalesBox=0;
  115. if([_detailModel.canSaleQuantity doubleValue]>=0)
  116. {
  117. canSalesPieces=(long)ceil([_detailModel.canSaleQuantity doubleValue]/acreage);
  118. canSalesBox=(int)floor(canSalesPieces/[_detailModel.package intValue]);
  119. }
  120. else
  121. {
  122. canSalesPieces=(long)floor([_detailModel.canSaleQuantity doubleValue]/acreage);
  123. canSalesBox=(int)ceil(canSalesPieces/[_detailModel.package intValue]);
  124. }
  125. int canSalesPiece=canSalesPieces%[_detailModel.package intValue];
  126. _detailModel.box = [NSString stringWithFormat:@"%d",canSalesBox];
  127. _detailModel.piece=[NSString stringWithFormat:@"%d",canSalesPiece];
  128. }
  129. else
  130. {
  131. _detailModel.box = @"0";
  132. _detailModel.piece = @"0";
  133. }
  134. }
  135. }
  136. else{
  137. _detailModel.boxPieceFlag = NO;
  138. }
  139. }
  140. else{
  141. _detailModel.boxPieceFlag = NO;
  142. }
  143. }
  144. _expandAttribute=_detailModel.expandAttribute;
  145. _expandAttribute2=_detailModel.expandAttribute2;
  146. _code=_detailModel.code;
  147. _unitName=_detailModel.unitName;
  148. _onlyCode=_detailModel.onlyCode;
  149. _goodName=_detailModel.goodName;
  150. _costPrice=_detailModel.costPrice;
  151. _brandName=_detailModel.brandName;
  152. _colorNumber=_detailModel.colorNumber;
  153. _specification= _detailModel.specification;
  154. _gradeName=_detailModel.gradeName;
  155. _photo=_detailModel.photo;
  156. _wareHouseName=_detailModel.wareHouseName;
  157. _positionNumber=_detailModel.positionNumber;
  158. _box=_detailModel.box;
  159. _piece=_detailModel.piece;
  160. _canSaleQuantity=_detailModel.canSaleQuantity;
  161. _inventoryQuantity= _detailModel.inventoryQuantity;
  162. _price= _detailModel.price;
  163. _occupyQuantity=_detailModel.occupyQuantity;
  164. _noOccupyQuantity=_detailModel.noBookOccupyQuantity;
  165. _noDeliveryQuantity = _detailModel.noDeliveryQuantity;
  166. _ceaseFlag=_detailModel.ceaseFlag;
  167. _weight=_detailModel.weight;
  168. _estimatedShortageQuantity=_detailModel.estimatedShortageQuantity;
  169. _boxPieceFlag=_detailModel.boxPieceFlag;
  170. _freezerQuantity=_detailModel.freezeQuantity;
  171. _deliveryQuantity=_detailModel.deliveryQuantity;
  172. _seriesName=_detailModel.seriesName;
  173. _varietyName=_detailModel.varietyName;
  174. _package=_detailModel.package;
  175. if(_detailModel.photo!=nil&&_detailModel.photo.length>0)
  176. {
  177. ImageModel *imgModel=[ImageModel new];
  178. imgModel.imageName=_detailModel.photo;
  179. [_detailImgList addObject:imgModel];
  180. }
  181. [self initUI];
  182. }
  183. }
  184. }
  185. // 服务器返回数据状态值异常
  186. else if(iStatus == ActionResultStatusAuthError
  187. ||iStatus == ActionResultStatusNoLogin
  188. ||iStatus == ActionResultStatusLogined||iStatus==ActionResultSessionOverdue){
  189. [self showReLoginDialog:message];
  190. }
  191. else
  192. {
  193. [self initUI];
  194. }
  195. }
  196. /**
  197. 初始化ui
  198. */
  199. - (void)initUI { ;
  200. self.navigationItem.title = @"库存商品详细";
  201. self.view.backgroundColor = LineBackgroundColor;
  202. CGFloat heightRow = 30;
  203. CGFloat lblx = 10;
  204. CGFloat lbly = 3;
  205. CGFloat lblwidth = 70;
  206. CGFloat lblheight = 25;
  207. CGFloat valuex = 80;
  208. CGFloat valuey = 3;
  209. CGFloat valueheight = 25;
  210. _scroll = [UIScrollView new];
  211. _scroll.frame=self.view.bounds;
  212. [self.view addSubview:_scroll];
  213. UIView *vTitle = [UIView new];
  214. [_scroll addSubview:vTitle];
  215. vTitle.backgroundColor = [UIColor whiteColor];
  216. //商品编码 —————————
  217. UIView *vcode = [UIView new];
  218. vcode.frame=CGRectMake(0, CGRectGetMaxY(vTitle.frame), Screen_Width, heightRow);
  219. [vTitle addSubview:vcode];
  220. UILabel *lblTitleCode = [UILabel new];
  221. lblTitleCode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  222. lblTitleCode.text = @"商品编码:";
  223. lblTitleCode.textColor = [UIColor blackColor];
  224. lblTitleCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  225. [vcode addSubview:lblTitleCode];
  226. _lblCode = [UILabel new];
  227. _lblCode.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  228. _lblCode.text=_code;
  229. _lblCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  230. [vcode addSubview:_lblCode];
  231. //唯一编码 —————————
  232. UIView *vonlyCode = [UIView new];
  233. vonlyCode.frame=CGRectMake(0, CGRectGetMaxY(vcode.frame), Screen_Width, heightRow);
  234. [vTitle addSubview:vonlyCode];
  235. UILabel *lblTitleOnlyCode = [UILabel new];
  236. lblTitleOnlyCode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  237. lblTitleOnlyCode.text = @"唯一编码:";
  238. lblTitleOnlyCode.textColor = [UIColor blackColor];
  239. lblTitleOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  240. [vonlyCode addSubview:lblTitleOnlyCode];
  241. _lblOnlyCode = [UILabel new];
  242. _lblOnlyCode.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  243. _lblOnlyCode.text=_onlyCode;
  244. _lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  245. [vonlyCode addSubview:_lblOnlyCode];
  246. // —————————
  247. UIView *vgoodName = [UIView new];
  248. vgoodName.frame=CGRectMake(0, CGRectGetMaxY(vonlyCode.frame), Screen_Width, heightRow);
  249. [vTitle addSubview:vgoodName];
  250. UILabel *lblTitleGoodsName = [UILabel new];
  251. lblTitleGoodsName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  252. lblTitleGoodsName.text = @"商品名称:";
  253. lblTitleGoodsName.textColor = [UIColor blackColor];
  254. lblTitleGoodsName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  255. [vgoodName addSubview:lblTitleGoodsName];
  256. _lblGoodsName= [UILabel new];
  257. _lblGoodsName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  258. _lblGoodsName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  259. _lblGoodsName.text = _goodName;
  260. [vgoodName addSubview:_lblGoodsName];
  261. // 品牌 —————————
  262. UIView *vbrandName = [UIView new];
  263. vbrandName.frame=CGRectMake(0, CGRectGetMaxY(vgoodName.frame), Screen_Width, heightRow);
  264. [vTitle addSubview:vbrandName];
  265. UILabel *lblTitleBrandName = [UILabel new];
  266. lblTitleBrandName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  267. lblTitleBrandName.text = @"品 牌:";
  268. lblTitleBrandName.textColor = [UIColor blackColor];
  269. lblTitleBrandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  270. [vbrandName addSubview:lblTitleBrandName];
  271. _lblBrandName= [UILabel new];
  272. _lblBrandName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  273. _lblBrandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  274. _lblBrandName.text = self.brandName;
  275. [vbrandName addSubview:_lblBrandName];
  276. //色号 —————————
  277. UIView *vcolorNumber = [UIView new];
  278. vcolorNumber.frame=CGRectMake(0, CGRectGetMaxY(vbrandName.frame), Screen_Width, heightRow);
  279. [vTitle addSubview:vcolorNumber];
  280. UILabel *lblTitleColorNumber = [UILabel new];
  281. lblTitleColorNumber.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  282. lblTitleColorNumber.text = @"色 号:";
  283. lblTitleColorNumber.textColor = [UIColor blackColor];
  284. lblTitleColorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  285. [vcolorNumber addSubview:lblTitleColorNumber];
  286. _lblColorNumber = [UILabel new];
  287. _lblColorNumber.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  288. _lblColorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  289. _lblColorNumber.text = self.colorNumber;
  290. [vcolorNumber addSubview:_lblColorNumber];
  291. //规格 —————————
  292. UIView *vspecification = [UIView new];
  293. vspecification.frame=CGRectMake(0, CGRectGetMaxY(vcolorNumber.frame), Screen_Width, heightRow);
  294. [vTitle addSubview:vspecification];
  295. UILabel *lblTitleSpecification = [UILabel new];
  296. lblTitleSpecification.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  297. lblTitleSpecification.text = @"规 格:";
  298. lblTitleSpecification.textColor = [UIColor blackColor];
  299. lblTitleSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  300. [vspecification addSubview:lblTitleSpecification];
  301. _lblSpecification = [UILabel new];
  302. _lblSpecification.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  303. _lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  304. _lblSpecification.text = self.specification;
  305. [vspecification addSubview:_lblSpecification];
  306. // —————————
  307. UIView *vgradeName = [UIView new];
  308. vgradeName.frame=CGRectMake(0, CGRectGetMaxY(vspecification.frame), Screen_Width, heightRow);
  309. [vTitle addSubview:vgradeName];
  310. UILabel *lblTitleGradeName = [UILabel new];
  311. lblTitleGradeName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  312. lblTitleGradeName.text = @"等 级:";
  313. lblTitleGradeName.textColor = [UIColor blackColor];
  314. lblTitleGradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  315. [vgradeName addSubview:lblTitleGradeName];
  316. _lblGrade = [UILabel new];
  317. _lblGrade.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  318. _lblGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  319. _lblGrade.text = self.gradeName;
  320. [vgradeName addSubview:_lblGrade];
  321. UIView *vwareHouseName = [UIView new];
  322. vwareHouseName.frame=CGRectMake(0, CGRectGetMaxY(vgradeName.frame), Screen_Width, heightRow);
  323. [vTitle addSubview:vwareHouseName];
  324. UILabel *lblTitlewareHouseName = [UILabel new];
  325. lblTitlewareHouseName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  326. lblTitlewareHouseName.text = @"库 区:";
  327. lblTitlewareHouseName.textColor = [UIColor blackColor];
  328. lblTitlewareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  329. [vwareHouseName addSubview:lblTitlewareHouseName];
  330. _lblWarehouseName = [UILabel new];
  331. _lblWarehouseName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  332. _lblWarehouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  333. _lblWarehouseName.text = self.wareHouseName;
  334. [vwareHouseName addSubview:_lblWarehouseName];
  335. // —————————
  336. UIView *vpositionNumber = [UIView new];
  337. vpositionNumber.frame=CGRectMake(0, CGRectGetMaxY(vwareHouseName.frame), Screen_Width, heightRow);
  338. [vTitle addSubview:vpositionNumber];
  339. UILabel *lblTitlePositionNumber = [UILabel new];
  340. lblTitlePositionNumber.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  341. lblTitlePositionNumber.text = @"仓 位:";
  342. lblTitlePositionNumber.textColor = [UIColor blackColor];
  343. lblTitlePositionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  344. [vpositionNumber addSubview:lblTitlePositionNumber];
  345. _lblPositionNumber= [UILabel new];
  346. _lblPositionNumber.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  347. _lblPositionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  348. _lblPositionNumber.text = self.positionNumber;
  349. [vpositionNumber addSubview:_lblPositionNumber];
  350. CGFloat height = CGRectGetMaxY(vpositionNumber.frame);
  351. if(_displayCanSalesQuantity)
  352. {
  353. if(_boxPieceFlag){
  354. UIView *vBox = [UIView new];
  355. vBox.frame=CGRectMake(0,height, Screen_Width, heightRow);
  356. UILabel *titleBox = [[UILabel alloc] init];
  357. titleBox.text = @"可 售 箱:";
  358. titleBox.frame = CGRectMake(lblx,lbly, lblwidth,lblheight);
  359. titleBox.textColor = [UIColor blackColor];
  360. titleBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  361. [vBox addSubview:titleBox];
  362. [vTitle addSubview:vBox];
  363. _lBox = [[UILabel alloc] init];
  364. _lBox.frame = CGRectMake(valuex, valuey,Screen_Width - valuex - lblx, valueheight);
  365. _lBox.text =[NSString stringWithFormat:@"%d", [_box intValue]];
  366. _lBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  367. [vBox addSubview:_lBox];
  368. height = CGRectGetMaxY(vBox.frame);
  369. UIView *vPiece = [UIView new];
  370. vPiece.frame=CGRectMake(0,height, Screen_Width, heightRow);
  371. [vTitle addSubview:vPiece];
  372. UILabel *titlepic = [[UILabel alloc] init];
  373. titlepic.text = @"可 售 片:";
  374. titlepic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  375. titlepic.frame = CGRectMake(lblx,lbly, lblwidth,lblheight);
  376. [vPiece addSubview:titlepic];
  377. _lPiece= [[UILabel alloc] init];
  378. _lPiece.frame =CGRectMake(valuex, valuey,Screen_Width - valuex - lblx, valueheight);
  379. _lPiece.text = _piece;
  380. _lPiece.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  381. [vPiece addSubview:_lPiece];
  382. height = CGRectGetMaxY(vPiece.frame);
  383. }
  384. if(_canSaleQuantity != nil){
  385. // —————————
  386. UIView *vcanSaleQuantity = [UIView new];
  387. vcanSaleQuantity.frame=CGRectMake(0, height, Screen_Width, heightRow);
  388. [vTitle addSubview:vcanSaleQuantity];
  389. UILabel *lblTitleCanSaleQuantity = [UILabel new];
  390. lblTitleCanSaleQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  391. lblTitleCanSaleQuantity.text = @"可 售 量:";
  392. lblTitleCanSaleQuantity.textColor = [UIColor blackColor];
  393. lblTitleCanSaleQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  394. [vcanSaleQuantity addSubview:lblTitleCanSaleQuantity];
  395. _lblCanSaleQuantity = [UILabel new];
  396. _lblCanSaleQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  397. _lblCanSaleQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  398. _lblCanSaleQuantity.text = self.canSaleQuantity;
  399. [vcanSaleQuantity addSubview:_lblCanSaleQuantity];
  400. height = CGRectGetMaxY(vcanSaleQuantity.frame);
  401. }
  402. }
  403. if(_displayInventoryQuantity)
  404. {
  405. if(_inventoryQuantity != nil){
  406. // —————————
  407. UIView *vinventoryQuantity = [UIView new];
  408. vinventoryQuantity.frame=CGRectMake(0,height, Screen_Width, heightRow);
  409. [vTitle addSubview:vinventoryQuantity];
  410. UILabel *lblTitleInventoryQuantity = [UILabel new];
  411. lblTitleInventoryQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  412. lblTitleInventoryQuantity.text = @"结 存 量:";
  413. lblTitleInventoryQuantity.textColor = [UIColor blackColor];
  414. lblTitleInventoryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  415. [vinventoryQuantity addSubview:lblTitleInventoryQuantity];
  416. _lblInventoryQuantity = [UILabel new];
  417. _lblInventoryQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  418. _lblInventoryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  419. _lblInventoryQuantity.text = self.inventoryQuantity;
  420. [vinventoryQuantity addSubview:_lblInventoryQuantity];
  421. height = CGRectGetMaxY(vinventoryQuantity.frame);
  422. }
  423. }
  424. if(_displayStandardPrice){
  425. UIView *vprice = [UIView new];
  426. vprice.frame=CGRectMake(0, height, Screen_Width, heightRow);
  427. [vTitle addSubview:vprice];
  428. UILabel *lblTitlePrice = [UILabel new];
  429. lblTitlePrice.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  430. lblTitlePrice.text = @"标 价:";
  431. lblTitlePrice.textColor = [UIColor blackColor];
  432. lblTitlePrice.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  433. [vprice addSubview:lblTitlePrice];
  434. _lblPrice= [UILabel new];
  435. _lblPrice.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  436. _lblPrice.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  437. _lblPrice.text = self.price;
  438. [vprice addSubview:_lblPrice];
  439. height = CGRectGetMaxY(vprice.frame);
  440. }
  441. if([_settingValues isEqualToString:@"1"])
  442. {
  443. UIView *vCostPrice = [UIView new];
  444. vCostPrice.frame=CGRectMake(0, height, Screen_Width, heightRow);
  445. [vTitle addSubview:vCostPrice];
  446. UILabel *lblTitleCostPrice = [UILabel new];
  447. lblTitleCostPrice.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  448. lblTitleCostPrice.text = @"成 本 价:";
  449. lblTitleCostPrice.textColor = [UIColor blackColor];
  450. lblTitleCostPrice.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  451. [vCostPrice addSubview:lblTitleCostPrice];
  452. _lblCostPrice= [UILabel new];
  453. _lblCostPrice.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  454. _lblCostPrice.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  455. _lblCostPrice.text = self.costPrice;
  456. [vCostPrice addSubview:_lblCostPrice];
  457. height = CGRectGetMaxY(vCostPrice.frame);
  458. }
  459. if(_occupyQuantity!=nil&&_occupyQuantity.length>0){
  460. UIView *vOccupyQuantity = [UIView new];
  461. vOccupyQuantity.frame=CGRectMake(0, height, Screen_Width, heightRow);
  462. [vTitle addSubview:vOccupyQuantity];
  463. UILabel *lblTitleOccupyQuantity = [UILabel new];
  464. lblTitleOccupyQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  465. lblTitleOccupyQuantity.text = @"占 库 量:";
  466. lblTitleOccupyQuantity.textColor = [UIColor blackColor];
  467. lblTitleOccupyQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  468. [vOccupyQuantity addSubview:lblTitleOccupyQuantity];
  469. _lblOccupyQuantity = [UILabel new];
  470. _lblOccupyQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  471. _lblOccupyQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  472. _lblOccupyQuantity.text = _occupyQuantity;
  473. [vOccupyQuantity addSubview:_lblOccupyQuantity];
  474. height = CGRectGetMaxY(vOccupyQuantity.frame);
  475. }
  476. if(_noOccupyQuantity!=nil&&_noOccupyQuantity.length>0){
  477. UIView *vNoOccupyQuantity = [UIView new];
  478. vNoOccupyQuantity.frame=CGRectMake(0, height, Screen_Width, heightRow);
  479. [vTitle addSubview:vNoOccupyQuantity];
  480. UILabel *lblTitleNoOccupyQuantity = [UILabel new];
  481. lblTitleNoOccupyQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  482. lblTitleNoOccupyQuantity.text = @"未占库量:";
  483. lblTitleNoOccupyQuantity.textColor = [UIColor blackColor];
  484. lblTitleNoOccupyQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  485. [vNoOccupyQuantity addSubview:lblTitleNoOccupyQuantity];
  486. _lblNoOccupyQuantity = [UILabel new];
  487. _lblNoOccupyQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  488. _lblNoOccupyQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  489. _lblNoOccupyQuantity.text = _noOccupyQuantity;
  490. [vNoOccupyQuantity addSubview:_lblNoOccupyQuantity];
  491. height = CGRectGetMaxY(vNoOccupyQuantity.frame);
  492. }
  493. //2019-05-21 新增未提量
  494. if (_noDeliveryQuantity!=nil&&_noDeliveryQuantity.length>0) {
  495. UIView *vNoDeliveryQuantity = [UIView new];
  496. vNoDeliveryQuantity.frame = CGRectMake(0, height, Screen_Width, heightRow);
  497. [vTitle addSubview:vNoDeliveryQuantity];
  498. UILabel *lblTitleNoDeliveryQuantity = [UILabel new];
  499. lblTitleNoDeliveryQuantity.frame = CGRectMake(lblx, lbly, lblwidth, lblheight);
  500. lblTitleNoDeliveryQuantity.text = @"未 提 量:";
  501. lblTitleNoDeliveryQuantity.textColor = [UIColor blackColor];
  502. lblTitleNoDeliveryQuantity.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
  503. [vNoDeliveryQuantity addSubview:lblTitleNoDeliveryQuantity];
  504. _lblNoDeliveryQuantity = [UILabel new];
  505. _lblNoDeliveryQuantity.frame = CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight);
  506. _lblNoDeliveryQuantity.font = [UIFont systemFontOfSize:LabelAndTextFontOfSize];
  507. _lblNoDeliveryQuantity.text = _noDeliveryQuantity;
  508. [vNoDeliveryQuantity addSubview:_lblNoDeliveryQuantity];
  509. height = CGRectGetMaxY(vNoDeliveryQuantity.frame);
  510. }
  511. if(_estimatedShortageQuantity!=nil&&_estimatedShortageQuantity.length>0){
  512. UIView *vEstimatedShortageQuantity = [UIView new];
  513. vEstimatedShortageQuantity.frame=CGRectMake(0, height, Screen_Width, heightRow);
  514. [vTitle addSubview:vEstimatedShortageQuantity];
  515. UILabel *lblTitleEstimatedShortageQuantity = [UILabel new];
  516. lblTitleEstimatedShortageQuantity.frame=CGRectMake(lblx, lbly, 90, lblheight);
  517. lblTitleEstimatedShortageQuantity.text = @"预估缺货量:";
  518. lblTitleEstimatedShortageQuantity.textColor = [UIColor blackColor];
  519. lblTitleEstimatedShortageQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  520. [vEstimatedShortageQuantity addSubview:lblTitleEstimatedShortageQuantity];
  521. _lblEstimatedShortageQuantity = [UILabel new];
  522. _lblEstimatedShortageQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  523. _lblEstimatedShortageQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  524. _lblEstimatedShortageQuantity.text = _estimatedShortageQuantity;
  525. [vEstimatedShortageQuantity addSubview:_lblEstimatedShortageQuantity];
  526. height = CGRectGetMaxY(vEstimatedShortageQuantity.frame);
  527. }
  528. UIView *vFreezeQuantity = [UIView new];
  529. vFreezeQuantity.frame=CGRectMake(0, height, Screen_Width, heightRow);
  530. [vTitle addSubview:vFreezeQuantity];
  531. UILabel *lblTitleFreezeQuantity = [UILabel new];
  532. lblTitleFreezeQuantity.frame=CGRectMake(lblx, lbly, 90, lblheight);
  533. lblTitleFreezeQuantity.text = @"冻 结 量:";
  534. lblTitleFreezeQuantity.textColor = [UIColor blackColor];
  535. lblTitleFreezeQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  536. [vFreezeQuantity addSubview:lblTitleFreezeQuantity];
  537. _lblFreezerQuantity = [UILabel new];
  538. _lblFreezerQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  539. _lblFreezerQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  540. _lblFreezerQuantity.text =_freezerQuantity;
  541. [vFreezeQuantity addSubview:_lblFreezerQuantity];
  542. UIView *vDeliveryQuantity = [UIView new];
  543. vDeliveryQuantity.frame=CGRectMake(0,CGRectGetMaxY(vFreezeQuantity.frame), Screen_Width, heightRow);
  544. [vTitle addSubview:vDeliveryQuantity];
  545. UILabel *lblTitleDeliveryQuantity = [UILabel new];
  546. lblTitleDeliveryQuantity.frame=CGRectMake(lblx, lbly, 90, lblheight);
  547. lblTitleDeliveryQuantity.text = @"采购发货量:";
  548. lblTitleDeliveryQuantity.textColor = [UIColor blackColor];
  549. lblTitleDeliveryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  550. [vDeliveryQuantity addSubview:lblTitleDeliveryQuantity];
  551. _lblDeliveryQuantity = [UILabel new];
  552. _lblDeliveryQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  553. _lblDeliveryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  554. _lblDeliveryQuantity.text =_deliveryQuantity;
  555. [vDeliveryQuantity addSubview:_lblDeliveryQuantity];
  556. UIView *vSeriesName = [UIView new];
  557. vSeriesName.frame=CGRectMake(0,CGRectGetMaxY(vDeliveryQuantity.frame), Screen_Width, heightRow);
  558. [vTitle addSubview:vSeriesName];
  559. UILabel *lblTitleSeriesName = [UILabel new];
  560. lblTitleSeriesName.frame=CGRectMake(lblx, lbly, 90, lblheight);
  561. lblTitleSeriesName.text = @"商品系列:";
  562. lblTitleSeriesName.textColor = [UIColor blackColor];
  563. lblTitleSeriesName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  564. [vSeriesName addSubview:lblTitleSeriesName];
  565. _lblSeriesName = [UILabel new];
  566. _lblSeriesName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  567. _lblSeriesName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  568. _lblSeriesName.text =_seriesName;
  569. [vSeriesName addSubview:_lblSeriesName];
  570. UIView *vVarietyName = [UIView new];
  571. vVarietyName.frame=CGRectMake(0,CGRectGetMaxY(vSeriesName.frame), Screen_Width, heightRow);
  572. [vTitle addSubview:vVarietyName];
  573. UILabel *lblTitleVarietyName = [UILabel new];
  574. lblTitleVarietyName.frame=CGRectMake(lblx, lbly, 90, lblheight);
  575. lblTitleVarietyName.text = @"商品品种:";
  576. lblTitleVarietyName.textColor = [UIColor blackColor];
  577. lblTitleVarietyName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  578. [vVarietyName addSubview:lblTitleVarietyName];
  579. _lblVarietyName = [UILabel new];
  580. _lblVarietyName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  581. _lblVarietyName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  582. _lblVarietyName.text =_varietyName;
  583. [vVarietyName addSubview:_lblVarietyName];
  584. UIView *vPackage = [UIView new];
  585. vPackage.frame=CGRectMake(0,CGRectGetMaxY(vVarietyName.frame), Screen_Width, heightRow);
  586. [vTitle addSubview:vPackage];
  587. UILabel *lblTitlePackage = [UILabel new];
  588. lblTitlePackage.frame=CGRectMake(lblx, lbly, 90, lblheight);
  589. lblTitlePackage.text = @"包 装:";
  590. lblTitlePackage.textColor = [UIColor blackColor];
  591. lblTitlePackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  592. [vPackage addSubview:lblTitlePackage];
  593. _lblPackage = [UILabel new];
  594. _lblPackage.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  595. _lblPackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  596. _lblPackage.text =_package;
  597. [vPackage addSubview:_lblPackage];
  598. UIView *vUnit = [UIView new];
  599. vUnit.frame=CGRectMake(0,CGRectGetMaxY(vPackage.frame), Screen_Width, heightRow);
  600. [vTitle addSubview:vUnit];
  601. UILabel *lblTitleUnit = [UILabel new];
  602. lblTitleUnit.frame=CGRectMake(lblx, lbly, 90, lblheight);
  603. lblTitleUnit.text = @"单 位:";
  604. lblTitleUnit.textColor = [UIColor blackColor];
  605. lblTitleUnit.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  606. [vUnit addSubview:lblTitleUnit];
  607. _lblUnit = [UILabel new];
  608. _lblUnit.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  609. _lblUnit.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  610. _lblUnit.text =_unitName;
  611. [vUnit addSubview:_lblUnit];
  612. UIView *vWeight = [UIView new];
  613. vWeight.frame=CGRectMake(0,CGRectGetMaxY(vUnit.frame), Screen_Width, heightRow);
  614. [vTitle addSubview:vWeight];
  615. UILabel *lblTitleWeight = [UILabel new];
  616. lblTitleWeight.frame=CGRectMake(lblx, lbly, 90, lblheight);
  617. lblTitleWeight.text = @"重 量:";
  618. lblTitleWeight.textColor = [UIColor blackColor];
  619. lblTitleWeight.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  620. [vWeight addSubview:lblTitleWeight];
  621. _lblWeight= [UILabel new];
  622. _lblWeight.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  623. _lblWeight.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  624. _lblWeight.text =_weight;
  625. [vWeight addSubview:_lblWeight];
  626. UIView *vCeaseFlag = [UIView new];
  627. vCeaseFlag.frame=CGRectMake(0, CGRectGetMaxY(vWeight.frame), Screen_Width, heightRow);
  628. [vTitle addSubview:vCeaseFlag];
  629. UILabel *lblTitleCeaseFlag = [UILabel new];
  630. lblTitleCeaseFlag.frame=CGRectMake(lblx, lbly, 90, lblheight);
  631. lblTitleCeaseFlag.text = @"停产标识:";
  632. lblTitleCeaseFlag.textColor = [UIColor blackColor];
  633. lblTitleCeaseFlag.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  634. [vCeaseFlag addSubview:lblTitleCeaseFlag];
  635. _lblCeaseFlag = [UILabel new];
  636. _lblCeaseFlag.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  637. _lblCeaseFlag.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  638. if([_ceaseFlag intValue]==1){
  639. _lblCeaseFlag.text =@"已停产";
  640. }
  641. else
  642. {
  643. _lblCeaseFlag.text =@"未停产";
  644. }
  645. [vCeaseFlag addSubview:_lblCeaseFlag];
  646. UIView *vExpandAttribute = [UIView new];
  647. vExpandAttribute.frame=CGRectMake(0,CGRectGetMaxY(vCeaseFlag.frame), Screen_Width, heightRow);
  648. [vTitle addSubview:vExpandAttribute];
  649. UILabel *lblTitleExpandAttribute = [UILabel new];
  650. lblTitleExpandAttribute.frame=CGRectMake(lblx, lbly, 90, lblheight);
  651. lblTitleExpandAttribute.text = @"扩展属性:";
  652. lblTitleExpandAttribute.textColor = [UIColor blackColor];
  653. lblTitleExpandAttribute.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  654. [vExpandAttribute addSubview:lblTitleExpandAttribute];
  655. _lblExpandAttribute = [UILabel new];
  656. _lblExpandAttribute.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  657. _lblExpandAttribute.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  658. _lblExpandAttribute.text =_expandAttribute;
  659. [vExpandAttribute addSubview:_lblExpandAttribute];
  660. UIView *vExpandAttribute2 = [UIView new];
  661. vExpandAttribute2.frame=CGRectMake(0,CGRectGetMaxY(vExpandAttribute.frame), Screen_Width, heightRow);
  662. [vTitle addSubview:vExpandAttribute2];
  663. UILabel *lblTitleExpandAttribute2 = [UILabel new];
  664. lblTitleExpandAttribute2.frame=CGRectMake(lblx, lbly, 90, lblheight);
  665. lblTitleExpandAttribute2.text = @"扩展属性二:";
  666. lblTitleExpandAttribute2.textColor = [UIColor blackColor];
  667. lblTitleExpandAttribute2.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  668. [vExpandAttribute2 addSubview:lblTitleExpandAttribute2];
  669. _lblExpandAttribute2 = [UILabel new];
  670. _lblExpandAttribute2.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx-20, valueheight);
  671. _lblExpandAttribute2.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  672. _lblExpandAttribute2.text =_expandAttribute2;
  673. [vExpandAttribute2 addSubview:_lblExpandAttribute2];
  674. height = CGRectGetMaxY(vExpandAttribute2.frame);
  675. vTitle.frame=CGRectMake(10, 10, Screen_Width-20, height);
  676. vTitle.layer.cornerRadius = CornerRadius;
  677. if(_detailImgList!=nil&&_detailImgList.count>0)
  678. {
  679. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  680. flowLayout.itemSize = CGSizeMake(85, 85);
  681. flowLayout.minimumInteritemSpacing = 5;
  682. flowLayout.minimumLineSpacing = 10;
  683. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  684. flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20);
  685. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(vExpandAttribute2.frame), self.view.bounds.size.width-40, [self getPhotoCollectionViewHeightWithPhotos:_detailImgList]) collectionViewLayout:flowLayout];
  686. self.collectionView.dataSource=self;
  687. self.collectionView.delegate=self;
  688. self.collectionView.scrollEnabled=NO;
  689. self.collectionView.backgroundColor=[UIColor whiteColor];
  690. [self.collectionView registerClass:[AlbumPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"PhotoCollectionViewCellIdentifier"];
  691. [vTitle addSubview:self.collectionView];
  692. vTitle.frame=CGRectMake(10,10,Screen_Width-20,CGRectGetMaxY(self.collectionView.frame)+10);
  693. }
  694. vTitle.layer.cornerRadius = CornerRadius;
  695. _scroll.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(vTitle.frame)+rectStatusHeight+rectNavHeight);
  696. }
  697. #pragma mark - UICollectionView回调函数
  698. -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  699. return _detailImgList.count;
  700. }
  701. -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  702. static NSString *PhotoCollectionViewCellIdentifier=@"PhotoCollectionViewCellIdentifier";
  703. AlbumPhotoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath];
  704. NSArray *followInfoarray=_detailImgList;
  705. cell.indexPath = indexPath;
  706. ImageModel *image1 = [followInfoarray objectAtIndex:indexPath.row];
  707. NSString *imagepath=[image1 imageName];
  708. if(imagepath!=nil&&[imagepath length]>0){
  709. NSData *decodedImageData = [[NSData alloc] initWithBase64Encoding:imagepath];
  710. UIImage *_decodedImage = [UIImage imageWithData:decodedImageData];
  711. [cell.photoImageView setImage:_decodedImage];
  712. }
  713. return cell;
  714. };
  715. /**
  716. 定义每个UICollectionView 的大小
  717. @param collectionView <#collectionView description#>
  718. @param collectionViewLayout <#collectionViewLayout description#>
  719. @param indexPath <#indexPath description#>
  720. @return <#return value description#>
  721. */
  722. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  723. {
  724. return CGSizeMake(85, 85);
  725. }
  726. /**
  727. 定义每个UICollectionView 的 margin
  728. @param collectionView <#collectionView description#>
  729. @param collectionViewLayout <#collectionViewLayout description#>
  730. @param section <#section description#>
  731. @return <#return value description#>
  732. */
  733. -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  734. {
  735. return UIEdgeInsetsMake(5, 5, 5, 5);
  736. }
  737. #pragma mark --UICollectionViewDelegate
  738. /**
  739. UICollectionView被选中时调用的方法
  740. @param collectionView <#collectionView description#>
  741. @param indexPath <#indexPath description#>
  742. */
  743. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  744. [self showImageViewerAtIndexPath:indexPath];
  745. }
  746. /**
  747. 返回这个UICollectionView是否可以被选择
  748. @param collectionView <#collectionView description#>
  749. @param indexPath <#indexPath description#>
  750. @return <#return value description#>
  751. */
  752. -(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
  753. {
  754. return YES;
  755. }
  756. #pragma mark - 私有函数
  757. /**
  758. 选择图片
  759. @param indexPath <#indexPath description#>
  760. */
  761. - (void)showImageViewerAtIndexPath:(NSIndexPath *)indexPath {
  762. AlbumPhotoCollectionViewCell *cell = (AlbumPhotoCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
  763. NSMutableArray *imageViews = [NSMutableArray array];
  764. NSArray *visibleCell = [self.collectionView visibleCells];
  765. NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"indexPath" ascending:YES];
  766. visibleCell = [visibleCell sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
  767. [visibleCell enumerateObjectsUsingBlock:^(AlbumPhotoCollectionViewCell *cell, NSUInteger idx, BOOL *stop) {
  768. [imageViews addObject:[[cell.contentView subviews] lastObject]];
  769. }];
  770. XHImageViewer *imageViewer = [[XHImageViewer alloc] init];
  771. [imageViewer showWithImageViews:imageViews selectedView:[[cell.contentView subviews] lastObject]];
  772. }
  773. /**
  774. 图片高度
  775. @param photos <#photos description#>
  776. @return <#return value description#>
  777. */
  778. - (CGFloat)getPhotoCollectionViewHeightWithPhotos:(NSArray *)photos {
  779. // 上下间隔已经在frame上做了
  780. NSInteger row = (photos.count / 3 + (photos.count % 3 ? 1 : 0));
  781. return (row *85 + (row *5));
  782. }
  783. @end