CustomerBalanceCell.m 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //
  2. // CustomerBalanceCell.m
  3. // IBOSSmini
  4. //
  5. // Created by apple on 2017/5/24.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "CustomerBalanceCell.h"
  9. @implementation CustomerBalanceCell
  10. /**
  11. awakeFromNib
  12. */
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. }
  16. /**
  17. 后台代码创建单元cell
  18. @param style <#style description#>
  19. @param reuseIdentifier <#reuseIdentifier description#>
  20. @return <#return value description#>
  21. */
  22. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  23. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  24. // [self initUI];
  25. return self;
  26. }
  27. /**
  28. 高度
  29. @return <#return value description#>
  30. */
  31. - (CGFloat)height{
  32. return CGRectGetMaxY(self.vBottom.frame);
  33. }
  34. /**
  35. 初始化ui
  36. */
  37. - (void) initUI: (NSDictionary *)dic{
  38. if (dic==nil) {
  39. return;
  40. }
  41. CGFloat heightLine = 1;
  42. CGFloat heightRow = 40;
  43. CGFloat lblx = 20;
  44. CGFloat lbly = 8;
  45. CGFloat lblwidth = 80;
  46. CGFloat lblsubwidth = 38;
  47. CGFloat lblheight = 25;
  48. CGFloat valuey = 8;
  49. CGFloat valueheight = 25;
  50. NSString *customerid = [[dic objectForKey:@"CustomerID"] stringValue];
  51. //title==================
  52. UIView *vTitle = [UIView new];
  53. vTitle.frame=CGRectMake(0, 0, Screen_Width, 10);
  54. vTitle.backgroundColor = LineBackgroundColor;
  55. [self.contentView addSubview:vTitle];
  56. //客户名称==================
  57. UIView *vcustomerName = [UIView new];
  58. vcustomerName.frame=CGRectMake(0, CGRectGetMaxY(vTitle.frame), Screen_Width, heightRow);
  59. [self.contentView addSubview:vcustomerName];
  60. // UILabel *lblName=[UILabel new];
  61. // lblName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
  62. // lblName.text=@"客户名称:";
  63. // lblName.textColor = [UIColor blackColor];
  64. // lblName.font = [UIFont systemFontOfSize: TitleFontOfSize];
  65. // [vcustomerName addSubview:lblName];
  66. _createTime = [UILabel new];
  67. _createTime.frame=CGRectMake(Screen_Width - 95 - lblx, valuey, 95, valueheight);
  68. _createTime.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  69. _createTime.textAlignment = NSTextAlignmentRight;
  70. //[vcustomerName addSubview:_createTime];
  71. _lblValueCustomerName = [UILabel new];
  72. _lblValueCustomerName.frame=CGRectMake(lblx, valuey, Screen_Width - 2*lblx , valueheight);
  73. _lblValueCustomerName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  74. [vcustomerName addSubview:_lblValueCustomerName];
  75. _lblValueCustomerName.text=[dic objectForKey:@"CustomerName"];
  76. if (customerid==nil || customerid.length==0) {
  77. _lblValueCustomerName.textColor = [UIColor redColor];
  78. }else{
  79. _lblValueCustomerName.textColor = [UIColor blackColor];
  80. }
  81. //分割线
  82. UIView *viewBackgroud = [UIView new];
  83. viewBackgroud.frame = CGRectMake(0, CGRectGetMaxY(vcustomerName.frame), Screen_Width, heightLine);
  84. viewBackgroud.backgroundColor = LineBackgroundColor;
  85. [self.contentView addSubview:viewBackgroud];
  86. UIView *viewTemp;
  87. if (customerid==nil || customerid.length==0) {
  88. viewTemp = viewBackgroud;
  89. }else{
  90. //业务部门 业务员==================
  91. UIView *vOrgStaff = [UIView new];
  92. vOrgStaff.frame=CGRectMake(0, CGRectGetMaxY(viewBackgroud.frame), Screen_Width, heightRow);
  93. [self.contentView addSubview:vOrgStaff];
  94. UIView *vOrg = [UIView new];
  95. vOrg.frame=CGRectMake(0, 0, Screen_Width/2, heightRow);
  96. [vOrgStaff addSubview:vOrg];
  97. UILabel *lblOrg=[UILabel new];
  98. lblOrg.frame=CGRectMake(lblx, lbly, lblwidth/2, lblheight);
  99. lblOrg.text=@"部门:";
  100. lblOrg.textColor = LabelGrayTextColor;
  101. lblOrg.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  102. [vOrg addSubview:lblOrg];
  103. _lblValueOrg = [UILabel new];
  104. _lblValueOrg.frame=CGRectMake(CGRectGetMaxX(lblOrg.frame), valuey, Screen_Width/2 - CGRectGetMaxX(lblOrg.frame), valueheight);
  105. _lblValueOrg.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  106. [vOrg addSubview:_lblValueOrg];
  107. UIView *vStaff = [UIView new];
  108. vStaff.frame=CGRectMake(Screen_Width/2, 0, Screen_Width/2, heightRow);
  109. [vOrgStaff addSubview:vStaff];
  110. UILabel *lblStaff=[UILabel new];
  111. lblStaff.frame=CGRectMake(5, lbly, 55, lblheight);
  112. lblStaff.text=@"业务员:";
  113. lblStaff.textColor = LabelGrayTextColor;
  114. lblStaff.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  115. [vStaff addSubview:lblStaff];
  116. _lblValueStaff = [UILabel new];
  117. _lblValueStaff.frame=CGRectMake(55, valuey, Screen_Width/2 - 55 - 10, valueheight);
  118. _lblValueStaff.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  119. [vStaff addSubview:_lblValueStaff];
  120. _lblValueStaff.text=[dic objectForKey:@"SalesManName"];
  121. _lblValueOrg.text=[dic objectForKey:@"OrganizationName"];
  122. viewTemp = vOrgStaff;
  123. }
  124. float receivableValue = [[dic objectForKey:@"AccountReceivable"]floatValue];
  125. float depositValue = [[dic objectForKey:@"DepositReceived"]floatValue];
  126. float earnestValue = [[dic objectForKey:@"Earnest"]floatValue];
  127. //定金 应收款 预收款==================
  128. UIView *vReceivableAndDepositAndEarnest = [UIView new];
  129. vReceivableAndDepositAndEarnest.frame=CGRectMake(0, CGRectGetMaxY(viewTemp.frame), Screen_Width, heightRow);
  130. [self.contentView addSubview:vReceivableAndDepositAndEarnest];
  131. UIView *vEarnest = [UIView new];
  132. vEarnest.frame=CGRectMake(0, 0, Screen_Width/3, heightRow);
  133. [vReceivableAndDepositAndEarnest addSubview:vEarnest];
  134. UILabel *lblEarnest=[UILabel new];
  135. lblEarnest.frame=CGRectMake(lblx, lbly, lblsubwidth, lblheight);
  136. lblEarnest.text=@"定金:";
  137. lblEarnest.textColor = [UIColor blackColor];
  138. lblEarnest.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  139. [vEarnest addSubview:lblEarnest];
  140. _lblValueEarnest = [UILabel new];
  141. _lblValueEarnest.frame=CGRectMake(CGRectGetMaxX(lblEarnest.frame), valuey, Screen_Width/3 -lblsubwidth - 20 , valueheight);
  142. _lblValueEarnest.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  143. [vEarnest addSubview:_lblValueEarnest];
  144. UIView *vReceivable = [UIView new];
  145. vReceivable.frame=CGRectMake(Screen_Width/3, 0, Screen_Width/3, heightRow);
  146. [vReceivableAndDepositAndEarnest addSubview:vReceivable];
  147. UILabel *lblReceivable=[UILabel new];
  148. lblReceivable.frame=CGRectMake(5, lbly, 55, lblheight);
  149. lblReceivable.text=@"应收款:";
  150. lblReceivable.textColor = [UIColor blackColor];
  151. lblReceivable.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  152. [vReceivable addSubview:lblReceivable];
  153. _lblValueReceivable = [UILabel new];
  154. _lblValueReceivable.frame=CGRectMake(55, valuey, Screen_Width/3 - 60, valueheight);
  155. _lblValueReceivable.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  156. [vReceivable addSubview:_lblValueReceivable];
  157. UIView *vDeposit = [UIView new];
  158. vDeposit.frame=CGRectMake(Screen_Width*2/3, 0, Screen_Width/3, heightRow);
  159. [vReceivableAndDepositAndEarnest addSubview:vDeposit];
  160. UILabel *lblDeposit=[UILabel new];
  161. lblDeposit.frame=CGRectMake(5, lbly, 55, lblheight);
  162. lblDeposit.text=@"预收款:";
  163. lblDeposit.textColor = [UIColor blackColor];
  164. lblDeposit.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  165. [vDeposit addSubview:lblDeposit];
  166. _lblValueDeposit = [UILabel new];
  167. _lblValueDeposit.frame=CGRectMake(55, valuey, Screen_Width/3 - 65, valueheight);
  168. _lblValueDeposit.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  169. [vDeposit addSubview:_lblValueDeposit];
  170. _lblValueReceivable.text = [NSString stringWithFormat:@"¥%.2f",receivableValue ];
  171. _lblValueDeposit.text = [NSString stringWithFormat:@"¥%.2f", depositValue ];
  172. _lblValueEarnest.text = [NSString stringWithFormat:@"¥%.2f", earnestValue ];
  173. self.vBottom = [UIView new];
  174. self.vBottom.frame=CGRectMake(0, CGRectGetMaxY(vReceivableAndDepositAndEarnest.frame), Screen_Width, heightRow);
  175. [self.contentView addSubview:self.vBottom];
  176. //
  177. // UILabel *lblreceivableAndDepositAndEarnest =[UILabel new];
  178. // lblreceivableAndDepositAndEarnest.frame=CGRectMake(lblx, lbly, lblwidth*2, lblheight);
  179. // lblreceivableAndDepositAndEarnest.text=@"应收款-预收款-定金:";
  180. // lblreceivableAndDepositAndEarnest.textColor = [UIColor blackColor];
  181. // lblreceivableAndDepositAndEarnest.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
  182. // [vBottom addSubview:lblreceivableAndDepositAndEarnest];
  183. _lblReceivableAndDepositAndEarnest = [UILabel new];
  184. _lblReceivableAndDepositAndEarnest.frame=CGRectMake(lblx, valuey, Screen_Width -2* lblx , valueheight);
  185. // _lblreceivableAndDepositAndEarnest = NSTextAlignmentRight;
  186. _lblReceivableAndDepositAndEarnest.font = [UIFont systemFontOfSize: SubLabelAndTextFontOfSize];
  187. [self.vBottom addSubview:_lblReceivableAndDepositAndEarnest];
  188. NSString *str = [NSString stringWithFormat:@"应收款-预收款-定金:¥%.2f",receivableValue-depositValue-earnestValue];
  189. _lblReceivableAndDepositAndEarnest.text = str;
  190. //
  191. // NSString *str = [NSString stringWithFormat:@"(收入:¥%@;成本:¥%@;毛利:¥%@)",m.inventoryQuantity,m.price];
  192. }
  193. @end