2026-02-28 15:29:12 +08:00
|
|
|
import { request } from '@umijs/max';
|
2026-03-30 02:56:16 +00:00
|
|
|
import type {
|
|
|
|
|
ApiResponse,
|
2026-04-20 01:58:36 +00:00
|
|
|
BoltInfo,
|
|
|
|
|
ColorDetailItem,
|
2026-03-30 02:56:16 +00:00
|
|
|
CurrentUser,
|
2026-05-24 20:05:28 +09:00
|
|
|
InventoryLog,
|
2026-03-30 02:56:16 +00:00
|
|
|
LoginParams,
|
|
|
|
|
LoginResult,
|
2026-04-20 01:58:36 +00:00
|
|
|
Menu,
|
|
|
|
|
OperationLog,
|
2026-03-30 02:56:16 +00:00
|
|
|
PaginatedData,
|
|
|
|
|
PaginationParams,
|
2026-04-20 01:58:36 +00:00
|
|
|
PanInfo,
|
|
|
|
|
PanInput,
|
2026-03-30 02:56:16 +00:00
|
|
|
Product,
|
2026-04-20 01:58:36 +00:00
|
|
|
ProductSummaryItem,
|
|
|
|
|
ProductTree,
|
2026-05-24 20:05:28 +09:00
|
|
|
PurchaseOrder,
|
|
|
|
|
PurchasePayment,
|
|
|
|
|
PurchaseReceipt,
|
|
|
|
|
PurchaseStatsByProductItem,
|
|
|
|
|
PurchaseStatsBySupplierItem,
|
|
|
|
|
PurchaseStatsSummary,
|
2026-03-30 02:56:16 +00:00
|
|
|
Relation,
|
|
|
|
|
RelationHistory,
|
2026-04-20 01:58:36 +00:00
|
|
|
Role,
|
|
|
|
|
StockAdjust,
|
|
|
|
|
StockCheck,
|
|
|
|
|
StockGroup,
|
|
|
|
|
StockSummary,
|
2026-05-24 20:05:28 +09:00
|
|
|
Supplier,
|
2026-04-20 01:58:36 +00:00
|
|
|
SystemConfig,
|
|
|
|
|
User,
|
2026-03-30 02:56:16 +00:00
|
|
|
} from '@/types/api';
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Auth ──────────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const login = (data: LoginParams) =>
|
|
|
|
|
request<ApiResponse<LoginResult>>('/api/v1/auth/login', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const logout = () =>
|
|
|
|
|
request<ApiResponse>('/api/v1/auth/logout', { method: 'POST' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getUserInfo = () =>
|
|
|
|
|
request<ApiResponse<CurrentUser>>('/api/v1/auth/info', { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const changePassword = (data: { oldPassword: string; newPassword: string }) =>
|
|
|
|
|
request<ApiResponse>('/api/v1/auth/password', { method: 'PUT', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Users ─────────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listUsers = (params: PaginationParams & { username?: string; realName?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<User>>>('/api/v1/system/users', { method: 'GET', params });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getUser = (id: string) =>
|
|
|
|
|
request<ApiResponse<User>>(`/api/v1/system/users/${id}`, { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const createUser = (data: Partial<User> & { password?: string }) =>
|
|
|
|
|
request<ApiResponse>('/api/v1/system/users', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const updateUser = (id: string, data: Partial<User>) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/users/${id}`, { method: 'PUT', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const deleteUser = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/users/${id}`, { method: 'DELETE' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const updateUserStatus = (id: string, status: number) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/users/${id}/status`, { method: 'PUT', data: { status } });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Roles ─────────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listRoles = (params?: PaginationParams & { roleName?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<Role>>>('/api/v1/system/roles', { method: 'GET', params });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const createRole = (data: Partial<Role>) =>
|
|
|
|
|
request<ApiResponse>('/api/v1/system/roles', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const updateRole = (id: string, data: Partial<Role>) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/roles/${id}`, { method: 'PUT', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const deleteRole = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/roles/${id}`, { method: 'DELETE' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const setRolePermissions = (id: string, menuIds: string[]) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/roles/${id}/permissions`, { method: 'PUT', data: { menuIds } });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Menus ─────────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listMenus = () =>
|
|
|
|
|
request<ApiResponse<PaginatedData<Menu>>>('/api/v1/system/menus', { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const createMenu = (data: Partial<Menu>) =>
|
|
|
|
|
request<ApiResponse>('/api/v1/system/menus', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const updateMenu = (id: string, data: Partial<Menu>) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/menus/${id}`, { method: 'PUT', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const deleteMenu = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/menus/${id}`, { method: 'DELETE' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Logs ──────────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listLogs = (params: PaginationParams & { username?: string; module?: string; operation?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<OperationLog>>>('/api/v1/system/logs', { method: 'GET', params });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Configs ───────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listConfigs = () =>
|
|
|
|
|
request<ApiResponse<PaginatedData<SystemConfig>>>('/api/v1/system/configs', { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const updateConfig = (key: string, value: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/system/configs/${key}`, { method: 'PUT', data: { configValue: value } });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Products ──────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-04-20 01:58:36 +00:00
|
|
|
export const listProducts = (params: PaginationParams & { productName?: string; spec?: string; color?: string }) =>
|
2026-03-30 02:56:16 +00:00
|
|
|
request<ApiResponse<PaginatedData<Product>>>('/api/v1/inventory/products', { method: 'GET', params });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getProduct = (id: string) =>
|
|
|
|
|
request<ApiResponse<Product>>(`/api/v1/inventory/products/${id}`, { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-04-20 01:58:36 +00:00
|
|
|
export const createProduct = (data: Partial<Product> & { pans?: PanInput[] }) =>
|
2026-03-30 02:56:16 +00:00
|
|
|
request<ApiResponse>('/api/v1/inventory/products', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const updateProduct = (id: string, data: Partial<Product>) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/inventory/products/${id}`, { method: 'PUT', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const deleteProduct = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/inventory/products/${id}`, { method: 'DELETE' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const exportProducts = () =>
|
|
|
|
|
request('/api/v1/inventory/products/export', { method: 'GET', responseType: 'blob' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-04-20 01:58:36 +00:00
|
|
|
// ── Product Panels ────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const getProductSummary = () =>
|
|
|
|
|
request<ApiResponse<{ list: ProductSummaryItem[] }>>('/api/v1/inventory/products/summary', { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
export const getColorDetail = (productName: string) =>
|
|
|
|
|
request<ApiResponse<{ list: ColorDetailItem[] }>>('/api/v1/inventory/products/colors', { method: 'GET', params: { productName } });
|
|
|
|
|
|
|
|
|
|
export const getProductTree = (id: string) =>
|
|
|
|
|
request<ApiResponse<ProductTree>>(`/api/v1/inventory/products/${id}/tree`, { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
// ── Pan / Bolt CRUD ───────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listPans = (productId: string) =>
|
|
|
|
|
request<ApiResponse<{ list: PanInfo[] }>>(`/api/v1/inventory/products/${productId}/pans`, { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
export const savePans = (productId: string, pans: PanInput[]) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/inventory/products/${productId}/pans`, { method: 'PUT', data: { pans } });
|
|
|
|
|
|
|
|
|
|
export const listBolts = (panId: string) =>
|
|
|
|
|
request<ApiResponse<{ list: BoltInfo[] }>>(`/api/v1/inventory/pans/${panId}/bolts`, { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
export const saveBolts = (panId: string, lengths: string[]) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/inventory/pans/${panId}/bolts`, { method: 'PUT', data: { lengths } });
|
|
|
|
|
|
|
|
|
|
// ── Pan / Bolt dimension panels ───────────────────
|
|
|
|
|
|
|
|
|
|
export const listPanView = (params: {
|
|
|
|
|
page?: number;
|
|
|
|
|
pageSize?: number;
|
|
|
|
|
productName?: string;
|
|
|
|
|
position?: string;
|
|
|
|
|
}) =>
|
|
|
|
|
request<ApiResponse<{ total: number; list: import('@/types/api').PanListItem[] }>>(
|
|
|
|
|
'/api/v1/inventory/pans',
|
|
|
|
|
{ method: 'GET', params },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export const listBoltView = (params: {
|
|
|
|
|
page?: number;
|
|
|
|
|
pageSize?: number;
|
|
|
|
|
productName?: string;
|
|
|
|
|
position?: string;
|
|
|
|
|
}) =>
|
|
|
|
|
request<ApiResponse<{ total: number; list: import('@/types/api').BoltListItem[] }>>(
|
|
|
|
|
'/api/v1/inventory/bolts',
|
|
|
|
|
{ method: 'GET', params },
|
|
|
|
|
);
|
|
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Stocks ────────────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getStockSummary = () =>
|
|
|
|
|
request<ApiResponse<StockSummary>>('/api/v1/inventory/stocks/summary', { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getStockByColor = () =>
|
|
|
|
|
request<ApiResponse<PaginatedData<StockGroup>>>('/api/v1/inventory/stocks/by-color', { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getStockByLocation = () =>
|
|
|
|
|
request<ApiResponse<PaginatedData<StockGroup>>>('/api/v1/inventory/stocks/by-location', { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Stock Checks ──────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listStockChecks = (params: PaginationParams) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<StockCheck>>>('/api/v1/inventory/checks', { method: 'GET', params });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getStockCheck = (id: string) =>
|
|
|
|
|
request<ApiResponse<StockCheck>>(`/api/v1/inventory/checks/${id}`, { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-06-18 18:33:57 +09:00
|
|
|
export const createStockCheck = (data: {
|
|
|
|
|
checkDate: string;
|
|
|
|
|
checker?: string;
|
|
|
|
|
remark?: string;
|
|
|
|
|
details?: Array<{ productId: string; actualQuantity: string; remark?: string }>;
|
|
|
|
|
}) => request<ApiResponse<{ id: string }>>('/api/v1/inventory/checks', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const confirmStockCheck = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/inventory/checks/${id}/confirm`, { method: 'POST' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
// ── Stock Adjusts ─────────────────────────────────
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const listStockAdjusts = (params: PaginationParams) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<StockAdjust>>>('/api/v1/inventory/adjusts', { method: 'GET', params });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const getStockAdjust = (id: string) =>
|
|
|
|
|
request<ApiResponse<StockAdjust>>(`/api/v1/inventory/adjusts/${id}`, { method: 'GET' });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-06-18 18:33:57 +09:00
|
|
|
export const createStockAdjust = (data: {
|
|
|
|
|
adjustDate: string;
|
|
|
|
|
adjustReason?: string;
|
|
|
|
|
remark?: string;
|
|
|
|
|
details?: Array<{ productId: string; adjustQuantity: string; remark?: string }>;
|
|
|
|
|
}) => request<ApiResponse<{ id: string }>>('/api/v1/inventory/adjusts', { method: 'POST', data });
|
2026-02-28 15:29:12 +08:00
|
|
|
|
2026-03-30 02:56:16 +00:00
|
|
|
export const approveStockAdjust = (id: string, action: number) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/inventory/adjusts/${id}/approve`, { method: 'POST', data: { action } });
|
|
|
|
|
|
|
|
|
|
// ── CRM Relations ─────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listUpstream = (depth = 1) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<Relation>>>('/api/v1/crm/graph/upstream', { method: 'GET', params: { depth } });
|
|
|
|
|
|
|
|
|
|
export const listDownstream = (depth = 1) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<Relation>>>('/api/v1/crm/graph/downstream', { method: 'GET', params: { depth } });
|
|
|
|
|
|
|
|
|
|
export const createRelation = (data: {
|
|
|
|
|
fromTenantId: string;
|
|
|
|
|
toTenantId: string;
|
|
|
|
|
relationType: string;
|
|
|
|
|
validFrom?: string;
|
|
|
|
|
validTo?: string;
|
|
|
|
|
}) =>
|
|
|
|
|
request<ApiResponse>('/api/v1/crm/relationships', { method: 'POST', data });
|
|
|
|
|
|
|
|
|
|
export const updateRelation = (id: string, data: { status: number; validFrom?: string; validTo?: string }) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/crm/relationships/${id}`, { method: 'PUT', data });
|
|
|
|
|
|
|
|
|
|
export const listRelationHistory = (params?: PaginationParams) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<RelationHistory>>>('/api/v1/crm/relationships/history', { method: 'GET', params });
|
2026-05-24 20:05:28 +09:00
|
|
|
|
|
|
|
|
// ── Suppliers ─────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listSuppliers = (params: PaginationParams & { supplierName?: string; status?: number }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<Supplier>>>('/api/v1/purchase/suppliers', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
export const getSupplier = (id: string) =>
|
|
|
|
|
request<ApiResponse<Supplier>>(`/api/v1/purchase/suppliers/${id}`, { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
export const createSupplier = (data: { supplierName: string; phone?: string; remark?: string }) =>
|
|
|
|
|
request<ApiResponse<{ id: string }>>('/api/v1/purchase/suppliers', { method: 'POST', data });
|
|
|
|
|
|
|
|
|
|
export const updateSupplier = (id: string, data: { supplierName?: string; phone?: string; status?: number; remark?: string }) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/purchase/suppliers/${id}`, { method: 'PUT', data });
|
|
|
|
|
|
|
|
|
|
export const deleteSupplier = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/purchase/suppliers/${id}`, { method: 'DELETE' });
|
|
|
|
|
|
|
|
|
|
// ── Purchase Orders ───────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listPurchaseOrders = (params: PaginationParams & { supplierId?: string; status?: number; startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<PurchaseOrder>>>('/api/v1/purchase/orders', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
export const getPurchaseOrder = (id: string) =>
|
|
|
|
|
request<ApiResponse<PurchaseOrder>>(`/api/v1/purchase/orders/${id}`, { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
export const createPurchaseOrder = (data: {
|
|
|
|
|
supplierId: string;
|
|
|
|
|
orderDate: string;
|
|
|
|
|
purchaseBy?: string;
|
|
|
|
|
remark?: string;
|
|
|
|
|
details: Array<{ productId: string; productName: string; spec?: string; color?: string; quantity: string; unitPrice: string; remark?: string }>;
|
|
|
|
|
}) =>
|
|
|
|
|
request<ApiResponse<{ id: string }>>('/api/v1/purchase/orders', { method: 'POST', data });
|
|
|
|
|
|
|
|
|
|
export const updatePurchaseOrder = (id: string, data: object) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/purchase/orders/${id}`, { method: 'PUT', data });
|
|
|
|
|
|
|
|
|
|
export const confirmPurchaseOrder = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/purchase/orders/${id}/confirm`, { method: 'POST' });
|
|
|
|
|
|
|
|
|
|
export const cancelPurchaseOrder = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/purchase/orders/${id}/cancel`, { method: 'POST' });
|
|
|
|
|
|
|
|
|
|
// ── Purchase Receipts ─────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listPurchaseReceipts = (params: PaginationParams & { orderId?: string; status?: number; startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<PurchaseReceipt>>>('/api/v1/purchase/receipts', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
export const getPurchaseReceipt = (id: string) =>
|
|
|
|
|
request<ApiResponse<PurchaseReceipt>>(`/api/v1/purchase/receipts/${id}`, { method: 'GET' });
|
|
|
|
|
|
|
|
|
|
export const createPurchaseReceipt = (data: {
|
|
|
|
|
orderId: string;
|
|
|
|
|
receiptDate: string;
|
|
|
|
|
receivedBy?: string;
|
|
|
|
|
remark?: string;
|
|
|
|
|
details: Array<{ orderDetailId: string; productId: string; actualQty: string; unitCost?: string; remark?: string }>;
|
|
|
|
|
}) =>
|
|
|
|
|
request<ApiResponse<{ id: string }>>('/api/v1/purchase/receipts', { method: 'POST', data });
|
|
|
|
|
|
|
|
|
|
export const confirmPurchaseReceipt = (id: string) =>
|
|
|
|
|
request<ApiResponse>(`/api/v1/purchase/receipts/${id}/confirm`, { method: 'POST' });
|
|
|
|
|
|
|
|
|
|
// ── Purchase Payments ─────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listPurchasePayments = (params: PaginationParams & { orderId?: string; startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<PurchasePayment>>>('/api/v1/purchase/payments', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
export const createPurchasePayment = (data: {
|
|
|
|
|
orderId: string;
|
|
|
|
|
paymentDate: string;
|
|
|
|
|
amount: string;
|
|
|
|
|
paymentMethod?: string;
|
|
|
|
|
remark?: string;
|
|
|
|
|
}) =>
|
|
|
|
|
request<ApiResponse<{ id: string }>>('/api/v1/purchase/payments', { method: 'POST', data });
|
|
|
|
|
|
|
|
|
|
// ── Purchase Stats ────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const getPurchaseStatsSummary = (params: { startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<PurchaseStatsSummary>>('/api/v1/purchase/stats/summary', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
export const getPurchaseStatsBySupplier = (params: { startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<{ list: PurchaseStatsBySupplierItem[] }>>('/api/v1/purchase/stats/by-supplier', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
export const getPurchaseStatsByProduct = (params: { startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<{ list: PurchaseStatsByProductItem[] }>>('/api/v1/purchase/stats/by-product', { method: 'GET', params });
|
|
|
|
|
|
|
|
|
|
// ── Inventory Logs ────────────────────────────────
|
|
|
|
|
|
|
|
|
|
export const listInventoryLogs = (params: PaginationParams & { productId?: string; changeType?: number; startDate?: string; endDate?: string }) =>
|
|
|
|
|
request<ApiResponse<PaginatedData<InventoryLog>>>('/api/v1/inventory/logs', { method: 'GET', params });
|