5月19
This commit is contained in:
parent
207a21e272
commit
3531a7893d
@ -52,7 +52,7 @@ export function matchPutaway(data: {
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
// 非本项目接口,不使用
|
||||
/** 按库位+商品维度移库(合并模式);quantity 必填 */
|
||||
export function transferByProduct(data: {
|
||||
space_id: number
|
||||
stock_id: number
|
||||
@ -71,8 +71,12 @@ export function transferByProduct(data: {
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
// 非本项目接口,不使用
|
||||
export function transferLocation(data:any) {
|
||||
/** 按单条 wms_storage 记录移库;quantity 可选,不传则全量 */
|
||||
export function transferLocation(data: {
|
||||
storage_id: number
|
||||
target_space_id: number
|
||||
quantity?: number
|
||||
}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
|
||||
@ -906,7 +906,8 @@ import WaveStrategyQuickScanProgressDialog from './component/WaveStrategyQuickSc
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import {
|
||||
settingWarehouseGetSettings as getWarehouseSettings,
|
||||
unwrapSettingWarehousePayload
|
||||
unwrapSettingWarehousePayload,
|
||||
type SettingWarehouseSettingsPayload
|
||||
} from '@/api/setting.warehouse/settingwarehouse'
|
||||
import {
|
||||
orderWaveBatchAllocateExpress,
|
||||
@ -1450,7 +1451,9 @@ async function loadWarehouseSettings() {
|
||||
if (!res || !okCode(res.code)) {
|
||||
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)
|
||||
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
||||
} catch (error) {
|
||||
|
||||
@ -487,7 +487,8 @@ import WaveFetchTaskProgressDialog from './component/WaveFetchTaskProgressDialog
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import {
|
||||
settingWarehouseGetSettings as getWarehouseSettings,
|
||||
unwrapSettingWarehousePayload
|
||||
unwrapSettingWarehousePayload,
|
||||
type SettingWarehouseSettingsPayload
|
||||
} from '@/api/setting.warehouse/settingwarehouse'
|
||||
import {
|
||||
orderWaveBatchAllocateExpress,
|
||||
@ -865,7 +866,9 @@ async function loadWarehouseSettings() {
|
||||
if (!res || !okCode(res.code)) {
|
||||
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)
|
||||
waveMaxOrderLimit.value = Number.isFinite(maxWaveQuantity) && maxWaveQuantity > 0 ? maxWaveQuantity : null
|
||||
} 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) => {
|
||||
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) {
|
||||
// 将厘米转换为米计算体积
|
||||
const volume = (length / 100) * (width / 100) * (height / 100)
|
||||
return parseFloat(volume.toFixed(2))
|
||||
return parseFloat(volume.toFixed(6))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function calculateVolume() {
|
||||
formData.volume = totalVolume(formData.length, formData.width, formData.height)
|
||||
formData.volume = calcVolumeCm3(formData.length, formData.width, formData.height)
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
@ -1,23 +1,71 @@
|
||||
<template>
|
||||
<div class="panel-stock-detail">
|
||||
<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 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>
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" title="移库" width="480px" align-center>
|
||||
<div style="display:flex;flex-direction:column;gap:8px;">
|
||||
<el-input v-model="targetSpace" placeholder="目标库位 ID,扫码或输入" clearable />
|
||||
<div style="min-height:22px;margin-top:4px;">
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
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-else-if="targetSpace && targetSpaceError" style="color:#f56c6c">未找到库位</span>
|
||||
<span v-else-if="targetSpace && targetSpaceError" class="target-space-error">未找到库位</span>
|
||||
</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>
|
||||
<template #footer>
|
||||
<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>
|
||||
</el-dialog>
|
||||
<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 warehouseApi from '@/api/warehouse/warehouse'
|
||||
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<{
|
||||
id: string | number
|
||||
@ -53,16 +103,18 @@ const loading = ref(false)
|
||||
const detailList = ref<any[]>([])
|
||||
const currentRow = ref<any>(null)
|
||||
const dialogVisible = ref(false)
|
||||
const transferMode = ref<TransferMode | null>(null)
|
||||
const targetSpace = ref<string | number>('')
|
||||
const spaceName = ref<string>('')
|
||||
const targetSpaceError = ref<string>('')
|
||||
let spaceInfoTimer: any = null
|
||||
let spaceInfoTimer: ReturnType<typeof setTimeout> | null = null
|
||||
const transferQty = ref<number | null>(null)
|
||||
const transferLoading = ref(false)
|
||||
|
||||
const detailColumns = computed(() => {
|
||||
if (props.groupByBatch) {
|
||||
return [
|
||||
{ prop: 'storage_id', label: '库存记录ID', width: '110' },
|
||||
{ prop: 'stock_id', label: '商品ID', width: '100' },
|
||||
{ prop: 'item_code', label: '商品编码', width: '140' },
|
||||
{ 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) {
|
||||
if (!r) return null
|
||||
const row = { ...r }
|
||||
@ -109,90 +199,133 @@ const loadData = () => {
|
||||
}, 120)
|
||||
}
|
||||
|
||||
const showTransferBtn = computed(() => {
|
||||
const row = currentRow.value || props.row || {}
|
||||
const stock = row.stock || {}
|
||||
console.log(stock, 'stock info for transfer button visibility')
|
||||
const flag = stock?.is_batch_mgmt_enabled
|
||||
const isBatchMgmt = (function (v: any) {
|
||||
if (v === true || v === 1) return true
|
||||
if (v === false || v === 0) return false
|
||||
const s = String(v || '').toLowerCase()
|
||||
return s === 'y' || s === '1' || s === 'true'
|
||||
})(flag)
|
||||
|
||||
const batchCount = Number(row.batch_count || 0)
|
||||
if (isBatchMgmt && batchCount > 1) return false
|
||||
return true
|
||||
})
|
||||
|
||||
function handleTransfer() {
|
||||
function openTransferDialog(mode: TransferMode) {
|
||||
if (mode === 'location' && !canTransferByLocation.value) {
|
||||
ElMessage.warning('当前记录缺少库存记录 ID,请开启「按批次查询」后选择明细行')
|
||||
return
|
||||
}
|
||||
if (mode === 'product' && !canTransferByProduct.value) {
|
||||
ElMessage.warning('当前记录不支持按商品移库(需有库位与商品,且非多批次管理商品)')
|
||||
return
|
||||
}
|
||||
transferMode.value = mode
|
||||
targetSpace.value = ''
|
||||
transferQty.value = null
|
||||
spaceName.value = ''
|
||||
targetSpaceError.value = ''
|
||||
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() {
|
||||
if (!transferMode.value) return
|
||||
if (!targetSpace.value) {
|
||||
ElMessage.warning('请输入或扫码目标库位ID')
|
||||
ElMessage.warning('请输入或扫码目标库位')
|
||||
return
|
||||
}
|
||||
const row = currentRow.value || props.row || {}
|
||||
const row = activeRow.value
|
||||
transferLoading.value = true
|
||||
try {
|
||||
// target_space_id 统一取 index.searchSpace 返回的首项 id
|
||||
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) {}
|
||||
|
||||
const targetSpaceId = await resolveTargetSpaceId()
|
||||
if (!targetSpaceId) {
|
||||
ElMessage.warning('未找到目标库位,请检查输入后重试')
|
||||
transferLoading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
// validate transferQty if provided
|
||||
if (transferQty.value !== null && transferQty.value !== undefined && String(transferQty.value).trim() !== '') {
|
||||
const q = Number(transferQty.value)
|
||||
if (isNaN(q) || q <= 0) {
|
||||
ElMessage.warning('移库数量必须为正数')
|
||||
transferLoading.value = false
|
||||
return
|
||||
}
|
||||
transferQty.value = q
|
||||
let ok = false
|
||||
if (transferMode.value === 'location') {
|
||||
ok = await confirmTransferLocation(row, targetSpaceId)
|
||||
} else {
|
||||
ok = await confirmTransferByProduct(row, targetSpaceId)
|
||||
}
|
||||
|
||||
// 优先使用 storage_id 精确移库
|
||||
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 || '移库成功')
|
||||
}
|
||||
if (!ok) return
|
||||
|
||||
dialogVisible.value = false
|
||||
// 触发父组件刷新(父组件在使用时绑定了 @refresh)
|
||||
emit('refresh')
|
||||
// 保留全局事件兼容旧逻辑
|
||||
try {
|
||||
// @ts-ignore
|
||||
const ev = new CustomEvent('transfer-success')
|
||||
window.dispatchEvent(ev)
|
||||
} catch (e) {}
|
||||
window.dispatchEvent(new CustomEvent('transfer-success'))
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error('移库失败', e)
|
||||
ElMessage.error(e?.message || '移库失败')
|
||||
@ -214,17 +347,13 @@ watch(targetSpace, (val) => {
|
||||
const id = Number(v)
|
||||
let res: any = null
|
||||
try {
|
||||
// prefer index.searchSpace which supports code/keyword search
|
||||
res = await indexApi.searchSpace({ keyword: v })
|
||||
} catch (e) {
|
||||
// fallback to warehouse.getSpaceInfo by id if searchSpace fails
|
||||
if (!isNaN(id)) res = await warehouseApi.getSpaceInfo(id)
|
||||
} catch {
|
||||
if (!Number.isNaN(id)) res = await warehouseApi.getSpaceInfo(id)
|
||||
}
|
||||
|
||||
// normalize various possible response shapes
|
||||
const data = res && (res.data || res.list || res)
|
||||
if (data) {
|
||||
// if list/array, take first
|
||||
const item = Array.isArray(data) ? (data[0] || null) : data
|
||||
if (item) {
|
||||
spaceName.value = item.custom_name || item.space_code || item.name || ''
|
||||
@ -258,5 +387,35 @@ watch(targetSpace, (val) => {
|
||||
flex: 1;
|
||||
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
|
||||
stock: item.stock || null,
|
||||
space: item.space || null,
|
||||
storage_id: item.storage_id || item.id || null,
|
||||
space_id: item.space_id || null,
|
||||
// transferLocation 需 wms_storage 主键:接口显式 storage_id,或按批次明细模式下的 id
|
||||
storage_id: item.storage_id ?? (groupByBatch.value ? item.id : null),
|
||||
space_id: item.space_id ?? item.space?.id ?? null,
|
||||
__raw: item
|
||||
}
|
||||
})
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
||||
import type { ExpressInterfaceCreateParams } from '@/api/setting.expressinterface/expressInterface'
|
||||
|
||||
export const expressInterfaceFieldLabels: Record<string, string> = {
|
||||
id: 'ID',
|
||||
@ -467,8 +468,10 @@ function omitOptionalNumber(val: unknown): number | undefined {
|
||||
}
|
||||
|
||||
/** setting.expressInterface.create 请求体(禁止 warehouse_id / express_platform_id) */
|
||||
export function buildExpressInterfaceCreatePayload(form: Record<string, any>) {
|
||||
const payload: Record<string, any> = {
|
||||
export function buildExpressInterfaceCreatePayload(
|
||||
form: Record<string, any>
|
||||
): ExpressInterfaceCreateParams {
|
||||
const payload: ExpressInterfaceCreateParams = {
|
||||
name: String(form.name || '').trim(),
|
||||
express_code: String(form.express_code || '').trim(),
|
||||
platform_code: String(form.platform_code || '').trim()
|
||||
@ -508,9 +511,11 @@ export function buildExpressInterfaceCreatePayload(form: Record<string, any>) {
|
||||
}
|
||||
|
||||
/** setting.expressInterface.update 请求体 */
|
||||
export function buildExpressInterfaceUpdatePayload(form: Record<string, any>) {
|
||||
const payload = buildExpressInterfaceCreatePayload(form)
|
||||
payload.id = form.id
|
||||
export function buildExpressInterfaceUpdatePayload(form: Record<string, any>): Record<string, any> {
|
||||
const payload: Record<string, any> = {
|
||||
...buildExpressInterfaceCreatePayload(form),
|
||||
id: form.id
|
||||
}
|
||||
const expressPlatformId = omitOptionalNumber(form.express_platform_id)
|
||||
if (expressPlatformId !== undefined) payload.express_platform_id = expressPlatformId
|
||||
return payload
|
||||
|
||||
@ -738,14 +738,10 @@ async function submitForm() {
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
const payload =
|
||||
dialogMode.value === 'create'
|
||||
? buildExpressInterfaceCreatePayload(formData)
|
||||
: buildExpressInterfaceUpdatePayload(formData)
|
||||
const res: any =
|
||||
dialogMode.value === 'create'
|
||||
? await expressInterfaceCreate(payload)
|
||||
: await expressInterfaceUpdate(payload)
|
||||
? await expressInterfaceCreate(buildExpressInterfaceCreatePayload(formData))
|
||||
: await expressInterfaceUpdate(buildExpressInterfaceUpdatePayload(formData))
|
||||
if (!isSuccess(res)) {
|
||||
ElMessage.error(res?.message || '保存失败')
|
||||
return
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -8,31 +8,31 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"method": "index.getExpressList",
|
||||
"method": "storage.inventory.quickPutaway",
|
||||
"body": {}
|
||||
},
|
||||
{
|
||||
"method": "setting.express.list",
|
||||
"method": "storage.inventory.matchPutaway",
|
||||
"body": {}
|
||||
},
|
||||
{
|
||||
"method": "setting.express.listBase",
|
||||
"method": "storage.inventory.transferLocation",
|
||||
"body": {}
|
||||
},
|
||||
{
|
||||
"method": "setting.express.create",
|
||||
"method": "storage.inventory.transferByProduct",
|
||||
"body": {}
|
||||
},
|
||||
{
|
||||
"method": "setting.express.checkCodeUnique",
|
||||
"method": "storage.inventory.list",
|
||||
"body": {}
|
||||
},
|
||||
{
|
||||
"method": "setting.express.update",
|
||||
"method": "storage.expiry.list",
|
||||
"body": {}
|
||||
},
|
||||
{
|
||||
"method": "setting.express.delete",
|
||||
"method": "storage.transaction.list",
|
||||
"body": {}
|
||||
}
|
||||
],
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user