dyjh 6 年之前
父节点
当前提交
5571d73722

+ 16 - 15
app/Http/Controllers/Admin/Album/ProductController.php

xqd xqd xqd
@@ -67,6 +67,10 @@ class ProductController extends Controller
         return view('admin.album.product.check', compact('list'));
     }
 
+    /**
+     * @param Request $request
+     * @return \Illuminate\Http\JsonResponse
+     */
     public function getSecondCategory(Request $request)
     {
         $cat_id = $request->input('cat_id');
@@ -95,13 +99,13 @@ class ProductController extends Controller
      */
     public function create(Request $request)
     {
-        if($request->method() == 'POST') {
+        if ($request->method() == 'POST') {
             return $this->_createSave();
         }
         $cat = AlbumCatModel::where([['store_id',$this->getStoreId()],['parent_id',0]])->get();
-        $style = AlbumProductStyleModel::Where('store_id',$this->getStoreId())->get();
-        $data['cat_id']=null;
-        return view('admin.album.product.edit',compact('data','cat','style'));
+
+        $data['cat_id'] = null;
+        return view('admin.album.product.edit', compact('data', 'cat', 'style'));
     }
 
     /**
@@ -151,21 +155,18 @@ class ProductController extends Controller
      * 
      * 
      */
-    public function update(Request $request) {
-        if($request->method() == 'POST') {
+    public function update(Request $request)
+    {
+        if ($request->method() == 'POST') {
             return $this->_updateSave();
         }
         $cat = AlbumCatModel::where([['store_id',$this->getStoreId()],['parent_id',0]])->get();
-        $style = AlbumProductStyleModel::Where('store_id',$this->getStoreId())->get();
         $data = $this->repository->find($request->get('id'));
-
-
-            $data['install_img'] = json_decode($data['install_img']);
-            $data['specifications_img'] = json_decode($data['specifications_img']);
-            $data['detail'] = json_decode($data['detail']);
-
-
-        return view('admin.album.product.edit',compact('data','cat','style'));
+        $parent = AlbumCatModel::where([['store_id',$this->getStoreId()],['parent_id',0],['id',$data->cat_id]])->get();
+        $data['install_img'] = json_decode($data['install_img']);
+        $data['specifications_img'] = json_decode($data['specifications_img']);
+        $data['detail'] = json_decode($data['detail']);
+        return view('admin.album.product.edit', compact('data', 'cat', 'parent'));
     }
 
     /**

+ 7 - 27
resources/views/admin/album/product/edit.blade.php

xqd xqd xqd xqd
@@ -33,7 +33,7 @@
 
 		            <div class="row">
                         <div class="col-lg-10">
-                            <form name="form_product" id="form-validation" action="" class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+                            <form name="form_product" id="form-validation" action="" class="form-horizontal form-validation" accept-charset="UTF-8" method="post" onsubmit="return checkLevel()">
 
                                     
                 <div class="form-group">
@@ -52,7 +52,7 @@
                        <select id="data_parent_id" class="form-control" onchange="getLevelSecondCategory()">
                            @if(isset($cat))
                                @foreach($cat as $key=>$val)
-                                       <option value="{{$val->id}}"  @if($val['id'] == (isset($data['cat_id'])? $data['cat_id']:''))selected @endif>{{$val->name}}</option>
+                                       <option value="{{$val->id}}"  @if($val['id'] == (isset($parent['id'])? $parent['id']:''))selected @endif>{{$val->name}}</option>
                                @endforeach
                            @endif
                        </select>
@@ -103,19 +103,6 @@
                         {!!  widget('Tools.ImgUpload')->multi2('/upload/install_img','install_img',"data[install_img]",  isset($data['install_img'])? $data['install_img'] : '',array("sizex"=>1920,"sizey"=>1080)) !!}
                     </div>
                 </div>
-                <div class="form-group">
-
-                 <label class="control-label col-sm-3">风格</label>
-                    <div class="col-sm-9">
-                        <select name="data[style]" id="data_style" class="form-control"  required="" aria-required="true">
-                            @if(isset($style))
-                                @foreach($style as $key=>$val)
-                                    <option value="{{$val->id}}"  @if($val['id'] == (isset($data['style'])? $data['style']:''))selected @endif>{{$val->name}}</option>
-                                @endforeach
-                            @endif
-                        </select>
-                    </div>
-                </div>
                 <div class="form-group">
 
                  <label class="control-label col-sm-3">排序</label>
@@ -236,24 +223,17 @@
         });
     }
 
+    document.ready(function () {
+        getLevelSecondCategory();
+    })
+
     function checkLevel(){
-        var second = $('#secondLevel').val();
+        var second = $('#data_cat_id').val();
         if (second == 0) {
-            $('#secondGroup').addClass('has-error');
             toastr.error('请选择二级分类!');
             return false;
         }
         return true;
     }
 </script>
-<script>
-    function check(){
-        //alert($('#data_cat_id').val());
-        if($('#data_cat_id').val() == '' || $('#data_cat_id').val() == null){
-
-            return false;
-        }
-    }
-
-</script>
 @endsection