ERP:初始化销售退货逻辑 70%(详情)

This commit is contained in:
YunaiV 2024-02-12 06:29:03 +08:00
parent 949096f776
commit 3860aaef6f
5 changed files with 41 additions and 44 deletions

View File

@ -152,7 +152,6 @@ const props = defineProps<{
const formLoading = ref(false) // const formLoading = ref(false) //
const formData = ref([]) const formData = ref([])
const formRules = reactive({ const formRules = reactive({
inId: [{ required: true, message: '出库编号不能为空', trigger: 'blur' }],
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }], productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }] count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
}) })

View File

@ -186,7 +186,6 @@ const props = defineProps<{
const formLoading = ref(false) // const formLoading = ref(false) //
const formData = ref([]) const formData = ref([])
const formRules = reactive({ const formRules = reactive({
inId: [{ required: true, message: '出库编号不能为空', trigger: 'blur' }],
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }], warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }],
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }], productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }] count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]

View File

@ -10,17 +10,17 @@
> >
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="出库单号" prop="no"> <el-form-item label="退货单号" prop="no">
<el-input disabled v-model="formData.no" placeholder="保存时自动生成" /> <el-input disabled v-model="formData.no" placeholder="保存时自动生成" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="出库时间" prop="outTime"> <el-form-item label="退货时间" prop="outTime">
<el-date-picker <el-date-picker
v-model="formData.outTime" v-model="formData.returnTime"
type="date" type="date"
value-format="x" value-format="x"
placeholder="选择出库时间" placeholder="选择退货时间"
class="!w-1/1" class="!w-1/1"
/> />
</el-form-item> </el-form-item>
@ -29,7 +29,7 @@
<el-form-item label="关联订单" prop="orderNo"> <el-form-item label="关联订单" prop="orderNo">
<el-input v-model="formData.orderNo" readonly> <el-input v-model="formData.orderNo" readonly>
<template #append> <template #append>
<el-button @click="openSaleOrderOutEnableList"> <el-button @click="openSaleOrderReturnEnableList">
<Icon icon="ep:search" /> 选择 <Icon icon="ep:search" /> 选择
</el-button> </el-button>
</template> </template>
@ -91,8 +91,8 @@
<!-- 子表的表单 --> <!-- 子表的表单 -->
<ContentWrap> <ContentWrap>
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px"> <el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
<el-tab-pane label="出库产品清单" name="item"> <el-tab-pane label="退货产品清单" name="item">
<SaleOutItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" /> <SaleReturnItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</ContentWrap> </ContentWrap>
@ -110,7 +110,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="款优惠" prop="discountPrice"> <el-form-item label="退款优惠" prop="discountPrice">
<el-input <el-input
disabled disabled
v-model="formData.discountPrice" v-model="formData.discountPrice"
@ -154,13 +154,13 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="本次收款" prop="payPrice"> <el-form-item label="本次退款" prop="refundPrice">
<el-input-number <el-input-number
v-model="formData.payPrice" v-model="formData.refundPrice"
controls-position="right" controls-position="right"
:min="0" :min="0"
:precision="2" :precision="2"
placeholder="请输入本次款" placeholder="请输入本次退款"
class="!w-1/1" class="!w-1/1"
/> />
</el-form-item> </el-form-item>
@ -175,21 +175,21 @@
</template> </template>
</Dialog> </Dialog>
<!-- 出库的订单列表 --> <!-- 退货的订单列表 -->
<SaleOrderOutEnableList ref="saleOrderOutEnableListRef" @success="handleSaleOrderChange" /> <!-- <SaleOrderReturnEnableList ref="saleOrderReturnEnableListRef" @success="handleSaleOrderChange" />-->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { SaleOutApi, SaleOutVO } from '@/api/erp/sale/out' import { SaleReturnApi, SaleReturnVO } from '@/api/erp/sale/return'
import SaleOutItemForm from './components/SaleOutItemForm.vue' import SaleReturnItemForm from './components/SaleReturnItemForm.vue'
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer' import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
import { AccountApi, AccountVO } from '@/api/erp/finance/account' import { AccountApi, AccountVO } from '@/api/erp/finance/account'
import { erpPriceInputFormatter, erpPriceMultiply } from '@/utils' import { erpPriceInputFormatter, erpPriceMultiply } from '@/utils'
import SaleOrderOutEnableList from '@/views/erp/sale/order/components/SaleOrderOutEnableList.vue' // import SaleOrderReturnEnableList from '@/views/erp/sale/order/components/SaleOrderReturnEnableList.vue'
import { SaleOrderVO } from '@/api/erp/sale/order' import { SaleOrderVO } from '@/api/erp/sale/order'
import * as UserApi from '@/api/system/user' import * as UserApi from '@/api/system/user'
/** ERP 销售出库表单 */ /** ERP 销售退货表单 */
defineOptions({ name: 'SaleOutForm' }) defineOptions({ name: 'SaleReturnForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -203,22 +203,22 @@ const formData = ref({
customerId: undefined, customerId: undefined,
accountId: undefined, accountId: undefined,
saleUserId: undefined, saleUserId: undefined,
outTime: undefined, returnTime: undefined,
remark: undefined, remark: undefined,
fileUrl: '', fileUrl: '',
discountPercent: 0, discountPercent: 0,
discountPrice: 0, discountPrice: 0,
totalPrice: 0, totalPrice: 0,
otherPrice: 0, otherPrice: 0,
payPrice: undefined, refundPrice: undefined,
orderNo: undefined, orderNo: undefined,
items: [], items: [],
no: undefined // no: undefined // 退
}) })
const formRules = reactive({ const formRules = reactive({
customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }], customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
outTime: [{ required: true, message: '出库时间不能为空', trigger: 'blur' }], returnTime: [{ required: true, message: '退货时间不能为空', trigger: 'blur' }],
payPrice: [{ required: true, message: '本次款不能为空', trigger: 'blur' }] refundPrice: [{ required: true, message: '本次退款不能为空', trigger: 'blur' }]
}) })
const disabled = computed(() => formType.value === 'detail') const disabled = computed(() => formType.value === 'detail')
const formRef = ref() // Ref const formRef = ref() // Ref
@ -242,13 +242,13 @@ watch(
const discountPrice = const discountPrice =
val.discountPercent != null ? erpPriceMultiply(totalPrice, val.discountPercent / 100.0) : 0 val.discountPercent != null ? erpPriceMultiply(totalPrice, val.discountPercent / 100.0) : 0
// debugger // debugger
// TODO payPrice // TODO refundPrice
// const payPrice = totalPrice - discountPrice + val.otherPrice // const refundPrice = totalPrice - discountPrice + val.otherPrice
// //
formData.value.discountPrice = discountPrice formData.value.discountPrice = discountPrice
formData.value.totalPrice = totalPrice - discountPrice formData.value.totalPrice = totalPrice - discountPrice
// val.payPrice = payPrice // val.refundPrice = refundPrice
// formData.value.payPrice = payPrice // formData.value.refundPrice = refundPrice
}, },
{ deep: true } { deep: true }
) )
@ -263,7 +263,7 @@ const open = async (type: string, id?: number) => {
if (id) { if (id) {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await SaleOutApi.getSaleOut(id) formData.value = await SaleReturnApi.getSaleReturn(id)
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
@ -281,14 +281,14 @@ const open = async (type: string, id?: number) => {
} }
defineExpose({ open }) // open defineExpose({ open }) // open
/** 打开【可出库的订单列表】弹窗 */ /** 打开【可退货的订单列表】弹窗 */
const saleOrderOutEnableListRef = ref() // Ref const saleOrderReturnEnableListRef = ref() // 退 Ref
const openSaleOrderOutEnableList = () => { const openSaleOrderReturnEnableList = () => {
saleOrderOutEnableListRef.value.open() saleOrderReturnEnableListRef.value.open()
} }
const handleSaleOrderChange = (order: SaleOrderVO) => { const handleSaleOrderChange = (order: SaleOrderVO) => {
// // 退
formData.value.orderId = order.id formData.value.orderId = order.id
formData.value.orderNo = order.no formData.value.orderNo = order.no
formData.value.customerId = order.customerId formData.value.customerId = order.customerId
@ -297,10 +297,10 @@ const handleSaleOrderChange = (order: SaleOrderVO) => {
formData.value.discountPercent = order.discountPercent formData.value.discountPercent = order.discountPercent
formData.value.remark = order.remark formData.value.remark = order.remark
formData.value.fileUrl = order.fileUrl formData.value.fileUrl = order.fileUrl
// // 退
order.items.forEach((item) => { order.items.forEach((item) => {
item.totalCount = item.count item.totalCount = item.count
item.count = item.totalCount - item.outCount item.count = item.totalCount - item.returnCount
item.orderItemId = item.id item.orderItemId = item.id
item.id = undefined item.id = undefined
}) })
@ -316,12 +316,12 @@ const submitForm = async () => {
// //
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as unknown as SaleOutVO const data = formData.value as unknown as SaleReturnVO
if (formType.value === 'create') { if (formType.value === 'create') {
await SaleOutApi.createSaleOut(data) await SaleReturnApi.createSaleReturn(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await SaleOutApi.updateSaleOut(data) await SaleReturnApi.updateSaleReturn(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
dialogVisible.value = false dialogVisible.value = false
@ -339,14 +339,14 @@ const resetForm = () => {
customerId: undefined, customerId: undefined,
accountId: undefined, accountId: undefined,
saleUserId: undefined, saleUserId: undefined,
outTime: undefined, returnTime: undefined,
remark: undefined, remark: undefined,
fileUrl: undefined, fileUrl: undefined,
discountPercent: 0, discountPercent: 0,
discountPrice: 0, discountPrice: 0,
totalPrice: 0, totalPrice: 0,
otherPrice: 0, otherPrice: 0,
payPrice: undefined, refundPrice: undefined,
items: [] items: []
} }
formRef.value?.resetFields() formRef.value?.resetFields()

View File

@ -186,7 +186,6 @@ const props = defineProps<{
const formLoading = ref(false) // const formLoading = ref(false) //
const formData = ref([]) const formData = ref([])
const formRules = reactive({ const formRules = reactive({
inId: [{ required: true, message: '出库编号不能为空', trigger: 'blur' }],
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }], warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }],
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }], productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }] count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]

View File

@ -287,7 +287,7 @@
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<SaleOutForm ref="formRef" @success="getList" /> <SaleReturnForm ref="formRef" @success="getList" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">