605 lines
13 KiB
TypeScript
605 lines
13 KiB
TypeScript
import request from '@/utils/request'
|
||
|
||
const v = "1.0";
|
||
|
||
export type StockWarehouseListSort = {
|
||
sortField?: string
|
||
sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC'
|
||
}
|
||
|
||
export type StockWarehouseListParams = {
|
||
pagination?: {
|
||
page?: number
|
||
pageSize?: number
|
||
}
|
||
where?: Record<string, any>
|
||
sort?: StockWarehouseListSort
|
||
}
|
||
|
||
export function stockWarehouse(pagination: any, data: any, sort?: StockWarehouseListSort) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.list',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: { pagination, where: data, sort },
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
/** 外仓商品列表 */
|
||
export function stockWarehouseExternalList(params: {
|
||
warehouse_id?: number | string
|
||
pagination?: { page?: number; pageSize?: number }
|
||
where?: Record<string, any>
|
||
sort?: StockWarehouseListSort
|
||
}) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.externalList',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: {
|
||
warehouse_id: params.warehouse_id,
|
||
pagination: params.pagination,
|
||
where: params.where,
|
||
sort: params.sort
|
||
},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
/** 提交外仓商品导出任务,返回 task_id/status/progress/message/result/error/update_time */
|
||
export function stockWarehouseExternalExport(data: {
|
||
warehouse_id?: number
|
||
where?: Record<string, any>
|
||
sort?: StockWarehouseListSort
|
||
}) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.externalExport',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data || {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getProhibitedType() {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getProhibitedType',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
// 未使用,获取违禁品(限制品)列表
|
||
export function getProhibitedList() {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getProhibitedList',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getInfo(id: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getInfo',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: { id },
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function saveWarehouseStock(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.saveWarehouseStock',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getBarcodes(id: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getBarcodes',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: { id },
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function saveWarehouseStockBarcode(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.saveWarehouseStockBarcode',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getStoreStocks(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getStoreStocks',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function bindItem(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.bindItem',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function unbindItem(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.unbindItem',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function queryStockLogs(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.queryStockLogs',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getStockUnits() {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getStockUnits',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getUnitList() {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getUnitList',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function createUnit(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.createUnit',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
// export function getBoxUnits() {
|
||
// return request({
|
||
// url: '/system',
|
||
// method: 'post',
|
||
// params: {
|
||
// method: 'stock.warehouse.getBoxUnits',
|
||
// v,
|
||
// timestamp: new Date().getTime()
|
||
// },
|
||
// data: {},
|
||
// isSystemApi: true
|
||
// } as any)
|
||
// }
|
||
|
||
/**
|
||
* stock.warehouse.checkItemCodeUnique(module/stock)
|
||
* 必填业务项:item_code、warehouse_id(可省略则由后端按登录仓库上下文补全)、货主 owner_id 或 store_id
|
||
* 编辑排除自身:item_id(推荐)或 id
|
||
*/
|
||
export type CheckItemCodeUniqueParams = {
|
||
warehouse_id?: number
|
||
item_code: string
|
||
item_id?: number
|
||
id?: number
|
||
owner_id?: number
|
||
store_id?: number
|
||
}
|
||
|
||
export function checkItemCodeUnique(data: CheckItemCodeUniqueParams) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.checkItemCodeUnique',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function createWarehouseStock(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.createWarehouseStock',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function handleBatchDelete(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.handleBatchDelete',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function handleBatchChange(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.handleBatchChange',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function deleteUnit(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.deleteUnit',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function createProhibited(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.createProhibited',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function deleteProhibited(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.deleteProhibited',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
// 未使用,在库存日志或历史记录组件中,用于执行“回退”到某个历史状态的操作
|
||
export function backData(data: any) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.backData',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getStockDetail(
|
||
stock_id: number,
|
||
options?: { page?: number; pageSize?: number; group_by_batch?: boolean }
|
||
) {
|
||
const data: Record<string, unknown> = { stock_id }
|
||
if (options?.group_by_batch !== undefined) {
|
||
data.group_by_batch = options.group_by_batch
|
||
}
|
||
if (options && (options.page !== undefined || options.pageSize !== undefined)) {
|
||
data.pagination = { page: options.page, pageSize: options.pageSize }
|
||
}
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.getStockDetail',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
// PDA使用,本项目不使用
|
||
export function warehouseSearch(data: {
|
||
keyword?: string
|
||
store_id?: number
|
||
with_stock?: boolean
|
||
is_batch?: boolean
|
||
/** 传 "combo" 时搜索组合商品 */
|
||
mode?: 'combo' | string
|
||
/** mode="combo" 时按组合商品 ID 精确查询 */
|
||
id?: number
|
||
/** mode="combo" 时按自定义编码模糊查询 */
|
||
custom_code?: string
|
||
}) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.search',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
/** 文档兼容入口 stock.stockWarehouse,请求体与 stock.warehouse.list 一致(pagination + where) */
|
||
export function stockStockWarehouse(data: { pagination?: any; where?: any }) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.stockWarehouse',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data || {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function exportStockWarehouse(data: {
|
||
where?: Record<string, any>
|
||
group_by_batch?: boolean
|
||
sort?: Record<string, any>
|
||
export_mode?: 'waybill' | 'item'
|
||
exportMode?: 'waybill' | 'item'
|
||
}) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.export',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data: data || {},
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export function getExportTaskProgress(data: { task_id?: string; taskId?: string }) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.exportTaskProgress',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export type StockWarehouseImportItem = {
|
||
stock_id?: string | number
|
||
sku?: string
|
||
item_code?: string
|
||
cargo_code?: string
|
||
sku_property?: string
|
||
stock_unit?: string
|
||
brand_name?: string
|
||
gross_weight?: string | number
|
||
tag_price?: string | number
|
||
retail_price?: string | number
|
||
[key: string]: any
|
||
}
|
||
|
||
export type StockWarehouseImportPayload =
|
||
| StockWarehouseImportItem[]
|
||
| {
|
||
items?: StockWarehouseImportItem[]
|
||
rows?: StockWarehouseImportItem[]
|
||
list?: StockWarehouseImportItem[]
|
||
data?: StockWarehouseImportItem[]
|
||
[key: string]: any
|
||
}
|
||
|
||
export type StockWarehouseImportResult = {
|
||
total_count?: number
|
||
created_count?: number
|
||
updated_count?: number
|
||
fail_count?: number
|
||
created_ids?: Array<number | string>
|
||
updated_ids?: Array<number | string>
|
||
fail_items?: Array<Record<string, unknown>>
|
||
}
|
||
|
||
export type StockWarehouseImportResponse = StockWarehouseImportResult & {
|
||
code?: number
|
||
message?: string
|
||
data?: StockWarehouseImportResult
|
||
}
|
||
|
||
export function importStockWarehouse(
|
||
data: StockWarehouseImportPayload
|
||
): Promise<StockWarehouseImportResponse> {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.warehouse.import',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
export type StockTransactionListSort = {
|
||
sortField?: string
|
||
sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC' | string
|
||
sort_field?: string
|
||
sort_order?: string
|
||
}
|
||
|
||
export type StockTransactionListParams = {
|
||
pagination?: {
|
||
page?: number
|
||
pageSize?: number
|
||
}
|
||
where?: Record<string, any>
|
||
sort?: StockTransactionListSort
|
||
}
|
||
|
||
/** 商品出入库流水列表查询 */
|
||
export function stockTransactionList(data: StockTransactionListParams) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.transaction.list',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
/** 货主侧商品出入库流水列表查询 */
|
||
export function stockTransactionStoreList(
|
||
data: StockTransactionListParams & { store_id?: number }
|
||
) {
|
||
return request({
|
||
url: '/system',
|
||
method: 'post',
|
||
params: {
|
||
method: 'stock.transaction.storeList',
|
||
v,
|
||
timestamp: new Date().getTime()
|
||
},
|
||
data,
|
||
isSystemApi: true
|
||
} as any)
|
||
}
|
||
|
||
|