| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- //
- // ScanModelListCell.m
- // HMLG Scan Order
- //
- // Created by Rui Zhang on 3/17/22.
- // Copyright © 2022 United Software Applications, Inc. All rights reserved.
- //
- #import "ScanModelListCell.h"
- #import "RAConvertor.h"
- #import "RAUtils.h"
- #import "RASingleton.h"
- #import "AppDelegate.h"
- #import "RADataProvider.h"
- #define NUMBERS @"0123456789\n"
- @implementation ScanModelListCell
- //- (IBAction)stepChange:(id)sender {
- // self.editQTY.text = [NSString stringWithFormat:@"%d",(int)((UIStepper*)sender).value ];
- //// self.pre_val =(int)((UIStepper*)sender).value;
- //}
- - (void)awakeFromNib {
- [super awakeFromNib];
- // self.editQTY.delegate = self;
- // _editQTY.delegate = self;
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)setModelJson:(NSMutableDictionary *)modelJson
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- NSDictionary* price_group = [RADataProvider get_price_group:appDelegate.price_group];
- self.labelPrice0.text = price_group[@"price_0"][@"display"];//appDelegate.price0_name;
- self.labelPrice1.text = price_group[@"price_1"][@"display"];//appDelegate.price1_name;
- self.labelPrice2.text = price_group[@"price_2"][@"display"];//appDelegate.price2_name;
- self.labelPrice3.text = price_group[@"price_3"][@"display"];//appDelegate.price3_name;
-
-
- if(price_group[@"price_4"])
- {
- self.labelPrice3.text = price_group[@"price_4"][@"display"];
- }
-
- _modelJson = modelJson;
-
-
- _labelModel.text=_modelJson[@"model"];
- _labelDescription.text=_modelJson[@"description"];
- _labelDimension.text=_modelJson[@"dimension"];
- _labelCuft.text=_modelJson[@"unit_cuft"];
- _labelOrigin.text=_modelJson[@"origin"];
- _labelPort.text=_modelJson[@"port"];
-
- // NSString * cell_price;
- // if(RASingleton.sharedInstance.price_type==1)
- // {
- //// if(_modelJson [@"net_price"])
- // cell_price=_modelJson[@"price3"];
- //// jitem[@"unit_price"] =jitem[@"price3"];
- //// jitem[@"erp_unit_price"] =jitem[@"price3"];
- //// else if(_modelJson [@"special_price"])
- //// {
- //// unit_price= _modelJson[@"price2"];
- //// }
- //// else
- //// {
- //// unit_price= _modelJson[@"price1"];
- //// }
- // }
- // else
- // {
- // cell_price=_modelJson[@"price0"];
- //// jitem[@"unit_price"] =jitem[@"price0"];
- //// jitem[@"erp_unit_price"] =jitem[@"price0"];
- // }
-
-
- // NSString* price0=_modelJson[@"price0"]; //DDP
- // NSString* price1=_modelJson[@"price1"]; //WHSE
- // NSString* price2=_modelJson[@"price2"]; //SHOW
- // NSString* price3=_modelJson[@"price3"]; //%25
- NSString* price0=_modelJson[price_group[@"price_0"][@"name"]]; //DDP
- NSString* price1=_modelJson[price_group[@"price_1"][@"name"]]; //WHSE
- NSString* price2=_modelJson[price_group[@"price_2"][@"name"]]; //SHOW
- NSString* price3=_modelJson[price_group[@"price_3"][@"name"]]; //%25
-
-
-
-
-
- if(![price0 isEqualToString: @"N/A"])
- price0 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_0"][@"name"]] doubleValue]];
- if(![price1 isEqualToString: @"N/A"])
- price1 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_1"][@"name"]] doubleValue]];
- if(![price2 isEqualToString: @"N/A"])
- {
- price2 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_2"][@"name"]] doubleValue]];
- // if(RASingleton.sharedInstance.price_type==1)
- _modelJson [@"special_price"] = @true;
- }
- if(![price3 isEqualToString: @"N/A"])
- price3 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_3"][@"name"]] doubleValue]];
- // if(![_modelJson [@"special_price"] boolValue]&& ![price1 isEqualToString: @"N/A"] && [price1 isEqual:price3])
- if((![price1 isEqualToString: @"N/A"] && [price1 isEqual:price3])||(![price2 isEqualToString: @"N/A"] && [price2 isEqual:price3]))
- {
- // if(RASingleton.sharedInstance.price_type==1)
- _modelJson [@"net_price"] = @true;
- }
-
-
-
- if([_modelJson[price_group[@"price_0"][@"name"]] isEqualToString:@"N/A"])
- _labelPriceCTNR.text=@"";//_modelJson[@"price0"];
- else
- _labelPriceCTNR.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_0"][@"name"]] floatValue]];
-
- // if([price3 isEqualToString:@"N/A"])
- // _labelPriceNCA.text= price3;
- // else
- // _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
-
- if([_modelJson [@"special_price"] boolValue])
- {
- if([_modelJson[price_group[@"price_2"][@"name"]] isEqualToString:@"N/A"])
- _labelPriceSpecial.text=@"";//_modelJson[@"price2"];
- else
- _labelPriceSpecial.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_2"][@"name"]] floatValue]];
- }
- else
- {
- _labelPriceSpecial.text=@"";//@"N/A";
- }
-
-
- if([_modelJson [@"net_price"] boolValue])
- {
- // if([_modelJson[@"price1"] isEqualToString:@"N/A"])
- // {
- // _labelPriceNet.text=_modelJson[@"price1"];
- //// _labelPriceNCA.text=@"N/A";
- // }
- // else
- // {
- // _labelPriceNet.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
- //// _labelPriceNCA.text=@"N/A";
- // }
-
- if([_modelJson[price_group[@"price_3"][@"name"]] isEqualToString:@"N/A"])
- {
- _labelPriceNet.text=@"";//_modelJson[@"price3"];
- // _labelPriceNCA.text=@"N/A";
- }
- else
- {
- _labelPriceNet.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_3"][@"name"]] floatValue]];
- // _labelPriceNCA.text=@"N/A";
- }
-
- }
- else
- {
- _labelPriceNet.text=@"";//@"N/A";
- }
-
-
- if(price_group[@"price_4"])
- {
- // price4 如果存在,会显示在price3的位置
- NSString* price4=_modelJson[price_group[@"price_4"][@"name"]]; //%25
-
- if(![price4 isEqualToString: @"N/A"])
- price4 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_4"][@"name"]] doubleValue]];
- else
- price4 =@"";
- _labelPriceNet.text=price4;
- }
- // {
- // if([_modelJson[@"price1"] isEqualToString:@"N/A"])
- // {
- // _labelPriceNCA.text=_modelJson[@"price1"];
- //// _labelPriceNCA.text=@"N/A";
- // }
- // else
- // {
- // _labelPriceNCA.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
- //// _labelPriceNet.text=@"N/A";
- // }
- // }
- {
- if([_modelJson[price_group[@"price_1"][@"name"]] isEqualToString:@"N/A"])
- {
- _labelPriceNCA.text=@"";//_modelJson[@"price1"];
- // _labelPriceNCA.text=@"N/A";
- }
- else
- {
- _labelPriceNCA.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_1"][@"name"]] floatValue]];
- // _labelPriceNet.text=@"N/A";
- }
- }
-
- //
- // if([cell_price isEqualToString:@"N/A"])
- // _labelPriceNCA.text=cell_price;//_modelJson[@"unit_price"];
- // else
- // _labelPriceNCA.text=[RAConvertor currencyNumber:[cell_price floatValue]];
- // if([_modelJson[@"price1"] isEqualToString:@"N/A"])
- // {
- // _labelPrice25p.text=@"";//_modelJson[@"price2"];
- // }
- // else
- // {
- // _labelPrice25p.text=_modelJson[@"price2"];
- // }
- //
- _labelAvailable.text=_modelJson[@"available"];
- _editQTY.text=[_modelJson[@"count"] stringValue];
-
- int c =[_modelJson[@"count"] intValue];
- int s =[_modelJson[@"stockUom"] intValue];
- [self init_Stepper:s max:9999 min:0 value:c];
-
-
-
- }
- -(void) init_Stepper:(int) step max:(int) max min:(int)min value:(int)value
- {
-
- // [self.stepper becomeFirstResponder];
- if(self.steper!=nil)
- {
- // if(min<=0)
- // min=1;
- if(step<=0)
- step=1;
- self.steper.minimumValue= min;
-
-
-
- self.steper.stepValue= step;
-
- self.steper.value= value;
-
-
-
- // [self.qtystepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-
-
- }
- }
- //
- //#pragma mark textField delegate
- //
- //- (BOOL)textFieldShouldReturn:(UITextField *)textField {
- // [textField resignFirstResponder];
- // return NO;
- //}
- //-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
- //
- //
- //// DebugLog(@"text:%@",textField.text);
- //
- //
- //
- // NSCharacterSet *cs;
- // cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
- //
- // NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
- //
- // BOOL canChange = [string isEqualToString:filtered];
- //
- //
- //
- //
- // return canChange;
- //}
- //- (void)textFieldDidEndEditing:(UITextField *)textField
- //{
- //
- //
- //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // int qty = [textField.text intValue];
- //
- // if(qty==0)
- // qty=self.steper.minimumValue;
- //
- //
- //// if ((int)qty % (int)self.stepper.stepValue != 0) {
- //// UIViewController* vc=[RAUtils getViewController :self];
- //// [((CartViewController *)vc).itemListTable reloadData];
- //// [RAUtils message_alert:[NSString stringWithFormat:@"Sold in quantities of %d",(int)(self.stepper.stepValue)] title:@"Change Model Count" controller:vc];
- //// return;
- //// }
- ////
- //
- // int c=qty;
- //
- // int m=c%(int)(self.steper.stepValue);
- // if(m!=0)
- //
- // {
- // [RAUtils message_alert:[NSString stringWithFormat:@"QTY must be a multiple of %d",(int)self.steper.stepValue] title:@"Warrning" controller:[RAUtils getViewController:self]];
- // textField.text = [NSString stringWithFormat:@"%d",self.pre_val];
- // }
- //
- // self.pre_val = qty;
- //
- //
- //
- //
- //
- //
- //
- //
- //}
- //
- //- (void)textFieldDidBeginEditing:(UITextField *)textField
- //{
- // NSString* text = textField.text;
- // if(text.length==0)
- // text=@"0";
- // self.pre_val = [textField.text intValue];
- //
- // // self.last_edit = textField.text;
- //}
- @end
|