oms/frontend/src/api/inboundOrder.ts
liufumingren 9774ee1414 feat(stock): 出入库单/记录增加货主并按货主隔离,创建人显示员工名称
- 迁移:inbound_orders / outbound_orders 增加 subsidiary_id 与索引,按仓库回填
- 单据货主由仓库决定:创建写入、改仓库同步,接口不接受直写 subsidiary_id
- 入库单/出库单列表返回 subsidiary_name 并新增货主筛选;详情/编辑/删除/审核/
  推送/完成/取消/恢复/作废/驳回与明细接口统一加货主越界 403
- 出入库记录按仓库归属货主:列表与导出收窄、返回 subsidiary_id/subsidiary_name、
  新增货主列与筛选
- 导出:入库单/出库单/出入库记录新增货主列并按所在公司权限收窄
- 新增 resolveAccountNameMap:列表/详情返回 creator_name/auditor_name/voider_name,
  创建人展示员工名称(principal_users.name),不再回退成邮箱账号
- 前端:三个列表新增货主列与筛选,创建人/作废人展示改为员工名称

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-05 15:13:22 +08:00

143 lines
5.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { get, post, put, del } from '@/utils/request'
import type { StockItemLine, StockItemPayload } from './stockOrder'
/** 入库单(单据头) */
export interface InboundOrder {
id: number
bill_no: string
principal_id: number
/** 所属货主(下属公司ID),跟随仓库 */
subsidiary_id?: number | null
/** 所属货主名称(列表/详情接口返回) */
subsidiary_name?: string
shop_id: number | null
inbound_type: string
status: number
warehouse_id: number | null
warehouse?: { id: number; code: string; name: string } | null
shop?: { id: number; name: string } | null
creator?: { id: number; nickname?: string | null; username: string } | null
/** 创建人展示名(员工名称,后端按 principal_users.name 解析) */
creator_name?: string
auditor?: { id: number; nickname?: string | null; username: string } | null
/** 审核人展示名(员工名称) */
auditor_name?: string
audit_by?: number | null
audit_time?: string | null
supplier?: string | null
supplier_code?: string | null
operator?: string | null
operator_code?: string | null
operate_time?: string | null
purchase_order_code?: string | null
expect_start_time?: string | null
expect_end_time?: string | null
logistics_code?: string | null
logistics_name?: string | null
express_code?: string | null
/** 发件人信息(仅本地留存:WMS 入库单报文不识别,不下发) */
sender_info?: Record<string, string> | null
/** 收件人信息(仅本地留存:WMS 入库单报文不识别,不下发) */
receiver_info?: Record<string, string> | null
/** 扩展属性(仅本地留存:不下发) */
extend_props?: Record<string, string> | null
pushed_at?: string | null
wms_push_result?: {
success?: boolean
code?: string | number | null
message?: string | null
flag?: string | null
entryOrderCode?: string
warehouseApiId?: number
apiType?: string
response?: unknown
error?: string
pushedAt?: string
} | null
item_total: number | string
item_kind: number | null
total_amount: number | string
remark?: string | null
void_at?: string | null
void_by?: number | null
void_reason?: string | null
voider?: { id: number; nickname?: string | null; username: string } | null
/** 作废人展示名(员工名称) */
voider_name?: string
items?: StockItemLine[]
created_at?: string
updated_at?: string
}
/** 明细行(创建时随单提交) */
export interface InboundItemInput {
product_id?: number | null
name?: string | null
code?: string | null
spec?: string | null
unit?: string | null
quantity?: number
price?: number | null
inventory_type?: 'ZP' | 'CC'
remark?: string | null
}
/** 创建 / 更新载荷 */
export interface InboundOrderPayload {
warehouse_id?: number | null
shop_id?: number | null
inbound_type?: string
status?: number
supplier?: string | null
supplier_code?: string | null
operate_time?: string | null
purchase_order_code?: string | null
expect_start_time?: string | null
expect_end_time?: string | null
logistics_code?: string | null
logistics_name?: string | null
express_code?: string | null
total_amount?: number
remark?: string | null
items?: InboundItemInput[]
}
/** 明细提交(含库存类型 ZP 正品 / CC 残次) */
export type InboundItemPayload = StockItemPayload & { inventory_type?: 'ZP' | 'CC' }
export const inboundOrderApi = {
getList: (params?: object) =>
get<{ list: InboundOrder[]; total: number; page: number; pageSize: number }>('/inbound-orders', params),
get: (id: number) => get<InboundOrder>(`/inbound-orders/${id}`),
create: (data: InboundOrderPayload) => post<{ id: number }>('/inbound-orders', data),
update: (id: number, data: Partial<InboundOrderPayload>) =>
put<{ id: number }>(`/inbound-orders/${id}`, data),
audit: (id: number) => post<{ id: number }>(`/inbound-orders/${id}/audit`),
push: (id: number) => post<{ id: number; reused?: boolean }>(`/inbound-orders/${id}/push`),
complete: (id: number) => post<{ id: number }>(`/inbound-orders/${id}/complete`),
cancel: (id: number) => post<{ id: number }>(`/inbound-orders/${id}/cancel`),
restore: (id: number) => post<{ id: number }>(`/inbound-orders/${id}/restore`),
/** 作废:仅「已审核(2)」可作废,记录作废人/时间/原因,不可恢复 */
voidOrder: (id: number, data?: { void_reason?: string }) =>
post<{ id: number }>(`/inbound-orders/${id}/void`, data || {}),
/** 驳回:已审核(2)/已推送(3) 且未完成 -> 回到待入库(1),已推送的先走接口取消外部单据 */
reject: (id: number) => post<{
id: number
bill_no?: string
cancel?: { attempted: boolean; success: boolean; orderType?: string; message?: string }
}>(`/inbound-orders/${id}/reject`),
remove: (id: number) => del<{ id: number }>(`/inbound-orders/${id}`),
/** 明细列表(复用通用 stock_items,bill_type=1 入库) */
getItems: (billId: number, params?: object) =>
get<{ list: StockItemLine[]; total: number; page: number; pageSize: number }>('/stock-items', {
bill_id: billId,
bill_type: 1,
...params,
}),
createItem: (data: InboundItemPayload) =>
post<{ id: number }>('/stock-items', { ...data, bill_type: 1 }),
updateItem: (id: number, data: Partial<InboundItemPayload>) =>
put<{ id: number }>(`/stock-items/${id}`, data),
removeItem: (id: number) => del<{ id: number }>(`/stock-items/${id}`),
}