wugg 8 months ago
parent
commit
d2bb7f359e

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

@@ -5,7 +5,8 @@ namespace app\admin\controller;
 
 
 use app\admin\model\AdminMenu;
-use think\App;use think\facade\Validate;
+use think\App;
+use think\facade\Validate;
 class Menu extends Base{
     protected $noLogin=[
         "GetMenuAction" ,

+ 4 - 0
app/admin/model/Role.php

@@ -20,4 +20,8 @@ class Role extends Base
     public function RoleInfo(){
       return  $this->belongsTo('RoleAction','id','role_id');
     }
+
+    public function ProcessInfo(){
+        return  $this->belongsTo('RoleProcess','id','role_id');
+    }
 }

+ 11 - 1
app/admin/model/RoleProcess.php

@@ -15,6 +15,16 @@ class RoleProcess extends Base
         'updaterid'       =>'int',//修改人id
         'updater'       =>'varchar',//修改人
         'updatetime'       =>'datetime',//修改时间
-
     ];
+    protected $updateTime='updatetime';
+    protected $createTime='addtime';
+
+    public function getActionDataAttr($value)
+    {
+        return explode(',',$value);
+    }
+    public function setActionDataAttr($value)
+    {
+        return implode(',',$value);
+    }
 }

+ 23 - 10
app/bug/listener/RoleEvent.php

@@ -71,7 +71,7 @@ class RoleEvent
 
     private function roleOn($event){
          $action = (new WorkAction)->GetBelongActionByIdArrs($event->action);
-        $info=$this->model->with(["RoleInfo"])->where('id',$event->belong_role_id)->findOrEmpty();
+        $info=$this->model->with(["RoleInfo","RoleProcess"])->where('id',$event->belong_role_id)->findOrEmpty();
         $info->role_name = $event->role_name;
         $info->role_level = $event->level;
         $info->level = $event->level;
@@ -92,6 +92,19 @@ class RoleEvent
                         'action_data' => [],
                         'private_data' => $action['private']??[],
                     ]);
+
+        	if(is_null($info->RoleProcess)){
+        		$info->RoleProcess()->save( [
+	                        'action_data' =>  $action['process']??[],
+	                        'role_id' => $info->id,
+	                        "createrid"=>$info->apply_id,
+	                        "creater"=>$info->apply_name,
+	                        "updaterid"=>$info->apply_id,
+	                        "updater"=>$info->apply_name,
+	                    ]);
+	        }else$info->RoleProcess->save( [
+                        'action_data' =>$action['process'],
+                    ]);
         	if($event->belong_role_id==0){
         		$event->belong_role_id =$info->id;
 		        $event->save();
@@ -100,16 +113,16 @@ class RoleEvent
         return $isSave;
     }
     private function roleOff($eventId){
-                $info=$this->model->where('id',$eventId)->findOrEmpty();
-                if($info->isEmpty())return false;
-                $info->status = 0;
-                $isSave = $info->save();
-                return $isSave;
+            $info=$this->model->where('id',$eventId)->findOrEmpty();
+            if($info->isEmpty())return false;
+            $info->status = 0;
+            $isSave = $info->save();
+            return $isSave;
     }
     private function roleDelete($eventId){
-                $info=$this->model->with(["RoleInfo"])->where('id',$eventId)->findOrEmpty();
-                if($info->isEmpty())return false;
-                $isSave = $info->together(['RoleInfo'])->delete();
-                return $isSave;
+        $info=$this->model->with(["RoleInfo","RoleProcess"])->where('id',$eventId)->findOrEmpty();
+        if($info->isEmpty())return false;
+        $isSave = $info->together(['RoleInfo','RoleProcess'])->delete();
+        return $isSave;
     }
 }

+ 2 - 1
app/bug/listener/UserEvent.php

@@ -5,7 +5,8 @@ namespace app\bug\listener;
 
 use app\bug\model\Work;use app\bug\model\WorkUser;
 use app\user\model\Headquarters;
-use think\facade\Log;class UserEvent
+use think\facade\Log;
+class UserEvent
 {
 	private $model;
     private $type=['on'=>'启用','off'=>'禁用','delete'=>'删除'];

+ 2 - 1
app/bug/model/WorkAction.php

@@ -125,7 +125,8 @@ class WorkAction extends Base
          if($list->isEmpty())return [];
          $action = array_column($list->toArray(),"belong_action");
          $private = array_column($list->toArray(),"belong_private");
+         $process = array_column($list->toArray(),"belong_process");
           return ["action"=>array_values(array_unique(Arr::flatten($action))),"private"=>array_values(array_unique(Arr::flatten
-          ($private)))];
+          ($private))),"process"=>array_values(array_unique(Arr::flatten($process)))];
     }
 }

+ 4 - 0
app/cxinv/model/Role.php

@@ -19,4 +19,8 @@ class Role extends Base
     public function RoleInfo(){
       return  $this->belongsTo('RoleAction','id','role_id');
     }
+
+    public function ProcessInfo(){
+        return  $this->belongsTo('RoleProcess','id','role_id');
+    }
 }

+ 11 - 0
app/cxinv/model/RoleProcess.php

@@ -16,4 +16,15 @@ class RoleProcess extends Base
         'updater'  =>'varchar',//修改人
         'updatetime'  =>'datetime',//修改时间
        ];
+    protected $updateTime='updatetime';
+    protected $createTime='addtime';
+
+    public function getActionDataAttr($value)
+    {
+        return explode(',',$value);
+    }
+    public function setActionDataAttr($value)
+    {
+        return implode(',',$value);
+    }
 }

+ 2 - 1
config/console.php

@@ -5,6 +5,7 @@
 return [
     // 指令定义
     'commands' => [
-    	"makemodel"=>\app\command\makeModel::class
+    	"makemodel"=>\app\command\makeModel::class,
+    	"syscnRole"=>\app\command\sysRole::class
     ],
 ];