feat(role): 添加角色用户关系管理功能并优化处方列表组件 bug#182
- 在SysUserRoleMapper中新增selectUserIdsByRoleId方法查询角色下的用户ID列表 - 在SysRoleServiceImpl中注入ISysMenuService并实现菜单缓存清理逻辑 - 修改updateRole方法在角色权限变更后清除相关用户的菜单缓存 - 更新处方列表组件确保showPopover初始值为false避免自动弹出问题 - 将采购入库页面的按钮文本从"添加记录"改为"采购入库" - 添加删除验证检查已审批记录不允许删除的功能
This commit is contained in:
@@ -54,9 +54,17 @@ public interface SysUserRoleMapper {
|
|||||||
/**
|
/**
|
||||||
* 批量取消授权用户角色
|
* 批量取消授权用户角色
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleId 角色 ID
|
||||||
* @param userIds 需要删除的用户数据ID
|
* @param userIds 需要删除的用户数据 ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
|
public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过角色 ID 查询用户 ID 列表
|
||||||
|
*
|
||||||
|
* @param roleId 角色 ID
|
||||||
|
* @return 用户 ID 列表
|
||||||
|
*/
|
||||||
|
public List<Long> selectUserIdsByRoleId(Long roleId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.core.system.mapper.SysRoleDeptMapper;
|
|||||||
import com.core.system.mapper.SysRoleMapper;
|
import com.core.system.mapper.SysRoleMapper;
|
||||||
import com.core.system.mapper.SysRoleMenuMapper;
|
import com.core.system.mapper.SysRoleMenuMapper;
|
||||||
import com.core.system.mapper.SysUserRoleMapper;
|
import com.core.system.mapper.SysUserRoleMapper;
|
||||||
|
import com.core.system.service.ISysMenuService;
|
||||||
import com.core.system.service.ISysRoleService;
|
import com.core.system.service.ISysRoleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -41,6 +42,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleDeptMapper roleDeptMapper;
|
private SysRoleDeptMapper roleDeptMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询角色数据
|
* 根据条件分页查询角色数据
|
||||||
*
|
*
|
||||||
@@ -221,11 +225,23 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int updateRole(SysRole role) {
|
public int updateRole(SysRole role) {
|
||||||
// 修改角色信息
|
// 1. 获取该角色下的所有用户 ID(在修改权限前查询)
|
||||||
|
List<Long> userIds = userRoleMapper.selectUserIdsByRoleId(role.getRoleId());
|
||||||
|
|
||||||
|
// 2. 修改角色信息
|
||||||
roleMapper.updateRole(role);
|
roleMapper.updateRole(role);
|
||||||
// 删除角色与菜单关联
|
// 3. 删除角色与菜单关联
|
||||||
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
||||||
return insertRoleMenu(role);
|
int result = insertRoleMenu(role);
|
||||||
|
|
||||||
|
// 4. 清除该角色下所有用户的菜单树缓存
|
||||||
|
if (userIds != null && !userIds.isEmpty()) {
|
||||||
|
for (Long userId : userIds) {
|
||||||
|
menuService.clearMenuCacheByUserId(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,4 +48,10 @@
|
|||||||
#{userId}
|
#{userId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectUserIdsByRoleId" resultType="Long">
|
||||||
|
select user_id
|
||||||
|
from sys_user_role
|
||||||
|
where role_id = #{roleId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1550,6 +1550,8 @@ function getListInfo(addNewRow) {
|
|||||||
adviceType_dictText: adviceType_dictText,
|
adviceType_dictText: adviceType_dictText,
|
||||||
// 🎯 修复:确保 orgId 被正确设置(从 positionId 映射)
|
// 🎯 修复:确保 orgId 被正确设置(从 positionId 映射)
|
||||||
orgId: item.positionId || item.orgId,
|
orgId: item.positionId || item.orgId,
|
||||||
|
// 🔧 Bug Fix: 确保 showPopover 为 false,避免患者切换时表格自动弹出
|
||||||
|
showPopover: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<!-- v-hasPermi="['system:user:add']" -->
|
<!-- v-hasPermi="['system:user:add']" -->
|
||||||
<el-button type="primary" plain icon="Plus" @click="openAddInventoryReceiptDialog"
|
<el-button type="primary" plain icon="Plus" @click="openAddInventoryReceiptDialog"
|
||||||
>添加记录</el-button
|
>采购入库</el-button
|
||||||
>
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
@@ -647,6 +647,13 @@ function handleDelete(row) {
|
|||||||
// 获取选中行的单据号列表
|
// 获取选中行的单据号列表
|
||||||
const busNoList = selectedRows.value.map((item) => item.supplyBusNo);
|
const busNoList = selectedRows.value.map((item) => item.supplyBusNo);
|
||||||
|
|
||||||
|
// 检查选中记录中是否有已审批的数据
|
||||||
|
const approvedRows = selectedRows.value.filter((item) => item.statusEnum);
|
||||||
|
if (approvedRows.length > 0) {
|
||||||
|
proxy.$modal.msgWarning('已审批的记录不能删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
proxy.$modal
|
proxy.$modal
|
||||||
.confirm('是否确认删除以上数据?')
|
.confirm('是否确认删除以上数据?')
|
||||||
.then(function () {
|
.then(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user