dever 3 years ago
parent
commit
02d10e51ef
3 changed files with 41 additions and 0 deletions
  1. 6 0
      app/goods/lib/Set.php
  2. 33 0
      app/shop/assets/pc/html/setGoods.html
  3. 2 0
      app/shop/lib/Set.php

+ 6 - 0
app/goods/lib/Set.php

@@ -48,6 +48,9 @@ class Set
                             $result[$i]['price'] = $v['f_price'];
                         } 
                         if ($other) {
+                            if (isset($other['min'])) {
+                                $result[$i]['min'] = $other['min'];
+                            }
                             if (isset($other['total_num'])) {
                                 $result[$i]['total'] = $other['total_num'] - $other['sell_num'];
                             } else {
@@ -110,6 +113,9 @@ class Set
                                 }
                                 $children['total'] = 0;
                                 if ($other_sku) {
+                                    if (isset($other_sku['min'])) {
+                                        $children['min'] = $other_sku['min'];
+                                    }
                                     if (isset($other_sku['total_num'])) {
                                         $children['total'] = $other_sku['total_num'] - $other_sku['sell_num'];
                                     } else {

+ 33 - 0
app/shop/assets/pc/html/setGoods.html

@@ -54,6 +54,7 @@
                                 <th lay-data="{field:'price', edit: 'text'}">销售价(元)</th>
                                 <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
                                 <th lay-data="{field:'number', edit: 'text'}">新增库存</th>
+                                <th lay-data="{field:'number', edit: 'text'}">起订数</th>
                                 <th lay-data="{field:'operation'}">操作</th>
                             </tr>
                         </thead>
@@ -126,6 +127,17 @@
             goods[id].num = num;
             setTotal();
         });
+
+        $("#goods").on("keyup", ".goods_min", function() {
+            var min = parseInt($(this).val());
+            if (!min || min <= 0) {
+                min = 0;
+                $(this).val(0);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].min = min;
+            setTotal();
+        });
     })
     var goods = {};
     var del_goods = {};
@@ -182,6 +194,7 @@
                 goods[key].price = parseFloat(goods[key].price);
                 goods[key].price_type = parseInt(goods[key].price_type);
                 goods[key].total = parseFloat(goods[key].total);
+                goods[key].min = parseInt(goods[key].min);
                 goods[key].num = 0;
                 goods[key].del = 1;
                 create(node);
@@ -210,6 +223,8 @@
             } else {
                 addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
             }   
+
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="decMin(\''+node.id+'\')">-</span><input type="text" value="'+node.min+'" class="goods_min"><span class="jia" onclick="addMin(\''+node.id+'\')">+</span></div></td>';
             
             if (node.total <= 0) {
                 addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
@@ -240,6 +255,24 @@
         setTotal();
     }
 
+    function addMin(id)
+    {
+        goods[id].min += 1;
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+    
+    function decMin(id)
+    {
+        goods[id].min -= 1;
+        if (goods[id].min < 1) {
+            goods[id].min = 0;
+        }
+
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+
     function del(id)
     {
         if (confirm('确定删除吗?')) {

+ 2 - 0
app/shop/lib/Set.php

@@ -95,6 +95,7 @@ class Set
 
                 $w['status'] = $goods_info['status'];
                 $w['total_num'] = $v['num'];
+                $w['min'] = $v['min'];
                 if (!$info) {
                     Dever::db('shop/goods')->insert($w);
                 } else {
@@ -112,6 +113,7 @@ class Set
 
                 $w['status'] = $goods_info['status'];
                 $w['total_num'] = $v['num'];
+                $w['min'] = $v['min'];
                 if (!$info) {
                     Dever::db('shop/goods_sku')->insert($w);
                 } else {