fix(组织架构):员工档案超500条分页器误显共500条 组织中心loadEmployees单页page_size=500拉取后丢弃服务端total,本地分页只在取回的500条里翻,最早建档的员工(现700人被截断200人)在列表永远不可见、搜索正常但列表翻不到。新增listAllOrgEmployees分页循环拉全量helper(与4e071f9 listAllTrainingMembers同款),loadEmployees改用之
This commit is contained in:
1 parent
4e071f9da0
commit
6a746cf810
2 files changed
+25
-4
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
import { get, post, put, del } from '@/utils/request'
|
import { get, post, put, del } from '@/utils/request'
|
||||||
|
import { unwrap } from '@/api/training'
|
||||||
import type { WecomSyncSummary } from '@/api/training'
|
import type { WecomSyncSummary } from '@/api/training'
|
||||||
|
|
||||||
// 组织中心(租户级共享组织架构)API 封装,对应后端 /api/v1/org/*(routes_org.go)。
|
// 组织中心(租户级共享组织架构)API 封装,对应后端 /api/v1/org/*(routes_org.go)。
|
||||||
@@ -79,6 +80,27 @@ export const deleteDept = (id: string) => del<{ success: boolean }>(`${base}/dep
|
|||||||
export const listEmployees = (query?: OrgListQuery) =>
|
export const listEmployees = (query?: OrgListQuery) =>
|
||||||
get<{ success: boolean; data: OrgPagedData<OrgEmployee> }>(`${base}/employees`, { params: query })
|
get<{ success: boolean; data: OrgPagedData<OrgEmployee> }>(`${base}/employees`, { params: query })
|
||||||
|
|
||||||
|
// listAllOrgEmployees 拉取全量员工档案(分页循环,直到取满 total 或空页)。
|
||||||
|
// [2026-11-30] 档案超过 500 条后,单页 page_size=500 会把最早建档的员工截断
|
||||||
|
// 在第一页之外,组织架构员工档案分页器误显「共500条」—— 与 listAllTrainingMembers
|
||||||
|
// 同根因(4e071f9 修了培训侧 7 处,组织中心此处漏网),选人/列表场景一律用本
|
||||||
|
// helper 拉全量,名册继续增长也不再复发。
|
||||||
|
export async function listAllOrgEmployees(
|
||||||
|
query?: Omit<OrgListQuery, 'page' | 'page_size'>,
|
||||||
|
pageSize = 500,
|
||||||
|
): Promise<OrgEmployee[]> {
|
||||||
|
const out: OrgEmployee[] = []
|
||||||
|
for (let page = 1; page <= 100; page++) {
|
||||||
|
const res = await listEmployees({ ...query, page, page_size: pageSize })
|
||||||
|
const pageData = unwrap<OrgPagedData<OrgEmployee>>(res)
|
||||||
|
const items = pageData?.items || []
|
||||||
|
out.push(...items)
|
||||||
|
const total = Number(pageData?.total || 0)
|
||||||
|
if (!items.length || (total > 0 && out.length >= total)) break
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
export interface OrgPlatformUser {
|
export interface OrgPlatformUser {
|
||||||
id: string
|
id: string
|
||||||
username: string
|
username: string
|
||||||
|
|||||||
@@ -305,8 +305,8 @@ import {
|
|||||||
deleteDept,
|
deleteDept,
|
||||||
importEmployees,
|
importEmployees,
|
||||||
listAdoptableUsers,
|
listAdoptableUsers,
|
||||||
|
listAllOrgEmployees,
|
||||||
listDepts,
|
listDepts,
|
||||||
listEmployees,
|
|
||||||
listPlatformUsers,
|
listPlatformUsers,
|
||||||
ORG_MODULE_TRAINING,
|
ORG_MODULE_TRAINING,
|
||||||
previewOrgWecomSync,
|
previewOrgWecomSync,
|
||||||
@@ -589,15 +589,14 @@ watch(pickerUserIds, (ids) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 员工列表:module_key='training' 联查职称角色展示;keyword 按姓名/工号/部门过滤。
|
// 员工列表:module_key='training' 联查职称角色展示;keyword 按姓名/工号/部门过滤。
|
||||||
|
// 分页循环拉全量(page_size=500 单页会把最早建档的员工截断,分页器误显「共500条」)。
|
||||||
const loadEmployees = async () => {
|
const loadEmployees = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const e = await listEmployees({
|
employees.value = await listAllOrgEmployees({
|
||||||
module_key: ORG_MODULE_TRAINING,
|
module_key: ORG_MODULE_TRAINING,
|
||||||
keyword: keyword.value.trim() || undefined,
|
keyword: keyword.value.trim() || undefined,
|
||||||
page_size: 500,
|
|
||||||
})
|
})
|
||||||
employees.value = unwrap(e)?.items || []
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user