xieruidong пре 2 година
родитељ
комит
a8de8f8934

+ 17 - 0
application/admin/controller/GoodsInstall.php

@@ -112,13 +112,30 @@ class GoodsInstall extends Backend
 
     public function add()
     {
+        return $this->makeAdd();
+    }
+
+    protected function makeAdd($id=null){
         if($this->request->isGet()){
             return $this->fetch();
         }else{
             $data=input('row/a');
             $this->validate($data,[
                 'name'=>['require'],
+                'goods'=>['require'],
+                'fee'=>['require','array','min:1']
             ]);
+
+            if($id) {
+                $install = $this->model->find($id);
+                $install['name']=$data['name'];
+                $install['fee']=$data['fee'];
+                foreach ($data['goods'] as $good){
+
+                }
+            }else{
+                $install = new $this->model;
+            }
         }
     }
 }

+ 1 - 1
application/admin/view/goods_install/add.html

@@ -16,7 +16,7 @@
         <div class="col-xs-12 col-sm-8">
             <span class="text-muted"><input type="checkbox" name="" id="checkall" /> <label for="checkall"><small>{:__('Check all')}</small></label></span>
             <span class="text-muted"><input type="checkbox" name="" id="expandall" /> <label for="expandall"><small>{:__('Expand all')}</small></label></span>
-            <input type="hidden" name="row[goods]" value="" data-rule="required"/>
+            <input type="hidden" name="row[goods]" value=""/>
             <div id="treeview"></div>
         </div>
     </div>

+ 15 - 0
public/assets/js/backend/goods_install.js

@@ -1,4 +1,19 @@
 define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form) {
+    $.jstree.core.prototype.get_all_checked = function (full) {
+        var obj = this.get_selected(), i, j;
+        for (i = 0, j = obj.length; i < j; i++) {
+            obj = obj.concat(this.get_node(obj[i]).parents);
+        }
+        obj = $.grep(obj, function (v, i, a) {
+            return v != '#';
+        });
+        obj = obj.filter(function (itm, i, a) {
+            return i == a.indexOf(itm);
+        });
+        return full ? $.map(obj, $.proxy(function (i) {
+            return this.get_node(i);
+        }, this)) : obj;
+    };
     let extend;
     var Controller = {
         index: function () {