feat(mes): 新增批次号和出厂检验标志字段

在相关数据对象中新增批次号和出厂检验标志字段,并在服务层实现相应的逻辑校验。此变更旨在增强库存管理的灵活性和准确性。
pull/871/MERGE
YunaiV 2026-03-30 21:51:40 +08:00
parent 47355814a2
commit 47db6c3b4c
4 changed files with 66 additions and 57 deletions

View File

@ -10,6 +10,8 @@ export interface WmProductSalesLineVO {
quantity: number quantity: number
pickedQuantity: number pickedQuantity: number
batchId: number batchId: number
batchCode: string
oqcCheckFlag: boolean
remark: string remark: string
createTime: string createTime: string
} }

View File

@ -146,7 +146,15 @@
</template> </template>
<template #footer> <template #footer>
<el-button v-if="isUpdate" @click="submitForm" type="primary" :disabled="formLoading"> <el-button v-if="isUpdate" @click="submitForm" type="primary" :disabled="formLoading">
</el-button>
<el-button
v-if="isUpdate && formData.status === MesWmProductSalesStatusEnum.PREPARE"
@click="handleSubmit"
type="warning"
:disabled="formLoading"
>
</el-button> </el-button>
<el-button v-if="isPick" @click="handleStock" type="primary" :disabled="formLoading"> <el-button v-if="isPick" @click="handleStock" type="primary" :disabled="formLoading">
执行拣货 执行拣货
@ -157,7 +165,7 @@
<el-button v-if="isFinish" @click="handleFinish" type="primary" :disabled="formLoading"> <el-button v-if="isFinish" @click="handleFinish" type="primary" :disabled="formLoading">
确认出库 确认出库
</el-button> </el-button>
<el-button @click="dialogVisible = false"></el-button> <el-button @click="dialogVisible = false"></el-button>
</template> </template>
</Dialog> </Dialog>
</template> </template>
@ -165,23 +173,41 @@
<script setup lang="ts"> <script setup lang="ts">
import { WmProductSalesApi, WmProductSalesVO } from '@/api/mes/wm/productsales' import { WmProductSalesApi, WmProductSalesVO } from '@/api/mes/wm/productsales'
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record' import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants' import { MesAutoCodeRuleCode, MesWmProductSalesStatusEnum } from '@/views/mes/utils/constants'
import MdClientSelect from '@/views/mes/md/client/components/MdClientSelect.vue' import MdClientSelect from '@/views/mes/md/client/components/MdClientSelect.vue'
import WmSalesNoticeSelect from '@/views/mes/wm/salesnotice/components/WmSalesNoticeSelect.vue' import WmSalesNoticeSelect from '@/views/mes/wm/salesnotice/components/WmSalesNoticeSelect.vue'
import { WmSalesNoticeVO } from '@/api/mes/wm/salesnotice' import { WmSalesNoticeVO } from '@/api/mes/wm/salesnotice'
import ProductSalesLineList from './ProductSalesLineList.vue' import ProductSalesLineList from './ProductSalesLineList.vue'
defineOptions({ name: 'ProductSalesForm' }) defineOptions({ name: 'ProductSalesForm' })
const emit = defineEmits(['success'])
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const formLoading = ref(false) // const formLoading = ref(false) //
const formType = ref<string>('create') // 表单的类型create / update / stock / shipping / finish / detail const formType = ref<string>('create') // 表单的类型create / update / stock / shipping / finish / detail
const isUpdate = computed(() => ['create', 'update'].includes(formType.value)) //
const isPick = computed(() => formType.value === 'stock') //
const isShipping = computed(() => formType.value === 'shipping') //
const isFinish = computed(() => formType.value === 'finish') //
const isHeaderReadonly = computed(() => ['stock', 'shipping', 'finish', 'detail'].includes(formType.value)) //
const dialogTitle = computed(() => {
const titles = {
create: '新增销售出库单',
update: '编辑销售出库单',
stock: '执行拣货',
shipping: '填写运单',
finish: '执行出库',
detail: '销售出库单详情'
}
return titles[formType.value] || formType.value
})
const formData = ref({ const formData = ref({
id: undefined as number | undefined, id: undefined as number | undefined,
code: undefined, code: undefined,
name: undefined, name: undefined,
status: undefined as number | undefined,
clientId: undefined, clientId: undefined,
noticeId: undefined, noticeId: undefined,
salesOrderCode: undefined, salesOrderCode: undefined,
@ -200,23 +226,7 @@ const formRules = reactive({
clientId: [{ required: true, message: '客户不能为空', trigger: 'change' }] clientId: [{ required: true, message: '客户不能为空', trigger: 'change' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const originalFormData = ref<string>('') //
const isUpdate = computed(() => ['create', 'update'].includes(formType.value)) //
const isPick = computed(() => formType.value === 'stock') //
const isShipping = computed(() => formType.value === 'shipping') //
const isFinish = computed(() => formType.value === 'finish') //
const isHeaderReadonly = computed(() => ['stock', 'shipping', 'finish', 'detail'].includes(formType.value)) //
const dialogTitle = computed(() => {
const titles = {
create: '新增销售出库单',
update: '编辑销售出库单',
stock: '执行拣货',
shipping: '填写运单',
finish: '执行出库',
detail: '销售出库单详情'
}
return titles[formType.value] || formType.value
})
/** 生成出库单编号 */ /** 生成出库单编号 */
const generateCode = async () => { const generateCode = async () => {
@ -251,11 +261,11 @@ const open = async (type: string, id?: number) => {
formLoading.value = false formLoading.value = false
} }
} }
//
originalFormData.value = JSON.stringify(formData.value)
} }
defineExpose({ open })
/** 提交表单create/update 模式) */ /** 提交表单create/update 模式) */
const emit = defineEmits(['success'])
const submitForm = async () => { const submitForm = async () => {
// //
await formRef.value.validate() await formRef.value.validate()
@ -267,11 +277,14 @@ const submitForm = async () => {
const res = await WmProductSalesApi.createProductSales(data) const res = await WmProductSalesApi.createProductSales(data)
message.success('新增成功') message.success('新增成功')
formData.value.id = res formData.value.id = res
formData.value.status = MesWmProductSalesStatusEnum.PREPARE
formType.value = 'update' formType.value = 'update'
} else { } else {
await WmProductSalesApi.updateProductSales(data) await WmProductSalesApi.updateProductSales(data)
message.success('修改成功') message.success('修改成功')
} }
//
originalFormData.value = JSON.stringify(formData.value)
// //
emit('success') emit('success')
} finally { } finally {
@ -279,6 +292,29 @@ const submitForm = async () => {
} }
} }
/** 提交操作:表单修改过则先保存,再提交 */
const handleSubmit = async () => {
//
await formRef.value.validate()
try {
await message.confirm('确认提交该销售出库单?【提交后将不能修改】')
formLoading.value = true
// 1.
if (JSON.stringify(formData.value) !== originalFormData.value) {
const data = formData.value as unknown as WmProductSalesVO
await WmProductSalesApi.updateProductSales(data)
}
// 2.
await WmProductSalesApi.submitProductSales(formData.value.id!)
message.success('提交成功')
dialogVisible.value = false
emit('success')
} catch {
} finally {
formLoading.value = false
}
}
/** 执行拣货 */ /** 执行拣货 */
const handleStock = async () => { const handleStock = async () => {
try { try {
@ -339,6 +375,7 @@ const resetForm = () => {
id: undefined, id: undefined,
code: undefined, code: undefined,
name: undefined, name: undefined,
status: undefined,
clientId: undefined, clientId: undefined,
noticeId: undefined, noticeId: undefined,
salesOrderCode: undefined, salesOrderCode: undefined,
@ -352,4 +389,6 @@ const resetForm = () => {
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
defineExpose({ open })
</script> </script>

View File

@ -98,12 +98,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="批次号" prop="batchId"> <el-form-item label="批次号" prop="batchCode">
<WmBatchSelect <el-input v-model="formData.batchCode" placeholder="请输入批次号" />
v-model="formData.batchId"
:item-id="formData.itemId"
@change="handleBatchChange"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@ -153,7 +149,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { WmProductSalesLineApi, WmProductSalesLineVO } from '@/api/mes/wm/productsales/line' import { WmProductSalesLineApi, WmProductSalesLineVO } from '@/api/mes/wm/productsales/line'
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue' import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
import WmBatchSelect from '@/views/mes/wm/batch/components/WmBatchSelect.vue'
import WmSalesNoticeLineSelect from '@/views/mes/wm/salesnotice/components/WmSalesNoticeLineSelect.vue' import WmSalesNoticeLineSelect from '@/views/mes/wm/salesnotice/components/WmSalesNoticeLineSelect.vue'
import ProductSalesDetailList from './ProductSalesDetailList.vue' import ProductSalesDetailList from './ProductSalesDetailList.vue'
import ProductSalesDetailForm from './ProductSalesDetailForm.vue' import ProductSalesDetailForm from './ProductSalesDetailForm.vue'
@ -171,7 +166,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() // const message = useMessage() //
const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) // const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) //
const isPick = computed(() => props.formType === 'pick') // const isPick = computed(() => props.formType === 'stock') //
const hasNoticeId = computed(() => !!props.noticeId) // const hasNoticeId = computed(() => !!props.noticeId) //
// ==================== ==================== // ==================== ====================
@ -218,7 +213,6 @@ const formData = ref({
noticeLineId: undefined as number | undefined, noticeLineId: undefined as number | undefined,
itemId: undefined, itemId: undefined,
quantity: undefined, quantity: undefined,
batchId: undefined as number | undefined,
batchCode: undefined as string | undefined, batchCode: undefined as string | undefined,
oqcCheckFlag: false, oqcCheckFlag: false,
remark: undefined remark: undefined
@ -245,17 +239,11 @@ const openForm = async (type: string, id?: number) => {
} }
} }
/** 批次选中回调,同步 batchCode */
const handleBatchChange = (batch: any) => {
formData.value.batchCode = batch?.code
}
/** 发货通知单行变化时,自动填充物料信息 */ /** 发货通知单行变化时,自动填充物料信息 */
const handleNoticeLineChange = (line: any) => { const handleNoticeLineChange = (line: any) => {
if (line) { if (line) {
formData.value.itemId = line.itemId formData.value.itemId = line.itemId
formData.value.quantity = line.quantity formData.value.quantity = line.quantity
formData.value.batchId = line.batchId
formData.value.batchCode = line.batchCode formData.value.batchCode = line.batchCode
formData.value.oqcCheckFlag = line.oqcCheckFlag ?? false formData.value.oqcCheckFlag = line.oqcCheckFlag ?? false
} }
@ -289,7 +277,6 @@ const resetForm = () => {
noticeLineId: undefined, noticeLineId: undefined,
itemId: undefined, itemId: undefined,
quantity: undefined, quantity: undefined,
batchId: undefined,
batchCode: undefined, batchCode: undefined,
oqcCheckFlag: false, oqcCheckFlag: false,
remark: undefined remark: undefined

View File

@ -130,15 +130,6 @@
> >
编辑 编辑
</el-button> </el-button>
<el-button
link
type="warning"
@click="handleSubmit(scope.row.id)"
v-hasPermi="['mes:wm-product-sales:submit']"
v-if="scope.row.status === MesWmProductSalesStatusEnum.PREPARE"
>
提交
</el-button>
<el-button <el-button
link link
type="danger" type="danger"
@ -268,16 +259,6 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 提交按钮操作 */
const handleSubmit = async (id: number) => {
try {
await message.confirm('确认提交该销售出库单?')
await WmProductSalesApi.submitProductSales(id)
message.success('提交成功')
await getList()
} catch {}
}
/** 取消按钮操作 */ /** 取消按钮操作 */
const handleCancel = async (id: number) => { const handleCancel = async (id: number) => {
try { try {