OrderSalesTableViewCell.m 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // OrderSalesTableViewCell.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2017/5/26.
  6. // Copyright © 2017年 elongtian. All rights reserved.
  7. //
  8. #import "OrderSalesTableViewCell.h"
  9. #import "DateFormat.h"
  10. #import "NSString+Tools.h"
  11. #define reportTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  12. @implementation OrderSalesTableViewCell
  13. /**
  14. 初始化数据
  15. @param style <#style description#>
  16. @param reuseIdentifier <#reuseIdentifier description#>
  17. @return <#return value description#>
  18. */
  19. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if (self) {
  23. }
  24. return self;
  25. }
  26. /**
  27. 单元格ui布局
  28. @param orderItem <#orderItem description#>
  29. */
  30. -(void)parseOrderSalesInfo:(OrderSaleListModel *)orderItem{
  31. CGFloat xpadding=20;
  32. CGFloat ypadding=10;
  33. _lblCustomerName=[[UILabel alloc]init];
  34. _lblCustomerName.frame=CGRectMake(xpadding,ypadding,150,25);
  35. _lblCustomerName.text=orderItem.customerName;
  36. _lblCustomerName.font=reportTextFont;
  37. [self.contentView addSubview:_lblCustomerName];
  38. _lblAccountDate=[[UILabel alloc]init];
  39. _lblAccountDate.frame=CGRectMake(Screen_Width-120,ypadding,100,25);
  40. _lblAccountDate.text=[DateFormat dateFormatSplit: orderItem.accountDate];
  41. _lblAccountDate.textAlignment=NSTextAlignmentRight;
  42. _lblAccountDate.font=reportTextFont;
  43. [self.contentView addSubview:_lblAccountDate];
  44. UIView *middleSeparator=[[UIView alloc]init];
  45. middleSeparator.frame=CGRectMake(0,CGRectGetMaxY(_lblCustomerName.frame)+10, Screen_Width, 1);
  46. middleSeparator.backgroundColor=LineBackgroundColor;
  47. [self.contentView addSubview:middleSeparator];
  48. NSDictionary *reportDict = @{NSFontAttributeName:reportTextFont};
  49. UILabel *lblTitleStaffName=[[UILabel alloc]init];
  50. NSString *titleStaffName=@"业务员:";
  51. CGRect titleStaffNameFrame = [titleStaffName textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict];
  52. titleStaffNameFrame.origin.x = xpadding;
  53. titleStaffNameFrame.origin.y = CGRectGetMaxY(middleSeparator.frame)+10;
  54. lblTitleStaffName.font=reportTextFont;
  55. lblTitleStaffName.frame=titleStaffNameFrame;
  56. lblTitleStaffName.text=titleStaffName;
  57. lblTitleStaffName.textColor=LabelGrayTextColor;
  58. [self.contentView addSubview:lblTitleStaffName];
  59. _lblStaffName=[[UILabel alloc]init];
  60. NSString *staffName=orderItem.staffName;
  61. CGFloat w = Screen_Width / 2 - CGRectGetMaxX(lblTitleStaffName.frame)-20;
  62. CGRect staffNameFrame = [staffName textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict];
  63. staffNameFrame.origin.x =CGRectGetMaxX(lblTitleStaffName.frame)+10;
  64. staffNameFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10;
  65. _lblStaffName.frame=staffNameFrame;
  66. _lblStaffName.text=orderItem.staffName;
  67. _lblStaffName.font=reportTextFont;
  68. [self.contentView addSubview:_lblStaffName];
  69. UILabel *lblTitleInoviceType=[[UILabel alloc]init];
  70. NSString *titleInvoiceType=@"单据类型:";
  71. CGRect titleInvoiceTypeFrame = [titleInvoiceType textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict];
  72. titleInvoiceTypeFrame.origin.x= Screen_Width/2;
  73. titleInvoiceTypeFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10;
  74. lblTitleInoviceType.frame=titleInvoiceTypeFrame;
  75. lblTitleInoviceType.font=reportTextFont;
  76. lblTitleInoviceType.text=titleInvoiceType;
  77. lblTitleInoviceType.textColor=LabelGrayTextColor;
  78. [self.contentView addSubview:lblTitleInoviceType];
  79. NSString *invoiceType=orderItem.invoiceTypeName;
  80. _lblInvoiceType=[[UILabel alloc]init];
  81. _lblInvoiceType.frame=CGRectMake(CGRectGetMaxX(lblTitleInoviceType.frame)+5, CGRectGetMaxY(middleSeparator.frame)+10,70, 17);
  82. _lblInvoiceType.text=invoiceType;
  83. _lblInvoiceType.lineBreakMode = NSLineBreakByWordWrapping | NSLineBreakByTruncatingTail;
  84. _lblInvoiceType.numberOfLines=1;
  85. _lblInvoiceType.font=reportTextFont;
  86. [self.contentView addSubview:_lblInvoiceType];
  87. // middleSeparator=[[UIView alloc]init];
  88. // middleSeparator.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleStaffName.frame)+10, Screen_Width, 1);
  89. // middleSeparator.backgroundColor=LineBackgroundColor;
  90. // [self.contentView addSubview:middleSeparator];
  91. UILabel *lblTitleOrganizationName=[[UILabel alloc]init];
  92. NSString *titleOrganizationName=@"部门:";
  93. lblTitleOrganizationName.text=titleOrganizationName;
  94. CGRect titleOrganizationNameFrame = [titleOrganizationName textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict];
  95. titleOrganizationNameFrame.origin.x =xpadding;
  96. titleOrganizationNameFrame.origin.y =CGRectGetMaxY(lblTitleStaffName.frame)+10;
  97. lblTitleOrganizationName.font=reportTextFont;
  98. lblTitleOrganizationName.textColor=LabelGrayTextColor;
  99. lblTitleOrganizationName.frame=titleOrganizationNameFrame;
  100. [self.contentView addSubview:lblTitleOrganizationName];
  101. NSString *organizationName=orderItem.organizationName;
  102. _lblOrganizationName=[[UILabel alloc]init];
  103. w = Screen_Width - CGRectGetMaxX(lblTitleOrganizationName.frame)-20;
  104. CGRect organizationNameFrame = [organizationName textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict];
  105. organizationNameFrame.origin.x =CGRectGetMaxX(lblTitleOrganizationName.frame)+10;
  106. organizationNameFrame.origin.y =CGRectGetMaxY(lblTitleStaffName.frame)+10;
  107. _lblOrganizationName.frame=organizationNameFrame;
  108. _lblOrganizationName.font=reportTextFont;
  109. _lblOrganizationName.text=organizationName;
  110. [self.contentView addSubview:_lblOrganizationName];
  111. middleSeparator=[[UIView alloc]init];
  112. middleSeparator.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleOrganizationName.frame)+10, Screen_Width, 1);
  113. middleSeparator.backgroundColor=LineBackgroundColor;
  114. [self.contentView addSubview:middleSeparator];
  115. NSDictionary *orderDict = @{NSFontAttributeName:[UIFont systemFontOfSize:SubLabelAndTextFontOfSize]};
  116. _lblTotalElse=[[UILabel alloc]init];
  117. _lblTotalElse.font=[UIFont systemFontOfSize:SubLabelAndTextFontOfSize];
  118. _lblTotalElse.textAlignment=NSTextAlignmentLeft;
  119. NSString *littleCountElse= [NSString stringWithFormat:@"(舍零¥%@;货款¥%@)",orderItem.discountAmount,orderItem.goodsAmount];
  120. _lblTotalElse.text=littleCountElse;
  121. CGRect littleCountElseFrame = [littleCountElse textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:orderDict];
  122. littleCountElseFrame.origin.x =Screen_Width-xpadding-littleCountElseFrame.size.width;
  123. littleCountElseFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10;
  124. _lblTotalElse.frame=littleCountElseFrame;
  125. [self.contentView addSubview:_lblTotalElse];
  126. _lblTotalAmount=[[UILabel alloc]init];
  127. _lblTotalAmount.font=[UIFont systemFontOfSize:SubLabelAndTextFontOfSize];
  128. _lblTotalAmount.textColor=[UIColor redColor];
  129. NSString *totalAmount= orderItem.totalAmount;
  130. _lblTotalAmount.text=totalAmount;
  131. CGRect littleCountFrame = [totalAmount textRectWithSize:CGSizeMake(150, MAXFLOAT) attributes:orderDict];
  132. littleCountFrame.origin.x =littleCountElseFrame.origin.x-littleCountFrame.size.width-3;
  133. littleCountFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10;
  134. _lblTotalAmount.frame=littleCountFrame;
  135. [self.contentView addSubview:_lblTotalAmount];
  136. UILabel *lblTitleLittleCount=[[UILabel alloc]init];
  137. NSString *titleLittleCount=@"小计:¥";
  138. lblTitleLittleCount.text=titleLittleCount;
  139. CGRect titleLittleCountFrame = [titleLittleCount textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:orderDict];
  140. titleLittleCountFrame.origin.x = littleCountFrame.origin.x-titleLittleCountFrame.size.width-3;
  141. titleLittleCountFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10;
  142. lblTitleLittleCount.font=[UIFont systemFontOfSize:SubLabelAndTextFontOfSize];
  143. lblTitleLittleCount.frame=titleLittleCountFrame;
  144. [self.contentView addSubview:lblTitleLittleCount];
  145. UIView *bottomSeparator=[[UIView alloc]init];
  146. bottomSeparator.frame=CGRectMake(0,CGRectGetMaxY(lblTitleLittleCount.frame)+10, Screen_Width, 10);
  147. bottomSeparator.backgroundColor=LineBackgroundColor;
  148. [self.contentView addSubview:bottomSeparator];
  149. }
  150. @end