Skip to content

fix(department): 修复部门成员显示报错#720

Merged
zds-s merged 1 commit intomineadmin:masterfrom
westng:fix/department-member-display-error
Apr 3, 2026
Merged

fix(department): 修复部门成员显示报错#720
zds-s merged 1 commit intomineadmin:masterfrom
westng:fix/department-member-display-error

Conversation

@westng
Copy link
Copy Markdown
Member

@westng westng commented Apr 2, 2026

描述

本次更新修复了部门管理中“部门成员”查看弹窗的显示报错问题。

本次修改优化了部门成员数据的表格渲染逻辑,并针对 department_users 字段增加了安全兜底处理,避免在接口返回数据为空、结构
不完整或字段映射不一致时出现运行时报错。同时,补充并校正了部门相关的前端类型定义,使其与接口实际返回结构保持一致,包括部
门层级数据及成员关联字段,从而提升页面展示的稳定性与代码的可维护性。

预期

image

Summary by CodeRabbit

发布说明

  • 新特性

    • 部门数据模型扩展:支持父子层级、时间戳与状态字段,并可展示领导、职位与部门成员等关联信息。
  • 优化

    • 部门用户视图表格重构:采用更可靠的表格初始化与数据绑定机制,实时同步部门成员数据并在初始化失败时记录错误;调整表格选项与样式细节以提升显示与交互体验。

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 52038a4a-ff0c-43aa-a35f-f94565256ae2

📥 Commits

Reviewing files that changed from the base of the PR and between 86fdcac and bdc03cf.

📒 Files selected for processing (2)
  • web/src/modules/base/api/department.ts
  • web/src/modules/base/views/permission/department/viewUser.vue
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/modules/base/views/permission/department/viewUser.vue
  • web/src/modules/base/api/department.ts

📝 Walkthrough

Walkthrough

扩展了部门 API 的 TypeScript 接口,新增 DepartmentUserPivotVoDepartmentUserVo,并扩展 DepartmentVo 的关联与时间字段;将部门用户列表视图的表格初始化从属性驱动改为基于 useTable('tableRef') 的命令式设置,调整数据绑定与列/选项应用方式,添加错误日志。

Changes

Cohort / File(s) Summary
数据接口扩展
web/src/modules/base/api/department.ts
新增 DepartmentUserPivotVoDepartmentUserVo 接口;扩展 DepartmentVo,加入 parent_id、时间戳字段、children?: DepartmentVo[]leader?: LeaderVo[]positions?: PositionVo[]department_users?: DepartmentUserVo[] 及索引签名;添加对 LeaderVoPositionVo 的导入。
组件表格配置重构
web/src/modules/base/views/permission/department/viewUser.vue
<ma-table>:options/:columns 属性驱动替换为 useTable('tableRef') 命令式初始化;行数据由 data?.department_users 计算并通过 tableRef.value?.setData(rows) 更新;列与选项在 table 初始化后通过 setColumns/setOptions 应用;增加初始化失败的 console.error 日志;仅样式微调。

Sequence Diagram(s)

(无 —— 更改为类型声明与单组件表格初始化重构,不符合生成序列图的条件)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug, size:S

Suggested reviewers

  • kanyxmo
  • zds-s

兔兔之歌

🐰 新字段跳出巢,接口枝叶又延伸
🌿 children 成行列,用户关联紧相邻
🛠️ 表格由钩子掌,数据更新更从容
✨ 小兔鼓掌喜洋洋,改动清晰又欢畅

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题清晰地表明了主要修复内容:修复部门成员显示报错。标题与变更集相符,涉及的两个文件都是围绕解决部门成员表格显示和类型定义问题。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/modules/base/views/permission/department/viewUser.vue`:
- Around line 49-59: The watch created inside the useTable(...).then(...)
callback is not being cleaned up and the promise has no error handling; capture
the unwatch function returned by watch (use a scoped variable, e.g., let
unwatch: ReturnType<typeof watch> or similar) and call it in onUnmounted to stop
the watcher when the component is destroyed, and add promise rejection handling
for useTable(tableRef) (attach .catch(...) or convert to async/await with
try/catch) to log/handle initialization errors; refer to useTable, tableRef,
MaTableExpose, table.setOptions, watch, tableData, and onUnmounted to locate and
implement these changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 01e77233-0699-44e0-9650-3f291fb7c6a1

📥 Commits

Reviewing files that changed from the base of the PR and between 06a8155 and 86fdcac.

📒 Files selected for processing (2)
  • web/src/modules/base/api/department.ts
  • web/src/modules/base/views/permission/department/viewUser.vue

@westng westng force-pushed the fix/department-member-display-error branch from 86fdcac to bdc03cf Compare April 2, 2026 05:02
@zds-s
Copy link
Copy Markdown
Member

zds-s commented Apr 2, 2026

@kanyxmo

@zds-s zds-s merged commit 7948261 into mineadmin:master Apr 3, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants