mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added search in UserManagement.
This commit is contained in:
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.cfive.pinnacle.entity.permission.Group;
|
import com.cfive.pinnacle.entity.permission.Group;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
|
||||||
import com.cfive.pinnacle.service.permission.IGroupService;
|
import com.cfive.pinnacle.service.permission.IGroupService;
|
||||||
|
import com.cfive.pinnacle.utils.WebUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
@@ -17,7 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,24 +42,15 @@ public class GroupController {
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAuthority('system:group:get')")
|
@PreAuthorize("hasAuthority('system:group:get')")
|
||||||
public ResponseResult<IPage<Group>> getAllGroup(Long currentPage, Long pageSize, String searchName, String searchRole, Integer searchEnable) {
|
public ResponseResult<IPage<Group>> getAllGroup(Long currentPage, Long pageSize, String searchName, String searchRole, Integer searchEnable) {
|
||||||
List<Long> searchRoleList = new ArrayList<>();
|
List<Long> searchRoleList = WebUtil.convertStringToList(searchRole, Long.class);
|
||||||
try {
|
|
||||||
if (searchRole != null && !searchRole.isBlank()) {
|
|
||||||
String[] searchRoleStr = searchRole.split(",");
|
|
||||||
for (String s : searchRoleStr) {
|
|
||||||
searchRoleList.add(Long.parseLong(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new DataValidationFailedException();
|
|
||||||
}
|
|
||||||
IPage<Group> groups = groupService.getAllGroup(currentPage, pageSize, searchName, searchRoleList, searchEnable);
|
IPage<Group> groups = groupService.getAllGroup(currentPage, pageSize, searchName, searchRoleList, searchEnable);
|
||||||
return ResponseResult.databaseSelectSuccess(groups);
|
return ResponseResult.databaseSelectSuccess(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取用户组列表")
|
@Operation(summary = "获取用户组列表")
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@PreAuthorize("hasAnyAuthority('system:user:add', 'system:user:modify')")
|
@PreAuthorize("hasAnyAuthority('system:user:get', 'system:user:add', 'system:user:modify')")
|
||||||
public ResponseResult<List<Group>> getGroupList() {
|
public ResponseResult<List<Group>> getGroupList() {
|
||||||
List<Group> groups = groupService.list();
|
List<Group> groups = groupService.list();
|
||||||
return ResponseResult.databaseSelectSuccess(groups);
|
return ResponseResult.databaseSelectSuccess(groups);
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.cfive.pinnacle.entity.permission.Role;
|
import com.cfive.pinnacle.entity.permission.Role;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
|
||||||
import com.cfive.pinnacle.service.permission.IRoleService;
|
import com.cfive.pinnacle.service.permission.IRoleService;
|
||||||
|
import com.cfive.pinnacle.utils.WebUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
@@ -18,7 +18,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,17 +45,7 @@ public class RoleController {
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAuthority('system:role:get')")
|
@PreAuthorize("hasAuthority('system:role:get')")
|
||||||
public ResponseResult<IPage<Role>> getAllRole(Long currentPage, Long pageSize, String searchName, String searchPower, Integer searchEnable) {
|
public ResponseResult<IPage<Role>> getAllRole(Long currentPage, Long pageSize, String searchName, String searchPower, Integer searchEnable) {
|
||||||
List<Long> searchPowerList = new ArrayList<>();
|
List<Long> searchPowerList = WebUtil.convertStringToList(searchPower, Long.class);
|
||||||
try {
|
|
||||||
if (searchPower != null && !searchPower.isBlank()) {
|
|
||||||
String[] searchPowerStr = searchPower.split(",");
|
|
||||||
for (String s : searchPowerStr) {
|
|
||||||
searchPowerList.add(Long.parseLong(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new DataValidationFailedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPage<Role> roles = roleService.getAllRole(currentPage, pageSize, searchName, searchPowerList, searchEnable);
|
IPage<Role> roles = roleService.getAllRole(currentPage, pageSize, searchName, searchPowerList, searchEnable);
|
||||||
return ResponseResult.databaseSelectSuccess(roles);
|
return ResponseResult.databaseSelectSuccess(roles);
|
||||||
@@ -64,7 +53,7 @@ public class RoleController {
|
|||||||
|
|
||||||
@Operation(summary = "获取角色列表")
|
@Operation(summary = "获取角色列表")
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@PreAuthorize("hasAnyAuthority('system:group:get', 'system:group:add', 'system:group:modify', 'system:user:add', 'system:user:modify')")
|
@PreAuthorize("hasAnyAuthority('system:group:get', 'system:group:add', 'system:group:modify', 'system:user:get', 'system:user:add', 'system:user:modify')")
|
||||||
public ResponseResult<List<Role>> getRoleList() {
|
public ResponseResult<List<Role>> getRoleList() {
|
||||||
List<Role> roles = roleService.list();
|
List<Role> roles = roleService.list();
|
||||||
return ResponseResult.databaseSelectSuccess(roles);
|
return ResponseResult.databaseSelectSuccess(roles);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.cfive.pinnacle.entity.permission.User;
|
|||||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.service.permission.IUserService;
|
import com.cfive.pinnacle.service.permission.IUserService;
|
||||||
|
import com.cfive.pinnacle.utils.WebUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -55,10 +56,13 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAnyAuthority('system:user:get', 'system:user:add', 'system:user:modify')")
|
@PreAuthorize("hasAuthority('system:user:get')")
|
||||||
@Operation(summary = "获取所有用户(权限管理相关)")
|
@Operation(summary = "获取所有用户(权限管理相关)")
|
||||||
public ResponseResult<IPage<User>> getAllUser(Long currentPage, Long pageSize) {
|
public ResponseResult<IPage<User>> getAllUser(Long currentPage, Long pageSize, String searchName, String searchRole, String searchGroup, Integer searchEnable) {
|
||||||
IPage<User> users = userService.getAllUser( currentPage, pageSize);
|
List<Long> searchRoleList = WebUtil.convertStringToList(searchRole, Long.class);
|
||||||
|
List<Long> searchGroupList = WebUtil.convertStringToList(searchGroup, Long.class);
|
||||||
|
|
||||||
|
IPage<User> users = userService.getAllUser(currentPage, pageSize, searchName, searchRoleList, searchGroupList, searchEnable);
|
||||||
return ResponseResult.databaseSelectSuccess(users);
|
return ResponseResult.databaseSelectSuccess(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface UserMapper extends BaseMapper<User> {
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
List<Long> filterUserByRoleIdAndGroupId(@Param("userList") List<Long> userList, @Param("roleId") Long roleId, @Param("groupId") Long groupId, String searchName, Integer searchEnable);
|
||||||
|
|
||||||
List<User> getAllWithRoleAndGroup(@Param("userList") List<User> userList);
|
List<User> getAllWithRoleAndGroup(@Param("userList") List<User> userList);
|
||||||
|
|
||||||
List<User> getAllAffairUser();
|
List<User> getAllAffairUser();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public interface IUserService extends IService<User> {
|
|||||||
|
|
||||||
List<User> getDepartmentUser();
|
List<User> getDepartmentUser();
|
||||||
|
|
||||||
IPage<User> getAllUser(Long currentPage, Long pageSize);
|
IPage<User> getAllUser(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, List<Long> searchGroup, Integer searchEnable);
|
||||||
|
|
||||||
User getUser(long id);
|
User getUser(long id);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
|
|||||||
Page<Group> groupIPage = PageDTO.of(currentPage, pageSize);
|
Page<Group> groupIPage = PageDTO.of(currentPage, pageSize);
|
||||||
searchName = searchName.trim();
|
searchName = searchName.trim();
|
||||||
List<Long> groupList = groupMapper.filterGroupByRoleId(null, null, searchName, searchEnable);
|
List<Long> groupList = groupMapper.filterGroupByRoleId(null, null, searchName, searchEnable);
|
||||||
if (searchRole.size() > 0) {
|
if (groupList.size() > 0) {
|
||||||
for (Long roleId : searchRole) {
|
for (Long roleId : searchRole) {
|
||||||
groupList = groupMapper.filterGroupByRoleId(groupList, roleId, null, null);
|
groupList = groupMapper.filterGroupByRoleId(groupList, roleId, null, null);
|
||||||
if (groupList.size() == 0) {
|
if (groupList.size() == 0) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
|||||||
IPage<Role> roleIPage = PageDTO.of(currentPage, pageSize);
|
IPage<Role> roleIPage = PageDTO.of(currentPage, pageSize);
|
||||||
searchName = searchName.trim();
|
searchName = searchName.trim();
|
||||||
List<Long> roleList = roleMapper.filterRoleByPowerId(null, null, searchName, searchEnable);
|
List<Long> roleList = roleMapper.filterRoleByPowerId(null, null, searchName, searchEnable);
|
||||||
if (searchPower.size() > 0) {
|
if (roleList.size() > 0) {
|
||||||
for (Long powerId : searchPower) {
|
for (Long powerId : searchPower) {
|
||||||
roleList = roleMapper.filterRoleByPowerId(roleList, powerId, null, null);
|
roleList = roleMapper.filterRoleByPowerId(roleList, powerId, null, null);
|
||||||
if (roleList.size() == 0) {
|
if (roleList.size() == 0) {
|
||||||
|
|||||||
@@ -90,17 +90,40 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<User> getAllUser(Long currentPage, Long pageSize) {
|
public IPage<User> getAllUser(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, List<Long> searchGroup, Integer searchEnable) {
|
||||||
IPage<User> userPage = PageDTO.of(currentPage, pageSize);
|
IPage<User> userIPage = PageDTO.of(currentPage, pageSize);
|
||||||
userPage = userMapper.selectPage(userPage, Wrappers.emptyWrapper());
|
searchName = searchName.trim();
|
||||||
userPage.setRecords(userMapper.getAllWithRoleAndGroup(userPage.getRecords()));
|
List<Long> userList = userMapper.filterUserByRoleIdAndGroupId(null, null, null, searchName, searchEnable);
|
||||||
userPage.getRecords().forEach(user -> {
|
if (userList.size() > 0) {
|
||||||
|
for (Long roleId : searchRole) {
|
||||||
|
userList = userMapper.filterUserByRoleIdAndGroupId(userList, roleId, null, null, null);
|
||||||
|
if (userList.size() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (userList.size() > 0) {
|
||||||
|
for (Long groupId : searchGroup) {
|
||||||
|
userList = userMapper.filterUserByRoleIdAndGroupId(userList, null, groupId, null, null);
|
||||||
|
if (userList.size() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userList.size() > 0) {
|
||||||
|
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<User>().in(User::getId, userList);
|
||||||
|
userIPage = userMapper.selectPage(userIPage, wrapper);
|
||||||
|
userIPage.setRecords(userMapper.getAllWithRoleAndGroup(userIPage.getRecords()));
|
||||||
|
userIPage.getRecords().forEach(user -> {
|
||||||
if (user.getId() == 1L) {
|
if (user.getId() == 1L) {
|
||||||
user.setRoles(List.of(new Role(0L, "超级管理员")));
|
user.setRoles(List.of(new Role(0L, "超级管理员")));
|
||||||
user.setGroups(List.of(new Group(0L, "超级管理员")));
|
user.setGroups(List.of(new Group(0L, "超级管理员")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return userPage;
|
}
|
||||||
|
|
||||||
|
return userIPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.cfive.pinnacle.utils;
|
package com.cfive.pinnacle.utils;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.permission.LoginUser;
|
import com.cfive.pinnacle.entity.permission.LoginUser;
|
||||||
|
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WebUtil {
|
public class WebUtil {
|
||||||
public static LoginUser getLoginUser() {
|
public static LoginUser getLoginUser() {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
@@ -23,4 +27,24 @@ public class WebUtil {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> convertStringToList(String str, Class<T> clazz) {
|
||||||
|
List<T> tList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
if (str != null && !str.isBlank()) {
|
||||||
|
String[] strings = str.split(",");
|
||||||
|
for (String string : strings) {
|
||||||
|
if (Integer.class.equals(clazz)) {
|
||||||
|
tList.add((T) Integer.valueOf(string));
|
||||||
|
}
|
||||||
|
if (Long.class.equals(clazz)) {
|
||||||
|
tList.add((T) Long.valueOf(string));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new DataValidationFailedException();
|
||||||
|
}
|
||||||
|
return tList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,34 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.permission.UserMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.UserMapper">
|
||||||
|
|
||||||
|
<select id="filterUserByRoleIdAndGroupId" resultType="long">
|
||||||
|
select distinct t_user.id as user_id
|
||||||
|
from (select * from t_user where deleted = 0) as t_user
|
||||||
|
left join (select * from t_staff where deleted = 0) as ts on ts.user_id = t_user.id
|
||||||
|
left join (select * from t_user_role where deleted = 0) as tur on t_user.id = tur.user_id
|
||||||
|
left join (select * from t_role where deleted = 0) as tr on tr.id = tur.role_id
|
||||||
|
left join (select * from t_user_group where deleted = 0) as tug on t_user.id = tug.user_id
|
||||||
|
left join (select * from t_group where deleted = 0) as tg on tg.id = tug.group_id
|
||||||
|
<where>
|
||||||
|
<if test="roleId != null">
|
||||||
|
tr.id = #{roleId}
|
||||||
|
</if>
|
||||||
|
<if test="groupId != null">
|
||||||
|
and tg.id = #{groupId}
|
||||||
|
</if>
|
||||||
|
<foreach collection="userList" item="item" index="index" open="and t_user.id in (" separator="," close=")"
|
||||||
|
nullable="true">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
<if test="searchName != null and searchName != ''">
|
||||||
|
and instr(t_user.username, #{searchName}) > 0
|
||||||
|
</if>
|
||||||
|
<if test="searchEnable != null and searchEnable != -1">
|
||||||
|
and t_user.enable = #{searchEnable}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getAllWithRoleAndGroup" resultMap="userMap">
|
<select id="getAllWithRoleAndGroup" resultMap="userMap">
|
||||||
select distinct t_user.id as user_id,
|
select distinct t_user.id as user_id,
|
||||||
t_user.username as user_username,
|
t_user.username as user_username,
|
||||||
|
|||||||
@@ -314,6 +314,7 @@ export default {
|
|||||||
this.searchInput = _.cloneDeep(this.inputInput)
|
this.searchInput = _.cloneDeep(this.inputInput)
|
||||||
this.searchGender = _.cloneDeep(this.selectedGender)
|
this.searchGender = _.cloneDeep(this.selectedGender)
|
||||||
this.searchBirth = _.cloneDeep(this.selectedBirth)
|
this.searchBirth = _.cloneDeep(this.selectedBirth)
|
||||||
|
this.currentPage = 1
|
||||||
this.loadStaffTable()
|
this.loadStaffTable()
|
||||||
},
|
},
|
||||||
handleClear() {
|
handleClear() {
|
||||||
@@ -321,7 +322,6 @@ export default {
|
|||||||
this.inputInput = ''
|
this.inputInput = ''
|
||||||
this.selectedGender = -1
|
this.selectedGender = -1
|
||||||
this.selectedBirth = []
|
this.selectedBirth = []
|
||||||
this.currentPage = 1
|
|
||||||
this.handleQuery()
|
this.handleQuery()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ export default {
|
|||||||
this.searchName = this.inputName
|
this.searchName = this.inputName
|
||||||
this.searchRole = this.selectedRole
|
this.searchRole = this.selectedRole
|
||||||
this.searchEnable = this.selectedEnable
|
this.searchEnable = this.selectedEnable
|
||||||
|
this.currentPage = 1
|
||||||
this.loadGroupTable()
|
this.loadGroupTable()
|
||||||
},
|
},
|
||||||
handleClear() {
|
handleClear() {
|
||||||
|
|||||||
@@ -432,13 +432,13 @@ export default {
|
|||||||
this.searchName = _.cloneDeep(this.inputName)
|
this.searchName = _.cloneDeep(this.inputName)
|
||||||
this.searchPower = _.cloneDeep(this.selectedPower)
|
this.searchPower = _.cloneDeep(this.selectedPower)
|
||||||
this.searchEnable = _.cloneDeep(this.selectedEnable)
|
this.searchEnable = _.cloneDeep(this.selectedEnable)
|
||||||
|
this.currentPage = 1
|
||||||
this.loadRoleTable()
|
this.loadRoleTable()
|
||||||
},
|
},
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.inputName = ''
|
this.inputName = ''
|
||||||
this.selectedPower = []
|
this.selectedPower = []
|
||||||
this.selectedEnable = -1
|
this.selectedEnable = -1
|
||||||
this.currentPage = 1
|
|
||||||
this.handleQuery()
|
this.handleQuery()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,19 +1,89 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-button bg style="background-color: white" :loading="tableLoading" @click="loadUserTable">
|
<el-row :gutter="5">
|
||||||
|
<el-col :span="-1">
|
||||||
|
<el-button
|
||||||
|
bg
|
||||||
|
style="background-color: white"
|
||||||
|
:loading="tableLoading"
|
||||||
|
@click="loadUserTable"
|
||||||
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<icon-pinnacle-refresh />
|
<icon-pinnacle-refresh />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-button>
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="-1">
|
||||||
<el-button type="primary" @click="handleAddBtn">
|
<el-button type="primary" @click="handleAddBtn">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<icon-pinnacle-plus />
|
<icon-pinnacle-plus />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</template>
|
</template>
|
||||||
<template #default> 添加 </template>
|
|
||||||
</el-button>
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4">
|
||||||
|
<el-form-item label="名称" class="fill-with">
|
||||||
|
<el-input
|
||||||
|
v-model="inputName"
|
||||||
|
maxlength="20"
|
||||||
|
show-word-limit
|
||||||
|
placeholder="请输入内容"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="5">
|
||||||
|
<el-select
|
||||||
|
v-model="selectedRole"
|
||||||
|
class="fill-with"
|
||||||
|
clearable
|
||||||
|
collapse-tags
|
||||||
|
collapse-tags-tooltip
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in roleOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:value="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="5">
|
||||||
|
<el-select
|
||||||
|
v-model="selectedGroup"
|
||||||
|
class="fill-with"
|
||||||
|
clearable
|
||||||
|
collapse-tags
|
||||||
|
collapse-tags-tooltip
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in groupOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:value="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="3">
|
||||||
|
<el-form-item label="状态" class="fill-with">
|
||||||
|
<el-select v-model="selectedEnable" class="fill-with">
|
||||||
|
<el-option label="全部" :value="-1" />
|
||||||
|
<el-option label="启用" :value="1" />
|
||||||
|
<el-option label="禁用" :value="0" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="-1">
|
||||||
|
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button @click="handleClear">清空</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
<common-table
|
<common-table
|
||||||
:table-date="userTable"
|
:table-date="userTable"
|
||||||
:table-loading="tableLoading"
|
:table-loading="tableLoading"
|
||||||
@@ -114,8 +184,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button type="primary" @click="handleSubmit" :disabled="dialogLoading"
|
<el-button type="primary" @click="handleSubmit" :disabled="dialogLoading"
|
||||||
>提交</el-button
|
>提交
|
||||||
>
|
</el-button>
|
||||||
<el-button @click="handleCancel" :disabled="dialogLoading">取消</el-button>
|
<el-button @click="handleCancel" :disabled="dialogLoading">取消</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -145,6 +215,16 @@ export default {
|
|||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
tableLoading: true,
|
tableLoading: true,
|
||||||
dialogLoading: true,
|
dialogLoading: true,
|
||||||
|
roleOptions: [],
|
||||||
|
groupOptions: [],
|
||||||
|
searchName: '',
|
||||||
|
searchRole: [],
|
||||||
|
searchGroup: [],
|
||||||
|
searchEnable: -1,
|
||||||
|
inputName: '',
|
||||||
|
selectedRole: [],
|
||||||
|
selectedGroup: [],
|
||||||
|
selectedEnable: -1,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
totalCount: 0,
|
totalCount: 0,
|
||||||
@@ -191,7 +271,14 @@ export default {
|
|||||||
loadUserTable() {
|
loadUserTable() {
|
||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
request
|
request
|
||||||
.get('/user', { currentPage: this.currentPage, pageSize: this.pageSize })
|
.get('/user', {
|
||||||
|
currentPage: this.currentPage,
|
||||||
|
pageSize: this.pageSize,
|
||||||
|
searchName: this.searchName,
|
||||||
|
searchRole: this.searchRole + '',
|
||||||
|
searchGroup: this.searchGroup + '',
|
||||||
|
searchEnable: this.searchEnable
|
||||||
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const response = res.data
|
const response = res.data
|
||||||
if (response.code === DATABASE_SELECT_OK) {
|
if (response.code === DATABASE_SELECT_OK) {
|
||||||
@@ -229,6 +316,7 @@ export default {
|
|||||||
request.get('/role/list').then((res) => {
|
request.get('/role/list').then((res) => {
|
||||||
const response = res.data
|
const response = res.data
|
||||||
if (response.code === DATABASE_SELECT_OK) {
|
if (response.code === DATABASE_SELECT_OK) {
|
||||||
|
this.roleOptions = response.data
|
||||||
this.roles = response.data
|
this.roles = response.data
|
||||||
this.getGroups()
|
this.getGroups()
|
||||||
} else {
|
} else {
|
||||||
@@ -243,6 +331,7 @@ export default {
|
|||||||
request.get('/group/list').then((res) => {
|
request.get('/group/list').then((res) => {
|
||||||
const response = res.data
|
const response = res.data
|
||||||
if (response.code === DATABASE_SELECT_OK) {
|
if (response.code === DATABASE_SELECT_OK) {
|
||||||
|
this.groupOptions = response.data
|
||||||
this.groups = response.data
|
this.groups = response.data
|
||||||
this.dialogLoading = false
|
this.dialogLoading = false
|
||||||
} else {
|
} else {
|
||||||
@@ -402,10 +491,26 @@ export default {
|
|||||||
handleCurrentChange(currentPage) {
|
handleCurrentChange(currentPage) {
|
||||||
this.currentPage = currentPage
|
this.currentPage = currentPage
|
||||||
this.loadUserTable()
|
this.loadUserTable()
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.searchName = this.inputName
|
||||||
|
this.searchRole = this.selectedRole
|
||||||
|
this.searchGroup = this.selectedGroup
|
||||||
|
this.searchEnable = this.selectedEnable
|
||||||
|
this.currentPage = 1
|
||||||
|
this.loadUserTable()
|
||||||
|
},
|
||||||
|
handleClear() {
|
||||||
|
this.inputName = ''
|
||||||
|
this.selectedRole = []
|
||||||
|
this.selectedGroup = []
|
||||||
|
this.selectedEnable = -1
|
||||||
|
this.handleQuery()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadUserTable()
|
this.loadUserTable()
|
||||||
|
this.getRoles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user