ERP:增加 ERP 销售订单的实现 60%(详情)

This commit is contained in:
YunaiV 2024-02-10 00:50:56 +08:00
parent ab63660bf8
commit 5deabcf692
2 changed files with 60 additions and 15 deletions

View File

@ -58,7 +58,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form>
<!-- 子表的表单 --> <!-- 子表的表单 -->
<ContentWrap> <ContentWrap>
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px"> <el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
@ -67,6 +66,35 @@
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</ContentWrap> </ContentWrap>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="优惠率(%" prop="discountPercent">
<el-input-number
v-model="formData.discountPercent"
controls-position="right"
:min="0"
:precision="2"
placeholder="请输入优惠率"
class="!w-1/1"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="收款优惠" prop="discountPrice">
<el-input
disabled
v-model="formData.discountPrice"
:formatter="erpPriceInputFormatter"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="优惠后金额">
<el-input disabled v-model="formData.totalPrice" :formatter="erpPriceInputFormatter" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled"> <el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled">
@ -79,6 +107,7 @@
import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order' import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
import SaleOrderItemForm from './components/SaleOrderItemForm.vue' import SaleOrderItemForm from './components/SaleOrderItemForm.vue'
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer' import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
import { erpPriceInputFormatter, erpPriceMultiply, getSumValue } from '@/utils'
/** ERP 销售订单表单 */ /** ERP 销售订单表单 */
defineOptions({ name: 'SaleOrderForm' }) defineOptions({ name: 'SaleOrderForm' })
@ -96,6 +125,9 @@ const formData = ref({
orderTime: undefined, orderTime: undefined,
remark: undefined, remark: undefined,
fileUrl: '', fileUrl: '',
discountPercent: 0,
discountPrice: 0,
totalPrice: 0,
items: [], items: [],
no: undefined // no: undefined //
}) })
@ -110,6 +142,22 @@ const customerList = ref<CustomerVO[]>([]) // 客户列表
const subTabsName = ref('item') const subTabsName = ref('item')
const itemFormRef = ref() const itemFormRef = ref()
/** 计算 discountPrice、totalPrice 价格 */
watch(
() => formData.value,
(val) => {
if (!val) {
return
}
const totalPrice = val.items.reduce((prev, curr) => prev + curr.totalPrice, 0)
const discountPrice =
val.discountPercent != null ? erpPriceMultiply(totalPrice, val.discountPercent / 100.0) : 0
formData.value.discountPrice = discountPrice
formData.value.totalPrice = totalPrice - discountPrice
},
{ deep: true }
)
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
@ -163,6 +211,9 @@ const resetForm = () => {
orderTime: undefined, orderTime: undefined,
remark: undefined, remark: undefined,
fileUrl: undefined, fileUrl: undefined,
discountPercent: 0,
discountPrice: 0,
totalPrice: 0,
items: [] items: []
} }
formRef.value?.resetFields() formRef.value?.resetFields()

View File

@ -104,13 +104,7 @@
<template #default="{ row, $index }"> <template #default="{ row, $index }">
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!"> <el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!"> <el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
<el-input-number <el-input disabled v-model="row.taxPrice" :formatter="erpPriceInputFormatter" />
v-model="row.taxPrice"
controls-position="right"
:min="0.01"
:precision="2"
class="!w-100%"
/>
</el-form-item> </el-form-item>
</el-form-item> </el-form-item>
</template> </template>