BookSystem/.trae/documents/debug_role_undefined_plan.md
jayhgq 6620aec5a2 fix(roles): 隐藏默认查看按钮并优化角色管理功能
- 在role-crud.ts中隐藏默认的查看按钮(view: { show: false })
- 优化RoleManage.vue的axios导入,仅导入isAxiosError
- 更新用户管理中的角色显示逻辑,确保正确显示角色名称
- 添加错误处理逻辑,显示友好的中文错误提示
- 更新相关构建文件和文档说明
2026-05-10 22:06:37 +08:00

26 lines
1020 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 角色显示 undefined 深度排查修复计划
## 问题分析
角色依然显示 undefined可能原因
1. `transformRes` 函数可能重置了数据,导致 `role_name` 字段丢失
2. FastCRUD 的 `dict-select` 类型本身就可以自动显示角色名称,不需要手动处理
3. `formatter` 函数可能没有正确工作
## 修复方案
| 序号 | 文件 | 修改内容 |
| :--- | :--- | :--- |
| 1 | `frontend/src/modules/admin/views/users/user-crud.ts` | 简化实现,让 FastCRUD 的 dict 功能自动处理角色显示 |
| 2 | `frontend/src/modules/admin/views/users/user-crud.ts` | 移除自定义的 role_name 处理逻辑,使用 FastCRUD 内置的 dict 功能 |
## 实施步骤
1. 修改 `role_id` 列配置,移除自定义 formatter启用 `column.dict: true`
2. 简化 `pageRequest`,移除手动设置 `role_name` 的逻辑
3. 移除不再需要的 `roleDict``loadRoleDict` 相关代码
## 风险评估
- 低风险:利用 FastCRUD 内置功能,减少自定义代码