优化打手接单上限统计
This commit is contained in:
@@ -33,7 +33,6 @@ import type { CollectField, WorkOrder, WorkerUser } from '@/types/worker-platfor
|
||||
import { formatDateTime } from '@/utils/date-time'
|
||||
|
||||
type HallSummary = {
|
||||
activeCount: number
|
||||
pendingAcceptanceCount: number
|
||||
problemCount: number
|
||||
}
|
||||
@@ -82,34 +81,24 @@ export default function WorkerHallPage() {
|
||||
const hallSummaryQuery = useQuery({
|
||||
queryKey: ['worker-hall-summary'],
|
||||
queryFn: async () => {
|
||||
const [inProgressResponse, pendingAcceptanceResponse, problemResponse] =
|
||||
await Promise.all([
|
||||
fetchWorkerMyOrders({
|
||||
status: 'in_progress',
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
}),
|
||||
fetchWorkerMyOrders({
|
||||
status: 'pending_acceptance',
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
}),
|
||||
fetchWorkerMyOrders({
|
||||
status: 'problem',
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
}),
|
||||
])
|
||||
const [pendingAcceptanceResponse, problemResponse] = await Promise.all([
|
||||
fetchWorkerMyOrders({
|
||||
status: 'pending_acceptance',
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
}),
|
||||
fetchWorkerMyOrders({
|
||||
status: 'problem',
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
}),
|
||||
])
|
||||
|
||||
const pendingAcceptanceCount =
|
||||
pendingAcceptanceResponse.data.pagination.total
|
||||
const problemCount = problemResponse.data.pagination.total
|
||||
|
||||
return {
|
||||
activeCount:
|
||||
inProgressResponse.data.pagination.total +
|
||||
pendingAcceptanceCount +
|
||||
problemCount,
|
||||
pendingAcceptanceCount,
|
||||
problemCount,
|
||||
} satisfies HallSummary
|
||||
@@ -121,7 +110,7 @@ export default function WorkerHallPage() {
|
||||
const pagination = ordersQuery.data?.data.pagination
|
||||
const categories = ordersQuery.data?.data.categories || []
|
||||
const worker = profileQuery.data?.data.worker
|
||||
const activeCount = hallSummaryQuery.data?.activeCount || 0
|
||||
const activeCount = Number(profileQuery.data?.data.summary.activeOrderCount || 0)
|
||||
const pendingAcceptanceCount = hallSummaryQuery.data?.pendingAcceptanceCount || 0
|
||||
const problemCount = hallSummaryQuery.data?.problemCount || 0
|
||||
const maxActiveOrders = Number(worker?.level?.permissions.maxActiveOrders || 0)
|
||||
@@ -215,7 +204,7 @@ export default function WorkerHallPage() {
|
||||
note:
|
||||
remainingSlots === null
|
||||
? '当前等级待配置'
|
||||
: `待验收 ${pendingAcceptanceCount} 单 / 问题单 ${problemCount} 单`,
|
||||
: `待验收 ${pendingAcceptanceCount} 单 / 问题单 ${problemCount} 单(不占上限)`,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user