OrderSalesTableViewCell.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //
  2. // OrderSalesTableViewCell.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 2017/5/26.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:订单销售单列表单元格
  9. //
  10. #import "OrderSalesTableViewCell.h"
  11. #import "DateFormat.h"
  12. #import "NSString+Tools.h"
  13. #define reportTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
  14. @implementation OrderSalesTableViewCell
  15. /**
  16. 初始化数据
  17. @param style <#style description#>
  18. @param reuseIdentifier <#reuseIdentifier description#>
  19. @return <#return value description#>
  20. */
  21. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  22. {
  23. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  24. if (self) {
  25. }
  26. return self;
  27. }
  28. /**
  29. 单元格ui布局
  30. @param orderItem <#orderItem description#>
  31. */
  32. - (void)parseOrderSalesInfo:(OrderSaleListModel *)orderItem{
  33. CGFloat xpadding=20;
  34. CGFloat ypadding=15;
  35. _lblCustomerName = [[UILabel alloc]init];
  36. _lblCustomerName.frame=CGRectMake(xpadding,ypadding,150,16);
  37. _lblCustomerName.text=orderItem.customerName;
  38. _lblCustomerName.font=reportTextFont;
  39. [self.contentView addSubview:_lblCustomerName];
  40. _lblAccountDate = [[UILabel alloc]init];
  41. _lblAccountDate.frame=CGRectMake(Screen_Width-120,ypadding,100,16);
  42. _lblAccountDate.text = [DateFormat dateFormatSplit: orderItem.accountDate];
  43. _lblAccountDate.textAlignment=NSTextAlignmentRight;
  44. _lblAccountDate.font=reportTextFont;
  45. [self.contentView addSubview:_lblAccountDate];
  46. UIView *middleSeparator = [[UIView alloc]init];
  47. middleSeparator.frame=CGRectMake(0,CGRectGetMaxY(_lblCustomerName.frame)+10, Screen_Width, 1);
  48. middleSeparator.backgroundColor=LineBackgroundColor;
  49. [self.contentView addSubview:middleSeparator];
  50. NSDictionary *reportDict = @{NSFontAttributeName:reportTextFont};
  51. UILabel *lblTitleStaffName = [[UILabel alloc]init];
  52. NSString *titleStaffName = @"业务员:";
  53. CGRect titleStaffNameFrame = [titleStaffName textRectWithSize:CGSizeMake(100,16) attributes:reportDict];
  54. titleStaffNameFrame.origin.x = xpadding;
  55. titleStaffNameFrame.origin.y = CGRectGetMaxY(middleSeparator.frame)+15;
  56. lblTitleStaffName.font=reportTextFont;
  57. lblTitleStaffName.frame=titleStaffNameFrame;
  58. lblTitleStaffName.text=titleStaffName;
  59. lblTitleStaffName.textColor=LabelGrayTextColor;
  60. [self.contentView addSubview:lblTitleStaffName];
  61. _lblStaffName = [[UILabel alloc]init];
  62. CGFloat w = Screen_Width / 2 - CGRectGetMaxX(lblTitleStaffName.frame)-5;
  63. CGRect staffNameFrame = CGRectMake(CGRectGetMaxX(lblTitleStaffName.frame), CGRectGetMaxY(middleSeparator.frame)+15, w, 16);
  64. _lblStaffName.frame=staffNameFrame;
  65. _lblStaffName.text=orderItem.staffName;
  66. _lblStaffName.font=reportTextFont;
  67. [self.contentView addSubview:_lblStaffName];
  68. UILabel *lblTitleInoviceType = [[UILabel alloc]init];
  69. NSString *titleInvoiceType = @"单据类型:";
  70. CGRect titleInvoiceTypeFrame = [titleInvoiceType textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict];
  71. titleInvoiceTypeFrame.origin.x= Screen_Width/2;
  72. titleInvoiceTypeFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+15;
  73. lblTitleInoviceType.frame=titleInvoiceTypeFrame;
  74. lblTitleInoviceType.font=reportTextFont;
  75. lblTitleInoviceType.text=titleInvoiceType;
  76. lblTitleInoviceType.textColor=LabelGrayTextColor;
  77. [self.contentView addSubview:lblTitleInoviceType];
  78. NSString *invoiceType=orderItem.invoiceTypeName;
  79. _lblInvoiceType = [[UILabel alloc]init];
  80. _lblInvoiceType.frame=CGRectMake(CGRectGetMaxX(lblTitleInoviceType.frame), CGRectGetMaxY(middleSeparator.frame)+15,70, 17);
  81. _lblInvoiceType.text=invoiceType;
  82. _lblInvoiceType.lineBreakMode = NSLineBreakByWordWrapping | NSLineBreakByTruncatingTail;
  83. _lblInvoiceType.numberOfLines=1;
  84. _lblInvoiceType.font=reportTextFont;
  85. [self.contentView addSubview:_lblInvoiceType];
  86. UILabel *lblTitleOrganizationName = [[UILabel alloc]init];
  87. NSString *titleOrganizationName = @"部门:";
  88. lblTitleOrganizationName.text=titleOrganizationName;
  89. CGRect titleOrganizationNameFrame = [titleOrganizationName textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict];
  90. titleOrganizationNameFrame.origin.x =xpadding;
  91. titleOrganizationNameFrame.origin.y =CGRectGetMaxY(lblTitleStaffName.frame)+15;
  92. lblTitleOrganizationName.font=reportTextFont;
  93. lblTitleOrganizationName.textColor=LabelGrayTextColor;
  94. lblTitleOrganizationName.frame=titleOrganizationNameFrame;
  95. [self.contentView addSubview:lblTitleOrganizationName];
  96. NSString *organizationName=orderItem.organizationName;
  97. _lblOrganizationName = [[UILabel alloc]init];
  98. w = Screen_Width - CGRectGetMaxX(lblTitleOrganizationName.frame)-20;
  99. CGRect organizationNameFrame = [organizationName textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict];
  100. organizationNameFrame.origin.x =CGRectGetMaxX(lblTitleOrganizationName.frame);
  101. organizationNameFrame.origin.y =CGRectGetMaxY(lblTitleStaffName.frame)+15;
  102. _lblOrganizationName.frame=organizationNameFrame;
  103. _lblOrganizationName.font=reportTextFont;
  104. _lblOrganizationName.text=organizationName;
  105. [self.contentView addSubview:_lblOrganizationName];
  106. UILabel *lblTitleCustomerAddress = [[UILabel alloc]init];
  107. NSString *titleCustomerAddress = @"客户地址:";
  108. lblTitleCustomerAddress.text=titleCustomerAddress;
  109. CGRect titleCustomerAddressFrame = [titleCustomerAddress textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:reportDict];
  110. titleCustomerAddressFrame.origin.x =xpadding;
  111. titleCustomerAddressFrame.origin.y =CGRectGetMaxY(lblTitleOrganizationName.frame)+15;
  112. lblTitleCustomerAddress.font=reportTextFont;
  113. lblTitleCustomerAddress.textColor=LabelGrayTextColor;
  114. lblTitleCustomerAddress.frame=titleCustomerAddressFrame;
  115. [self.contentView addSubview:lblTitleCustomerAddress];
  116. NSString *customerAddress=orderItem.customerAddress;
  117. _lblCustomerAddress = [[UILabel alloc]init];
  118. w = Screen_Width - CGRectGetMaxX(lblTitleCustomerAddress.frame)-20;
  119. CGRect customerAddressFrame = [customerAddress textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict];
  120. customerAddressFrame.origin.x =CGRectGetMaxX(lblTitleCustomerAddress.frame);
  121. customerAddressFrame.origin.y =CGRectGetMaxY(lblTitleOrganizationName.frame)+15;
  122. _lblCustomerAddress.frame=customerAddressFrame;
  123. _lblCustomerAddress.font=reportTextFont;
  124. _lblCustomerAddress.text=customerAddress;
  125. [self.contentView addSubview:_lblCustomerAddress];
  126. UILabel *lblTitleTelephone = [[UILabel alloc]init];
  127. NSString *titleTelephone = @"联系电话:";
  128. lblTitleTelephone.text=titleTelephone;
  129. CGRect titleTelephoneFrame = [titleTelephone textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:reportDict];
  130. titleTelephoneFrame.origin.x =xpadding;
  131. titleTelephoneFrame.origin.y =CGRectGetMaxY(lblTitleCustomerAddress.frame)+15;
  132. lblTitleTelephone.font=reportTextFont;
  133. lblTitleTelephone.textColor=LabelGrayTextColor;
  134. lblTitleTelephone.frame=titleTelephoneFrame;
  135. [self.contentView addSubview:lblTitleTelephone];
  136. NSString *telephone=orderItem.telephone;
  137. _lblTelephone = [[UILabel alloc]init];
  138. w = Screen_Width - CGRectGetMaxX(lblTitleTelephone.frame)-20;
  139. CGRect telephoneFrame = [telephone textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict];
  140. telephoneFrame.origin.x =CGRectGetMaxX(lblTitleTelephone.frame);
  141. telephoneFrame.origin.y =CGRectGetMaxY(lblTitleCustomerAddress.frame)+15;
  142. _lblTelephone.frame=telephoneFrame;
  143. _lblTelephone.font=reportTextFont;
  144. _lblTelephone.text=telephone;
  145. [self.contentView addSubview:_lblTelephone];
  146. middleSeparator = [[UIView alloc]init];
  147. middleSeparator.frame=CGRectMake(0,CGRectGetMaxY(lblTitleTelephone.frame)+15, Screen_Width, 1);
  148. middleSeparator.backgroundColor=LineBackgroundColor;
  149. [self.contentView addSubview:middleSeparator];
  150. NSDictionary *orderDict = @{NSFontAttributeName:[UIFont systemFontOfSize:SubLabelAndTextFontOfSize]};
  151. _lblTotalElse = [[UILabel alloc]init];
  152. _lblTotalElse.font = [UIFont systemFontOfSize:11];
  153. _lblTotalElse.textAlignment=NSTextAlignmentRight;
  154. CGRect littleCountElseFrame;
  155. NSString *littleCountTitle=@"小计:¥";
  156. NSString *semicolon=@";";
  157. NSString *abandonZeroTitle=@"(舍零¥";
  158. NSString *goodsAmountTitle=@"货款¥";
  159. NSString *outInventoryAmountTitle=@"出库金额¥";
  160. NSString *rightBrackets=@")";
  161. if([orderItem.invoiceType isEqualToString:@"2"]){
  162. NSString *littleCountElse= [NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@%@%@%@",littleCountTitle,orderItem.totalAmount,semicolon,abandonZeroTitle,orderItem.discountAmount,semicolon,goodsAmountTitle,orderItem.goodsAmount,semicolon,outInventoryAmountTitle,orderItem.outAmount,rightBrackets];
  163. NSMutableAttributedString *littleCountStr = [[NSMutableAttributedString alloc] initWithString:littleCountElse];
  164. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,littleCountTitle.length)];
  165. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(littleCountTitle.length,orderItem.totalAmount.length)];
  166. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length,semicolon.length)];
  167. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length,abandonZeroTitle.length)];
  168. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length,orderItem.discountAmount.length)];
  169. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length,semicolon.length)];
  170. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length,goodsAmountTitle.length)];
  171. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length,orderItem.goodsAmount.length)];
  172. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length+orderItem.goodsAmount.length,semicolon.length)];
  173. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length+orderItem.goodsAmount.length+semicolon.length,outInventoryAmountTitle.length)];
  174. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length+orderItem.goodsAmount.length+semicolon.length+outInventoryAmountTitle.length,orderItem.outAmount.length)];
  175. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length+orderItem.goodsAmount.length+semicolon.length+outInventoryAmountTitle.length+orderItem.outAmount.length,rightBrackets.length)];
  176. _lblTotalElse.attributedText=littleCountStr;
  177. littleCountElseFrame = [littleCountElse textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:orderDict];
  178. littleCountElseFrame.origin.x =Screen_Width-littleCountElseFrame.size.width-xpadding;
  179. littleCountElseFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+ 15;
  180. _lblTotalElse.frame=littleCountElseFrame;
  181. [self.contentView addSubview:_lblTotalElse];
  182. }
  183. else
  184. {
  185. NSString *littleCountElse= [NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@",littleCountTitle,orderItem.totalAmount,semicolon,abandonZeroTitle,orderItem.discountAmount,semicolon,goodsAmountTitle,orderItem.goodsAmount,rightBrackets];
  186. NSMutableAttributedString *littleCountStr = [[NSMutableAttributedString alloc] initWithString:littleCountElse];
  187. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,littleCountTitle.length)];
  188. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(littleCountTitle.length,orderItem.totalAmount.length)];
  189. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length,semicolon.length)];
  190. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length,abandonZeroTitle.length)];
  191. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length,orderItem.discountAmount.length)];
  192. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length,semicolon.length)];
  193. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length,goodsAmountTitle.length)];
  194. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length,orderItem.goodsAmount.length)];
  195. [littleCountStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(littleCountTitle.length+orderItem.totalAmount.length+semicolon.length+abandonZeroTitle.length+orderItem.discountAmount.length+semicolon.length+goodsAmountTitle.length+orderItem.goodsAmount.length,rightBrackets.length)];
  196. _lblTotalElse.attributedText=littleCountStr;
  197. _lblTotalElse.text=littleCountElse;
  198. littleCountElseFrame = [littleCountElse textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:orderDict];
  199. littleCountElseFrame.origin.x =Screen_Width-littleCountElseFrame.size.width-xpadding;
  200. littleCountElseFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+ 15;
  201. _lblTotalElse.frame=littleCountElseFrame;
  202. [self.contentView addSubview:_lblTotalElse];
  203. }
  204. UIView *bottomSeparator = [[UIView alloc]init];
  205. bottomSeparator.frame=CGRectMake(0,CGRectGetMaxY(_lblTotalElse.frame)+15, Screen_Width, 10);
  206. bottomSeparator.backgroundColor=LineBackgroundColor;
  207. [self.contentView addSubview:bottomSeparator];
  208. }
  209. @end