✨ feat(mes): 增强产品入库单功能,新增数量校验和明细检查
新增上架数量的正数校验,确保入库单的数量大于0。同时,增加了收货单明细为空的错误提示,提升数据完整性和用户体验。pull/871/MERGE
parent
4ec4c4dd09
commit
79d63523fe
|
|
@ -424,6 +424,7 @@ export const MesAutoCodeRuleCode = {
|
||||||
WM_RETURN_VENDOR_CODE: 'WM_RETURN_VENDOR_CODE', // 采购退货单编码
|
WM_RETURN_VENDOR_CODE: 'WM_RETURN_VENDOR_CODE', // 采购退货单编码
|
||||||
WM_PRODUCT_ISSUE_CODE: 'WM_PRODUCT_ISSUE_CODE', // 生产领料出库单编码
|
WM_PRODUCT_ISSUE_CODE: 'WM_PRODUCT_ISSUE_CODE', // 生产领料出库单编码
|
||||||
WM_RETURN_ISSUE_CODE: 'WM_RETURN_ISSUE_CODE', // 生产退料单编码
|
WM_RETURN_ISSUE_CODE: 'WM_RETURN_ISSUE_CODE', // 生产退料单编码
|
||||||
|
PRODUCTRECPT_CODE: 'PRODUCTRECPT_CODE', // 产品入库单编码
|
||||||
WM_SN_CODE: 'WM_SN_CODE', // SN 码
|
WM_SN_CODE: 'WM_SN_CODE', // SN 码
|
||||||
WM_PACKAGE_CODE: 'WM_PACKAGE_CODE', // 装箱单编码
|
WM_PACKAGE_CODE: 'WM_PACKAGE_CODE', // 装箱单编码
|
||||||
WM_BATCH_CODE: 'WM_BATCH_CODE', // 批次编码
|
WM_BATCH_CODE: 'WM_BATCH_CODE', // 批次编码
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
:rules="formRules"
|
:rules="formRules"
|
||||||
label-width="110px"
|
label-width="110px"
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
|
:disabled="isDetail"
|
||||||
>
|
>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
|
|
@ -16,9 +17,7 @@
|
||||||
:disabled="isHeaderReadonly"
|
:disabled="isHeaderReadonly"
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<el-button @click="generateCode">
|
<el-button @click="generateCode" :disabled="isHeaderReadonly"> 生成 </el-button>
|
||||||
生成
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -74,34 +73,65 @@
|
||||||
<ProductReceiptLineList :receipt-id="formData.id" :form-type="formType" />
|
<ProductReceiptLineList :receipt-id="formData.id" :form-type="formType" />
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button v-if="isUpdate" @click="submitForm" type="primary" :disabled="formLoading">
|
<el-button v-if="isEditable" @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
确 定
|
保 存
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isEditable && formData.status === MesWmProductReceiptStatusEnum.PREPARE"
|
||||||
|
@click="handleSubmit"
|
||||||
|
type="warning"
|
||||||
|
:disabled="formLoading"
|
||||||
|
>
|
||||||
|
提 交
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-if="isStock" @click="handleStock" type="primary" :disabled="formLoading">
|
<el-button v-if="isStock" @click="handleStock" type="primary" :disabled="formLoading">
|
||||||
执行上架
|
执行上架
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button v-if="isFinish" @click="handleFinish" type="success" :disabled="formLoading">
|
||||||
|
执行入库
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { generateRandomStr } from '@/utils'
|
|
||||||
import { WmProductReceiptApi, WmProductReceiptVO } from '@/api/mes/wm/productreceipt'
|
import { WmProductReceiptApi, WmProductReceiptVO } from '@/api/mes/wm/productreceipt'
|
||||||
|
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
|
||||||
import ProWorkOrderSelect from '@/views/mes/pro/workorder/components/ProWorkOrderSelect.vue'
|
import ProWorkOrderSelect from '@/views/mes/pro/workorder/components/ProWorkOrderSelect.vue'
|
||||||
import ProductReceiptLineList from './ProductReceiptLineList.vue'
|
import ProductReceiptLineList from './ProductReceiptLineList.vue'
|
||||||
|
import {
|
||||||
|
MesAutoCodeRuleCode,
|
||||||
|
MesWmProductReceiptStatusEnum
|
||||||
|
} from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'ProductReceiptForm' })
|
defineOptions({ name: 'ProductReceiptForm' })
|
||||||
|
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 / finish / detail
|
||||||
const formType = ref<string>('create')
|
const isEditable = computed(() => ['create', 'update'].includes(formType.value)) // 是否为编辑模式
|
||||||
|
const isStock = computed(() => formType.value === 'stock') // 是否为上架模式
|
||||||
|
const isFinish = computed(() => formType.value === 'finish') // 是否为执行入库模式
|
||||||
|
const isDetail = computed(() => ['detail', 'finish'].includes(formType.value)) // 是否为详情模式
|
||||||
|
const isHeaderReadonly = computed(() => ['stock', 'detail', 'finish'].includes(formType.value)) // 是否只读
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
const titles = {
|
||||||
|
create: '新增产品入库单',
|
||||||
|
update: '编辑产品入库单',
|
||||||
|
stock: '执行上架',
|
||||||
|
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,
|
||||||
workOrderId: undefined,
|
workOrderId: undefined,
|
||||||
receiptDate: undefined,
|
receiptDate: undefined,
|
||||||
remark: undefined
|
remark: undefined
|
||||||
|
|
@ -111,24 +141,14 @@ const formRules = reactive({
|
||||||
name: [{ required: true, message: '入库单名称不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '入库单名称不能为空', trigger: 'blur' }],
|
||||||
receiptDate: [{ required: true, message: '入库日期不能为空', trigger: 'change' }]
|
receiptDate: [{ required: true, message: '入库日期不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const formRef = ref()
|
const formRef = ref() // 表单 Ref
|
||||||
|
const originalFormData = ref<string>('') // 原始表单数据快照,用于脏检查
|
||||||
const isUpdate = computed(() => ['create', 'update'].includes(formType.value))
|
|
||||||
const isStock = computed(() => formType.value === 'stock')
|
|
||||||
const isHeaderReadonly = computed(() => ['stock', 'detail'].includes(formType.value))
|
|
||||||
const dialogTitle = computed(() => {
|
|
||||||
const titles = {
|
|
||||||
create: '新增产品入库单',
|
|
||||||
update: '编辑产品入库单',
|
|
||||||
stock: '执行上架',
|
|
||||||
detail: '产品入库单详情'
|
|
||||||
}
|
|
||||||
return titles[formType.value] || formType.value
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 生成入库单编号 */
|
/** 生成入库单编号 */
|
||||||
const generateCode = () => {
|
const generateCode = async () => {
|
||||||
formData.value.code = 'PR' + generateRandomStr(10)
|
formData.value.code = await AutoCodeRecordApi.generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.PRODUCTRECPT_CODE
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
|
|
@ -136,6 +156,7 @@ const open = async (type: string, id?: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
formType.value = type
|
formType.value = type
|
||||||
resetForm()
|
resetForm()
|
||||||
|
// 修改/上架/入库/详情时,加载数据
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
|
|
@ -144,31 +165,61 @@ 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()
|
||||||
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = formData.value as unknown as WmProductReceiptVO
|
const data = formData.value as unknown as WmProductReceiptVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
const res = await WmProductReceiptApi.createProductReceipt(data)
|
const res = await WmProductReceiptApi.createProductReceipt(data)
|
||||||
message.success('新增成功')
|
message.success('新增成功')
|
||||||
|
// 创建成功后,更新表单数据和状态为编辑模式
|
||||||
formData.value.id = res
|
formData.value.id = res
|
||||||
|
formData.value.status = MesWmProductReceiptStatusEnum.PREPARE
|
||||||
formType.value = 'update'
|
formType.value = 'update'
|
||||||
} else {
|
} else {
|
||||||
await WmProductReceiptApi.updateProductReceipt(data)
|
await WmProductReceiptApi.updateProductReceipt(data)
|
||||||
message.success('修改成功')
|
message.success('修改成功')
|
||||||
}
|
}
|
||||||
|
// 更新快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
|
// 发送操作成功的事件
|
||||||
emit('success')
|
emit('success')
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 提交操作:表单修改过则先保存,再提交 */
|
||||||
|
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 WmProductReceiptVO
|
||||||
|
await WmProductReceiptApi.updateProductReceipt(data)
|
||||||
|
}
|
||||||
|
// 2. 提交入库单
|
||||||
|
await WmProductReceiptApi.submitProductReceipt(formData.value.id!)
|
||||||
|
message.success('提交成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 执行上架 */
|
/** 执行上架 */
|
||||||
const handleStock = async () => {
|
const handleStock = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -190,16 +241,34 @@ const handleStock = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 执行入库 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认执行入库?执行后将更新库存台账。')
|
||||||
|
formLoading.value = true
|
||||||
|
await WmProductReceiptApi.finishProductReceipt(formData.value.id!)
|
||||||
|
message.success('入库成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
status: undefined,
|
||||||
workOrderId: undefined,
|
workOrderId: undefined,
|
||||||
receiptDate: undefined,
|
receiptDate: undefined,
|
||||||
remark: undefined
|
remark: undefined
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,13 @@
|
||||||
|
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
<el-table-column label="入库单编号" align="center" prop="code" min-width="160" />
|
<el-table-column label="入库单编号" align="center" prop="code" min-width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" @click="openForm('detail', scope.row.id)">
|
||||||
|
{{ scope.row.code }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="入库单名称" align="center" prop="name" min-width="150" />
|
<el-table-column label="入库单名称" align="center" prop="name" min-width="150" />
|
||||||
<el-table-column label="生产工单" align="center" prop="workOrderCode" min-width="140" />
|
<el-table-column label="生产工单" align="center" prop="workOrderCode" min-width="140" />
|
||||||
<el-table-column label="产品物料编码" align="center" prop="itemCode" min-width="120" />
|
<el-table-column label="产品物料编码" align="center" prop="itemCode" min-width="120" />
|
||||||
|
|
@ -78,7 +84,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" width="240" fixed="right">
|
<el-table-column label="操作" align="center" width="240" fixed="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<!-- 草稿:编辑、提交、删除 -->
|
<!-- 草稿:编辑、删除 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|
@ -88,15 +94,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="warning"
|
|
||||||
@click="handleSubmit(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:wm-product-receipt:update']"
|
|
||||||
v-if="scope.row.status === MesWmProductReceiptStatusEnum.PREPARE"
|
|
||||||
>
|
|
||||||
提交
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -106,7 +103,7 @@
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 待拣货:执行上架 -->
|
<!-- 待上架:执行上架、取消 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="success"
|
type="success"
|
||||||
|
|
@ -116,17 +113,16 @@
|
||||||
>
|
>
|
||||||
执行上架
|
执行上架
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 待执行入库:执行入库 -->
|
<!-- 待执行入库:执行入库、取消 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="success"
|
||||||
@click="handleFinish(scope.row.id)"
|
@click="openForm('finish', scope.row.id)"
|
||||||
v-hasPermi="['mes:wm-product-receipt:finish']"
|
v-hasPermi="['mes:wm-product-receipt:finish']"
|
||||||
v-if="scope.row.status === MesWmProductReceiptStatusEnum.APPROVED"
|
v-if="scope.row.status === MesWmProductReceiptStatusEnum.APPROVED"
|
||||||
>
|
>
|
||||||
执行入库
|
执行入库
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 待拣货、待执行入库:取消 -->
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -167,13 +163,13 @@ import { MesWmProductReceiptStatusEnum } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'MesWmProductReceipt' })
|
defineOptions({ name: 'MesWmProductReceipt' })
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n()
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
const loading = ref(true)
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<WmProductReceiptVO[]>([])
|
const list = ref<WmProductReceiptVO[]>([]) // 列表的数据
|
||||||
const total = ref(0)
|
const total = ref(0) // 列表的总页数
|
||||||
const exportLoading = ref(false)
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
|
|
@ -182,8 +178,8 @@ const queryParams = reactive({
|
||||||
workOrderId: undefined,
|
workOrderId: undefined,
|
||||||
itemId: undefined
|
itemId: undefined
|
||||||
})
|
})
|
||||||
const queryFormRef = ref()
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const formRef = ref()
|
const formRef = ref() // 表单弹窗
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
|
|
@ -214,26 +210,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 WmProductReceiptApi.submitProductReceipt(id)
|
|
||||||
message.success('提交成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 执行入库 */
|
|
||||||
const handleFinish = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.confirm('确认执行入库?执行后将更新库存台账。')
|
|
||||||
await WmProductReceiptApi.finishProductReceipt(id)
|
|
||||||
message.success('入库成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 取消按钮操作 */
|
/** 取消按钮操作 */
|
||||||
const handleCancel = async (id: number) => {
|
const handleCancel = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue