Skip to content

fix: system role member list display - #8287

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_sysRoleMemberListDisplay
Dec 3, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_sysRoleMemberListDisplay

Conversation

@shaohuzhang1

@shaohuzhang1 shaohuzhang1 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

【【角色管理】角色成员列表中,同一个成员的不同记录没有合并显示】
https://www.tapd.cn/tapd_fe/45245355/bug/detail/1145245355001081034

:span-method="objectSpanMethod"
@current-change="loadMembers()"
@size-change="loadMembers()"
:max-table-height="290"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review of the diff

Correctness / potential issues

  1. column.type === 'selection' assumption is fragile. With span-method, Element Plus still renders one selection checkbox per row, but merged rows get [0, 0], so hidden checkboxes disappear. The header "select all" and the internal selection state then no longer map 1:1 to visible checkboxes. Verify that selection-group-key="user_id" + span merging yields the intended UX (e.g., selecting a merged row selects only the first visually rendered row). Relying on column.type === 'selection' instead of column.property is correct for the checkbox column, but confirm it stays stable across Element Plus versions.

  2. Merge requires contiguous, sorted records. objectSpanMethod merges only consecutive rows with the same user_id. If the backend returns users interleaved (e.g., by role), you'll get multiple fragments per user and unstable spans. Ensure data ordering guarantees grouping, or sort client-side before rendering (but beware sorting interacts with server pagination).

  3. Pagination breaks the merge. Merging is computed from members.value only, so a user spanning a page boundary will render as separate groups on each page. Acceptable, but worth documenting.

  4. Whole-table scan is O(n²) in the worst case. For every non-merged row the while loop re-scans forward. On large lists, this is repeated work. A single precomputed pass is cheaper:

    const spanMap = computed(() => {
      const m = new Map<number, [number, number]>()
      const rows = members.value
      for (let i = 0; i < rows.length; ) {
        let j = i + 1
        while (j < rows.length && rows[j].user_id === rows[i].user_id) j++
        m.set(i, [j - i, 1])
        for (let k = i + 1; k < j; k++) m.set(k, [0, 0])
        i = j
      }
      return m
    })

    Then lookup by rowIndex in objectSpanMethod. Note: if you memoize, key it off members reactively (the computed does that) rather than calling inside the render function each time.

  5. Reactivity inside span-method. Reading members.value inside a render-time callback is fine since it's reactive, but the method is invoked frequently during table layout. The precomputed map above avoids repeated array access.

  6. row.user_id may be undefined/null. If user_id is missing, undefined === undefined merges all such rows together incorrectly. Add a guard:

    if (userId == null) return
  7. Signature duplication. The inline parameter type duplicates TableColumnCtx<RoleMember> details; consider using the exported helper type for span-method params (or TableSpanMethod) to avoid drift.

Style / minor

  1. Lines exceed typical line length (the shouldMerge expression). Consider wrapping.
  2. Comment is in Chinese while the request asked for English review — just noting consistency, not a bug.
  3. while (...) rowspan += 1 could use braces for readability.

Summary

Logic is basically sound for contiguous, non-paginated groups. Main risks: interleaved/unordered data, pagination splits, null user_id, and the check-all semantics of merged selection columns. Recommend replacing the per-row forward scan with a precomputed span map and adding guards.

@fit2cloudwxx
fit2cloudwxx merged commit ede8945 into v3 Dec 3, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@fix_sysRoleMemberListDisplay branch December 3, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants