feat: 收货单新增直入库存按钮,快捷入库更名为转入库单
This commit is contained in:
parent
06029b6bb3
commit
2a1efd296f
@ -108,6 +108,36 @@ export function matchPutaway(data: {
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export type DirectPutawayResponse = {
|
||||
entry_order_id?: number
|
||||
entry_order_code?: string
|
||||
order_status?: string
|
||||
receiving_id?: number
|
||||
total_lines?: number
|
||||
total_quantity?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
/** 收货单直入库存(一步完成):将已审核收货单(completed + is_review)未入库明细
|
||||
* 按收货明细库位直接写入 wms_storage,生成 SCRK 入库单(一步置为 COMPLETED),
|
||||
* 明细与收货明细一一对应,不合并。 */
|
||||
export function directPutaway(data: {
|
||||
/** 收货单ID(必填) */
|
||||
receiving_id: number
|
||||
}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.inventory.directPutaway',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
/** 按库位+商品维度移库(合并模式);quantity 必填 */
|
||||
export function transferByProduct(data: {
|
||||
space_id: number
|
||||
|
||||
@ -399,6 +399,7 @@ const activeTab = ref('details')
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const quickPutawayLoading = ref(false)
|
||||
const directPutawayLoading = ref(false)
|
||||
const reviewLoading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
|
||||
@ -436,7 +437,8 @@ const buttonLoadingMap = computed(() => ({
|
||||
loading: loading.value,
|
||||
exportLoading: exportLoading.value,
|
||||
reviewLoading: reviewLoading.value,
|
||||
quickPutawayLoading: quickPutawayLoading.value
|
||||
quickPutawayLoading: quickPutawayLoading.value,
|
||||
directPutawayLoading: directPutawayLoading.value
|
||||
}))
|
||||
|
||||
const buttonDisabledMap = computed(() => ({
|
||||
@ -497,6 +499,9 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
handleQuickPutaway: () => {
|
||||
void handleQuickPutaway()
|
||||
},
|
||||
handleDirectPutaway: () => {
|
||||
void handleDirectPutaway()
|
||||
},
|
||||
handleOpenPrintDialog: () => {
|
||||
void handleOpenPrintDialog()
|
||||
}
|
||||
@ -1448,7 +1453,7 @@ function printReceiving() {
|
||||
|
||||
async function handleQuickPutaway() {
|
||||
if (selectionRows.value.length !== 1) {
|
||||
ElMessage.warning('请仅选择一条收货单进行快捷入库')
|
||||
ElMessage.warning('请仅选择一条收货单进行转入库单')
|
||||
return
|
||||
}
|
||||
|
||||
@ -1472,7 +1477,7 @@ async function handleQuickPutaway() {
|
||||
if (errors.length > 0) {
|
||||
ElMessageBox.alert(
|
||||
`<div style="max-height: 300px; overflow: auto;">${errors.join('<br/>')}</div>`,
|
||||
'校验未通过,无法快捷入库',
|
||||
'校验未通过,无法转入库单',
|
||||
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error' }
|
||||
)
|
||||
return
|
||||
@ -1480,8 +1485,8 @@ async function handleQuickPutaway() {
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定对选中的 ${validRows.length} 条收货单执行快捷入库上架吗?`,
|
||||
'快捷入库确认',
|
||||
`确定对选中的 ${validRows.length} 条收货单执行转入库单吗?`,
|
||||
'转入库单确认',
|
||||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
} catch {
|
||||
@ -1510,7 +1515,7 @@ async function handleQuickPutaway() {
|
||||
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error' }
|
||||
)
|
||||
} else {
|
||||
ElMessage.success('选中的收货单已全部快捷入库成功')
|
||||
ElMessage.success('选中的收货单已全部转入库单成功')
|
||||
}
|
||||
loadData()
|
||||
} finally {
|
||||
@ -1518,6 +1523,76 @@ async function handleQuickPutaway() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货单直入库存(一步完成):将已审核(completed + is_review)且未全部入库的收货单
|
||||
* 明细按库位直接写入库位库存,并生成一步完成的 SCRK 入库单。
|
||||
*/
|
||||
async function handleDirectPutaway() {
|
||||
if (selectionRows.value.length !== 1) {
|
||||
ElMessage.warning('请仅选择一条收货单进行收货单直入')
|
||||
return
|
||||
}
|
||||
|
||||
const row = selectionRows.value[0]
|
||||
const errors: string[] = []
|
||||
const isCompleted = (row.status || '').toLowerCase() === 'completed'
|
||||
const isReviewed = row.is_review === 1 || row.is_review === true
|
||||
const hasPendingStorage = (row.storage_status || '') !== 'all'
|
||||
|
||||
if (!isCompleted) {
|
||||
errors.push(`收货单【${row.receiving_number}】未完成(当前状态:${row.status || '未知'})`)
|
||||
} else if (!isReviewed) {
|
||||
errors.push(`收货单【${row.receiving_number}】未审核,不允许直入库存`)
|
||||
} else if (!hasPendingStorage) {
|
||||
errors.push(`收货单【${row.receiving_number}】明细已全部入库,禁止重复直入库存`)
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
ElMessageBox.alert(
|
||||
`<div style="max-height: 300px; overflow: auto;">${errors.join('<br/>')}</div>`,
|
||||
'校验未通过,无法收货单直入',
|
||||
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error' }
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定对收货单「${row.receiving_number}」执行收货单直入吗?未入库明细将按库位直接写入库存并生成入库单。`,
|
||||
'收货单直入确认',
|
||||
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
directPutawayLoading.value = true
|
||||
try {
|
||||
const res: any = await inventoryApi.directPutaway({ receiving_id: row.id })
|
||||
if (res && (res.code === 200 || res.flag === 'success' || res.status === 'success')) {
|
||||
const data = res.data && typeof res.data === 'object' ? res.data : res
|
||||
const entryOrderCode = data?.entry_order_code || ''
|
||||
const totalLines = data?.total_lines ?? ''
|
||||
const totalQuantity = data?.total_quantity ?? ''
|
||||
const detail = [
|
||||
entryOrderCode ? `入库单 ${entryOrderCode}` : '',
|
||||
totalLines !== '' ? `共 ${totalLines} 行` : '',
|
||||
totalQuantity !== '' ? `总数量 ${totalQuantity}` : ''
|
||||
].filter(Boolean).join(',')
|
||||
ElMessage.success(detail ? `收货单直入成功:${detail}` : '收货单直入成功')
|
||||
selectionRows.value = []
|
||||
loadData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || res?.msg || '收货单直入失败')
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error('收货单直入出错:', e)
|
||||
ElMessage.error(e?.message || '收货单直入请求失败')
|
||||
} finally {
|
||||
directPutawayLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function buildExportPayload() {
|
||||
if (currentCondition.value && currentCondition.value !== 'reset') {
|
||||
return { where: normalizeToWhere(currentCondition.value) }
|
||||
|
||||
@ -622,13 +622,22 @@ export const receivingToolbarButtons: ToolbarButtonConfig[] = [
|
||||
},
|
||||
{
|
||||
key: 'quickPutaway',
|
||||
label: '快捷入库',
|
||||
label: '转入库单',
|
||||
category: 'action',
|
||||
size: 'small',
|
||||
disabledKey: 'singleSelectionOnly',
|
||||
loadingKey: 'quickPutawayLoading',
|
||||
action: 'handleQuickPutaway'
|
||||
},
|
||||
{
|
||||
key: 'directPutaway',
|
||||
label: '收货单直入',
|
||||
category: 'action',
|
||||
size: 'small',
|
||||
disabledKey: 'singleSelectionOnly',
|
||||
loadingKey: 'directPutawayLoading',
|
||||
action: 'handleDirectPutaway'
|
||||
},
|
||||
{
|
||||
key: 'print',
|
||||
label: '打印收货单',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user