feat(mes): 新增执行退货功能及相关逻辑优化

pull/871/MERGE
YunaiV 2026-03-30 19:22:29 +08:00
parent 696069e212
commit 64e7b17631
2 changed files with 38 additions and 26 deletions

View File

@ -6,6 +6,7 @@
:rules="formRules"
label-width="110px"
v-loading="formLoading"
:disabled="isDetail"
>
<el-row>
<el-col :span="8">
@ -16,9 +17,7 @@
:disabled="isHeaderReadonly"
>
<template #append>
<el-button @click="generateCode">
生成
</el-button>
<el-button @click="generateCode" :disabled="isHeaderReadonly"> 生成 </el-button>
</template>
</el-input>
</el-form-item>
@ -55,8 +54,8 @@
type="date"
value-format="x"
placeholder="选择退货日期"
class="!w-1/1"
:disabled="isHeaderReadonly"
class="!w-full"
/>
</el-form-item>
</el-col>
@ -106,6 +105,9 @@
<el-button v-if="isStock" @click="handleStock" type="primary" :disabled="formLoading">
执行上架
</el-button>
<el-button v-if="isFinish" @click="handleFinish" type="success" :disabled="formLoading">
执行退货
</el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
@ -122,18 +124,22 @@ defineOptions({ name: 'ReturnSalesForm' })
const emit = defineEmits(['success'])
const message = useMessage() //
const dialogVisible = 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 isHeaderReadonly = computed(() => ['stock', 'detail'].includes(formType.value)) //
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
@ -142,11 +148,11 @@ const formData = ref({
id: undefined as number | undefined,
code: undefined,
name: undefined,
status: undefined as number | undefined,
salesOrderCode: undefined,
clientId: undefined,
returnDate: undefined,
returnReason: undefined,
status: undefined as number | undefined,
remark: undefined
})
const formRules = reactive({
@ -171,7 +177,7 @@ const open = async (type: string, id?: number) => {
dialogVisible.value = true
formType.value = type
resetForm()
// //
// //退/
if (id) {
formLoading.value = true
try {
@ -183,9 +189,8 @@ const open = async (type: string, id?: number) => {
//
originalFormData.value = JSON.stringify(formData.value)
}
defineExpose({ open })
/** 保存表单create/update 模式的保存按钮 */
/** 保存表单create/update 模式 */
const submitForm = async () => {
//
await formRef.value.validate()
@ -251,19 +256,36 @@ const handleStock = async () => {
}
}
/** 执行退货 */
const handleFinish = async () => {
try {
await message.confirm('确认执行退货?执行后将进入待上架状态。')
formLoading.value = true
await WmReturnSalesApi.finishReturnSales(formData.value.id!)
message.success('执行退货成功')
dialogVisible.value = false
emit('success')
} catch {
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
code: undefined,
name: undefined,
status: undefined,
salesOrderCode: undefined,
clientId: undefined,
returnDate: undefined,
returnReason: undefined,
status: undefined,
remark: undefined
}
formRef.value?.resetFields()
}
defineExpose({ open })
</script>

View File

@ -118,17 +118,17 @@
>
执行质检
</el-button>
<!-- 待执行执行退货 -->
<!-- 待执行执行退货进入弹窗 -->
<el-button
link
type="primary"
@click="handleFinish(scope.row.id)"
type="success"
@click="openForm('finish', scope.row.id)"
v-hasPermi="['mes:wm-return-sales:finish']"
v-if="scope.row.status === MesWmReturnSalesStatusEnum.APPROVING"
>
执行退货
</el-button>
<!-- 待上架执行上架 -->
<!-- 待上架执行上架进入弹窗 -->
<el-button
link
type="success"
@ -226,16 +226,6 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 执行退货 */
const handleFinish = async (id: number) => {
try {
await message.confirm('确认执行退货?')
await WmReturnSalesApi.finishReturnSales(id)
message.success('执行成功')
await getList()
} catch {}
}
/** 取消按钮操作 */
const handleCancel = async (id: number) => {
try {