wugg 8 months ago
parent
commit
e4aa758225
2 changed files with 16 additions and 7 deletions
  1. 15 7
      app/bug/listener/RoleEvent.php
  2. 1 0
      app/bug/model/WorkRole.php

+ 15 - 7
app/bug/listener/RoleEvent.php

@@ -50,9 +50,10 @@ class RoleEvent
                 // 处理未知的belong值
                 throw new \Exception('Unsupported belong value.');
         }
-
+		
         // 使用方法常量代替硬编码字符串
-        $result = $this->{"role{$type}"}($type === 'off' || $type === 'delete' ? $info->belong_role_id : $info);
+	       $method = "role".ucfirst($type);
+        $result = $this->$method($type === 'off' || $type === 'delete' ? $info->belong_role_id : $info);
 
         if ($result === false) {
             $date = date('Y-m-d H:i:s');
@@ -75,11 +76,18 @@ class RoleEvent
         $info->role_level = $event->level;
         $info->companyNo = $event->companyNo;
         $info->status = 1;
-        $isSave = $info->together(['RoleInfo'=>['action_conllect'=>$action,
-        								'action_data'=>[],
-        								'private_data'=>[],
-        								'status'=>1]])->save();
-        echo $info->getLastSql();
+        $isSave = $info->save();
+        if($isSave){
+            $info->RoleInfo()->save( [
+                        'action_conllect' => $action,
+                        'action_data' => [],
+                        'private_data' => [],
+                        'role_id' => $info->id,
+                        'status' => 1
+                    ]);
+            $event->belong_role_id =$info->id;
+            $event->save();
+        }
         return $isSave;
     }
     private function roleOff($eventId){

+ 1 - 0
app/bug/model/WorkRole.php

@@ -13,6 +13,7 @@ class WorkRole extends Base
         'companyNo'       =>'varchar',//归属业务公司
         'work_id'       =>'int',//采购的功能模板
         'belong'       =>'tinyint',//系统归属1采销2结算3数据统计
+        'belong_role_id'       =>'int',//系统归属角色id
         'action'       =>'text',//权限集合
         'process'       =>'text',//流程节点
         'status'       =>'tinyint',//状态