// // OrderSalesTableViewCell.m // IBOSSmini // // Created by guan hong hou on 2017/5/26. // Copyright © 2017年 elongtian. All rights reserved. // #import "OrderSalesTableViewCell.h" #import "DateFormat.h" #import "NSString+Tools.h" #define reportTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize] @implementation OrderSalesTableViewCell /** 初始化数据 @param style <#style description#> @param reuseIdentifier <#reuseIdentifier description#> @return <#return value description#> */ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { } return self; } /** 单元格ui布局 @param orderItem <#orderItem description#> */ -(void)parseOrderSalesInfo:(OrderSaleListModel *)orderItem{ CGFloat xpadding=20; CGFloat ypadding=10; _lblCustomerName=[[UILabel alloc]init]; _lblCustomerName.frame=CGRectMake(xpadding,ypadding,150,25); _lblCustomerName.text=orderItem.customerName; _lblCustomerName.font=reportTextFont; [self.contentView addSubview:_lblCustomerName]; _lblAccountDate=[[UILabel alloc]init]; _lblAccountDate.frame=CGRectMake(Screen_Width-120,ypadding,100,25); _lblAccountDate.text=[DateFormat dateFormatSplit: orderItem.accountDate]; _lblAccountDate.textAlignment=NSTextAlignmentRight; _lblAccountDate.font=reportTextFont; [self.contentView addSubview:_lblAccountDate]; UIView *middleSeparator=[[UIView alloc]init]; middleSeparator.frame=CGRectMake(0,CGRectGetMaxY(_lblCustomerName.frame)+10, Screen_Width, 1); middleSeparator.backgroundColor=LineBackgroundColor; [self.contentView addSubview:middleSeparator]; NSDictionary *reportDict = @{NSFontAttributeName:reportTextFont}; UILabel *lblTitleStaffName=[[UILabel alloc]init]; NSString *titleStaffName=@"业务员:"; CGRect titleStaffNameFrame = [titleStaffName textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict]; titleStaffNameFrame.origin.x = xpadding; titleStaffNameFrame.origin.y = CGRectGetMaxY(middleSeparator.frame)+10; lblTitleStaffName.font=reportTextFont; lblTitleStaffName.frame=titleStaffNameFrame; lblTitleStaffName.text=titleStaffName; lblTitleStaffName.textColor=LabelGrayTextColor; [self.contentView addSubview:lblTitleStaffName]; _lblStaffName=[[UILabel alloc]init]; NSString *staffName=orderItem.staffName; CGFloat w = Screen_Width / 2 - CGRectGetMaxX(lblTitleStaffName.frame)-20; CGRect staffNameFrame = [staffName textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict]; staffNameFrame.origin.x =CGRectGetMaxX(lblTitleStaffName.frame)+10; staffNameFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10; _lblStaffName.frame=staffNameFrame; _lblStaffName.text=orderItem.staffName; _lblStaffName.font=reportTextFont; [self.contentView addSubview:_lblStaffName]; UILabel *lblTitleInoviceType=[[UILabel alloc]init]; NSString *titleInvoiceType=@"单据类型:"; CGRect titleInvoiceTypeFrame = [titleInvoiceType textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict]; titleInvoiceTypeFrame.origin.x= Screen_Width/2; titleInvoiceTypeFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10; lblTitleInoviceType.frame=titleInvoiceTypeFrame; lblTitleInoviceType.font=reportTextFont; lblTitleInoviceType.text=titleInvoiceType; lblTitleInoviceType.textColor=LabelGrayTextColor; [self.contentView addSubview:lblTitleInoviceType]; NSString *invoiceType=orderItem.invoiceTypeName; _lblInvoiceType=[[UILabel alloc]init]; _lblInvoiceType.frame=CGRectMake(CGRectGetMaxX(lblTitleInoviceType.frame)+5, CGRectGetMaxY(middleSeparator.frame)+10,70, 17); _lblInvoiceType.text=invoiceType; _lblInvoiceType.lineBreakMode = NSLineBreakByWordWrapping | NSLineBreakByTruncatingTail; _lblInvoiceType.numberOfLines=1; _lblInvoiceType.font=reportTextFont; [self.contentView addSubview:_lblInvoiceType]; // middleSeparator=[[UIView alloc]init]; // middleSeparator.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleStaffName.frame)+10, Screen_Width, 1); // middleSeparator.backgroundColor=LineBackgroundColor; // [self.contentView addSubview:middleSeparator]; UILabel *lblTitleOrganizationName=[[UILabel alloc]init]; NSString *titleOrganizationName=@"部门:"; lblTitleOrganizationName.text=titleOrganizationName; CGRect titleOrganizationNameFrame = [titleOrganizationName textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:reportDict]; titleOrganizationNameFrame.origin.x =xpadding; titleOrganizationNameFrame.origin.y =CGRectGetMaxY(lblTitleStaffName.frame)+10; lblTitleOrganizationName.font=reportTextFont; lblTitleOrganizationName.textColor=LabelGrayTextColor; lblTitleOrganizationName.frame=titleOrganizationNameFrame; [self.contentView addSubview:lblTitleOrganizationName]; NSString *organizationName=orderItem.organizationName; _lblOrganizationName=[[UILabel alloc]init]; w = Screen_Width - CGRectGetMaxX(lblTitleOrganizationName.frame)-20; CGRect organizationNameFrame = [organizationName textRectWithSize:CGSizeMake(w, MAXFLOAT) attributes:reportDict]; organizationNameFrame.origin.x =CGRectGetMaxX(lblTitleOrganizationName.frame)+10; organizationNameFrame.origin.y =CGRectGetMaxY(lblTitleStaffName.frame)+10; _lblOrganizationName.frame=organizationNameFrame; _lblOrganizationName.font=reportTextFont; _lblOrganizationName.text=organizationName; [self.contentView addSubview:_lblOrganizationName]; middleSeparator=[[UIView alloc]init]; middleSeparator.frame=CGRectMake(xpadding,CGRectGetMaxY(lblTitleOrganizationName.frame)+10, Screen_Width, 1); middleSeparator.backgroundColor=LineBackgroundColor; [self.contentView addSubview:middleSeparator]; NSDictionary *orderDict = @{NSFontAttributeName:[UIFont systemFontOfSize:SubLabelAndTextFontOfSize]}; _lblTotalElse=[[UILabel alloc]init]; _lblTotalElse.font=[UIFont systemFontOfSize:SubLabelAndTextFontOfSize]; _lblTotalElse.textAlignment=NSTextAlignmentLeft; NSString *littleCountElse= [NSString stringWithFormat:@"(舍零¥%@;货款¥%@)",orderItem.discountAmount,orderItem.goodsAmount]; _lblTotalElse.text=littleCountElse; CGRect littleCountElseFrame = [littleCountElse textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:orderDict]; littleCountElseFrame.origin.x =Screen_Width-xpadding-littleCountElseFrame.size.width; littleCountElseFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10; _lblTotalElse.frame=littleCountElseFrame; [self.contentView addSubview:_lblTotalElse]; _lblTotalAmount=[[UILabel alloc]init]; _lblTotalAmount.font=[UIFont systemFontOfSize:SubLabelAndTextFontOfSize]; _lblTotalAmount.textColor=[UIColor redColor]; NSString *totalAmount= orderItem.totalAmount; _lblTotalAmount.text=totalAmount; CGRect littleCountFrame = [totalAmount textRectWithSize:CGSizeMake(150, MAXFLOAT) attributes:orderDict]; littleCountFrame.origin.x =littleCountElseFrame.origin.x-littleCountFrame.size.width-3; littleCountFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10; _lblTotalAmount.frame=littleCountFrame; [self.contentView addSubview:_lblTotalAmount]; UILabel *lblTitleLittleCount=[[UILabel alloc]init]; NSString *titleLittleCount=@"小计:¥"; lblTitleLittleCount.text=titleLittleCount; CGRect titleLittleCountFrame = [titleLittleCount textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:orderDict]; titleLittleCountFrame.origin.x = littleCountFrame.origin.x-titleLittleCountFrame.size.width-3; titleLittleCountFrame.origin.y =CGRectGetMaxY(middleSeparator.frame)+10; lblTitleLittleCount.font=[UIFont systemFontOfSize:SubLabelAndTextFontOfSize]; lblTitleLittleCount.frame=titleLittleCountFrame; [self.contentView addSubview:lblTitleLittleCount]; UIView *bottomSeparator=[[UIView alloc]init]; bottomSeparator.frame=CGRectMake(0,CGRectGetMaxY(lblTitleLittleCount.frame)+10, Screen_Width, 10); bottomSeparator.backgroundColor=LineBackgroundColor; [self.contentView addSubview:bottomSeparator]; } @end