rabin 2 years ago
parent
commit
327739842c
3 changed files with 34 additions and 2 deletions
  1. 1 1
      assets/layadmin/html/inc/script.html
  2. 27 1
      database/admin.php
  3. 6 0
      src/Auth.php

+ 1 - 1
assets/layadmin/html/inc/script.html

@@ -41,4 +41,4 @@
 <script type="text/javascript" src="../script/lib/layui/xm-select/xm-select.js"></script>
 
 <!-- 加载主要js,很乱,后续优化 -->
-<script type="text/javascript" src="../script/lib/manage/main.js?710"></script>
+<script type="text/javascript" src="../script/lib/manage/main.js?712"></script>

+ 27 - 1
database/admin.php

@@ -71,7 +71,19 @@ $config = function()
 {
 	return Dever::load('manage/config-all');
 };
-
+# 获取权限list 建议这里使用匿名函数
+$auth = function() use($cur)
+{
+	if($cur['role'] > 1)
+	{
+		$auth = Dever::load('manage/auth.get', false);
+	}
+	else
+	{
+		$auth = Dever::load('manage/auth.get', true);
+	}
+	return $auth;
+};
 # 获取头部菜单list 建议这里使用匿名函数
 $top = function()
 {
@@ -685,6 +697,20 @@ return array
 			//'update_search' => 'goods/lib/manage.search_sku',
 		),
 
+		'auth'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '功能权限',
+			'default' 	=> '',
+			'desc' 		=> '请选择功能权限',
+			'match' 	=> 'option',
+			'update'	=> 'checkbox',
+			//每个项对应的一个input以及父级更新的类型
+			//'update_input' => '数量',
+			//'update_parent' => 'radio',
+			'option'	=> $auth,
+		),
+
 		'top'		=> array
 		(
 			'type' 		=> 'text-255',

+ 6 - 0
src/Auth.php

@@ -197,6 +197,12 @@ class Auth
             if ($admin['status'] != 1) {
                 echo '管理账户已被封禁';die;
             }
+            if ($admin['auth']) {
+                $admin['auth'] = explode(',', $admin['auth']);
+                $info['auth'] = explode(',', $info['auth']);
+                $info['auth'] = array_unique(array_merge($info['auth'], $admin['auth']));
+                $info['auth'] = implode(',', $info['auth']);
+            }
             if ($admin['top']) {
                 $info['top'] = $admin['top'];
             }