Ray Zhang 1 месяц назад
Родитель
Сommit
b180676866

+ 3 - 0
RedAnt ERP Mobile/HMLG Scan Order/CartViewController.h

@@ -51,6 +51,9 @@
 
 
 @property (strong, nonatomic) IBOutlet UILabel *labelTotal;
 @property (strong, nonatomic) IBOutlet UILabel *labelTotal;
 
 
+
+@property (strong, nonatomic) IBOutlet UILabel *labelScanSubtotal;
+
 @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *mum;
 @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *mum;
 -(void)placeOrder;
 -(void)placeOrder;
 
 

+ 15 - 31
RedAnt ERP Mobile/HMLG Scan Order/CartViewController.m

@@ -468,10 +468,10 @@
 - (IBAction)onEditClick:(id)sender {
 - (IBAction)onEditClick:(id)sender {
     
     
 //        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
 //        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//    
+//
 //        [appDelegate test_onDecodedDataResult:@"4400022"];
 //        [appDelegate test_onDecodedDataResult:@"4400022"];
-//    
-//    
+//
+//
 //        return;
 //        return;
     
     
     
     
@@ -1877,7 +1877,7 @@
 //        if(check)
 //        if(check)
 //        {
 //        {
 //            [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
 //            [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
-//            
+//
 //        }
 //        }
         if(product_id.length==0)
         if(product_id.length==0)
         {
         {
@@ -2152,17 +2152,17 @@
 //        NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
 //        NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
 //        //   NSString * string = [checked componentsJoinedByString:@","];
 //        //   NSString * string = [checked componentsJoinedByString:@","];
 //        //  [params setValue:string forKey:@"cart2Checkbox"];
 //        //  [params setValue:string forKey:@"cart2Checkbox"];
-//        
-//        
-//        
 //
 //
-//        
+//
+//
+//
+//
 //         CreateOrderViewController * orderinfoVC = [[CreateOrderViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
 //         CreateOrderViewController * orderinfoVC = [[CreateOrderViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
-//        
+//
 //        orderinfoVC.disable_dropdown_refresh=true;
 //        orderinfoVC.disable_dropdown_refresh=true;
 //        orderinfoVC.url_type = URL_REMOTE;
 //        orderinfoVC.url_type = URL_REMOTE;
 //        orderinfoVC.request_url=URL_CARTDELIVERY;
 //        orderinfoVC.request_url=URL_CARTDELIVERY;
-//        
+//
 //        orderinfoVC.params = params;
 //        orderinfoVC.params = params;
 //        orderinfoVC.title=@"";
 //        orderinfoVC.title=@"";
 //        orderinfoVC.delegate=self;
 //        orderinfoVC.delegate=self;
@@ -2171,7 +2171,7 @@
 //        //    {
 //        //    {
 //        //    orderinfoVC.have_tail = true
 //        //    orderinfoVC.have_tail = true
 //        //    }
 //        //    }
-//        
+//
 //        [self.navigationController pushViewController:orderinfoVC animated:true];
 //        [self.navigationController pushViewController:orderinfoVC animated:true];
 //    }
 //    }
     
     
@@ -2358,25 +2358,8 @@
             int item_qty=1;
             int item_qty=1;
 //            NSDictionary * bundle_item =[item_json objectForKey:@"combine"];
 //            NSDictionary * bundle_item =[item_json objectForKey:@"combine"];
             
             
-            double msurcharge =0;
-            // remove net price
-//            if(RASingleton.sharedInstance.price_type==1)
-//            {
-//                if([item_json[@"special_price"] boolValue])
-//                {
-//                    msurcharge=([item_json[price_group[@"price_3"][@"name"]] doubleValue]-[item_json[price_group[@"price_2"][@"name"]] doubleValue])*count*(1-discount/100.0);
-//                    if(msurcharge<0)
-//                        msurcharge = 0;
-//                }
-//                else
-//                {
-//                    msurcharge=([item_json[price_group[@"price_3"][@"name"]] doubleValue]-[item_json[price_group[@"price_1"][@"name"]] doubleValue])*count*(1-discount/100.0);
-//                    if(msurcharge<0)
-//                        msurcharge = 0;
-//
-//
-//                }
-//            }
+            // surcharge = unit_surcharge * qty
+            double msurcharge = [[item_json valueForKey:@"unit_surcharge"] doubleValue] * count;
 
 
             
             
 //            double dprice=0;
 //            double dprice=0;
@@ -2446,6 +2429,7 @@
     self.labelTotalSurcharge.text = surcharge;
     self.labelTotalSurcharge.text = surcharge;
     self.labelTotalPrice.text = totalprice;
     self.labelTotalPrice.text = totalprice;
     self.labelTotal.text=subtotal;
     self.labelTotal.text=subtotal;
+    self.labelScanSubtotal.text = subtotal;
     self.label_cuft.text=subcuft;
     self.label_cuft.text=subcuft;
     self.label_carton.text=subcarton;
     self.label_carton.text=subcarton;
     self.label_weight.text=subweight;
     self.label_weight.text=subweight;
@@ -4003,7 +3987,7 @@
 //        vc.onSetValue = ^(){
 //        vc.onSetValue = ^(){
 //            [self reload_data];//[main_vc checklogin:true];
 //            [self reload_data];//[main_vc checklogin:true];
 //        };
 //        };
-//        
+//
         
         
         UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
         UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
         
         

Разница между файлами не показана из-за своего большого размера
+ 88 - 688
RedAnt ERP Mobile/HMLG Scan Order/SO.storyboard


+ 49 - 81
RedAnt ERP Mobile/HMLG Scan Order/ScanHistoryViewController.m

@@ -12,128 +12,96 @@
 #import "RADataProvider.h"
 #import "RADataProvider.h"
 
 
 @interface ScanHistoryViewController ()
 @interface ScanHistoryViewController ()
-
 @end
 @end
 
 
 @implementation ScanHistoryViewController
 @implementation ScanHistoryViewController
 
 
 - (void)viewDidLoad {
 - (void)viewDidLoad {
     [super viewDidLoad];
     [super viewDidLoad];
-    // Do any additional setup after loading the view.
-    
-//    [self refreshStock];
+    // 购物车更新后刷新高亮
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(onCartUpdatedRefreshHighlight)
+                                                 name:@"ScanListShouldRefreshHighlight"
+                                               object:nil];
+}
+
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 }
+
 - (IBAction)onUpdateStock:(id)sender {
 - (IBAction)onUpdateStock:(id)sender {
     [RADataProvider updateStock:self];
     [RADataProvider updateStock:self];
 }
 }
 
 
-
-- (void)viewWillAppear:(BOOL)animated
-{
+- (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     [super viewWillAppear:animated];
     self.labelStock.text = [RADataProvider queryStockUpdateTime];
     self.labelStock.text = [RADataProvider queryStockUpdateTime];
 }
 }
 
 
-
--(void) refreshStock
-{
-    
-    
-//    NSDictionary *addressDic1 = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanStock"];
-//    if (addressDic1) {
-//        NSString* updatetime=addressDic1[@"updatetime"];
-//        self.labelStock.text = updatetime;
-//    }
-//
+- (void)refreshStock {
     self.labelStock.text = [RADataProvider queryStockUpdateTime];
     self.labelStock.text = [RADataProvider queryStockUpdateTime];
     [self.tableview reloadData];
     [self.tableview reloadData];
 }
 }
-/*
-#pragma mark - Navigation
 
 
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
+#pragma mark - UITableViewDataSource
 
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    
     return RASingleton.sharedInstance.scan_list.count;
     return RASingleton.sharedInstance.scan_list.count;
-    
-    
-
 }
 }
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
-    //        return 166.0f;
-            UILabel * label = [UILabel new];
-            
-            
-            NSMutableArray* arr = RASingleton.sharedInstance.scan_list;
-
-    
-    NSMutableDictionary* model = arr[indexPath.row];
-    label.frame = CGRectMake(0, 0, tableView.frame.size.width-32, 0);
-    label.text = model[@"description"];
-    label.font = [UIFont systemFontOfSize:15];
-    label.numberOfLines=0;
 
 
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    NSMutableArray *arr   = RASingleton.sharedInstance.scan_list;
+    NSMutableDictionary *model = arr[indexPath.row];
+
+    // 计算 description 多行文字高度
+    UILabel *label      = [UILabel new];
+    label.frame         = CGRectMake(0, 0, tableView.frame.size.width - 32, 0);
+    label.text          = model[@"description"];
+    label.font          = [UIFont systemFontOfSize:15];
+    label.numberOfLines = 0;
     label.lineBreakMode = NSLineBreakByWordWrapping;
     label.lineBreakMode = NSLineBreakByWordWrapping;
-//    double s = label.font.pointSize;
-    
-    
-//        NSLog(label.text);
-//        CGSize s=[label sizeThatFits:CGSizeMake(tableView.frame.size.width-32, 0)];
     [label sizeToFit];
     [label sizeToFit];
-    
-    return label.frame.size.height+112;
+
+    // 布局高度拆解:
+    //   顶部区域(model/button 行):top(13) + button高度(41) + desc top间距(4) = 58
+    //   description:动态高度
+    //   scrollView上间距:8
+    //   scrollView高度:48(header行24 + data行24)
+    //   scrollView下间距:8
+    //   bottomLine:2
+    //   合计固定部分:58 + 8 + 48 + 8 + 2 = 124,再加底部留白约 4 = 128
+    //   注:此处用 label.frame.size.height 取 description 实际高度
+    return label.frame.size.height + 128;
 }
 }
 
 
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
-{
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     ScanListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ScanListCell"];
     ScanListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ScanListCell"];
     if (!cell) {
     if (!cell) {
-        cell = [[ScanListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ScanListCell"];
+        cell = [[ScanListCell alloc] initWithStyle:UITableViewCellStyleDefault
+                                   reuseIdentifier:@"ScanListCell"];
     }
     }
 
 
-    NSMutableArray* arr = RASingleton.sharedInstance.scan_list;
-    
+    NSMutableArray *arr = RASingleton.sharedInstance.scan_list;
     [cell setModelJson:arr[indexPath.row]];
     [cell setModelJson:arr[indexPath.row]];
-   
+
+    // labelModel 和 labelStock 均保留为 outlet,赋值逻辑不变
     cell.labelStock.text = [RADataProvider queryStock:cell.labelModel.text];
     cell.labelStock.text = [RADataProvider queryStock:cell.labelModel.text];
+
     return cell;
     return cell;
 }
 }
 
 
-//#pragma mark - TableView Delegate
-
+#pragma mark - RA_NOTIFICATION
 
 
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
+- (void)onCartUpdatedRefreshHighlight {
+    [self.tableview reloadData];
 }
 }
-*/
-
-
-//- (IBAction)onAddToCart:(id)sender {
-//    
-//    [self dismissViewControllerAnimated:true completion:^{
-//            if(self.returnValue)
-//                self.returnValue(self.modellist);
-//        }];
-//    
-//    
-//}
-#pragma mark - RA_NOTIFICAITON
--(void) refresh_ui
-{
+
+- (void)refresh_ui {
     [self.tableview reloadData];
     [self.tableview reloadData];
 }
 }
--(void) reload_data {
+
+- (void)reload_data {
     [self.tableview reloadData];
     [self.tableview reloadData];
 }
 }
+
 @end
 @end

+ 11 - 21
RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.h

@@ -12,32 +12,22 @@
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
 @interface ScanListCell : UITableViewCell
 @interface ScanListCell : UITableViewCell
-@property (weak, nonatomic) IBOutlet UILabel *labelModel;
-@property (weak, nonatomic) IBOutlet UILabel *labelDescription;
-@property (weak, nonatomic) IBOutlet UILabel *labelDimension;
-@property (weak, nonatomic) IBOutlet UILabel *labelCuft;
-@property (weak, nonatomic) IBOutlet UILabel *labelOrigin;
-@property (weak, nonatomic) IBOutlet UILabel *labelPort;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceCTNR;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceNCA;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice25p;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceSpecial;
-@property (weak, nonatomic) IBOutlet UILabel *labelAvailable;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceDisplay1;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceDisplay2;
 
 
-@property (weak, nonatomic) IBOutlet UILabel *labelStock;
-
-
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice0;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice1;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice2;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice3;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice4;
+// --- 顶部信息区 ---
+@property (weak, nonatomic) IBOutlet UILabel      *labelModel;
+@property (weak, nonatomic) IBOutlet UILabel      *labelDescription;
+@property (weak, nonatomic) IBOutlet UILabel      *labelDimension;
+@property (weak, nonatomic) IBOutlet UILabel      *labelStock;   // "Stock:" 静态文字
 
 
+// --- 数量输入框 (Stock 与 Add to cart 之间) ---
+@property (weak, nonatomic) IBOutlet UITextField  *qtyField;
 
 
+// --- 动态价格表 ScrollView ---
+@property (weak, nonatomic) IBOutlet UIScrollView *priceScrollView;
 
 
+// --- 数据模型 ---
 @property (strong, nonatomic) NSMutableDictionary *modelJson;
 @property (strong, nonatomic) NSMutableDictionary *modelJson;
+
 @end
 @end
 
 
 NS_ASSUME_NONNULL_END
 NS_ASSUME_NONNULL_END

+ 357 - 367
RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.m

@@ -13,409 +13,399 @@
 #import "RAConvertor.h"
 #import "RAConvertor.h"
 #import "RAUtils.h"
 #import "RAUtils.h"
 #import "AppDelegate.h"
 #import "AppDelegate.h"
-
 #import "RADataProvider.h"
 #import "RADataProvider.h"
 
 
+// 表格行高(header 行 + data 行各一行)
+static const CGFloat kTableRowHeight   = 24.0;
+// 单元格左右内边距
+static const CGFloat kCellHPadding     = 20;
+// 列最小宽度
+static const CGFloat kMinColumnWidth   = 125;
+
 @implementation ScanListCell
 @implementation ScanListCell
 
 
 - (void)awakeFromNib {
 - (void)awakeFromNib {
     [super awakeFromNib];
     [super awakeFromNib];
-    // Initialization code
+
+    // priceScrollView
+    self.priceScrollView.showsVerticalScrollIndicator   = NO;
+    self.priceScrollView.showsHorizontalScrollIndicator = YES;
+    self.priceScrollView.alwaysBounceVertical           = NO;
+    self.priceScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
+
+    // 关闭默认选中高亮,避免与购物车高亮冲突
+    self.selectionStyle = UITableViewCellSelectionStyleNone;
+
+    // qtyField 样式
+    self.qtyField.text                     = @"1";
+    // iPad 上 NumberPad 会浮动,改用 numbersAndPunctuation 让键盘固定在底部
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+        self.qtyField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
+        // cell 内部过滤非数字,不依赖外部 delegate
+        [self.qtyField addTarget:self
+                          action:@selector(qtyFieldDidChange:)
+                forControlEvents:UIControlEventEditingChanged];
+    } else {
+        self.qtyField.keyboardType = UIKeyboardTypeNumberPad;
+    }
+    self.qtyField.textAlignment            = NSTextAlignmentCenter;
+    self.qtyField.borderStyle              = UITextBorderStyleRoundedRect;
+    self.qtyField.font                     = [UIFont systemFontOfSize:15.0];
+    self.qtyField.layer.cornerRadius       = 4.0;
+    self.qtyField.layer.borderWidth        = 1.0;
+    self.qtyField.layer.borderColor        = [UIColor systemGrayColor].CGColor;
+    self.qtyField.layer.masksToBounds      = YES;
 }
 }
 
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:selected animated:animated];
     [super setSelected:selected animated:animated];
-
-    // Configure the view for the selected state
 }
 }
+
+// MARK: - Add to Cart
+
 - (IBAction)onAddToCart:(id)sender {
 - (IBAction)onAddToCart:(id)sender {
-     //            DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
-    
-    
-    
- 
-        
-        if(RASingleton.sharedInstance.scan_cart ==nil)
-        {
-//            NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:URL_SO_CART ofType:@"json" ]];
-            NSMutableDictionary* cartTemplate=[OLDataProvider loadScanTemplate:@"scan_cart.json"];
-            RASingleton.sharedInstance.scan_cart=cartTemplate;//[[RAConvertor data2dict:json] mutableCopy];
-        }
-        // 初始化为 FOB CTNR;
-    if(RASingleton.sharedInstance.scan_cart[@"price_type"] ==nil)
-    {
+    // ── 读取用户输入数量,默认 1,不允许 <= 0 ──────────────────────────────
+    int userQty = [self.qtyField.text intValue];
+    if (userQty <= 0) userQty = 1;
+
+    if (RASingleton.sharedInstance.scan_cart == nil) {
+        NSMutableDictionary *cartTemplate = [OLDataProvider loadScanTemplate:@"scan_cart.json"];
+        RASingleton.sharedInstance.scan_cart = cartTemplate;
+    }
+
+    if (RASingleton.sharedInstance.scan_cart[@"price_type"] == nil) {
         RASingleton.sharedInstance.scan_cart[@"price_type"] = @1;
         RASingleton.sharedInstance.scan_cart[@"price_type"] = @1;
-    RASingleton.sharedInstance.price_type = 1;
+        RASingleton.sharedInstance.price_type = 1;
     }
     }
 
 
-        NSMutableDictionary* section =[RASingleton.sharedInstance.scan_cart[@"section_0"] mutableCopy];
-        int count =[section[@"count"] intValue];
-        
-        
-        
-        NSMutableDictionary* jitem = nil;
-         jitem = [self.modelJson mutableCopy];
-    int stockUom =[jitem[@"stockUom"] intValue];
-    if(stockUom==0)
-        stockUom=1;
-        bool newitem = true;
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    NSDictionary* price_group = [RADataProvider get_price_group:appDelegate.price_group];
-        for(int i=0;i<count;i++)
-        {
-            
-            NSMutableDictionary* litem = [section[[NSString stringWithFormat:@"item_%i",i]] mutableCopy];
-            
-            if([litem[@"product_id"] isEqualToString:jitem[@"product_id"]])
-            {
-                
-//                    int oldcount = [litem[@"stockUom"] intValue];
-                newitem = false;
-            
-                litem[@"count"]=@([litem[@"count"] intValue] +[jitem[@"count"] intValue]);
-                litem[@"cuft"]=@([litem[@"count"] intValue] * [litem[@"unit_cuft"] doubleValue]);
-                
-                // 计算subtotal
-                double discount = [litem[@"discount"] doubleValue];
-                int qty = [litem[@"count"] intValue];
-                double unit_price = [litem[@"unit_price"] doubleValue];
-                litem[@"subtotal_price"]= [NSString stringWithFormat:@"%f",unit_price*qty*(1-discount/100.0)];
-                
-                section[[NSString stringWithFormat:@"item_%i",i]] = litem;
-                break;
-                
-                
-            }
-            
+    NSMutableDictionary *section = [RASingleton.sharedInstance.scan_cart[@"section_0"] mutableCopy];
+    int count = [section[@"count"] intValue];
 
 
+    NSMutableDictionary *jitem = [self.modelJson mutableCopy];
 
 
-        }
-        if(newitem)
-        {
-            jitem[@"count"]=@(stockUom);
-            jitem[@"check"]=@(true);
-            jitem[@"cart_item_id"]=[NSUUID UUID].UUIDString;
-            
-            NSString * unit_price;
-            if(RASingleton.sharedInstance.price_type==0)
-                unit_price=_modelJson[price_group[@"price_0"][@"name"]];
-            else if(_modelJson [@"special_price"])
-            {
-                unit_price= _modelJson[price_group[@"price_2"][@"name"]];
-            }
-            else if(_modelJson [@"net_price"])
-                unit_price=_modelJson[price_group[@"price_3"][@"name"]];
-            else
-            {
-                unit_price= _modelJson[price_group[@"price_1"][@"name"]];
-            }
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    NSDictionary *price_group = [RADataProvider get_price_group:appDelegate.price_group];
 
 
-            if([unit_price isEqualToString:@"N/A"])
-                unit_price = @"0";
-            else
-            {
-                
-                unit_price = [NSString stringWithFormat:@"%.2f", [unit_price doubleValue]];
-            }
-            
-//            [jitem[@"subtotal_price"]= [NSString stringWithFormat:@"%f",unit_price*qty*(1-discount/100.0)];
-            jitem[@"unit_price"] = unit_price;
-            jitem[@"erp_unit_price"] = unit_price;
-            
-            
-            // 计算subtotal
-            double discount = [jitem[@"discount"] doubleValue];
-            int qty = [jitem[@"count"] intValue];
-            double dunit_price = [jitem[@"unit_price"] doubleValue];
-            jitem[@"subtotal_price"]= [NSString stringWithFormat:@"%f",dunit_price*qty*(1-discount/100.0)];
-            
-            
-            section[[NSString stringWithFormat:@"item_%i",count]] = jitem;
-            section[@"count"]= @(count+1);
-            count++;
-            
+    BOOL newitem = YES;
+    for (int i = 0; i < count; i++) {
+        NSMutableDictionary *litem = [section[[NSString stringWithFormat:@"item_%i", i]] mutableCopy];
+        if ([litem[@"product_id"] isEqualToString:jitem[@"product_id"]]) {
+            newitem = NO;
+            // 用 userQty 累加
+            litem[@"count"]      = @([litem[@"count"] intValue] + userQty);
+            litem[@"cuft"]       = @([litem[@"count"] intValue] * [litem[@"unit_cuft"] doubleValue]);
+            double discount      = [litem[@"discount"] doubleValue];
+            int qty              = [litem[@"count"] intValue];
+            double unit_price    = [litem[@"unit_price"] doubleValue];
+            litem[@"subtotal_price"] = [NSString stringWithFormat:@"%f", unit_price * qty * (1 - discount / 100.0)];
+            section[[NSString stringWithFormat:@"item_%i", i]] = litem;
+            break;
         }
         }
-        
-        
-        RASingleton.sharedInstance.scan_cart[@"section_0"] = section;
-        
-        //加list
-        
-        
-        
-        
-        
-
-            [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-
-            
-        [OLDataProvider saveScanCart:RASingleton.sharedInstance.scan_cart];
-
-    
-    [RAUtils message_box:[NSString stringWithFormat: @"%@ added to cart",jitem[@"model"]] message:@"Successfully" completion:nil];
+    }
+
+    if (newitem) {
+        jitem[@"count"]        = @(userQty);   // 使用用户输入数量
+        jitem[@"check"]        = @(YES);
+        jitem[@"cart_item_id"] = [NSUUID UUID].UUIDString;
+
+        NSString *unit_price_key;
+        if (RASingleton.sharedInstance.price_type == 0)
+            unit_price_key = price_group[@"price_0"][@"name"];
+        else if (_modelJson[@"special_price"])
+            unit_price_key = price_group[@"price_2"][@"name"];
+        else if (_modelJson[@"net_price"])
+            unit_price_key = price_group[@"price_3"][@"name"];
+        else
+            unit_price_key = price_group[@"price_1"][@"name"];
+
+        NSString *unit_price = _modelJson[unit_price_key];
+        if ([unit_price isEqualToString:@"N/A"])
+            unit_price = @"0";
+        else
+            unit_price = [NSString stringWithFormat:@"%.2f", [unit_price doubleValue]];
+
+        jitem[@"unit_price"]     = unit_price;
+        jitem[@"erp_unit_price"] = unit_price;
+
+        // surcharge:key = 当前价格列名 + "_surcharge"
+        NSString *surcharge_key  = [unit_price_key stringByAppendingString:@"_surcharge"];
+        NSString *unit_surcharge = _modelJson[surcharge_key];
+//        if (unit_surcharge && unit_surcharge.length > 0 && ![unit_surcharge isEqualToString:@"N/A"])
+        if (unit_surcharge )
+            jitem[@"unit_surcharge"] = [NSString stringWithFormat:@"%.2f", [unit_surcharge doubleValue]];
+        else
+            jitem[@"unit_surcharge"] = @"0";
+
+        double discount    = [jitem[@"discount"] doubleValue];
+        double dunit_price = [jitem[@"unit_price"] doubleValue];
+        jitem[@"subtotal_price"] = [NSString stringWithFormat:@"%f", dunit_price * userQty * (1 - discount / 100.0)];
+
+        section[[NSString stringWithFormat:@"item_%i", count]] = jitem;
+        section[@"count"] = @(count + 1);
+    }
+
+    RASingleton.sharedInstance.scan_cart[@"section_0"] = section;
+    [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+    [OLDataProvider saveScanCart:RASingleton.sharedInstance.scan_cart];
+
+    // ── 重置数量输入框 ────────────────────────────────────────────────────────
+    self.qtyField.text = @"1";
+
+    // ── 刷新当前列表高亮(Search 和 History VC 都会收到)────────────────────
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"ScanListShouldRefreshHighlight"
+                                                        object:nil];
+
+    [RAUtils message_box:[NSString stringWithFormat:@"%@ added to cart", jitem[@"model"]]
+                 message:@"Successfully"
+              completion:nil];
 }
 }
 
 
-- (void)setModelJson:(NSMutableDictionary *)modelJson
-{
+// MARK: - setModelJson
+
+- (void)setModelJson:(NSMutableDictionary *)modelJson {
     _modelJson = modelJson;
     _modelJson = modelJson;
-    
-    
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-//    self.labelPrice0.text = appDelegate.price0_name;
-//    self.labelPrice1.text = appDelegate.price1_name;
-//    self.labelPrice2.text = appDelegate.price2_name;
-//    self.labelPrice3.text = appDelegate.price3_name;
-    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;
-    self.labelPrice4.text = price_group[@"price_4"][@"display"];//appDelegate.price4_name;
-    
-    //    remove net price
-//    if(price_group[@"price_4"])
-//    {
-//        self.labelPrice3.text = price_group[@"price_4"][@"display"];
-//    }
-//
-  
+
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    NSDictionary *price_group = [RADataProvider get_price_group:appDelegate.price_group];
+
 #ifdef DEBUG
 #ifdef DEBUG
-    
-    NSLog(@"%@",[RAConvertor dict2string:modelJson]);
-    
+    NSLog(@"%@", [RAConvertor dict2string:modelJson]);
 #endif
 #endif
-//    NSString* s=[RAConvertor dict2string:modelJson];
-//    @try {
-//
-////        NSLog( s);
-//
-//        NSLog([RAConvertor dict2string:modelJson]);
-//
-//    }
-//    @catch (NSException * e) {
-//       NSLog(@"Exception: %@", e);
-//        [RAUtils message_box:@"exception" message:[NSString stringWithFormat:@"%@ %@",e,modelJson] completion:nil];
-//    }
-
-    
-    
-    NSString * port=_modelJson[@"port"];
-    if(port.length==0)
-        port = @"N/A";
-    
-    NSString * origin=_modelJson[@"origin"];
-    if(origin.length==0)
-        origin = @"N/A";
-    NSString * dimension=_modelJson[@"dimension"];
-    if(dimension.length==0)
-        dimension = @"N/A";
-    
-    _labelModel.text=_modelJson[@"model"];
-    _labelDescription.text=_modelJson[@"description"];
-    _labelDimension.text=dimension;
-    _labelCuft.text=_modelJson[@"unit_cuft"];
-    _labelOrigin.text=origin;
-    _labelPort.text=port;
-    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"]]; //NET
- 
-    
-    
-    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 isEqualToString:price3])||(![price2 isEqualToString: @"N/A"] && [price2 isEqualToString:price3]))
-    {
-//        if(RASingleton.sharedInstance.price_type==1)
-//            _modelJson [@"net_price"] = @true;
-        // remove net price
-        _modelJson [@"net_price"] = @false;
-    }
-    
-    
-//
-//    if(![price1 isEqualToString:@"N/A"])
-//    {
-//        price2 =  [NSString stringWithFormat:@"%.2f",[_modelJson[@"price1"] doubleValue] *1.25];
-//        _modelJson[@"price2"]= price2;
-//    }
-//    else
-//    {
-//        price2=@"N/A";
-//    }
-//
-    
- 
-    if([price0 isEqualToString:@"N/A"])
-        _labelPriceCTNR.text= @"";//price0;
-    else
-        _labelPriceCTNR.text=[RAConvertor currencyNumber:[price0 floatValue]];
-    
-//
-//    if([price3 isEqualToString:@"N/A"])
-//        _labelPriceNCA.text= price3;
-//    else
-//        _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
-//    _labelPrice25p.text=price2;
-    
-    
-    
-    
-    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";
+
+    NSString *port = _modelJson[@"port"];
+    if (port.length == 0) port = @"N/A";
+    NSString *origin = _modelJson[@"origin"];
+    if (origin.length == 0) origin = @"N/A";
+    NSString *dimension = _modelJson[@"dimension"];
+    if (dimension.length == 0) dimension = @"N/A";
+    NSString *available = _modelJson[@"available"];
+    if (available.length == 0) available = @"N/A";
+    NSString *unit_cuft = _modelJson[@"unit_cuft"];
+    if (unit_cuft.length == 0) {
+        unit_cuft = @"N/A";
+    } else {
+        unit_cuft = [NSString stringWithFormat:@"%.4f", [_modelJson[@"unit_cuft"] doubleValue]];
     }
     }
-    
-    // remove net price
-//    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([_modelJson[price_group[@"price_3"][@"name"]] isEqualToString:@"N/A"]||_modelJson[price_group[@"price_3"][@"name"]]==nil)
-    {
-        _labelPriceDisplay1.text=@"";//_modelJson[@"price3"];
-//            _labelPriceNCA.text=@"N/A";
+
+    _labelModel.text       = _modelJson[@"model"];
+    _labelDescription.text = _modelJson[@"description"];
+    _labelDimension.text   = dimension;
+
+    // ── 重置数量输入框(cell 复用时还原为 1)────────────────────────────────
+    self.qtyField.text = @"1";
+
+    // ── 价格 flag 处理 ─────────────────────────────────────────────────────
+    NSString *price1 = _modelJson[price_group[@"price_1"][@"name"]];
+    NSString *price2 = _modelJson[price_group[@"price_2"][@"name"]];
+    NSString *price3 = _modelJson[price_group[@"price_3"][@"name"]];
+
+    if (![price1 isEqualToString:@"N/A"] && price1)
+        price1 = [NSString stringWithFormat:@"%.2f", [price1 doubleValue]];
+    if (![price2 isEqualToString:@"N/A"] && price2)
+        price2 = [NSString stringWithFormat:@"%.2f", [price2 doubleValue]];
+    if (![price3 isEqualToString:@"N/A"] && price3)
+        price3 = [NSString stringWithFormat:@"%.2f", [price3 doubleValue]];
+
+    if (price2 && ![price2 isEqualToString:@"N/A"])
+        _modelJson[@"special_price"] = @YES;
+
+    if ((price1 && ![price1 isEqualToString:@"N/A"] && [price1 isEqualToString:price3]) ||
+        (price2 && ![price2 isEqualToString:@"N/A"] && [price2 isEqualToString:price3]))
+        _modelJson[@"net_price"] = @NO;
+
+    // ── 构建动态表格列 ──────────────────────────────────────────────────────
+    NSMutableArray<NSDictionary *> *columns = [NSMutableArray array];
+    [columns addObject:@{ @"header": @"CuFT",      @"value": unit_cuft }];
+    [columns addObject:@{ @"header": @"Origin",    @"value": origin    }];
+    [columns addObject:@{ @"header": @"Port",      @"value": port      }];
+    [columns addObject:@{ @"header": @"Available", @"value": available }];
+
+    // 根据 price_count 遍历当前价格组的所有价格列
+    int priceCount = [price_group[@"price_count"] intValue];
+    for (int i = 0; i < priceCount; i++) {
+        NSString *key = [NSString stringWithFormat:@"price_%d", i];
+        NSDictionary *pg = price_group[key];
+        if (!pg || !pg[@"display"]) continue;
+        NSString *displayName  = pg[@"display"];
+        NSString *rawValue     = _modelJson[pg[@"name"]];
+        NSString *displayValue = @"";
+        if (rawValue && ![rawValue isEqualToString:@"N/A"]) {
+            double dval = [rawValue doubleValue];
+            if (dval > 0)
+                displayValue = [RAConvertor currencyNumber:(float)dval];
+        }
+        // price_2 固定为 Show Special,仅在 special_price 时显示数值
+        if (i == 2 && ![_modelJson[@"special_price"] boolValue])
+            displayValue = @"";
+        [columns addObject:@{ @"header": displayName, @"value": displayValue }];
     }
     }
+
+    [self buildPriceTableWithColumns:columns];
+
+    // ── 购物车高亮 ─────────────────────────────────────────────────────────────
+    [self updateCartHighlight];
+
+    // ── 更新 modelJson 供购物车使用 ────────────────────────────────────────
+    NSString *cell_price;
+    if (RASingleton.sharedInstance.price_type == 1)
+        cell_price = _modelJson[price_group[@"price_3"][@"name"]];
     else
     else
-    {
-        _labelPriceDisplay1.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_3"][@"name"]] floatValue]];
-//            _labelPriceNCA.text=@"N/A";
+        cell_price = _modelJson[price_group[@"price_0"][@"name"]];
+
+    NSString *mpack = _modelJson[@"stockUom"];
+    if ([mpack isEqualToString:@"N/A"]) mpack = @"1";
+    _modelJson[@"count"]          = _modelJson[@"stockUom"];
+    _modelJson[@"cuft"]           = @([mpack intValue] * [unit_cuft doubleValue]);
+    _modelJson[@"subtotal_price"] = @([mpack intValue] * [cell_price doubleValue]);
+}
+
+// MARK: - 购物车高亮
+
+/**
+ 检查当前 modelJson 对应的商品是否已在购物车中。
+ 在购物车中:浅绿背景;不在:恢复默认背景。
+ 在 setModelJson: 末尾调用,也可在外部主动调用(如加入购物车后刷新列表时)。
+ */
+- (void)updateCartHighlight {
+    NSString *productId = _modelJson[@"product_id"];
+    BOOL inCart = NO;
+
+    NSDictionary *section = RASingleton.sharedInstance.scan_cart[@"section_0"];
+    if (section && productId.length > 0) {
+        int count = [section[@"count"] intValue];
+        for (int i = 0; i < count; i++) {
+            NSDictionary *item = section[[NSString stringWithFormat:@"item_%i", i]];
+            if ([item[@"product_id"] isEqualToString:productId]) {
+                inCart = YES;
+                break;
+            }
+        }
     }
     }
-    
-    if([_modelJson[price_group[@"price_4"][@"name"]] isEqualToString:@"N/A"]||_modelJson[price_group[@"price_4"][@"name"]]==nil )
-    {
-        _labelPriceDisplay2.text=@"";//_modelJson[@"price3"];
-//            _labelPriceNCA.text=@"N/A";
+
+    UIColor *highlightColor = inCart
+        ? [[UIColor systemGreenColor] colorWithAlphaComponent:0.12]
+        : [UIColor systemBackgroundColor];
+
+    self.contentView.backgroundColor = highlightColor;
+    self.backgroundColor             = highlightColor;
+}
+
+// MARK: - 动态表格构建
+
+- (void)buildPriceTableWithColumns:(NSArray<NSDictionary *> *)columns {
+    for (UIView *v in self.priceScrollView.subviews)
+        [v removeFromSuperview];
+
+    if (columns.count == 0) {
+        self.priceScrollView.contentSize = CGSizeZero;
+        return;
     }
     }
-    else
-    {
-        _labelPriceDisplay2.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_4"][@"name"]] floatValue]];
-//            _labelPriceNCA.text=@"N/A";
+
+    UIFont  *font        = [UIFont systemFontOfSize:15.0];
+    UIColor *borderColor = UIColor.labelColor;
+    CGFloat  totalWidth  = 0;
+
+    NSMutableArray<NSNumber *> *colWidths = [NSMutableArray arrayWithCapacity:columns.count];
+    for (NSDictionary *col in columns) {
+        NSString *header = col[@"header"] ?: @"";
+        NSString *value  = col[@"value"]  ?: @"";
+        NSDictionary *attrs = @{ NSFontAttributeName: font };
+        CGFloat hw = [header sizeWithAttributes:attrs].width + kCellHPadding * 2;
+        CGFloat vw = [value  sizeWithAttributes:attrs].width + kCellHPadding * 2;
+        CGFloat w  = MAX(MAX(hw, vw), kMinColumnWidth);
+        [colWidths addObject:@(w)];
     }
     }
-    
-    //    remove net price
-//    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[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";
-        }
+
+    BOOL isLast = NO;
+    CGFloat x = 0;
+    for (NSUInteger i = 0; i < columns.count; i++) {
+        CGFloat w         = [colWidths[i] floatValue];
+        NSDictionary *col = columns[i];
+        isLast = (i == columns.count - 1);
+
+        // header 行:画上、左(不画下,避免与 data 行上边框叠加)
+        UILabel *hLabel = [self makeCellLabel:col[@"header"]
+                                         font:font
+                                  borderColor:borderColor
+                                        frame:CGRectMake(x, 0, w, kTableRowHeight)
+                                      drawTop:YES drawBottom:NO isLast:isLast];
+        hLabel.backgroundColor = [UIColor secondarySystemBackgroundColor];
+        [self.priceScrollView addSubview:hLabel];
+
+        // data 行:画下、左(不画上,避免与 header 行下边框叠加)
+        UILabel *vLabel = [self makeCellLabel:col[@"value"]
+                                         font:font
+                                  borderColor:borderColor
+                                        frame:CGRectMake(x, kTableRowHeight, w, kTableRowHeight)
+                                      drawTop:NO drawBottom:YES isLast:isLast];
+        [self.priceScrollView addSubview:vLabel];
+
+        x += w;
+        totalWidth = x;
     }
     }
-    
-    
-    NSString * available=_modelJson[@"available"];
-    if(available.length==0)
-        available = @"N/A";
-    
-    _labelAvailable.text=available;
-    NSString * unit_cuft=_modelJson[@"unit_cuft"];
-    if(unit_cuft.length==0)
-        unit_cuft = @"N/A";
-    else
-    {
-        
-        unit_cuft = [NSString stringWithFormat:@"%.2f", [_modelJson[@"unit_cuft"] doubleValue]];
+
+    self.priceScrollView.contentSize = CGSizeMake(totalWidth, kTableRowHeight * 2);
+}
+
+// MARK: - qtyField 数字过滤(iPad 全键盘模式)
+
+- (void)qtyFieldDidChange:(UITextField *)textField {
+    NSString *filtered = [[textField.text componentsSeparatedByCharactersInSet:
+                           [[NSCharacterSet decimalDigitCharacterSet] invertedSet]]
+                          componentsJoinedByString:@""];
+    if (![textField.text isEqualToString:filtered])
+        textField.text = filtered;
+}
+
+// MARK: - 辅助
+
+/**
+ 用 CAShapeLayer 画边框,避免相邻列边框叠加变粗:
+ 每列只画上、下、左三边;最后一列额外画右边。
+ */
+- (UILabel *)makeCellLabel:(NSString *)text
+                      font:(UIFont *)font
+               borderColor:(UIColor *)borderColor
+                     frame:(CGRect)frame
+                   drawTop:(BOOL)drawTop
+                drawBottom:(BOOL)drawBottom
+                    isLast:(BOOL)isLast {
+    UILabel *label      = [[UILabel alloc] initWithFrame:frame];
+    label.text          = text ?: @"";
+    label.font          = font;
+    label.textAlignment = NSTextAlignmentCenter;
+    label.clipsToBounds = YES;
+
+    CGFloat w  = frame.size.width;
+    CGFloat h  = frame.size.height;
+
+    CAShapeLayer *border = [CAShapeLayer layer];
+    UIBezierPath *path   = [UIBezierPath bezierPath];
+
+    if (drawTop) {
+        [path moveToPoint:CGPointMake(0, 0)];
+        [path addLineToPoint:CGPointMake(w, 0)];
     }
     }
-    
-    NSString * cell_price;
-
-    if(RASingleton.sharedInstance.price_type==1)
-    {
-//        if(_modelJson [@"net_price"])
-            cell_price=_modelJson[price_group[@"price_3"][@"name"]];
-//        else if(_modelJson [@"special_price"])
-//        {
-//            unit_price= _modelJson[@"price2"];
-//        }
-//        else
-//        {
-//            unit_price= _modelJson[@"price1"];
-//        }
+    if (drawBottom) {
+        [path moveToPoint:CGPointMake(0, h)];
+        [path addLineToPoint:CGPointMake(w, h)];
     }
     }
-    else
-    {
-        cell_price=_modelJson[price_group[@"price_0"][@"name"]];
+    // 左边(每列都画)
+    [path moveToPoint:CGPointMake(0, 0)];
+    [path addLineToPoint:CGPointMake(0, h)];
+    // 最后一列补右边
+    if (isLast) {
+        [path moveToPoint:CGPointMake(w, 0)];
+        [path addLineToPoint:CGPointMake(w, h)];
     }
     }
-    
-    
-
-  
-    
-    
-    NSString * mpack=_modelJson[@"stockUom"];
-    if([mpack isEqualToString:@"N/A"])
-        mpack=@"1";
-    _modelJson[@"count"]=_modelJson[@"stockUom"];
-    _modelJson[@"cuft"] = @([mpack intValue]* [unit_cuft doubleValue]);
-    _modelJson[@"subtotal_price"] = @([mpack intValue]* [cell_price doubleValue]);
 
 
+    border.path        = path.CGPath;
+    border.strokeColor = borderColor.CGColor;
+    border.lineWidth   = 1.0;
+    border.fillColor   = [UIColor clearColor].CGColor;
+    [label.layer addSublayer:border];
 
 
+    return label;
 }
 }
 
 
 @end
 @end

+ 17 - 24
RedAnt ERP Mobile/HMLG Scan Order/ScanModelListCell.h

@@ -10,31 +10,24 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
-@interface ScanModelListCell : UITableViewCell//<UITextFieldDelegate>
-@property (weak, nonatomic) IBOutlet UILabel *labelModel;
-@property (weak, nonatomic) IBOutlet UILabel *labelDescription;
-@property (weak, nonatomic) IBOutlet UILabel *labelDimension;
-@property (weak, nonatomic) IBOutlet UILabel *labelCuft;
-@property (weak, nonatomic) IBOutlet UILabel *labelOrigin;
-@property (weak, nonatomic) IBOutlet UILabel *labelPort;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceCTNR;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceNCA;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice25p;
-@property (weak, nonatomic) IBOutlet UILabel *labelAvailable;
-@property (weak, nonatomic) IBOutlet UITextField *editQTY;
+@interface ScanModelListCell : UITableViewCell
+
+// --- 顶部信息区 ---
+@property (weak, nonatomic) IBOutlet UILabel      *labelModel;
+@property (weak, nonatomic) IBOutlet UILabel      *labelDescription;
+@property (weak, nonatomic) IBOutlet UILabel      *labelDimension;
+@property (weak, nonatomic) IBOutlet UILabel      *labelStock;
+
+// --- 数量编辑区 ---
+@property (weak, nonatomic) IBOutlet UITextField  *editQTY;
+@property (weak, nonatomic) IBOutlet UIStepper    *steper;
+
+// --- 动态价格表 ScrollView ---
+@property (weak, nonatomic) IBOutlet UIScrollView *priceScrollView;
+
+// --- 数据模型 ---
 @property (strong, nonatomic) NSMutableDictionary *modelJson;
 @property (strong, nonatomic) NSMutableDictionary *modelJson;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceDisplay1;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceDisplay2;
-@property (weak, nonatomic) IBOutlet UILabel *labelPriceSpecial;
-@property (weak, nonatomic) IBOutlet UIStepper *steper;
-@property (weak, nonatomic) IBOutlet UILabel *labelStock;
-
-//@property int pre_val;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice0;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice1;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice2;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice3;
-@property (weak, nonatomic) IBOutlet UILabel *labelPrice4;
+
 @end
 @end
 
 
 NS_ASSUME_NONNULL_END
 NS_ASSUME_NONNULL_END

+ 177 - 251
RedAnt ERP Mobile/HMLG Scan Order/ScanModelListCell.m

@@ -7,288 +7,214 @@
 //
 //
 
 
 #import "ScanModelListCell.h"
 #import "ScanModelListCell.h"
-
 #import "RAConvertor.h"
 #import "RAConvertor.h"
 #import "RAUtils.h"
 #import "RAUtils.h"
 #import "RASingleton.h"
 #import "RASingleton.h"
 #import "AppDelegate.h"
 #import "AppDelegate.h"
 #import "RADataProvider.h"
 #import "RADataProvider.h"
 
 
+static const CGFloat kTableRowHeight = 24.0;
+static const CGFloat kCellHPadding   = 20.0;
+static const CGFloat kMinColumnWidth = 125;
 
 
-#define NUMBERS @"0123456789\n"
 @implementation ScanModelListCell
 @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 {
 - (void)awakeFromNib {
     [super awakeFromNib];
     [super awakeFromNib];
-//    self.editQTY.delegate = self;
-//    _editQTY.delegate = self;
-    // Initialization code
+    self.selectionStyle = UITableViewCellSelectionStyleNone;
+
+    self.priceScrollView.showsVerticalScrollIndicator   = NO;
+    self.priceScrollView.showsHorizontalScrollIndicator = YES;
+    self.priceScrollView.alwaysBounceVertical           = NO;
+    self.priceScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
 }
 }
 
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:selected animated: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;
-    self.labelPrice4.text = price_group[@"price_4"][@"display"];//appDelegate.price3_name;
-    
-    //    remove net price
-//    if(price_group[@"price_4"])
-//    {
-//        self.labelPrice3.text = price_group[@"price_4"][@"display"];
-//    }
-    
+// MARK: - setModelJson
+
+- (void)setModelJson:(NSMutableDictionary *)modelJson {
     _modelJson = modelJson;
     _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 isEqualToString:price3])||(![price2 isEqualToString: @"N/A"] && [price2 isEqualToString:price3]))
-    {
-//        if(RASingleton.sharedInstance.price_type==1)
- //           _modelJson [@"net_price"] = @true;
-        
-        // remove net price
-        _modelJson [@"net_price"] = @false;
-    }
-    
-    
-    
-    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]];
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    NSDictionary *price_group = [RADataProvider get_price_group:appDelegate.price_group];
+
+    // ── 基础字段 ────────────────────────────────────────────────────────────
+    NSString *port      = _modelJson[@"port"];      if (port.length == 0)      port      = @"N/A";
+    NSString *origin    = _modelJson[@"origin"];    if (origin.length == 0)    origin    = @"N/A";
+    NSString *available = _modelJson[@"available"]; if (available.length == 0) available = @"N/A";
+    NSString *unit_cuft = _modelJson[@"unit_cuft"];
+    if (unit_cuft.length == 0) {
+        unit_cuft = @"N/A";
+    } else {
+        unit_cuft = [NSString stringWithFormat:@"%.4f", [_modelJson[@"unit_cuft"] doubleValue]];
     }
     }
-    else
-    {
-        _labelPriceSpecial.text=@"";//@"N/A";
+
+    // ── 静态 label ──────────────────────────────────────────────────────────
+    _labelModel.text       = _modelJson[@"model"];
+    _labelDescription.text = _modelJson[@"description"];
+    _labelDimension.text   = _modelJson[@"dimension"];
+
+    // ── 数量 / stepper ──────────────────────────────────────────────────────
+    _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];
+
+    // ── 价格 flag 处理(与 ScanListCell 保持一致)───────────────────────────
+    NSString *price1 = _modelJson[price_group[@"price_1"][@"name"]];
+    NSString *price2 = _modelJson[price_group[@"price_2"][@"name"]];
+    NSString *price3 = _modelJson[price_group[@"price_3"][@"name"]];
+
+    if (price1 && ![price1 isEqualToString:@"N/A"])
+        price1 = [NSString stringWithFormat:@"%.2f", [price1 doubleValue]];
+    if (price2 && ![price2 isEqualToString:@"N/A"]) {
+        price2 = [NSString stringWithFormat:@"%.2f", [price2 doubleValue]];
+        _modelJson[@"special_price"] = @YES;
     }
     }
-    
-    // remove net price
-//    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([_modelJson[price_group[@"price_3"][@"name"]] isEqualToString:@"N/A"]||_modelJson[price_group[@"price_3"][@"name"]]==nil)
-    {
-        _labelPriceDisplay1.text=@"";//_modelJson[@"price3"];
-//            _labelPriceNCA.text=@"N/A";
+    if (price3 && ![price3 isEqualToString:@"N/A"])
+        price3 = [NSString stringWithFormat:@"%.2f", [price3 doubleValue]];
+
+    if ((price1 && ![price1 isEqualToString:@"N/A"] && [price1 isEqualToString:price3]) ||
+        (price2 && ![price2 isEqualToString:@"N/A"] && [price2 isEqualToString:price3]))
+        _modelJson[@"net_price"] = @NO;
+
+    // ── 构建动态表格列 ───────────────────────────────────────────────────────
+    NSMutableArray<NSDictionary *> *columns = [NSMutableArray array];
+    [columns addObject:@{ @"header": @"CuFT",      @"value": unit_cuft }];
+    [columns addObject:@{ @"header": @"Origin",    @"value": origin    }];
+    [columns addObject:@{ @"header": @"Port",      @"value": port      }];
+    [columns addObject:@{ @"header": @"Available", @"value": available }];
+
+    int priceCount = [price_group[@"price_count"] intValue];
+    for (int i = 0; i < priceCount; i++) {
+        NSString *key   = [NSString stringWithFormat:@"price_%d", i];
+        NSDictionary *pg = price_group[key];
+        if (!pg || !pg[@"display"]) continue;
+
+        NSString *rawValue     = _modelJson[pg[@"name"]];
+        NSString *displayValue = @"";
+        if (rawValue && ![rawValue isEqualToString:@"N/A"]) {
+            double dval = [rawValue doubleValue];
+            if (dval > 0)
+                displayValue = [RAConvertor currencyNumber:(float)dval];
+        }
+        // price_2 固定为 Show Special
+        if (i == 2 && ![_modelJson[@"special_price"] boolValue])
+            displayValue = @"";
+
+        [columns addObject:@{ @"header": pg[@"display"], @"value": displayValue }];
     }
     }
-    else
-    {
-        _labelPriceDisplay1.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_3"][@"name"]] floatValue]];
-//            _labelPriceNCA.text=@"N/A";
+
+    [self buildPriceTableWithColumns:columns];
+}
+
+// MARK: - Stepper
+
+- (void)init_Stepper:(int)step max:(int)max min:(int)min value:(int)value {
+    if (self.steper != nil) {
+        if (step <= 0) step = 1;
+        self.steper.minimumValue = min;
+        self.steper.stepValue    = step;
+        self.steper.value        = value;
     }
     }
-        
-    
-    if([_modelJson[price_group[@"price_4"][@"name"]] isEqualToString:@"N/A"]||_modelJson[price_group[@"price_4"][@"name"]]==nil)
-    {
-        _labelPriceDisplay2.text=@"";//_modelJson[@"price3"];
-//            _labelPriceNCA.text=@"N/A";
+}
+
+// MARK: - 动态表格构建
+
+- (void)buildPriceTableWithColumns:(NSArray<NSDictionary *> *)columns {
+    for (UIView *v in self.priceScrollView.subviews)
+        [v removeFromSuperview];
+
+    if (columns.count == 0) {
+        self.priceScrollView.contentSize = CGSizeZero;
+        return;
     }
     }
-    else
-    {
-        _labelPriceDisplay2.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_4"][@"name"]] floatValue]];
-//            _labelPriceNCA.text=@"N/A";
+
+    UIFont  *font        = [UIFont systemFontOfSize:15.0];
+    UIColor *borderColor = UIColor.labelColor;
+    CGFloat  totalWidth  = 0;
+
+    NSMutableArray<NSNumber *> *colWidths = [NSMutableArray arrayWithCapacity:columns.count];
+    for (NSDictionary *col in columns) {
+        NSString *header = col[@"header"] ?: @"";
+        NSString *value  = col[@"value"]  ?: @"";
+        NSDictionary *attrs = @{ NSFontAttributeName: font };
+        CGFloat hw = [header sizeWithAttributes:attrs].width + kCellHPadding * 2;
+        CGFloat vw = [value  sizeWithAttributes:attrs].width + kCellHPadding * 2;
+        CGFloat w  = MAX(MAX(hw, vw), kMinColumnWidth);
+        [colWidths addObject:@(w)];
     }
     }
-    
-//    remove net price
-//    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";
-        }
+
+    BOOL isLast = NO;
+    CGFloat x = 0;
+    for (NSUInteger i = 0; i < columns.count; i++) {
+        CGFloat w         = [colWidths[i] floatValue];
+        NSDictionary *col = columns[i];
+        isLast = (i == columns.count - 1);
+
+        UILabel *hLabel = [self makeCellLabel:col[@"header"]
+                                         font:font
+                                  borderColor:borderColor
+                                        frame:CGRectMake(x, 0, w, kTableRowHeight)
+                                       isLast:isLast];
+        hLabel.backgroundColor = [UIColor secondarySystemBackgroundColor];
+        [self.priceScrollView addSubview:hLabel];
+
+        UILabel *vLabel = [self makeCellLabel:col[@"value"]
+                                         font:font
+                                  borderColor:borderColor
+                                        frame:CGRectMake(x, kTableRowHeight, w, kTableRowHeight)
+                                       isLast:isLast];
+        [self.priceScrollView addSubview:vLabel];
+
+        x += w;
+        totalWidth = x;
     }
     }
-    
-//
-//    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];
-    
-    
-    
+
+    self.priceScrollView.contentSize = CGSizeMake(totalWidth, kTableRowHeight * 2);
 }
 }
 
 
+// MARK: - 辅助
+
+- (UILabel *)makeCellLabel:(NSString *)text
+                      font:(UIFont *)font
+               borderColor:(UIColor *)borderColor
+                     frame:(CGRect)frame
+                    isLast:(BOOL)isLast {
+    UILabel *label      = [[UILabel alloc] initWithFrame:frame];
+    label.text          = text ?: @"";
+    label.font          = font;
+    label.textAlignment = NSTextAlignmentCenter;
+    label.clipsToBounds = YES;
 
 
+    CGFloat w  = frame.size.width;
+    CGFloat h  = frame.size.height;
+    CGFloat lw = 1.0;
 
 
+    CAShapeLayer *border = [CAShapeLayer layer];
+    UIBezierPath *path   = [UIBezierPath bezierPath];
 
 
--(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];
-        
-        
+    [path moveToPoint:CGPointMake(0, 0)];
+    [path addLineToPoint:CGPointMake(w, 0)];
+    [path moveToPoint:CGPointMake(0, h)];
+    [path addLineToPoint:CGPointMake(w, h)];
+    [path moveToPoint:CGPointMake(0, 0)];
+    [path addLineToPoint:CGPointMake(0, h)];
+    if (isLast) {
+        [path moveToPoint:CGPointMake(w, 0)];
+        [path addLineToPoint:CGPointMake(w, h)];
     }
     }
+
+    border.path        = path.CGPath;
+    border.strokeColor = borderColor.CGColor;
+    border.lineWidth   = lw;
+    border.fillColor   = [UIColor clearColor].CGColor;
+    [label.layer addSublayer:border];
+
+    return label;
 }
 }
+
 @end
 @end

+ 20 - 16
RedAnt ERP Mobile/HMLG Scan Order/ScanOrderModelListViewController.m

@@ -188,30 +188,34 @@
 //            jitem[@"erp_unit_price"] =jitem[@"price0"];
 //            jitem[@"erp_unit_price"] =jitem[@"price0"];
         }
         }
         
         
-        NSString * unit_price;
+        // 先确定价格列 key,再用同一个 key 读 surcharge
+        NSString * unit_price_key;
         if(RASingleton.sharedInstance.price_type==0)
         if(RASingleton.sharedInstance.price_type==0)
-            unit_price=jitem[price_group[@"price_0"][@"name"]];
+            unit_price_key=price_group[@"price_0"][@"name"];
         else if(jitem [@"special_price"])
         else if(jitem [@"special_price"])
-        {
-            unit_price= jitem[price_group[@"price_2"][@"name"]];
-        }
+            unit_price_key=price_group[@"price_2"][@"name"];
         else if(jitem [@"net_price"])
         else if(jitem [@"net_price"])
-            unit_price=jitem[price_group[@"price_3"][@"name"]];
+            unit_price_key=price_group[@"price_3"][@"name"];
         else
         else
-        {
-            unit_price= jitem[price_group[@"price_1"][@"name"]];
-        }
+            unit_price_key=price_group[@"price_1"][@"name"];
 
 
+        NSString * unit_price = jitem[unit_price_key];
         if([unit_price isEqualToString:@"N/A"])
         if([unit_price isEqualToString:@"N/A"])
             unit_price = @"0";
             unit_price = @"0";
         else
         else
-        {
-            
             unit_price = [NSString stringWithFormat:@"%.2f", [unit_price doubleValue]];
             unit_price = [NSString stringWithFormat:@"%.2f", [unit_price doubleValue]];
-        }
-        
+
                     jitem[@"unit_price"] =unit_price;
                     jitem[@"unit_price"] =unit_price;
                     jitem[@"erp_unit_price"] =unit_price;
                     jitem[@"erp_unit_price"] =unit_price;
+
+        // surcharge:key = 当前价格列名 + "_surcharge"
+        NSString *surcharge_key  = [unit_price_key stringByAppendingString:@"_surcharge"];
+        NSString *unit_surcharge = jitem[surcharge_key];
+//        if (unit_surcharge && unit_surcharge.length > 0 && ![unit_surcharge isEqualToString:@"N/A"])
+        if (unit_surcharge )
+            jitem[@"unit_surcharge"] = [NSString stringWithFormat:@"%.2f", [unit_surcharge doubleValue]];
+        else
+            jitem[@"unit_surcharge"] = @"0";
         
         
 //        jitem[@"price0"] =price0;
 //        jitem[@"price0"] =price0;
 //        jitem[@"price1"] =price1;
 //        jitem[@"price1"] =price1;
@@ -432,13 +436,13 @@
 //    scancell.pre_val=[textField.text intValue];
 //    scancell.pre_val=[textField.text intValue];
     
     
 //    self.lastedit_from  = [self.editorTable indexPathForCell:cell];
 //    self.lastedit_from  = [self.editorTable indexPathForCell:cell];
-//    
+//
 //    NSDictionary* item_json =((NSMutableArray*)self.content_data_control[self.lastedit_from.section])[self.lastedit_from.row];
 //    NSDictionary* item_json =((NSMutableArray*)self.content_data_control[self.lastedit_from.section])[self.lastedit_from.row];
-//    
+//
 //    if ([item_json valueForKey:@"clear"]) {
 //    if ([item_json valueForKey:@"clear"]) {
 //        //开始编辑时清掉旧内容
 //        //开始编辑时清掉旧内容
 //        BOOL clear = [[item_json valueForKey:@"clear"] doubleValue] == [textField.text doubleValue];
 //        BOOL clear = [[item_json valueForKey:@"clear"] doubleValue] == [textField.text doubleValue];
-//        
+//
 //        if (clear) {
 //        if (clear) {
 //            textField.text = nil;
 //            textField.text = nil;
 //        }
 //        }

+ 10 - 0
RedAnt ERP Mobile/HMLG Scan Order/ScanSearchViewController.m

@@ -12,6 +12,7 @@
 #import "RADataProvider.h"
 #import "RADataProvider.h"
 
 
 
 
+
 #define PAGE_ITEM 20000
 #define PAGE_ITEM 20000
 
 
 @interface ScanSearchViewController ()
 @interface ScanSearchViewController ()
@@ -132,6 +133,11 @@
     
     
     
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clear) name:@"Clear" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clear) name:@"Clear" object:nil];
+    // 购物车更新后刷新高亮
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(onCartUpdatedRefreshHighlight)
+                                                 name:@"ScanListShouldRefreshHighlight"
+                                               object:nil];
     
     
 //    [self refreshStock];
 //    [self refreshStock];
 }
 }
@@ -532,6 +538,10 @@
     [self reload];
     [self reload];
     
     
 }
 }
+- (void)onCartUpdatedRefreshHighlight {
+    [self.tableview reloadData];
+}
+
 -(void) refresh_ui
 -(void) refresh_ui
 {
 {
     [self.tableview reloadData];
     [self.tableview reloadData];

+ 2 - 1
RedAnt ERP Mobile/HMLG Scan Order/config.h

@@ -73,7 +73,8 @@
 
 
 
 
 
 
-#define BASE_URL @"http://192.168.0.112:8088/wm_postgresql/"
+#define BASE_URL @"http://192.168.14.127:8088/wm_postgresql/"
+//@"http://192.168.0.112:8088/wm_postgresql/"
 
 
 //------------------- chen server-----------------------
 //------------------- chen server-----------------------
 
 

Некоторые файлы не были показаны из-за большого количества измененных файлов