wugg %!s(int64=3) %!d(string=hai) anos
pai
achega
dffb54cfab

+ 1 - 0
app/admin/controller/Menu.php

@@ -57,6 +57,7 @@ class Menu extends BaseController
             $list[$value["id"]]['menu_name']=$value['menu_name'];
             $list[$value["id"]]['menu_img']=$value['menu_img'];
             $list[$value["id"]]['menu_route']=$value['menu_route'];
+            $list[$value["id"]]['is_display']=$value['is_display'];
             $list[$value["id"]]['status']=$value['status'];
             $temp = [];
             $temp['menu_name']=$value['cname'];

+ 19 - 10
app/admin/controller/User.php

@@ -42,9 +42,12 @@ class User extends BaseController
             if(!empty($depart)){
               //  $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->column("name");
                 $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->column("id,name,depart_link");
-                array_walk($deparname,function (&$v){
-                    $v['depart'] = array_filter(explode("-",$v['depart_link'])) ;
-                });
+                $value['depart_code'] = [];
+                if(!empty($deparname)){
+                    foreach ($deparname as $item) {
+                        $value['depart_code'][] = array_filter(explode("-",$item['depart_link'])) ;
+                    }
+                }
                 $value['depart'] = $deparname;
             }
             $list[]=$value;
@@ -82,9 +85,12 @@ class User extends BaseController
         $data['depart']="";
         if(!empty($depart)){
             $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->field("id,name,depart_link")->select();
-            array_walk($deparname,function (&$v){
-                $v = array_filter(explode("-",$v['depart_link'])) ;
-            });
+            $value['depart_code'] = [];
+            if(!empty($deparname)){
+                foreach ($deparname as $item) {
+                    $value['depart_code'][] = array_filter(explode("-",$item['depart_link'])) ;
+                }
+            }
             $data['depart'] = $deparname;
         }
         return app_show(0,"获取成功",$data);
@@ -196,10 +202,13 @@ class User extends BaseController
             if(!empty($depart)){
                 $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->field("id,name,depart_link")
                     ->select()->toArray();
-                array_walk($deparname,function (&$v){
-                    $v = array_filter(explode("-",$v['depart_link'])) ;
-                });
                 $value['depart'] = $deparname;
+                $value['depart_code'] = [];
+                if(!empty($deparname)){
+                    foreach ($deparname as $item) {
+                        $value['depart_code'][] = array_filter(explode("-",$item['depart_link'])) ;
+                    }
+                }
             }
             $list[]=$value;
         }
@@ -285,7 +294,7 @@ class User extends BaseController
                 return error_show(1002,"角色已禁用");
             }
         }
-        $itemid = isset($post['item'])&&$post['item']!=="" ?$post['item'] :"";
+        $itemid = isset($post['itemid'])&&$post['itemid']!=="" ?$post['itemid'] :"";
         $item_arr = [];
         if($itemid!==""){
             foreach ($itemid as $value){

+ 79 - 25
app/admin/controller/WareHouse.php

@@ -57,13 +57,16 @@ class WareHouse extends BaseController
             return error_show(1004,'参数mobile 不能为空');
         }
         $position = isset($post['position'])&& $post['position']!='' ?trim($post['position']) :'';
-        $wsm_type = isset($post['wsm_type']) && $post['wsm_type']!=="" ? intval($post['wsm_type']):"";
+        $wsm_type = isset($post['wsm_type']) && $post['wsm_type']!=="" ? intval($post['wsm_type']):"1";
         $wsm_name = isset($post['wsm_name']) && $post['wsm_name']!=="" ? trim($post['wsm_name']):"";
         $wsm_mobile = isset($post['wsm_mobile']) && $post['wsm_mobile']!=="" ? trim($post['wsm_mobile']):"";
         $addr_code = isset($post['addr_code']) && $post['addr_code']!=="" ? trim($post['addr_code']):"";
+        $wsm_addr = isset($post['wsm_addr']) && $post['wsm_addr']!=="" ? trim($post['wsm_addr']):"";
+        Db::startTrans();
         try{
+            $wsm_code = makeNo("WSM");
             $data =[
-                'wsm_code'=>makeNo("WSM"),
+                'wsm_code'=>$wsm_code,
                 'name'=>$name,
                 'wsm_type'=>$wsmtype,
                 'supplierNo'=>$supplier,
@@ -75,19 +78,37 @@ class WareHouse extends BaseController
                 'addtime'=>date("Y-m-d H:i:s"),
                 'updatetime'=>date("Y-m-d H:i:s")
             ];
-            $add = Db::name('warehouse_info')->insert($data);
-            if($add){}
+            $add = Db::name('warehouse_info')->insert($data,true);
+            if($add>0){
+                $addrinfo = [
+                    "wsm_code"=>$wsm_code,
+                    "wsm_type"=> $wsm_type,
+                    "wsm_name"=>$wsm_name,
+                    "wsm_mobile"=>$wsm_mobile,
+                    "wsm_addr"=>$wsm_addr,
+                    "addr_code"=>$addr_code,
+                    "status"=>1,
+                    "addtime"=>date("Y-m-d H:i:s"),
+                    "updatetime"=>date("Y-m-d H:i:s"),
+                ];
+                $addri = DB::name("warehouse_addr")->insert($addrinfo);
+                if($addri){
+                    Db::commit();
+                    return app_show(0,'仓库创建成功');
+                }
+            }
+            Db::rollback();
+            return  error_show(1005,'仓库创建失败');
         }catch (\Exception $e){
+            Db::rollback();
             return error_show(1005,$e->getMessage());
         }
-
-        return $add ? app_show(0,'仓库创建成功'): error_show(1005,'仓库创建失败');
     }
 
     public function list(){
         $post  =$this->request->post();
 
-        $condition= [['is_del',"=",0]];
+        $condition= [['a.is_del',"=",0],["b.is_del","=",0]];
 
         $supplier = isset($post['supplierNo'])&&$post['supplierNo']!="" ? trim($post['supplierNo']) :"";
         if($supplier!=""){
@@ -95,29 +116,33 @@ class WareHouse extends BaseController
         }
         $wsm_code = isset($post['wsm_code'])&&$post['wsm_code']!="" ? trim($post['wsm_code']) :"";
         if($wsm_code!=""){
-            $condition[]=["wsm_code","=",$wsm_code];
+            $condition[]=["a.wsm_code","=",$wsm_code];
         }
         $start = isset($post['start'])&&$post['start']!="" ? $post['start'] :"";
         if($start!=""){
-            $condition[]=["addtime",">=",$start];
+            $condition[]=["a.addtime",">=",$start];
         }
         $end = isset($post['end'])&&$post['end']!="" ? $post['end'] :"";
         if($end!=""){
-            $condition[]=["addtime","<=",$end];
+            $condition[]=["a.addtime","<=",$end];
         }
         $mobile = isset($post['mobile'])&&$post['mobile']!="" ?  trim($post['mobile']) :"";
         if($mobile!=""){
-            $condition[]=["mobile","like","%{$mobile}%"];
+            $condition[]=["a.mobile","like","%{$mobile}%"];
         }
         $contactor = isset($post['contactor'])&&$post['contactor']!="" ? trim($post['contactor']) :"";
         if($contactor!=""){
-            $condition[]=["contactor","like","%{$contactor}%"];
+            $condition[]=["a.contactor","like","%{$contactor}%"];
         }
         $page = isset($post['page']) &&$post['page']!=='' ?intval($post['page']) :1;
         $size = isset($post['size']) &&$post['size']!=='' ?intval($post['size']) :10;
-        $count = Db::name("warehouse_info")->where($condition)->count();
+        $count = Db::name("warehouse_info")->alias("a")->join("warehouse_addr as b ","a.wsm_code=b.wsm_code","left")
+            ->where($condition)->count();
         $page>=ceil($count/$size) ? $page = ceil($count/$size): '';
-        $list = Db::name("warehouse_info")->where($condition)->page($page,$size)->order("addtime desc")->select();
+        $list = Db::name("warehouse_info")->alias("a")->join("warehouse_addr as b ","a.wsm_code=b.wsm_code","left")
+            ->where($condition)->field("a.id.a.wsm_code,a.name,a.wsm_type,a.supplierNo,a.addr,a.contactor,a.mobile,a.position,a.status,a.addtime,
+            a.updatetime,b.wsm_type,b.wsm_name,b.wsm_mobile,b.wsm_addr,b.addr_code")->page($page,$size)->order("a.addtime desc")
+            ->select();
         foreach ($list as $key=>$value){
             if($value['supplierNo']!=""){
                 $supplierinfo = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
@@ -143,7 +168,9 @@ class WareHouse extends BaseController
         if($id===""){
           return  error_show(1004,"参数id不能为空");
         };
-        $warse = Db::name("warehouse_info")->where(["id"=>$id,"is_del"=>0])->find();
+        $warse = Db::name("warehouse_info")->alias("a")->join("warehouse_addr as b ","a.wsm_code=b.wsm_code","left")
+            ->where(["a.id"=>$id,"a.is_del"=>0])->field("a.id.a.wsm_code,a.name,a.wsm_type,a.supplierNo,a.addr,a.contactor,a.mobile,a.position,a.status,a.addtime,
+            a.updatetime,b.wsm_type,b.wsm_name,b.wsm_mobile,b.wsm_addr,b.addr_code")->find();
         if(empty($warse)){
             return error_show(1004,"未找到数据");
         }
@@ -193,16 +220,43 @@ class WareHouse extends BaseController
             return error_show(1004,'参数mobile 不能为空');
         }
         $position = isset($post['position'])&& $post['position']!='' ?trim($post['position']) :'';
-        $data =[
-            'name'=>$name,
-            'addr'=>$addr,
-            'contactor'=>$contactor,
-            'mobile'=>$mobile,
-            'position'=>$position,
-            'updatetime'=>date("Y-m-d H:i:s")
-        ];
-        $add = Db::name('warehouse_info')->where($warse)->update($data);
-        return $add ? app_show(0,'仓库修改成功'): error_show(1005,'仓库修改失败');
+        $wsm_type = isset($post['wsm_type']) && $post['wsm_type']!=="" ? intval($post['wsm_type']):"1";
+        $wsm_name = isset($post['wsm_name']) && $post['wsm_name']!=="" ? trim($post['wsm_name']):"";
+        $wsm_mobile = isset($post['wsm_mobile']) && $post['wsm_mobile']!=="" ? trim($post['wsm_mobile']):"";
+        $addr_code = isset($post['addr_code']) && $post['addr_code']!=="" ? $post['addr_code']:"";
+        $wsm_addr = isset($post['wsm_addr']) && $post['wsm_addr']!=="" ? trim($post['wsm_addr']):"";
+        Db::startTrans();
+        try{
+            $data =[
+                'name'=>$name,
+                'addr'=>$addr,
+                'contactor'=>$contactor,
+                'mobile'=>$mobile,
+                'position'=>$position,
+                'updatetime'=>date("Y-m-d H:i:s")
+            ];
+            $add = Db::name('warehouse_info')->where($warse)->update($data);
+            if($add){
+                $addrinfo = [
+                    "wsm_type"=> $wsm_type,
+                    "wsm_name"=>$wsm_name,
+                    "wsm_mobile"=>$wsm_mobile,
+                    "wsm_addr"=>$wsm_addr,
+                    "addr_code"=>$addr_code,
+                    "updatetime"=>date("Y-m-d H:i:s"),
+                ];
+             $addri = DB::name("warehouse_addr")->where(["wsm_code"=>$warse['wsm_code'],"is_del"=>0])->update($addrinfo);
+                if($addri){
+                    Db::commit();
+                    return app_show(0,'仓库更新成功');
+                }
+            }
+            Db::rollback();
+            return  error_show(1005,'仓库更新失败');
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1005,$e->getMessage());
+        }
     }
 
     public function delete(){