weiximei 6 jaren geleden
bovenliggende
commit
c124d4da45
47 gewijzigde bestanden met toevoegingen van 3429 en 1614 verwijderingen
  1. 2
    0
      CODE/smart-community/mq-message/src/main/java/com/community/huiju/dao/MqMessageMapper.java
  2. 2
    0
      CODE/smart-community/mq-message/src/main/java/com/community/huiju/service/impl/MqMessageServiceImpl.java
  3. 3
    0
      CODE/smart-community/mq-message/src/main/resources/mapper/MqMessageMapper.xml
  4. 28
    1
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/MqMessageController.java
  5. 33
    1
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/UserController.java
  6. 4
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/MqMessageMapper.java
  7. 2
    1
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToSysUserRoleMapper.java
  8. 9
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToUserMapper.java
  9. 12
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/model/ToUser.java
  10. 12
    1
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IMqMessageService.java
  11. 24
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IToUserService.java
  12. 20
    0
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/MqMessageService.java
  13. 100
    5
      CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java
  14. 13
    0
      CODE/smart-community/operate-api/src/main/resources/mapper/MqMessageMapper.xml
  15. 9
    0
      CODE/smart-community/operate-api/src/main/resources/mapper/ToSysUserRoleMapper.xml
  16. 35
    1
      CODE/smart-community/operate-api/src/main/resources/mapper/ToUserMapper.xml
  17. 21
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/SysUserRoleController.java
  18. 56
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/UserController.java
  19. 16
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/SysUserRoleMapper.java
  20. 24
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/UserMapper.java
  21. 38
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysUserRole.java
  22. 21
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/User.java
  23. 16
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/ISysUserRoleService.java
  24. 38
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IUserService.java
  25. 1
    1
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/TpAnnouncementService.java
  26. 20
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/SysUserRoleServiceImpl.java
  27. 174
    2
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/UserServiceImpl.java
  28. 103
    0
      CODE/smart-community/property-api/src/main/resources/mapper/UserMapper.xml
  29. 21
    0
      VUECODE/smart-operate-manage/src/api/index.js
  30. 54
    1
      VUECODE/smart-operate-manage/src/api/user.js
  31. 53
    20
      VUECODE/smart-operate-manage/src/components/chart/chart3.vue
  32. 7
    0
      VUECODE/smart-operate-manage/src/router/index.js
  33. 14
    1
      VUECODE/smart-operate-manage/src/store/modules/trunkIndex.js
  34. 42
    3
      VUECODE/smart-operate-manage/src/store/modules/user.js
  35. 95
    85
      VUECODE/smart-operate-manage/src/views/account/user/addUser.vue
  36. 156
    0
      VUECODE/smart-operate-manage/src/views/account/user/edit.vue
  37. 46
    25
      VUECODE/smart-operate-manage/src/views/account/user/index.vue
  38. 87
    1
      VUECODE/smart-operate-manage/src/views/index/index.vue
  39. 81
    0
      VUECODE/smart-property-manage/src/api/user.js
  40. 1
    1
      VUECODE/smart-property-manage/src/router/index.js
  41. 62
    0
      VUECODE/smart-property-manage/src/store/modules/user.js
  42. 0
    262
      VUECODE/smart-property-manage/src/views/account/user.vue
  43. 137
    0
      VUECODE/smart-property-manage/src/views/account/user/addUser.vue
  44. 156
    0
      VUECODE/smart-property-manage/src/views/account/user/editUser.vue
  45. 195
    0
      VUECODE/smart-property-manage/src/views/account/user/index.vue
  46. 693
    601
      文档/MYSQL/smartCommunity.pdb
  47. 693
    601
      文档/MYSQL/smartCommunity.pdm

+ 2
- 0
CODE/smart-community/mq-message/src/main/java/com/community/huiju/dao/MqMessageMapper.java Bestand weergeven

@@ -18,4 +18,6 @@ public interface MqMessageMapper {
18 18
     int updateByPrimaryKeyWithBLOBs(MqMessage record);
19 19
 
20 20
     int updateByPrimaryKey(MqMessage record);
21
+	
22
+	int updateConnectionByName();
21 23
 }

+ 2
- 0
CODE/smart-community/mq-message/src/main/java/com/community/huiju/service/impl/MqMessageServiceImpl.java Bestand weergeven

@@ -61,5 +61,7 @@ public class MqMessageServiceImpl implements MqMessageServiceI {
61 61
 		mqMessage.setPicUrl(exitFrom.getPicUrl());
62 62
 		//插入mq_message
63 63
 		mqMessageMapper.insertSelective(mqMessage);
64
+		//改变长连接表里的状态
65
+		mqMessageMapper.updateConnectionByName();
64 66
 	}
65 67
 }

+ 3
- 0
CODE/smart-community/mq-message/src/main/resources/mapper/MqMessageMapper.xml Bestand weergeven

@@ -399,4 +399,7 @@
399 399
       pic_url = #{picUrl,jdbcType=VARCHAR}
400 400
     where id = #{id,jdbcType=INTEGER}
401 401
   </update>
402
+  <update id="updateConnectionByName">
403
+    update long_connection_status set `status` = '1' WHERE `connection_name` = "mq"
404
+  </update>
402 405
 </mapper>

+ 28
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/MqMessageController.java Bestand weergeven

@@ -13,6 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
13 13
 import org.springframework.web.bind.annotation.RequestMethod;
14 14
 import org.springframework.web.bind.annotation.RestController;
15 15
 
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.io.PrintWriter;
18
+import java.util.Random;
19
+
16 20
 @RestController
17 21
 @RefreshScope
18 22
 @RequestMapping("/")
@@ -32,5 +36,28 @@ public class MqMessageController extends BaseController {
32 36
         responseBean = iMqMessageService.selectOpenDoorCount();
33 37
         return responseBean;
34 38
     }
35
-
39
+    
40
+    @ApiOperation(value = "长连接", notes = "长连接")
41
+    @ApiImplicitParams({
42
+    })
43
+    @RequestMapping(value = "/mq/connection",method = RequestMethod.GET)
44
+    public ResponseBean ajax(HttpServletResponse response) throws Exception {
45
+        Long startTime = System.currentTimeMillis();
46
+        // 死循环 查询有无数据变化
47
+        while (true) {
48
+            Long endTime = System.currentTimeMillis();
49
+            if (endTime - startTime > 8000){
50
+                return null;
51
+            }
52
+            // 获取开门次数的状态值
53
+            String status = iMqMessageService.getConnectionByName();
54
+            if (status.equals("1")) {
55
+                iMqMessageService.updateConnectionByName();
56
+                return getOpenDoor();
57
+            } else { // 模拟没有数据变化,将休眠 hold住连接
58
+                Thread.sleep(5000);
59
+            }
60
+        }
61
+        
62
+    }
36 63
 }

+ 33
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/UserController.java Bestand weergeven

@@ -96,7 +96,7 @@ public class UserController extends BaseController {
96 96
         return responseBean;
97 97
     }
98 98
 
99
-    @ApiOperation(value = "用户成员列表", notes = "用户成员列表")
99
+    @ApiOperation(value = "添加成员", notes = "用户成员列表")
100 100
     @ApiImplicitParams({
101 101
             @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "loginName:手机号,userName:姓名" )
102 102
     })
@@ -107,5 +107,37 @@ public class UserController extends BaseController {
107 107
         return responseBean;
108 108
     }
109 109
 
110
+    @ApiOperation(value = "修改成员", notes = "修改成员")
111
+    @ApiImplicitParams({
112
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "loginName:手机号,userName:姓名" )
113
+    })
114
+    @RequestMapping(value = "/user/upDate", method = RequestMethod.POST)
115
+    public ResponseBean upDate(@RequestBody String parameter,HttpSession session){
116
+        UserElement userElement = getUserElement(session);
117
+        ResponseBean  responseBean = iToUserService.upDate(parameter,userElement.getId());
118
+        return responseBean;
119
+    }
120
+
121
+    @ApiOperation(value = "查看成员详情", notes = "查看成员详情")
122
+    @ApiImplicitParams({
123
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter" )
124
+    })
125
+    @RequestMapping(value = "/user/selectById", method = RequestMethod.POST)
126
+    public ResponseBean selectById(@RequestBody String parameter,HttpSession session){
127
+        UserElement userElement = getUserElement(session);
128
+        ResponseBean  responseBean = iToUserService.selectById(parameter,userElement.getId());
129
+        return responseBean;
130
+    }
131
+
132
+    @ApiOperation(value = "修改当前状态", notes = "修改当前状态")
133
+    @ApiImplicitParams({
134
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter" )
135
+    })
136
+    @RequestMapping(value = "/user/upDateStatus", method = RequestMethod.POST)
137
+    public ResponseBean upDateStatus(@RequestBody String parameter,HttpSession session){
138
+        UserElement userElement = getUserElement(session);
139
+        ResponseBean  responseBean = iToUserService.upDateStatus(parameter,userElement.getId());
140
+        return responseBean;
141
+    }
110 142
 
111 143
 }

+ 4
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/MqMessageMapper.java Bestand weergeven

@@ -30,4 +30,8 @@ public interface MqMessageMapper {
30 30
      * @return
31 31
      */
32 32
     int selectUnitsOpenDoorCount(Integer eventType);
33
+    
34
+    String getConnectionByName();
35
+    
36
+    int updateConnectionByName();
33 37
 }

+ 2
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToSysUserRoleMapper.java Bestand weergeven

@@ -3,7 +3,6 @@ package com.community.huiju.dao;
3 3
 import com.community.huiju.model.ToSysUserRole;
4 4
 import org.apache.ibatis.annotations.Mapper;
5 5
 import org.apache.ibatis.annotations.Param;
6
-
7 6
 import java.util.List;
8 7
 
9 8
 @Mapper
@@ -20,6 +19,8 @@ public interface ToSysUserRoleMapper {
20 19
 
21 20
     int updateByPrimaryKey(ToSysUserRole record);
22 21
 
22
+
23
+    void deleteRole(@Param("userId") Integer userId);
23 24
     /**
24 25
      * 根据 角色id 查询 用户和角色关联关系
25 26
      * @param roleId

+ 9
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/dao/ToUserMapper.java Bestand weergeven

@@ -31,4 +31,13 @@ public interface ToUserMapper {
31 31
      * @return
32 32
      */
33 33
     String selectByIdUserName(Integer createUser);
34
+
35
+    List<ToUser> selectUser(@Param("id") Integer id);
36
+
37
+    /**
38
+     * 查询多个角色
39
+     * @return
40
+     */
41
+    List<ToUser>  selectRole(@Param("id") Integer id);
42
+
34 43
 }

+ 12
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/model/ToUser.java Bestand weergeven

@@ -42,6 +42,18 @@ public class ToUser {
42 42
      */
43 43
     private String updateNmae;
44 44
 
45
+    /**
46
+     * 角色id
47
+     */
48
+    private  String roleId;
49
+
50
+    public String getRoleId() {
51
+        return roleId;
52
+    }
53
+
54
+    public void setRoleId(String roleId) {
55
+        this.roleId = roleId;
56
+    }
45 57
 
46 58
     public String getCreateNmae() {
47 59
         return createNmae;

+ 12
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IMqMessageService.java Bestand weergeven

@@ -14,5 +14,16 @@ public interface IMqMessageService {
14 14
      * @return
15 15
      */
16 16
     ResponseBean selectOpenDoorCount();
17
-
17
+	
18
+	/**
19
+	 * 是否需要返回数据
20
+	 * @return
21
+	 */
22
+	String getConnectionByName();
23
+	
24
+	/**
25
+	 * 更新长连接的状态
26
+	 * @return
27
+	 */
28
+	int updateConnectionByName();
18 29
 }

+ 24
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/IToUserService.java Bestand weergeven

@@ -37,4 +37,28 @@ public interface IToUserService {
37 37
      * @return
38 38
      */
39 39
     ResponseBean addUser(String parameter,Integer UserID);
40
+
41
+    /**
42
+     * 修改成员
43
+     * @param parameter
44
+     * @param id
45
+     * @return
46
+     */
47
+    ResponseBean upDate(String parameter, Integer id);
48
+
49
+    /**
50
+     * 查看成员详情
51
+     * @param parameter
52
+     * @param id
53
+     * @return
54
+     */
55
+    ResponseBean selectById(String parameter, Integer id);
56
+
57
+    /**
58
+     * 修改当前状态
59
+     * @param parameter
60
+     * @return
61
+     */
62
+    ResponseBean upDateStatus(String parameter,Integer userID);
63
+
40 64
 }

+ 20
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/MqMessageService.java Bestand weergeven

@@ -48,4 +48,24 @@ public class MqMessageService implements IMqMessageService {
48 48
         responseBean.addSuccess(mapList);
49 49
         return responseBean;
50 50
     }
51
+    
52
+    /**
53
+     * 是否需要返回数据
54
+     *
55
+     * @return
56
+     */
57
+    @Override
58
+    public String getConnectionByName() {
59
+        return mqMessageMapper.getConnectionByName();
60
+    }
61
+    
62
+    /**
63
+     * 更新长连接的状态
64
+     *
65
+     * @return
66
+     */
67
+    @Override
68
+    public int updateConnectionByName() {
69
+        return mqMessageMapper.updateConnectionByName();
70
+    }
51 71
 }

+ 100
- 5
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToUserServerImpl.java Bestand weergeven

@@ -23,9 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
23 23
 import org.springframework.stereotype.Service;
24 24
 
25 25
 import javax.security.auth.callback.TextOutputCallback;
26
-import java.util.Date;
27
-import java.util.List;
28
-import java.util.Map;
26
+import java.util.*;
29 27
 
30 28
 @Service("iToUserServer")
31 29
 @Slf4j
@@ -113,6 +111,8 @@ public class ToUserServerImpl implements IToUserService {
113 111
         List<ToUser> userList=toUserMapper.userList(loginName,userName);
114 112
 
115 113
         for (ToUser toUser:userList){
114
+            //查询当前所有角色
115
+            toUser.setRoleName(selectRole(toUser.getId()));
116 116
             // 创建人
117 117
             String createNmae=toUserMapper.selectByIdUserName(toUser.getCreateUser());
118 118
             // 修改人
@@ -137,8 +137,8 @@ public class ToUserServerImpl implements IToUserService {
137 137
 
138 138
         String loginName= object.getString("loginName");
139 139
         String userName = object.getString("userName");
140
-        JSONArray contentImg = object.getJSONArray("roleName");
141
-        Integer[] roleIDArray = contentImg.toArray(new Integer[]{});
140
+        JSONArray List = object.getJSONArray("menuArray");
141
+        Integer[] roleIDArray = List.toArray(new Integer[]{});
142 142
         String remark = object.getString("remark");
143 143
 
144 144
         toUser.setUserName(userName);
@@ -159,4 +159,99 @@ public class ToUserServerImpl implements IToUserService {
159 159
          response.addSuccess("成功");
160 160
         return response;
161 161
     }
162
+
163
+    @Override
164
+    public ResponseBean upDate(String parameter, Integer userID) {
165
+        ResponseBean response = new ResponseBean<>();
166
+        JSONObject object = JSONObject.parseObject(parameter);
167
+        ToUser toUser = new ToUser();
168
+
169
+        String loginName = object.getString("loginName");
170
+        Integer ID= object.getInteger("id");
171
+        String userName = object.getString("userName");
172
+        JSONArray List = object.getJSONArray("menuArray");
173
+        Integer[] roleIDArray = List.toArray(new Integer[]{});
174
+        String remark = object.getString("remark");
175
+
176
+        toUser.setUserName(userName);
177
+        toUser.setLoginName(loginName);
178
+        toUser.setRemark(remark);
179
+        toUser.setStatus("1");
180
+        toUser.setId(ID);
181
+        toUser.setUpdateUser(userID);
182
+        toUser.setUpdateDate(new Date());
183
+        toUserMapper.updateByPrimaryKeySelective(toUser);
184
+
185
+        //会对应多个角色
186
+        if (null!=List) {
187
+            toSysUserRoleMapper.deleteRole(ID);
188
+            for (Integer roleID : roleIDArray) {
189
+                ToSysUserRole toSysUserRole = new ToSysUserRole();
190
+                toSysUserRole.setUserId(toUser.getId());
191
+                toSysUserRole.setRoleId(roleID);
192
+                toSysUserRoleMapper.insert(toSysUserRole);
193
+            }
194
+        }
195
+        response.addSuccess("成功");
196
+        return response;
197
+    }
198
+
199
+    @Override
200
+    public ResponseBean selectById(String parameter, Integer userID) {
201
+        ResponseBean response= new ResponseBean<>();
202
+        JSONObject object= JSONObject.parseObject(parameter);
203
+        Integer ID= object.getInteger("id");
204
+        List<String> list=new ArrayList<String>();
205
+        List<ToUser> userList=toUserMapper.selectUser(ID);
206
+        for (ToUser toUser:userList){
207
+            list.add(toUser.getRoleId());
208
+        }
209
+         HashMap map= new HashMap<>();
210
+        map.put("userList",userList);
211
+        map.put("roleList",list);
212
+        response.addSuccess(map);
213
+        return response;
214
+    }
215
+
216
+    @Override
217
+    public ResponseBean upDateStatus(String parameter,Integer userID) {
218
+        ResponseBean response = new ResponseBean<>();
219
+        JSONObject object = JSONObject.parseObject(parameter);
220
+        Integer status = object.getInteger("status");
221
+        Integer id = object.getInteger("id");
222
+        ToUser toUser = new ToUser();
223
+        toUser.setId(id);
224
+        int st=status.intValue();
225
+        if (st==1){
226
+            toUser.setStatus("0");
227
+        }else if (st==0){
228
+            toUser.setStatus("1");
229
+        }
230
+        toUser.setUpdateUser(userID);
231
+        toUser.setUpdateDate(new Date());
232
+        toUserMapper.updateByPrimaryKey(toUser);
233
+        response.addSuccess("成功");
234
+        return response;
235
+    }
236
+
237
+    //查询多个角色转换为字符串
238
+    public String selectRole(Integer id) {
239
+        List<ToUser> toUser= toUserMapper.selectRole(id);
240
+        List<String> list=new ArrayList<String>();
241
+         for (ToUser user:toUser){
242
+             list.add(user.getRoleName());
243
+         }
244
+        String result = "";
245
+        if (list != null && list.size() > 0) {
246
+            for (String item : list) {
247
+                // 把列表中的每条数据用逗号分割开来,然后拼接成字符串
248
+                result += item + ",";
249
+
250
+            }
251
+            result = result.substring(0,result.length()-1);
252
+        }
253
+        return result;
254
+    }
255
+
256
+
162 257
 }

+ 13
- 0
CODE/smart-community/operate-api/src/main/resources/mapper/MqMessageMapper.xml Bestand weergeven

@@ -410,4 +410,17 @@
410 410
     from mq_message
411 411
     where event_type = #{eventType,jdbcType=INTEGER}
412 412
   </select>
413
+
414
+  <select id="getConnectionByName" resultType="java.lang.String">
415
+    SELECT
416
+        `status`
417
+    FROM
418
+        long_connection_status
419
+    WHERE
420
+        `connection_name` = "mq"
421
+  </select>
422
+
423
+  <update id="updateConnectionByName">
424
+    update long_connection_status set `status` = '0' WHERE `connection_name` = "mq"
425
+  </update>
413 426
 </mapper>

+ 9
- 0
CODE/smart-community/operate-api/src/main/resources/mapper/ToSysUserRoleMapper.xml Bestand weergeven

@@ -50,6 +50,7 @@
50 50
       </if>
51 51
     </trim>
52 52
   </insert>
53
+
53 54
   <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToSysUserRole" >
54 55
     update to_sys_user_role
55 56
     <set >
@@ -62,16 +63,24 @@
62 63
     </set>
63 64
     where id = #{id,jdbcType=INTEGER}
64 65
   </update>
66
+
65 67
   <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToSysUserRole" >
66 68
     update to_sys_user_role
67 69
     set user_id = #{userId,jdbcType=INTEGER},
68 70
       role_id = #{roleId,jdbcType=INTEGER}
69 71
     where id = #{id,jdbcType=INTEGER}
70 72
   </update>
73
+
74
+  <delete id="deleteRole" parameterType="java.lang.Integer" >
75
+    delete from to_sys_user_role
76
+    where user_id = #{userId,jdbcType=INTEGER}
77
+  </delete>
78
+
71 79
   <select id="selelctByRoleId" parameterType="integer" resultMap="BaseResultMap">
72 80
     select
73 81
     <include refid="Base_Column_List"/>
74 82
     from to_sys_user_role
75 83
     where role_id = #{roleId,jdbcType=INTEGER}
76 84
   </select>
85
+
77 86
 </mapper>

+ 35
- 1
CODE/smart-community/operate-api/src/main/resources/mapper/ToUserMapper.xml Bestand weergeven

@@ -15,6 +15,7 @@
15 15
     <result column="update_user" property="updateUser" jdbcType="INTEGER" />
16 16
     <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
17 17
     <result column="role_name" property="roleName" jdbcType="VARCHAR" />
18
+    <result column="role_id" property="roleId" jdbcType="VARCHAR" />
18 19
   </resultMap>
19 20
   <sql id="Base_Column_List" >
20 21
     id, user_name, login_name, login_password, email, head_portrait, remark, status, 
@@ -193,13 +194,13 @@
193 194
     tu.user_name,
194 195
     tu.remark,
195 196
     tu.login_name,
196
-    tu.remark,
197 197
     tu.status,
198 198
     tu.id
199 199
     FROM
200 200
     to_user tu
201 201
     LEFT JOIN to_sys_user_role ON tu.id = to_sys_user_role.user_id
202 202
     LEFT JOIN to_sys_role sr ON to_sys_user_role.role_id = sr.id
203
+    group by to_sys_user_role.user_id
203 204
     <where>
204 205
     <if test="loginName != null and loginName !=''" >
205 206
       and tu.login_name = #{loginName,jdbcType=VARCHAR}
@@ -218,4 +219,37 @@
218 219
     WHERE id=#{id,jdbcType=INTEGER}
219 220
   </select>
220 221
 
222
+  <select id="selectUser"  resultMap="BaseResultMap" >
223
+    SELECT
224
+    sr.role_name,
225
+    sr.description,
226
+    sr.create_user,
227
+    sr.create_date,
228
+    sr.update_date,
229
+    sr.update_user,
230
+    tu.user_name,
231
+    tu.remark,
232
+    tu.login_name,
233
+    tu.status,
234
+    tu.id,
235
+    to_sys_user_role.role_id
236
+    FROM
237
+    to_user tu
238
+    LEFT JOIN to_sys_user_role ON tu.id = to_sys_user_role.user_id
239
+    LEFT JOIN to_sys_role sr ON to_sys_user_role.role_id = sr.id
240
+    WHERE tu.id=#{id,jdbcType=INTEGER}
241
+  </select>
242
+  <select id="selectRole"  resultMap="BaseResultMap" parameterType="int">
243
+      SELECT
244
+          sr.role_name,
245
+          tu.remark,
246
+          tu.login_name,
247
+          tu.id,
248
+          to_sys_user_role.role_id
249
+      FROM
250
+          to_user tu
251
+      LEFT JOIN to_sys_user_role ON tu.id = to_sys_user_role.user_id
252
+      LEFT JOIN to_sys_role sr ON to_sys_user_role.role_id = sr.id
253
+      WHERE tu.id=#{id,jdbcType=INTEGER}
254
+  </select>
221 255
 </mapper>

+ 21
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/SysUserRoleController.java Bestand weergeven

@@ -0,0 +1,21 @@
1
+package com.community.huiju.controller;
2
+
3
+
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+
6
+import org.springframework.web.bind.annotation.RestController;
7
+import com.community.huiju.common.base.BaseController;
8
+
9
+/**
10
+ * <p>
11
+ * 物业web端用户是那些角色 前端控制器
12
+ * </p>
13
+ *
14
+ * @author jobob
15
+ * @since 2019-01-21
16
+ */
17
+@RestController
18
+@RequestMapping("/tp/sys-user-role")
19
+public class SysUserRoleController extends BaseController {
20
+
21
+}

+ 56
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/UserController.java Bestand weergeven

@@ -99,4 +99,60 @@ public class UserController extends BaseController {
99 99
 		responseBean.addSuccess("退出成功!");
100 100
 		return responseBean;
101 101
 	}
102
+	@ApiOperation(value = "用户成员列表", notes = "用户成员列表")
103
+	@ApiImplicitParams({
104
+			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "loginName:手机号, " +
105
+					"userName:用户名,pageNum:第几页,pageSize:每页长度")
106
+	})
107
+	@RequestMapping(value = "/user/userList", method = RequestMethod.POST)
108
+	public ResponseBean userList(@RequestBody String parameter,HttpSession session){
109
+		UserElement userElement = getUserElement(session);
110
+		ResponseBean  responseBean = userService.userList(parameter,userElement.getCommunityId());
111
+		return responseBean;
112
+	}
113
+
114
+	@ApiOperation(value = "添加成员", notes = "用户成员列表")
115
+	@ApiImplicitParams({
116
+			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "loginName:手机号,userName:姓名" )
117
+	})
118
+	@RequestMapping(value = "/user/addUser", method = RequestMethod.POST)
119
+	public ResponseBean addUser(@RequestBody String parameter,HttpSession session){
120
+		UserElement userElement = getUserElement(session);
121
+		ResponseBean  responseBean = userService.addUser(parameter,userElement.getId(),userElement.getCommunityId());
122
+		return responseBean;
123
+	}
124
+
125
+	@ApiOperation(value = "修改成员", notes = "修改成员")
126
+	@ApiImplicitParams({
127
+			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "loginName:手机号,userName:姓名" )
128
+	})
129
+	@RequestMapping(value = "/user/upDate", method = RequestMethod.POST)
130
+	public ResponseBean upDate(@RequestBody String parameter,HttpSession session){
131
+		UserElement userElement = getUserElement(session);
132
+		ResponseBean  responseBean = userService.upDate(parameter,userElement.getId());
133
+		return responseBean;
134
+	}
135
+
136
+	@ApiOperation(value = "查看成员详情", notes = "查看成员详情")
137
+	@ApiImplicitParams({
138
+			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter" )
139
+	})
140
+	@RequestMapping(value = "/user/selectById", method = RequestMethod.POST)
141
+	public ResponseBean selectById(@RequestBody String parameter,HttpSession session){
142
+		UserElement userElement = getUserElement(session);
143
+		ResponseBean  responseBean = userService.selectById(parameter,userElement.getId());
144
+		return responseBean;
145
+	}
146
+
147
+	@ApiOperation(value = "修改当前状态", notes = "修改当前状态")
148
+	@ApiImplicitParams({
149
+			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter" )
150
+	})
151
+	@RequestMapping(value = "/user/upDateStatus", method = RequestMethod.POST)
152
+	public ResponseBean upDateStatus(@RequestBody String parameter,HttpSession session){
153
+		UserElement userElement = getUserElement(session);
154
+		ResponseBean  responseBean = userService.upDateStatus(parameter,userElement.getId());
155
+		return responseBean;
156
+	}
157
+
102 158
 }

+ 16
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/SysUserRoleMapper.java Bestand weergeven

@@ -0,0 +1,16 @@
1
+package com.community.huiju.dao;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.community.huiju.model.SysUserRole;
5
+
6
+/**
7
+ * <p>
8
+ * 物业web端用户是那些角色 Mapper 接口
9
+ * </p>
10
+ *
11
+ * @author jobob
12
+ * @since 2019-01-21
13
+ */
14
+public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
15
+
16
+}

+ 24
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/UserMapper.java Bestand weergeven

@@ -1,11 +1,17 @@
1 1
 package com.community.huiju.dao;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4 6
 import com.community.huiju.model.TaUser;
7
+import com.community.huiju.model.TpAnnouncement;
8
+import com.community.huiju.model.TpBuildingOwnerInfo;
5 9
 import com.community.huiju.model.User;
6 10
 import org.apache.ibatis.annotations.Mapper;
7 11
 import org.apache.ibatis.annotations.Param;
8 12
 
13
+import java.util.List;
14
+
9 15
 /**
10 16
  * <p>
11 17
  * 物业web端用户表 Mapper 接口
@@ -18,4 +24,22 @@ import org.apache.ibatis.annotations.Param;
18 24
 public interface UserMapper extends BaseMapper<User> {
19 25
     String selectByIdUserName(@Param("id") Integer id);
20 26
 
27
+    IPage<User> userList(Page page, @Param("loginName") String loginName, @Param("userName") String userName,@Param("communityId")Integer communityId);
28
+
29
+
30
+    void updateByPrimaryKeySelective(User user);
31
+
32
+    /**
33
+     * 当前成员信息
34
+     * @param id
35
+     * @return
36
+     */
37
+    List<User> selectUser(@Param("id") Integer id);
38
+
39
+    /**
40
+     * 查询当前多个角色
41
+     * @param id
42
+     * @return
43
+     */
44
+    List<User> selectRole(@Param("id") Integer id);
21 45
 }

+ 38
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/SysUserRole.java Bestand weergeven

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

+ 21
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/User.java Bestand weergeven

@@ -1,5 +1,7 @@
1 1
 package com.community.huiju.model;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
3 5
 import com.baomidou.mybatisplus.annotation.TableName;
4 6
 import lombok.Data;
5 7
 import lombok.EqualsAndHashCode;
@@ -25,6 +27,7 @@ public class User implements Serializable {
25 27
 
26 28
     private static final long serialVersionUID = 1L;
27 29
 
30
+    @TableId(value = "id", type = IdType.AUTO)
28 31
     private Integer id;
29 32
 
30 33
     /**
@@ -87,5 +90,23 @@ public class User implements Serializable {
87 90
      */
88 91
     private LocalDateTime updateDate;
89 92
 
93
+    /**
94
+     * 角色名称
95
+     */
96
+    private String RoleName;
97
+
98
+    /**
99
+     * 创建人名称
100
+     */
101
+    private String CreateNmae;
90 102
 
103
+    /**
104
+     * 修改人名称
105
+     */
106
+    private String UpdateNmae;
107
+
108
+    /**
109
+     * 角色ID
110
+     */
111
+    private String RoleId;
91 112
 }

+ 16
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/ISysUserRoleService.java Bestand weergeven

@@ -0,0 +1,16 @@
1
+package com.community.huiju.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.community.huiju.model.SysUserRole;
5
+
6
+/**
7
+ * <p>
8
+ * 物业web端用户是那些角色 服务类
9
+ * </p>
10
+ *
11
+ * @author jobob
12
+ * @since 2019-01-21
13
+ */
14
+public interface ISysUserRoleService extends IService<SysUserRole> {
15
+
16
+}

+ 38
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IUserService.java Bestand weergeven

@@ -39,4 +39,42 @@ public interface IUserService extends IService<User> {
39 39
      */
40 40
     ResponseBean userInfo(UserElement userElement);
41 41
 
42
+    /**
43
+     * 获取成员列表
44
+     * @param parameter
45
+     * @return
46
+     */
47
+    ResponseBean userList(String parameter,Integer communityId);
48
+
49
+    /**
50
+     * 添加成员角色
51
+     * @param parameter
52
+     * @param UserID
53
+     * @return
54
+     */
55
+    ResponseBean addUser(String parameter,Integer UserID,Integer communityId);
56
+
57
+    /**
58
+     * 修改成员
59
+     * @param parameter
60
+     * @param id
61
+     * @return
62
+     */
63
+    ResponseBean upDate(String parameter, Integer id);
64
+
65
+    /**
66
+     * 查看成员详情
67
+     * @param parameter
68
+     * @param id
69
+     * @return
70
+     */
71
+    ResponseBean selectById(String parameter, Integer id);
72
+
73
+    /**
74
+     * 修改当前状态
75
+     * @param parameter
76
+     * @return
77
+     */
78
+    ResponseBean upDateStatus(String parameter,Integer userID);
79
+
42 80
 }

+ 1
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/TpAnnouncementService.java Bestand weergeven

@@ -34,7 +34,7 @@ public interface TpAnnouncementService extends IService<TpAnnouncement> {
34 34
     ResponseBean announcementById(String paramets);
35 35
 
36 36
     /**
37
-     * 添加公告
37
+     * 修改公告
38 38
       * @param paramets
39 39
      * @return
40 40
      */

+ 20
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/SysUserRoleServiceImpl.java Bestand weergeven

@@ -0,0 +1,20 @@
1
+package com.community.huiju.service.impl;
2
+
3
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.community.huiju.dao.SysUserRoleMapper;
5
+import com.community.huiju.model.SysUserRole;
6
+import com.community.huiju.service.ISysUserRoleService;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 物业web端用户是那些角色 服务实现类
12
+ * </p>
13
+ *
14
+ * @author jobob
15
+ * @since 2019-01-21
16
+ */
17
+@Service
18
+public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {
19
+
20
+}

+ 174
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/UserServiceImpl.java Bestand weergeven

@@ -1,7 +1,9 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3 3
 
4
+import com.alibaba.fastjson.JSONArray;
4 5
 import com.alibaba.fastjson.JSONObject;
6
+import com.baomidou.mybatisplus.core.metadata.IPage;
5 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 9
 import com.community.commom.mode.ResponseBean;
@@ -29,8 +31,8 @@ import org.springframework.beans.factory.annotation.Autowired;
29 31
 import org.springframework.stereotype.Service;
30 32
 import org.springframework.transaction.annotation.Transactional;
31 33
 
32
-import java.util.List;
33
-import java.util.Map;
34
+import java.time.LocalDateTime;
35
+import java.util.*;
34 36
 
35 37
 /**
36 38
  * <p>
@@ -57,6 +59,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
57 59
     @Autowired
58 60
     private ToCommunitiesMapper toCommunitiesMapper;
59 61
 
62
+    @Autowired
63
+    private  SysUserRoleMapper sysUserRoleMapper;
64
+
65
+
60 66
     @Override
61 67
     public ResponseBean login(String phone, Integer communityId, String code) {
62 68
         ResponseBean responseBean = new ResponseBean();
@@ -161,4 +167,170 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
161 167
         }
162 168
     }
163 169
 
170
+    @Override
171
+    public ResponseBean userList(String parameter,Integer communityId) {
172
+        ResponseBean response= new ResponseBean<>();
173
+        JSONObject object= JSONObject.parseObject(parameter);
174
+        String loginName= object.getString("loginName");
175
+        String userName = object.getString("userName");
176
+
177
+        Integer pageNum = object.getInteger("pageNum");
178
+        Integer pageSize = object.getInteger("pageSize");
179
+
180
+        // 分页
181
+        Page<TpBuildingOwnerInfo> page = new Page<>();
182
+        page.setSize(pageSize == null ? 10 : pageSize);
183
+        page.setCurrent(pageNum == null ? 1 : pageNum);
184
+
185
+        IPage<User> pageInfo = userMapper.userList(page,loginName,userName,communityId);
186
+        List<User> userList = pageInfo.getRecords();
187
+        for (User user:userList){
188
+            //查询当前所有角色
189
+            user.setRoleName(selectRole(user.getId()));
190
+            // 创建人
191
+            String createNmae=userMapper.selectByIdUserName(user.getCreateUser());
192
+            // 修改人
193
+            String updateNmae=userMapper.selectByIdUserName(user.getUpdateUser());
194
+
195
+            user.setCreateNmae(createNmae);
196
+            user.setUpdateNmae(updateNmae);
197
+        }
198
+
199
+        Map<String, Object> map = Maps.newHashMap();
200
+        map.put("list", userList);
201
+        map.put("total", pageInfo.getTotal());
202
+        map.put("pageNum", pageInfo.getCurrent());
203
+        map.put("pageSize", pageInfo.getSize());
204
+        response.addSuccess(map);
205
+        return response;
206
+    }
207
+
208
+    @Override
209
+    public ResponseBean addUser(String parameter,Integer userID,Integer communityId) {
210
+        ResponseBean response= new ResponseBean<>();
211
+        JSONObject object= JSONObject.parseObject(parameter);
212
+        User user= new User();
213
+
214
+        String loginName= object.getString("loginName");
215
+        String userName = object.getString("userName");
216
+        JSONArray List = object.getJSONArray("menuArray");
217
+        Integer[] roleIdArray = List.toArray(new Integer[]{});
218
+        String remark = object.getString("remark");
219
+
220
+        user.setUserName(userName);
221
+        user.setLoginName(loginName);
222
+        user.setRemark(remark);
223
+        user.setStatus("1");;
224
+        user.setCreateUser(userID);
225
+        user.setCreateDate(LocalDateTime.now());
226
+        userMapper.insert(user);
227
+        //维护小区
228
+        TpUserCommunity tpUserCommunity= new TpUserCommunity();
229
+        tpUserCommunity.setCommunityId(communityId);
230
+        tpUserCommunity.setId(user.getId());
231
+        tpUserCommunityMapper.insert(tpUserCommunity);
232
+        //会对应多个角色
233
+        for (Integer roleID:roleIdArray  ){
234
+            SysUserRole toSysUserRole= new SysUserRole();
235
+            toSysUserRole.setUserId(user.getId());
236
+            toSysUserRole.setRoleId(roleID);
237
+            sysUserRoleMapper.insert(toSysUserRole);
238
+        }
239
+        response.addSuccess("成功");
240
+        return response;
241
+    }
242
+
243
+    @Override
244
+    public ResponseBean upDate(String parameter, Integer userID) {
245
+        ResponseBean response = new ResponseBean<>();
246
+        JSONObject object = JSONObject.parseObject(parameter);
247
+        User user = new User();
248
+
249
+        String loginName = object.getString("loginName");
250
+        Integer ID= object.getInteger("id");
251
+        String userName = object.getString("userName");
252
+        JSONArray List = object.getJSONArray("menuArray");
253
+        Integer[] roleIDArray = List.toArray(new Integer[]{});
254
+        String remark = object.getString("remark");
255
+
256
+        user.setUserName(userName);
257
+        user.setLoginName(loginName);
258
+        user.setRemark(remark);
259
+        user.setStatus("1");
260
+        user.setId(ID);
261
+        user.setUpdateUser(userID);
262
+        user.setUpdateDate(LocalDateTime.now());
263
+        userMapper.updateByPrimaryKeySelective(user);
264
+
265
+        //会对应多个角色
266
+        if (null!=List) {
267
+            sysUserRoleMapper.deleteById(ID);
268
+            for (Integer roleID : roleIDArray) {
269
+                SysUserRole sysUserRole = new SysUserRole();
270
+                sysUserRole.setUserId(user.getId());
271
+                sysUserRole.setRoleId(roleID);
272
+                sysUserRoleMapper.insert(sysUserRole);
273
+            }
274
+        }
275
+        response.addSuccess("成功");
276
+        return response;
277
+    }
278
+
279
+    @Override
280
+    public ResponseBean selectById(String parameter, Integer userID) {
281
+        ResponseBean response= new ResponseBean<>();
282
+        JSONObject object= JSONObject.parseObject(parameter);
283
+        Integer ID= object.getInteger("id");
284
+        List<String> list=new ArrayList<String>();
285
+        List<User> userList=userMapper.selectUser(ID);
286
+        for (User user:userList){
287
+            list.add(user.getRoleId());
288
+        }
289
+        HashMap map= new HashMap<>();
290
+        map.put("userList",userList);
291
+        map.put("roleList",list);
292
+        response.addSuccess(map);
293
+        return response;
294
+    }
295
+
296
+    @Override
297
+    public ResponseBean upDateStatus(String parameter,Integer userID) {
298
+        ResponseBean response = new ResponseBean<>();
299
+        JSONObject object = JSONObject.parseObject(parameter);
300
+        Integer status = object.getInteger("status");
301
+        Integer id = object.getInteger("id");
302
+        User user = new User();
303
+        user.setId(id);
304
+        int st=status.intValue();
305
+        if (st==1){
306
+            user.setStatus("0");
307
+        }else if (st==0){
308
+            user.setStatus("1");
309
+        }
310
+        user.setUpdateUser(userID);
311
+        user.setUpdateDate(LocalDateTime.now());
312
+        userMapper.updateByPrimaryKeySelective(user);
313
+        response.addSuccess("成功");
314
+        return response;
315
+    }
316
+
317
+    //查询多个角色转换为字符串
318
+    public String selectRole(Integer id) {
319
+        List<User> toUser= userMapper.selectRole(id);
320
+        List<String> list=new ArrayList<String>();
321
+        for (User user:toUser){
322
+            list.add(user.getRoleName());
323
+        }
324
+        String result = "";
325
+        if (list != null && list.size() > 0) {
326
+            for (String item : list) {
327
+                // 把列表中的每条数据用逗号分割开来,然后拼接成字符串
328
+                result += item + ",";
329
+
330
+            }
331
+            result = result.substring(0,result.length()-1);
332
+        }
333
+        return result;
334
+    }
335
+
164 336
 }

+ 103
- 0
CODE/smart-community/property-api/src/main/resources/mapper/UserMapper.xml Bestand weergeven

@@ -9,4 +9,107 @@
9 9
         WHERE id=#{id,jdbcType=INTEGER}
10 10
     </select>
11 11
 
12
+    <select id="userList" resultType="com.community.huiju.model.User" >
13
+        SELECT
14
+        sr.role_name,
15
+        sr.description,
16
+        sr.create_user,
17
+        sr.create_date,
18
+        sr.update_date,
19
+        sr.update_user,
20
+        tu.user_name,
21
+        tu.remark,
22
+        tu.login_name,
23
+        tu.status,
24
+        tu.id
25
+        FROM
26
+        tp_user tu
27
+        LEFT JOIN tp_sys_user_role ON tu.id = tp_sys_user_role.user_id
28
+        LEFT JOIN tp_sys_role sr ON tp_sys_user_role.role_id = sr.id
29
+        LEFT JOIN tp_user_community uc ON tu.id=uc.tp_user_id
30
+        group by tp_sys_user_role.user_id
31
+        <where>
32
+            <if test="loginName != null and loginName !=''" >
33
+                and tu.login_name = #{loginName,jdbcType=VARCHAR}
34
+            </if>
35
+            <if test="userName != null and userName !=''" >
36
+                and tu.user_name like concat('%',#{userName,jdbcType=VARCHAR},'%')
37
+            </if>
38
+            and  uc.community_id=#{communityId,jdbcType=INTEGER}
39
+        </where>
40
+    </select>
41
+
42
+    <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.User" >
43
+    update tp_user
44
+    <set >
45
+        <if test="userName != null" >
46
+            user_name = #{userName,jdbcType=VARCHAR},
47
+        </if>
48
+        <if test="loginName != null" >
49
+            login_name = #{loginName,jdbcType=VARCHAR},
50
+        </if>
51
+        <if test="loginPassword != null" >
52
+            login_password = #{loginPassword,jdbcType=VARCHAR},
53
+        </if>
54
+        <if test="email != null" >
55
+            email = #{email,jdbcType=VARCHAR},
56
+        </if>
57
+        <if test="headPortrait != null" >
58
+            head_portrait = #{headPortrait,jdbcType=VARCHAR},
59
+        </if>
60
+        <if test="remark != null" >
61
+            remark = #{remark,jdbcType=VARCHAR},
62
+        </if>
63
+        <if test="status != null" >
64
+            status = #{status,jdbcType=CHAR},
65
+        </if>
66
+        <if test="createUser != null" >
67
+            create_user = #{createUser,jdbcType=INTEGER},
68
+        </if>
69
+        <if test="createDate != null" >
70
+            create_date = #{createDate,jdbcType=TIMESTAMP},
71
+        </if>
72
+        <if test="updateUser != null" >
73
+            update_user = #{updateUser,jdbcType=INTEGER},
74
+        </if>
75
+        <if test="updateDate != null" >
76
+            update_date = #{updateDate,jdbcType=TIMESTAMP},
77
+        </if>
78
+    </set>
79
+    </update>
80
+
81
+    <select id="selectUser"  resultType="com.community.huiju.model.User" >
82
+        SELECT
83
+        sr.role_name,
84
+        sr.description,
85
+        sr.create_user,
86
+        sr.create_date,
87
+        sr.update_date,
88
+        sr.update_user,
89
+        tu.user_name,
90
+        tu.remark,
91
+        tu.login_name,
92
+        tu.status,
93
+        tu.id,
94
+        tp_sys_user_role.role_id
95
+        FROM
96
+        tp_user tu
97
+        LEFT JOIN tp_sys_user_role ON tu.id = tp_sys_user_role.user_id
98
+        LEFT JOIN tp_sys_role sr ON tp_sys_user_role.role_id = sr.id
99
+        WHERE tu.id=#{id,jdbcType=INTEGER}
100
+    </select>
101
+    <select id="selectRole"  resultType="com.community.huiju.model.User" parameterType="int">
102
+        SELECT
103
+        sr.role_name,
104
+        tu.remark,
105
+        tu.login_name,
106
+        tu.id,
107
+        tp_sys_user_role.role_id
108
+        FROM
109
+        tp_user tu
110
+        LEFT JOIN tp_sys_user_role ON tu.id = tp_sys_user_role.user_id
111
+        LEFT JOIN tp_sys_role sr ON tp_sys_user_role.role_id = sr.id
112
+        WHERE tu.id=#{id,jdbcType=INTEGER}
113
+    </select>
114
+
12 115
 </mapper>

+ 21
- 0
VUECODE/smart-operate-manage/src/api/index.js Bestand weergeven

@@ -1,4 +1,6 @@
1
+import axios from 'axios'
1 2
 import request from '@/utils/request'
3
+import { getToken } from '@/utils/auth'
2 4
 
3 5
 // 硬件数据统计
4 6
 export function getHardData() {
@@ -15,3 +17,22 @@ export function getSignUser() {
15 17
     method: 'get'
16 18
   })
17 19
 }
20
+
21
+// 硬件数据统计
22
+export function setUpConnection() {
23
+  return new Promise((resolve, reject) => {
24
+    axios({
25
+      url: '/mq/connection',
26
+      method: 'get',
27
+      baseURL: process.env.BASE_API,
28
+      timeout: 10000,
29
+      headers: {
30
+        'X-Auth-Token': getToken(),
31
+        'Login-Type': 'web'
32
+      }
33
+    }).then(response => {
34
+      resolve(response.data)
35
+    }).catch(e => reject(e))
36
+  })
37
+}
38
+

+ 54
- 1
VUECODE/smart-operate-manage/src/api/user.js Bestand weergeven

@@ -25,4 +25,57 @@ export function userRoleById(data) {
25 25
     }
26 26
   })
27 27
 }
28
-
28
+// 添加用户角色
29
+export function addUser(data) {
30
+  return request({
31
+    url: '/user/addUser',
32
+    method: 'post',
33
+    data: {
34
+      pageNum: data.pageNum,
35
+      pageSize: data.pageSize,
36
+      roleName: data.roleName,
37
+      remark: data.remark,
38
+      userName: data.userName,
39
+      loginName: data.loginName,
40
+      menuArray: data.menuArray
41
+    }
42
+  })
43
+}
44
+// 查看用户角色
45
+export function selectUser(data) {
46
+  return request({
47
+    url: '/user/selectById',
48
+    method: 'post',
49
+    data: {
50
+      id: data.id
51
+    }
52
+  })
53
+}
54
+// 修改用户角色
55
+export function upDate(data) {
56
+  return request({
57
+    url: '/user/upDate',
58
+    method: 'post',
59
+    data: {
60
+      id: data.id,
61
+      pageNum: data.pageNum,
62
+      pageSize: data.pageSize,
63
+      roleName: data.roleName,
64
+      remark: data.remark,
65
+      userName: data.userName,
66
+      loginName: data.loginName,
67
+      menuArray: data.menuArray
68
+    }
69
+  })
70
+}
71
+// 修改用户当前状态
72
+export function upDateStatus(data) {
73
+  return request({
74
+    url: '/user/upDateStatus',
75
+    method: 'post',
76
+    data: {
77
+      id: data.id,
78
+      status: data.status
79
+    }
80
+  })
81
+}

+ 53
- 20
VUECODE/smart-operate-manage/src/components/chart/chart3.vue Bestand weergeven

@@ -20,16 +20,20 @@
20 20
 import { mapState, mapActions } from 'vuex'
21 21
 
22 22
 export default {
23
+  props: [
24
+    'arr'
25
+  ],
23 26
   data() {
24 27
     return {
25
-      arr: [
26
-        { text: '小区门禁开启', num: '13400次', active: false },
27
-        { text: '单元门开启', num: '12788次', active: false },
28
-        { text: '车辆进入数量', num: '5664辆', active: false },
29
-        { text: '咖啡厅销量', num: '3994次', active: false },
30
-        { text: '智慧食堂销量', num: '5664人次', active: false },
31
-        { text: '健身房健身', num: '1255人次', active: false }
32
-      ]
28
+      longPoll: true,
29
+      // arr: [
30
+      //   { text: '小区门禁开启', num: '13400次', active: false },
31
+      //   { text: '单元门开启', num: '12788次', active: false },
32
+      //   { text: '车辆进入数量', num: '5664辆', active: false },
33
+      //   { text: '咖啡厅销量', num: '3994次', active: false },
34
+      //   { text: '智慧食堂销量', num: '5664人次', active: false },
35
+      //   { text: '健身房健身', num: '1255人次', active: false }
36
+      // ]
33 37
     }
34 38
   },
35 39
   computed: {
@@ -37,22 +41,51 @@ export default {
37 41
       hardData: item => item.trunkIndex.hardData
38 42
     })
39 43
   },
44
+  // beforeRouteEnter (to, from, next) {
45
+  //   next(vm => {
46
+  //     vm.longPoll = true
47
+  //     const foo = () => {
48
+  //       if (!vm.longPoll) return
49
+
50
+  //       vm.SetUpConnection().then(() => {
51
+  //         vm.hardData.forEach(item => {
52
+  //           if (item.message === '小区开门次数') {
53
+  //             vm.arr[0].num = item.count + '次'
54
+  //           } else if (item.message === '单元门开门次数') {
55
+  //             vm.arr[1].num = item.count + '次'
56
+  //           }
57
+  //         })
58
+  //         vm.arr = JSON.parse(JSON.stringify(vm.arr))
59
+  //         foo()
60
+  //       }).catch(() => {
61
+  //         foo()
62
+  //       })
63
+  //     }
64
+  //     foo()
65
+  //   })
66
+  // },
67
+  // beforeRouteLeave(to, from, next) {
68
+  //   this.longPoll = false
69
+  //   next()
70
+  // },
40 71
   created() {
41
-    this.GetHardData().then(() => {
42
-      console.log(this.hardData)
43
-      this.hardData.forEach(item => {
44
-        if (item.message === '小区开门次数') {
45
-          this.arr[0].num = item.count + '次'
46
-        } else if (item.message === '单元门开门次数') {
47
-          this.arr[1].num = item.count + '次'
48
-        }
49
-      })
50
-      this.arr = JSON.parse(JSON.stringify(this.arr))
51
-    })
72
+    // this.GetHardData().then(() => {
73
+    //   console.log(this.hardData)
74
+    //   this.hardData.forEach(item => {
75
+    //     if (item.message === '小区开门次数') {
76
+    //       this.arr[0].num = item.count + '次'
77
+    //     } else if (item.message === '单元门开门次数') {
78
+    //       this.arr[1].num = item.count + '次'
79
+    //     }
80
+    //   })
81
+    //   this.arr = JSON.parse(JSON.stringify(this.arr))
82
+    // })
83
+
52 84
   },
53 85
   methods: {
54 86
     ...mapActions('trunkIndex', [
55
-      'GetHardData'
87
+      'GetHardData',
88
+      'SetUpConnection'
56 89
     ])
57 90
   }
58 91
 }

+ 7
- 0
VUECODE/smart-operate-manage/src/router/index.js Bestand weergeven

@@ -148,6 +148,13 @@ export const constantRouterMap = [
148 148
         name: 'user-addUser',
149 149
         hidden: true,
150 150
         meta: { title: '添加成员', icon: 'table' }
151
+      },
152
+      {
153
+        path: '/account/user/edit',
154
+        component: () => import('@/views/account/user/edit'),
155
+        name: 'user-edit',
156
+        hidden: true,
157
+        meta: { title: '添加成员', icon: 'table' }
151 158
       }
152 159
     ]
153 160
   },

+ 14
- 1
VUECODE/smart-operate-manage/src/store/modules/trunkIndex.js Bestand weergeven

@@ -1,4 +1,4 @@
1
-import { getHardData, getSignUser } from '@/api/index'
1
+import { getHardData, getSignUser, setUpConnection } from '@/api/index'
2 2
 
3 3
 const trunkIndex = {
4 4
   namespaced: true,
@@ -30,6 +30,19 @@ const trunkIndex = {
30 30
       })
31 31
     },
32 32
 
33
+    // 建立长连接
34
+    SetUpConnection({ commit }) {
35
+      return new Promise((resolve, reject) => {
36
+        setUpConnection().then(response => {
37
+          const data = response.data
38
+          commit('upDateHardData', data)
39
+          resolve()
40
+        }).catch(error => {
41
+          reject(error)
42
+        })
43
+      })
44
+    },
45
+
33 46
     // 注册用户统计
34 47
     GetSignUser({ commit }) {
35 48
       return new Promise((resolve, reject) => {

+ 42
- 3
VUECODE/smart-operate-manage/src/store/modules/user.js Bestand weergeven

@@ -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, userRoleById } from '@/api/user'
3
+import { employeesList, userRoleById, addUser, selectUser, upDate, upDateStatus } from '@/api/user'
4 4
 
5 5
 const user = {
6 6
   state: {
@@ -112,7 +112,7 @@ const user = {
112 112
       })
113 113
     },
114 114
     // 查询角色 UserRoleById
115
-    UserRoleById({ commit, state }, data) { // 查询活动详情
115
+    UserRoleById({ commit, state }, data) {
116 116
       return new Promise((resolve, reject) => {
117 117
         userRoleById(data).then(response => {
118 118
           resolve(response)
@@ -120,8 +120,47 @@ const user = {
120 120
           reject(error)
121 121
         })
122 122
       })
123
+    },
124
+    // 添加成员角色
125
+    AddUser({ commit, state }, data) {
126
+      return new Promise((resolve, reject) => {
127
+        addUser(data).then(response => {
128
+          resolve(response)
129
+        }).catch(error => {
130
+          reject(error)
131
+        })
132
+      })
133
+    },
134
+    // 获取成员信息
135
+    SelectUser({ commit, state }, data) {
136
+      return new Promise((resolve, reject) => {
137
+        selectUser(data).then(response => {
138
+          resolve(response)
139
+        }).catch(error => {
140
+          reject(error)
141
+        })
142
+      })
143
+    },
144
+    // 修改成员信息
145
+    UpDate({ commit, state }, data) {
146
+      return new Promise((resolve, reject) => {
147
+        upDate(data).then(response => {
148
+          resolve(response)
149
+        }).catch(error => {
150
+          reject(error)
151
+        })
152
+      })
153
+    },
154
+    // 修改成员状态(停用或者启用)
155
+    UpDateStatus({ commit, state }, data) {
156
+      return new Promise((resolve, reject) => {
157
+        upDateStatus(data).then(response => {
158
+          resolve(response)
159
+        }).catch(error => {
160
+          reject(error)
161
+        })
162
+      })
123 163
     }
124 164
   }
125 165
 }
126
-
127 166
 export default user

+ 95
- 85
VUECODE/smart-operate-manage/src/views/account/user/addUser.vue Bestand weergeven

@@ -1,127 +1,137 @@
1 1
 <template>
2 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"/>
3
+    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
4
+      <el-form-item label="名称" prop="userName">
5
+        <el-input v-model="ruleForm.userName"/>
6 6
       </el-form-item>
7
-      <el-form-item label="手机号:" prop="description">
8
-        <el-input v-model="listQuery.description"/>
7
+     <el-form-item class="filter-item" label="手机号" prop="loginName" >
8
+        <el-input v-model.trim="ruleForm.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
9 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"/>
10
+      <el-form-item label="角色" prop="menuArray">
11
+        <!-- default-expanded-keys 展示选中的
12
+             default-checked-keys 勾上选中的-->
13
+        <el-tree
14
+          ref="tree"
15
+          :data="menuData"
16
+          :default-expanded-keys="ruleForm.menuArray"
17
+          :default-checked-keys="ruleForm.menuArray"
18
+          :props="defaultProps"
19
+          show-checkbox
20
+          node-key="id"
21
+          @check-change="handleCheckChange"/>
22
+      </el-form-item>
23
+      <el-form-item label="备注" prop="remark">
24
+        <el-input v-model="ruleForm.remark"/>
20 25
       </el-form-item>
21 26
       <el-form-item>
22
-        <el-button type="primary">立即创建</el-button>
27
+        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
23 28
       </el-form-item>
24 29
     </el-form>
25 30
   </div>
26 31
 </template>
27 32
 
28 33
 <script>
29
-import { mapActions } from 'vuex'
30 34
 export default {
31 35
   data() {
32 36
     return {
33
-      listQuery: {
34
-        id: '',  
37
+      ruleForm: {
38
+        id: '',
39
+        userName: '',
40
+        loginName:'',
41
+        remark: '',
35 42
         roleName: '',
36
-        description: '',
37
-        menuArray: [], // 已选中的权限资源
43
+        createUser: '',
44
+        updateUser: '',
45
+        updateDate: '',
38 46
         pageNum: 1,
39
-        pageSize:100
47
+        pageSize: 10,
48
+        menuArray: [] // 已选中的权限资源
49
+      },
50
+      menuData: [], // 所有权限资源
51
+      defaultProps: { // 设置树形节点的渲染的属性
52
+        id: 'id',
53
+        label: 'roleName',
54
+        children: 'children'
40 55
       },
41
-       va3:[], 
42
-       value2:[1,4],
43
-       dataList:[],
44
-       citiesList:['上海', '北京', '广州', '深圳', '南京', '西安'],
45
-       pinyinList:['上海', '北京', '广州', '深圳', '南京', '西安', '成都'],
46 56
       rules: {
47 57
         roleName: [
48
-          { required: true, message: '请输入名称', trigger: 'blur' }
58
+          { required: true, message: '名称', trigger: 'blur' }
49 59
         ],
50
-        description: [
60
+        loginName: [
51 61
           { required: true, message: '请输入手机号', trigger: 'blur' }
52 62
         ],
63
+        
53 64
       }
54 65
     }
55 66
   },
56 67
   mounted() {
57
-      this.getById()
58
-    //    this.roleBox()
68
+     this.getById()
59 69
   },
60 70
   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)
71
+    submitForm(formName) {
72
+      // 获取选中的树形节点 key
73
+      this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
74
+      this.$refs[formName].validate((valid) => {
75
+        const loading = this.$loading({
76
+          lock: true,
77
+          text: 'Loading',
78
+          spinner: 'el-icon-loading',
79
+          background: 'rgba(0, 0, 0, 0.7)'
80
+        })
81
+        if (valid) {
82
+          console.log('this.roleName',this.roleName)
83
+          this.$store.dispatch('AddUser', this.ruleForm).then((res) => {
84
+            const resCode = res.code
85
+            this.ruleForm.id=''
86
+            if (resCode === '0') {
87
+              this.$message({
88
+                message: res.message,
89
+                type: 'success'
90
+              })
91
+              loading.close()
92
+              this.$router.push({ name: 'user-index' })
93
+            }
94
+          }).catch(() => {
95
+            console.log('error AddUser')
96
+            loading.close()
97
+          })
98
+        } else {
99
+          console.log('error submit!!')
100
+          loading.close()
101
+          return false
70 102
         }
71 103
       })
72 104
     },
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
-  }    
105
+    resetForm(formName) {
106
+      this.$refs[formName].resetFields()
107
+    },
108
+    handleCheckChange(data, checked, indeterminate) { // 树形图选择事件
109
+      console.log(data, checked, indeterminate)
110
+    },
111
+    getMenuList() { // 获取 菜单列表
112
+      this.$store.dispatch('GetMenuList').then((res) => {
113
+        this.menuData = res.data
114
+      }).catch(() => {
115
+        console.log('error GetMenuList')
116
+      })
117
+    },
118
+    getById(){
119
+    this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
120
+      this.menuData = res.data.list
121
+      console.log(this.menuData)
122
+    }).catch(() => {
123
+      console.log('error UserRoleById')
124
+    })
113 125
 }
126
+  }
127
+  }
114 128
 </script>
115 129
 
116 130
 <style scoped>
117
-.demo-listQuery {
131
+.demo-ruleForm {
118 132
   width: 500px;
119 133
   margin-top: 20px;
120 134
   margin-left: auto;
121 135
   margin-right: auto;
122 136
 }
123
-#button-checked{
124
-     float:right;
125
-     margin-right: 50px; 
126
-}
127 137
 </style>

+ 156
- 0
VUECODE/smart-operate-manage/src/views/account/user/edit.vue Bestand weergeven

@@ -0,0 +1,156 @@
1
+<template>
2
+  <div id="root">
3
+    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
4
+      <el-form-item label="名称" prop="userName">
5
+        <el-input v-model="ruleForm.userName"/>
6
+      </el-form-item>
7
+     <el-form-item class="filter-item" label="手机号" prop="loginName" >
8
+        <el-input v-model.trim="ruleForm.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
9
+      </el-form-item>
10
+      <el-form-item label="角色" prop="menuArray">
11
+        <!-- default-expanded-keys 展示选中的
12
+             default-checked-keys 勾上选中的-->
13
+        <el-tree
14
+          ref="tree"
15
+          :data="menuData"
16
+          :default-expanded-keys="ruleForm.menuArray"
17
+          :default-checked-keys="ruleForm.menuArray"
18
+          :props="defaultProps"
19
+          show-checkbox
20
+          node-key="id"
21
+          @check-change="handleCheckChange"/>
22
+      </el-form-item>
23
+      <el-form-item label="备注" prop="remark">
24
+        <el-input v-model="ruleForm.remark"/>
25
+      </el-form-item>
26
+      <el-form-item>
27
+        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
28
+      </el-form-item>
29
+    </el-form>
30
+  </div>
31
+</template>
32
+
33
+<script>
34
+export default {
35
+  data() {
36
+    return {
37
+      ruleForm: {
38
+        id: '',
39
+        userName: '',
40
+        loginName:'',
41
+        remark: '',
42
+        roleName: '',
43
+        createUser: '',
44
+        updateUser: '',
45
+        updateDate: '',
46
+        pageNum: 1,
47
+        pageSize: 10,
48
+        menuArray: [] // 已选中的权限资源
49
+      },
50
+      menuData: [], // 所有权限资源
51
+      defaultProps: { // 设置树形节点的渲染的属性
52
+        id: 'id',
53
+        label: 'roleName',
54
+        children: 'children'
55
+      },
56
+      rules: {
57
+        roleName: [
58
+          { required: true, message: '名称', trigger: 'blur' }
59
+        ],
60
+        loginName: [
61
+          { required: true, message: '请输入手机号', trigger: 'blur' }
62
+        ],
63
+        
64
+      }
65
+    }
66
+  },
67
+  mounted() {
68
+     this.selectUser(this.$route.params.id)
69
+     console.log('this.$route.params.id',this.$route.params.id)
70
+     this.getById()
71
+  },
72
+  methods: {
73
+    submitForm(formName) {
74
+      // 获取选中的树形节点 key
75
+      this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
76
+      this.$refs[formName].validate((valid) => {
77
+        const loading = this.$loading({
78
+          lock: true,
79
+          text: 'Loading',
80
+          spinner: 'el-icon-loading',
81
+          background: 'rgba(0, 0, 0, 0.7)'
82
+        })
83
+        if (valid) {
84
+          console.log('this.roleName',this.roleName)
85
+          this.$store.dispatch('UpDate', this.ruleForm).then((res) => {
86
+            const resCode = res.code
87
+            if (resCode === '0') {
88
+              this.$message({
89
+                message: res.message,
90
+                type: 'success'
91
+              })
92
+              loading.close()
93
+              this.$router.push({ name: 'user-index' })
94
+            }
95
+          }).catch(() => {
96
+            console.log('error AddUser')
97
+            loading.close()
98
+          })
99
+        } else {
100
+          console.log('error submit!!')
101
+          loading.close()
102
+          return false
103
+        }
104
+      })
105
+    },
106
+    resetForm(formName) {
107
+      this.$refs[formName].resetFields()
108
+    },
109
+    handleCheckChange(data, checked, indeterminate) { // 树形图选择事件
110
+      console.log(data, checked, indeterminate)
111
+    },
112
+    getMenuList() { // 获取 菜单列表
113
+      this.$store.dispatch('GetMenuList').then((res) => {
114
+        this.menuData = res.data
115
+      }).catch(() => {
116
+        console.log('error GetMenuList')
117
+      })
118
+    },
119
+    getById(){
120
+    this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
121
+      this.menuData = res.data.list
122
+      console.log(this.menuData)
123
+    }).catch(() => {
124
+      console.log('error UserRoleById')
125
+    })
126
+},
127
+  selectUser(id){
128
+    this.ruleForm.id=id
129
+    this.$store.dispatch('SelectUser', this.ruleForm).then((res) => {
130
+      // this.ruleForm.loginName = res.data.loginName
131
+      // this.ruleForm=res.data[0]
132
+        // this.ruleForm.loginName.push(res.data[0])
133
+        this.ruleForm.loginName=res.data.userList[0].loginName
134
+         this.ruleForm.userName=res.data.userList[0].userName
135
+         this.ruleForm.remark=res.data.userList[0].remark
136
+         this.ruleForm.menuArray=res.data.roleList
137
+        console.log('res.data',res.data)
138
+
139
+    }).catch(() => {
140
+      console.log('error SelectUser')
141
+    })
142
+
143
+
144
+  }
145
+  }
146
+  }
147
+</script>
148
+
149
+<style scoped>
150
+.demo-ruleForm {
151
+  width: 500px;
152
+  margin-top: 20px;
153
+  margin-left: auto;
154
+  margin-right: auto;
155
+}
156
+</style>

+ 46
- 25
VUECODE/smart-operate-manage/src/views/account/user/index.vue Bestand weergeven

@@ -14,7 +14,7 @@
14 14
     </el-form>
15 15
     <div class="button">
16 16
       <el-button type="primary" @click="addUser">添加</el-button>
17
-      <el-button type="warning" >修改</el-button>
17
+      <el-button type="warning" @click="upDate">修改</el-button>
18 18
     </div>
19 19
     <el-table
20 20
       v-loading="listLoading"
@@ -36,7 +36,7 @@
36 36
       <el-table-column prop="updateNmae" label="修改人" align="center"/>
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
-          <template slot-scope="scope"><a><span style="color: #63B8FF" @click="clickTitle(scope.row.id)">{{ scope.row.status =='1' ? '停用账号':'启用账号' }}</span></a></template>
39
+          <template slot-scope="scope"><a><span style="color: #63B8FF" @click="upDateStatus(scope.row.id,scope.row.status)">{{ scope.row.status =='1' ? '停用账号':'启用账号' }}</span></a></template>
40 40
       <!-- <a><template slot-scope="scope">
41 41
           <span v-if="scope.row.status==1">{{ '停用账号' }}</span>
42 42
           <span v-if="scope.row.status==0">{{ '启用账号' }}</span>
@@ -70,6 +70,7 @@ export default {
70 70
         createUser: '',
71 71
         updateUser: '',
72 72
         updateDate: '',
73
+        status : '',
73 74
         pageNum: 1,
74 75
         pageSize: 10
75 76
       },
@@ -101,34 +102,33 @@ export default {
101 102
       value = value < 10 ? '0' + value : value
102 103
       return value
103 104
     },
104
-    getStatus(row) { // 获取状态
105
-      let statusName = ''
105
+    // getStatus(row) { // 获取状态
106
+    //   let statusName = ''
106 107
 
107
-      // 判断状态
108
-      switch (row.status) {
109
-        case '0':
110
-          statusName = '已作废'
111
-          break
112
-        case '1':
113
-          statusName = '已发布'
114
-          break
115
-        case '2':
116
-          statusName = '草稿'
117
-          break
118
-      }
108
+    //   // 判断状态
109
+    //   switch (row.status) {
110
+    //     case '0':
111
+    //       statusName = '已作废'
112
+    //       break
113
+    //     case '1':
114
+    //       statusName = '已发布'
115
+    //       break
116
+    //     case '2':
117
+    //       statusName = '草稿'
118
+    //       break
119
+    //   }
119 120
 
120
-      // 如果修改时间和创建时间不一致, 就显示已修改
121
-      if (row.status === '1' && (row.updateDate > row.createDate)) {
122
-        statusName = '已修改'
123
-      }
121
+    //   // 如果修改时间和创建时间不一致, 就显示已修改
122
+    //   if (row.status === '1' && (row.updateDate > row.createDate)) {
123
+    //     statusName = '已修改'
124
+    //   }
124 125
 
125
-      return statusName
126
-    },
126
+    //   return statusName
127
+    // },
127 128
     dataQuery() { // 查询数据
128 129
       this.listLoading = true
129 130
       this.$store.dispatch('EmployeesList', this.listQuery).then((res) => {
130 131
          this.listDate = res.item
131
-        console.log('resData1',this.listDate)
132 132
         this.list = res.item
133 133
         this.total = res.total
134 134
         this.listLoading = false
@@ -136,6 +136,7 @@ export default {
136 136
         this.listLoading = false
137 137
         console.log('error EmployeesList')
138 138
       })
139
+      
139 140
     },
140 141
     handleSelectionChange(data) {
141 142
       // 设置为 空
@@ -171,9 +172,29 @@ export default {
171 172
     },
172 173
     addUser(){
173 174
     this.$router.push({ name: 'user-addUser' })
175
+     this.listQuery.id=''
176
+    },
177
+    upDate(){
178
+      //  this.$router.push({ name: 'user-edit' })
179
+       const ids = this.deleteIds[0]
180
+          this.$router.push({ name: 'user-edit', params: { id: ids }})
181
+    },
182
+    upDateStatus(id,status){
183
+      this.listQuery.id=id
184
+      this.listQuery.status=status
185
+      this.$store.dispatch('UpDateStatus', this.listQuery).then((res) => {
186
+        console.log('res',res)
187
+        this.dataQuery()
188
+        this.listLoading = false
189
+      }).catch(() => {
190
+        this.listLoading = false
191
+        console.log('error UpDateStatus')
192
+      })
174 193
     }
175
-  }
176
-}
194
+    }
195
+    }
196
+  
197
+
177 198
 </script>
178 199
 
179 200
 <style scoped>

+ 87
- 1
VUECODE/smart-operate-manage/src/views/index/index.vue Bestand weergeven

@@ -3,7 +3,7 @@
3 3
     <div class="left">
4 4
       <chart1/>
5 5
       <chart2/>
6
-      <chart3/>
6
+      <chart3 :arr="arr"/>
7 7
     </div>
8 8
     <div class="middle">
9 9
       <chart4/>
@@ -24,6 +24,7 @@ import chart4 from '@/components/chart/chart4.vue'
24 24
 import chart5 from '@/components/chart/chart5.vue'
25 25
 import chart6 from '@/components/chart/chart6.vue'
26 26
 import chart7 from '@/components/chart/chart7.vue'
27
+import { mapState, mapActions } from 'vuex'
27 28
 
28 29
 export default {
29 30
   components: {
@@ -34,6 +35,91 @@ export default {
34 35
     chart5,
35 36
     chart6,
36 37
     chart7
38
+  },
39
+  data() {
40
+    return {
41
+      longPoll: true,
42
+      // arr: [
43
+      //   { text: '小区门禁开启', num: '13400次', active: false },
44
+      //   { text: '单元门开启', num: '12788次', active: false },
45
+      //   { text: '车辆进入数量', num: '5664辆', active: false },
46
+      //   { text: '咖啡厅销量', num: '3994次', active: false },
47
+      //   { text: '智慧食堂销量', num: '5664人次', active: false },
48
+      //   { text: '健身房健身', num: '1255人次', active: false }
49
+      // ]
50
+    }
51
+  },
52
+  computed: {
53
+    ...mapState('trunkIndex', {
54
+      hardData: item => item.trunkIndex.hardData
55
+    }),
56
+    arr() {
57
+      let num1, num2
58
+
59
+      const rawData = !this.hardData ? [] : this.hardData
60
+      rawData.forEach(item => {
61
+        if (item.message === '小区开门次数') {
62
+          num1 = item.count
63
+        } else if (item.message === '单元门开门次数') {
64
+          num2 = item.count
65
+        }
66
+      })
67
+
68
+      return [
69
+        { text: '小区门禁开启', num: `${num1}次`, active: false },
70
+        { text: '单元门开启', num: `${num2}次`, active: false },
71
+        { text: '车辆进入数量', num: '5664辆', active: false },
72
+        { text: '咖啡厅销量', num: '3994次', active: false },
73
+        { text: '智慧食堂销量', num: '5664人次', active: false },
74
+        { text: '健身房健身', num: '1255人次', active: false }
75
+      ]
76
+    }
77
+  },
78
+  beforeRouteEnter (to, from, next) {
79
+    next(vm => {
80
+      vm.longPoll = true
81
+      const foo = () => {
82
+        if (!vm.longPoll) return
83
+
84
+        vm.SetUpConnection().then(() => {
85
+          // vm.hardData.forEach(item => {
86
+          //   if (item.message === '小区开门次数') {
87
+          //     vm.arr[0].num = item.count + '次'
88
+          //   } else if (item.message === '单元门开门次数') {
89
+          //     vm.arr[1].num = item.count + '次'
90
+          //   }
91
+          // })
92
+          vm.arr = JSON.parse(JSON.stringify(vm.arr))
93
+          foo()
94
+        }).catch(() => {
95
+          foo()
96
+        })
97
+      }
98
+      foo()
99
+    })
100
+  },
101
+  beforeRouteLeave(to, from, next) {
102
+    this.longPoll = false
103
+    next()
104
+  },
105
+  created() {
106
+    this.GetHardData().then(() => {
107
+      // console.log(this.hardData)
108
+      // this.hardData.forEach(item => {
109
+      //   if (item.message === '小区开门次数') {
110
+      //     this.arr[0].num = item.count + '次'
111
+      //   } else if (item.message === '单元门开门次数') {
112
+      //     this.arr[1].num = item.count + '次'
113
+      //   }
114
+      // })
115
+      // this.arr = JSON.parse(JSON.stringify(this.arr))
116
+    })
117
+  },
118
+  methods: {
119
+    ...mapActions('trunkIndex', [
120
+      'GetHardData',
121
+      'SetUpConnection'
122
+    ])
37 123
   }
38 124
 }
39 125
 

+ 81
- 0
VUECODE/smart-property-manage/src/api/user.js Bestand weergeven

@@ -0,0 +1,81 @@
1
+import request from '@/utils/request'
2
+
3
+// 根据条件查询成员
4
+export function employeesList(data) {
5
+  return request({
6
+    url: '/user/userList',
7
+    method: 'post',
8
+    data: {
9
+      loginName: data.loginName,
10
+      userName: data.userName,
11
+      pageNum: data.pageNum,
12
+      pageSize: data.pageSize
13
+    }
14
+  })
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
+}
28
+// 添加用户角色
29
+export function addUser(data) {
30
+  return request({
31
+    url: '/user/addUser',
32
+    method: 'post',
33
+    data: {
34
+      pageNum: data.pageNum,
35
+      pageSize: data.pageSize,
36
+      roleName: data.roleName,
37
+      remark: data.remark,
38
+      userName: data.userName,
39
+      loginName: data.loginName,
40
+      menuArray: data.menuArray
41
+    }
42
+  })
43
+}
44
+// 查看用户角色
45
+export function selectUser(data) {
46
+  return request({
47
+    url: '/user/selectById',
48
+    method: 'post',
49
+    data: {
50
+      id: data.id
51
+    }
52
+  })
53
+}
54
+// 修改用户角色
55
+export function upDate(data) {
56
+  return request({
57
+    url: '/user/upDate',
58
+    method: 'post',
59
+    data: {
60
+      id: data.id,
61
+      pageNum: data.pageNum,
62
+      pageSize: data.pageSize,
63
+      roleName: data.roleName,
64
+      remark: data.remark,
65
+      userName: data.userName,
66
+      loginName: data.loginName,
67
+      menuArray: data.menuArray
68
+    }
69
+  })
70
+}
71
+// 修改用户当前状态
72
+export function upDateStatus(data) {
73
+  return request({
74
+    url: '/user/upDateStatus',
75
+    method: 'post',
76
+    data: {
77
+      id: data.id,
78
+      status: data.status
79
+    }
80
+  })
81
+}

+ 1
- 1
VUECODE/smart-property-manage/src/router/index.js Bestand weergeven

@@ -183,7 +183,7 @@ export const constantRouterMap = [
183 183
     children: [
184 184
       {
185 185
         path: '/account/user',
186
-        component: () => import('@/views/account/user'),
186
+        component: () => import('@/views/account/user/index'),
187 187
         name: 'user-index',
188 188
         meta: { title: '员工管理', icon: 'table' }
189 189
       },

+ 62
- 0
VUECODE/smart-property-manage/src/store/modules/user.js Bestand weergeven

@@ -1,5 +1,6 @@
1 1
 import { login, logOut, getInfo, sendCode } from '@/api/login'
2 2
 import { getToken, setToken, removeToken } from '@/utils/auth'
3
+import { employeesList, userRoleById, addUser, selectUser, upDate, upDateStatus } from '@/api/user'
3 4
 
4 5
 const user = {
5 6
   state: {
@@ -99,6 +100,67 @@ const user = {
99 100
         removeToken()
100 101
         resolve()
101 102
       })
103
+    },
104
+    // 根据条件查询 employeesList
105
+    EmployeesList({ commit }, listQuery) {
106
+      return new Promise((resolve, reject) => {
107
+        employeesList(listQuery).then(response => {
108
+          const data = response.data
109
+          resolve(data)
110
+        }).catch(error => {
111
+          reject(error)
112
+        })
113
+      })
114
+    },
115
+    // 查询角色 UserRoleById
116
+    UserRoleById({ commit, state }, data) {
117
+      return new Promise((resolve, reject) => {
118
+        userRoleById(data).then(response => {
119
+          resolve(response)
120
+        }).catch(error => {
121
+          reject(error)
122
+        })
123
+      })
124
+    },
125
+    // 添加成员角色
126
+    AddUser({ commit, state }, data) {
127
+      return new Promise((resolve, reject) => {
128
+        addUser(data).then(response => {
129
+          resolve(response)
130
+        }).catch(error => {
131
+          reject(error)
132
+        })
133
+      })
134
+    },
135
+    // 获取成员信息
136
+    SelectUser({ commit, state }, data) {
137
+      return new Promise((resolve, reject) => {
138
+        selectUser(data).then(response => {
139
+          resolve(response)
140
+        }).catch(error => {
141
+          reject(error)
142
+        })
143
+      })
144
+    },
145
+    // 修改成员信息
146
+    UpDate({ commit, state }, data) {
147
+      return new Promise((resolve, reject) => {
148
+        upDate(data).then(response => {
149
+          resolve(response)
150
+        }).catch(error => {
151
+          reject(error)
152
+        })
153
+      })
154
+    },
155
+    // 修改成员状态(停用或者启用)
156
+    UpDateStatus({ commit, state }, data) {
157
+      return new Promise((resolve, reject) => {
158
+        upDateStatus(data).then(response => {
159
+          resolve(response)
160
+        }).catch(error => {
161
+          reject(error)
162
+        })
163
+      })
102 164
     }
103 165
   }
104 166
 }

+ 0
- 262
VUECODE/smart-property-manage/src/views/account/user.vue Bestand weergeven

@@ -1,262 +0,0 @@
1
-<template>
2
-  <div class="app-container">
3
-    <span>这个是用户相关的页面</span>
4
-    <div class="filter-container">
5
-      <el-input v-model="listQuery.transactionId" placeholder="帖子编号" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"/>
6
-      <el-input v-model="listQuery.transactionTitle" placeholder="帖子标题" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"/>
7
-      <el-select v-model="listQuery.status" placeholder="发布状态" style="width: 130px" class="filter-item">
8
-        <el-option label="已发布" value="1"/>
9
-        <el-option label="已作废" value="0"/>
10
-      </el-select>
11
-      <el-select v-model="listQuery.isReported" placeholder="是否被举报" class="filter-item" style="width: 130px">
12
-        <el-option label="无举报" value="0"/>
13
-        <el-option label="被举报" value="1"/>
14
-      </el-select>
15
-      <el-button v-waves class="filter-item" type="info" @click="clearListQuery">清空</el-button>
16
-      <el-button v-waves class="filter-item" type="primary" @click="handleFilter">查询</el-button>
17
-    </div>
18
-
19
-    <el-table
20
-      v-loading="listLoading"
21
-      :key="tableKey"
22
-      :data="transactionList"
23
-      border
24
-      fit
25
-      highlight-current-row
26
-      style="width: 100%; margin-top: 20px;"
27
-      @sort-change="sortChange">
28
-      <el-table-column label="编号" align="center">
29
-        <template slot-scope="scope">
30
-          <span>{{ scope.row.id }}</span>
31
-        </template>
32
-      </el-table-column>
33
-      <el-table-column label="类型" align="center">
34
-        <template slot-scope="scope">
35
-          <span v-if="scope.row.type === '0'">二手</span>
36
-          <span v-if="scope.row.type === '1'">求购</span>
37
-          <span v-if="scope.row.type === '2'">租赁</span>
38
-        </template>
39
-      </el-table-column>
40
-      <el-table-column label="标题" align="center">
41
-        <template slot-scope="scope">
42
-          <span @click="handleLook(scope.row.id)" style="color: #409EFF;cursor: pointer">{{ scope.row.transactionTitle }}</span>
43
-        </template>
44
-      </el-table-column>
45
-      <el-table-column label="查看人数" align="center">
46
-        <template slot-scope="scope">
47
-          <span>{{ scope.row.viewCount }}</span>
48
-        </template>
49
-      </el-table-column>
50
-      <el-table-column label="发布人" align="center">
51
-        <template slot-scope="scope">
52
-          <span>{{ scope.row.userName }}</span>
53
-        </template>
54
-      </el-table-column>
55
-      <el-table-column label="发布时间" align="center">
56
-        <template slot-scope="scope">
57
-          <span>{{ formatDate(scope.row.createDate) }}</span>
58
-        </template>
59
-      </el-table-column>
60
-      <el-table-column label="发布状态" align="center">
61
-        <template slot-scope="scope">
62
-          <span v-if="scope.row.status === '0'">已作废</span>
63
-          <span v-if="scope.row.status === '1'">已发布</span>
64
-        </template>
65
-      </el-table-column>
66
-      <el-table-column label="举报状态" align="center">
67
-        <template slot-scope="scope">
68
-          <span>{{ scope.row.isReported === '1' ? "被举报" : "无举报" }}</span>
69
-        </template>
70
-      </el-table-column>
71
-    </el-table>
72
-
73
-    <!-- <pagination v-show="total>0" :total="total" :current-page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" :page-sizes="[5, 10, 20, 30]" @pagination="getList" /> -->
74
-    <el-pagination
75
-      :total="total"
76
-      :current-page="listQuery.pageNum"
77
-      :page-sizes="[5, 10, 20, 30]"
78
-      :page-size="listQuery.pageSize"
79
-      layout="total, sizes, prev, pager, next, jumper"
80
-      @size-change="handleSizeChange"
81
-      @current-change="handleCurrentChange"/>
82
-
83
-  </div>
84
-</template>
85
-
86
-<script>
87
-import { mapState, mapActions, mapMutations } from 'vuex'
88
-import waves from '@/directive/waves' // Waves directive
89
-import { parseTime } from '@/utils'
90
-
91
-export default {
92
-  computed: {
93
-    ...mapState('transaction', {
94
-      transactionList: s => s.transactionList,
95
-      total: s => s.total
96
-    })
97
-  },
98
-  directives: { waves },
99
-  data() {
100
-    var _self = this
101
-    return {
102
-      events: {
103
-        click: (e) => {
104
-          // _self.postData.Coordinate = e.lnglat.lat + ',' + e.lnglat.lng
105
-          _self.detail.longitude = e.lnglat.lng
106
-          _self.detail.latitude = e.lnglat.lat
107
-        }
108
-      },
109
-      markers: [],
110
-      searchOption: {
111
-        city: '南京',
112
-        citylimit: false
113
-      },
114
-      listLoading: true,
115
-      listQuery: {
116
-        pageNum: 1,
117
-        pageSize: 20,
118
-        transactionId: undefined,
119
-        transactionTitle: undefined,
120
-        status: undefined,
121
-        isReported: undefined
122
-      },
123
-      tableKey: 0,
124
-      downloadLoading: false
125
-    }
126
-  },
127
-  created() {
128
-    this.getList()
129
-  },
130
-  methods: {
131
-    ...mapMutations('transaction', {
132
-    }),
133
-    ...mapActions('transaction', [
134
-      'FetchTransactionList'
135
-    ]),
136
-    setCurrent(item) {
137
-      this.setDetail({ ...item })
138
-    },
139
-    getList() {
140
-      this.listLoading = true
141
-      this.FetchTransactionList(this.listQuery).then(() => {
142
-        this.listLoading = false
143
-      }).catch(() => {
144
-        this.loading = false
145
-        console.log('get list error')
146
-      })
147
-    },
148
-    clearListQuery() {
149
-      this.listQuery.pageNum = 1
150
-      this.listQuery.pageSize = 20
151
-      this.listQuery.transactionId = undefined
152
-      this.listQuery.transactionTitle = undefined
153
-      this.listQuery.status = undefined
154
-      this.listQuery.isReported = undefined
155
-      this.getList()
156
-    },
157
-    handleFilter() {
158
-      this.listQuery.pageNum = 1
159
-      this.getList()
160
-    },
161
-    handleModifyStatus(row, status) {
162
-      this.$message({
163
-        message: '操作成功',
164
-        type: 'success'
165
-      })
166
-      row.status = status
167
-    },
168
-    sortChange(data) {
169
-      const { prop, order } = data
170
-      if (prop === 'id') {
171
-        this.sortByID(order)
172
-      }
173
-    },
174
-    handleSizeChange(val) {
175
-      // console.log(`每页 ${val} 条`);
176
-      this.listQuery.pageSize = val
177
-      this.getList()
178
-    },
179
-    handleCurrentChange(val) {
180
-      // console.log(`当前页: ${val}`);
181
-      this.listQuery.pageNum = val
182
-      this.getList()
183
-    },
184
-    sortByID(order) {
185
-      if (order === 'ascending') {
186
-        this.listQuery.sort = '+id'
187
-      } else {
188
-        this.listQuery.sort = '-id'
189
-      }
190
-      this.handleFilter()
191
-    },
192
-    handleUpdate(row) {
193
-      this.setCurrent(row)
194
-      this.dialogStatus = 'update'
195
-      this.dialogFormVisible = true
196
-      this.$nextTick(() => {
197
-        this.$refs['dataForm'].clearValidate()
198
-      })
199
-      this.getEditCityList()
200
-      this.getEditDistrictList()
201
-    },
202
-    handleLook(id) {
203
-      this.$router.push({ name: 'transaction-info', params: { id: id }})
204
-    },
205
-    handleCreate() {
206
-      this.resetDetail()
207
-      this.dialogStatus = 'create'
208
-      this.dialogFormVisible = true
209
-      this.$nextTick(() => {
210
-        this.$refs['dataForm'].clearValidate()
211
-      })
212
-    },
213
-    handleDelete(row) {
214
-      this.$notify({
215
-        title: '成功',
216
-        message: '删除成功',
217
-        type: 'success',
218
-        duration: 2000
219
-      })
220
-      const index = this.list.indexOf(row)
221
-      this.list.splice(index, 1)
222
-    },
223
-    handleDownload() {
224
-      this.downloadLoading = true
225
-      import('@/vendor/Export2Excel').then(excel => {
226
-        const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
227
-        const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
228
-        const data = this.formatJson(filterVal, this.list)
229
-        excel.export_json_to_excel({
230
-          header: tHeader,
231
-          data,
232
-          filename: 'table-list'
233
-        })
234
-        this.downloadLoading = false
235
-      })
236
-    },
237
-    padDate(value) {
238
-      value = value < 10 ? '0' + value : value
239
-      return value
240
-    },
241
-    formatDate(val) {
242
-      var value = new Date(val)
243
-      var year = value.getFullYear()
244
-      var month = this.padDate(value.getMonth() + 1)
245
-      var day = this.padDate(value.getDate())
246
-      var hour = this.padDate(value.getHours())
247
-      var minutes = this.padDate(value.getMinutes())
248
-      var seconds = this.padDate(value.getSeconds())
249
-      return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds
250
-    },
251
-    formatJson(filterVal, jsonData) {
252
-      return jsonData.map(v => filterVal.map(j => {
253
-        if (j === 'timestamp') {
254
-          return parseTime(v[j])
255
-        } else {
256
-          return v[j]
257
-        }
258
-      }))
259
-    },
260
-  }
261
-}
262
-</script>

+ 137
- 0
VUECODE/smart-property-manage/src/views/account/user/addUser.vue Bestand weergeven

@@ -0,0 +1,137 @@
1
+<template>
2
+  <div id="root">
3
+    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
4
+      <el-form-item label="名称" prop="userName">
5
+        <el-input v-model="ruleForm.userName"/>
6
+      </el-form-item>
7
+     <el-form-item class="filter-item" label="手机号" prop="loginName" >
8
+        <el-input v-model.trim="ruleForm.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
9
+      </el-form-item>
10
+      <el-form-item label="角色" prop="menuArray">
11
+        <!-- default-expanded-keys 展示选中的
12
+             default-checked-keys 勾上选中的-->
13
+        <el-tree
14
+          ref="tree"
15
+          :data="menuData"
16
+          :default-expanded-keys="ruleForm.menuArray"
17
+          :default-checked-keys="ruleForm.menuArray"
18
+          :props="defaultProps"
19
+          show-checkbox
20
+          node-key="id"
21
+          @check-change="handleCheckChange"/>
22
+      </el-form-item>
23
+      <el-form-item label="备注" prop="remark">
24
+        <el-input v-model="ruleForm.remark"/>
25
+      </el-form-item>
26
+      <el-form-item>
27
+        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
28
+      </el-form-item>
29
+    </el-form>
30
+  </div>
31
+</template>
32
+
33
+<script>
34
+export default {
35
+  data() {
36
+    return {
37
+      ruleForm: {
38
+        id: '',
39
+        userName: '',
40
+        loginName:'',
41
+        remark: '',
42
+        roleName: '',
43
+        createUser: '',
44
+        updateUser: '',
45
+        updateDate: '',
46
+        pageNum: 1,
47
+        pageSize: 10,
48
+        menuArray: [] // 已选中的权限资源
49
+      },
50
+      menuData: [], // 所有权限资源
51
+      defaultProps: { // 设置树形节点的渲染的属性
52
+        id: 'id',
53
+        label: 'roleName',
54
+        children: 'children'
55
+      },
56
+      rules: {
57
+        roleName: [
58
+          { required: true, message: '名称', trigger: 'blur' }
59
+        ],
60
+        loginName: [
61
+          { required: true, message: '请输入手机号', trigger: 'blur' }
62
+        ],
63
+        
64
+      }
65
+    }
66
+  },
67
+  mounted() {
68
+     this.getById()
69
+  },
70
+  methods: {
71
+    submitForm(formName) {
72
+      // 获取选中的树形节点 key
73
+      this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
74
+      this.$refs[formName].validate((valid) => {
75
+        const loading = this.$loading({
76
+          lock: true,
77
+          text: 'Loading',
78
+          spinner: 'el-icon-loading',
79
+          background: 'rgba(0, 0, 0, 0.7)'
80
+        })
81
+        if (valid) {
82
+          console.log('this.roleName',this.roleName)
83
+          this.$store.dispatch('AddUser', this.ruleForm).then((res) => {
84
+            const resCode = res.code
85
+            this.ruleForm.id=''
86
+            if (resCode === '0') {
87
+              this.$message({
88
+                message: res.message,
89
+                type: 'success'
90
+              })
91
+              loading.close()
92
+              this.$router.push({ name: 'user-index' })
93
+            }
94
+          }).catch(() => {
95
+            console.log('error AddUser')
96
+            loading.close()
97
+          })
98
+        } else {
99
+          console.log('error submit!!')
100
+          loading.close()
101
+          return false
102
+        }
103
+      })
104
+    },
105
+    resetForm(formName) {
106
+      this.$refs[formName].resetFields()
107
+    },
108
+    handleCheckChange(data, checked, indeterminate) { // 树形图选择事件
109
+      console.log(data, checked, indeterminate)
110
+    },
111
+    getMenuList() { // 获取 菜单列表
112
+      this.$store.dispatch('GetMenuList').then((res) => {
113
+        this.menuData = res.data
114
+      }).catch(() => {
115
+        console.log('error GetMenuList')
116
+      })
117
+    },
118
+    getById(){
119
+    this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
120
+      this.menuData = res.data.list
121
+      console.log(this.menuData)
122
+    }).catch(() => {
123
+      console.log('error UserRoleById')
124
+    })
125
+}
126
+  }
127
+  }
128
+</script>
129
+
130
+<style scoped>
131
+.demo-ruleForm {
132
+  width: 500px;
133
+  margin-top: 20px;
134
+  margin-left: auto;
135
+  margin-right: auto;
136
+}
137
+</style>

+ 156
- 0
VUECODE/smart-property-manage/src/views/account/user/editUser.vue Bestand weergeven

@@ -0,0 +1,156 @@
1
+<template>
2
+  <div id="root">
3
+    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
4
+      <el-form-item label="名称" prop="userName">
5
+        <el-input v-model="ruleForm.userName"/>
6
+      </el-form-item>
7
+     <el-form-item class="filter-item" label="手机号" prop="loginName" >
8
+        <el-input v-model.trim="ruleForm.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
9
+      </el-form-item>
10
+      <el-form-item label="角色" prop="menuArray">
11
+        <!-- default-expanded-keys 展示选中的
12
+             default-checked-keys 勾上选中的-->
13
+        <el-tree
14
+          ref="tree"
15
+          :data="menuData"
16
+          :default-expanded-keys="ruleForm.menuArray"
17
+          :default-checked-keys="ruleForm.menuArray"
18
+          :props="defaultProps"
19
+          show-checkbox
20
+          node-key="id"
21
+          @check-change="handleCheckChange"/>
22
+      </el-form-item>
23
+      <el-form-item label="备注" prop="remark">
24
+        <el-input v-model="ruleForm.remark"/>
25
+      </el-form-item>
26
+      <el-form-item>
27
+        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
28
+      </el-form-item>
29
+    </el-form>
30
+  </div>
31
+</template>
32
+
33
+<script>
34
+export default {
35
+  data() {
36
+    return {
37
+      ruleForm: {
38
+        id: '',
39
+        userName: '',
40
+        loginName:'',
41
+        remark: '',
42
+        roleName: '',
43
+        createUser: '',
44
+        updateUser: '',
45
+        updateDate: '',
46
+        pageNum: 1,
47
+        pageSize: 10,
48
+        menuArray: [] // 已选中的权限资源
49
+      },
50
+      menuData: [], // 所有权限资源
51
+      defaultProps: { // 设置树形节点的渲染的属性
52
+        id: 'id',
53
+        label: 'roleName',
54
+        children: 'children'
55
+      },
56
+      rules: {
57
+        roleName: [
58
+          { required: true, message: '名称', trigger: 'blur' }
59
+        ],
60
+        loginName: [
61
+          { required: true, message: '请输入手机号', trigger: 'blur' }
62
+        ],
63
+        
64
+      }
65
+    }
66
+  },
67
+  mounted() {
68
+     this.selectUser(this.$route.params.id)
69
+     console.log('this.$route.params.id',this.$route.params.id)
70
+     this.getById()
71
+  },
72
+  methods: {
73
+    submitForm(formName) {
74
+      // 获取选中的树形节点 key
75
+      this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
76
+      this.$refs[formName].validate((valid) => {
77
+        const loading = this.$loading({
78
+          lock: true,
79
+          text: 'Loading',
80
+          spinner: 'el-icon-loading',
81
+          background: 'rgba(0, 0, 0, 0.7)'
82
+        })
83
+        if (valid) {
84
+          console.log('this.roleName',this.roleName)
85
+          this.$store.dispatch('UpDate', this.ruleForm).then((res) => {
86
+            const resCode = res.code
87
+            if (resCode === '0') {
88
+              this.$message({
89
+                message: res.message,
90
+                type: 'success'
91
+              })
92
+              loading.close()
93
+              this.$router.push({ name: 'user-index' })
94
+            }
95
+          }).catch(() => {
96
+            console.log('error AddUser')
97
+            loading.close()
98
+          })
99
+        } else {
100
+          console.log('error submit!!')
101
+          loading.close()
102
+          return false
103
+        }
104
+      })
105
+    },
106
+    resetForm(formName) {
107
+      this.$refs[formName].resetFields()
108
+    },
109
+    handleCheckChange(data, checked, indeterminate) { // 树形图选择事件
110
+      console.log(data, checked, indeterminate)
111
+    },
112
+    getMenuList() { // 获取 菜单列表
113
+      this.$store.dispatch('GetMenuList').then((res) => {
114
+        this.menuData = res.data
115
+      }).catch(() => {
116
+        console.log('error GetMenuList')
117
+      })
118
+    },
119
+    getById(){
120
+    this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
121
+      this.menuData = res.data.list
122
+      console.log(this.menuData)
123
+    }).catch(() => {
124
+      console.log('error UserRoleById')
125
+    })
126
+},
127
+  selectUser(id){
128
+    this.ruleForm.id=id
129
+    this.$store.dispatch('SelectUser', this.ruleForm).then((res) => {
130
+      // this.ruleForm.loginName = res.data.loginName
131
+      // this.ruleForm=res.data[0]
132
+        // this.ruleForm.loginName.push(res.data[0])
133
+        this.ruleForm.loginName=res.data.userList[0].loginName
134
+         this.ruleForm.userName=res.data.userList[0].userName
135
+         this.ruleForm.remark=res.data.userList[0].remark
136
+         this.ruleForm.menuArray=res.data.roleList
137
+        console.log('res.data',res.data)
138
+
139
+    }).catch(() => {
140
+      console.log('error SelectUser')
141
+    })
142
+
143
+
144
+  }
145
+  }
146
+  }
147
+</script>
148
+
149
+<style scoped>
150
+.demo-ruleForm {
151
+  width: 500px;
152
+  margin-top: 20px;
153
+  margin-left: auto;
154
+  margin-right: auto;
155
+}
156
+</style>

+ 195
- 0
VUECODE/smart-property-manage/src/views/account/user/index.vue Bestand weergeven

@@ -0,0 +1,195 @@
1
+<template>
2
+  <div class="root">
3
+    <el-form :inline="true" :model="listQuery" class="form-listQuery">
4
+      <el-form-item class="filter-item" label="姓名">
5
+        <el-input v-model.trim="listQuery.userName" placeholder="姓名" />
6
+      </el-form-item>
7
+      <el-form-item class="filter-item" label="手机号" >
8
+        <el-input v-model.trim="listQuery.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
9
+      </el-form-item>
10
+      <el-form-item>
11
+        <el-button type="info" class="filter-item" @click="handleFilter">清空</el-button>
12
+        <el-button type="primary" @click="search">查询</el-button>
13
+      </el-form-item>
14
+    </el-form>
15
+    <div class="button">
16
+      <el-button type="primary" @click="addUser">添加</el-button>
17
+      <el-button type="warning" @click="upDate">修改</el-button>
18
+    </div>
19
+    <el-table
20
+      v-loading="listLoading"
21
+      ref="multipleTable"
22
+      :data="listDate"
23
+      border
24
+      tooltip-effect="dark"
25
+      style="width: 100%; margin-top: 20px;"
26
+      @selection-change="handleSelectionChange">
27
+      <el-table-column
28
+        type="selection"
29
+        width="55"/>
30
+      <el-table-column prop="userName" label="姓名" align="center"/>
31
+      <el-table-column prop="roleName" label="角色权限" align="center"/>
32
+      <el-table-column prop="loginName" label="手机号" align="center"/>
33
+      <el-table-column prop="remark" label="备注" align="center"/>
34
+      <el-table-column prop="createNmae" label="创建人" align="center"/>
35
+      <el-table-column prop="createDate" label="创建时间" align="center"><template slot-scope="scope">{{ formatDate(scope.row.createDate) }}</template></el-table-column>
36
+      <el-table-column prop="id" label="操作" align="center">
37
+          <template slot-scope="scope"><a><span style="color: #63B8FF" @click="upDateStatus(scope.row.id,scope.row.status)">{{ scope.row.status =='1' ? '停用账号':'启用账号' }}</span></a></template>
38
+          </el-table-column>
39
+    </el-table>
40
+    <div class="block">
41
+      <el-pagination
42
+        :current-page.sync="listQuery.pageNum"
43
+        :page-sizes="[10, 20, 50, 100]"
44
+        :page-size.sync="listQuery.pageSize"
45
+        :total="total"
46
+        layout="total, sizes, prev, pager, next, jumper"
47
+        @size-change="handleSizeChange"
48
+        @current-change="handleCurrentChange"/>
49
+    </div>
50
+  </div>
51
+</template>
52
+
53
+<script>
54
+import { mapActions } from 'vuex'
55
+
56
+export default {
57
+  data() {
58
+    return {
59
+      listQuery: {
60
+        id: '',
61
+        userName: '',
62
+        loginName:'',
63
+        roleName: '',
64
+        createUser: '',
65
+        updateUser: '',
66
+        updateDate: '',
67
+        status : '',
68
+        pageNum: 1,
69
+        pageSize: 10
70
+      },
71
+      total: 0, // 数据总数
72
+      listDate: [],
73
+      deleteIds: [], // 选择的id集合
74
+      listLoading: true // 加载圈
75
+    }
76
+  },
77
+  mounted() {
78
+    // 获取数据
79
+    this.dataQuery()
80
+  },
81
+  methods: {
82
+    ...mapActions('listAnnouncement', [
83
+      'BserPassCertification'
84
+    ]),
85
+    handleSizeChange(val) {
86
+      console.log(`每页 ${val} 条`)
87
+      this.listQuery.pageSize = val
88
+      this.dataQuery()
89
+    },
90
+    handleCurrentChange(val) {
91
+      console.log(`当前页: ${val}`)
92
+      this.listQuery.pageNum = val
93
+      this.dataQuery()
94
+    },
95
+    padDate(value) {
96
+      value = value < 10 ? '0' + value : value
97
+      return value
98
+    },
99
+    dataQuery() { // 查询数据
100
+      this.listLoading = true
101
+      this.$store.dispatch('EmployeesList', this.listQuery).then((res) => {
102
+         this.listDate = res.item
103
+        this.list = res.item
104
+        this.total = res.total
105
+        this.listLoading = false
106
+      }).catch(() => {
107
+        this.listLoading = false
108
+        console.log('error EmployeesList')
109
+      })
110
+      
111
+    },
112
+    handleSelectionChange(data) {
113
+      // 设置为 空
114
+      this.deleteIds = []
115
+      for (let i = 0; i < data.length; i++) {
116
+        this.deleteIds.push(data[i].id)
117
+      }
118
+    },
119
+	  search() {
120
+      this.listQuery.pageNum = 1
121
+      this.dataQuery()
122
+    },
123
+    handleFilter() {
124
+      this.listQuery.pageNum = 1
125
+      this.listQuery.pageSize = 10
126
+      this.listQuery.ownerName =''
127
+      this.listQuery.userName=''
128
+      this.listQuery.loginName=''
129
+      this.dataQuery()
130
+    },
131
+    clickTitle(id) {
132
+      this.$router.push({ name: 'contentParticulars-details', params: { id: id }})
133
+    },
134
+    formatDate(val) {
135
+      if (val === null) {
136
+        return ''
137
+      }
138
+      var value = new Date(val)
139
+      var year = value.getFullYear()
140
+      var month = value.getMonth() + 1
141
+      var day = value.getDate()
142
+      return year + '-' + month + '-' + day
143
+    },
144
+    addUser(){
145
+    this.$router.push({ name: 'user-addUser' })
146
+     this.listQuery.id=''
147
+    },
148
+    upDate(){
149
+      //  this.$router.push({ name: 'user-edit' })
150
+       const ids = this.deleteIds[0]
151
+          this.$router.push({ name: 'user-edit', params: { id: ids }})
152
+    },
153
+    upDateStatus(id,status){
154
+      this.listQuery.id=id
155
+      this.listQuery.status=status
156
+      this.$store.dispatch('UpDateStatus', this.listQuery).then((res) => {
157
+        console.log('res',res)
158
+        this.dataQuery()
159
+        this.listLoading = false
160
+      }).catch(() => {
161
+        this.listLoading = false
162
+        console.log('error UpDateStatus')
163
+      })
164
+    }
165
+    }
166
+    }
167
+  
168
+
169
+</script>
170
+
171
+<style scoped>
172
+.root{
173
+  display: flex;
174
+  flex-flow: column;
175
+}
176
+.form-listQuery{
177
+  margin-top: 20px;
178
+  margin-left: 30px;
179
+}
180
+.operation{
181
+  display: flex;
182
+  justify-content: space-between;
183
+  margin-left: 20px;
184
+  margin-right: 20px;
185
+}
186
+.block{
187
+  display: flex;
188
+  justify-content: flex-end;
189
+  margin-top: 10px;
190
+}
191
+.button {
192
+  margin-left: 20px;
193
+}
194
+</style>
195
+

+ 693
- 601
文档/MYSQL/smartCommunity.pdb
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 693
- 601
文档/MYSQL/smartCommunity.pdm
Diff onderdrukt omdat het te groot bestand
Bestand weergeven