✨ feat(mes): 优化退货单操作逻辑,简化提交与完成流程
parent
1f2a0904f4
commit
5856838c73
|
|
@ -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" :disabled="isHeaderReadonly">
|
<el-button @click="generateCode" :disabled="isHeaderReadonly"> 生成 </el-button>
|
||||||
生成
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -104,13 +103,24 @@
|
||||||
<ReturnVendorLineList :return-id="formData.id" :form-type="formType" />
|
<ReturnVendorLineList :return-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 === MesWmReturnVendorStatusEnum.PREPARE) || isSubmit"
|
||||||
|
@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>
|
||||||
|
|
@ -120,22 +130,38 @@ import { WmReturnVendorApi, WmReturnVendorVO } from '@/api/mes/wm/returnvendor'
|
||||||
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
|
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
|
||||||
import MdVendorSelect from '@/views/mes/md/vendor/components/MdVendorSelect.vue'
|
import MdVendorSelect from '@/views/mes/md/vendor/components/MdVendorSelect.vue'
|
||||||
import ReturnVendorLineList from './ReturnVendorLineList.vue'
|
import ReturnVendorLineList from './ReturnVendorLineList.vue'
|
||||||
import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
import { MesAutoCodeRuleCode, MesWmReturnVendorStatusEnum } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'ReturnVendorForm' })
|
defineOptions({ name: 'ReturnVendorForm' })
|
||||||
|
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 / stock / finish / detail
|
||||||
|
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,
|
||||||
|
status: undefined as number | undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
purchaseOrderCode: undefined,
|
purchaseOrderCode: undefined,
|
||||||
vendorId: undefined,
|
vendorId: undefined,
|
||||||
|
|
||||||
returnDate: undefined,
|
returnDate: undefined,
|
||||||
returnReason: undefined,
|
returnReason: undefined,
|
||||||
transportCode: undefined,
|
transportCode: undefined,
|
||||||
|
|
@ -149,19 +175,7 @@ const formRules = reactive({
|
||||||
returnDate: [{ required: true, message: '退货日期不能为空', trigger: 'change' }]
|
returnDate: [{ 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 () => {
|
||||||
|
|
@ -175,7 +189,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 {
|
||||||
|
|
@ -184,11 +198,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()
|
||||||
|
|
@ -199,12 +213,16 @@ const submitForm = async () => {
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
const res = await WmReturnVendorApi.createReturnVendor(data)
|
const res = await WmReturnVendorApi.createReturnVendor(data)
|
||||||
message.success('新增成功')
|
message.success('新增成功')
|
||||||
|
// 创建成功后,更新表单数据和状态为编辑模式
|
||||||
formData.value.id = res
|
formData.value.id = res
|
||||||
|
formData.value.status = MesWmReturnVendorStatusEnum.PREPARE
|
||||||
formType.value = 'update'
|
formType.value = 'update'
|
||||||
} else {
|
} else {
|
||||||
await WmReturnVendorApi.updateReturnVendor(data)
|
await WmReturnVendorApi.updateReturnVendor(data)
|
||||||
message.success('修改成功')
|
message.success('修改成功')
|
||||||
}
|
}
|
||||||
|
// 更新快照
|
||||||
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
// 发送操作成功的事件
|
// 发送操作成功的事件
|
||||||
emit('success')
|
emit('success')
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -212,6 +230,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 WmReturnVendorVO
|
||||||
|
await WmReturnVendorApi.updateReturnVendor(data)
|
||||||
|
}
|
||||||
|
// 2. 提交退货单
|
||||||
|
await WmReturnVendorApi.submitReturnVendor(formData.value.id!)
|
||||||
|
message.success('提交成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 执行拣货 */
|
/** 执行拣货 */
|
||||||
const handleStock = async () => {
|
const handleStock = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -231,15 +272,30 @@ const handleStock = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 完成退货 */
|
||||||
|
const handleFinish = async () => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认完成该退货单并执行退货?')
|
||||||
|
formLoading.value = true
|
||||||
|
await WmReturnVendorApi.finishReturnVendor(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,
|
||||||
|
status: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
purchaseOrderCode: undefined,
|
purchaseOrderCode: undefined,
|
||||||
vendorId: undefined,
|
vendorId: undefined,
|
||||||
|
|
||||||
returnDate: undefined,
|
returnDate: undefined,
|
||||||
returnReason: undefined,
|
returnReason: undefined,
|
||||||
transportCode: undefined,
|
transportCode: undefined,
|
||||||
|
|
@ -248,4 +304,6 @@ const resetForm = () => {
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,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"
|
||||||
|
|
@ -98,15 +98,6 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="warning"
|
|
||||||
@click="handleSubmit(scope.row.id)"
|
|
||||||
v-hasPermi="['mes:wm-return-vendor:update']"
|
|
||||||
v-if="scope.row.status === MesWmReturnVendorStatusEnum.PREPARE"
|
|
||||||
>
|
|
||||||
提交
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -116,7 +107,7 @@
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 待拣货:执行拣货 -->
|
<!-- 待拣货:执行拣货、取消 -->
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="success"
|
type="success"
|
||||||
|
|
@ -126,17 +117,16 @@
|
||||||
>
|
>
|
||||||
执行拣货
|
执行拣货
|
||||||
</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-vendor:update-status']"
|
v-hasPermi="['mes:wm-return-vendor:update-status']"
|
||||||
v-if="scope.row.status === MesWmReturnVendorStatusEnum.APPROVED"
|
v-if="scope.row.status === MesWmReturnVendorStatusEnum.APPROVED"
|
||||||
>
|
>
|
||||||
完成
|
完成退货
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- 待拣货、待执行退货:取消 -->
|
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="danger"
|
type="danger"
|
||||||
|
|
@ -223,16 +213,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 WmReturnVendorApi.submitReturnVendor(id)
|
|
||||||
message.success('提交成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -253,16 +233,6 @@ const handleCancel = async (id: number) => {
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成按钮操作 */
|
|
||||||
const handleFinish = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await message.confirm('确认完成该退货单并执行退货?')
|
|
||||||
await WmReturnVendorApi.finishReturnVendor(id)
|
|
||||||
message.success('完成成功')
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue