出入库已库位为主要操作单位

besure_bit
ck-chenkang 4 weeks ago
parent ff0b41820e
commit 8a7bcd1f31

@ -2,9 +2,9 @@ import request from '@/config/axios'
export interface BitWmsInboundReqVO { export interface BitWmsInboundReqVO {
productId: number productId: number
warehouseId: number warehouseId?: number
areaId?: number areaId?: number
locationId?: number locationId: number
count: number count: number
unitId: number unitId: number
supplierId?: number supplierId?: number
@ -13,8 +13,9 @@ export interface BitWmsInboundReqVO {
export interface BitWmsOutboundReqVO { export interface BitWmsOutboundReqVO {
productId: number productId: number
warehouseId: number warehouseId?: number
areaId?: number areaId?: number
locationId: number
count: number count: number
outReason: string outReason: string
remark?: string remark?: string
@ -22,9 +23,11 @@ export interface BitWmsOutboundReqVO {
export interface BitWmsMoveReqVO { export interface BitWmsMoveReqVO {
productId: number productId: number
fromWarehouseId: number fromLocationId: number
toLocationId: number
fromWarehouseId?: number
fromAreaId?: number fromAreaId?: number
toWarehouseId: number toWarehouseId?: number
toAreaId?: number toAreaId?: number
count: number count: number
remark?: string remark?: string
@ -43,6 +46,15 @@ export const BitWmsApi = {
getSampleSimpleList: async (params?: any) => { getSampleSimpleList: async (params?: any) => {
return await request.get({ url: '/erp/product/sample-simple-list', params }) return await request.get({ url: '/erp/product/sample-simple-list', params })
}, },
getLocationStockPage: async (params: any) => {
return await request.get({ url: '/erp/bit-wms/location-stock/page', params })
},
getLocationStockCount: async (productId: number, locationId: number) => {
return await request.get({ url: '/erp/bit-wms/location-stock/count', params: { productId, locationId } })
},
getLocationStockRecordPage: async (params: any) => {
return await request.get({ url: '/erp/bit-wms/location-stock-record/page', params })
},
inbound: async (data: BitWmsInboundReqVO) => { inbound: async (data: BitWmsInboundReqVO) => {
return await request.post({ url: '/erp/bit-wms/inbound', data }) return await request.post({ url: '/erp/bit-wms/inbound', data })
}, },

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

@ -16,21 +16,26 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="12">
<el-form-item label="仓库" prop="warehouseId"> <el-form-item label="库位" prop="locationId">
<el-select v-model="formData.warehouseId" placeholder="请选择仓库" filterable class="!w-full" @change="handleWarehouseChange"> <el-select
<el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" /> v-model="formData.locationId"
</el-select> placeholder="请选择库位"
</el-form-item> filterable
</el-col> clearable
<el-col :span="8"> class="!w-full"
<el-form-item label="库区" prop="areaId"> @change="handleLocationChange"
<el-select v-model="formData.areaId" placeholder="请选择库区" filterable clearable class="!w-full" @change="loadCurrentStock"> >
<el-option v-for="item in filteredAreaList" :key="item.id" :label="item.areaName" :value="item.id" /> <el-option
v-for="item in filteredLocationList"
:key="item.id"
:label="formatLocationLabel(item)"
:value="item.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="12">
<el-form-item label="数量" prop="count"> <el-form-item label="数量" prop="count">
<el-input-number v-model="formData.count" :min="1" :precision="0" class="!w-full" /> <el-input-number v-model="formData.count" :min="1" :precision="0" class="!w-full" />
</el-form-item> </el-form-item>
@ -59,10 +64,12 @@ import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { BitWmsApi } from '@/api/erp/bitwms' import { BitWmsApi } from '@/api/erp/bitwms'
import { WarehouseApi } from '@/api/erp/stock/warehouse' import { WarehouseApi } from '@/api/erp/stock/warehouse'
import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea' import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea'
import { StockApi } from '@/api/erp/stock/stock' import { WarehouseLocationApi } from '@/api/erp/stock/warehouselocation'
defineOptions({ name: 'ErpBitWmsOut' }) defineOptions({ name: 'ErpBitWmsOut' })
const DEFAULT_WAREHOUSE_NAME = '样品仓'
const DEFAULT_AREA_NAME = '必硕三楼'
const message = useMessage() const message = useMessage()
const formRef = ref() const formRef = ref()
const submitLoading = ref(false) const submitLoading = ref(false)
@ -71,23 +78,25 @@ const currentStock = ref<number | undefined>(undefined)
const sampleList = ref<any[]>([]) const sampleList = ref<any[]>([])
const warehouseList = ref<any[]>([]) const warehouseList = ref<any[]>([])
const areaList = ref<any[]>([]) const areaList = ref<any[]>([])
const locationList = ref<any[]>([])
const formData = reactive<any>({ const formData = reactive<any>({
productId: undefined, productId: undefined,
warehouseId: undefined, warehouseId: undefined,
areaId: undefined, areaId: undefined,
locationId: undefined,
count: 1, count: 1,
outReason: undefined, outReason: undefined,
remark: undefined remark: undefined
}) })
const formRules = reactive({ const formRules = reactive({
productId: [{ required: true, message: '请选择样品', trigger: 'change' }], productId: [{ required: true, message: '请选择样品', trigger: 'change' }],
warehouseId: [{ required: true, message: '请选择库', trigger: 'change' }], locationId: [{ required: true, message: '请选择', trigger: 'change' }],
count: [{ required: true, message: '请输入数量', trigger: 'blur' }], count: [{ required: true, message: '请输入数量', trigger: 'blur' }],
outReason: [{ required: true, message: '请选择出库原因', trigger: 'change' }] outReason: [{ required: true, message: '请选择出库原因', trigger: 'change' }]
}) })
const filteredAreaList = computed(() => { const filteredLocationList = computed(() => {
if (!formData.warehouseId) return areaList.value if (!formData.warehouseId || !formData.areaId) return []
return areaList.value.filter((item) => item.warehouseId === formData.warehouseId) return locationList.value.filter((item) => item.warehouseId === formData.warehouseId && item.areaId === formData.areaId)
}) })
const currentStockText = computed(() => { const currentStockText = computed(() => {
if (stockLoading.value) return '查询中...' if (stockLoading.value) return '查询中...'
@ -95,27 +104,57 @@ const currentStockText = computed(() => {
}) })
const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}` const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}`
const handleWarehouseChange = () => { const formatLocationLabel = (item: any) => `${item.code || '-'} / ${item.name || '-'}`
formData.areaId = undefined const applyDefaultWarehouseArea = () => {
const warehouse = warehouseList.value.find((item) => item.name === DEFAULT_WAREHOUSE_NAME)
if (!warehouse) {
formData.warehouseId = undefined
formData.areaId = undefined
return
}
formData.warehouseId = warehouse.id
const area = areaList.value.find(
(item) => item.warehouseId === warehouse.id && item.areaName === DEFAULT_AREA_NAME
)
formData.areaId = area?.id
}
const handleLocationChange = (locationId?: number) => {
const location = locationList.value.find((item) => item.id === locationId)
if (!location) {
currentStock.value = undefined
return
}
formData.warehouseId = location.warehouseId
formData.areaId = location.areaId
loadCurrentStock() loadCurrentStock()
} }
const loadCurrentStock = async () => { const loadCurrentStock = async () => {
if (!formData.productId || !formData.warehouseId) { if (!formData.productId || !formData.locationId) {
currentStock.value = undefined currentStock.value = undefined
return return
} }
stockLoading.value = true stockLoading.value = true
try { try {
const data = await StockApi.getStock2(formData.productId, formData.warehouseId, formData.areaId) currentStock.value = await BitWmsApi.getLocationStockCount(
currentStock.value = data?.count || 0 formData.productId,
formData.locationId
)
} finally { } finally {
stockLoading.value = false stockLoading.value = false
} }
} }
const resetForm = () => { const resetInnerFormData = () => {
formRef.value?.resetFields() formData.productId = undefined
formData.locationId = undefined
formData.count = 1 formData.count = 1
formData.outReason = undefined
formData.remark = undefined
currentStock.value = undefined currentStock.value = undefined
applyDefaultWarehouseArea()
}
const resetForm = () => {
formRef.value?.resetFields()
resetInnerFormData()
} }
const submitForm = async () => { const submitForm = async () => {
await formRef.value.validate() await formRef.value.validate()
@ -130,13 +169,16 @@ const submitForm = async () => {
} }
onMounted(async () => { onMounted(async () => {
const [samples, warehouses, areas] = await Promise.all([ const [samples, warehouses, areas, locations] = await Promise.all([
BitWmsApi.getSampleSimpleList(), BitWmsApi.getSampleSimpleList(),
WarehouseApi.getWarehouseSimpleList(), WarehouseApi.getWarehouseSimpleList(),
WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }) WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }),
WarehouseLocationApi.getWarehouseLocationPage({ pageNo: 1, pageSize: 100 })
]) ])
sampleList.value = samples || [] sampleList.value = samples || []
warehouseList.value = warehouses || [] warehouseList.value = warehouses || []
areaList.value = areas.list || [] areaList.value = areas.list || []
locationList.value = locations.list || []
resetInnerFormData()
}) })
</script> </script>

@ -47,6 +47,7 @@
clearable clearable
filterable filterable
class="!w-220px" class="!w-220px"
@change="handleAreaChange"
> >
<el-option <el-option
v-for="item in filteredAreaList" v-for="item in filteredAreaList"
@ -56,6 +57,22 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="库位" prop="locationId">
<el-select
v-model="queryParams.locationId"
placeholder="请选择库位"
clearable
filterable
class="!w-240px"
>
<el-option
v-for="item in filteredLocationList"
:key="item.id"
:label="formatLocationLabel(item)"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="业务单号" prop="bizNo"> <el-form-item label="业务单号" prop="bizNo">
<el-input <el-input
v-model="queryParams.bizNo" v-model="queryParams.bizNo"
@ -93,6 +110,8 @@
<!-- <el-table-column label="分类" align="center" prop="categoryName" min-width="120" /> --> <!-- <el-table-column label="分类" align="center" prop="categoryName" min-width="120" /> -->
<el-table-column label="仓库" align="center" prop="warehouseName" min-width="140" /> <el-table-column label="仓库" align="center" prop="warehouseName" min-width="140" />
<el-table-column label="库区" align="center" prop="areaName" min-width="120" /> <el-table-column label="库区" align="center" prop="areaName" min-width="120" />
<el-table-column label="库位编码" align="center" prop="locationCode" min-width="130" />
<el-table-column label="库位名称" align="center" prop="locationName" min-width="140" />
<el-table-column label="变动数量" align="center" prop="count" min-width="120"> <el-table-column label="变动数量" align="center" prop="count" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
<span :class="getDirectionClass(row.bizDirection)">{{ <span :class="getDirectionClass(row.bizDirection)">{{
@ -124,9 +143,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { BitWmsApi } from '@/api/erp/bitwms' import { BitWmsApi } from '@/api/erp/bitwms'
import { StockRecordApi } from '@/api/erp/stock/record'
import { WarehouseApi } from '@/api/erp/stock/warehouse' import { WarehouseApi } from '@/api/erp/stock/warehouse'
import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea' import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea'
import { WarehouseLocationApi } from '@/api/erp/stock/warehouselocation'
defineOptions({ name: 'ErpBitWmsRecord' }) defineOptions({ name: 'ErpBitWmsRecord' })
@ -137,23 +156,30 @@ const queryFormRef = ref()
const sampleList = ref<any[]>([]) const sampleList = ref<any[]>([])
const warehouseList = ref<any[]>([]) const warehouseList = ref<any[]>([])
const areaList = ref<any[]>([]) const areaList = ref<any[]>([])
const locationList = ref<any[]>([])
const queryParams = reactive<any>({ const queryParams = reactive<any>({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
productId: undefined, productId: undefined,
warehouseId: undefined, warehouseId: undefined,
areaId: undefined, areaId: undefined,
bizNo: undefined, locationId: undefined,
isSample: true, bizNo: undefined
bizUnit: 'BIT',
bitWmsOnly: true
}) })
const filteredAreaList = computed(() => { const filteredAreaList = computed(() => {
if (!queryParams.warehouseId) return areaList.value if (!queryParams.warehouseId) return areaList.value
return areaList.value.filter((item) => item.warehouseId === queryParams.warehouseId) return areaList.value.filter((item) => item.warehouseId === queryParams.warehouseId)
}) })
const filteredLocationList = computed(() =>
locationList.value.filter((item) => {
if (queryParams.warehouseId && item.warehouseId !== queryParams.warehouseId) return false
if (queryParams.areaId && item.areaId !== queryParams.areaId) return false
return true
})
)
const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}` const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}`
const formatLocationLabel = (item: any) => `${item.code || '-'} / ${item.name || '-'}`
const isStockIn = (direction?: string) => direction === '入库' const isStockIn = (direction?: string) => direction === '入库'
const isStockOut = (direction?: string) => direction === '出库' const isStockOut = (direction?: string) => direction === '出库'
const getDirectionTagType = (direction?: string) => { const getDirectionTagType = (direction?: string) => {
@ -195,7 +221,7 @@ const buildQueryParams = () =>
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await StockRecordApi.getStockRecordPage(buildQueryParams()) const data = await BitWmsApi.getLocationStockRecordPage(buildQueryParams())
list.value = data.list || [] list.value = data.list || []
total.value = data.total || 0 total.value = data.total || 0
} finally { } finally {
@ -204,6 +230,10 @@ const getList = async () => {
} }
const handleWarehouseChange = () => { const handleWarehouseChange = () => {
queryParams.areaId = undefined queryParams.areaId = undefined
queryParams.locationId = undefined
}
const handleAreaChange = () => {
queryParams.locationId = undefined
} }
const handleQuery = () => { const handleQuery = () => {
queryParams.pageNo = 1 queryParams.pageNo = 1
@ -211,21 +241,20 @@ const handleQuery = () => {
} }
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
queryParams.isSample = true
queryParams.bizUnit = 'BIT'
queryParams.bitWmsOnly = true
handleQuery() handleQuery()
} }
onMounted(async () => { onMounted(async () => {
const [samples, warehouses, areas] = await Promise.all([ const [samples, warehouses, areas, locations] = await Promise.all([
BitWmsApi.getSampleSimpleList(), BitWmsApi.getSampleSimpleList(),
WarehouseApi.getWarehouseSimpleList(), WarehouseApi.getWarehouseSimpleList(),
WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }) WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }),
WarehouseLocationApi.getWarehouseLocationPage({ pageNo: 1, pageSize: 100 })
]) ])
sampleList.value = samples || [] sampleList.value = samples || []
warehouseList.value = warehouses || [] warehouseList.value = warehouses || []
areaList.value = areas.list || [] areaList.value = areas.list || []
locationList.value = locations.list || []
await getList() await getList()
}) })
</script> </script>

@ -47,6 +47,7 @@
clearable clearable
filterable filterable
class="!w-220px" class="!w-220px"
@change="handleAreaChange"
> >
<el-option <el-option
v-for="item in filteredAreaList" v-for="item in filteredAreaList"
@ -56,6 +57,22 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="库位" prop="locationId">
<el-select
v-model="queryParams.locationId"
placeholder="请选择库位"
clearable
filterable
class="!w-240px"
>
<el-option
v-for="item in filteredLocationList"
:key="item.id"
:label="formatLocationLabel(item)"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" />查询</el-button> <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" />查询</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" />重置</el-button> <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" />重置</el-button>
@ -78,6 +95,8 @@
<!-- <el-table-column label="样品分类" align="center" prop="categoryName" min-width="130" /> --> <!-- <el-table-column label="样品分类" align="center" prop="categoryName" min-width="130" /> -->
<el-table-column label="仓库" align="center" prop="warehouseName" min-width="140" /> <el-table-column label="仓库" align="center" prop="warehouseName" min-width="140" />
<el-table-column label="库区" align="center" prop="areaName" min-width="120" /> <el-table-column label="库区" align="center" prop="areaName" min-width="120" />
<el-table-column label="库位编码" align="center" prop="locationCode" min-width="130" />
<el-table-column label="库位名称" align="center" prop="locationName" min-width="140" />
<el-table-column label="库存" align="center" prop="count" min-width="120"> <el-table-column label="库存" align="center" prop="count" min-width="120">
<template #default="{ row }">{{ formatCount(row.count) }}</template> <template #default="{ row }">{{ formatCount(row.count) }}</template>
</el-table-column> </el-table-column>
@ -97,9 +116,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { BitWmsApi } from '@/api/erp/bitwms' import { BitWmsApi } from '@/api/erp/bitwms'
import { StockApi } from '@/api/erp/stock/stock'
import { WarehouseApi } from '@/api/erp/stock/warehouse' import { WarehouseApi } from '@/api/erp/stock/warehouse'
import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea' import { WarehouseAreaApi } from '@/api/erp/stock/warehousearea'
import { WarehouseLocationApi } from '@/api/erp/stock/warehouselocation'
defineOptions({ name: 'ErpBitWmsStock' }) defineOptions({ name: 'ErpBitWmsStock' })
@ -110,21 +129,29 @@ const queryFormRef = ref()
const sampleList = ref<any[]>([]) const sampleList = ref<any[]>([])
const warehouseList = ref<any[]>([]) const warehouseList = ref<any[]>([])
const areaList = ref<any[]>([]) const areaList = ref<any[]>([])
const locationList = ref<any[]>([])
const queryParams = reactive<any>({ const queryParams = reactive<any>({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
productId: undefined, productId: undefined,
warehouseId: undefined, warehouseId: undefined,
areaId: undefined, areaId: undefined,
isSample: true, locationId: undefined
bizUnit: 'BIT'
}) })
const filteredAreaList = computed(() => { const filteredAreaList = computed(() => {
if (!queryParams.warehouseId) return areaList.value if (!queryParams.warehouseId) return areaList.value
return areaList.value.filter((item) => item.warehouseId === queryParams.warehouseId) return areaList.value.filter((item) => item.warehouseId === queryParams.warehouseId)
}) })
const filteredLocationList = computed(() =>
locationList.value.filter((item) => {
if (queryParams.warehouseId && item.warehouseId !== queryParams.warehouseId) return false
if (queryParams.areaId && item.areaId !== queryParams.areaId) return false
return true
})
)
const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}` const formatSampleLabel = (item: any) => `${item.barCode || item.code || '-'} / ${item.name || '-'}`
const formatLocationLabel = (item: any) => `${item.code || '-'} / ${item.name || '-'}`
const formatCount = (value: number | string | undefined) => { const formatCount = (value: number | string | undefined) => {
if (value === undefined || value === null || value === '') return '-' if (value === undefined || value === null || value === '') return '-'
const num = Number(value) const num = Number(value)
@ -139,7 +166,7 @@ const buildQueryParams = () =>
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await StockApi.getStockPage(buildQueryParams()) const data = await BitWmsApi.getLocationStockPage(buildQueryParams())
list.value = data.list || [] list.value = data.list || []
total.value = data.total || 0 total.value = data.total || 0
} finally { } finally {
@ -148,6 +175,10 @@ const getList = async () => {
} }
const handleWarehouseChange = () => { const handleWarehouseChange = () => {
queryParams.areaId = undefined queryParams.areaId = undefined
queryParams.locationId = undefined
}
const handleAreaChange = () => {
queryParams.locationId = undefined
} }
const handleQuery = () => { const handleQuery = () => {
queryParams.pageNo = 1 queryParams.pageNo = 1
@ -155,20 +186,20 @@ const handleQuery = () => {
} }
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
queryParams.isSample = true
queryParams.bizUnit = 'BIT'
handleQuery() handleQuery()
} }
onMounted(async () => { onMounted(async () => {
const [samples, warehouses, areas] = await Promise.all([ const [samples, warehouses, areas, locations] = await Promise.all([
BitWmsApi.getSampleSimpleList(), BitWmsApi.getSampleSimpleList(),
WarehouseApi.getWarehouseSimpleList(), WarehouseApi.getWarehouseSimpleList(),
WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }) WarehouseAreaApi.getWarehouseAreaPage({ pageNo: 1, pageSize: 100 }),
WarehouseLocationApi.getWarehouseLocationPage({ pageNo: 1, pageSize: 100 })
]) ])
sampleList.value = samples || [] sampleList.value = samples || []
warehouseList.value = warehouses || [] warehouseList.value = warehouses || []
areaList.value = areas.list || [] areaList.value = areas.list || []
locationList.value = locations.list || []
await getList() await getList()
}) })
</script> </script>

Loading…
Cancel
Save