| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- //
- // NewSalesOutStorageGoodsListCell.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/18.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewSalesOutStorageGoodsListCell.h"
- @implementation NewSalesOutStorageGoodsListCell
- #pragma mark 公共函数
- /**
- 加载cell
- @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];
-
- return self;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
-
- }
- #pragma 委托函数
- /**
- textfield结束编辑回调函数
- @param field <#field description#>
- */
- - (void) textFieldDidEndEditing:(UITextField *) field
- {
- if(field.tag==1000){
- NSString *remarks=field.text;
- _goodsListModel.remark=remarks;
- return;
- }
-
- else if(field.tag==1001){
- NSString *outGoingQuantity=field.text;
-
- if(outGoingQuantity!=nil){
- double quantityValue=outGoingQuantity.doubleValue;
- NSInteger circulateType= _goodsListModel.circulateType;
- NSString *quantity= [NSString stringWithFormat:@"%lf",quantityValue];
- double acreage=[_goodsListModel.acreage doubleValue];
- OrderQuantity *orderQuantity=[OrderQuantity new];
- NSInteger decimalPlaces= _goodsListModel.decimalPlaces;
- NSString *calculateQuantity= [orderQuantity calculateOrderQuantity:circulateType decimalPlaces:[NSString stringWithFormat:@"%ld",(long)decimalPlaces] quantity:quantity acreage:acreage];
-
- _goodsListModel.outGoingQuantity=calculateQuantity;
- _txtDeliveryQuantity.text=calculateQuantity;
- }
-
- else{
- _goodsListModel.outGoingQuantity=@"0";
- _txtDeliveryQuantity.text=@"0";
- }
-
- return;
- }
-
- }
- #pragma mark 私有函数
- /**
- 初始化cell UI和数据
- @param salesOutStorageGoodsListModel <#salesOutStorageGoodsListModel description#>
- */
- - (void)setNewSalesOutStorageGoodsDetailListModel:(SalesOutStorageSalesSlipGoodsListModel *)salesOutStorageGoodsListModel{
- _goodsListModel=salesOutStorageGoodsListModel;
- if(_goodsListModel==nil){
- return;
- }
- CGFloat heightLine = 1;
- CGFloat heightRow = 40;
- CGFloat lblx = 20;
- CGFloat lbly = 8;
- CGFloat lblwidth = 70;
- CGFloat lblheight = 25;
- CGFloat valuey = 8;
- CGFloat valueheight = 25;
- UIView *vGoodsName = [UIView new];
- vGoodsName.frame=CGRectMake(0, valuey, Screen_Width, heightRow);
- [self.contentView addSubview:vGoodsName];
- _lblGoodsName=[[UILabel alloc]init];
- _lblGoodsName.frame=CGRectMake(lblx, lbly+2,Screen_Width-85, valueheight);
- _lblGoodsName.text=salesOutStorageGoodsListModel.goodsName;
- _lblGoodsName.font=orderTextFont;
- [self.contentView addSubview:_lblGoodsName];
- _btnDelete=[UIButton buttonWithType:UIButtonTypeCustom];
-
- _btnDelete.frame=CGRectMake(Screen_Width-80,lbly-5,80, valueheight);
- [vGoodsName addSubview:_btnDelete];
- [_btnDelete addTarget:self action:@selector(deleteGoods) forControlEvents:UIControlEventTouchUpInside];
- UIImageView *deleteImg=[[UIImageView alloc]init];
- deleteImg.frame=CGRectMake(0,5,15,15);
- [deleteImg setImage:[UIImage imageNamed:@"icon_delete"]];
- deleteImg.userInteractionEnabled=NO;
- [_btnDelete addSubview:deleteImg];
- UILabel *deleteTitle=[[UILabel alloc]init];
- deleteTitle.frame=CGRectMake(CGRectGetMaxX(deleteImg.frame)+3,0,40, 25);
- deleteTitle.text=@"删除";
- deleteTitle.font=orderTextFont;
- [_btnDelete addSubview:deleteTitle];
-
- //分割线
- _topSeparator= [UIView new];
- _topSeparator.frame = CGRectMake(0, CGRectGetMaxY(vGoodsName.frame), Screen_Width, heightLine);
-
- [self.contentView addSubview:_topSeparator];
- UIButton *btnLine = [UIButton buttonWithType:UIButtonTypeCustom];
- [btnLine setBackgroundImage:[UIImage imageNamed:@"dash"] forState:UIControlStateNormal];
- btnLine.frame = CGRectMake(0 ,0 , Screen_Width, heightLine);
- [_topSeparator addSubview:btnLine];
-
- //商品编码
- UIView *vGoodsCode = [UIView new];
- vGoodsCode.frame=CGRectMake(0, CGRectGetMaxY(_topSeparator.frame), Screen_Width/2, heightRow);
- [self.contentView addSubview:vGoodsCode];
-
- UILabel *lblGoodsCodeTitle=[UILabel new];
- lblGoodsCodeTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
- lblGoodsCodeTitle.text=@"商品编码:";
- lblGoodsCodeTitle.textColor = LabelGrayTextColor;
- lblGoodsCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vGoodsCode addSubview:lblGoodsCodeTitle];
- _lblGoodsCode = [UILabel new];
- _lblGoodsCode.frame=CGRectMake(CGRectGetMaxX(lblGoodsCodeTitle.frame), valuey, Screen_Width/2 -CGRectGetMaxX(lblGoodsCodeTitle.frame), valueheight);
- _lblGoodsCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vGoodsCode addSubview:_lblGoodsCode];
- _lblGoodsCode.text = salesOutStorageGoodsListModel.goodsCode;
-
- //唯一编码
- UIView *vOnlyCode = [UIView new];
- vOnlyCode.frame=CGRectMake(Screen_Width / 2, CGRectGetMaxY(_topSeparator.frame), Screen_Width / 2, heightRow);
- [self.contentView addSubview: vOnlyCode];
-
- UILabel *lblOnlyCodeTitle=[UILabel new];
- lblOnlyCodeTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
- lblOnlyCodeTitle.text=@"唯一编码:";
- lblOnlyCodeTitle.textColor = LabelGrayTextColor;
- lblOnlyCodeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vOnlyCode addSubview:lblOnlyCodeTitle];
- _lblOnlyCode= [UILabel new];
- _lblOnlyCode.frame=CGRectMake(CGRectGetMaxX(lblOnlyCodeTitle.frame), valuey, Screen_Width/2-lblwidth-5 , valueheight);
- _lblOnlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vOnlyCode addSubview:_lblOnlyCode];
- _lblOnlyCode.text = salesOutStorageGoodsListModel.onlyCode;
-
- UIView *vColorNumber= [UIView new];
- vColorNumber.frame=CGRectMake(0, CGRectGetMaxY(vGoodsCode.frame), Screen_Width/3, heightRow);
- [self.contentView addSubview: vColorNumber];
-
- UILabel *lblColorNumberTitle=[UILabel new];
- lblColorNumberTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
- lblColorNumberTitle.text=@"色 号:";
- lblColorNumberTitle.textColor = [UIColor redColor];
- lblColorNumberTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vColorNumber addSubview:lblColorNumberTitle];
- _lblColorNumber= [UILabel new];
- _lblColorNumber.frame=CGRectMake(CGRectGetMaxX(lblColorNumberTitle.frame), valuey, vColorNumber.frame.size.width-lblwidth-5 , valueheight);
- _lblColorNumber.userInteractionEnabled=YES;
- _lblColorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vColorNumber addSubview:_lblColorNumber];
- _lblColorNumber.text = salesOutStorageGoodsListModel.colorNumber;
-
- UITapGestureRecognizer *tapRecognizerColorNumber=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goColorNumber:)];
- _lblColorNumber.userInteractionEnabled=YES;
- [_lblColorNumber addGestureRecognizer:tapRecognizerColorNumber];
-
- UIView *vSpecification= [UIView new];
- vSpecification.frame=CGRectMake(Screen_Width/3, CGRectGetMaxY(vGoodsCode.frame), Screen_Width/3, heightRow);
- [self.contentView addSubview:vSpecification];
- UILabel *lblSpecificationTitle=[UILabel new];
- lblSpecificationTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
- lblSpecificationTitle.text=@"规 格:";
- lblSpecificationTitle.textColor = LabelGrayTextColor;
- lblSpecificationTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vSpecification addSubview:lblSpecificationTitle];
- _lblSpecification = [UILabel new];
- _lblSpecification.frame=CGRectMake(CGRectGetMaxX(lblSpecificationTitle.frame), valuey, vSpecification.frame.size.width -lblwidth, valueheight);
- _lblSpecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vSpecification addSubview:_lblSpecification];
- _lblSpecification.text = salesOutStorageGoodsListModel.goodsSpecification;
-
- UIView *vGrade= [UIView new];
- vGrade.frame=CGRectMake(CGRectGetMaxX(vSpecification.frame), CGRectGetMaxY(vGoodsCode.frame),Screen_Width-CGRectGetMaxX(vSpecification.frame), heightRow);
- [self.contentView addSubview:vGrade];
- UILabel *lblGradeTitle=[UILabel new];
- lblGradeTitle.frame=CGRectMake(0, lbly, lblwidth, lblheight);
- lblGradeTitle.text=@"等 级:";
- lblGradeTitle.textColor = LabelGrayTextColor;
- lblGradeTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vGrade addSubview:lblGradeTitle];
- _lblGrade = [UILabel new];
- _lblGrade.frame=CGRectMake(CGRectGetMaxX(lblGradeTitle.frame), lbly,vGrade.frame.size.width-lblwidth-5, valueheight);
- _lblGrade.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vGrade addSubview:_lblGrade];
- _lblGrade.text = salesOutStorageGoodsListModel.gradeName;
-
- UIView *vRemarks= [UIView new];
- vRemarks.frame=CGRectMake(0, CGRectGetMaxY(vColorNumber.frame), Screen_Width, heightRow);
- [self.contentView addSubview:vRemarks];
- UILabel *lblRemarksTitle=[UILabel new];
- lblRemarksTitle.frame=CGRectMake(lblx, lbly, lblwidth, lblheight);
- lblRemarksTitle.text=@"备 注:";
- lblRemarksTitle.textColor = LabelGrayTextColor;
- lblRemarksTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vRemarks addSubview:lblRemarksTitle];
- _txtRemarks =[UITextField new];
- _txtRemarks.placeholder=@"请输入备注";
- _txtRemarks.delegate=self;
- _txtRemarks.tag=1000;
- _txtRemarks.text=salesOutStorageGoodsListModel.remark;
- _txtRemarks.frame=CGRectMake(CGRectGetMaxX(lblRemarksTitle.frame), valuey, Screen_Width-CGRectGetMaxX(lblRemarksTitle.frame)-5, valueheight);
- _txtRemarks.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vRemarks addSubview:_txtRemarks];
- _middleSeparator= [UIView new];
- _middleSeparator.frame = CGRectMake(0, CGRectGetMaxY(vRemarks.frame), Screen_Width,1);
- [_middleSeparator setBackgroundColor:LineBackgroundColor];
- [self.contentView addSubview:_middleSeparator];
- NSDictionary *outStorageDict = @{NSFontAttributeName:orderTextFont};
- UIView *vQuantity=[UIView new];
- vQuantity.frame=CGRectMake(0,CGRectGetMaxY(_middleSeparator.frame),Screen_Width, heightRow);
- [self.contentView addSubview:vQuantity];
- NSString *outQuantityStr = salesOutStorageGoodsListModel.outQuantity;
-
- CGRect outQuantityFrame = [outQuantityStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
- outQuantityFrame.origin.x =Screen_Width-outQuantityFrame.size.width-20;
- outQuantityFrame.origin.y = lbly;
- _lblOutQuantity=[UILabel new];
- _lblOutQuantity.frame=outQuantityFrame;
- _lblOutQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- _lblOutQuantity.textColor=[UIColor redColor];
- [vQuantity addSubview:_lblOutQuantity];
- _lblOutQuantity.text = salesOutStorageGoodsListModel.outQuantity;
-
- NSString *outQuantityTitleStr =@"已出数量:";
- CGRect outQuantityTitleFrame = [outQuantityTitleStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
- outQuantityTitleFrame.origin.x =Screen_Width-outQuantityFrame.size.width-outQuantityTitleFrame.size.width-3-20;
- outQuantityTitleFrame.origin.y = lbly;
- UILabel *lblOutQuantityTitle=[UILabel new];
- lblOutQuantityTitle.frame=outQuantityTitleFrame;
- lblOutQuantityTitle.textColor=[UIColor redColor];
- lblOutQuantityTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- lblOutQuantityTitle.text=outQuantityTitleStr;
- [vQuantity addSubview:lblOutQuantityTitle];
- NSString *salesQuantityStr = salesOutStorageGoodsListModel.salesQuantity;
- CGRect salesQuantityFrame = [salesQuantityStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
- salesQuantityFrame.origin.x =Screen_Width-outQuantityFrame.size.width-outQuantityTitleFrame.size.width-salesQuantityFrame.size.width-20-3-5;
- salesQuantityFrame.origin.y = lbly;
- _lblSalesQuantity=[UILabel new];
- _lblSalesQuantity.frame=salesQuantityFrame;
- _lblSalesQuantity.text=salesQuantityStr;
- _lblSalesQuantity.textColor=[UIColor redColor];
- _lblSalesQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [vQuantity addSubview:_lblSalesQuantity];
- NSString *salesQuantityTitle=@"销售数量";
- CGRect salesQuantityTitleFrame = [salesQuantityTitle textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:outStorageDict];
- salesQuantityTitleFrame.origin.x =Screen_Width-outQuantityFrame.size.width-outQuantityTitleFrame.size.width-salesQuantityFrame.size.width-salesQuantityTitleFrame.size.width-20-3*2-5;
- salesQuantityTitleFrame.origin.y = lbly;
- UILabel *lblSalesQuantityTitle=[UILabel new];
- lblSalesQuantityTitle.frame=salesQuantityTitleFrame;
- lblSalesQuantityTitle.textColor=[UIColor redColor];
- lblSalesQuantityTitle.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- lblSalesQuantityTitle.text=salesQuantityTitle;
- [vQuantity addSubview:lblSalesQuantityTitle];
- UIView *vOutQuantity=[UIView new];
- vOutQuantity.frame=CGRectMake(0,CGRectGetMaxY(vQuantity.frame),Screen_Width, heightRow);
- [self.contentView addSubview:vOutQuantity];
- _txtDeliveryQuantity=[UITextField new];
- _txtDeliveryQuantity.frame=CGRectMake(Screen_Width-110,0,90, valueheight);
- _txtDeliveryQuantity.text=salesOutStorageGoodsListModel.outGoingQuantity;
- _txtDeliveryQuantity.delegate=self;
- _txtDeliveryQuantity.keyboardType=UIKeyboardTypeDecimalPad;
- _txtDeliveryQuantity.layer.borderWidth=0.5f;
- _txtDeliveryQuantity.tag=1001;
- _txtDeliveryQuantity.textAlignment=NSTextAlignmentCenter;
- _txtDeliveryQuantity.layer.borderColor=[UIColor blackColor].CGColor;
- _txtDeliveryQuantity.font=orderTextFont;
- [vOutQuantity addSubview:_txtDeliveryQuantity];
- _lblSalesPrice=[UILabel new];
- _lblSalesPrice.frame=CGRectMake(Screen_Width-210,0,100, valueheight);
- _lblSalesPrice.text=[NSString stringWithFormat:@"¥%@",salesOutStorageGoodsListModel.salesPrice];
- _lblSalesPrice.layer.borderWidth=0.5f;
- _lblSalesPrice.textColor=LabelGrayTextColor;
- _lblSalesPrice.textAlignment=NSTextAlignmentCenter;
- _lblSalesPrice.layer.borderColor=[UIColor blackColor].CGColor;
- _lblSalesPrice.font=orderTextFont;
- [vOutQuantity addSubview:_lblSalesPrice];
- _bottomSeparator= [UIView new];
- _bottomSeparator.frame = CGRectMake(0, CGRectGetMaxY(vOutQuantity.frame), Screen_Width,10);
- [_bottomSeparator setBackgroundColor:LineBackgroundColor];
- [self.contentView addSubview:_bottomSeparator];
-
- }
- /**
- 跳转到色号页面
- @param gesture <#gesture description#>
- */
- -(void)goColorNumber:(UITapGestureRecognizer *)gesture{
- if([self.goodsDelegate respondsToSelector:@selector(goColorNumber:)])
- {
- [self.goodsDelegate goColorNumber:_index];
-
- }
-
- }
- /**
- 删除商品
- */
- -(void)deleteGoods{
- if([self.goodsDelegate respondsToSelector:@selector(deleteGoods:)])
- {
- [self.goodsDelegate deleteGoods:_index];
-
- }
- }
- @end
|