|
|
|
|
@ -1,39 +1,68 @@
|
|
|
|
|
<template>
|
|
|
|
|
<ContentWrap>
|
|
|
|
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" class="bit-wms-form">
|
|
|
|
|
<el-form-item label="样品" prop="productId">
|
|
|
|
|
<el-select v-model="formData.productId" placeholder="请选择样品" filterable clearable class="!w-full">
|
|
|
|
|
<el-option v-for="item in sampleList" :key="item.id" :label="formatSampleLabel(item)" :value="item.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="来源仓库" prop="fromWarehouseId">
|
|
|
|
|
<el-select v-model="formData.fromWarehouseId" placeholder="请选择来源仓库" filterable class="!w-full" @change="handleFromWarehouseChange">
|
|
|
|
|
<el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
<el-form-item label="样品" prop="productId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.productId"
|
|
|
|
|
placeholder="请选择样品"
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-full"
|
|
|
|
|
@change="loadCurrentStock"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in sampleList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="formatSampleLabel(item)"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="来源库区" prop="fromAreaId">
|
|
|
|
|
<el-select v-model="formData.fromAreaId" placeholder="请选择来源库区" filterable clearable class="!w-full">
|
|
|
|
|
<el-option v-for="item in fromAreaList" :key="item.id" :label="item.areaName" :value="item.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-form-item label="来源库存">
|
|
|
|
|
<el-input :model-value="currentStockText" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="目标仓库" prop="toWarehouseId">
|
|
|
|
|
<el-select v-model="formData.toWarehouseId" placeholder="请选择目标仓库" filterable class="!w-full" @change="handleToWarehouseChange">
|
|
|
|
|
<el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
<el-form-item label="来源库位" prop="fromLocationId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.fromLocationId"
|
|
|
|
|
placeholder="请选择来源库位"
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-full"
|
|
|
|
|
@change="handleFromLocationChange"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in filteredLocationList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="formatLocationLabel(item)"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="目标库区" prop="toAreaId">
|
|
|
|
|
<el-select v-model="formData.toAreaId" placeholder="请选择目标库区" filterable clearable class="!w-full">
|
|
|
|
|
<el-option v-for="item in toAreaList" :key="item.id" :label="item.areaName" :value="item.id" />
|
|
|
|
|
<el-form-item label="目标库位" prop="toLocationId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.toLocationId"
|
|
|
|
|
placeholder="请选择目标库位"
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-full"
|
|
|
|
|
@change="handleToLocationChange"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in filteredLocationList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="formatLocationLabel(item)"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
@ -58,19 +87,27 @@
|
|
|
|
|
import { BitWmsApi } from '@/api/erp/bitwms'
|
|
|
|
|
import { WarehouseApi } from '@/api/erp/stock/warehouse'
|
|
|
|
|
import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea'
|
|
|
|
|
import { WarehouseLocationApi } from '@/api/erp/stock/warehouselocation'
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'ErpBitWmsMove' })
|
|
|
|
|
|
|
|
|
|
const DEFAULT_WAREHOUSE_NAME = '样品仓'
|
|
|
|
|
const DEFAULT_AREA_NAME = '必硕三楼'
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const submitLoading = ref(false)
|
|
|
|
|
const stockLoading = ref(false)
|
|
|
|
|
const currentStock = ref<number | undefined>(undefined)
|
|
|
|
|
const sampleList = ref<any[]>([])
|
|
|
|
|
const warehouseList = ref<any[]>([])
|
|
|
|
|
const areaList = ref<any[]>([])
|
|
|
|
|
const locationList = ref<any[]>([])
|
|
|
|
|
const formData = reactive<any>({
|
|
|
|
|
productId: undefined,
|
|
|
|
|
fromLocationId: undefined,
|
|
|
|
|
fromWarehouseId: undefined,
|
|
|
|
|
fromAreaId: undefined,
|
|
|
|
|
toLocationId: undefined,
|
|
|
|
|
toWarehouseId: undefined,
|
|
|
|
|
toAreaId: undefined,
|
|
|
|
|
count: 1,
|
|
|
|
|
@ -78,50 +115,102 @@ const formData = reactive<any>({
|
|
|
|
|
})
|
|
|
|
|
const formRules = reactive({
|
|
|
|
|
productId: [{ required: true, message: '请选择样品', trigger: 'change' }],
|
|
|
|
|
fromWarehouseId: [{ required: true, message: '请选择来源仓库', trigger: 'change' }],
|
|
|
|
|
toWarehouseId: [{ required: true, message: '请选择目标仓库', trigger: 'change' }],
|
|
|
|
|
fromLocationId: [{ required: true, message: '请选择来源库位', trigger: 'change' }],
|
|
|
|
|
toLocationId: [{ required: true, message: '请选择目标库位', trigger: 'change' }],
|
|
|
|
|
count: [{ required: true, message: '请输入数量', trigger: 'blur' }]
|
|
|
|
|
})
|
|
|
|
|
const fromAreaList = computed(() => {
|
|
|
|
|
if (!formData.fromWarehouseId) return areaList.value
|
|
|
|
|
return areaList.value.filter((item) => item.warehouseId === formData.fromWarehouseId)
|
|
|
|
|
const defaultWarehouseId = computed(
|
|
|
|
|
() => warehouseList.value.find((item) => item.name === DEFAULT_WAREHOUSE_NAME)?.id
|
|
|
|
|
)
|
|
|
|
|
const defaultAreaId = computed(() => {
|
|
|
|
|
if (!defaultWarehouseId.value) return undefined
|
|
|
|
|
return areaList.value.find(
|
|
|
|
|
(item) => item.warehouseId === defaultWarehouseId.value && item.areaName === DEFAULT_AREA_NAME
|
|
|
|
|
)?.id
|
|
|
|
|
})
|
|
|
|
|
const toAreaList = computed(() => {
|
|
|
|
|
if (!formData.toWarehouseId) return areaList.value
|
|
|
|
|
return areaList.value.filter((item) => item.warehouseId === formData.toWarehouseId)
|
|
|
|
|
const filteredLocationList = computed(() =>
|
|
|
|
|
locationList.value.filter((item) => {
|
|
|
|
|
if (defaultWarehouseId.value && item.warehouseId !== defaultWarehouseId.value) return false
|
|
|
|
|
if (defaultAreaId.value && item.areaId !== defaultAreaId.value) return false
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
const currentStockText = computed(() => {
|
|
|
|
|
if (stockLoading.value) return '查询中...'
|
|
|
|
|
return currentStock.value === undefined ? '-' : `${currentStock.value}`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}`
|
|
|
|
|
const handleFromWarehouseChange = () => {
|
|
|
|
|
formData.fromAreaId = undefined
|
|
|
|
|
const formatLocationLabel = (item: any) => `${item.code || '-'} / ${item.name || '-'}`
|
|
|
|
|
const fillLocationFields = (prefix: 'from' | 'to', locationId?: number) => {
|
|
|
|
|
const location = locationList.value.find((item) => item.id === locationId)
|
|
|
|
|
formData[`${prefix}WarehouseId`] = location?.warehouseId
|
|
|
|
|
formData[`${prefix}AreaId`] = location?.areaId
|
|
|
|
|
}
|
|
|
|
|
const handleFromLocationChange = (locationId?: number) => {
|
|
|
|
|
fillLocationFields('from', locationId)
|
|
|
|
|
loadCurrentStock()
|
|
|
|
|
}
|
|
|
|
|
const handleToLocationChange = (locationId?: number) => {
|
|
|
|
|
fillLocationFields('to', locationId)
|
|
|
|
|
}
|
|
|
|
|
const loadCurrentStock = async () => {
|
|
|
|
|
if (!formData.productId || !formData.fromLocationId) {
|
|
|
|
|
currentStock.value = undefined
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
stockLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
currentStock.value = await BitWmsApi.getLocationStockCount(
|
|
|
|
|
formData.productId,
|
|
|
|
|
formData.fromLocationId
|
|
|
|
|
)
|
|
|
|
|
} finally {
|
|
|
|
|
stockLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const handleToWarehouseChange = () => {
|
|
|
|
|
const resetInnerFormData = () => {
|
|
|
|
|
formData.productId = undefined
|
|
|
|
|
formData.fromLocationId = undefined
|
|
|
|
|
formData.fromWarehouseId = undefined
|
|
|
|
|
formData.fromAreaId = undefined
|
|
|
|
|
formData.toLocationId = undefined
|
|
|
|
|
formData.toWarehouseId = undefined
|
|
|
|
|
formData.toAreaId = undefined
|
|
|
|
|
formData.count = 1
|
|
|
|
|
formData.remark = undefined
|
|
|
|
|
currentStock.value = undefined
|
|
|
|
|
}
|
|
|
|
|
const resetForm = () => {
|
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
|
formData.count = 1
|
|
|
|
|
resetInnerFormData()
|
|
|
|
|
}
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
|
await formRef.value.validate()
|
|
|
|
|
if (formData.fromLocationId === formData.toLocationId) {
|
|
|
|
|
message.warning('来源库位和目标库位不能相同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
submitLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
await BitWmsApi.move(formData)
|
|
|
|
|
message.success('移库成功')
|
|
|
|
|
resetForm()
|
|
|
|
|
await loadCurrentStock()
|
|
|
|
|
} finally {
|
|
|
|
|
submitLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
const [samples, warehouses, areas] = await Promise.all([
|
|
|
|
|
const [samples, warehouses, areas, locations] = await Promise.all([
|
|
|
|
|
BitWmsApi.getSampleSimpleList(),
|
|
|
|
|
WarehouseApi.getWarehouseSimpleList(),
|
|
|
|
|
WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 })
|
|
|
|
|
WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }),
|
|
|
|
|
WarehouseLocationApi.getWarehouseLocationPage({ pageNo: 1, pageSize: 100 })
|
|
|
|
|
])
|
|
|
|
|
sampleList.value = samples || []
|
|
|
|
|
warehouseList.value = warehouses || []
|
|
|
|
|
areaList.value = areas.list || []
|
|
|
|
|
locationList.value = locations.list || []
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|