✨ feat(mes): 优化退料单功能,新增提交和执行退料操作
parent
91b2fbb659
commit
4ec4c4dd09
|
|
@ -213,10 +213,6 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 取消按钮操作 */
|
/** 取消按钮操作 */
|
||||||
const handleCancel = async (id: number) => {
|
const handleCancel = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -89,13 +89,24 @@
|
||||||
<ReturnIssueLineList :issue-id="formData.id" :form-type="formType" />
|
<ReturnIssueLineList :issue-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 === MesWmReturnIssueStatusEnum.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>
|
||||||
|
|
@ -104,22 +115,41 @@
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { WmReturnIssueApi, WmReturnIssueVO } from '@/api/mes/wm/returnissue'
|
import { WmReturnIssueApi, WmReturnIssueVO } from '@/api/mes/wm/returnissue'
|
||||||
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, MesWmReturnIssueStatusEnum } from '@/views/mes/utils/constants'
|
||||||
import ProWorkOrderSelect from '@/views/mes/pro/workorder/components/ProWorkOrderSelect.vue'
|
import ProWorkOrderSelect from '@/views/mes/pro/workorder/components/ProWorkOrderSelect.vue'
|
||||||
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
||||||
import ReturnIssueLineList from './ReturnIssueLineList.vue'
|
import ReturnIssueLineList from './ReturnIssueLineList.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'ReturnIssueForm' })
|
defineOptions({ name: 'ReturnIssueForm' })
|
||||||
|
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 / detail
|
const formType = ref<string>('create') // 表单的类型:create / update / submit / stock / finish / detail
|
||||||
|
const isEditable = computed(() => ['create', 'update', 'submit'].includes(formType.value)) // 是否为编辑模式
|
||||||
|
const isStock = computed(() => formType.value === 'stock') // 是否为入库上架模式
|
||||||
|
const isFinish = computed(() => formType.value === 'finish') // 是否为执行退料模式
|
||||||
|
const isHeaderReadonly = computed(() =>
|
||||||
|
['stock', 'detail', 'finish'].includes(formType.value)
|
||||||
|
) // 表头是否只读
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
const titles = {
|
||||||
|
create: '新增生产退料单',
|
||||||
|
update: '编辑生产退料单',
|
||||||
|
submit: '提交生产退料单',
|
||||||
|
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,
|
||||||
workstationId: undefined,
|
workstationId: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
|
|
@ -133,19 +163,7 @@ const formRules = reactive({
|
||||||
workOrderId: [{ required: true, message: '生产工单不能为空', trigger: 'change' }]
|
workOrderId: [{ 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 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 = async () => {
|
const generateCode = async () => {
|
||||||
|
|
@ -159,7 +177,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 {
|
||||||
|
|
@ -168,11 +186,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/submit 模式的保存按钮) */
|
||||||
const emit = defineEmits(['success'])
|
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
// 校验表单
|
// 校验表单
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
|
|
@ -183,12 +201,16 @@ const submitForm = async () => {
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
const res = await WmReturnIssueApi.createReturnIssue(data)
|
const res = await WmReturnIssueApi.createReturnIssue(data)
|
||||||
message.success('新增成功')
|
message.success('新增成功')
|
||||||
|
// 创建成功后,更新表单数据和状态为编辑模式
|
||||||
formData.value.id = res
|
formData.value.id = res
|
||||||
|
formData.value.status = MesWmReturnIssueStatusEnum.PREPARE
|
||||||
formType.value = 'update'
|
formType.value = 'update'
|
||||||
} else {
|
} else {
|
||||||
await WmReturnIssueApi.updateReturnIssue(data)
|
await WmReturnIssueApi.updateReturnIssue(data)
|
||||||
message.success('修改成功')
|
message.success('修改成功')
|
||||||
}
|
}
|
||||||
|
// 更新快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
// 发送操作成功的事件
|
// 发送操作成功的事件
|
||||||
emit('success')
|
emit('success')
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -196,6 +218,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 WmReturnIssueVO
|
||||||
|
await WmReturnIssueApi.updateReturnIssue(data)
|
||||||
|
}
|
||||||
|
// 2. 提交退料单
|
||||||
|
await WmReturnIssueApi.submitReturnIssue(formData.value.id!)
|
||||||
|
message.success('提交成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 入库上架 */
|
/** 入库上架 */
|
||||||
const handleStock = async () => {
|
const handleStock = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -210,12 +255,28 @@ const handleStock = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 执行退料 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认完成该退料单并执行入库吗?')
|
||||||
|
formLoading.value = true
|
||||||
|
await WmReturnIssueApi.finishReturnIssue(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,
|
||||||
workstationId: undefined,
|
workstationId: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
|
|
@ -224,4 +285,6 @@ const resetForm = () => {
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="物料">
|
<el-form-item label="物料">
|
||||||
<el-input :model-value="stockInfo.itemName" disabled placeholder="选择库存后自动带出" />
|
<MdItemSelect v-model="formData.itemId" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
|
|
@ -123,11 +123,6 @@
|
||||||
<el-input :model-value="formData.batchCode" disabled placeholder="选择库存后自动带出" />
|
<el-input :model-value="formData.batchCode" disabled placeholder="选择库存后自动带出" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
|
||||||
<el-form-item label="库存数量">
|
|
||||||
<el-input :model-value="stockInfo.stockQuantity" disabled placeholder="选择库存后自动带出" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
|
|
@ -158,6 +153,7 @@ import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { WmReturnIssueLineApi, WmReturnIssueLineVO } from '@/api/mes/wm/returnissue/line'
|
import { WmReturnIssueLineApi, WmReturnIssueLineVO } from '@/api/mes/wm/returnissue/line'
|
||||||
import { WmMaterialStockVO } from '@/api/mes/wm/materialstock'
|
import { WmMaterialStockVO } from '@/api/mes/wm/materialstock'
|
||||||
import WmMaterialStockSelect from '@/views/mes/wm/materialstock/components/WmMaterialStockSelect.vue'
|
import WmMaterialStockSelect from '@/views/mes/wm/materialstock/components/WmMaterialStockSelect.vue'
|
||||||
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
import ReturnIssueDetailList from './ReturnIssueDetailList.vue'
|
import ReturnIssueDetailList from './ReturnIssueDetailList.vue'
|
||||||
import ReturnIssueDetailForm from './ReturnIssueDetailForm.vue'
|
import ReturnIssueDetailForm from './ReturnIssueDetailForm.vue'
|
||||||
import { BarcodeDetail } from '@/views/mes/wm/barcode/components'
|
import { BarcodeDetail } from '@/views/mes/wm/barcode/components'
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,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"
|
||||||
|
|
@ -108,15 +108,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="warning"
|
|
||||||
@click="handleSubmit(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:wm-return-issue:update']"
|
|
||||||
v-if="scope.row.status === MesWmReturnIssueStatusEnum.PREPARE"
|
|
||||||
>
|
|
||||||
提交
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -126,6 +117,15 @@
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<!-- 待检验:执行质检(提示去质检模块操作) -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="warning"
|
||||||
|
v-if="scope.row.status === MesWmReturnIssueStatusEnum.CONFIRMED"
|
||||||
|
@click="message.alert('请前往【质量管理 - 退货检验(RQC)】中进行退料检验操作')"
|
||||||
|
>
|
||||||
|
执行质检
|
||||||
|
</el-button>
|
||||||
<!-- 待上架:执行上架 -->
|
<!-- 待上架:执行上架 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
|
|
@ -136,26 +136,28 @@
|
||||||
>
|
>
|
||||||
执行上架
|
执行上架
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 已入库:执行退料 -->
|
<!-- 待执行退料:执行退料 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="success"
|
type="success"
|
||||||
@click="handleFinish(scope.row.id)"
|
@click="openForm('finish', scope.row.id)"
|
||||||
v-hasPermi="['mes:wm-return-issue:finish']"
|
v-hasPermi="['mes:wm-return-issue:finish']"
|
||||||
v-if="scope.row.status === MesWmReturnIssueStatusEnum.APPROVED"
|
v-if="scope.row.status === MesWmReturnIssueStatusEnum.APPROVED"
|
||||||
>
|
>
|
||||||
执行退料
|
执行退料
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 待入库、已入库:取消 -->
|
<!-- 待检验、待上架、待执行退料:取消 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleCancel(scope.row.id)"
|
@click="handleCancel(scope.row.id)"
|
||||||
v-hasPermi="['mes:wm-return-issue:update']"
|
v-hasPermi="['mes:wm-return-issue:update']"
|
||||||
v-if="
|
v-if="
|
||||||
[MesWmReturnIssueStatusEnum.APPROVING, MesWmReturnIssueStatusEnum.APPROVED].includes(
|
[
|
||||||
scope.row.status
|
MesWmReturnIssueStatusEnum.CONFIRMED,
|
||||||
)
|
MesWmReturnIssueStatusEnum.APPROVING,
|
||||||
|
MesWmReturnIssueStatusEnum.APPROVED
|
||||||
|
].includes(scope.row.status)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
取消
|
取消
|
||||||
|
|
@ -232,26 +234,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 WmReturnIssueApi.submitReturnIssue(id)
|
|
||||||
message.success('提交成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
const handleDelete = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.delConfirm()
|
|
||||||
await WmReturnIssueApi.deleteReturnIssue(id)
|
|
||||||
message.success(t('common.delSuccess'))
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 取消按钮操作 */
|
/** 取消按钮操作 */
|
||||||
const handleCancel = async (id: number) => {
|
const handleCancel = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -262,12 +244,12 @@ const handleCancel = async (id: number) => {
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleFinish = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
await message.confirm('确认完成该退料单并执行入库吗?')
|
await message.delConfirm()
|
||||||
await WmReturnIssueApi.finishReturnIssue(id)
|
await WmReturnIssueApi.deleteReturnIssue(id)
|
||||||
message.success('完成成功')
|
message.success(t('common.delSuccess'))
|
||||||
await getList()
|
await getList()
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
@ -285,6 +267,7 @@ const handleExport = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue