✨ feat(mes): 新增执行退货功能及相关逻辑优化
parent
696069e212
commit
64e7b17631
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue