73
This commit is contained in:
parent
2fbe0c2f8e
commit
a9ba68e0fd
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
@ -377,4 +377,41 @@ export function getLocationTypeList(data?: Record<string, unknown>) {
|
||||
data: data ?? {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export type IndexToOrderWave = {
|
||||
wave_id: number
|
||||
wave_no: string
|
||||
order_ids: number[]
|
||||
}
|
||||
|
||||
export type IndexToOrderParams = {
|
||||
/** 运单号 */
|
||||
waybill_code: string
|
||||
}
|
||||
|
||||
export type IndexToOrderResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
order_id?: number
|
||||
waves?: IndexToOrderWave[]
|
||||
data?: {
|
||||
order_id?: number
|
||||
waves?: IndexToOrderWave[]
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据运单号快速查询订单ID及其所属波次下所有订单ID列表 */
|
||||
export function toOrder(data: IndexToOrderParams): Promise<IndexToOrderResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'index.toOrder',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
@ -630,6 +630,39 @@ export function orderPendingOrderBatchUnlockTaskProgress(data: PendingOrderBatch
|
||||
} as any)
|
||||
}
|
||||
|
||||
export type PendingOrderUpdateRemarkParams = {
|
||||
ids: number[]
|
||||
remark: string
|
||||
}
|
||||
|
||||
export type PendingOrderUpdateRemarkResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
updated_count?: number
|
||||
ids?: number[]
|
||||
data?: {
|
||||
updated_count?: number
|
||||
ids?: number[]
|
||||
}
|
||||
}
|
||||
|
||||
/** order.pendingOrder.updateRemark:批量修改待处理订单备注 */
|
||||
export function orderPendingOrderUpdateRemark(
|
||||
data: PendingOrderUpdateRemarkParams,
|
||||
): Promise<PendingOrderUpdateRemarkResponse> {
|
||||
return request({
|
||||
url: "/system",
|
||||
method: "post",
|
||||
params: {
|
||||
method: "order.pendingOrder.updateRemark",
|
||||
v,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
} as any);
|
||||
}
|
||||
|
||||
export type OrderPendingOrderApi = {
|
||||
list: typeof orderPendingOrderList;
|
||||
detail: typeof orderPendingOrderDetail;
|
||||
@ -644,6 +677,7 @@ export type OrderPendingOrderApi = {
|
||||
updateOrderPlatform: typeof orderPendingOrderUpdateOrderPlatform;
|
||||
updateOrderExpress: typeof orderPendingOrderUpdateOrderExpress;
|
||||
updateAddress: typeof orderPendingOrderUpdateAddress;
|
||||
updateRemark: typeof orderPendingOrderUpdateRemark;
|
||||
cloneOrder: typeof orderPendingOrderCloneOrder;
|
||||
manualWaybill: typeof orderPendingOrderManualWaybill;
|
||||
createOrder: typeof orderPendingOrderCreateOrder;
|
||||
@ -674,6 +708,7 @@ export const orderPendingOrder: OrderPendingOrderApi = {
|
||||
updateOrderPlatform: orderPendingOrderUpdateOrderPlatform,
|
||||
updateOrderExpress: orderPendingOrderUpdateOrderExpress,
|
||||
updateAddress: orderPendingOrderUpdateAddress,
|
||||
updateRemark: orderPendingOrderUpdateRemark,
|
||||
cloneOrder: orderPendingOrderCloneOrder,
|
||||
manualWaybill: orderPendingOrderManualWaybill,
|
||||
createOrder: orderPendingOrderCreateOrder,
|
||||
|
||||
@ -1,250 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const v = '1.0'
|
||||
|
||||
export type DirectInboundGetItemsParams = {
|
||||
/** 入库单号 */
|
||||
entry_order_code: string
|
||||
}
|
||||
|
||||
export type DirectInboundEntryOrder = {
|
||||
id?: number
|
||||
entry_order_code?: string
|
||||
order_type?: string
|
||||
order_status?: string
|
||||
source_type?: string
|
||||
warehouse_id?: number
|
||||
store_id?: number
|
||||
remark?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundLog = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
remark?: string
|
||||
/** 存放库位ID,关联 wms_location_space.id */
|
||||
space_id?: number
|
||||
created_at?: string
|
||||
warehouse_item_code?: string
|
||||
warehouse_item_name?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
/** pending 绑定项,结构同 storage.entry.get */
|
||||
export type DirectInboundItemBinding = {
|
||||
id?: number
|
||||
entry_item_id?: number
|
||||
receiving_detail_id?: number
|
||||
allocated_quantity?: number
|
||||
status?: string
|
||||
receivingDetail?: Record<string, unknown>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundItem = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
count?: number
|
||||
received_quantity?: number
|
||||
direct_inbound_quantity?: number
|
||||
remaining_quantity?: number
|
||||
/** pending 绑定总量 */
|
||||
pending_binding_total?: number
|
||||
/** pending 绑定列表 */
|
||||
bindings?: DirectInboundItemBinding[]
|
||||
direct_logs?: DirectInboundLog[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundSummary = {
|
||||
total_items?: number
|
||||
total_planned?: number
|
||||
total_direct_inbound?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundGetItemsResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
entryOrder?: DirectInboundEntryOrder
|
||||
items?: DirectInboundItem[]
|
||||
direct_logs?: DirectInboundLog[]
|
||||
summary?: DirectInboundSummary
|
||||
data?: {
|
||||
entryOrder?: DirectInboundEntryOrder
|
||||
items?: DirectInboundItem[]
|
||||
direct_logs?: DirectInboundLog[]
|
||||
summary?: DirectInboundSummary
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取入库单的导入/PDA 入库信息 */
|
||||
export function getDirectInboundItems(
|
||||
data: DirectInboundGetItemsParams
|
||||
): Promise<DirectInboundGetItemsResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.directInbound.getItems',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemBatchEntry = {
|
||||
/** 商品SKU ID(对应 wms_stock_warehouse.id) */
|
||||
stock_id: number
|
||||
/** 本次入库数量(正整数) */
|
||||
quantity: number
|
||||
/** 入库方式:import(导入入库)、pda(PDA入库) */
|
||||
inbound_type: 'import' | 'pda' | string
|
||||
/** 存放库位ID,关联 wms_location_space.id;为空时 commit 默认使用库位 1 */
|
||||
space_id?: number
|
||||
/** 备注(如导入文件名、PDA操作备注等) */
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemSingleParams = {
|
||||
/** 入库单号 */
|
||||
entry_order_code: string
|
||||
/** 商品SKU ID(对应 wms_stock_warehouse.id) */
|
||||
stock_id: number
|
||||
/** 本次入库数量(正整数) */
|
||||
quantity: number
|
||||
/** 入库方式:import(导入入库)、pda(PDA入库) */
|
||||
inbound_type: 'import' | 'pda' | string
|
||||
/** 存放库位ID,关联 wms_location_space.id;为空时 commit 默认使用库位 1 */
|
||||
space_id?: number
|
||||
/** 备注(如导入文件名、PDA操作备注等) */
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemBatchParams = {
|
||||
/** 入库单号 */
|
||||
entry_order_code: string
|
||||
/** 批量模式:商品列表。传入 items 时忽略顶层的 stock_id/quantity/inbound_type/remark */
|
||||
items: DirectInboundAddItemBatchEntry[]
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemParams =
|
||||
| DirectInboundAddItemSingleParams
|
||||
| DirectInboundAddItemBatchParams
|
||||
|
||||
export type DirectInboundAddItemResultEntry = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
/** 存放库位ID */
|
||||
space_id?: number
|
||||
plan_quantity?: number
|
||||
existing_before?: number
|
||||
existing_after?: number
|
||||
remaining?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
/** 单条模式 */
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
plan_quantity?: number
|
||||
existing_before?: number
|
||||
existing_after?: number
|
||||
remaining?: number
|
||||
/** 批量模式 */
|
||||
count?: number
|
||||
total_quantity?: number
|
||||
items?: DirectInboundAddItemResultEntry[]
|
||||
data?: Partial<DirectInboundAddItemResponse>
|
||||
}
|
||||
|
||||
/** 按商品增量添加导入/PDA 入库记录(支持单条与批量) */
|
||||
export function addDirectInboundItem(
|
||||
data: DirectInboundAddItemParams
|
||||
): Promise<DirectInboundAddItemResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.directInbound.addItem',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundCommitParams = {
|
||||
/** 入库单号 */
|
||||
entry_order_code: string
|
||||
}
|
||||
|
||||
export type DirectInboundCommitResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
id?: number
|
||||
entry_order_code?: string
|
||||
order_status?: string
|
||||
sync_status?: string
|
||||
items_count?: number
|
||||
total_quantity?: number
|
||||
data?: Partial<DirectInboundCommitResponse>
|
||||
}
|
||||
|
||||
/** 提交确认完成导入/PDA 入库 */
|
||||
export function commitDirectInbound(
|
||||
data: DirectInboundCommitParams
|
||||
): Promise<DirectInboundCommitResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.directInbound.commit',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundRemoveItemParams = {
|
||||
/** 入库记录ID(wms_inbound_direct_log.id) */
|
||||
id: number
|
||||
}
|
||||
|
||||
export type DirectInboundRemoveItemResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
data?: Partial<DirectInboundRemoveItemResponse>
|
||||
}
|
||||
|
||||
/** 移除一条导入/PDA 入库记录(仅限未提交的入库单) */
|
||||
export function removeDirectInboundItem(
|
||||
data: DirectInboundRemoveItemParams
|
||||
): Promise<DirectInboundRemoveItemResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.directInbound.removeItem',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const v = "1.0"
|
||||
const v = '1.0'
|
||||
|
||||
/** storage.entry.list 查询参数(pagination / where / sort) */
|
||||
export type StorageEntryListPagination = {
|
||||
@ -59,17 +59,15 @@ export function getEntryList(data: StorageEntryListParams = {}): Promise<Storage
|
||||
params: {
|
||||
method: 'storage.entry.list',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data: data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export type GetEntryDetailParams = {
|
||||
/** 入库单ID,与 entry_order_code 二选一 */
|
||||
id?: number
|
||||
/** 入库单号,与 id 二选一 */
|
||||
entry_order_code?: string
|
||||
/** 入库单ID(必填) */
|
||||
id: number
|
||||
}
|
||||
|
||||
export type EntryDetailBinding = {
|
||||
@ -108,6 +106,20 @@ export type EntryDetailItemBarcode = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundLog = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
remark?: string
|
||||
/** 存放库位ID,关联 wms_location_space.id */
|
||||
space_id?: number
|
||||
created_at?: string
|
||||
warehouse_item_code?: string
|
||||
warehouse_item_name?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type EntryDetailItem = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
@ -119,12 +131,12 @@ export type EntryDetailItem = {
|
||||
count?: number
|
||||
received_quantity?: number
|
||||
confirm_quantity?: number
|
||||
warehouse_quantity?: number
|
||||
warehouse_locked_quantity?: number
|
||||
warehouse_is_batch_mgmt?: string
|
||||
warehouse_is_shelf_life_mgmt?: string
|
||||
warehouse_quantity?: number | null
|
||||
warehouse_locked_quantity?: number | null
|
||||
warehouse_is_batch_mgmt?: string | null
|
||||
warehouse_is_shelf_life_mgmt?: string | null
|
||||
warehouse_image_url?: string
|
||||
warehouse_is_images?: number
|
||||
warehouse_is_images?: string | null
|
||||
barcodes?: EntryDetailItemBarcode[]
|
||||
direct_inbound_quantity?: number
|
||||
remaining_quantity?: number
|
||||
@ -136,6 +148,8 @@ export type EntryDetailItem = {
|
||||
bindings?: EntryDetailBinding[]
|
||||
/** 可绑定/已绑定的收货明细(含可用量) */
|
||||
available_receiving_details?: EntryAvailableReceivingDetail[]
|
||||
/** 导入/PDA 入库记录(明细级) */
|
||||
direct_logs?: DirectInboundLog[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
@ -160,6 +174,8 @@ export type EntryOrderDetail = {
|
||||
order_status?: string
|
||||
items?: EntryDetailItem[]
|
||||
receivingBindings?: EntryOrderReceivingBinding[]
|
||||
/** 入库单级导入/PDA 记录汇总(若后端返回) */
|
||||
direct_logs?: DirectInboundLog[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
@ -172,6 +188,33 @@ export type GetEntryDetailResponse = {
|
||||
}
|
||||
}
|
||||
|
||||
/** 从 storage.entry.get 返回的入库单详情中汇总导入/PDA 入库记录 */
|
||||
export function collectDirectInboundLogs(
|
||||
entryOrder: EntryOrderDetail | undefined | null
|
||||
): DirectInboundLog[] {
|
||||
if (!entryOrder) return []
|
||||
|
||||
const topLevel = entryOrder.direct_logs
|
||||
if (Array.isArray(topLevel) && topLevel.length) {
|
||||
return topLevel
|
||||
}
|
||||
|
||||
const logs: DirectInboundLog[] = []
|
||||
for (const item of entryOrder.items || []) {
|
||||
const itemLogs = item.direct_logs
|
||||
if (!Array.isArray(itemLogs)) continue
|
||||
for (const log of itemLogs) {
|
||||
logs.push({
|
||||
...log,
|
||||
stock_id: log.stock_id ?? item.stock_id,
|
||||
warehouse_item_code: log.warehouse_item_code ?? item.warehouse_item_code,
|
||||
warehouse_item_name: log.warehouse_item_name ?? item.warehouse_item_name,
|
||||
})
|
||||
}
|
||||
}
|
||||
return logs
|
||||
}
|
||||
|
||||
export function getEntryDetail(data: GetEntryDetailParams): Promise<GetEntryDetailResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
@ -179,9 +222,9 @@ export function getEntryDetail(data: GetEntryDetailParams): Promise<GetEntryDeta
|
||||
params: {
|
||||
method: 'storage.entry.get',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data: data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@ -210,309 +253,13 @@ export function cancelEntry(data: CancelEntryParams): Promise<CancelEntryRespons
|
||||
params: {
|
||||
method: 'storage.entry.cancel',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data: data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export type CompleteEntryParams = {
|
||||
/** 入库单ID */
|
||||
entry_order_id: number
|
||||
}
|
||||
|
||||
export type CompleteEntryResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
entry_order_id?: number
|
||||
order_status?: string
|
||||
data?: {
|
||||
entry_order_id?: number
|
||||
order_status?: string
|
||||
}
|
||||
}
|
||||
|
||||
export function completeEntry(data: CompleteEntryParams): Promise<CompleteEntryResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.completeEntry',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 废弃接口,不再使用
|
||||
export function createEntry(data:any): Promise<any> {
|
||||
return Promise.reject(new Error('storage.entry.create 已下线,请使用 quickPutaway / matchPutaway 流程'))
|
||||
}
|
||||
|
||||
export function addDetail(data:any): Promise<any> {
|
||||
return Promise.reject(new Error('storage.entry.addDetail 已下线,入库单明细不再对外编辑'))
|
||||
}
|
||||
|
||||
export function deleteDetail(data:any): Promise<any> {
|
||||
return Promise.reject(new Error('storage.entry.deleteDetail 已下线,入库单明细不再对外编辑'))
|
||||
}
|
||||
|
||||
export function detailChange(data:any): Promise<any> {
|
||||
return Promise.reject(new Error('storage.entry.detailChange 已下线,入库单明细不再对外编辑'))
|
||||
}
|
||||
|
||||
export type BindReceivingParams = {
|
||||
/** 入库单ID */
|
||||
entry_order_id: number
|
||||
/** 要绑定的收货单ID列表 */
|
||||
receiving_ids: number[]
|
||||
}
|
||||
|
||||
export type BindReceivingSuccessItem = {
|
||||
receiving_id?: number
|
||||
receiving_number?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type BindReceivingFailedItem = {
|
||||
receiving_id?: number
|
||||
error_code?: string
|
||||
message?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type BindReceivingResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
success?: BindReceivingSuccessItem[]
|
||||
failed?: BindReceivingFailedItem[]
|
||||
success_count?: number
|
||||
failed_count?: number
|
||||
data?: {
|
||||
success?: BindReceivingSuccessItem[]
|
||||
failed?: BindReceivingFailedItem[]
|
||||
success_count?: number
|
||||
failed_count?: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 将收货单绑定到入库单(主表级关联) */
|
||||
export function bindReceiving(data: BindReceivingParams): Promise<BindReceivingResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.bindReceiving',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type BindReceivingDetailsBinding = {
|
||||
entry_item_id: number
|
||||
receiving_detail_id: number
|
||||
allocated_quantity: number
|
||||
}
|
||||
|
||||
export type BindReceivingDetailsParams = {
|
||||
/** 入库单ID */
|
||||
entry_order_id: number
|
||||
bindings: BindReceivingDetailsBinding[]
|
||||
}
|
||||
|
||||
export type BindReceivingDetailsResultItem = {
|
||||
entry_item_id?: number
|
||||
receiving_detail_id?: number
|
||||
allocated_quantity?: number
|
||||
error_code?: string
|
||||
message?: string
|
||||
detail?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type BindReceivingDetailsResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
success?: BindReceivingDetailsResultItem[]
|
||||
failed?: BindReceivingDetailsResultItem[]
|
||||
success_count?: number
|
||||
failed_count?: number
|
||||
data?: {
|
||||
success?: BindReceivingDetailsResultItem[]
|
||||
failed?: BindReceivingDetailsResultItem[]
|
||||
success_count?: number
|
||||
failed_count?: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 入库单明细绑定收货明细 */
|
||||
export function bindReceivingDetails(data: BindReceivingDetailsParams): Promise<BindReceivingDetailsResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.bindReceivingDetails',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type UnbindReceivingDetailsParams = {
|
||||
/** 入库单明细ID */
|
||||
entry_item_id: number
|
||||
}
|
||||
|
||||
export type UnbindReceivingDetailsResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
entry_item_id?: number
|
||||
released_quantity?: number
|
||||
data?: {
|
||||
entry_item_id?: number
|
||||
released_quantity?: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 解绑入库明细的收货明细绑定 */
|
||||
export function unbindReceivingDetails(
|
||||
data: UnbindReceivingDetailsParams
|
||||
): Promise<UnbindReceivingDetailsResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.unbindReceivingDetails',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type GetEntryPrintDataParams = {
|
||||
/** 入库单ID */
|
||||
id: number
|
||||
}
|
||||
|
||||
/** 打印明细行(RECEIPT 模板 field_code 映射) */
|
||||
export type EntryPrintDataItem = Record<string, unknown>
|
||||
|
||||
/** 打印数据:扁平键值对 + items 明细数组 */
|
||||
export type EntryPrintData = {
|
||||
items?: EntryPrintDataItem[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type GetEntryPrintDataResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
data?: EntryPrintData
|
||||
}
|
||||
|
||||
/** 获取入库单打印数据(按 RECEIPT 模板 field_code 映射) */
|
||||
export function getEntryPrintData(
|
||||
data: GetEntryPrintDataParams
|
||||
): Promise<GetEntryPrintDataResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.getPrintData',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundGetItemsParams = {
|
||||
/** 入库单号 */
|
||||
entry_order_code: string
|
||||
}
|
||||
|
||||
export type DirectInboundEntryOrder = {
|
||||
id?: number
|
||||
entry_order_code?: string
|
||||
order_type?: string
|
||||
order_status?: string
|
||||
source_type?: string
|
||||
warehouse_id?: number
|
||||
store_id?: number
|
||||
remark?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundLog = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
remark?: string
|
||||
/** 存放库位ID,关联 wms_location_space.id */
|
||||
space_id?: number
|
||||
created_at?: string
|
||||
warehouse_item_code?: string
|
||||
warehouse_item_name?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundItem = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
count?: number
|
||||
received_quantity?: number
|
||||
direct_inbound_quantity?: number
|
||||
remaining_quantity?: number
|
||||
pending_binding_total?: number
|
||||
bindings?: EntryDetailBinding[]
|
||||
direct_logs?: DirectInboundLog[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundSummary = {
|
||||
total_items?: number
|
||||
total_planned?: number
|
||||
total_direct_inbound?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundGetItemsResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
entryOrder?: DirectInboundEntryOrder
|
||||
items?: DirectInboundItem[]
|
||||
direct_logs?: DirectInboundLog[]
|
||||
summary?: DirectInboundSummary
|
||||
data?: {
|
||||
entryOrder?: DirectInboundEntryOrder
|
||||
items?: DirectInboundItem[]
|
||||
direct_logs?: DirectInboundLog[]
|
||||
summary?: DirectInboundSummary
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取入库单的导入/PDA 入库信息 */
|
||||
export function getDirectInboundItems(
|
||||
data: DirectInboundGetItemsParams
|
||||
): Promise<DirectInboundGetItemsResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.getDirectInboundItems',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemBatchEntry = {
|
||||
export type AddItemBatchEntry = {
|
||||
stock_id: number
|
||||
quantity?: number
|
||||
inbound_type: 'import' | 'pda' | string
|
||||
@ -522,7 +269,7 @@ export type DirectInboundAddItemBatchEntry = {
|
||||
allocated_quantity?: number
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemSingleParams = {
|
||||
export type AddItemSingleParams = {
|
||||
/** 入库单 ID */
|
||||
entry_order_id: number
|
||||
stock_id: number
|
||||
@ -534,17 +281,15 @@ export type DirectInboundAddItemSingleParams = {
|
||||
allocated_quantity?: number
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemBatchParams = {
|
||||
export type AddItemBatchParams = {
|
||||
/** 入库单 ID */
|
||||
entry_order_id: number
|
||||
items: DirectInboundAddItemBatchEntry[]
|
||||
items: AddItemBatchEntry[]
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemParams =
|
||||
| DirectInboundAddItemSingleParams
|
||||
| DirectInboundAddItemBatchParams
|
||||
export type AddItemParams = AddItemSingleParams | AddItemBatchParams
|
||||
|
||||
export type DirectInboundAddItemResultEntry = {
|
||||
export type AddItemResultEntry = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
@ -557,7 +302,7 @@ export type DirectInboundAddItemResultEntry = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type DirectInboundAddItemResponse = {
|
||||
export type AddItemResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
id?: number
|
||||
@ -570,31 +315,30 @@ export type DirectInboundAddItemResponse = {
|
||||
remaining?: number
|
||||
count?: number
|
||||
total_quantity?: number
|
||||
items?: DirectInboundAddItemResultEntry[]
|
||||
data?: Partial<DirectInboundAddItemResponse>
|
||||
items?: AddItemResultEntry[]
|
||||
data?: Partial<AddItemResponse>
|
||||
}
|
||||
|
||||
/** 按商品增量添加导入/PDA 入库记录(支持单条与批量) */
|
||||
export function addDirectInboundItem(
|
||||
data: DirectInboundAddItemParams
|
||||
): Promise<DirectInboundAddItemResponse> {
|
||||
export function addItem(data: AddItemParams): Promise<AddItemResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.addDirectInboundItem',
|
||||
method: 'storage.entry.addItem',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundCommitParams = {
|
||||
entry_order_code: string
|
||||
export type EntryCommitParams = {
|
||||
/** 入库单 ID */
|
||||
entry_order_id: number
|
||||
}
|
||||
|
||||
export type DirectInboundCommitResponse = {
|
||||
export type EntryCommitResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
id?: number
|
||||
@ -603,53 +347,49 @@ export type DirectInboundCommitResponse = {
|
||||
sync_status?: string
|
||||
items_count?: number
|
||||
total_quantity?: number
|
||||
data?: Partial<DirectInboundCommitResponse>
|
||||
data?: Partial<EntryCommitResponse>
|
||||
}
|
||||
|
||||
/** 提交确认完成导入/PDA 入库 */
|
||||
export function commitDirectInbound(
|
||||
data: DirectInboundCommitParams
|
||||
): Promise<DirectInboundCommitResponse> {
|
||||
export function commit(data: EntryCommitParams): Promise<EntryCommitResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.commitDirectInbound',
|
||||
method: 'storage.entry.commit',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export type DirectInboundRemoveItemParams = {
|
||||
export type RemoveItemParams = {
|
||||
/** 入库记录ID(wms_inbound_direct_log.id) */
|
||||
id: number
|
||||
}
|
||||
|
||||
export type DirectInboundRemoveItemResponse = {
|
||||
export type RemoveItemResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
id?: number
|
||||
stock_id?: number
|
||||
quantity?: number
|
||||
inbound_type?: string
|
||||
data?: Partial<DirectInboundRemoveItemResponse>
|
||||
data?: Partial<RemoveItemResponse>
|
||||
}
|
||||
|
||||
/** 移除一条导入/PDA 入库记录(仅限未提交的入库单) */
|
||||
export function removeDirectInboundItem(
|
||||
data: DirectInboundRemoveItemParams
|
||||
): Promise<DirectInboundRemoveItemResponse> {
|
||||
export function removeItem(data: RemoveItemParams): Promise<RemoveItemResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.removeDirectInboundItem',
|
||||
method: 'storage.entry.removeItem',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@ -678,9 +418,9 @@ export function quickInbound(data: QuickInboundParams): Promise<QuickInboundResp
|
||||
params: {
|
||||
method: 'storage.entry.quickInbound',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@ -710,29 +450,6 @@ export type ReceivingCompareRow = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
/** storage.entry.queryEntryLogs 参数 */
|
||||
export type QueryEntryLogsParams = {
|
||||
id?: number | string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
/** 查询入库单操作日志 */
|
||||
export function queryEntryLogs(data: QueryEntryLogsParams = {}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.queryEntryLogs',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 汇总统计(summary 对象) */
|
||||
export type ReceivingCompareSummary = {
|
||||
total_rows?: number
|
||||
total_entry_items?: number
|
||||
@ -803,9 +520,58 @@ export function receivingCompare(
|
||||
params: {
|
||||
method: 'storage.entry.receivingCompare',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export type BindReceivingParams = {
|
||||
/** 入库单ID */
|
||||
entry_order_id: number
|
||||
/** 要绑定的收货单ID列表 */
|
||||
receiving_ids: number[]
|
||||
}
|
||||
|
||||
export type BindReceivingSuccessItem = {
|
||||
receiving_id?: number
|
||||
receiving_number?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type BindReceivingFailedItem = {
|
||||
receiving_id?: number
|
||||
error_code?: string
|
||||
message?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type BindReceivingResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
success?: BindReceivingSuccessItem[]
|
||||
failed?: BindReceivingFailedItem[]
|
||||
success_count?: number
|
||||
failed_count?: number
|
||||
data?: {
|
||||
success?: BindReceivingSuccessItem[]
|
||||
failed?: BindReceivingFailedItem[]
|
||||
success_count?: number
|
||||
failed_count?: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 将收货单绑定到入库单(主表级关联) */
|
||||
export function bindReceiving(data: BindReceivingParams): Promise<BindReceivingResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.bindReceiving',
|
||||
v,
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@ -834,8 +600,75 @@ export function reviewEntry(data: ReviewEntryParams): Promise<ReviewEntryRespons
|
||||
params: {
|
||||
method: 'storage.entry.reviewEntry',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export type EntryContainerListParams = {
|
||||
/** 入库单 ID */
|
||||
entry_order_id: number
|
||||
/** 商品 stock_id(wms_stock_warehouse.id) */
|
||||
stock_id: number
|
||||
}
|
||||
|
||||
export type EntryContainerListItem = {
|
||||
detail_id?: number
|
||||
receiving_id?: number
|
||||
barcode?: string
|
||||
product_name?: string
|
||||
actual_quantity?: number
|
||||
receiving_status?: string
|
||||
stock?: Record<string, unknown>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type EntryContainerListResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
list?: EntryContainerListItem[]
|
||||
total?: number
|
||||
data?: {
|
||||
list?: EntryContainerListItem[]
|
||||
total?: number
|
||||
}
|
||||
}
|
||||
|
||||
/** PDA 上架时拉取入库单已绑定收货单中指定商品的可用容器列表 */
|
||||
export function containerList(
|
||||
data: EntryContainerListParams
|
||||
): Promise<EntryContainerListResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.containerList',
|
||||
v,
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/** storage.entry.queryEntryLogs 参数 */
|
||||
export type QueryEntryLogsParams = {
|
||||
id?: number | string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
/** 查询入库单操作日志 */
|
||||
export function queryEntryLogs(data: QueryEntryLogsParams = {}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.queryEntryLogs',
|
||||
v,
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
} as any)
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ export default {
|
||||
"Dashboard": "Dashboard",
|
||||
"Download": "Download",
|
||||
"orderManagement": "Order Management",
|
||||
"stockManagement": "Stock Management",
|
||||
"System": "System",
|
||||
"deliverOrder": "Deliver Order",
|
||||
"orderSetting": "Order Setting",
|
||||
|
||||
@ -17,6 +17,7 @@ export default {
|
||||
"Dashboard": "控制台",
|
||||
"Download": "下载",
|
||||
"orderManagement": "订单管理",
|
||||
"stockManagement": "商品管理",
|
||||
"System": "系统",
|
||||
"deliverOrder": "配送订单",
|
||||
"orderSetting": "订单设置",
|
||||
|
||||
@ -13,10 +13,13 @@ export const componentMap: Record<string, any> = {
|
||||
'account/index': () => import('@/views/system/setting/account/index.vue'),
|
||||
// 'permission/index': () => import('@/views/system/setting/permission/index.vue'),
|
||||
'warehouse/index': () => import('@/views/warehouse/index.vue'),
|
||||
'stock/index': () => import('@/views/stock/stock/index.vue'),
|
||||
'stock/stockManagement': () => import('@/views/stock/stockManagement/index.vue'),
|
||||
/** 与后端菜单 component 字段兼容:商品管理入口 */
|
||||
'stock/index': () => import('@/views/stock/stockManagement/index.vue'),
|
||||
'stock/storestock/index': () => import('@/views/stock/storestock/index.vue'),
|
||||
'stock/combo_stock': () => import('@/views/stock/combo_stock/index.vue'),
|
||||
'stock/combo_stock/index': () => import('@/views/stock/combo_stock/index.vue'),
|
||||
/** 组合商品并入商品管理,保留旧路径兼容 */
|
||||
// 'stock/combo_stock': () => import('@/views/stock/stockManagement/index.vue'),
|
||||
// 'stock/combo_stock/index': () => import('@/views/stock/stockManagement/index.vue'),
|
||||
'stock/pickingShortage/index': () => import('@/views/storage/management/replenishmentDemand/index.vue'),
|
||||
'storage/management/replenishmentDemand/index': () => import('@/views/storage/management/replenishmentDemand/index.vue'),
|
||||
'storage/receiving': () => import('@/views/storage/receiving/index.vue'),
|
||||
|
||||
@ -290,6 +290,24 @@
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<template #column-source_platform_code="{ row }">
|
||||
<el-select
|
||||
v-model="row.source_platform_code"
|
||||
size="small"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择来源平台"
|
||||
:disabled="isPreviewRowLocked(row)"
|
||||
@change="markPreviewRowDirty(row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in importSourcePlatformOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<template #column-sys_platform_code="{ row }">
|
||||
<el-select
|
||||
v-model="row.sys_platform_code"
|
||||
@ -424,6 +442,7 @@ import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import SelectProductDialog from './SelectProductDialog.vue'
|
||||
import type { SelectProductItem } from './SelectProductDialog.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { settingPlatformList } from '@/api/setting.platform/platform'
|
||||
import {
|
||||
lookupProductByKeyword
|
||||
} from '../utils/stock-picker-helpers'
|
||||
@ -513,6 +532,7 @@ type ImportPreviewRow = {
|
||||
shop_nick: string
|
||||
remark: string
|
||||
logistics_code: string
|
||||
source_platform_code: string
|
||||
sys_platform_code: string
|
||||
import_status: string
|
||||
import_message: string
|
||||
@ -534,6 +554,7 @@ const importPreviewColumns = [
|
||||
{ prop: 'area', label: '区/县*', minWidth: '120' },
|
||||
{ prop: 'detail_address', label: '详细地址', minWidth: '150' },
|
||||
{ prop: 'logistics_code', label: '快递', minWidth: '140' },
|
||||
{ prop: 'source_platform_code', label: '来源平台', minWidth: '140' },
|
||||
{ prop: 'sys_platform_code', label: '平台', minWidth: '140' },
|
||||
{ prop: 'import_status', label: '状态', width: '90' },
|
||||
{ prop: 'import_message', label: '结果说明', minWidth: '180' },
|
||||
@ -551,6 +572,7 @@ const importPreviewRows = ref<ImportPreviewRow[]>([])
|
||||
const importOrderResult = ref<ImportOrderResult | null>(null)
|
||||
const storeOptions = ref<Array<{ label: string; value: number | string }>>([])
|
||||
const importExpressOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const importSourcePlatformOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const importPlatformOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const defaultStoreId = ref<number | undefined>(undefined)
|
||||
const provinceOptions = buildProvinceOptions()
|
||||
@ -713,6 +735,7 @@ onBeforeUnmount(() => {
|
||||
selectProductTargetRow.value = null
|
||||
storeOptions.value = []
|
||||
importExpressOptions.value = []
|
||||
importSourcePlatformOptions.value = []
|
||||
importPlatformOptions.value = []
|
||||
if (!sessionActive.value) {
|
||||
resetImportOrderDialog()
|
||||
@ -776,6 +799,7 @@ function createEmptyPreviewRowForm(): ImportPreviewRow {
|
||||
selected_items: [],
|
||||
plan_qty: '1',
|
||||
logistics_code: '',
|
||||
source_platform_code: '',
|
||||
sys_platform_code: '',
|
||||
import_status: '待创建',
|
||||
import_message: ''
|
||||
@ -1071,6 +1095,7 @@ function mergeDuplicateOrderRows(rows: ImportPreviewRow[]): ImportPreviewRow[] {
|
||||
if (!existing.shop_nick && row.shop_nick) existing.shop_nick = row.shop_nick
|
||||
if (!existing.remark && row.remark) existing.remark = row.remark
|
||||
if (!existing.logistics_code && row.logistics_code) existing.logistics_code = row.logistics_code
|
||||
if (!existing.source_platform_code && row.source_platform_code) existing.source_platform_code = row.source_platform_code
|
||||
if (!existing.sys_platform_code && row.sys_platform_code) existing.sys_platform_code = row.sys_platform_code
|
||||
}
|
||||
}
|
||||
@ -1113,16 +1138,20 @@ function resolveStoreId(raw: unknown): number | undefined {
|
||||
|
||||
async function loadImportSelectOptions() {
|
||||
try {
|
||||
const [expressRes, platformRes]: any = await Promise.all([
|
||||
const [expressRes, sourcePlatformRes, platformRes]: any = await Promise.all([
|
||||
indexApi.getExpressList({}),
|
||||
settingPlatformList({ pagination: { page: 1, pageSize: 500 } }),
|
||||
indexApi.getPlatformList({})
|
||||
])
|
||||
const expressRaw = expressRes?.data?.list || expressRes?.data || []
|
||||
const sourcePlatformRaw = sourcePlatformRes?.data?.list || sourcePlatformRes?.data || []
|
||||
const platformRaw = platformRes?.data?.list || platformRes?.data || []
|
||||
importExpressOptions.value = mapCodeNameLabelOptions(expressRaw, ['code', 'express_code', 'value'], ['name', 'express_name', 'label'])
|
||||
importSourcePlatformOptions.value = mapCodeNameLabelOptions(sourcePlatformRaw, ['code'], ['name', 'platform_name', 'label'])
|
||||
importPlatformOptions.value = mapCodeNameLabelOptions(platformRaw, ['code', 'platform_code', 'value'], ['name', 'platform_name', 'sys_platform_name', 'label'])
|
||||
} catch {
|
||||
importExpressOptions.value = []
|
||||
importSourcePlatformOptions.value = []
|
||||
importPlatformOptions.value = []
|
||||
}
|
||||
}
|
||||
@ -1165,6 +1194,7 @@ function getNextPreviewRowTemplate(copyFrom?: ImportPreviewRow): ImportPreviewRo
|
||||
shop_nick: lastRow.shop_nick,
|
||||
remark: lastRow.remark,
|
||||
logistics_code: lastRow.logistics_code,
|
||||
source_platform_code: lastRow.source_platform_code,
|
||||
sys_platform_code: lastRow.sys_platform_code,
|
||||
selected_items: [],
|
||||
plan_qty: '1',
|
||||
@ -1516,6 +1546,7 @@ function buildPreviewRow(row: Record<string, any>, rowNo: number): ImportPreview
|
||||
selected_items: selectedItems,
|
||||
plan_qty: planQty || '1',
|
||||
logistics_code: toImportString(pickImportValue(row, ['快递编码', 'logistics_code'])),
|
||||
source_platform_code: toImportString(pickImportValue(row, ['来源平台编码', 'source_platform_code', '来源平台'])),
|
||||
sys_platform_code: toImportString(pickImportValue(row, ['系统平台编码', 'sys_platform_code', '平台编码'])),
|
||||
import_status: '待创建',
|
||||
import_message: ''
|
||||
@ -1706,6 +1737,7 @@ function buildCreateOrderPayload(rows: ImportPreviewRow[]): PendingOrderCreateOr
|
||||
shop_nick: String(header.shop_nick || '').trim(),
|
||||
remark: String(header.remark || '').trim() || undefined,
|
||||
logistics_code: String(header.logistics_code || '').trim() || undefined,
|
||||
source_platform_code: String(header.source_platform_code || '').trim() || undefined,
|
||||
sys_platform_code: String(header.sys_platform_code || '').trim() || undefined
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ export const ORDER_TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
|
||||
updateExpress: { key: 'updateExpress', label: '修改快递', size: 'small', type: 'warning', plain: true, loadingKey: 'updateOrderMetaLoading', disabledKey: 'hasNoSelection', action: 'openUpdateOrderExpressDialog' },
|
||||
updatePlatform: { key: 'updatePlatform', label: '修改平台', size: 'small', type: 'info', plain: true, loadingKey: 'updateOrderMetaLoading', disabledKey: 'hasNoSelection', action: 'openUpdateOrderPlatformDialog' },
|
||||
updateAddress: { key: 'updateAddress', label: '修改地址', size: 'small', type: 'warning', plain: true, loadingKey: 'updateAddressLoading', disabledKey: 'hasNoSelection', action: 'openUpdateAddressDialog' },
|
||||
|
||||
updateRemark: { key: 'updateRemark', label: '修改留言', size: 'small', type: 'warning', plain: true, loadingKey: 'updateRemarkLoading', disabledKey: 'hasNoSelection', action: 'openUpdateRemarkDialog' },
|
||||
cloneOrder: { key: 'cloneOrder', label: '克隆订单', size: 'small', type: 'warning', plain: true, loadingKey: 'cloneOrderLoading', disabledKey: 'notSingleSelection', action: 'openCloneOrderDialog' },
|
||||
syncOrderIds: { key: 'syncOrderIds', label: '同步订单', size: 'small', type: 'primary', plain: true, loadingKey: 'syncOrderIdsLoading', disabledKey: 'hasNoSelection', action: 'openSyncOrderIdsDialog' },
|
||||
cancelOrder: { key: 'cancelOrder', label: '取消订单', size: 'small', type: 'danger', loadingKey: 'actionLoading', disabledKey: 'hasNoSelection', action: 'handleCancelOrder' },
|
||||
@ -378,6 +378,17 @@ export function pickToolbarButtons(keys: string[]) {
|
||||
.filter((button): button is ToolbarButtonConfig => Boolean(button))
|
||||
}
|
||||
|
||||
/** 取消订单(待处理 / 待审核等页面共用,接口 order.pendingOrder.cancelOrder) */
|
||||
export const ORDER_CANCEL_TOOLBAR_API_ACTION: ToolbarApiActionConfig = {
|
||||
action: 'handleCancelOrder',
|
||||
apiMethod: 'cancelOrder',
|
||||
payloadKey: 'ids',
|
||||
confirmText: '确定取消选中的 {count} 条订单吗?',
|
||||
confirmType: 'error',
|
||||
successText: '取消订单成功',
|
||||
failText: '取消订单失败'
|
||||
}
|
||||
|
||||
/** 同步批量操作:提交后立即返回结果 */
|
||||
export const PENDING_SYNC_TOOLBAR_API_ACTIONS: ToolbarApiActionConfig[] = [
|
||||
{
|
||||
@ -398,15 +409,7 @@ export const PENDING_SYNC_TOOLBAR_API_ACTIONS: ToolbarApiActionConfig[] = [
|
||||
successText: '标记待出库成功',
|
||||
failText: '标记待出库失败'
|
||||
},
|
||||
{
|
||||
action: 'handleCancelOrder',
|
||||
apiMethod: 'cancelOrder',
|
||||
payloadKey: 'ids',
|
||||
confirmText: '确定取消选中的 {count} 条订单吗?',
|
||||
confirmType: 'error',
|
||||
successText: '取消订单成功',
|
||||
failText: '取消订单失败'
|
||||
}
|
||||
ORDER_CANCEL_TOOLBAR_API_ACTION
|
||||
]
|
||||
|
||||
/** 异步批量任务:提交后返回 task_id,需轮询 TaskProgress */
|
||||
@ -484,6 +487,11 @@ export const REVIEW_TOOLBAR_API_ACTIONS: ToolbarApiActionConfig[] = [
|
||||
}
|
||||
]
|
||||
|
||||
/** 待审核页复用待处理订单接口的同步操作 */
|
||||
export const REVIEW_ORDER_SHARED_API_ACTIONS: ToolbarApiActionConfig[] = [
|
||||
ORDER_CANCEL_TOOLBAR_API_ACTION
|
||||
]
|
||||
|
||||
function normalizeUrgencyValue(value: any): string | undefined {
|
||||
if (value === true || value === 1 || value === '1') return 'Y'
|
||||
if (value === false || value === 0 || value === '0') return 'N'
|
||||
@ -1597,7 +1605,9 @@ export const reviewOrderbuttonList: any[] = [
|
||||
export const reviewToolbarButtonKeys = [
|
||||
...simpleListToolbarButtonKeys,
|
||||
'createOrder',
|
||||
'batchReview'
|
||||
'batchReview',
|
||||
'updateRemark',
|
||||
'cancelOrder'
|
||||
]
|
||||
|
||||
/** 页面级按钮列表:reviewOrder 直接消费,避免页面内重复拼装 */
|
||||
@ -1857,6 +1867,7 @@ export const pendingToolbarButtonKeys = [
|
||||
'updateExpress',
|
||||
'updatePlatform',
|
||||
'updateAddress',
|
||||
'updateRemark',
|
||||
'batchQuickRecheck',
|
||||
'cloneOrder',
|
||||
'syncOrderIds',
|
||||
|
||||
@ -286,6 +286,14 @@
|
||||
@closed="resetUpdateAddressDialog"
|
||||
@submit="submitUpdateAddress"
|
||||
/>
|
||||
<update-remark-form
|
||||
v-model="updateRemarkDialogVisible"
|
||||
v-model:form="updateRemarkForm"
|
||||
:order-count="updateRemarkOrderIds.length"
|
||||
:loading="updateRemarkLoading"
|
||||
@closed="resetUpdateRemarkDialog"
|
||||
@submit="submitUpdateRemark"
|
||||
/>
|
||||
<batch-async-task-form
|
||||
v-if="batchAsyncTaskConfig"
|
||||
v-model="batchAsyncTaskDialogVisible"
|
||||
@ -400,6 +408,7 @@ import CloneOrderForm from './form/CloneOrderForm.vue'
|
||||
import ManualWaybillForm from './form/ManualWaybillForm.vue'
|
||||
import SyncOrderIdsForm from './form/SyncOrderIdsForm.vue'
|
||||
import UpdateAddressForm from './form/UpdateAddressForm.vue'
|
||||
import UpdateRemarkForm from './form/UpdateRemarkForm.vue'
|
||||
import BatchAsyncTaskForm from './form/BatchAsyncTaskForm.vue'
|
||||
import OrderExportProgressDialog from './component/OrderExportProgressDialog.vue'
|
||||
import { createOrderPageExport } from './utils/order-page-export'
|
||||
@ -870,6 +879,10 @@ const {
|
||||
updateAddressLoading,
|
||||
updateAddressOrderIds,
|
||||
updateAddressForm,
|
||||
updateRemarkDialogVisible,
|
||||
updateRemarkLoading,
|
||||
updateRemarkOrderIds,
|
||||
updateRemarkForm,
|
||||
batchAsyncTaskDialogVisible,
|
||||
batchAsyncTaskLoading,
|
||||
batchAsyncTaskConfig,
|
||||
@ -885,6 +898,7 @@ const {
|
||||
submitSyncOrderIds,
|
||||
submitAllocateExpress,
|
||||
submitUpdateAddress,
|
||||
submitUpdateRemark,
|
||||
submitBatchAsyncTask,
|
||||
resetAllocateDialog,
|
||||
resetStorageAllocateDialog,
|
||||
@ -893,6 +907,7 @@ const {
|
||||
resetManualWaybillDialog,
|
||||
resetSyncOrderIdsDialog,
|
||||
resetUpdateAddressDialog,
|
||||
resetUpdateRemarkDialog,
|
||||
resetBatchAsyncTaskDialog
|
||||
} = createPendingToolbarController({
|
||||
loadData,
|
||||
@ -933,6 +948,7 @@ const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
manualWaybillLoading: manualWaybillLoading.value,
|
||||
syncOrderIdsLoading: syncOrderIdsLoading.value,
|
||||
updateAddressLoading: updateAddressLoading.value,
|
||||
updateRemarkLoading: updateRemarkLoading.value,
|
||||
batchAsyncTaskLoading: batchAsyncTaskLoading.value,
|
||||
resolveExceptionLoading: resolveExceptionLoading.value,
|
||||
waveSingleFetchLoading: waveSingleFetchLoading.value,
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
placeholder="留空则不修改"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="留言">
|
||||
<!-- <el-form-item label="留言">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
@ -109,7 +109,7 @@
|
||||
show-word-limit
|
||||
placeholder="留空则不修改;填写后将批量覆盖所选订单的留言"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
|
||||
70
src/views/order/orderManagement/form/UpdateRemarkForm.vue
Normal file
70
src/views/order/orderManagement/form/UpdateRemarkForm.vue
Normal file
@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="批量修改留言"
|
||||
width="520px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
@closed="emit('closed')"
|
||||
>
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="update-remark-alert"
|
||||
title="修改说明"
|
||||
description="批量覆盖所选订单的备注/留言,不受 post_status 限制。更新成功后写入操作日志。"
|
||||
/>
|
||||
|
||||
<el-form label-width="96px" class="update-remark-form">
|
||||
<el-form-item label="已选订单数">
|
||||
<span>{{ orderCount }} 条</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="留言" required>
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
resize="none"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="请输入订单备注/留言"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="emit('submit')">确认修改</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
export type UpdateRemarkFormModel = {
|
||||
remark: string
|
||||
}
|
||||
|
||||
const visible = defineModel<boolean>({ default: false })
|
||||
const form = defineModel<UpdateRemarkFormModel>('form', {
|
||||
default: () => ({
|
||||
remark: ''
|
||||
})
|
||||
})
|
||||
|
||||
defineProps<{
|
||||
orderCount: number
|
||||
loading: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'submit'): void
|
||||
(e: 'closed'): void
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.update-remark-alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
</style>
|
||||
@ -258,6 +258,14 @@
|
||||
@closed="resetUpdateAddressDialog"
|
||||
@submit="submitUpdateAddress"
|
||||
/>
|
||||
<update-remark-form
|
||||
v-model="updateRemarkDialogVisible"
|
||||
v-model:form="updateRemarkForm"
|
||||
:order-count="updateRemarkOrderIds.length"
|
||||
:loading="updateRemarkLoading"
|
||||
@closed="resetUpdateRemarkDialog"
|
||||
@submit="submitUpdateRemark"
|
||||
/>
|
||||
<batch-async-task-form
|
||||
v-if="batchAsyncTaskConfig"
|
||||
v-model="batchAsyncTaskDialogVisible"
|
||||
@ -372,6 +380,7 @@ import ManualWaybillForm from './form/ManualWaybillForm.vue'
|
||||
import SyncOrderIdsForm from './form/SyncOrderIdsForm.vue'
|
||||
import BatchQuickRecheckForm from './form/BatchQuickRecheckForm.vue'
|
||||
import UpdateAddressForm from './form/UpdateAddressForm.vue'
|
||||
import UpdateRemarkForm from './form/UpdateRemarkForm.vue'
|
||||
import BatchAsyncTaskForm from './form/BatchAsyncTaskForm.vue'
|
||||
import ExpressWaybillPanel from './component/ExpressWaybillPanel.vue'
|
||||
import OrderExportProgressDialog from './component/OrderExportProgressDialog.vue'
|
||||
@ -728,6 +737,10 @@ const {
|
||||
updateAddressLoading,
|
||||
updateAddressOrderIds,
|
||||
updateAddressForm,
|
||||
updateRemarkDialogVisible,
|
||||
updateRemarkLoading,
|
||||
updateRemarkOrderIds,
|
||||
updateRemarkForm,
|
||||
batchAsyncTaskDialogVisible,
|
||||
batchAsyncTaskLoading,
|
||||
batchAsyncTaskConfig,
|
||||
@ -743,6 +756,7 @@ const {
|
||||
submitSyncOrderIds,
|
||||
submitAllocateExpress,
|
||||
submitUpdateAddress,
|
||||
submitUpdateRemark,
|
||||
submitBatchAsyncTask,
|
||||
handleBatchQuickRecheckSuccess,
|
||||
resetAllocateDialog,
|
||||
@ -753,6 +767,7 @@ const {
|
||||
resetSyncOrderIdsDialog,
|
||||
resetBatchQuickRecheckDialog,
|
||||
resetUpdateAddressDialog,
|
||||
resetUpdateRemarkDialog,
|
||||
resetBatchAsyncTaskDialog
|
||||
} = createPendingToolbarController({
|
||||
loadData,
|
||||
@ -790,6 +805,7 @@ const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
manualWaybillLoading: manualWaybillLoading.value,
|
||||
syncOrderIdsLoading: syncOrderIdsLoading.value,
|
||||
updateAddressLoading: updateAddressLoading.value,
|
||||
updateRemarkLoading: updateRemarkLoading.value,
|
||||
batchAsyncTaskLoading: batchAsyncTaskLoading.value,
|
||||
resolveExceptionLoading: resolveExceptionLoading.value,
|
||||
waveSingleFetchLoading: waveSingleFetchLoading.value,
|
||||
|
||||
@ -143,6 +143,15 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<update-remark-form
|
||||
v-model="updateRemarkDialogVisible"
|
||||
v-model:form="updateRemarkForm"
|
||||
:order-count="updateRemarkOrderIds.length"
|
||||
:loading="updateRemarkLoading"
|
||||
@closed="resetUpdateRemarkDialog"
|
||||
@submit="submitUpdateRemark"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<order-export-progress-dialog
|
||||
@ -165,6 +174,7 @@ import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { orderReviewOrder } from '@/api/order.revieworder/orderreviewOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
|
||||
import {
|
||||
reviewAvailableFields,
|
||||
@ -183,6 +193,7 @@ import OrderDetailDisplayToggle, { type OrderDetailDisplayMode } from './compone
|
||||
import { useCreateOrderSession } from './composables/useCreateOrderSession'
|
||||
import log from './component/log.vue'
|
||||
import OrderExportProgressDialog from './component/OrderExportProgressDialog.vue'
|
||||
import UpdateRemarkForm from './form/UpdateRemarkForm.vue'
|
||||
import { createOrderPageExport } from './utils/order-page-export'
|
||||
import { buildOrderWhereConditions, parseOrderListResponse, resolveOrderRecheckStatus } from './utils/order-index-helpers'
|
||||
import { useOrderListPageCleanup } from './utils/use-order-list-page-cleanup'
|
||||
@ -416,32 +427,17 @@ function toggleDetailVisible() {
|
||||
detailVisible.value = !detailVisible.value
|
||||
}
|
||||
|
||||
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
exportLoading: exportLoading.value,
|
||||
exportSelectionLoading: exportSelectionLoading.value,
|
||||
reviewSubmitting: reviewSubmitting.value
|
||||
}))
|
||||
|
||||
const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
|
||||
hasNoSelection: selectionRows.value.length === 0
|
||||
}))
|
||||
|
||||
const buttonLabelMap = computed<Record<string, string>>(() => ({
|
||||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||||
}))
|
||||
|
||||
const toolbarLayoutKey = computed(() =>
|
||||
JSON.stringify({
|
||||
loading: buttonLoadingMap.value,
|
||||
disabled: buttonDisabledMap.value,
|
||||
labels: buttonLabelMap.value
|
||||
})
|
||||
)
|
||||
|
||||
const {
|
||||
actionMap: toolbarActionMap,
|
||||
reviewSubmitting,
|
||||
submitReview
|
||||
actionLoading,
|
||||
submitReview,
|
||||
updateRemarkDialogVisible,
|
||||
updateRemarkLoading,
|
||||
updateRemarkOrderIds,
|
||||
updateRemarkForm,
|
||||
submitUpdateRemark,
|
||||
resetUpdateRemarkDialog
|
||||
} = createReviewToolbarController({
|
||||
loadData,
|
||||
handleExport,
|
||||
@ -460,9 +456,34 @@ const {
|
||||
selectionRows.value = []
|
||||
hasSelection.value = false
|
||||
},
|
||||
reviewApi: orderReviewOrder
|
||||
reviewApi: orderReviewOrder,
|
||||
orderActionApi: orderPendingOrder
|
||||
})
|
||||
|
||||
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
exportLoading: exportLoading.value,
|
||||
exportSelectionLoading: exportSelectionLoading.value,
|
||||
reviewSubmitting: reviewSubmitting.value,
|
||||
actionLoading: actionLoading.value,
|
||||
updateRemarkLoading: updateRemarkLoading.value
|
||||
}))
|
||||
|
||||
const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
|
||||
hasNoSelection: selectionRows.value.length === 0
|
||||
}))
|
||||
|
||||
const buttonLabelMap = computed<Record<string, string>>(() => ({
|
||||
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||||
}))
|
||||
|
||||
const toolbarLayoutKey = computed(() =>
|
||||
JSON.stringify({
|
||||
loading: buttonLoadingMap.value,
|
||||
disabled: buttonDisabledMap.value,
|
||||
labels: buttonLabelMap.value
|
||||
})
|
||||
)
|
||||
|
||||
function resolveButtonLoading(loadingKey?: string) {
|
||||
if (!loadingKey) return false
|
||||
return Boolean(buttonLoadingMap.value[loadingKey])
|
||||
|
||||
@ -4,6 +4,7 @@ import { useRouter } from 'vue-router'
|
||||
import {
|
||||
PENDING_BATCH_ASYNC_TASK_ACTIONS,
|
||||
PENDING_SYNC_TOOLBAR_API_ACTIONS,
|
||||
REVIEW_ORDER_SHARED_API_ACTIONS,
|
||||
REVIEW_TOOLBAR_API_ACTIONS,
|
||||
type PendingBatchAsyncTaskConfig,
|
||||
type ToolbarApiActionConfig
|
||||
@ -157,6 +158,83 @@ function buildUpdateAddressPayload(ids: OrderId[], form: UpdateAddressFormModel)
|
||||
return { payload, hasUpdateField }
|
||||
}
|
||||
|
||||
function createUpdateRemarkController(params: {
|
||||
getSelectedIds: () => OrderId[]
|
||||
pendingApi: Record<string, any>
|
||||
clearSelection: () => void
|
||||
loadData: () => Promise<void>
|
||||
}) {
|
||||
const updateRemarkDialogVisible = ref(false)
|
||||
const updateRemarkLoading = ref(false)
|
||||
const updateRemarkOrderIds = ref<number[]>([])
|
||||
const updateRemarkForm = reactive({ remark: '' })
|
||||
|
||||
function openUpdateRemarkDialog() {
|
||||
const ids = params
|
||||
.getSelectedIds()
|
||||
.map((id) => Number(id))
|
||||
.filter((id) => Number.isInteger(id) && id > 0)
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('请先勾选需要修改留言的订单')
|
||||
return
|
||||
}
|
||||
updateRemarkOrderIds.value = [...ids]
|
||||
updateRemarkForm.remark = ''
|
||||
updateRemarkDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function submitUpdateRemark() {
|
||||
if (updateRemarkLoading.value) return
|
||||
const ids = [...updateRemarkOrderIds.value]
|
||||
if (!ids.length) {
|
||||
ElMessage.error('没有可提交的订单')
|
||||
return
|
||||
}
|
||||
const remark = String(updateRemarkForm.remark ?? '').trim()
|
||||
if (!remark) {
|
||||
ElMessage.warning('请填写留言内容')
|
||||
return
|
||||
}
|
||||
if (remark.length > 500) {
|
||||
ElMessage.warning('留言最多500字符')
|
||||
return
|
||||
}
|
||||
updateRemarkLoading.value = true
|
||||
try {
|
||||
const res = await params.pendingApi.updateRemark({ ids, remark })
|
||||
const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success')
|
||||
if (!ok) {
|
||||
ElMessage.error(res?.message || '批量修改留言失败')
|
||||
return
|
||||
}
|
||||
const updated = Number(res?.data?.updated_count ?? res?.updated_count ?? ids.length) || ids.length
|
||||
ElMessage.success(`留言修改成功 ${updated} 条`)
|
||||
updateRemarkDialogVisible.value = false
|
||||
params.clearSelection()
|
||||
await params.loadData()
|
||||
} catch {
|
||||
ElMessage.error('批量修改留言失败')
|
||||
} finally {
|
||||
updateRemarkLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetUpdateRemarkDialog() {
|
||||
updateRemarkOrderIds.value = []
|
||||
updateRemarkForm.remark = ''
|
||||
}
|
||||
|
||||
return {
|
||||
updateRemarkDialogVisible,
|
||||
updateRemarkLoading,
|
||||
updateRemarkOrderIds,
|
||||
updateRemarkForm,
|
||||
openUpdateRemarkDialog,
|
||||
submitUpdateRemark,
|
||||
resetUpdateRemarkDialog
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeBatchTaskState(value: unknown) {
|
||||
return String(value ?? '').trim().toLowerCase()
|
||||
}
|
||||
@ -202,6 +280,8 @@ export function createReviewToolbarActionMap(params: {
|
||||
getSelectedIds: () => OrderId[]
|
||||
reviewApi: Record<string, any>
|
||||
reviewSubmitting: { value: boolean }
|
||||
orderActionApi?: Record<string, any>
|
||||
actionLoading?: { value: boolean }
|
||||
clearSelection: () => void
|
||||
loadData: () => Promise<void>
|
||||
}) {
|
||||
@ -220,6 +300,22 @@ export function createReviewToolbarActionMap(params: {
|
||||
reload: params.loadData
|
||||
})
|
||||
}
|
||||
|
||||
const { orderActionApi, actionLoading } = params
|
||||
if (orderActionApi && actionLoading) {
|
||||
for (const config of REVIEW_ORDER_SHARED_API_ACTIONS) {
|
||||
actionMap[config.action] = () =>
|
||||
executeApiAction({
|
||||
ids: params.getSelectedIds(),
|
||||
api: orderActionApi,
|
||||
config,
|
||||
loading: actionLoading,
|
||||
clearSelection: params.clearSelection,
|
||||
reload: params.loadData
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return actionMap
|
||||
}
|
||||
|
||||
@ -235,8 +331,19 @@ export function createReviewToolbarController(params: {
|
||||
getSelectedIds: () => Array<number | string>
|
||||
clearSelection: () => void
|
||||
reviewApi: Record<string, any>
|
||||
orderActionApi?: Record<string, any>
|
||||
}) {
|
||||
const reviewSubmitting = ref(false)
|
||||
const actionLoading = ref(false)
|
||||
|
||||
const updateRemarkController = params.orderActionApi
|
||||
? createUpdateRemarkController({
|
||||
getSelectedIds: params.getSelectedIds,
|
||||
pendingApi: params.orderActionApi,
|
||||
clearSelection: params.clearSelection,
|
||||
loadData: params.loadData
|
||||
})
|
||||
: null
|
||||
|
||||
const actionMap = createReviewToolbarActionMap({
|
||||
baseActions: {
|
||||
@ -244,11 +351,16 @@ export function createReviewToolbarController(params: {
|
||||
...bindExportToolbarActions(params),
|
||||
openColumnConfigPanel: params.openColumnConfigPanel,
|
||||
toggleDetailVisible: params.toggleDetailVisible,
|
||||
openCreateOrderDialog: params.openCreateOrderDialog
|
||||
openCreateOrderDialog: params.openCreateOrderDialog,
|
||||
...(updateRemarkController
|
||||
? { openUpdateRemarkDialog: updateRemarkController.openUpdateRemarkDialog }
|
||||
: {})
|
||||
},
|
||||
getSelectedIds: params.getSelectedIds,
|
||||
reviewApi: params.reviewApi,
|
||||
reviewSubmitting,
|
||||
orderActionApi: params.orderActionApi,
|
||||
actionLoading,
|
||||
clearSelection: params.clearSelection,
|
||||
loadData: params.loadData
|
||||
})
|
||||
@ -280,7 +392,9 @@ export function createReviewToolbarController(params: {
|
||||
return {
|
||||
actionMap,
|
||||
reviewSubmitting,
|
||||
submitReview
|
||||
actionLoading,
|
||||
submitReview,
|
||||
...(updateRemarkController ?? {})
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,6 +537,21 @@ export function createPendingToolbarController(params: {
|
||||
const updateAddressOrderIds = ref<number[]>([])
|
||||
const updateAddressForm = reactive(createEmptyUpdateAddressForm())
|
||||
|
||||
const {
|
||||
updateRemarkDialogVisible,
|
||||
updateRemarkLoading,
|
||||
updateRemarkOrderIds,
|
||||
updateRemarkForm,
|
||||
openUpdateRemarkDialog,
|
||||
submitUpdateRemark,
|
||||
resetUpdateRemarkDialog
|
||||
} = createUpdateRemarkController({
|
||||
getSelectedIds: params.getSelectedIds,
|
||||
pendingApi: params.pendingApi,
|
||||
clearSelection: params.clearSelection,
|
||||
loadData: params.loadData
|
||||
})
|
||||
|
||||
const batchAsyncTaskDialogVisible = ref(false)
|
||||
const batchAsyncTaskLoading = ref(false)
|
||||
const batchAsyncTaskConfig = ref<PendingBatchAsyncTaskConfig | null>(null)
|
||||
@ -520,6 +649,7 @@ export function createPendingToolbarController(params: {
|
||||
openUpdateOrderExpressDialog: () => openUpdateOrderMetaDialog('express'),
|
||||
openUpdateOrderPlatformDialog: () => openUpdateOrderMetaDialog('platform'),
|
||||
openUpdateAddressDialog,
|
||||
openUpdateRemarkDialog,
|
||||
openCreateOrderDialog: params.openCreateOrderDialog,
|
||||
openCloneOrderDialog,
|
||||
openSyncOrderIdsDialog,
|
||||
@ -1163,6 +1293,10 @@ export function createPendingToolbarController(params: {
|
||||
updateAddressLoading,
|
||||
updateAddressOrderIds,
|
||||
updateAddressForm,
|
||||
updateRemarkDialogVisible,
|
||||
updateRemarkLoading,
|
||||
updateRemarkOrderIds,
|
||||
updateRemarkForm,
|
||||
batchAsyncTaskDialogVisible,
|
||||
batchAsyncTaskLoading,
|
||||
batchAsyncTaskConfig,
|
||||
@ -1178,6 +1312,7 @@ export function createPendingToolbarController(params: {
|
||||
submitSyncOrderIds,
|
||||
submitAllocateExpress,
|
||||
submitUpdateAddress,
|
||||
submitUpdateRemark,
|
||||
submitBatchAsyncTask,
|
||||
handleBatchQuickRecheckSuccess,
|
||||
resetAllocateDialog,
|
||||
@ -1188,6 +1323,7 @@ export function createPendingToolbarController(params: {
|
||||
resetSyncOrderIdsDialog,
|
||||
resetBatchQuickRecheckDialog,
|
||||
resetUpdateAddressDialog,
|
||||
resetUpdateRemarkDialog,
|
||||
resetBatchAsyncTaskDialog
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="order-sub-container" :style="{ height: containerHeight }">
|
||||
<div class="order-sub-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
cache-key="stock-combo-goods"
|
||||
@ -91,12 +91,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import { comboGoodsDelete, comboGoodsList } from '@/api/combogoods/combogoods'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import ComboGoodsFormDialog from './component/ComboGoodsFormDialog.vue'
|
||||
import ComboGoodsSearchDialog from './component/ComboGoodsSearchDialog.vue'
|
||||
import {
|
||||
@ -111,17 +110,11 @@ import {
|
||||
type ComboGoodsRecord
|
||||
} from './combo-stock-config'
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const scanBox = ref<any>(null)
|
||||
|
||||
const presetTree = ref<any[]>([])
|
||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(comboGoodsScanFields)))
|
||||
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() =>
|
||||
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
|
||||
)
|
||||
|
||||
const columns = comboGoodsColumns
|
||||
const loading = ref(false)
|
||||
const tableData = ref<ComboGoodsRecord[]>([])
|
||||
|
||||
184
src/views/stock/stockManagement/index.vue
Normal file
184
src/views/stock/stockManagement/index.vue
Normal file
@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<div class="stock-management-wrapper" :style="{ height: containerHeight }">
|
||||
<el-tabs
|
||||
v-model="activeTab"
|
||||
tab-position="top"
|
||||
type="border-card"
|
||||
class="tab-container"
|
||||
@tab-change="handleTabChange"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="tab in tabs"
|
||||
:key="tab.name"
|
||||
:name="tab.name"
|
||||
:label="tab.label"
|
||||
:lazy="false"
|
||||
>
|
||||
<component :is="tab.component" v-if="activeTab === tab.name" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, markRaw, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
import StockDetail from '../stock/index.vue'
|
||||
import ComboStock from '../combo_stock/index.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() =>
|
||||
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
|
||||
)
|
||||
|
||||
type StockTabItem = {
|
||||
name: string
|
||||
label: string
|
||||
component: any
|
||||
}
|
||||
|
||||
const tabs = ref<StockTabItem[]>([
|
||||
{
|
||||
name: 'stockDetail',
|
||||
label: '商品明细',
|
||||
component: markRaw(StockDetail)
|
||||
},
|
||||
{
|
||||
name: 'comboStock',
|
||||
label: '组合商品',
|
||||
component: markRaw(ComboStock)
|
||||
}
|
||||
])
|
||||
|
||||
const activeTab = ref('stockDetail')
|
||||
|
||||
function resolveDefaultTab(): string {
|
||||
const path = String(route.path || '').toLowerCase()
|
||||
if (path.includes('combo')) {
|
||||
return 'comboStock'
|
||||
}
|
||||
return 'stockDetail'
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [route.query.tab, route.path] as const,
|
||||
([newTab]) => {
|
||||
const validTabs = tabs.value.map((tab) => tab.name)
|
||||
const raw = newTab === undefined || newTab === null ? '' : String(newTab).trim()
|
||||
|
||||
if (raw && validTabs.includes(raw)) {
|
||||
activeTab.value = raw
|
||||
return
|
||||
}
|
||||
|
||||
activeTab.value = resolveDefaultTab()
|
||||
if (raw && !validTabs.includes(raw)) {
|
||||
router.replace({
|
||||
query: {
|
||||
...route.query,
|
||||
tab: resolveDefaultTab()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const handleTabChange = (tabName: string | number) => {
|
||||
safeInvoke(() => {
|
||||
const name = String(tabName)
|
||||
if (String(route.query.tab ?? '') === name) {
|
||||
return
|
||||
}
|
||||
router.replace({
|
||||
query: {
|
||||
...route.query,
|
||||
tab: name
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.stock-management-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
|
||||
:deep(.el-tabs__header) {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__header.is-top) {
|
||||
padding: 4px 12px 0;
|
||||
background: #f8fbff;
|
||||
border-bottom: 1px solid #e8eef7;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__nav-wrap::after) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item.is-top) {
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
padding: 0 20px;
|
||||
border-radius: 6px 6px 0 0;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||
border: 1px solid transparent;
|
||||
border-bottom: none;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item.is-top:hover) {
|
||||
color: #409eff;
|
||||
background-color: rgba(64, 158, 255, 0.05);
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item.is-top.is-active) {
|
||||
color: #409eff;
|
||||
font-weight: 600;
|
||||
background: #ffffff;
|
||||
border-color: #e8eef7;
|
||||
border-bottom: 2px solid #ffffff;
|
||||
margin-bottom: -1px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__active-bar) {
|
||||
height: 2px;
|
||||
border-radius: 2px;
|
||||
background-color: #409eff;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__content) {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
|
||||
.el-tab-pane {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,375 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="绑定收货明细"
|
||||
width="920px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="!submitting"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<!-- <el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="bind-tip"
|
||||
title="storage.entry.bindReceivingDetails"
|
||||
description="按入库明细 stock_id 查询可入库收货明细,选择并填写分配数量后完成绑定。重复绑定将覆盖该入库明细下所有 pending 绑定。"
|
||||
/> -->
|
||||
|
||||
<div v-if="entryItem" class="entry-item-summary">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">商品编码</span>
|
||||
<span class="summary-value">{{ entryItem.warehouse_item_code || '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">商品名称</span>
|
||||
<span class="summary-value">{{ entryItem.warehouse_item_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">应收数量</span>
|
||||
<span class="summary-value">{{ entryItem.count ?? '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">实收数量</span>
|
||||
<span class="summary-value">{{ entryItem.pending_total ?? '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">SKU</span>
|
||||
<span class="summary-value">{{ entryItem.stock_id ?? '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-toolbar">
|
||||
<span class="toolbar-meta">可绑定收货明细 {{ receivingList.length }} 条</span>
|
||||
<el-button size="small" :loading="loading" @click="loadReceivingList">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="receivingList"
|
||||
border
|
||||
size="small"
|
||||
max-height="360"
|
||||
v-loading="loading"
|
||||
row-key="detail_id"
|
||||
empty-text="暂无可绑定的收货明细"
|
||||
>
|
||||
<el-table-column prop="receiving_number" label="收货单号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="product_name" label="商品名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="actual_quantity" label="实收数量" width="90" align="right" />
|
||||
<el-table-column prop="stored_quantity" label="已入库" width="90" align="right" />
|
||||
<el-table-column prop="available_quantity" label="可入库" width="90" align="right">
|
||||
<template #default="{ row }">
|
||||
<el-tag type="success" size="small">{{ row.available_quantity ?? 0 }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="batch_number" label="批次号" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="production_date" label="生产日期" width="110" />
|
||||
<el-table-column prop="expiry_date" label="有效期" width="110" />
|
||||
<el-table-column label="分配数量" width="200" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="allocation-cell">
|
||||
<el-input-number
|
||||
v-model="allocationMap[row.detail_id]"
|
||||
:min="0"
|
||||
:max="getRowMaxAllocation(row)"
|
||||
:precision="0"
|
||||
size="small"
|
||||
controls-position="right"
|
||||
style="width: 110px"
|
||||
/>
|
||||
<el-button link type="primary" size="small" @click="setMaxAllocation(row)">
|
||||
最大
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="allocation-summary">
|
||||
已填写分配数量合计:<strong>{{ totalAllocated }}</strong>
|
||||
/ 可绑上限 <strong>{{ remainingBindCapacity }}</strong>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button :disabled="submitting" @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">确认绑定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
bindReceivingDetails,
|
||||
type BindReceivingDetailsBinding,
|
||||
} from '@/api/storage.entry/entry'
|
||||
import {
|
||||
getAvailableInboundQuantity,
|
||||
type AvailableInboundQuantityItem,
|
||||
} from '@/api/storage.receiving/receiving'
|
||||
|
||||
export type EntryDetailBindRow = {
|
||||
id?: number
|
||||
stock_id?: number
|
||||
warehouse_item_code?: string
|
||||
warehouse_item_name?: string
|
||||
count?: number
|
||||
pending_total?: number
|
||||
bindings?: Array<Record<string, unknown>>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
entryItem: EntryDetailBindRow | null
|
||||
entryOrderId?: string | number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
success: []
|
||||
}>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value),
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const receivingList = ref<AvailableInboundQuantityItem[]>([])
|
||||
const allocationMap = reactive<Record<number, number>>({})
|
||||
|
||||
const totalAllocated = computed(() =>
|
||||
Object.values(allocationMap).reduce((sum, qty) => sum + (Number(qty) || 0), 0)
|
||||
)
|
||||
|
||||
/** 应收数量 - 实收数量(pending 绑定合计) */
|
||||
const remainingBindCapacity = computed(() => {
|
||||
const count = Number(props.entryItem?.count) || 0
|
||||
const receivedQty = Number(props.entryItem?.pending_total) || 0
|
||||
return Math.max(0, count - receivedQty)
|
||||
})
|
||||
|
||||
function getOtherAllocatedTotal(excludeDetailId: number): number {
|
||||
return receivingList.value.reduce((sum, row) => {
|
||||
const detailId = Number(row.detail_id)
|
||||
if (!Number.isFinite(detailId) || detailId <= 0 || detailId === excludeDetailId) return sum
|
||||
return sum + (Number(allocationMap[detailId]) || 0)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function getRowMaxAllocation(row: AvailableInboundQuantityItem): number {
|
||||
const detailId = Number(row.detail_id)
|
||||
const available = Math.max(0, Number(row.available_quantity) || 0)
|
||||
if (!Number.isFinite(detailId) || detailId <= 0) return available
|
||||
const capacityLeft = remainingBindCapacity.value - getOtherAllocatedTotal(detailId)
|
||||
return Math.max(0, Math.min(available, capacityLeft))
|
||||
}
|
||||
|
||||
function setMaxAllocation(row: AvailableInboundQuantityItem) {
|
||||
const detailId = Number(row.detail_id)
|
||||
if (!Number.isFinite(detailId) || detailId <= 0) return
|
||||
allocationMap[detailId] = getRowMaxAllocation(row)
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
receivingList.value = []
|
||||
Object.keys(allocationMap).forEach((key) => {
|
||||
delete allocationMap[Number(key)]
|
||||
})
|
||||
}
|
||||
|
||||
function parseReceivingList(res: any): AvailableInboundQuantityItem[] {
|
||||
const data = res?.data && typeof res.data === 'object' ? res.data : res
|
||||
return (data?.list ?? res?.list ?? []) as AvailableInboundQuantityItem[]
|
||||
}
|
||||
|
||||
function isApiSuccess(res: any): boolean {
|
||||
return !!(res && (res.code === 200 || res.code === 1 || res.flag === 'success'))
|
||||
}
|
||||
|
||||
async function loadReceivingList() {
|
||||
const stockId = Number(props.entryItem?.stock_id)
|
||||
if (!Number.isFinite(stockId) || stockId <= 0) {
|
||||
receivingList.value = []
|
||||
ElMessage.warning('当前入库明细缺少有效的 stock_id,无法查询收货单')
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getAvailableInboundQuantity({ stock_id: stockId })
|
||||
if (!isApiSuccess(res)) {
|
||||
receivingList.value = []
|
||||
ElMessage.error(res?.message || '查询可入库收货明细失败')
|
||||
return
|
||||
}
|
||||
receivingList.value = parseReceivingList(res)
|
||||
receivingList.value.forEach((row) => {
|
||||
const detailId = Number(row.detail_id)
|
||||
if (!Number.isFinite(detailId) || detailId <= 0) return
|
||||
if (allocationMap[detailId] == null) {
|
||||
allocationMap[detailId] = 0
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('查询可入库收货明细失败:', error)
|
||||
receivingList.value = []
|
||||
ElMessage.error('查询可入库收货明细失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function buildBindings(entryItemId: number): BindReceivingDetailsBinding[] {
|
||||
const bindings: BindReceivingDetailsBinding[] = []
|
||||
for (const row of receivingList.value) {
|
||||
const detailId = Number(row.detail_id)
|
||||
const allocated = Number(allocationMap[detailId] || 0)
|
||||
const maxAllowed = getRowMaxAllocation(row)
|
||||
if (!Number.isFinite(detailId) || detailId <= 0 || allocated <= 0) continue
|
||||
if (allocated > maxAllowed) {
|
||||
throw new Error(
|
||||
`收货明细 ${row.receiving_number || detailId} 的分配数量不能超过 ${maxAllowed}(应收减实收后的剩余可绑量)`
|
||||
)
|
||||
}
|
||||
bindings.push({
|
||||
entry_item_id: entryItemId,
|
||||
receiving_detail_id: detailId,
|
||||
allocated_quantity: Math.floor(allocated),
|
||||
})
|
||||
}
|
||||
if (totalAllocated.value > remainingBindCapacity.value) {
|
||||
throw new Error(
|
||||
`分配数量合计不能超过 ${remainingBindCapacity.value}(应收数量减实收数量)`
|
||||
)
|
||||
}
|
||||
return bindings
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
const entryOrderId = Number(props.entryOrderId)
|
||||
if (!Number.isFinite(entryOrderId) || entryOrderId <= 0) {
|
||||
ElMessage.warning('入库单 ID 无效,无法绑定')
|
||||
return
|
||||
}
|
||||
|
||||
const entryItemId = Number(props.entryItem?.id)
|
||||
if (!Number.isFinite(entryItemId) || entryItemId <= 0) {
|
||||
ElMessage.warning('入库明细 ID 无效,无法绑定')
|
||||
return
|
||||
}
|
||||
|
||||
let bindings: BindReceivingDetailsBinding[] = []
|
||||
try {
|
||||
bindings = buildBindings(entryItemId)
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : '分配数量填写有误'
|
||||
ElMessage.warning(message)
|
||||
return
|
||||
}
|
||||
|
||||
if (!bindings.length) {
|
||||
ElMessage.warning('请至少填写一条大于 0 的分配数量')
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const res = await bindReceivingDetails({
|
||||
entry_order_id: entryOrderId,
|
||||
bindings,
|
||||
})
|
||||
if (!isApiSuccess(res)) {
|
||||
ElMessage.error(res?.message || '绑定收货明细失败')
|
||||
return
|
||||
}
|
||||
const bindingCount = res?.success_count ?? res?.data?.success_count ?? bindings.length
|
||||
ElMessage.success(`绑定成功,共 ${bindingCount} 条`)
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (error) {
|
||||
console.error('绑定收货明细失败:', error)
|
||||
ElMessage.error('绑定收货明细失败')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
resetState()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue, props.entryItem?.id, props.entryItem?.stock_id] as const,
|
||||
([open]) => {
|
||||
if (!open) return
|
||||
resetState()
|
||||
void loadReceivingList()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.bind-tip {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.entry-item-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding: 12px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px;
|
||||
|
||||
.summary-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.toolbar-meta {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
|
||||
.allocation-summary {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.allocation-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -33,7 +33,7 @@
|
||||
<el-form-item label="SKU">
|
||||
<el-input :model-value="String(singleTarget.stock_id ?? '')" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="入库数量" prop="quantity">
|
||||
<el-form-item v-if="!showContainerPicker" label="入库数量" prop="quantity">
|
||||
<el-input-number
|
||||
v-model="singleForm.quantity"
|
||||
:min="1"
|
||||
@ -54,6 +54,24 @@
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="showContainerPicker" label="收货容器" prop="receiving_detail_id">
|
||||
<el-select
|
||||
v-model="singleForm.receiving_detail_id"
|
||||
placeholder="请选择收货容器"
|
||||
filterable
|
||||
clearable
|
||||
:loading="containerLoading"
|
||||
style="width: 100%"
|
||||
@visible-change="(open: boolean) => open && loadContainers()"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in containerOptions"
|
||||
:key="item.detail_id"
|
||||
:label="formatContainerLabel(item)"
|
||||
:value="Number(item.detail_id)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="库位">
|
||||
<el-input :model-value="singleSpaceDisplay" readonly>
|
||||
<template #append>
|
||||
@ -230,7 +248,7 @@ import { ElMessage, type FormInstance, type FormRules, type UploadFile } from 'e
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { addDirectInboundItem } from '@/api/storage.entry/entry'
|
||||
import { addItem, containerList, type EntryContainerListItem } from '@/api/storage.entry/entry'
|
||||
import { directInboundInboundTypeOptions } from '../entry-config'
|
||||
import {
|
||||
downloadDirectInboundImportTemplate,
|
||||
@ -247,9 +265,11 @@ export type { DirectInboundImportRow }
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
/** 入库单 ID(storage.entry.addDirectInboundItem 必填) */
|
||||
/** 入库单 ID(storage.entry.addItem 必填) */
|
||||
entryOrderId?: string | number
|
||||
entryOrderCode?: string
|
||||
/** 入库单状态,PENDING + PDA 时需选择收货容器 */
|
||||
orderStatus?: string
|
||||
/** 单条导入目标 */
|
||||
targetItem?: DirectInboundImportRow | null
|
||||
/** Excel 批量导入模式 */
|
||||
@ -281,6 +301,15 @@ const singleForm = reactive({
|
||||
space_id: undefined as number | undefined,
|
||||
space_keyword: '',
|
||||
remark: '',
|
||||
receiving_detail_id: undefined as number | undefined,
|
||||
})
|
||||
|
||||
const containerLoading = ref(false)
|
||||
const containerOptions = ref<EntryContainerListItem[]>([])
|
||||
|
||||
const showContainerPicker = computed(() => {
|
||||
const status = String(props.orderStatus ?? '').trim().toUpperCase()
|
||||
return singleForm.inbound_type === 'pda' && status === 'PENDING'
|
||||
})
|
||||
|
||||
const spacePickerVisible = ref(false)
|
||||
@ -327,6 +356,23 @@ const singleFormRules: FormRules = {
|
||||
},
|
||||
],
|
||||
inbound_type: [{ required: true, message: '请选择入库方式', trigger: 'change' }],
|
||||
receiving_detail_id: [
|
||||
{
|
||||
validator: (_rule, value, callback) => {
|
||||
if (!showContainerPicker.value) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
const detailId = Number(value)
|
||||
if (!Number.isInteger(detailId) || detailId <= 0) {
|
||||
callback(new Error('PDA 上架须选择收货容器'))
|
||||
return
|
||||
}
|
||||
callback()
|
||||
},
|
||||
trigger: 'change',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
watch(
|
||||
@ -342,6 +388,8 @@ watch(
|
||||
singleForm.space_id = undefined
|
||||
singleForm.space_keyword = ''
|
||||
singleForm.remark = ''
|
||||
singleForm.receiving_detail_id = undefined
|
||||
containerOptions.value = []
|
||||
resetBatchState()
|
||||
return
|
||||
}
|
||||
@ -354,6 +402,53 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => singleForm.inbound_type,
|
||||
(type) => {
|
||||
if (type !== 'pda') {
|
||||
singleForm.receiving_detail_id = undefined
|
||||
containerOptions.value = []
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
function formatContainerLabel(item: EntryContainerListItem): string {
|
||||
const barcode = item.barcode ? String(item.barcode) : ''
|
||||
const name = item.product_name ? String(item.product_name) : ''
|
||||
const qty = item.actual_quantity ?? '—'
|
||||
const parts = [barcode, name].filter(Boolean)
|
||||
const base = parts.length ? parts.join(' / ') : `明细 ${item.detail_id ?? ''}`
|
||||
return `${base}(实收 ${qty})`
|
||||
}
|
||||
|
||||
async function loadContainers() {
|
||||
if (!showContainerPicker.value) return
|
||||
|
||||
const entryOrderId = Number(props.entryOrderId)
|
||||
const stockId = Number(singleTarget.value?.stock_id)
|
||||
if (!Number.isInteger(entryOrderId) || entryOrderId <= 0) return
|
||||
if (!Number.isInteger(stockId) || stockId <= 0) {
|
||||
ElMessage.warning('当前商品缺少有效 SKU,无法查询收货容器')
|
||||
return
|
||||
}
|
||||
|
||||
containerLoading.value = true
|
||||
try {
|
||||
const res = await containerList({ entry_order_id: entryOrderId, stock_id: stockId })
|
||||
if (res?.code !== 200 && res?.code !== undefined) {
|
||||
throw new Error(res?.message || '查询收货容器失败')
|
||||
}
|
||||
const payload = (res.data && typeof res.data === 'object' ? res.data : res) as Record<string, unknown>
|
||||
containerOptions.value = Array.isArray(payload.list) ? (payload.list as EntryContainerListItem[]) : []
|
||||
} catch (error) {
|
||||
console.error('查询收货容器失败:', error)
|
||||
containerOptions.value = []
|
||||
ElMessage.error(error instanceof Error ? error.message : '查询收货容器失败')
|
||||
} finally {
|
||||
containerLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetBatchState() {
|
||||
importFileName.value = ''
|
||||
parsedRows.value = []
|
||||
@ -560,14 +655,21 @@ async function handleSubmit() {
|
||||
ElMessage.warning(spaceError)
|
||||
return
|
||||
}
|
||||
if (showContainerPicker.value && !normalizeSpaceId(singleForm.space_id)) {
|
||||
ElMessage.warning('PDA 上架须选择存放库位')
|
||||
return
|
||||
}
|
||||
|
||||
const res = await addDirectInboundItem({
|
||||
const res = await addItem({
|
||||
entry_order_id: entryOrderId,
|
||||
stock_id: Number(singleTarget.value.stock_id),
|
||||
quantity: Number(singleForm.quantity),
|
||||
quantity: showContainerPicker.value ? undefined : Number(singleForm.quantity),
|
||||
inbound_type: singleForm.inbound_type,
|
||||
space_id: normalizeSpaceId(singleForm.space_id),
|
||||
remark: singleForm.remark?.trim() || undefined,
|
||||
receiving_detail_id: showContainerPicker.value
|
||||
? Number(singleForm.receiving_detail_id)
|
||||
: undefined,
|
||||
})
|
||||
if (res?.code !== 200 && res?.code !== undefined) {
|
||||
throw new Error(res?.message || '导入入库失败')
|
||||
@ -593,7 +695,7 @@ async function handleSubmit() {
|
||||
}
|
||||
}
|
||||
|
||||
const res = await addDirectInboundItem({
|
||||
const res = await addItem({
|
||||
entry_order_id: entryOrderId,
|
||||
items: parsedRows.value.map((row) => ({
|
||||
stock_id: Number(row.stock_id),
|
||||
|
||||
@ -64,10 +64,11 @@ import { computed, reactive, ref, watch, onActivated } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import {
|
||||
getDirectInboundItems,
|
||||
removeDirectInboundItem,
|
||||
collectDirectInboundLogs,
|
||||
getEntryDetail,
|
||||
removeItem,
|
||||
type DirectInboundLog,
|
||||
} from '@/api/storage.directinbound/directinbound'
|
||||
} from '@/api/storage.entry/entry'
|
||||
import {
|
||||
canDirectInboundOperate,
|
||||
directInboundLogActionColumn,
|
||||
@ -91,11 +92,6 @@ const directLogList = ref<DirectInboundLog[]>([])
|
||||
const selectedRows = ref<DirectInboundLog[]>([])
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
const entryOrderCode = computed(() => {
|
||||
const code = props.row?.entry_order_code
|
||||
return code ? String(code) : ''
|
||||
})
|
||||
|
||||
const canRemove = computed(() => canDirectInboundOperate(props.row?.order_status))
|
||||
|
||||
const logColumns = computed(() => {
|
||||
@ -104,10 +100,10 @@ const logColumns = computed(() => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [props.id, entryOrderCode.value],
|
||||
() => [props.id],
|
||||
() => {
|
||||
selectedRows.value = []
|
||||
if (props.id && entryOrderCode.value) {
|
||||
if (props.id) {
|
||||
void loadLogs()
|
||||
} else {
|
||||
directLogList.value = []
|
||||
@ -118,19 +114,11 @@ watch(
|
||||
)
|
||||
|
||||
onActivated(() => {
|
||||
if (props.id && entryOrderCode.value) {
|
||||
if (props.id) {
|
||||
void loadLogs()
|
||||
}
|
||||
})
|
||||
|
||||
function unwrapPayload(res: Record<string, unknown> | null | undefined) {
|
||||
if (!res) return null
|
||||
if (res.data && typeof res.data === 'object') {
|
||||
return res.data as Record<string, unknown>
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function canRemoveRow(row: DirectInboundLog): boolean {
|
||||
const logId = Number(row.id)
|
||||
return Number.isInteger(logId) && logId > 0
|
||||
@ -147,8 +135,8 @@ function getRowLabel(row: DirectInboundLog): string {
|
||||
}
|
||||
|
||||
async function loadLogs() {
|
||||
const code = entryOrderCode.value
|
||||
if (!code) {
|
||||
const entryId = Number(props.id)
|
||||
if (!Number.isInteger(entryId) || entryId <= 0) {
|
||||
directLogList.value = []
|
||||
pagination.total = 0
|
||||
return
|
||||
@ -156,15 +144,13 @@ async function loadLogs() {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getDirectInboundItems({ entry_order_code: code })
|
||||
const res = await getEntryDetail({ id: entryId })
|
||||
if (res?.code !== 200 && res?.code !== undefined) {
|
||||
throw new Error(res?.message || '获取入库记录失败')
|
||||
}
|
||||
|
||||
const payload = unwrapPayload(res as Record<string, unknown>)
|
||||
directLogList.value = Array.isArray(payload?.direct_logs)
|
||||
? (payload.direct_logs as DirectInboundLog[])
|
||||
: []
|
||||
const entryOrder = res.data?.entryOrder
|
||||
directLogList.value = collectDirectInboundLogs(entryOrder)
|
||||
pagination.total = directLogList.value.length
|
||||
selectedRows.value = []
|
||||
} catch (error) {
|
||||
@ -196,7 +182,7 @@ async function removeLogRow(row: DirectInboundLog): Promise<boolean> {
|
||||
return false
|
||||
}
|
||||
|
||||
const res = await removeDirectInboundItem({ id: logId })
|
||||
const res = await removeItem({ id: logId })
|
||||
if (res?.code !== 200 && res?.code !== undefined) {
|
||||
throw new Error(res?.message || '移除入库记录失败')
|
||||
}
|
||||
|
||||
@ -1,340 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="解绑收货明细"
|
||||
width="920px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="!submitting"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div v-if="entryItem" class="entry-item-summary">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">商品编码</span>
|
||||
<span class="summary-value">{{ entryItem.warehouse_item_code || '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">商品名称</span>
|
||||
<span class="summary-value">{{ entryItem.warehouse_item_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">实收数量</span>
|
||||
<span class="summary-value">{{ entryItem.pending_total ?? '—' }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">SKU</span>
|
||||
<span class="summary-value">{{ entryItem.stock_id ?? '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-toolbar">
|
||||
<span class="toolbar-meta">pending 绑定 {{ bindingList.length }} 条</span>
|
||||
<el-button size="small" :loading="loading" @click="loadBindings">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="bindingList"
|
||||
border
|
||||
size="small"
|
||||
max-height="360"
|
||||
v-loading="loading"
|
||||
row-key="id"
|
||||
empty-text="暂无可解绑的绑定记录"
|
||||
>
|
||||
<el-table-column label="收货单ID" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.receiving_id ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品名称" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.product_name ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实收数量" width="90" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.actual_quantity ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="已入库" width="90" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.stored_quantity ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="allocated_quantity" label="分配数量" width="90" align="right" />
|
||||
<el-table-column prop="batch_number" label="批次号" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.batch_number ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="生产日期" width="110">
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.production_date ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效期" width="110">
|
||||
<template #default="{ row }">
|
||||
{{ row.receivingDetail?.expiry_date ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
size="small"
|
||||
:loading="unbindingId === row.id"
|
||||
:disabled="submitting"
|
||||
@click="handleUnbindRow(row)"
|
||||
>
|
||||
解绑
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button :disabled="submitting" @click="visible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
bindReceivingDetails,
|
||||
getEntryDetail,
|
||||
unbindReceivingDetails,
|
||||
type EntryDetailBinding,
|
||||
} from '@/api/storage.entry/entry'
|
||||
import type { EntryDetailBindRow } from './BindReceivingDetailsDialog.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
entryItem: EntryDetailBindRow | null
|
||||
entryOrderId?: string | number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
success: []
|
||||
}>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value),
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const unbindingId = ref<number | null>(null)
|
||||
const bindingList = ref<EntryDetailBinding[]>([])
|
||||
|
||||
function isApiSuccess(res: any): boolean {
|
||||
return !!(res && (res.code === 200 || res.code === 1 || res.flag === 'success'))
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
bindingList.value = []
|
||||
unbindingId.value = null
|
||||
}
|
||||
|
||||
function parseBindingsFromEntryItem(item: EntryDetailBindRow | null | undefined): EntryDetailBinding[] {
|
||||
const bindings = item?.bindings
|
||||
if (!Array.isArray(bindings)) return []
|
||||
return bindings.filter((binding) => {
|
||||
const status = String(binding?.status ?? 'pending').toLowerCase()
|
||||
return status === 'pending' || !binding?.status
|
||||
}) as EntryDetailBinding[]
|
||||
}
|
||||
|
||||
async function loadBindings() {
|
||||
const entryItemId = Number(props.entryItem?.id)
|
||||
if (!Number.isFinite(entryItemId) || entryItemId <= 0) {
|
||||
bindingList.value = []
|
||||
ElMessage.warning('入库明细 ID 无效')
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const entryOrderId = Number(props.entryOrderId)
|
||||
if (Number.isFinite(entryOrderId) && entryOrderId > 0) {
|
||||
const res = await getEntryDetail({ id: entryOrderId })
|
||||
if (!isApiSuccess(res) || !res.data?.entryOrder) {
|
||||
bindingList.value = parseBindingsFromEntryItem(props.entryItem)
|
||||
ElMessage.error(res?.message || '刷新绑定列表失败')
|
||||
return
|
||||
}
|
||||
const matchedItem = (res.data.entryOrder.items || []).find(
|
||||
(item) => Number(item.id) === entryItemId
|
||||
)
|
||||
bindingList.value = parseBindingsFromEntryItem(matchedItem as EntryDetailBindRow)
|
||||
} else {
|
||||
bindingList.value = parseBindingsFromEntryItem(props.entryItem)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('刷新绑定列表失败:', error)
|
||||
bindingList.value = parseBindingsFromEntryItem(props.entryItem)
|
||||
ElMessage.error('刷新绑定列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function unbindBindings(selected: EntryDetailBinding[]) {
|
||||
const entryItemId = Number(props.entryItem?.id)
|
||||
if (!Number.isFinite(entryItemId) || entryItemId <= 0) {
|
||||
ElMessage.warning('入库明细 ID 无效,无法解绑')
|
||||
return false
|
||||
}
|
||||
if (!selected.length) {
|
||||
ElMessage.warning('请选择要解绑的绑定记录')
|
||||
return false
|
||||
}
|
||||
|
||||
const selectedIds = new Set(
|
||||
selected
|
||||
.map((item) => Number(item.id))
|
||||
.filter((id) => Number.isFinite(id) && id > 0)
|
||||
)
|
||||
const remaining = bindingList.value.filter((item) => {
|
||||
const id = Number(item.id)
|
||||
return !selectedIds.has(id)
|
||||
})
|
||||
const unbindQty = selected.reduce(
|
||||
(sum, item) => sum + (Number(item.allocated_quantity) || 0),
|
||||
0
|
||||
)
|
||||
|
||||
if (!remaining.length) {
|
||||
const res = await unbindReceivingDetails({ entry_item_id: entryItemId })
|
||||
if (!isApiSuccess(res)) {
|
||||
ElMessage.error(res?.message || '解绑收货明细失败')
|
||||
return false
|
||||
}
|
||||
const releasedQuantity = res?.released_quantity ?? res?.data?.released_quantity ?? unbindQty
|
||||
ElMessage.success(`解绑成功,已释放 ${releasedQuantity} 件`)
|
||||
} else {
|
||||
const entryOrderId = Number(props.entryOrderId)
|
||||
if (!Number.isFinite(entryOrderId) || entryOrderId <= 0) {
|
||||
ElMessage.warning('入库单 ID 无效,无法解绑')
|
||||
return false
|
||||
}
|
||||
const res = await bindReceivingDetails({
|
||||
entry_order_id: entryOrderId,
|
||||
bindings: remaining.map((item) => ({
|
||||
entry_item_id: entryItemId,
|
||||
receiving_detail_id: Number(item.receiving_detail_id),
|
||||
allocated_quantity: Math.floor(Number(item.allocated_quantity) || 0),
|
||||
})),
|
||||
})
|
||||
if (!isApiSuccess(res)) {
|
||||
ElMessage.error(res?.message || '解绑收货明细失败')
|
||||
return false
|
||||
}
|
||||
ElMessage.success(`解绑成功,已释放 ${unbindQty} 件`)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleUnbindRow(row: EntryDetailBinding) {
|
||||
const entryItemId = Number(props.entryItem?.id)
|
||||
const bindingId = Number(row.id)
|
||||
const allocatedQty = Number(row.allocated_quantity) || 0
|
||||
const itemLabel =
|
||||
props.entryItem?.warehouse_item_name || props.entryItem?.warehouse_item_code || entryItemId
|
||||
const productName = row.receivingDetail?.product_name || `绑定 #${bindingId}`
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定解绑「${itemLabel}」的收货明细「${productName}」(${allocatedQty} 件)?`,
|
||||
'确认解绑',
|
||||
{
|
||||
confirmButtonText: '确定解绑',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
unbindingId.value = bindingId
|
||||
try {
|
||||
const ok = await unbindBindings([row])
|
||||
if (!ok) return
|
||||
emit('success')
|
||||
if (bindingList.value.length <= 1) {
|
||||
visible.value = false
|
||||
return
|
||||
}
|
||||
await loadBindings()
|
||||
} catch (error) {
|
||||
console.error('解绑收货明细失败:', error)
|
||||
ElMessage.error('解绑收货明细失败')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
unbindingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
resetState()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue, props.entryItem?.id, props.entryOrderId] as const,
|
||||
([open]) => {
|
||||
if (!open) return
|
||||
resetState()
|
||||
void loadBindings()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.entry-item-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding: 12px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px;
|
||||
|
||||
.summary-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.toolbar-meta {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -70,6 +70,7 @@
|
||||
v-model="importDialogVisible"
|
||||
:entry-order-id="entryOrderId"
|
||||
:entry-order-code="entryOrderCode"
|
||||
:order-status="entryOrderStatus"
|
||||
:target-item="importTargetItem"
|
||||
:batch-file-mode="batchFileMode"
|
||||
:entry-items="tableData as DirectInboundImportRow[]"
|
||||
@ -82,12 +83,11 @@
|
||||
import { computed, reactive, ref, watch, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as entryApi from '@/api/storage.entry/entry'
|
||||
import {
|
||||
commitDirectInbound,
|
||||
getDirectInboundItems,
|
||||
type DirectInboundItem,
|
||||
} from '@/api/storage.directinbound/directinbound'
|
||||
commit,
|
||||
getEntryDetail,
|
||||
type EntryDetailItem,
|
||||
} from '@/api/storage.entry/entry'
|
||||
import DirectInboundImportDialog, {
|
||||
type DirectInboundImportRow,
|
||||
} from './DirectInboundImportDialog.vue'
|
||||
@ -194,35 +194,25 @@ function unwrapPayload(res: Record<string, unknown> | null | undefined) {
|
||||
return res
|
||||
}
|
||||
|
||||
function mergeDirectInboundFields(
|
||||
items: Record<string, unknown>[],
|
||||
directItems: DirectInboundItem[]
|
||||
) {
|
||||
const directMap = new Map<number, DirectInboundItem>()
|
||||
directItems.forEach((item) => {
|
||||
if (item.stock_id != null) {
|
||||
directMap.set(Number(item.stock_id), item)
|
||||
}
|
||||
})
|
||||
|
||||
return items.map((item) => {
|
||||
const stockId = item.stock_id != null ? Number(item.stock_id) : NaN
|
||||
const direct = Number.isFinite(stockId) ? directMap.get(stockId) : undefined
|
||||
return {
|
||||
...item,
|
||||
direct_inbound_quantity: direct?.direct_inbound_quantity ?? 0,
|
||||
remaining_quantity: direct?.remaining_quantity ?? item.count ?? 0,
|
||||
pending_total: direct?.pending_binding_total ?? item.pending_total ?? 0,
|
||||
bindings: direct?.bindings ?? item.bindings,
|
||||
}
|
||||
})
|
||||
function buildDirectSummary(items: EntryDetailItem[]) {
|
||||
let totalPlanned = 0
|
||||
let totalDirectInbound = 0
|
||||
for (const item of items) {
|
||||
totalPlanned += Number(item.count) || 0
|
||||
totalDirectInbound += Number(item.direct_inbound_quantity) || 0
|
||||
}
|
||||
return {
|
||||
total_items: items.length,
|
||||
total_planned: totalPlanned,
|
||||
total_direct_inbound: totalDirectInbound,
|
||||
}
|
||||
}
|
||||
|
||||
async function loadEntryDetail() {
|
||||
if (!props.id) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await entryApi.getEntryDetail({ id: Number(props.id) })
|
||||
const res = await getEntryDetail({ id: Number(props.id) })
|
||||
|
||||
if (res && res.code === 200 && res.data?.entryOrder) {
|
||||
const entryOrder = res.data.entryOrder
|
||||
@ -230,13 +220,16 @@ async function loadEntryDetail() {
|
||||
entryOrderCode.value = entryOrder.entry_order_code || ''
|
||||
const items = entryOrder.items || []
|
||||
|
||||
tableData.value = items.map((item: Record<string, unknown>) => ({
|
||||
tableData.value = items.map((item: EntryDetailItem) => ({
|
||||
...item,
|
||||
direct_inbound_quantity: item.direct_inbound_quantity ?? 0,
|
||||
remaining_quantity: item.remaining_quantity ?? item.count ?? 0,
|
||||
entry_order_code: entryOrder.entry_order_code || '',
|
||||
purchase_order_code: entryOrder.purchase_order_code || '',
|
||||
store_name: entryOrder.store_name || '',
|
||||
}))
|
||||
|
||||
directSummary.value = buildDirectSummary(items)
|
||||
pagination.total = tableData.value.length
|
||||
} else {
|
||||
throw new Error(res?.message || '接口返回数据异常')
|
||||
@ -248,39 +241,14 @@ async function loadEntryDetail() {
|
||||
pagination.total = 0
|
||||
entryOrderStatus.value = ''
|
||||
entryOrderCode.value = ''
|
||||
directSummary.value = {}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDirectInboundMeta() {
|
||||
const code = entryOrderCode.value || (props.row?.entry_order_code ? String(props.row.entry_order_code) : '')
|
||||
if (!code) {
|
||||
directSummary.value = {}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await getDirectInboundItems({ entry_order_code: code })
|
||||
if (res?.code !== 200 && res?.code !== undefined) {
|
||||
throw new Error(res?.message || '获取导入入库信息失败')
|
||||
}
|
||||
|
||||
const payload = unwrapPayload(res as Record<string, unknown>)
|
||||
const directItems = Array.isArray(payload?.items) ? (payload.items as DirectInboundItem[]) : []
|
||||
directSummary.value = (payload?.summary as Record<string, unknown>) || {}
|
||||
|
||||
if (tableData.value.length) {
|
||||
tableData.value = mergeDirectInboundFields(tableData.value, directItems)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取导入入库信息失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadAll() {
|
||||
await loadEntryDetail()
|
||||
await loadDirectInboundMeta()
|
||||
}
|
||||
|
||||
function canImportRow(row: DirectInboundImportRow) {
|
||||
@ -318,9 +286,10 @@ async function handleImportSuccess() {
|
||||
}
|
||||
|
||||
async function handleCommit() {
|
||||
const id = entryOrderId.value
|
||||
const code = entryOrderCode.value
|
||||
if (!code) {
|
||||
ElMessage.warning('缺少入库单号')
|
||||
if (!id) {
|
||||
ElMessage.warning('缺少入库单 ID')
|
||||
return
|
||||
}
|
||||
if (!canDirectInbound.value) {
|
||||
@ -330,7 +299,7 @@ async function handleCommit() {
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认提交并完成入库单「${code}」的导入/PDA 入库?提交后将写入库存并更新入库单状态为已完成。`,
|
||||
`确认提交并完成入库单「${code || id}」的导入/PDA 入库?提交后将写入库存并更新入库单状态为已完成。`,
|
||||
'提交完成入库',
|
||||
{ type: 'warning', confirmButtonText: '确认提交', cancelButtonText: '取消' }
|
||||
)
|
||||
@ -340,7 +309,7 @@ async function handleCommit() {
|
||||
|
||||
commitLoading.value = true
|
||||
try {
|
||||
const res = await commitDirectInbound({ entry_order_code: code })
|
||||
const res = await commit({ entry_order_id: id })
|
||||
if (res?.code !== 200 && res?.code !== undefined) {
|
||||
throw new Error(res?.message || '提交完成入库失败')
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user