weiximei 6 gadus atpakaļ
vecāks
revīzija
1664067966
22 mainītis faili ar 448 papildinājumiem un 42 dzēšanām
  1. 12
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/UserController.java
  2. 8
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IToUserService.java
  3. 39
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java
  4. 1
    1
      CODE/smart-community/operate-api/src/main/resources/mapper/ToUserMapper.xml
  5. 17
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/RoleController.java
  6. 4
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/SysMenuController.java
  7. 19
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/SysRoleMenuMapper.java
  8. 2
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysMenu.java
  9. 9
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysRole.java
  10. 39
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysRoleMenu.java
  11. 8
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/RoleServiceI.java
  12. 50
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/RoleServiceImpl.java
  13. 3
    1
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/SysMenuServiceImpl.java
  14. 12
    0
      CODE/smart-community/property-api/src/main/resources/mapper/SysRoleMenuMapper.xml
  15. 12
    0
      VUECODE/smart-operate-manage/src/api/user.js
  16. 7
    0
      VUECODE/smart-operate-manage/src/router/index.js
  17. 11
    1
      VUECODE/smart-operate-manage/src/store/modules/user.js
  18. 127
    0
      VUECODE/smart-operate-manage/src/views/account/user/addUser.vue
  19. 4
    2
      VUECODE/smart-operate-manage/src/views/account/user/index.vue
  20. 13
    0
      VUECODE/smart-property-manage/src/api/role.js
  21. 21
    13
      VUECODE/smart-property-manage/src/store/modules/role.js
  22. 30
    24
      VUECODE/smart-property-manage/src/views/account/add/role-add.vue

+ 12
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/UserController.java Parādīt failu

@@ -96,4 +96,16 @@ public class UserController extends BaseController {
96 96
         return responseBean;
97 97
     }
98 98
 
99
+    @ApiOperation(value = "用户成员列表", notes = "用户成员列表")
100
+    @ApiImplicitParams({
101
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "loginName:手机号,userName:姓名" )
102
+    })
103
+    @RequestMapping(value = "/user/addUser", method = RequestMethod.POST)
104
+    public ResponseBean addUser(@RequestBody String parameter,HttpSession session){
105
+        UserElement userElement = getUserElement(session);
106
+        ResponseBean  responseBean = iToUserService.addUser(parameter,userElement.getId());
107
+        return responseBean;
108
+    }
109
+
110
+
99 111
 }

+ 8
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IToUserService.java Parādīt failu

@@ -29,4 +29,12 @@ public interface IToUserService {
29 29
      * @return
30 30
      */
31 31
     ResponseBean userList(String parameter);
32
+
33
+    /**
34
+     * 添加成员角色
35
+     * @param parameter
36
+     * @param UserID
37
+     * @return
38
+     */
39
+    ResponseBean addUser(String parameter,Integer UserID);
32 40
 }

+ 39
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java Parādīt failu

@@ -1,13 +1,16 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONArray;
3 4
 import com.alibaba.fastjson.JSONObject;
4 5
 import com.beust.jcommander.internal.Maps;
5 6
 import com.community.commom.mode.ResponseBean;
6 7
 import com.community.commom.utils.AccountValidatorUtil;
7 8
 import com.community.huiju.common.code.cache.AppkeyCache;
8 9
 import com.community.huiju.dao.ToSysRoleMapper;
10
+import com.community.huiju.dao.ToSysUserRoleMapper;
9 11
 import com.community.huiju.dao.ToUserMapper;
10 12
 import com.community.huiju.model.ToSysRole;
13
+import com.community.huiju.model.ToSysUserRole;
11 14
 import com.community.huiju.model.ToUser;
12 15
 import com.community.huiju.service.IToUserService;
13 16
 import com.community.huiju.vo.ToUserVO;
@@ -19,6 +22,8 @@ import org.springframework.beans.BeanUtils;
19 22
 import org.springframework.beans.factory.annotation.Autowired;
20 23
 import org.springframework.stereotype.Service;
21 24
 
25
+import javax.security.auth.callback.TextOutputCallback;
26
+import java.util.Date;
22 27
 import java.util.List;
23 28
 import java.util.Map;
24 29
 
@@ -32,6 +37,9 @@ public class ToUserServerImpl implements IToUserService {
32 37
     @Autowired
33 38
     private ToSysRoleMapper toSysRoleMapper;
34 39
 
40
+    @Autowired
41
+    private ToSysUserRoleMapper toSysUserRoleMapper;
42
+
35 43
     @Override
36 44
     public ResponseBean login(String loginName, String code) {
37 45
 
@@ -120,4 +128,35 @@ public class ToUserServerImpl implements IToUserService {
120 128
         response.addSuccess(map);
121 129
         return response;
122 130
     }
131
+
132
+    @Override
133
+    public ResponseBean addUser(String parameter,Integer userID) {
134
+        ResponseBean response= new ResponseBean<>();
135
+        JSONObject object= JSONObject.parseObject(parameter);
136
+        ToUser toUser= new ToUser();
137
+
138
+        String loginName= object.getString("loginName");
139
+        String userName = object.getString("userName");
140
+        JSONArray contentImg = object.getJSONArray("roleName");
141
+        Integer[] roleIDArray = contentImg.toArray(new Integer[]{});
142
+        String remark = object.getString("remark");
143
+
144
+        toUser.setUserName(userName);
145
+        toUser.setLoginName(loginName);
146
+        toUser.setRemark(remark);
147
+        toUser.setStatus("1");;
148
+        toUser.setCreateUser(userID);
149
+        toUser.setCreateDate(new Date());
150
+        toUserMapper.insert(toUser);
151
+
152
+        //会对应多个角色
153
+        for (Integer roleID:roleIDArray  ){
154
+           ToSysUserRole toSysUserRole= new ToSysUserRole();
155
+            toSysUserRole.setUserId(toUser.getId());
156
+            toSysUserRole.setRoleId(roleID);
157
+            toSysUserRoleMapper.insert(toSysUserRole);
158
+        }
159
+         response.addSuccess("成功");
160
+        return response;
161
+    }
123 162
 }

+ 1
- 1
CODE/smart-community/operate-api/src/main/resources/mapper/ToUserMapper.xml Parādīt failu

@@ -30,7 +30,7 @@
30 30
     delete from to_user
31 31
     where id = #{id,jdbcType=INTEGER}
32 32
   </delete>
33
-  <insert id="insert" parameterType="com.community.huiju.model.ToUser" >
33
+  <insert id="insert" parameterType="com.community.huiju.model.ToUser" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
34 34
     insert into to_user (id, user_name, login_name, 
35 35
       login_password, email, head_portrait, 
36 36
       remark, status, create_user, 

+ 17
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/RoleController.java Parādīt failu

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4 4
 import com.community.commom.mode.ResponseBean;
5 5
 import com.community.commom.session.UserElement;
6 6
 import com.community.huiju.common.base.BaseController;
7
+import com.community.huiju.model.SysMenu;
8
+import com.community.huiju.model.SysRole;
7 9
 import com.community.huiju.service.RoleServiceI;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiImplicitParam;
@@ -11,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
11 13
 import io.swagger.annotations.ApiOperation;
12 14
 import org.springframework.beans.factory.annotation.Autowired;
13 15
 import org.springframework.cloud.context.config.annotation.RefreshScope;
16
+import org.springframework.web.bind.annotation.RequestBody;
14 17
 import org.springframework.web.bind.annotation.RequestMapping;
15 18
 import org.springframework.web.bind.annotation.RequestMethod;
16 19
 import org.springframework.web.bind.annotation.RequestParam;
@@ -47,4 +50,18 @@ public class RoleController extends BaseController {
47 50
 		responseBean = roleService.getRoleList(roleName,userElement,pageNum,pageSize);
48 51
 		return responseBean;
49 52
 	}
53
+	
54
+	@ApiOperation(value = "添加角色", notes = "添加角色")
55
+	@ApiImplicitParams({
56
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token"),
57
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "Login-Type", value = "值为 web"),
58
+			@ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "sysRole", value = "roleName角色名称;description角色描述;menuArray菜单id集合")
59
+	})
60
+	@RequestMapping(value = "/role/add", method = RequestMethod.POST)
61
+	public ResponseBean addRole(@RequestBody SysRole sysRole, HttpSession session) {
62
+		ResponseBean responseBean = new ResponseBean();
63
+		UserElement userElement = getUserElement(session);
64
+		responseBean = roleService.addRole(sysRole, userElement);
65
+		return responseBean;
66
+	}
50 67
 }

+ 4
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/SysMenuController.java Parādīt failu

@@ -4,6 +4,7 @@ package com.community.huiju.controller;
4 4
 import com.community.commom.mode.ResponseBean;
5 5
 import com.community.commom.session.UserElement;
6 6
 import com.community.huiju.common.base.BaseController;
7
+import com.community.huiju.model.SysMenu;
7 8
 import com.community.huiju.service.ISysMenuService;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiImplicitParam;
@@ -11,6 +12,7 @@ import io.swagger.annotations.ApiImplicitParams;
11 12
 import io.swagger.annotations.ApiOperation;
12 13
 import org.springframework.beans.factory.annotation.Autowired;
13 14
 import org.springframework.cloud.context.config.annotation.RefreshScope;
15
+import org.springframework.web.bind.annotation.RequestBody;
14 16
 import org.springframework.web.bind.annotation.RequestMapping;
15 17
 import org.springframework.web.bind.annotation.RequestMethod;
16 18
 import org.springframework.web.bind.annotation.RequestParam;
@@ -37,6 +39,8 @@ public class SysMenuController extends BaseController {
37 39
 	
38 40
 	@ApiOperation(value = "根据搜索条件获取菜单列表", notes = "根据搜索条件获取菜单列表")
39 41
 	@ApiImplicitParams({
42
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token"),
43
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "Login-Type", value = "值为 web"),
40 44
 	})
41 45
 	@RequestMapping(value = "/menus",method = RequestMethod.GET)
42 46
 	public ResponseBean getInfo(HttpSession session) {

+ 19
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/SysRoleMenuMapper.java Parādīt failu

@@ -0,0 +1,19 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.community.huiju.model.SysRoleMenu;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * <p>
10
+ * 物业端角色可查看的菜单 Mapper 接口
11
+ * </p>
12
+ *
13
+ * @author jobob
14
+ * @since 2019-01-18
15
+ */
16
+public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
17
+	
18
+	int insertList(List<SysRoleMenu> sysRoleMenuList);
19
+}

+ 2
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysMenu.java Parādīt failu

@@ -1,5 +1,6 @@
1 1
 package com.community.huiju.model;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
3 4
 import com.baomidou.mybatisplus.annotation.TableName;
4 5
 import lombok.Data;
5 6
 import lombok.EqualsAndHashCode;
@@ -68,5 +69,6 @@ public class SysMenu implements Serializable {
68 69
     /**
69 70
      * 子节点
70 71
      */
72
+    @TableField(exist = false)
71 73
     private List<SysMenu> children;
72 74
 }

+ 9
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysRole.java Parādīt failu

@@ -1,5 +1,6 @@
1 1
 package com.community.huiju.model;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
3 4
 import com.baomidou.mybatisplus.annotation.TableName;
4 5
 import lombok.Data;
5 6
 import lombok.EqualsAndHashCode;
@@ -7,6 +8,7 @@ import lombok.experimental.Accessors;
7 8
 
8 9
 import java.io.Serializable;
9 10
 import java.time.LocalDateTime;
11
+import java.util.List;
10 12
 
11 13
 /**
12 14
  * <p>
@@ -24,6 +26,7 @@ public class SysRole implements Serializable {
24 26
 
25 27
     private static final long serialVersionUID = 1L;
26 28
 
29
+    private Integer id;
27 30
     /**
28 31
      * 小区id
29 32
      */
@@ -68,4 +71,10 @@ public class SysRole implements Serializable {
68 71
      * 更新人
69 72
      */
70 73
     private String updateName;
74
+    
75
+    /**
76
+     * 前端的menuId
77
+     */
78
+    @TableField(exist = false)
79
+    private List<Integer> menuArray;
71 80
 }

+ 39
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysRoleMenu.java Parādīt failu

@@ -0,0 +1,39 @@
1
+package com.community.huiju.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+import java.io.Serializable;
9
+
10
+/**
11
+ * <p>
12
+ * 物业端角色可查看的菜单
13
+ * </p>
14
+ *
15
+ * @author jobob
16
+ * @since 2019-01-18
17
+ */
18
+@Data
19
+@EqualsAndHashCode(callSuper = false)
20
+@Accessors(chain = true)
21
+@TableName("tp_sys_role_menu")
22
+public class SysRoleMenu implements Serializable {
23
+
24
+    private static final long serialVersionUID = 1L;
25
+
26
+    private Integer communityId;
27
+
28
+    /**
29
+     * 角色ID
30
+     */
31
+    private Integer roleId;
32
+
33
+    /**
34
+     * 菜单ID
35
+     */
36
+    private Integer menuId;
37
+
38
+
39
+}

+ 8
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/RoleServiceI.java Parādīt failu

@@ -16,4 +16,12 @@ public interface RoleServiceI extends IService<SysRole> {
16 16
 	 * @return
17 17
 	 */
18 18
 	ResponseBean getRoleList(String roleName, UserElement userElement, Integer pageNum, Integer pageSize);
19
+	
20
+	/**
21
+	 * 添加角色
22
+	 * @param sysRole
23
+	 * @param userElement
24
+	 * @return
25
+	 */
26
+	ResponseBean addRole(SysRole sysRole, UserElement userElement);
19 27
 }

+ 50
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/RoleServiceImpl.java Parādīt failu

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6 6
 import com.community.commom.mode.ResponseBean;
7 7
 import com.community.commom.session.UserElement;
8 8
 import com.community.huiju.dao.RoleMapper;
9
+import com.community.huiju.dao.SysRoleMenuMapper;
9 10
 import com.community.huiju.model.SysRole;
11
+import com.community.huiju.model.SysRoleMenu;
10 12
 import com.community.huiju.model.TpTransaction;
11 13
 import com.community.huiju.service.RoleServiceI;
12 14
 import com.google.common.collect.Maps;
@@ -14,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
14 16
 import org.springframework.beans.factory.annotation.Autowired;
15 17
 import org.springframework.stereotype.Service;
16 18
 
19
+import java.time.LocalDateTime;
20
+import java.util.ArrayList;
17 21
 import java.util.List;
18 22
 import java.util.Map;
19 23
 
@@ -27,6 +31,9 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, SysRole> implements
27 31
 	
28 32
 	@Autowired
29 33
 	private RoleMapper roleMapper;
34
+	
35
+	@Autowired
36
+	private SysRoleMenuMapper sysRoleMenuMapper;
30 37
 	/**
31 38
 	 * 获取角色列表
32 39
 	 *
@@ -51,4 +58,47 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, SysRole> implements
51 58
 		responseBean.addSuccess(map);
52 59
 		return responseBean;
53 60
 	}
61
+	
62
+	/**
63
+	 * 添加角色
64
+	 *
65
+	 * @param sysRole
66
+	 * @param userElement
67
+	 * @return
68
+	 */
69
+	@Override
70
+	public ResponseBean addRole(SysRole sysRole, UserElement userElement) {
71
+		ResponseBean responseBean = new ResponseBean();
72
+		//接收数据
73
+		sysRole.setCommunityId(userElement.getCommunityId());
74
+		Integer userId = userElement.getId();
75
+		LocalDateTime dateTime = LocalDateTime.now();
76
+		sysRole.setCreateUser(userId);
77
+		sysRole.setCreateDate(dateTime);
78
+		sysRole.setUpdateUser(userId);
79
+		sysRole.setUpdateDate(dateTime);
80
+		//插入角色表
81
+		int size = roleMapper.insert(sysRole);
82
+		if (size < 1){
83
+			responseBean.addError("插入失败");
84
+			return responseBean;
85
+		}
86
+		//维护角色与menu的关系表
87
+		List<SysRoleMenu> sysRoleMenuList = new ArrayList<SysRoleMenu>();
88
+		List<Integer> menuIdList = sysRole.getMenuArray();
89
+		menuIdList.stream().forEach(menuId -> {
90
+			SysRoleMenu sysRoleMenu = new SysRoleMenu();
91
+			sysRoleMenu.setCommunityId(userElement.getCommunityId());
92
+			sysRoleMenu.setRoleId(sysRole.getId());
93
+			sysRoleMenu.setMenuId(menuId);
94
+			sysRoleMenuList.add(sysRoleMenu);
95
+		});
96
+		int count = sysRoleMenuMapper.insertList(sysRoleMenuList);
97
+		if (count < 1){
98
+			responseBean.addError("插入失败");
99
+			return responseBean;
100
+		}
101
+		responseBean.addSuccess(size);
102
+		return responseBean;
103
+	}
54 104
 }

+ 3
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/SysMenuServiceImpl.java Parādīt failu

@@ -9,6 +9,7 @@ import com.community.huiju.model.SysMenu;
9 9
 import com.community.huiju.service.ISysMenuService;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11 11
 import org.springframework.stereotype.Service;
12
+import org.springframework.transaction.annotation.Transactional;
12 13
 
13 14
 import java.util.ArrayList;
14 15
 import java.util.List;
@@ -22,6 +23,7 @@ import java.util.List;
22 23
  * @since 2019-01-17
23 24
  */
24 25
 @Service
26
+@Transactional(rollbackFor = Exception.class)
25 27
 public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
26 28
 	
27 29
 	@Autowired
@@ -39,7 +41,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
39 41
 		List<SysMenu> menuList = new ArrayList<SysMenu>();
40 42
 		sysMenuList.stream().forEach(sysMenu -> {
41 43
 			//父节点是0的,为根节点。
42
-			if(sysMenu.getParentId().equals("0")){
44
+			if(sysMenu.getParentId().equals(0)){
43 45
 				menuList.add(sysMenu);
44 46
 			}
45 47
 		});

+ 12
- 0
CODE/smart-community/property-api/src/main/resources/mapper/SysRoleMenuMapper.xml Parādīt failu

@@ -0,0 +1,12 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.SysRoleMenuMapper">
4
+
5
+    <insert id="insertList" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.ArrayList">
6
+        insert into tp_sys_role_menu(community_id,role_id,menu_id)
7
+        VALUES
8
+        <foreach collection="list" item="item" index="index" separator=",">
9
+            (#{item.communityId},#{item.roleId},#{item.menuId})
10
+        </foreach>
11
+    </insert>
12
+</mapper>

+ 12
- 0
VUECODE/smart-operate-manage/src/api/user.js Parādīt failu

@@ -13,4 +13,16 @@ export function employeesList(data) {
13 13
     }
14 14
   })
15 15
 }
16
+// 获取角色暂定写死
17
+export function userRoleById(data) {
18
+  return request({
19
+    url: '/role/list',
20
+    method: 'post',
21
+    data: {
22
+      pageNum: data.pageNum,
23
+      pageSize: data.pageSize,
24
+      roleName: data.roleName
25
+    }
26
+  })
27
+}
16 28
 

+ 7
- 0
VUECODE/smart-operate-manage/src/router/index.js Parādīt failu

@@ -141,6 +141,13 @@ export const constantRouterMap = [
141 141
         name: 'role-info',
142 142
         hidden: true,
143 143
         meta: { title: '角色详情', icon: 'table' }
144
+      },
145
+      {
146
+        path: '/account/user/addUser',
147
+        component: () => import('@/views/account/user/addUser'),
148
+        name: 'user-addUser',
149
+        hidden: true,
150
+        meta: { title: '添加成员', icon: 'table' }
144 151
       }
145 152
     ]
146 153
   },

+ 11
- 1
VUECODE/smart-operate-manage/src/store/modules/user.js Parādīt failu

@@ -1,6 +1,6 @@
1 1
 import { login, logOut, getInfo, sendCode } from '@/api/login'
2 2
 import { getToken, setToken, removeToken } from '@/utils/auth'
3
-import { employeesList } from '@/api/user'
3
+import { employeesList, userRoleById } from '@/api/user'
4 4
 
5 5
 const user = {
6 6
   state: {
@@ -110,6 +110,16 @@ const user = {
110 110
           reject(error)
111 111
         })
112 112
       })
113
+    },
114
+    // 查询角色 UserRoleById
115
+    UserRoleById({ commit, state }, data) { // 查询活动详情
116
+      return new Promise((resolve, reject) => {
117
+        userRoleById(data).then(response => {
118
+          resolve(response)
119
+        }).catch(error => {
120
+          reject(error)
121
+        })
122
+      })
113 123
     }
114 124
   }
115 125
 }

+ 127
- 0
VUECODE/smart-operate-manage/src/views/account/user/addUser.vue Parādīt failu

@@ -0,0 +1,127 @@
1
+<template>
2
+  <div id="root">
3
+    <el-form ref="listQuery" :model="listQuery" :rules="rules" label-width="100px" class="demo-listQuery">
4
+      <el-form-item label="姓名:" prop="roleName">
5
+        <el-input v-model="listQuery.roleName"/>
6
+      </el-form-item>
7
+      <el-form-item label="手机号:" prop="description">
8
+        <el-input v-model="listQuery.description"/>
9
+      </el-form-item>
10
+      <el-transfer
11
+    filterable
12
+    :titles="['所有角色', '已选角色']"
13
+    :left-default-checked="[2, 3]"
14
+    :filter-method="filterMethod"
15
+    filter-placeholder="请输角色名称"
16
+    v-model="value2"
17
+    :data="dataList"/>
18
+      <el-form-item label="备注:" prop="description">
19
+        <el-input v-model="listQuery.description"/>
20
+      </el-form-item>
21
+      <el-form-item>
22
+        <el-button type="primary">立即创建</el-button>
23
+      </el-form-item>
24
+    </el-form>
25
+  </div>
26
+</template>
27
+
28
+<script>
29
+import { mapActions } from 'vuex'
30
+export default {
31
+  data() {
32
+    return {
33
+      listQuery: {
34
+        id: '',  
35
+        roleName: '',
36
+        description: '',
37
+        menuArray: [], // 已选中的权限资源
38
+        pageNum: 1,
39
+        pageSize:100
40
+      },
41
+       va3:[], 
42
+       value2:[1,4],
43
+       dataList:[],
44
+       citiesList:['上海', '北京', '广州', '深圳', '南京', '西安'],
45
+       pinyinList:['上海', '北京', '广州', '深圳', '南京', '西安', '成都'],
46
+      rules: {
47
+        roleName: [
48
+          { required: true, message: '请输入名称', trigger: 'blur' }
49
+        ],
50
+        description: [
51
+          { required: true, message: '请输入手机号', trigger: 'blur' }
52
+        ],
53
+      }
54
+    }
55
+  },
56
+  mounted() {
57
+      this.getById()
58
+    //    this.roleBox()
59
+  },
60
+  methods: {
61
+     getById() { // 根据ID获取活动信息
62
+    //   this.ruleForm.id = this.$route.params.id
63
+      this.$store.dispatch('UserRoleById', this.listQuery).then((res) => {
64
+            console.log('1111',res.data.list)
65
+             const iss= res.data.list
66
+
67
+    for (let i = 0; i < iss.length;i++) {
68
+          this.va3.push(iss[i].id)
69
+          console.log('this.va3',this.va3)
70
+        }
71
+      })
72
+    },
73
+    roleBox(){
74
+        const generateData2 = _ => {
75
+        const data = this.dataList;
76
+        const cities = this.citiesList
77
+        const pinyin = this.pinyinList
78
+        cities.forEach((city, index) => {
79
+          data.push({
80
+            label: city,
81
+            key: index,
82
+            pinyin: pinyin[index]
83
+          });
84
+        });
85
+         console.log('data:',data)
86
+        return data;
87
+        this.filterMethod(query,item)
88
+      };
89
+      return {
90
+        data2: generateData2(),
91
+        }
92
+        this.filterMethod
93
+      },
94
+      filterMethod(query, item) {
95
+        //  console.log('item:',item)
96
+        const s = item.pinyin.indexOf(query) > -1;
97
+        //  console.log('this.value2:++',this.value2)
98
+        // console.log('this.value2:++',this.citiesList[2])
99
+        // console.log('this.value2:++',this.citiesList[4])
100
+        return s
101
+        },
102
+        // ss4(){
103
+        //   console.log('11111111111111111111')
104
+        //    console.log('this.checked:',this.checked)
105
+        // let value = this.value2
106
+        // for(let i=0;i < value.length;i++){
107
+        //      const va= this.value2[i]
108
+        //    console.log('根据下标遍历每一条数据',this.citiesList[va])
109
+        // }
110
+
111
+        // }
112
+  }    
113
+}
114
+</script>
115
+
116
+<style scoped>
117
+.demo-listQuery {
118
+  width: 500px;
119
+  margin-top: 20px;
120
+  margin-left: auto;
121
+  margin-right: auto;
122
+}
123
+#button-checked{
124
+     float:right;
125
+     margin-right: 50px; 
126
+}
127
+</style>

+ 4
- 2
VUECODE/smart-operate-manage/src/views/account/user/index.vue Parādīt failu

@@ -13,7 +13,7 @@
13 13
       </el-form-item>
14 14
     </el-form>
15 15
     <div class="button">
16
-      <el-button type="primary">添加</el-button>
16
+      <el-button type="primary" @click="addUser">添加</el-button>
17 17
       <el-button type="warning" >修改</el-button>
18 18
     </div>
19 19
     <el-table
@@ -37,7 +37,6 @@
37 37
       <el-table-column prop="updateDate" label="修改时间" align="center" ><template slot-scope="scope">{{ formatDate(scope.row.updateDate) }}</template></el-table-column>
38 38
       <el-table-column prop="id" label="操作" align="center">
39 39
           <template slot-scope="scope"><a><span style="color: #63B8FF" @click="clickTitle(scope.row.id)">{{ scope.row.status =='1' ? '停用账号':'启用账号' }}</span></a></template>
40
-
41 40
       <!-- <a><template slot-scope="scope">
42 41
           <span v-if="scope.row.status==1">{{ '停用账号' }}</span>
43 42
           <span v-if="scope.row.status==0">{{ '启用账号' }}</span>
@@ -169,6 +168,9 @@ export default {
169 168
       var month = value.getMonth() + 1
170 169
       var day = value.getDate()
171 170
       return year + '-' + month + '-' + day
171
+    },
172
+    addUser(){
173
+    this.$router.push({ name: 'user-addUser' })
172 174
     }
173 175
   }
174 176
 }

+ 13
- 0
VUECODE/smart-property-manage/src/api/role.js Parādīt failu

@@ -14,3 +14,16 @@ export function fetchMenuList() {
14 14
     method: 'get'
15 15
   })
16 16
 }
17
+
18
+export function addMenuInfo(data) {
19
+  return request({
20
+    url: '/role/add',
21
+    method: 'post',
22
+    data: {
23
+      roleName: data.roleName,
24
+      description: data.description,
25
+      menuArray: data.menuArray
26
+    }
27
+  })
28
+}
29
+

+ 21
- 13
VUECODE/smart-property-manage/src/store/modules/role.js Parādīt failu

@@ -1,4 +1,4 @@
1
-import { fetchList, fetchMenuList } from '@/api/role'
1
+import { fetchList, fetchMenuList, addMenuInfo } from '@/api/role'
2 2
 
3 3
 const transaction = {
4 4
   namespaced: true,
@@ -33,19 +33,27 @@ const transaction = {
33 33
           reject(error)
34 34
         })
35 35
       })
36
-    }
37
-  },
38
-  FetchMenuList({ commit }) {
39
-    console.log(1)
40
-    return new Promise((resolve, reject) => {
41
-      fetchMenuList().then(response => {
42
-        const data = response.data
43
-        commit('SET_MENU_LIST', data)
44
-        resolve()
45
-      }).catch(error => {
46
-        reject(error)
36
+    },
37
+    FetchMenuList({ commit }) {
38
+      return new Promise((resolve, reject) => {
39
+        fetchMenuList().then(response => {
40
+          const data = response.data
41
+          commit('SET_MENU_LIST', data)
42
+          resolve()
43
+        }).catch(error => {
44
+          reject(error)
45
+        })
46
+      })
47
+    },
48
+    AddMenuInfo({ commit }, listQuery) {
49
+      return new Promise((resolve, reject) => {
50
+        addMenuInfo(listQuery).then(response => {
51
+          resolve(response)
52
+        }).catch(error => {
53
+          reject(error)
54
+        })
47 55
       })
48
-    })
56
+    }
49 57
   }
50 58
 }
51 59
 

+ 30
- 24
VUECODE/smart-property-manage/src/views/account/add/role-add.vue Parādīt failu

@@ -1,18 +1,21 @@
1 1
 <template>
2 2
   <div class="root">
3 3
     <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="add-ruleForm">
4
-      <el-form-item label="角色名称" prop="phase">
5
-        <el-input v-model="ruleForm.phase"/>
4
+      <el-form-item label="角色名称" prop="roleName">
5
+        <el-input v-model="ruleForm.roleName"/>
6 6
       </el-form-item>
7
-      <el-form-item label="角色描述" prop="building">
8
-        <el-input v-model="ruleForm.building"/>
7
+      <el-form-item label="角色描述" prop="description">
8
+        <el-input v-model="ruleForm.description"/>
9 9
       </el-form-item>
10
-      <el-tree
11
-        :data="menuList"
12
-        show-checkbox
13
-        node-key="id"
14
-        :props="defaultProps">
15
-      </el-tree>
10
+      <el-form-item label="资源权限" prop="menuArray">
11
+        <el-tree
12
+          ref="tree"
13
+          :data="menuList"
14
+          show-checkbox
15
+          node-key="id"
16
+          :props="defaultProps">
17
+        </el-tree>
18
+      </el-form-item> 
16 19
       <el-form-item>
17 20
         <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
18 21
         <el-button @click="resetForm('ruleForm')">重置</el-button>
@@ -35,17 +38,16 @@ export default {
35 38
   data() {
36 39
     return {
37 40
       ruleForm: {
38
-        phase: '',
39
-        building: '',
40
-        unit: '',
41
-        level: '',
42
-        roomNo: '',
43
-        ownerName: '',
44
-        ownerTel: ''
41
+        roleName: '',
42
+        description: '',
43
+        menuArray: []
45 44
       },
46 45
       rules: {
47
-        phase: [
46
+        roleName: [
48 47
           { required: true, message: '请输入角色名称', trigger: 'blur' }
48
+        ],
49
+        menuArray: [
50
+          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
49 51
         ]
50 52
       },
51 53
       defaultProps: {
@@ -61,12 +63,16 @@ export default {
61 63
     ...mapMutations('role', {
62 64
     }),
63 65
     ...mapActions('role', [
64
-      'FetchMenuList'
66
+      'FetchMenuList',
67
+      'AddMenuInfo'
65 68
     ]),
66 69
     submitForm(formName) { // 提交
70
+      // 获取选中的树形节点 key
71
+      this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
72
+      console.log(this.ruleForm.menuArray)
67 73
       this.$refs[formName].validate((valid) => {
68 74
         if (valid) {
69
-          this.addBuilding()
75
+          this.addRole()
70 76
         } else {
71 77
           console.log('error submit!!')
72 78
           return false
@@ -82,7 +88,7 @@ export default {
82 88
     resetForm(formName) { // 重置
83 89
       this.$refs[formName].resetFields()
84 90
     },
85
-    addBuilding() {
91
+    addRole() {
86 92
       // 加载框
87 93
       const loading = this.$loading({
88 94
         lock: true,
@@ -90,13 +96,13 @@ export default {
90 96
         spinner: 'el-icon-loading',
91 97
         background: 'rgba(0, 0, 0, 0.7)'
92 98
       })
93
-      this.$store.dispatch('AddBuilding', this.ruleForm).then((res) => {
99
+      this.AddMenuInfo(this.ruleForm).then((res) => {
94 100
         if (res.code === '0') {
95 101
           this.$message({
96 102
             message: res.message,
97 103
             type: 'success'
98 104
           })
99
-          this.$router.push({ name: 'building-index' })
105
+          this.$router.push({ name: 'role-index' })
100 106
           loading.close()
101 107
           return
102 108
         }
@@ -104,7 +110,7 @@ export default {
104 110
         loading.close()
105 111
       }).catch(() => {
106 112
         loading.close()
107
-        console.log('error AddBuilding')
113
+        console.log('error addRole')
108 114
       })
109 115
     }
110 116
   }