dingxin 6 лет назад
Родитель
Сommit
65eb491d68

+ 11
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/UserController.java Просмотреть файл

@@ -37,7 +37,6 @@ public class UserController extends BaseController {
37 37
 	
38 38
 	@Autowired
39 39
 	private IUserService userService;
40
-
41 40
 	
42 41
 	@ApiOperation(value = "获取用户列表",nickname = "获取用户信息")
43 42
 	@ApiImplicitParams({
@@ -129,7 +128,7 @@ public class UserController extends BaseController {
129 128
 	@RequestMapping(value = "/user/upDate", method = RequestMethod.POST)
130 129
 	public ResponseBean upDate(@RequestBody String parameter,HttpSession session){
131 130
 		UserElement userElement = getUserElement(session);
132
-		ResponseBean  responseBean = userService.upDate(parameter,userElement.getId());
131
+		ResponseBean  responseBean = userService.upDate(parameter,userElement.getId(),userElement.getCommunityId());
133 132
 		return responseBean;
134 133
 	}
135 134
 
@@ -154,5 +153,15 @@ public class UserController extends BaseController {
154 153
 		ResponseBean  responseBean = userService.upDateStatus(parameter,userElement.getId());
155 154
 		return responseBean;
156 155
 	}
156
+	@ApiOperation(value = "查看所有角色", notes = "查看所有角色")
157
+	@ApiImplicitParams({
158
+			@ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter" )
159
+	})
160
+	@RequestMapping(value = "/user/userRole", method = RequestMethod.POST)
161
+	public ResponseBean userRole(@RequestBody String parameter,HttpSession session){
162
+		UserElement userElement = getUserElement(session);
163
+		ResponseBean  responseBean = userService.allUserRole(parameter,userElement.getId(),userElement.getCommunityId());
164
+		return responseBean;
165
+	}
157 166
 
158 167
 }

+ 6
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/TpSysRoleMapper.java Просмотреть файл

@@ -3,6 +3,7 @@ package com.community.huiju.dao;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.community.huiju.model.TpSysRole;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 import java.util.List;
8 9
 import java.util.Map;
@@ -25,4 +26,9 @@ public interface TpSysRoleMapper extends BaseMapper<TpSysRole> {
25 26
      */
26 27
     List<TpSysRole> selectByUserIdAndRoleId(Map<String, Object> map);
27 28
 
29
+    /**
30
+     * 得到所有角色
31
+     * @param communityId
32
+     */
33
+    List<TpSysRole> allUserRole(@Param("communityId") Integer communityId);
28 34
 }

+ 4
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/UserMapper.java Просмотреть файл

@@ -7,6 +7,7 @@ import com.community.huiju.model.TaUser;
7 7
 import com.community.huiju.model.TpAnnouncement;
8 8
 import com.community.huiju.model.TpBuildingOwnerInfo;
9 9
 import com.community.huiju.model.User;
10
+import com.community.huiju.vo.UserVO;
10 11
 import org.apache.ibatis.annotations.Mapper;
11 12
 import org.apache.ibatis.annotations.Param;
12 13
 
@@ -34,12 +35,13 @@ public interface UserMapper extends BaseMapper<User> {
34 35
      * @param id
35 36
      * @return
36 37
      */
37
-    List<User> selectUser(@Param("id") Integer id);
38
+    List<UserVO> selectUser(@Param("id") Integer id);
38 39
 
39 40
     /**
40 41
      * 查询当前多个角色
41 42
      * @param id
42 43
      * @return
43 44
      */
44
-    List<User> selectRole(@Param("id") Integer id);
45
+    List<UserVO> selectRole(@Param("id") Integer id);
46
+
45 47
 }

+ 4
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TpSysRole.java Просмотреть файл

@@ -24,6 +24,10 @@ public class TpSysRole implements Serializable {
24 24
 
25 25
     private static final long serialVersionUID = 1L;
26 26
 
27
+    /**
28
+     * id
29
+     */
30
+    private Integer id;
27 31
     /**
28 32
      * 小区id
29 33
      */

+ 9
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IUserService.java Просмотреть файл

@@ -60,7 +60,7 @@ public interface IUserService extends IService<User> {
60 60
      * @param id
61 61
      * @return
62 62
      */
63
-    ResponseBean upDate(String parameter, Integer id);
63
+    ResponseBean upDate(String parameter, Integer id,Integer communityId);
64 64
 
65 65
     /**
66 66
      * 查看成员详情
@@ -77,4 +77,12 @@ public interface IUserService extends IService<User> {
77 77
      */
78 78
     ResponseBean upDateStatus(String parameter,Integer userID);
79 79
 
80
+    /**
81
+     * 获取所有角色
82
+     * @param parameter
83
+     * @param id
84
+     * @param communityId
85
+     * @return
86
+     */
87
+    ResponseBean allUserRole(String parameter, Integer id, Integer communityId);
80 88
 }

+ 79
- 24
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/UserServiceImpl.java Просмотреть файл

@@ -23,6 +23,7 @@ import com.community.commom.utils.AccountValidatorUtil;
23 23
 import com.community.huiju.common.code.cache.AppkeyCache;
24 24
 import com.community.huiju.service.IUserService;
25 25
 import com.community.huiju.vo.UserVO;
26
+import com.google.common.collect.Lists;
26 27
 import lombok.extern.slf4j.Slf4j;
27 28
 import com.google.common.collect.Maps;
28 29
 import org.apache.commons.lang.StringUtils;
@@ -184,20 +185,24 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
184 185
 
185 186
         IPage<User> pageInfo = userMapper.userList(page,loginName,userName,communityId);
186 187
         List<User> userList = pageInfo.getRecords();
188
+        List<UserVO> userVOList = Lists.newArrayList();
187 189
         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);
190
+            UserVO userVO = new UserVO();
191
+            BeanUtils.copyProperties(user, userVO);
192
+            //查询当前所有角色
193
+            userVO.setRoleName(selectRole(user.getId()));
194
+            // 创建人
195
+            String createNmae=userMapper.selectByIdUserName(user.getCreateUser());
196
+            // 修改人
197
+            String updateNmae=userMapper.selectByIdUserName(user.getUpdateUser());
198
+
199
+            userVO.setCreateNmae(createNmae);
200
+            userVO.setUpdateNmae(updateNmae);
201
+            userVOList.add(userVO);
197 202
         }
198 203
 
199 204
         Map<String, Object> map = Maps.newHashMap();
200
-        map.put("list", userList);
205
+        map.put("list", userVOList);
201 206
         map.put("total", pageInfo.getTotal());
202 207
         map.put("pageNum", pageInfo.getCurrent());
203 208
         map.put("pageSize", pageInfo.getSize());
@@ -212,6 +217,21 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
212 217
         User user= new User();
213 218
 
214 219
         String loginName= object.getString("loginName");
220
+        if (!AccountValidatorUtil.isPhone(loginName)){
221
+            response.addError("请输入正确的手机号!");
222
+            return response;
223
+        }
224
+
225
+        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
226
+        queryWrapper.lambda().eq(User::getLoginName,loginName);
227
+        queryWrapper.lambda().eq(User::getCommunityId,communityId);
228
+        List<User> userLoginName= userMapper.selectList(queryWrapper);
229
+        for (User us:userLoginName) {
230
+            if (null != us.getLoginName()) {
231
+                response.addError("您输入的手机号已存在");
232
+                return response;
233
+            }
234
+        }
215 235
         String userName = object.getString("userName");
216 236
         JSONArray List = object.getJSONArray("menuArray");
217 237
         Integer[] roleIdArray = List.toArray(new Integer[]{});
@@ -223,12 +243,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
223 243
         user.setStatus("1");;
224 244
         user.setCreateUser(userID);
225 245
         user.setCreateDate(LocalDateTime.now());
246
+        user.setCommunityId(communityId);
226 247
         userMapper.insert(user);
227 248
         //维护小区
228
-        TpUserCommunity tpUserCommunity= new TpUserCommunity();
229
-        tpUserCommunity.setCommunityId(communityId);
230
-        tpUserCommunity.setId(user.getId());
231
-        tpUserCommunityMapper.insert(tpUserCommunity);
249
+//        TpUserCommunity tpUserCommunity= new TpUserCommunity();
250
+//        tpUserCommunity.setCommunityId(communityId);
251
+//        tpUserCommunity.setTpUserId(user.getId());
252
+//        tpUserCommunityMapper.insert(tpUserCommunity);
232 253
         //会对应多个角色
233 254
         for (Integer roleID:roleIdArray  ){
234 255
             SysUserRole toSysUserRole= new SysUserRole();
@@ -241,12 +262,31 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
241 262
     }
242 263
 
243 264
     @Override
244
-    public ResponseBean upDate(String parameter, Integer userID) {
265
+    public ResponseBean upDate(String parameter, Integer userID,Integer communityId) {
245 266
         ResponseBean response = new ResponseBean<>();
246 267
         JSONObject object = JSONObject.parseObject(parameter);
247 268
         User user = new User();
248 269
 
249 270
         String loginName = object.getString("loginName");
271
+        if (!AccountValidatorUtil.isPhone(loginName)){
272
+            response.addError("请输入正确的手机号!");
273
+            return response;
274
+        }
275
+
276
+        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
277
+        queryWrapper.lambda().eq(User::getLoginName,loginName);
278
+        queryWrapper.lambda().eq(User::getCommunityId,communityId);
279
+        List<User> userLoginName= userMapper.selectList(queryWrapper);
280
+        for (User us:userLoginName) {
281
+            // 修改手机号码时排除自身
282
+            if (null != us.getLoginName()&&loginName.equals(us.getLoginName())){
283
+                break;
284
+            }
285
+            if (null != us.getLoginName()) {
286
+                response.addError("您输入的手机号已存在");
287
+                return response;
288
+            }
289
+        }
250 290
         Integer ID= object.getInteger("id");
251 291
         String userName = object.getString("userName");
252 292
         JSONArray List = object.getJSONArray("menuArray");
@@ -264,7 +304,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
264 304
 
265 305
         //会对应多个角色
266 306
         if (null!=List) {
267
-            sysUserRoleMapper.deleteById(ID);
307
+            QueryWrapper<SysUserRole> queryWrapperRole = new QueryWrapper<>();
308
+            queryWrapperRole.lambda().eq(SysUserRole::getUserId,ID);
309
+             sysUserRoleMapper.delete(queryWrapperRole);
268 310
             for (Integer roleID : roleIDArray) {
269 311
                 SysUserRole sysUserRole = new SysUserRole();
270 312
                 sysUserRole.setUserId(user.getId());
@@ -282,9 +324,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
282 324
         JSONObject object= JSONObject.parseObject(parameter);
283 325
         Integer ID= object.getInteger("id");
284 326
         List<String> list=new ArrayList<String>();
285
-        List<User> userList=userMapper.selectUser(ID);
286
-        for (User user:userList){
287
-            // list.add(user.getRoleId());
327
+        List<UserVO> userList=userMapper.selectUser(ID);
328
+        for (UserVO userVO:userList){
329
+            list.add(userVO.getRoleId());
288 330
         }
289 331
         HashMap map= new HashMap<>();
290 332
         map.put("userList",userList);
@@ -314,15 +356,28 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
314 356
         return response;
315 357
     }
316 358
 
359
+    @Override
360
+    public ResponseBean allUserRole(String parameter, Integer id, Integer communityId) {
361
+        ResponseBean response = new ResponseBean<>();
362
+        List<TpSysRole> tpSysRole=tpSysRoleMapper.allUserRole(communityId);
363
+        response.addSuccess(tpSysRole);
364
+        return  response;
365
+    }
366
+
317 367
     //查询多个角色转换为字符串
318 368
     public String selectRole(Integer id) {
319
-        List<User> toUser= userMapper.selectRole(id);
369
+        List<UserVO> toUser= userMapper.selectRole(id);
370
+
320 371
         List<String> list=new ArrayList<String>();
321
-        for (User user:toUser){
322
-            // list.add(user.getRoleName());
323
-        }
372
+
373
+            for (UserVO userVo : toUser) {
374
+                if (userVo !=null &&userVo.getRoleName() != null && !userVo.getRoleName().equals("")) {
375
+                list.add(userVo.getRoleName());
376
+                }
377
+            }
378
+
324 379
         String result = "";
325
-        if (list != null && list.size() > 0) {
380
+        if ( null!=list && list.size() > 0) {
326 381
             for (String item : list) {
327 382
                 // 把列表中的每条数据用逗号分割开来,然后拼接成字符串
328 383
                 result += item + ",";

+ 8
- 1
CODE/smart-community/property-api/src/main/resources/mapper/TpSysRoleMapper.xml Просмотреть файл

@@ -9,5 +9,12 @@
9 9
       on tsur.role_id = tsr.id
10 10
       WHERE tsur.user_id = #{userId}
11 11
     </select>
12
-
12
+    <select id="allUserRole" parameterType="int" resultType="com.community.huiju.model.TpSysRole">
13
+    SELECT
14
+    role_name,
15
+    id
16
+    FROM
17
+    tp_sys_role
18
+    WHERE community_id=#{communityId,jdbcType=INTEGER}
19
+    </select>
13 20
 </mapper>

+ 44
- 49
CODE/smart-community/property-api/src/main/resources/mapper/UserMapper.xml Просмотреть файл

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

+ 1
- 1
VUECODE/smart-property-manage/src/api/user.js Просмотреть файл

@@ -16,7 +16,7 @@ export function employeesList(data) {
16 16
 // 获取角色暂定写死
17 17
 export function userRoleById(data) {
18 18
   return request({
19
-    url: '/role/list',
19
+    url: '/user/userRole',
20 20
     method: 'post',
21 21
     data: {
22 22
       pageNum: data.pageNum,

+ 14
- 0
VUECODE/smart-property-manage/src/router/index.js Просмотреть файл

@@ -213,6 +213,20 @@ export const constantRouterMap = [
213 213
         name: 'role-info',
214 214
         hidden: true,
215 215
         meta: { title: '查看角色', icon: 'table' }
216
+      },
217
+      {
218
+        path: '/account/user/addUser',
219
+        component: () => import('@/views/account/user/addUser'),
220
+        name: 'user-addUser',
221
+        hidden: true,
222
+        meta: { title: '添加成员', icon: 'table' }
223
+      },
224
+      {
225
+        path: '/account/user/editUser',
226
+        component: () => import('@/views/account/user/editUser'),
227
+        name: 'user-edit',
228
+        hidden: true,
229
+        meta: { title: '编辑成员', icon: 'table' }
216 230
       }
217 231
     ]
218 232
   },

+ 1
- 2
VUECODE/smart-property-manage/src/store/modules/user.js Просмотреть файл

@@ -105,8 +105,7 @@ const user = {
105 105
     EmployeesList({ commit }, listQuery) {
106 106
       return new Promise((resolve, reject) => {
107 107
         employeesList(listQuery).then(response => {
108
-          const data = response.data
109
-          resolve(data)
108
+          resolve(response)
110 109
         }).catch(error => {
111 110
           reject(error)
112 111
         })

+ 7
- 2
VUECODE/smart-property-manage/src/views/account/user/addUser.vue Просмотреть файл

@@ -60,7 +60,9 @@ export default {
60 60
         loginName: [
61 61
           { required: true, message: '请输入手机号', trigger: 'blur' }
62 62
         ],
63
-        
63
+        menuArray: [
64
+          { required: true, message: '请选择角色', trigger: 'blur' }
65
+        ],       
64 66
       }
65 67
     }
66 68
   },
@@ -90,6 +92,9 @@ export default {
90 92
               })
91 93
               loading.close()
92 94
               this.$router.push({ name: 'user-index' })
95
+            }else{
96
+              this.$message.error(res.message)
97
+               loading.close()
93 98
             }
94 99
           }).catch(() => {
95 100
             console.log('error AddUser')
@@ -117,7 +122,7 @@ export default {
117 122
     },
118 123
     getById(){
119 124
     this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
120
-      this.menuData = res.data.list
125
+      this.menuData = res.data
121 126
       console.log(this.menuData)
122 127
     }).catch(() => {
123 128
       console.log('error UserRoleById')

+ 33
- 17
VUECODE/smart-property-manage/src/views/account/user/editUser.vue Просмотреть файл

@@ -1,9 +1,10 @@
1 1
 <template>
2 2
   <div id="root">
3 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>
4
+       <el-form-item label="活动名称" prop="userName">
5
+          <el-input v-model="ruleForm.userName"/>
6
+       </el-form-item>
7
+    
7 8
      <el-form-item class="filter-item" label="手机号" prop="loginName" >
8 9
         <el-input v-model.trim="ruleForm.loginName" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="手机号" />
9 10
       </el-form-item>
@@ -55,11 +56,15 @@ export default {
55 56
       },
56 57
       rules: {
57 58
         roleName: [
58
-          { required: true, message: '名称', trigger: 'blur' }
59
-        ],
59
+            { required: true, message: '请输入活动名称', trigger: 'blur' },
60
+            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
61
+          ],
60 62
         loginName: [
61 63
           { required: true, message: '请输入手机号', trigger: 'blur' }
62 64
         ],
65
+        menuArray: [
66
+          { required: true, message: '请选择角色', trigger: 'blur' }
67
+        ],
63 68
         
64 69
       }
65 70
     }
@@ -82,16 +87,31 @@ export default {
82 87
         })
83 88
         if (valid) {
84 89
           console.log('this.roleName',this.roleName)
90
+          console.log('this.ruleForm.menuArray',this.ruleForm.menuArray)
91
+          // 各种校验
92
+          if(this.ruleForm.userName<=0){
93
+              this.$message.error('名称不能为空!')
94
+              loading.close()
95
+               return
96
+            }
97
+          if(this.ruleForm.menuArray[0]<0){
98
+              this.$message.error('请您选择角色!')
99
+              loading.close()
100
+               return
101
+            }
85 102
           this.$store.dispatch('UpDate', this.ruleForm).then((res) => {
86 103
             const resCode = res.code
87 104
             if (resCode === '0') {
88 105
               this.$message({
89 106
                 message: res.message,
90 107
                 type: 'success'
91
-              })
108
+              })           
92 109
               loading.close()
93 110
               this.$router.push({ name: 'user-index' })
94
-            }
111
+            }else {      
112
+           this.$message.error(res.message)
113
+           loading.close()
114
+        }
95 115
           }).catch(() => {
96 116
             console.log('error AddUser')
97 117
             loading.close()
@@ -118,22 +138,18 @@ export default {
118 138
     },
119 139
     getById(){
120 140
     this.$store.dispatch('UserRoleById', this.ruleForm).then((res) => {
121
-      this.menuData = res.data.list
122
-      console.log(this.menuData)
141
+      this.menuData = res.data
123 142
     }).catch(() => {
124 143
       console.log('error UserRoleById')
125 144
     })
126 145
 },
127
-  selectUser(id){
146
+    selectUser(id){
128 147
     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])
148
+      this.$store.dispatch('SelectUser', this.ruleForm).then((res) => {
133 149
         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
150
+        this.ruleForm.userName=res.data.userList[0].userName
151
+        this.ruleForm.remark=res.data.userList[0].remark
152
+        this.ruleForm.menuArray=res.data.roleList
137 153
         console.log('res.data',res.data)
138 154
 
139 155
     }).catch(() => {

+ 16
- 7
VUECODE/smart-property-manage/src/views/account/user/index.vue Просмотреть файл

@@ -19,7 +19,7 @@
19 19
     <el-table
20 20
       v-loading="listLoading"
21 21
       ref="multipleTable"
22
-      :data="listDate"
22
+      :data="listData"
23 23
       border
24 24
       tooltip-effect="dark"
25 25
       style="width: 100%; margin-top: 20px;"
@@ -69,7 +69,7 @@ export default {
69 69
         pageSize: 10
70 70
       },
71 71
       total: 0, // 数据总数
72
-      listDate: [],
72
+      listData: [],
73 73
       deleteIds: [], // 选择的id集合
74 74
       listLoading: true // 加载圈
75 75
     }
@@ -99,9 +99,11 @@ export default {
99 99
     dataQuery() { // 查询数据
100 100
       this.listLoading = true
101 101
       this.$store.dispatch('EmployeesList', this.listQuery).then((res) => {
102
-         this.listDate = res.item
103
-        this.list = res.item
104
-        this.total = res.total
102
+        const resData = res.data
103
+        this.listData = resData.list
104
+        this.listQuery.pageNum = resData.pageNum
105
+        this.listQuery.pageSize = resData.pageSize
106
+        this.total = resData.total
105 107
         this.listLoading = false
106 108
       }).catch(() => {
107 109
         this.listLoading = false
@@ -143,10 +145,17 @@ export default {
143 145
     },
144 146
     addUser(){
145 147
     this.$router.push({ name: 'user-addUser' })
146
-     this.listQuery.id=''
147 148
     },
148 149
     upDate(){
149
-      //  this.$router.push({ name: 'user-edit' })
150
+      const deleteIds = this.deleteIds
151
+      if (deleteIds.length > 1) {
152
+        this.$message.error('只能选择一行数据进行修改!')
153
+        return
154
+      }
155
+      if (deleteIds < 1) {
156
+        this.$message.error('请选择一行数据进行修改!')
157
+        return
158
+      }
150 159
        const ids = this.deleteIds[0]
151 160
           this.$router.push({ name: 'user-edit', params: { id: ids }})
152 161
     },