5月19
This commit is contained in:
parent
207a21e272
commit
3531a7893d
@ -52,7 +52,7 @@ export function matchPutaway(data: {
|
|||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
// 非本项目接口,不使用
|
/** 按库位+商品维度移库(合并模式);quantity 必填 */
|
||||||
export function transferByProduct(data: {
|
export function transferByProduct(data: {
|
||||||
space_id: number
|
space_id: number
|
||||||
stock_id: number
|
stock_id: number
|
||||||
@ -71,8 +71,12 @@ export function transferByProduct(data: {
|
|||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
// 非本项目接口,不使用
|
/** 按单条 wms_storage 记录移库;quantity 可选,不传则全量 */
|
||||||
export function transferLocation(data:any) {
|
export function transferLocation(data: {
|
||||||
|
storage_id: number
|
||||||
|
target_space_id: number
|
||||||
|
quantity?: number
|
||||||
|
}): Promise<any> {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
@ -906,7 +906,8 @@ import WaveStrategyQuickScanProgressDialog from './component/WaveStrategyQuickSc
|
|||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import {
|
import {
|
||||||
settingWarehouseGetSettings as getWarehouseSettings,
|
settingWarehouseGetSettings as getWarehouseSettings,
|
||||||
unwrapSettingWarehousePayload
|
unwrapSettingWarehousePayload,
|
||||||
|
type SettingWarehouseSettingsPayload
|
||||||
} from '@/api/setting.warehouse/settingwarehouse'
|
} from '@/api/setting.warehouse/settingwarehouse'
|
||||||
import {
|
import {
|
||||||
orderWaveBatchAllocateExpress,
|
orderWaveBatchAllocateExpress,
|
||||||
@ -1450,7 +1451,9 @@ async function loadWarehouseSettings() {
|
|||||||
if (!res || !okCode(res.code)) {
|
if (!res || !okCode(res.code)) {
|
||||||
throw new Error(res?.message || '获取仓库配置失败')
|
throw new Error(res?.message || '获取仓库配置失败')
|
||||||
}
|
}
|
||||||
const payload = unwrapSettingWarehousePayload(res as Record<string, unknown>)
|
const payload = unwrapSettingWarehousePayload(
|
||||||
|
res as Record<string, unknown>
|
||||||
|
) as SettingWarehouseSettingsPayload
|
||||||
const maxWaveQuantity = Number(payload?.subject_config?.max_wave_quantity)
|
const maxWaveQuantity = Number(payload?.subject_config?.max_wave_quantity)
|
||||||
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -487,7 +487,8 @@ import WaveFetchTaskProgressDialog from './component/WaveFetchTaskProgressDialog
|
|||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import {
|
import {
|
||||||
settingWarehouseGetSettings as getWarehouseSettings,
|
settingWarehouseGetSettings as getWarehouseSettings,
|
||||||
unwrapSettingWarehousePayload
|
unwrapSettingWarehousePayload,
|
||||||
|
type SettingWarehouseSettingsPayload
|
||||||
} from '@/api/setting.warehouse/settingwarehouse'
|
} from '@/api/setting.warehouse/settingwarehouse'
|
||||||
import {
|
import {
|
||||||
orderWaveBatchAllocateExpress,
|
orderWaveBatchAllocateExpress,
|
||||||
@ -865,7 +866,9 @@ async function loadWarehouseSettings() {
|
|||||||
if (!res || !okCode(res.code)) {
|
if (!res || !okCode(res.code)) {
|
||||||
throw new Error(res?.message || '获取仓库配置失败')
|
throw new Error(res?.message || '获取仓库配置失败')
|
||||||
}
|
}
|
||||||
const payload = unwrapSettingWarehousePayload(res as Record<string, unknown>)
|
const payload = unwrapSettingWarehousePayload(
|
||||||
|
res as Record<string, unknown>
|
||||||
|
) as SettingWarehouseSettingsPayload
|
||||||
const maxWaveQuantity = Number(payload?.subject_config?.max_wave_quantity)
|
const maxWaveQuantity = Number(payload?.subject_config?.max_wave_quantity)
|
||||||
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -716,15 +716,6 @@ watch(() => props.id, (newVal) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 体积计算相关监听
|
|
||||||
watch([() => formData.length, () => formData.width, () => formData.height], () => {
|
|
||||||
formData.volume = totalVolume(formData.length, formData.width, formData.height)
|
|
||||||
})
|
|
||||||
|
|
||||||
watch([() => formData.box_length, () => formData.box_width, () => formData.box_height], () => {
|
|
||||||
formData.box_volume = totalVolume(formData.box_length, formData.box_width, formData.box_height)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 管理标识监听
|
// 管理标识监听
|
||||||
watch(() => formData.managementFlags, (newFlags) => {
|
watch(() => formData.managementFlags, (newFlags) => {
|
||||||
if (newFlags) {
|
if (newFlags) {
|
||||||
@ -802,21 +793,29 @@ function normalizeStockInfoFormNumbers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function totalVolume(length: number, width: number, height: number) {
|
/** 商品体积(cm³):长×宽×高,尺寸单位为 cm */
|
||||||
|
function calcVolumeCm3(length: number, width: number, height: number) {
|
||||||
|
if (length && width && height) {
|
||||||
|
return Math.round(length * width * height)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 箱体积(m³):尺寸 cm 换算为米后相乘 */
|
||||||
|
function calcBoxVolumeM3(length: number, width: number, height: number) {
|
||||||
if (length && width && height) {
|
if (length && width && height) {
|
||||||
// 将厘米转换为米计算体积
|
|
||||||
const volume = (length / 100) * (width / 100) * (height / 100)
|
const volume = (length / 100) * (width / 100) * (height / 100)
|
||||||
return parseFloat(volume.toFixed(2))
|
return parseFloat(volume.toFixed(6))
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateVolume() {
|
function calculateVolume() {
|
||||||
formData.volume = totalVolume(formData.length, formData.width, formData.height)
|
formData.volume = calcVolumeCm3(formData.length, formData.width, formData.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateBoxVolume() {
|
function calculateBoxVolume() {
|
||||||
formData.box_volume = totalVolume(formData.box_length, formData.box_width, formData.box_height)
|
formData.box_volume = calcBoxVolumeM3(formData.box_length, formData.box_width, formData.box_height)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateManagementFlags() {
|
function updateManagementFlags() {
|
||||||
|
|||||||
@ -1,23 +1,71 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel-stock-detail">
|
<div class="panel-stock-detail">
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<div class="panel-actions" style="padding-bottom:8px;">
|
<div class="panel-actions">
|
||||||
<el-button-group class="toolbar-btn-group">
|
<el-button-group class="toolbar-btn-group">
|
||||||
<el-button size="small" type="primary" @click="handleTransfer" v-if="showTransferBtn">移库</el-button>
|
<el-tooltip
|
||||||
|
content="需按批次查询且选中单条库存记录(含 storage_id)"
|
||||||
|
:disabled="canTransferByLocation"
|
||||||
|
>
|
||||||
|
<span class="transfer-btn-wrap">
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:disabled="!canTransferByLocation"
|
||||||
|
@click="openTransferDialog('location')"
|
||||||
|
>
|
||||||
|
按库存记录移库
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip
|
||||||
|
content="不适用于开启批次管理且多批次的商品;合并模式下按库位+商品移库"
|
||||||
|
:disabled="canTransferByProduct"
|
||||||
|
>
|
||||||
|
<span class="transfer-btn-wrap">
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="success"
|
||||||
|
:disabled="!canTransferByProduct"
|
||||||
|
@click="openTransferDialog('product')"
|
||||||
|
>
|
||||||
|
按商品移库
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</el-tooltip>
|
||||||
</el-button-group>
|
</el-button-group>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog v-model="dialogVisible" title="移库" width="480px" align-center>
|
<el-dialog
|
||||||
<div style="display:flex;flex-direction:column;gap:8px;">
|
v-model="dialogVisible"
|
||||||
<el-input v-model="targetSpace" placeholder="目标库位 ID,扫码或输入" clearable />
|
:title="dialogTitle"
|
||||||
<div style="min-height:22px;margin-top:4px;">
|
width="480px"
|
||||||
|
align-center
|
||||||
|
@closed="resetTransferDialog"
|
||||||
|
>
|
||||||
|
<p v-if="transferMode === 'location'" class="transfer-hint">
|
||||||
|
单条 wms_storage 记录移库;移库数量不填则全量移库。
|
||||||
|
</p>
|
||||||
|
<p v-else-if="transferMode === 'product'" class="transfer-hint">
|
||||||
|
按原库位 + 商品合并移库,自动合并该库位下该商品的所有库存;不适用于开启批次管理且多批次的商品。
|
||||||
|
</p>
|
||||||
|
<div class="transfer-form">
|
||||||
|
<el-input v-model="targetSpace" placeholder="目标库位编码或 ID,扫码或输入" clearable />
|
||||||
|
<div class="target-space-tip">
|
||||||
<span v-if="spaceName">目标库位名称: {{ spaceName }}</span>
|
<span v-if="spaceName">目标库位名称: {{ spaceName }}</span>
|
||||||
<span v-else-if="targetSpace && targetSpaceError" style="color:#f56c6c">未找到库位</span>
|
<span v-else-if="targetSpace && targetSpaceError" class="target-space-error">未找到库位</span>
|
||||||
</div>
|
</div>
|
||||||
<el-input-number v-model="transferQty" :min="1" placeholder="移库数量(不填则全量移库)" style="width:200px;" />
|
<el-input-number
|
||||||
|
v-model="transferQty"
|
||||||
|
:min="1"
|
||||||
|
:placeholder="transferMode === 'product' ? '移库数量(必填)' : '移库数量(不填则全量移库)'"
|
||||||
|
style="width: 100%;"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="dialogVisible = false">取消</el-button>
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
<el-button type="primary" :loading="transferLoading" @click="confirmTransfer">确认移库</el-button>
|
<el-button type="primary" :loading="transferLoading" @click="confirmTransfer">
|
||||||
|
{{ confirmButtonText }}
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-table :data="detailList" border stripe size="small" v-loading="loading">
|
<el-table :data="detailList" border stripe size="small" v-loading="loading">
|
||||||
@ -39,7 +87,9 @@ import { computed, ref, watch } from 'vue'
|
|||||||
import * as inventoryApi from '@/api/storage.inventory/inventory'
|
import * as inventoryApi from '@/api/storage.inventory/inventory'
|
||||||
import * as warehouseApi from '@/api/warehouse/warehouse'
|
import * as warehouseApi from '@/api/warehouse/warehouse'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
|
type TransferMode = 'location' | 'product'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
id: string | number
|
id: string | number
|
||||||
@ -53,16 +103,18 @@ const loading = ref(false)
|
|||||||
const detailList = ref<any[]>([])
|
const detailList = ref<any[]>([])
|
||||||
const currentRow = ref<any>(null)
|
const currentRow = ref<any>(null)
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
|
const transferMode = ref<TransferMode | null>(null)
|
||||||
const targetSpace = ref<string | number>('')
|
const targetSpace = ref<string | number>('')
|
||||||
const spaceName = ref<string>('')
|
const spaceName = ref<string>('')
|
||||||
const targetSpaceError = ref<string>('')
|
const targetSpaceError = ref<string>('')
|
||||||
let spaceInfoTimer: any = null
|
let spaceInfoTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
const transferQty = ref<number | null>(null)
|
const transferQty = ref<number | null>(null)
|
||||||
const transferLoading = ref(false)
|
const transferLoading = ref(false)
|
||||||
|
|
||||||
const detailColumns = computed(() => {
|
const detailColumns = computed(() => {
|
||||||
if (props.groupByBatch) {
|
if (props.groupByBatch) {
|
||||||
return [
|
return [
|
||||||
|
{ prop: 'storage_id', label: '库存记录ID', width: '110' },
|
||||||
{ prop: 'stock_id', label: '商品ID', width: '100' },
|
{ prop: 'stock_id', label: '商品ID', width: '100' },
|
||||||
{ prop: 'item_code', label: '商品编码', width: '140' },
|
{ prop: 'item_code', label: '商品编码', width: '140' },
|
||||||
{ prop: 'item_name', label: '商品名称', width: '200' },
|
{ prop: 'item_name', label: '商品名称', width: '200' },
|
||||||
@ -89,6 +141,44 @@ const detailColumns = computed(() => {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
if (transferMode.value === 'location') return '按库存记录移库'
|
||||||
|
if (transferMode.value === 'product') return '按商品移库'
|
||||||
|
return '移库'
|
||||||
|
})
|
||||||
|
|
||||||
|
const confirmButtonText = computed(() => {
|
||||||
|
if (transferMode.value === 'location') return '确认按库存记录移库'
|
||||||
|
if (transferMode.value === 'product') return '确认按商品移库'
|
||||||
|
return '确认移库'
|
||||||
|
})
|
||||||
|
|
||||||
|
function isBatchMgmtEnabled(row: any) {
|
||||||
|
const flag = row?.stock?.is_batch_mgmt_enabled ?? row?.is_batch_mgmt_enabled
|
||||||
|
if (flag === true || flag === 1) return true
|
||||||
|
if (flag === false || flag === 0) return false
|
||||||
|
const s = String(flag || '').toLowerCase()
|
||||||
|
return s === 'y' || s === '1' || s === 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeRow = computed(() => currentRow.value || props.row || {})
|
||||||
|
|
||||||
|
const canTransferByLocation = computed(() => {
|
||||||
|
const row = activeRow.value
|
||||||
|
const storageId = Number(row.storage_id)
|
||||||
|
return Number.isFinite(storageId) && storageId > 0
|
||||||
|
})
|
||||||
|
|
||||||
|
const canTransferByProduct = computed(() => {
|
||||||
|
const row = activeRow.value
|
||||||
|
const spaceId = Number(row.space_id)
|
||||||
|
const stockId = Number(row.stock_id)
|
||||||
|
if (!Number.isFinite(spaceId) || spaceId <= 0) return false
|
||||||
|
if (!Number.isFinite(stockId) || stockId <= 0) return false
|
||||||
|
if (isBatchMgmtEnabled(row) && Number(row.batch_count || 0) > 1) return false
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
function normalizeRow(r: any) {
|
function normalizeRow(r: any) {
|
||||||
if (!r) return null
|
if (!r) return null
|
||||||
const row = { ...r }
|
const row = { ...r }
|
||||||
@ -109,90 +199,133 @@ const loadData = () => {
|
|||||||
}, 120)
|
}, 120)
|
||||||
}
|
}
|
||||||
|
|
||||||
const showTransferBtn = computed(() => {
|
function openTransferDialog(mode: TransferMode) {
|
||||||
const row = currentRow.value || props.row || {}
|
if (mode === 'location' && !canTransferByLocation.value) {
|
||||||
const stock = row.stock || {}
|
ElMessage.warning('当前记录缺少库存记录 ID,请开启「按批次查询」后选择明细行')
|
||||||
console.log(stock, 'stock info for transfer button visibility')
|
return
|
||||||
const flag = stock?.is_batch_mgmt_enabled
|
}
|
||||||
const isBatchMgmt = (function (v: any) {
|
if (mode === 'product' && !canTransferByProduct.value) {
|
||||||
if (v === true || v === 1) return true
|
ElMessage.warning('当前记录不支持按商品移库(需有库位与商品,且非多批次管理商品)')
|
||||||
if (v === false || v === 0) return false
|
return
|
||||||
const s = String(v || '').toLowerCase()
|
}
|
||||||
return s === 'y' || s === '1' || s === 'true'
|
transferMode.value = mode
|
||||||
})(flag)
|
|
||||||
|
|
||||||
const batchCount = Number(row.batch_count || 0)
|
|
||||||
if (isBatchMgmt && batchCount > 1) return false
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleTransfer() {
|
|
||||||
targetSpace.value = ''
|
targetSpace.value = ''
|
||||||
transferQty.value = null
|
transferQty.value = null
|
||||||
|
spaceName.value = ''
|
||||||
|
targetSpaceError.value = ''
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetTransferDialog() {
|
||||||
|
transferMode.value = null
|
||||||
|
targetSpace.value = ''
|
||||||
|
transferQty.value = null
|
||||||
|
spaceName.value = ''
|
||||||
|
targetSpaceError.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveTargetSpaceId(): Promise<number | null> {
|
||||||
|
const raw = String(targetSpace.value).trim()
|
||||||
|
if (!raw) return null
|
||||||
|
try {
|
||||||
|
const res: any = await indexApi.searchSpace({ keyword: raw })
|
||||||
|
const data = res && (res.data || res.list || res)
|
||||||
|
const item = Array.isArray(data) ? (data[0] || null) : data
|
||||||
|
if (item?.id !== undefined && item?.id !== null) {
|
||||||
|
const parsed = Number(item.id)
|
||||||
|
if (Number.isFinite(parsed) && parsed > 0) return parsed
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseOptionalQuantity(): number | null {
|
||||||
|
if (transferQty.value === null || transferQty.value === undefined) return null
|
||||||
|
if (String(transferQty.value).trim() === '') return null
|
||||||
|
const q = Number(transferQty.value)
|
||||||
|
if (!Number.isFinite(q) || q <= 0) return NaN
|
||||||
|
return q
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseRequiredQuantity(): number | null {
|
||||||
|
const q = parseOptionalQuantity()
|
||||||
|
if (q === null || Number.isNaN(q)) return null
|
||||||
|
return q
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmTransferLocation(row: any, targetSpaceId: number) {
|
||||||
|
const storageId = Number(row.storage_id)
|
||||||
|
const payload: { storage_id: number; target_space_id: number; quantity?: number } = {
|
||||||
|
storage_id: storageId,
|
||||||
|
target_space_id: targetSpaceId
|
||||||
|
}
|
||||||
|
const qty = parseOptionalQuantity()
|
||||||
|
if (qty !== null) {
|
||||||
|
if (Number.isNaN(qty)) {
|
||||||
|
ElMessage.warning('移库数量必须为正数')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
payload.quantity = qty
|
||||||
|
}
|
||||||
|
const res: any = await inventoryApi.transferLocation(payload)
|
||||||
|
ElMessage.success(res?.message || '按库存记录移库成功')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmTransferByProduct(row: any, targetSpaceId: number) {
|
||||||
|
const qty = parseRequiredQuantity()
|
||||||
|
if (qty === null) {
|
||||||
|
ElMessage.warning('按商品移库时移库数量为必填')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (Number.isNaN(qty)) {
|
||||||
|
ElMessage.warning('移库数量必须为正数')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
space_id: Number(row.space_id),
|
||||||
|
stock_id: Number(row.stock_id),
|
||||||
|
target_space_id: targetSpaceId,
|
||||||
|
quantity: qty
|
||||||
|
}
|
||||||
|
const res: any = await inventoryApi.transferByProduct(payload)
|
||||||
|
ElMessage.success(res?.message || '按商品移库成功')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
async function confirmTransfer() {
|
async function confirmTransfer() {
|
||||||
|
if (!transferMode.value) return
|
||||||
if (!targetSpace.value) {
|
if (!targetSpace.value) {
|
||||||
ElMessage.warning('请输入或扫码目标库位ID')
|
ElMessage.warning('请输入或扫码目标库位')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const row = currentRow.value || props.row || {}
|
const row = activeRow.value
|
||||||
transferLoading.value = true
|
transferLoading.value = true
|
||||||
try {
|
try {
|
||||||
// target_space_id 统一取 index.searchSpace 返回的首项 id
|
const targetSpaceId = await resolveTargetSpaceId()
|
||||||
const raw = String(targetSpace.value).trim()
|
|
||||||
let targetSpaceId: number | null = null
|
|
||||||
try {
|
|
||||||
const res: any = await indexApi.searchSpace({ keyword: raw })
|
|
||||||
const data = res && (res.data || res.list || res)
|
|
||||||
const item = Array.isArray(data) ? (data[0] || null) : data
|
|
||||||
if (item?.id !== undefined && item?.id !== null) {
|
|
||||||
const parsed = Number(item.id)
|
|
||||||
if (!isNaN(parsed)) targetSpaceId = parsed
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (!targetSpaceId) {
|
if (!targetSpaceId) {
|
||||||
ElMessage.warning('未找到目标库位,请检查输入后重试')
|
ElMessage.warning('未找到目标库位,请检查输入后重试')
|
||||||
transferLoading.value = false
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate transferQty if provided
|
let ok = false
|
||||||
if (transferQty.value !== null && transferQty.value !== undefined && String(transferQty.value).trim() !== '') {
|
if (transferMode.value === 'location') {
|
||||||
const q = Number(transferQty.value)
|
ok = await confirmTransferLocation(row, targetSpaceId)
|
||||||
if (isNaN(q) || q <= 0) {
|
} else {
|
||||||
ElMessage.warning('移库数量必须为正数')
|
ok = await confirmTransferByProduct(row, targetSpaceId)
|
||||||
transferLoading.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
transferQty.value = q
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 优先使用 storage_id 精确移库
|
if (!ok) return
|
||||||
if (row.storage_id) {
|
|
||||||
const payload: any = { storage_id: row.storage_id, target_space_id: targetSpaceId }
|
|
||||||
if (transferQty.value && Number(transferQty.value) > 0) payload.quantity = Number(transferQty.value)
|
|
||||||
const res: any = await inventoryApi.transferLocation(payload)
|
|
||||||
ElMessage.success(res?.message || '移库成功')
|
|
||||||
} else {
|
|
||||||
// 回退到按商品移库(仅适用于非批次管理场景)
|
|
||||||
const payload: any = { space_id: row.space_id, stock_id: row.stock_id, target_space_id: targetSpaceId }
|
|
||||||
if (transferQty.value && Number(transferQty.value) > 0) payload.quantity = Number(transferQty.value)
|
|
||||||
const res: any = await inventoryApi.transferByProduct(payload)
|
|
||||||
ElMessage.success(res?.message || '移库成功')
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
// 触发父组件刷新(父组件在使用时绑定了 @refresh)
|
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
// 保留全局事件兼容旧逻辑
|
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
window.dispatchEvent(new CustomEvent('transfer-success'))
|
||||||
const ev = new CustomEvent('transfer-success')
|
} catch {
|
||||||
window.dispatchEvent(ev)
|
// ignore
|
||||||
} catch (e) {}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error('移库失败', e)
|
console.error('移库失败', e)
|
||||||
ElMessage.error(e?.message || '移库失败')
|
ElMessage.error(e?.message || '移库失败')
|
||||||
@ -214,17 +347,13 @@ watch(targetSpace, (val) => {
|
|||||||
const id = Number(v)
|
const id = Number(v)
|
||||||
let res: any = null
|
let res: any = null
|
||||||
try {
|
try {
|
||||||
// prefer index.searchSpace which supports code/keyword search
|
|
||||||
res = await indexApi.searchSpace({ keyword: v })
|
res = await indexApi.searchSpace({ keyword: v })
|
||||||
} catch (e) {
|
} catch {
|
||||||
// fallback to warehouse.getSpaceInfo by id if searchSpace fails
|
if (!Number.isNaN(id)) res = await warehouseApi.getSpaceInfo(id)
|
||||||
if (!isNaN(id)) res = await warehouseApi.getSpaceInfo(id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize various possible response shapes
|
|
||||||
const data = res && (res.data || res.list || res)
|
const data = res && (res.data || res.list || res)
|
||||||
if (data) {
|
if (data) {
|
||||||
// if list/array, take first
|
|
||||||
const item = Array.isArray(data) ? (data[0] || null) : data
|
const item = Array.isArray(data) ? (data[0] || null) : data
|
||||||
if (item) {
|
if (item) {
|
||||||
spaceName.value = item.custom_name || item.space_code || item.name || ''
|
spaceName.value = item.custom_name || item.space_code || item.name || ''
|
||||||
@ -258,5 +387,35 @@ watch(targetSpace, (val) => {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.panel-actions {
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transfer-btn-wrap {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transfer-hint {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transfer-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-space-tip {
|
||||||
|
min-height: 22px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-space-error {
|
||||||
|
color: #f56c6c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -300,8 +300,9 @@ async function loadData() {
|
|||||||
// preserve original structures for child components that need full network shape
|
// preserve original structures for child components that need full network shape
|
||||||
stock: item.stock || null,
|
stock: item.stock || null,
|
||||||
space: item.space || null,
|
space: item.space || null,
|
||||||
storage_id: item.storage_id || item.id || null,
|
// transferLocation 需 wms_storage 主键:接口显式 storage_id,或按批次明细模式下的 id
|
||||||
space_id: item.space_id || null,
|
storage_id: item.storage_id ?? (groupByBatch.value ? item.id : null),
|
||||||
|
space_id: item.space_id ?? item.space?.id ?? null,
|
||||||
__raw: item
|
__raw: item
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
||||||
|
import type { ExpressInterfaceCreateParams } from '@/api/setting.expressinterface/expressInterface'
|
||||||
|
|
||||||
export const expressInterfaceFieldLabels: Record<string, string> = {
|
export const expressInterfaceFieldLabels: Record<string, string> = {
|
||||||
id: 'ID',
|
id: 'ID',
|
||||||
@ -467,8 +468,10 @@ function omitOptionalNumber(val: unknown): number | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** setting.expressInterface.create 请求体(禁止 warehouse_id / express_platform_id) */
|
/** setting.expressInterface.create 请求体(禁止 warehouse_id / express_platform_id) */
|
||||||
export function buildExpressInterfaceCreatePayload(form: Record<string, any>) {
|
export function buildExpressInterfaceCreatePayload(
|
||||||
const payload: Record<string, any> = {
|
form: Record<string, any>
|
||||||
|
): ExpressInterfaceCreateParams {
|
||||||
|
const payload: ExpressInterfaceCreateParams = {
|
||||||
name: String(form.name || '').trim(),
|
name: String(form.name || '').trim(),
|
||||||
express_code: String(form.express_code || '').trim(),
|
express_code: String(form.express_code || '').trim(),
|
||||||
platform_code: String(form.platform_code || '').trim()
|
platform_code: String(form.platform_code || '').trim()
|
||||||
@ -508,9 +511,11 @@ export function buildExpressInterfaceCreatePayload(form: Record<string, any>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** setting.expressInterface.update 请求体 */
|
/** setting.expressInterface.update 请求体 */
|
||||||
export function buildExpressInterfaceUpdatePayload(form: Record<string, any>) {
|
export function buildExpressInterfaceUpdatePayload(form: Record<string, any>): Record<string, any> {
|
||||||
const payload = buildExpressInterfaceCreatePayload(form)
|
const payload: Record<string, any> = {
|
||||||
payload.id = form.id
|
...buildExpressInterfaceCreatePayload(form),
|
||||||
|
id: form.id
|
||||||
|
}
|
||||||
const expressPlatformId = omitOptionalNumber(form.express_platform_id)
|
const expressPlatformId = omitOptionalNumber(form.express_platform_id)
|
||||||
if (expressPlatformId !== undefined) payload.express_platform_id = expressPlatformId
|
if (expressPlatformId !== undefined) payload.express_platform_id = expressPlatformId
|
||||||
return payload
|
return payload
|
||||||
|
|||||||
@ -738,14 +738,10 @@ async function submitForm() {
|
|||||||
|
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
const payload =
|
|
||||||
dialogMode.value === 'create'
|
|
||||||
? buildExpressInterfaceCreatePayload(formData)
|
|
||||||
: buildExpressInterfaceUpdatePayload(formData)
|
|
||||||
const res: any =
|
const res: any =
|
||||||
dialogMode.value === 'create'
|
dialogMode.value === 'create'
|
||||||
? await expressInterfaceCreate(payload)
|
? await expressInterfaceCreate(buildExpressInterfaceCreatePayload(formData))
|
||||||
: await expressInterfaceUpdate(payload)
|
: await expressInterfaceUpdate(buildExpressInterfaceUpdatePayload(formData))
|
||||||
if (!isSuccess(res)) {
|
if (!isSuccess(res)) {
|
||||||
ElMessage.error(res?.message || '保存失败')
|
ElMessage.error(res?.message || '保存失败')
|
||||||
return
|
return
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -8,31 +8,31 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "index.getExpressList",
|
"method": "storage.inventory.quickPutaway",
|
||||||
"body": {}
|
"body": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "setting.express.list",
|
"method": "storage.inventory.matchPutaway",
|
||||||
"body": {}
|
"body": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "setting.express.listBase",
|
"method": "storage.inventory.transferLocation",
|
||||||
"body": {}
|
"body": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "setting.express.create",
|
"method": "storage.inventory.transferByProduct",
|
||||||
"body": {}
|
"body": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "setting.express.checkCodeUnique",
|
"method": "storage.inventory.list",
|
||||||
"body": {}
|
"body": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "setting.express.update",
|
"method": "storage.expiry.list",
|
||||||
"body": {}
|
"body": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"method": "setting.express.delete",
|
"method": "storage.transaction.list",
|
||||||
"body": {}
|
"body": {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user