✨ feat(mes): 新增批次号和出厂检验标志字段
在相关数据对象中新增批次号和出厂检验标志字段,并在服务层实现相应的逻辑校验。此变更旨在增强库存管理的灵活性和准确性。pull/871/MERGE
parent
47355814a2
commit
47db6c3b4c
|
|
@ -10,6 +10,8 @@ export interface WmProductSalesLineVO {
|
|||
quantity: number
|
||||
pickedQuantity: number
|
||||
batchId: number
|
||||
batchCode: string
|
||||
oqcCheckFlag: boolean
|
||||
remark: string
|
||||
createTime: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,15 @@
|
|||
</template>
|
||||
<template #footer>
|
||||
<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 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>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
|
@ -165,23 +173,41 @@
|
|||
<script setup lang="ts">
|
||||
import { WmProductSalesApi, WmProductSalesVO } from '@/api/mes/wm/productsales'
|
||||
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 WmSalesNoticeSelect from '@/views/mes/wm/salesnotice/components/WmSalesNoticeSelect.vue'
|
||||
import { WmSalesNoticeVO } from '@/api/mes/wm/salesnotice'
|
||||
import ProductSalesLineList from './ProductSalesLineList.vue'
|
||||
|
||||
defineOptions({ name: 'ProductSalesForm' })
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
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({
|
||||
id: undefined as number | undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
status: undefined as number | undefined,
|
||||
clientId: undefined,
|
||||
noticeId: undefined,
|
||||
salesOrderCode: undefined,
|
||||
|
|
@ -200,23 +226,7 @@ const formRules = reactive({
|
|||
clientId: [{ required: true, message: '客户不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
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 originalFormData = ref<string>('') // 原始表单数据快照,用于脏检查
|
||||
|
||||
/** 生成出库单编号 */
|
||||
const generateCode = async () => {
|
||||
|
|
@ -251,11 +261,11 @@ const open = async (type: string, id?: number) => {
|
|||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
// 保存原始数据快照
|
||||
originalFormData.value = JSON.stringify(formData.value)
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
/** 提交表单(create/update 模式) */
|
||||
const emit = defineEmits(['success'])
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
|
|
@ -267,11 +277,14 @@ const submitForm = async () => {
|
|||
const res = await WmProductSalesApi.createProductSales(data)
|
||||
message.success('新增成功')
|
||||
formData.value.id = res
|
||||
formData.value.status = MesWmProductSalesStatusEnum.PREPARE
|
||||
formType.value = 'update'
|
||||
} else {
|
||||
await WmProductSalesApi.updateProductSales(data)
|
||||
message.success('修改成功')
|
||||
}
|
||||
// 更新快照
|
||||
originalFormData.value = JSON.stringify(formData.value)
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} 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 () => {
|
||||
try {
|
||||
|
|
@ -339,6 +375,7 @@ const resetForm = () => {
|
|||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
status: undefined,
|
||||
clientId: undefined,
|
||||
noticeId: undefined,
|
||||
salesOrderCode: undefined,
|
||||
|
|
@ -352,4 +389,6 @@ const resetForm = () => {
|
|||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -98,12 +98,8 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="批次号" prop="batchId">
|
||||
<WmBatchSelect
|
||||
v-model="formData.batchId"
|
||||
:item-id="formData.itemId"
|
||||
@change="handleBatchChange"
|
||||
/>
|
||||
<el-form-item label="批次号" prop="batchCode">
|
||||
<el-input v-model="formData.batchCode" placeholder="请输入批次号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
|
|
@ -153,7 +149,6 @@
|
|||
<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 WmSalesNoticeLineSelect from '@/views/mes/wm/salesnotice/components/WmSalesNoticeLineSelect.vue'
|
||||
import ProductSalesDetailList from './ProductSalesDetailList.vue'
|
||||
import ProductSalesDetailForm from './ProductSalesDetailForm.vue'
|
||||
|
|
@ -171,7 +166,7 @@ const { t } = useI18n() // 国际化
|
|||
const message = useMessage() // 消息弹窗
|
||||
|
||||
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) // 是否有关联的发货通知单
|
||||
|
||||
// ==================== 列表 ====================
|
||||
|
|
@ -218,7 +213,6 @@ const formData = ref({
|
|||
noticeLineId: undefined as number | undefined,
|
||||
itemId: undefined,
|
||||
quantity: undefined,
|
||||
batchId: undefined as number | undefined,
|
||||
batchCode: undefined as string | undefined,
|
||||
oqcCheckFlag: false,
|
||||
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) => {
|
||||
if (line) {
|
||||
formData.value.itemId = line.itemId
|
||||
formData.value.quantity = line.quantity
|
||||
formData.value.batchId = line.batchId
|
||||
formData.value.batchCode = line.batchCode
|
||||
formData.value.oqcCheckFlag = line.oqcCheckFlag ?? false
|
||||
}
|
||||
|
|
@ -289,7 +277,6 @@ const resetForm = () => {
|
|||
noticeLineId: undefined,
|
||||
itemId: undefined,
|
||||
quantity: undefined,
|
||||
batchId: undefined,
|
||||
batchCode: undefined,
|
||||
oqcCheckFlag: false,
|
||||
remark: undefined
|
||||
|
|
|
|||
|
|
@ -130,15 +130,6 @@
|
|||
>
|
||||
编辑
|
||||
</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
|
||||
link
|
||||
type="danger"
|
||||
|
|
@ -268,16 +259,6 @@ const openForm = (type: string, id?: number) => {
|
|||
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) => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue