fix(admin): load picker warehouses from domestic master

This commit is contained in:
2026-08-26 11:42:46 +08:00
parent 011195012b
commit 8307510fc3
3 changed files with 127 additions and 24 deletions
+32 -7
View File
@@ -1,5 +1,4 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import { overseasHttp } from '@/shared/api/overseasHttp'
import type { PlatformPermissionResource } from '@/shared/types/platformPermission'
export type { PlatformPermissionResource } from '@/shared/types/platformPermission'
@@ -277,6 +276,11 @@ export interface PlatformUserOptions {
roles: Array<{ id: number | string; tenantId: number | string; roleCode: string; name: string; status: string }>
}
interface PlatformUserOptionsPayload {
tenants: PlatformUserOptions['tenants']
roles: Array<Omit<PlatformUserOptions['roles'][number], 'roleCode'>>
}
export interface SharedReceivingOverseasWarehouseOption {
id: string
warehouseCode: string
@@ -565,15 +569,27 @@ export async function listPlatformManagedUsers(query: PlatformManagedUserQuery)
}
}
export function getPlatformUserOptions() {
return getData<PlatformUserOptions>('/platform/v1/iam/users/options')
export async function getPlatformUserOptions(): Promise<PlatformUserOptions> {
const [optionsResponse, rolesResponse] = await Promise.all([
http.get<ApiEnvelope<PlatformUserOptionsPayload>, ApiEnvelope<PlatformUserOptionsPayload>>('/platform/v1/iam/users/options'),
http.get<ApiEnvelope<PlatformRoleResource[]>, ApiEnvelope<PlatformRoleResource[]>>('/platform/v1/iam/roles'),
])
const options = unwrapApiResponse(optionsResponse)
const roleCodes = new Map(unwrapApiResponse(rolesResponse).map((role) => [String(role.id), role.roleCode]))
return {
tenants: options.tenants,
roles: options.roles.map((role) => ({
...role,
roleCode: roleCodes.get(String(role.id)) ?? '',
})),
}
}
export async function listSharedReceivingOverseasWarehouseOptions() {
interface WarehousePage {
records: Array<{
id: number | string
customerId: number | string
tenantId: number | string
warehouseCode: string
warehouseName: string
warehouseType: string
@@ -581,12 +597,21 @@ export async function listSharedReceivingOverseasWarehouseOptions() {
status: string
}>
}
const response = await overseasHttp.get<ApiEnvelope<WarehousePage>, ApiEnvelope<WarehousePage>>(
const response = await http.get<ApiEnvelope<WarehousePage>, ApiEnvelope<WarehousePage>>(
'/platform/v1/warehouse-admin',
{ params: { customerId: '0', page: 1, size: 200, capabilityCode: 'RECEIVING', status: 'ACTIVE' } },
{
params: {
tenantId: '0',
page: 1,
size: 200,
capabilityCode: 'RECEIVING',
warehouseType: 'OVERSEAS',
status: 'ACTIVE',
},
},
)
return unwrapApiResponse(response).records
.filter((warehouse) => String(warehouse.customerId) === '0'
.filter((warehouse) => String(warehouse.tenantId) === '0'
&& warehouse.warehouseType === 'OVERSEAS'
&& warehouse.status === 'ACTIVE')
.map((warehouse) => ({