- 新增 sn_code_rules 规则编辑组件,支持前缀/后缀匹配与 full/strip 取值 - 开启序列号管理后必须配置规则,并提供扫码内容本地校验预览(不随表单提交) - 新增/编辑保存时归一化规则并校验空值、长度、重复及条数上限 - getInfo 回显与保存请求补充 sn_code_rules 类型 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
734 lines
18 KiB
TypeScript
734 lines
18 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)
|
||
}
|
||
|
||
/** 序列号规则:扫码时按规则从扫码内容中提取 SN 码 */
|
||
export type SnCodeRule = {
|
||
/** prefix=匹配前缀,suffix=匹配后缀 */
|
||
match_type: 'prefix' | 'suffix'
|
||
/** 要匹配的前缀/后缀字符串,1~64 字符 */
|
||
match_value: string
|
||
/** full=整个扫码内容作为 SN 码,strip=去掉匹配到的前后缀后作为 SN 码 */
|
||
keep_mode: 'full' | 'strip'
|
||
}
|
||
|
||
/** stock.warehouse.getInfo 响应 data */
|
||
export type StockWarehouseInfoResponse = {
|
||
/** 是否需要复核:Y=需要复核,N=不需要复核 */
|
||
need_recheck?: string
|
||
/** 序列号规则(接口统一输出数组) */
|
||
sn_code_rules?: SnCodeRule[]
|
||
[key: string]: 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)
|
||
}
|
||
|
||
/** stock.warehouse.saveWarehouseStock 请求参数 */
|
||
export type SaveWarehouseStockParams = {
|
||
/** 是否需要复核:Y=需要复核,N=不需要复核(非 Y/N 值会报错) */
|
||
need_recheck?: string
|
||
/** 序列号规则:整体覆盖保存,传 [] 清空,不传保持原值 */
|
||
sn_code_rules?: SnCodeRule[]
|
||
[key: string]: any
|
||
}
|
||
|
||
/** stock.warehouse.saveWarehouseStock:新增/更新仓库商品 */
|
||
export function saveWarehouseStock(data: SaveWarehouseStockParams) {
|
||
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)
|
||
}
|
||
|
||
/** stock.warehouse.createWarehouseStock 请求参数 */
|
||
export type CreateWarehouseStockParams = {
|
||
/** 是否需要复核:Y=需要复核,N=不需要复核;缺省默认 Y(需要复核) */
|
||
need_recheck?: string
|
||
/** 序列号规则:整体覆盖保存,不传时创建为 [] */
|
||
sn_code_rules?: SnCodeRule[]
|
||
[key: string]: any
|
||
}
|
||
|
||
/** stock.warehouse.createWarehouseStock:新增仓库商品 */
|
||
export function createWarehouseStock(data: CreateWarehouseStockParams) {
|
||
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)
|
||
}
|
||
|
||
/** stock.warehouse.handleBatchChange 请求参数 */
|
||
export type HandleBatchChangeParams = {
|
||
/** 要批量修改的仓库商品记录 ID 数组(stock_warehouse.id) */
|
||
ids?: number[]
|
||
/**
|
||
* 要修改的字段名(后端白名单 canChangeField):brand_name、prohibited_id、gross_weight、
|
||
* managementFlags、stock_unit、need_recheck,
|
||
* 以及与「作业要求」相关的四个字段:packing_requirements、pick_requirements、recheck_requirements、merge_requirements
|
||
*/
|
||
method?: string
|
||
/**
|
||
* 修改值,类型依 method 而定:
|
||
* - brand_name/stock_unit:string(<=255 字符)
|
||
* - 作业要求三字段 packing_requirements / pick_requirements / recheck_requirements:string(<=255 字符)
|
||
* - merge_requirements(是否合并):string,仅支持 'Y'(合并)/ 'N'(拆分)
|
||
* - prohibited_id:number(整数)
|
||
* - gross_weight:number(正整数,单位 g)
|
||
* - managementFlags:object(含 is_sn_mgmt/is_shelf_life_mgmt/is_batch_mgmt,值为 Y/N)
|
||
* - need_recheck:string(仅支持 Y/N)
|
||
*
|
||
* ⚠️ 单次请求只改 method 指定的一个字段(一次只传一个字段,不支持多字段批量)。
|
||
* ⚠️ 待确认:`merge_requirements=Y` 时后端是否会联动清空 pick/recheck_requirements;
|
||
* 若不联动,前端需在改「是否合并」后另行下发清空(当前实现按「后端自行处理」处理,未额外下发)。
|
||
*/
|
||
value?: string | number | Record<string, any>
|
||
/** 兼容字段:当前实现以 value 为准,不使用 values */
|
||
values?: any
|
||
[key: string]: any
|
||
}
|
||
|
||
/** stock.warehouse.handleBatchChange:批量修改仓库商品字段 */
|
||
export function handleBatchChange(data: HandleBatchChangeParams) {
|
||
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)
|
||
}
|
||
|
||
/** stock.warehouse.getStockDetail 库存明细行(storageList 元素) */
|
||
export type StockWarehouseStorageItem = {
|
||
/** 明细ID */
|
||
id?: number
|
||
/** 库位ID */
|
||
space_id?: number
|
||
/** 库位名称 */
|
||
space_name?: string
|
||
/** 批次号(group_by_batch=false 按库位合并时为 null) */
|
||
batch_no?: string | null
|
||
/** 生产日期(按库位合并时为 null) */
|
||
production_date?: string | null
|
||
/** 到期日期(按库位合并时为 null) */
|
||
expiry_date?: string | null
|
||
/** 入库时间(按库位合并时为 null) */
|
||
inbound_time?: string | null
|
||
/** 入库单号(按库位合并时为 null) */
|
||
inbound_order_no?: string | null
|
||
/** 供应商批次号(按库位合并时为 null) */
|
||
supplier_batch_no?: string | null
|
||
/** 数量 */
|
||
quantity?: number
|
||
/** 锁定数量 */
|
||
locked_quantity?: number
|
||
/** 拦截锁定数量(按库位合并明细,默认 0) */
|
||
intercept_locked_quantity?: number
|
||
/** 可用数量 = quantity - locked_quantity - intercept_locked_quantity */
|
||
available_quantity?: number
|
||
[key: string]: any
|
||
}
|
||
|
||
/** stock.warehouse.getStockDetail 响应 */
|
||
export type StockWarehouseDetailResponse = {
|
||
code?: number
|
||
message?: string
|
||
/** 响应数据 */
|
||
data?: {
|
||
/** 商品概要,包含 id、item_code、item_name、sku_property、stock_unit、quantity、locked_quantity 等 */
|
||
stockItem?: {
|
||
id?: number
|
||
item_code?: string
|
||
item_name?: string
|
||
sku_property?: string
|
||
stock_unit?: string
|
||
quantity?: number
|
||
locked_quantity?: number
|
||
[key: string]: any
|
||
}
|
||
/** 库存明细数组;group_by_batch=true 返回 wms_storage 明细,false 按库位合并 */
|
||
storageList?: StockWarehouseStorageItem[]
|
||
/** 分页信息 */
|
||
pagination?: {
|
||
page: number
|
||
pageSize: number
|
||
total: number
|
||
}
|
||
}
|
||
}
|
||
|
||
export function getStockDetail(
|
||
stock_id: number,
|
||
options?: { page?: number; pageSize?: number; group_by_batch?: boolean }
|
||
): Promise<StockWarehouseDetailResponse> {
|
||
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)
|
||
}
|
||
|
||
|