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" :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>
@ -55,8 +54,8 @@
type="date" type="date"
value-format="x" value-format="x"
placeholder="选择退货日期" placeholder="选择退货日期"
class="!w-1/1"
:disabled="isHeaderReadonly" :disabled="isHeaderReadonly"
class="!w-full"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -106,6 +105,9 @@
<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 v-if="isFinish" @click="handleFinish" type="success" :disabled="formLoading">
执行退货
</el-button>
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
</template> </template>
</Dialog> </Dialog>
@ -122,18 +124,22 @@ defineOptions({ name: 'ReturnSalesForm' })
const emit = defineEmits(['success']) 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 isEditable = computed(() => ['create', 'update'].includes(formType.value)) //
const isStock = computed(() => formType.value === 'stock') // 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 dialogTitle = computed(() => {
const titles = { const titles = {
create: '新增销售退货单', create: '新增销售退货单',
update: '编辑销售退货单', update: '编辑销售退货单',
stock: '执行上架', stock: '执行上架',
finish: '执行退货',
detail: '销售退货单详情' detail: '销售退货单详情'
} }
return titles[formType.value] || formType.value return titles[formType.value] || formType.value
@ -142,11 +148,11 @@ 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,
salesOrderCode: undefined, salesOrderCode: undefined,
clientId: undefined, clientId: undefined,
returnDate: undefined, returnDate: undefined,
returnReason: undefined, returnReason: undefined,
status: undefined as number | undefined,
remark: undefined remark: undefined
}) })
const formRules = reactive({ const formRules = reactive({
@ -171,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 {
@ -183,9 +189,8 @@ const open = async (type: string, id?: number) => {
// //
originalFormData.value = JSON.stringify(formData.value) originalFormData.value = JSON.stringify(formData.value)
} }
defineExpose({ open })
/** 保存表单create/update 模式的保存按钮 */ /** 保存表单create/update 模式 */
const submitForm = async () => { const submitForm = async () => {
// //
await formRef.value.validate() 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 = () => { const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
code: undefined, code: undefined,
name: undefined, name: undefined,
status: undefined,
salesOrderCode: undefined, salesOrderCode: undefined,
clientId: undefined, clientId: undefined,
returnDate: undefined, returnDate: undefined,
returnReason: undefined, returnReason: undefined,
status: undefined,
remark: undefined remark: undefined
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
defineExpose({ open })
</script> </script>

View File

@ -118,17 +118,17 @@
> >
执行质检 执行质检
</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-return-sales:finish']" v-hasPermi="['mes:wm-return-sales:finish']"
v-if="scope.row.status === MesWmReturnSalesStatusEnum.APPROVING" v-if="scope.row.status === MesWmReturnSalesStatusEnum.APPROVING"
> >
执行退货 执行退货
</el-button> </el-button>
<!-- 待上架执行上架 --> <!-- 待上架执行上架进入弹窗 -->
<el-button <el-button
link link
type="success" type="success"
@ -226,16 +226,6 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) 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) => { const handleCancel = async (id: number) => {
try { try {