Pārlūkot izejas kodu

搜索商品bug

sunhao 5 gadi atpakaļ
vecāks
revīzija
c30dedede9

+ 3 - 0
app/Http/Controllers/Admin/GoodsController.php

@@ -383,6 +383,9 @@ class GoodsController extends Controller
383 383
      */
384 384
     public function searchSkus(Request $request){
385 385
         $name = trim($request->input('name'));
386
+        if(!$name){
387
+            exit('0');
388
+        }
386 389
         $result = Goods::select('gs.id as sku_id', 'goods.id as goods_id', 'goods.name', 'gs.propsName', 'gs.price', 'gs.is_weigh', 'gs.quantity', 'gs.is_white')->leftJoin('goods_skus as gs', 'gs.goodsCode', '=', 'goods.id')->where('goods.name', 'like', '%'.$name.'%')->where('goods.is_del', 0)->where('gs.is_del', 0)->orderBy('goods.id', 'desc')->get();
387 390
         $result = json_decode(json_encode($result), true);
388 391
         foreach($result as $k=>&$v){

+ 19 - 18
resources/views/order/ordercreate.blade.php

@@ -611,24 +611,24 @@
611 611
             }
612 612
         }
613 613
 
614
-        function getGoods(){
615
-            var name = $('input[name=goods_name]').val();
616
-            if(!name){
617
-                return false;
618
-            }
619
-            $.ajax({
620
-                    'url': '/admin/goods/searchSkus',
621
-                    'type': 'get',
622
-                    'data':{name:name},
623
-                    'dateType': 'json',
624
-                    success:function(data){
625
-                        if(data != '0'){
626
-                            data = eval("("+data+")");
627
-
628
-                        }
629
-                    }
630
-                })
631
-        }
614
+        // function getGoods(){
615
+        //     var name = $('input[name=goods_name]').val();
616
+        //     if(!name){
617
+        //         return false;
618
+        //     }
619
+        //     $.ajax({
620
+        //             'url': '/admin/goods/searchSkus',
621
+        //             'type': 'get',
622
+        //             'data':{name:name},
623
+        //             'dateType': 'json',
624
+        //             success:function(data){
625
+        //                 if(data != '0'){
626
+        //                     data = eval("("+data+")");
627
+
628
+        //                 }
629
+        //             }
630
+        //         })
631
+        // }
632 632
 
633 633
         function to_verify(){
634 634
             if(!form_verify()){
@@ -672,6 +672,7 @@
672 672
 
673 673
     $('input[name=goods_name]').on('keyup focus', function(){
674 674
         var name = $('input[name=goods_name]').val();
675
+            name = name.replace(/\s+/g,"");
675 676
             if(!name){
676 677
                 return false;
677 678
             }