feat(cost-center): 成本中心与商品映射开发草案 (含文档与订单页调整 WIP)
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
import { apiGet, apiPatch, apiPost } from '@/lib/http'
|
||||
import type {
|
||||
ChannelProductMapping,
|
||||
ChannelProductMappingListResult,
|
||||
CostCenterOptions,
|
||||
CostCenterOverview,
|
||||
CostException,
|
||||
CostExceptionListResult,
|
||||
CostItem,
|
||||
CostItemListResult,
|
||||
CostPreview,
|
||||
CostVersion,
|
||||
CostVersionListResult,
|
||||
ProductCatalogItem,
|
||||
ProductCatalogListResult,
|
||||
TemplateProductBootstrapPreview,
|
||||
TemplateProductBootstrapResult,
|
||||
} from '@/types/admin'
|
||||
|
||||
export function fetchAdminCostCenterOverview() {
|
||||
return apiGet<CostCenterOverview>('/api/v1/admin/cost-center/overview')
|
||||
}
|
||||
|
||||
export function fetchAdminCostCenterOptions() {
|
||||
return apiGet<CostCenterOptions>('/api/v1/admin/cost-center/options')
|
||||
}
|
||||
|
||||
export function previewAdminTemplateProductBootstrap() {
|
||||
return apiGet<TemplateProductBootstrapPreview>(
|
||||
'/api/v1/admin/cost-center/template-bootstrap/preview',
|
||||
)
|
||||
}
|
||||
|
||||
export function applyAdminTemplateProductBootstrap() {
|
||||
return apiPost<TemplateProductBootstrapResult>(
|
||||
'/api/v1/admin/cost-center/template-bootstrap/apply',
|
||||
{ repair: true },
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminProductCatalog(params?: Record<string, unknown>) {
|
||||
return apiGet<ProductCatalogListResult>('/api/v1/admin/cost-center/products', params)
|
||||
}
|
||||
|
||||
export function createAdminProductCatalog(payload: Record<string, unknown>) {
|
||||
return apiPost<{ product: ProductCatalogItem }>('/api/v1/admin/cost-center/products', payload)
|
||||
}
|
||||
|
||||
export function updateAdminProductCatalog(productId: number, payload: Record<string, unknown>) {
|
||||
return apiPatch<{ product: ProductCatalogItem }>(
|
||||
`/api/v1/admin/cost-center/products/${productId}`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminChannelProductMappings(params?: Record<string, unknown>) {
|
||||
return apiGet<ChannelProductMappingListResult>('/api/v1/admin/cost-center/mappings', params)
|
||||
}
|
||||
|
||||
export function createAdminChannelProductMapping(payload: Record<string, unknown>) {
|
||||
return apiPost<{ mapping: ChannelProductMapping }>('/api/v1/admin/cost-center/mappings', payload)
|
||||
}
|
||||
|
||||
export function updateAdminChannelProductMapping(
|
||||
mappingId: number,
|
||||
payload: Record<string, unknown>,
|
||||
) {
|
||||
return apiPatch<{ mapping: ChannelProductMapping }>(
|
||||
`/api/v1/admin/cost-center/mappings/${mappingId}`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function backfillAdminProductMappings(payload: Record<string, unknown>) {
|
||||
return apiPost<{
|
||||
updatedCount: number
|
||||
limit: number
|
||||
batches: number
|
||||
remainingCount: number
|
||||
}>('/api/v1/admin/cost-center/mappings/backfill', payload)
|
||||
}
|
||||
|
||||
export function backfillAdminNormalizedQuantities(payload: Record<string, unknown>) {
|
||||
return apiPost<{
|
||||
updatedCount: number
|
||||
limit: number
|
||||
batches: number
|
||||
remainingCount: number
|
||||
}>('/api/v1/admin/cost-center/normalized-quantities/backfill', payload)
|
||||
}
|
||||
|
||||
export function fetchAdminCostItems(params?: Record<string, unknown>) {
|
||||
return apiGet<CostItemListResult>('/api/v1/admin/cost-center/cost-items', params)
|
||||
}
|
||||
|
||||
export function createAdminCostItem(payload: Record<string, unknown>) {
|
||||
return apiPost<{ costItem: CostItem }>('/api/v1/admin/cost-center/cost-items', payload)
|
||||
}
|
||||
|
||||
export function updateAdminCostItem(costItemId: number, payload: Record<string, unknown>) {
|
||||
return apiPatch<{ costItem: CostItem }>(
|
||||
`/api/v1/admin/cost-center/cost-items/${costItemId}`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminCostVersions(params?: Record<string, unknown>) {
|
||||
return apiGet<CostVersionListResult>('/api/v1/admin/cost-center/cost-versions', params)
|
||||
}
|
||||
|
||||
export function createAdminCostVersion(payload: Record<string, unknown>) {
|
||||
return apiPost<{ version: CostVersion }>('/api/v1/admin/cost-center/cost-versions', payload)
|
||||
}
|
||||
|
||||
export function retireAdminCostVersion(versionId: number, payload: Record<string, unknown>) {
|
||||
return apiPatch<{ version: CostVersion }>(
|
||||
`/api/v1/admin/cost-center/cost-versions/${versionId}/retire`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminCostExceptions(params?: Record<string, unknown>) {
|
||||
return apiGet<CostExceptionListResult>('/api/v1/admin/cost-center/exceptions', params)
|
||||
}
|
||||
|
||||
export function resolveAdminCostException(exceptionId: number, payload: Record<string, unknown>) {
|
||||
return apiPatch<{ exception: CostException }>(
|
||||
`/api/v1/admin/cost-center/exceptions/${exceptionId}`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function previewAdminCost(payload: Record<string, unknown>) {
|
||||
return apiPost<CostPreview>('/api/v1/admin/cost-center/preview', payload)
|
||||
}
|
||||
|
||||
export function createAdminCostSnapshot(payload: Record<string, unknown>) {
|
||||
return apiPost<{
|
||||
preview: CostPreview
|
||||
snapshots: Array<Record<string, unknown>>
|
||||
createdCount: number
|
||||
exceptionCreatedCount: number
|
||||
}>('/api/v1/admin/cost-center/snapshots', payload)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
export * from './auth'
|
||||
export * from './dashboard'
|
||||
export * from './finance'
|
||||
export * from './cost-center'
|
||||
export * from './fund'
|
||||
export * from './users'
|
||||
export * from './audit-logs'
|
||||
|
||||
Reference in New Issue
Block a user