wugg hace 9 meses
padre
commit
9036e2561d
Se han modificado 3 ficheros con 45 adiciones y 3 borrados
  1. 3 1
      app/admin/controller/Menu.php
  2. 4 2
      app/cxinv/controller/Menu.php
  3. 38 0
      app/cxinv/model/UserRole.php

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

@@ -7,7 +7,9 @@ namespace app\admin\controller;
 use app\admin\model\AdminMenu;
 use think\App;
 class Menu extends Base{
-    protected $noLogin=["*"];
+    protected $noLogin=[
+        "GetMenuAction" , //功能权限集合 工单调用
+        ];
 	public function __construct(App $app) {
 		parent::__construct($app);
 		$this->model=new AdminMenu();

+ 4 - 2
app/cxinv/controller/Menu.php

@@ -7,7 +7,9 @@ namespace app\cxinv\controller;
 use app\cxinv\model\AdminMenu;
 use think\App;
 class Menu extends Base{
-    protected $noLogin=["*"];
+    protected $noLogin=[
+        "GetMenuAction" , //功能权限集合 工单调用
+    ];
 	public function __construct(App $app) {
 		parent::__construct($app);
 		$this->model=new AdminMenu();
@@ -20,7 +22,7 @@ class Menu extends Base{
 	        ['is_display','=',1],
 	        ['is_del','=',0]
         ];
-        $action = \app\admin\model\UserRole::getAllAction($this->uid,$param['relaComNo'],$this->level);
+        $action = \app\cxinv\model\UserRole::getAllAction($this->uid,$param['relaComNo'],$this->level);
         if(isset($param['level']) && $param['level'] !== '') $condition[] = ['level','in',[0,$param['level']]];
         else {
             if($this->level == 1) $condition[] = ['level','in',[0,1,2]];

+ 38 - 0
app/cxinv/model/UserRole.php

@@ -19,4 +19,42 @@ class UserRole extends Base
        ];
     protected $updateTime='updatetime';
     protected $createTime='addtime';
+
+    public static function GetRoleIdByCompnyNoAndUid($companyNo,$uid){
+	    return self::where([
+	        'uid' => $uid,
+	        'companyNo' => $companyNo,
+	        'is_del' => 0])
+	        ->value('role_id','');
+    }
+
+    public function RoleInfo(){
+	  return  $this->belongsTo(RoleAction::class,'roleid','role_id')->bind(['action_conllect']);
+    }
+
+    public static function getAllAction($uid=0,$companyNo='',$level=0){
+	    switch ($level){
+	        case 1:
+	            $action = Action::where(['is_del' => 0, 'status' => 1]) ->column('id');
+	            break;
+	        case 2:
+	            $role = self::where([
+	                'uid' => $uid,
+	                'companyNo' => $companyNo,
+	                'is_del' => 0])->with('RoleInfo')
+	               ->findOrEmpty();
+	            $action = $role->action_conllect??[];
+	           break;
+	       case 3:
+	          $role = self::where([
+	          	                'uid' => $uid,
+	          	                'is_del' => 0])->with('RoleInfo')
+	          	               ->findOrEmpty();
+	           $action = $role->action_conllect??[];
+	         break;
+	         default:
+	             $action = [];
+	    }
+	    return $action;
+    }
 }