peiguo 5 år sedan
förälder
incheckning
66f8ac774b

+ 46 - 18
admin-ui/app/whepi/index.js

@@ -1,3 +1,4 @@
+var userRole = 0;
 $(function () {
   //隐藏角色上的提示红点
   $('#role-name-num').hide();
@@ -25,26 +26,51 @@ $(function () {
         }]
     });
     $('.easyui-menubutton').menubutton();
-    $('#menutree').tree({
-      url: '/app/whepi/mock/menu.json', //api('/menu_tree'),
-      onDblClick: function (node) {
-        var $this = $(this);
-        if (!$this.tree('isLeaf', node.target)) {
-          $this.tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
+    // 根据userRole读取不同的菜单
+    if (userRole == "1") {
+      $('#menutree').tree({
+        url: '/app/whepi/mock/menu.json', //api('/menu_tree'),
+        onDblClick: function (node) {
+          var $this = $(this);
+          if (!$this.tree('isLeaf', node.target)) {
+            $this.tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
+          }
+        },
+        onSelect: function () {
+          return false;
+        },
+        onClick: function (node) {
+          var href = node.href;
+          if ($.trim(href)) {
+            App.addTab({title: node.text, url: node.href, id: node.id, iconCls: node.iconCls});
+          }
+        },
+        onLoadSuccess: function (node, data) {
         }
-      },
-      onSelect: function () {
-        return false;
-      },
-      onClick: function (node) {
-        var href = node.href;
-        if ($.trim(href)) {
-          App.addTab({title: node.text, url: node.href, id: node.id, iconCls: node.iconCls});
+      });
+    } else if (userRole == "2") {
+      $('#menutree').tree({
+        url: '/app/whepi/mock/menu2.json', //api('/menu_tree'),
+        onDblClick: function (node) {
+          var $this = $(this);
+          if (!$this.tree('isLeaf', node.target)) {
+            $this.tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
+          }
+        },
+        onSelect: function () {
+          return false;
+        },
+        onClick: function (node) {
+          var href = node.href;
+          if ($.trim(href)) {
+            App.addTab({title: node.text, url: node.href, id: node.id, iconCls: node.iconCls});
+          }
+        },
+        onLoadSuccess: function (node, data) {
         }
-      },
-      onLoadSuccess: function (node, data) {
-      }
-    });
+      });
+    }
+
 
     $('#mm').menu({
       onClick: function (item) {
@@ -90,6 +116,8 @@ var App = {
       method: 'get',
       loadingMask: false,
       success: function (data) {
+        userRole = data.data.user.userType;
+        console.log(data.data.user.userType);
         if (!$.trim(data.data.userId)) {
           top.window.location.href = jumpApi(YJYDLOGINURL);
           return;

+ 14 - 0
admin-ui/app/whepi/mock/menu2.json

@@ -0,0 +1,14 @@
+{
+  "success": true,
+  "msg": "",
+  "data": [
+    {
+      "id": "ENT10000",
+      "text": "系统首页",
+      "href": "/app/whepi/home/home.js",
+      "iconCls": "icon-blank fa fa-desktop",
+      "state": "close",
+      "children": []
+    }
+  ]
+}

+ 1 - 1
whepi-doc/login.sql

@@ -7,7 +7,7 @@ create table sys_user
   user_id             BIGINT          not null             comment '用户编号',
   login_name          VARCHAR(50)     not null default ''  comment '登录账户',
   login_pwd           VARCHAR(50)     not null default '123456'  comment '登录密码',
-  user_type           VARCHAR(1)      not null             comment '角色ID:1居民,2业委会,3商家',
+  user_type           VARCHAR(1)      not null             comment '角色ID:1管理员,2角色1',
   staff_name          VARCHAR(20)     not null             comment '用户姓名',
 
   be_active           CHAR(1)         not null default 'Y' comment '是否活动 Y=活动/N=禁用/D=删除',

+ 1 - 0
whepi-web/src/main/java/com/bofeng/controller/LoginController.java

@@ -50,6 +50,7 @@ public class LoginController {
         model.put("userId", JwtHelper.getUserId());
         model.put("staffName", JwtHelper.getStaffName());
         model.put("expireTime", JwtHelper.getExpireTime());
+        model.put("user", userMapper.selectById(JwtHelper.getUserId()));
 //        ResultModel model = new ResultModel()
 //                .set("userId", JwtHelper.getUserId())
 //                .set("staffName", JwtHelper.getStaffName())