WEB/src/api/storage.stockout/stockout.ts
liufumingren 3ef327e0b8 1
2026-08-26 09:04:05 +08:00

238 lines
5.6 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 request from '@/utils/request'
const v = "1.0"
// ── storage.stockout.list ──
export type StockoutListParams = {
pagination?: {
page?: number
pageSize?: number
}
where?: Record<string, unknown>
sort?: {
sortField?: string
sortOrder?: string
}
}
export type StockoutListResponse = {
list: Record<string, unknown>[]
pagination: {
page?: number
pageSize?: number
total?: number
totalPages?: number
hasPrevious?: boolean
hasNext?: boolean
}
}
export const stockoutList = (data: StockoutListParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.list',
v,
timestamp: new Date().getTime()
},
data: data
})
}
// ── storage.stockout.listItems ──
export type StockoutListItemsParams = {
/** 出库单号(推荐) */
stockout_order_code?: string
/** 出库单ID,与 stockout_order_code 至少传一个 */
id?: number
/** @deprecated 旧参数名,兼容 delivery_order_code */
delivery_order_code?: string
}
export type StockoutListItemsResponse = {
order: Record<string, unknown>
list: Record<string, unknown>[]
}
export const stockoutListItems = (data: StockoutListItemsParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.listItems',
v,
timestamp: new Date().getTime()
},
data: data
})
}
// ── storage.stockout.toOrder ──
export type StockoutToOrderReceiverInfo = {
name?: string
mobile?: string
tel?: string
province?: string
city?: string
area?: string
town?: string
detailAddress?: string
zipCode?: string
}
export type StockoutToOrderParams = {
/** 出库单ID(必填) */
id: number
/** 新订单号,不传自动生成(SK 前缀) */
delivery_order_code?: string
/** 收件人信息,不传时新订单收货信息为空 */
receiverInfo?: StockoutToOrderReceiverInfo
}
export type StockoutToOrderResponse = {
/** 出库单ID */
id: number
/** 出库单号 */
stockout_order_code: string
/** 新订单ID */
order_id: number
/** 新订单号 */
delivery_order_code: string
/** 订单步骤(0=待审核,1=待处理) */
step?: number
}
/** 将非订单出库单转为正式销售订单:新订单 create_channel 固定为 STOCKOUT;转单成功后原出库单置为 CANCELLED(幂等,重复调用返回原订单信息)。仅 CREATED / PENDING 状态允许转单 */
export const stockoutToOrder = (data: StockoutToOrderParams): Promise<StockoutToOrderResponse> => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.toOrder',
v,
timestamp: new Date().getTime()
},
data: data
})
}
// ── storage.stockout.confirm ──
export type StockoutConfirmParams = {
/** 出库单ID(必填) */
id: number
}
export type StockoutConfirmResponse = {
id: number
stockout_order_code: string
order_status: string
logisticsName: string
/** 运单号(取自表中 express_code 字段) */
expressCode: string
/** 运单号列表(取自表中 express_codes 字段) */
expressCodes?: string[]
}
/** 直出确认出库单:不改变内部库存,按出库单明细计划数量(plan_qty)直接确认,状态推进到 COMPLETED。要求 express_code 已填写 */
export const stockoutConfirm = (data: StockoutConfirmParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.confirm',
v,
timestamp: new Date().getTime()
},
data: data
})
}
// ── storage.stockout.updateExpress ──
export type StockoutUpdateExpressParams = {
/** 出库单ID(必填) */
id: number
/** 运单号 */
express_code?: string
/** 运单号列表(JSON 数组) */
express_codes?: string[]
}
export type StockoutUpdateExpressResponse = {
id: number
stockout_order_code: string
express_code?: string
express_codes?: string[]
}
/** 更新出库单的运单号字段(express_code / express_codes),用于在确认前填写运单信息 */
export const stockoutUpdateExpress = (data: StockoutUpdateExpressParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.updateExpress',
v,
timestamp: new Date().getTime()
},
data: data
})
}
// ── storage.stockout.listLogs ──
export type StockoutLogItem = {
id: number
/** 操作编码(STOCKOUT_TO_ORDER / STOCKOUT_CONFIRM / STOCKOUT_CANCEL / STOCKOUT_UPDATE_INFO 等) */
operation_code: string
/** 操作名称(后端按编码解析) */
operation_name?: string
/** 操作人姓名 */
operator_name?: string
/** 格式化后的操作时间 */
created_at: string
platform_code?: string
platform_name?: string
/** 日志内容 */
message?: string
}
export type StockoutListLogsParams = {
/** 出库单ID(与 stockout_order_code 至少传一个) */
id?: number
/** 出库单号 */
stockout_order_code?: string
/** 页码(也支持 pagination.page) */
page?: number
/** 每页数量 */
pageSize?: number
}
export type StockoutListLogsResponse = {
list: StockoutLogItem[]
pagination: {
page: number
pageSize: number
total: number
totalPages: number
}
}
/** 查询出库单操作日志(business_type=stockout),按创建时间倒序分页 */
export const stockoutListLogs = (data: StockoutListLogsParams) => {
return request({
url: `/system`,
method: 'post',
params: {
method: 'storage.stockout.listLogs',
v,
timestamp: new Date().getTime()
},
data: data
})
}