| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- //
- // WareHouseCell.m
- // IBOSSIPAD
- //
- // Created by iHope on 14-7-21.
- // Copyright (c) 2014年 elongtian. All rights reserved.
- //
- #import "GoodsSearchCell.h"
- #import "GoodsSearchModel.h"
- #import "GoodsSearchItemModel.h"
- #import "OrderQuantity.h"
- @interface GoodsSearchCell()<UITextFieldDelegate,UITextFieldDelegate>
- {
-
- }
- @end
- @implementation GoodsSearchCell
- #pragma mark - 公共函数
- /**
- initWithStyle函数
- */
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
-
-
- }
- return self;
- }
- /**
- setSelected函数
- */
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated
- {
- [super setSelected:selected animated:animated];
-
-
- }
- #pragma mark - 委托函数
- /**
- 数量回调函数
- */
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
- {
-
- NSCharacterSet *cs;
- if(textField == _txtQuantity)
- {
- cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSANDDOT] invertedSet];
- NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
- BOOL basicTest = [string isEqualToString:filtered];
- if(!basicTest)
- {
-
- return NO;
- }
- }
-
- return YES;
- }
- /**
- 文本回调函数
- */
- - (void) textFieldDidEndEditing:(UITextField *) field
- {
- [self endEditing:YES];
- if([self.delegate respondsToSelector:@selector(textValueChange: txtField:)])
- {
- [self.delegate textValueChange:self txtField:field];
-
- }
- }
- #pragma mark - 私有函数
- /**
- 初始化订单cell UI
- */
- -(void)parseOrderInfo:(OrderSearchFrame *)orderFrame
- {
- _searchItemModel=orderFrame.searchModel;
- _lblCode=[[UILabel alloc]init];
- _lblCode.frame=orderFrame.productCodeF;
- _lblCode.text=_searchItemModel.code;
- _lblCode.font=orderTextFont;
- [self.contentView addSubview:_lblCode];
- _lblInventoryId=[[UILabel alloc]init];
- _lblInventoryId.frame=orderFrame.inventoryIdF;
- [self.contentView addSubview:_lblInventoryId];
- _lblInventoryId.hidden=YES;
- _lblInventoryId.text=_searchItemModel.inventoryID;
- UIButton *substractButton=[UIButton buttonWithType:UIButtonTypeCustom];
- [substractButton setTitle:@"-" forState:UIControlStateNormal];
- [substractButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
- substractButton.frame=orderFrame.substractBtnF;
- substractButton.layer.borderColor=[UIColor blackColor].CGColor;
- substractButton.layer.borderWidth=1.0;
- [substractButton addTarget:self action:@selector(substractQuantity) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:substractButton];
- _txtQuantity=[UITextField new];
- _txtQuantity.frame=orderFrame.salesQuantityF;
- _txtQuantity.text=_searchItemModel.salesQuantity;
- _txtQuantity.delegate=self;
- _txtQuantity.keyboardType= UIKeyboardTypeDecimalPad;
- _txtQuantity.layer.borderWidth=1.0f;
- _txtQuantity.tag=1002;
- _txtQuantity.textAlignment=NSTextAlignmentCenter;
- _txtQuantity.layer.borderColor=[UIColor blackColor].CGColor;
- _txtQuantity.font=orderTextFont;
- [self.contentView addSubview:_txtQuantity];
-
- UIButton *addButton=[UIButton buttonWithType:UIButtonTypeCustom];
- [addButton setTitle:@"+" forState:UIControlStateNormal];
- [addButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
- addButton.frame=orderFrame.addBtnF;
- addButton.layer.borderColor=[UIColor blackColor].CGColor;
- addButton.layer.borderWidth=1.0;
- [addButton addTarget:self action:@selector(addQuantity) forControlEvents:UIControlEventTouchUpInside];
- [self.contentView addSubview:addButton];
- UIButton *joinCartBtn=[UIButton buttonWithType:UIButtonTypeCustom];
- joinCartBtn.frame=orderFrame.joinCartBtnF;
- [joinCartBtn setImage:[UIImage imageNamed:@"bt_cart"] forState:UIControlStateNormal];
- [self.contentView addSubview:joinCartBtn];
- [ joinCartBtn addTarget:self action:@selector(goCart) forControlEvents:UIControlEventTouchUpInside];
- UIView *middleView=[[UIView alloc]init];
- middleView.frame=orderFrame.middleSeparatorF;
- middleView.backgroundColor=LineBackgroundColor;
- [self.contentView addSubview:middleView];
- UILabel *titleBrandLbl=[[UILabel alloc]init];
- titleBrandLbl.text=@"品牌:";
- titleBrandLbl.textColor=LabelGrayTextColor;
- titleBrandLbl.font=orderTextFont;
- titleBrandLbl.frame=orderFrame.titleBrandF;
- [self.contentView addSubview:titleBrandLbl];
- _lblBrandName=[[UILabel alloc]init];
- if(_searchItemModel.brandName!=nil){
- _lblBrandName.text=_searchItemModel.brandName;
- _lblBrandName.frame=orderFrame.brandF;
- _lblBrandName.font=orderTextFont;
- [self.contentView addSubview:_lblBrandName];
- }
- UILabel *titleOnlyCodeLbl=[[UILabel alloc]init];
- titleOnlyCodeLbl.text=@"唯一编码:";
- titleOnlyCodeLbl.font=orderTextFont;
- titleOnlyCodeLbl.textColor=LabelGrayTextColor;
- titleOnlyCodeLbl.frame=orderFrame.titleOnlyCodeF;
- [self.contentView addSubview:titleOnlyCodeLbl];
- _lblOnlyCode=[[UILabel alloc]init];
- NSString *onlyCode=[_searchItemModel onlyCode];
- if(onlyCode!=nil){
- _lblOnlyCode.text=onlyCode;
- _lblOnlyCode.frame=orderFrame.onlyCodeF;
- _lblOnlyCode.font=orderTextFont;
- [self.contentView addSubview:_lblOnlyCode];
- }
- UILabel *titleColorNumber=[[UILabel alloc]init];
- titleColorNumber.text=@"色号:";
- titleColorNumber.font=orderTextFont;
- titleColorNumber.textColor=LabelGrayTextColor;
- titleColorNumber.frame=orderFrame.titleColorNumberF;
- [self.contentView addSubview:titleColorNumber];
- _lblColorNumber=[[UILabel alloc]init];
- if(_searchItemModel.colorNumber!=nil){
- _lblColorNumber.frame=orderFrame.colorNumberF;
- _lblColorNumber.text=_searchItemModel.colorNumber;
- _lblColorNumber.font=orderTextFont;
- [self.contentView addSubview:_lblColorNumber];
- }
- UILabel *titleSpecificationLbl=[[UILabel alloc]init];
- titleSpecificationLbl.text=@"规格:";
- titleSpecificationLbl.font=orderTextFont;
- titleSpecificationLbl.textColor=LabelGrayTextColor;
- titleSpecificationLbl.font=orderTextFont;
- titleSpecificationLbl.frame=orderFrame.titleSpecificationF;
- [self.contentView addSubview:titleSpecificationLbl];
- _lblSpecification=[[UILabel alloc]init];
- if(_searchItemModel.specification!=nil){
- _lblSpecification.text=_searchItemModel.specification;
- _lblSpecification.frame=orderFrame.specificationF;
- _lblSpecification.font=orderTextFont;
- [self.contentView addSubview:_lblSpecification];
- }
-
- UILabel *titleLevelLbl=[[UILabel alloc]init];
- titleLevelLbl.text=@"等级:";
- titleLevelLbl.font=orderTextFont;
- titleLevelLbl.textColor=LabelGrayTextColor;
- titleLevelLbl.frame=orderFrame.titleLevelF;
- [self.contentView addSubview:titleLevelLbl];
- _lblGradeName=[[UILabel alloc]init];
- if(_searchItemModel.gradeName!=nil){
- _lblGradeName.frame=orderFrame.levelF;
- _lblGradeName.text=_searchItemModel.gradeName;
- _lblGradeName.font=orderTextFont;
- [self.contentView addSubview:_lblGradeName];
- }
- UILabel *titleWarehouseAreaLbl=[[UILabel alloc]init];
- titleWarehouseAreaLbl.text=@"库区:";
- titleWarehouseAreaLbl.font=orderTextFont;
- titleWarehouseAreaLbl.textColor=LabelGrayTextColor;
- titleWarehouseAreaLbl.frame=orderFrame.titleWarehouseAreaF;
- [self.contentView addSubview:titleWarehouseAreaLbl];
- _lblWareHouseName=[[UILabel alloc]init];
- if(_searchItemModel.warehouseName!=nil){
- _lblWareHouseName.text=_searchItemModel.warehouseName;
- _lblWareHouseName.frame=orderFrame.warehouseAreaF;
- _lblWareHouseName.font=orderTextFont;
- [self.contentView addSubview:_lblWareHouseName];
- }
- UIView *bottomline= [[UIView alloc]init];
- bottomline.frame = orderFrame.separatorF;
- bottomline.backgroundColor = LineBackgroundColor;
- [self.contentView addSubview:bottomline];
- UILabel *lbBottomText = [[UILabel alloc] init];
- lbBottomText.frame = orderFrame.bottomTextF;
- lbBottomText.textAlignment = NSTextAlignmentRight;
- lbBottomText.textColor =[UIColor blackColor];
- lbBottomText.text = [NSString stringWithFormat:@"可售量:%@ 结存量:%@",_searchItemModel.balanceQuantity,_searchItemModel.inventoryQuantity];
- lbBottomText.font = orderTextFont;
- [self.contentView addSubview:lbBottomText];
- UIView *bottomSeparatorView=[[UIView alloc]init];
- bottomSeparatorView.frame=orderFrame.bottomSeparatorF;
- bottomSeparatorView.backgroundColor=LineBackgroundColor;
- [self.contentView addSubview:bottomSeparatorView];
- }
- //订单数量减少函数
- -(void)substractQuantity{
- NSString *quantity=_txtQuantity.text;
- if(quantity!=nil){
- double quantityValue=quantity.doubleValue;
- NSInteger circulateType= _searchItemModel.circulateType;
- if(circulateType==2){
- [self.delegate alertMessage:@"请手动输入商品数量"];
- return;
- }
- --quantityValue;
- if(quantityValue<0){
- quantityValue=0;
- }
-
- NSString *quantity= [NSString stringWithFormat:@"%lld",(long long)quantityValue];
- _txtQuantity.text=quantity;
-
- if([self.delegate respondsToSelector:@selector(textValueChange: txtField:)])
- {
- [self.delegate textValueChange:self txtField:_txtQuantity];
-
- }
- }
-
-
- }
- //订单数量增加函数
- -(void)addQuantity{
- NSString *quantity=_txtQuantity.text;
- if(quantity!=nil){
- double quantityValue=quantity.doubleValue;
- NSInteger circulateType= _searchItemModel.circulateType;
- if(circulateType==2){
- [self.delegate alertMessage:@"请手动输入商品数量"];
- return;
- }
-
- ++quantityValue;
- NSString *quantity= [NSString stringWithFormat:@"%lld",(long long)quantityValue];
- _txtQuantity.text=quantity;
- if([self.delegate respondsToSelector:@selector(textValueChange: txtField:)])
- {
- [self.delegate textValueChange:self txtField:_txtQuantity];
-
- }
- }
- }
- //加入购物车函数
- -(void)goCart{
- [self endEditing:YES];
- if([self.delegate respondsToSelector:@selector(joinCart:)])
- {
- [self.delegate joinCart:_searchItemModel];
-
- }
- }
- @end
|