✨ feat(mes): 优化库存选择器和退货明细表单布局
调整库存选择器为下拉选择组件,支持前端过滤,提升用户体验。更新退货明细表单,增加库存记录选择,优化表单布局,确保信息展示更为清晰。pull/871/MERGE
parent
51e8cd35fa
commit
ef2b54316e
|
|
@ -45,5 +45,13 @@ export const WmMaterialStockApi = {
|
|||
// 导出库存台账 Excel
|
||||
exportMaterialStock: async (params: any) => {
|
||||
return await request.download({ url: '/mes/wm/material-stock/export-excel', params })
|
||||
},
|
||||
|
||||
// 获取库存精简列表(主要用于前端下拉,可按 itemId 过滤)
|
||||
getMaterialStockSimpleList: async (itemId?: number) => {
|
||||
return await request.get({
|
||||
url: '/mes/wm/material-stock/simple-list',
|
||||
params: { itemId }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ defineOptions({ name: 'WmBatchSelect' })
|
|||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: number
|
||||
itemId?: number
|
||||
disabled?: boolean
|
||||
clearable?: boolean
|
||||
placeholder?: string
|
||||
|
|
@ -62,11 +63,22 @@ const handleFilter = (query: string) => {
|
|||
const keyword = query.toLowerCase()
|
||||
filteredList.value = allList.value.filter(
|
||||
(item) =>
|
||||
item.code?.toLowerCase().includes(keyword) ||
|
||||
item.itemCode?.toLowerCase().includes(keyword)
|
||||
item.code?.toLowerCase().includes(keyword) || item.itemCode?.toLowerCase().includes(keyword)
|
||||
)
|
||||
}
|
||||
|
||||
/** 监听 itemId 变化,前端过滤(如果是基于 itemId 的过滤) */
|
||||
watch(
|
||||
() => props.itemId,
|
||||
(val) => {
|
||||
if (val) {
|
||||
filteredList.value = allList.value.filter((item) => item.itemId === val)
|
||||
} else {
|
||||
filteredList.value = allList.value
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/** 选中变化 */
|
||||
const handleChange = (val: number | undefined) => {
|
||||
const item = allList.value.find((o) => o.id === val)
|
||||
|
|
@ -76,6 +88,10 @@ const handleChange = (val: number | undefined) => {
|
|||
/** 加载批次列表 */
|
||||
onMounted(async () => {
|
||||
allList.value = await BatchApi.getBatchSimpleList()
|
||||
if (props.itemId) {
|
||||
filteredList.value = allList.value.filter((item) => item.itemId === props.itemId)
|
||||
} else {
|
||||
filteredList.value = allList.value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@
|
|||
<WmWarehouseAreaSelect v-model="formData.areaId" :location-id="formData.locationId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="批次号" prop="batchId">
|
||||
<el-input v-model="formData.batchId" placeholder="请输入批次号" />
|
||||
<WmBatchSelect
|
||||
v-model="formData.batchId"
|
||||
:item-id="formData.itemId"
|
||||
@change="handleBatchChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量" prop="quantity">
|
||||
<el-input-number
|
||||
|
|
@ -49,7 +53,7 @@ import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
|||
import WmWarehouseSelect from '@/views/mes/wm/warehouse/components/WmWarehouseSelect.vue'
|
||||
import WmWarehouseLocationSelect from '@/views/mes/wm/warehouse/components/WmWarehouseLocationSelect.vue'
|
||||
import WmWarehouseAreaSelect from '@/views/mes/wm/warehouse/components/WmWarehouseAreaSelect.vue'
|
||||
// import WmBatchSelect from '@/views/mes/wm/batch/components/WmBatchSelect.vue'
|
||||
import WmBatchSelect from '@/views/mes/wm/batch/components/WmBatchSelect.vue'
|
||||
|
||||
defineOptions({ name: 'ProductSalesDetailForm' })
|
||||
|
||||
|
|
@ -77,7 +81,8 @@ const formData = ref({
|
|||
warehouseId: undefined as number | undefined,
|
||||
locationId: undefined as number | undefined,
|
||||
areaId: undefined as number | undefined,
|
||||
batchId: undefined as number | undefined
|
||||
batchId: undefined as number | undefined,
|
||||
batchCode: undefined as string | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
itemId: [{ required: true, message: '物料不能为空', trigger: 'change' }],
|
||||
|
|
@ -108,6 +113,11 @@ const open = async (type: string, lineId: number, itemId?: number, detailId?: nu
|
|||
}
|
||||
defineExpose({ open })
|
||||
|
||||
/** 批次选中回调,同步 batchCode */
|
||||
const handleBatchChange = (batch: any) => {
|
||||
formData.value.batchCode = batch?.code
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
|
|
@ -146,7 +156,8 @@ const resetForm = () => {
|
|||
warehouseId: undefined,
|
||||
locationId: undefined,
|
||||
areaId: undefined,
|
||||
batchId: undefined
|
||||
batchId: undefined,
|
||||
batchCode: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,11 @@
|
|||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="批次号" prop="batchId">
|
||||
<el-input v-model="formData.batchId" placeholder="请输入批次号" />
|
||||
<WmBatchSelect
|
||||
v-model="formData.batchId"
|
||||
:item-id="formData.itemId"
|
||||
@change="handleBatchChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
|
|
@ -140,7 +144,7 @@
|
|||
<script setup lang="ts">
|
||||
import { WmProductSalesLineApi, WmProductSalesLineVO } from '@/api/mes/wm/productsales/line'
|
||||
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||
// import WmBatchSelect from '@/views/mes/wm/batch/components/WmBatchSelect.vue'
|
||||
import WmBatchSelect from '@/views/mes/wm/batch/components/WmBatchSelect.vue'
|
||||
import ProductSalesDetailList from './ProductSalesDetailList.vue'
|
||||
import ProductSalesDetailForm from './ProductSalesDetailForm.vue'
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
|
|
@ -201,7 +205,8 @@ const formData = ref({
|
|||
salesId: undefined as number | undefined,
|
||||
itemId: undefined,
|
||||
quantity: undefined,
|
||||
batchId: undefined,
|
||||
batchId: undefined as number | undefined,
|
||||
batchCode: undefined as string | undefined,
|
||||
oqcCheckFlag: false,
|
||||
remark: undefined
|
||||
})
|
||||
|
|
@ -227,6 +232,11 @@ const openForm = async (type: string, id?: number) => {
|
|||
}
|
||||
}
|
||||
|
||||
/** 批次选中回调,同步 batchCode */
|
||||
const handleBatchChange = (batch: any) => {
|
||||
formData.value.batchCode = batch?.code
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
|
|
@ -255,6 +265,7 @@ const resetForm = () => {
|
|||
itemId: undefined,
|
||||
quantity: undefined,
|
||||
batchId: undefined,
|
||||
batchCode: undefined,
|
||||
oqcCheckFlag: false,
|
||||
remark: undefined
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,11 @@
|
|||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="批次号" prop="batchId">
|
||||
<WmBatchSelect v-model="formData.batchId" @change="handleBatchChange" />
|
||||
<WmBatchSelect
|
||||
v-model="formData.batchId"
|
||||
:item-id="formData.itemId"
|
||||
@change="handleBatchChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
|
|
|||
Loading…
Reference in New Issue