Skip to content

Commit 5deabcf

Browse files
committed
✨ ERP:增加 ERP 销售订单的实现 60%(详情)
1 parent ab63660 commit 5deabcf

File tree

2 files changed

+60
-15
lines changed

2 files changed

+60
-15
lines changed

src/views/erp/sale/order/SaleOrderForm.vue

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,43 @@
5858
</el-form-item>
5959
</el-col>
6060
</el-row>
61+
<!-- 子表的表单 -->
62+
<ContentWrap>
63+
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
64+
<el-tab-pane label="订单产品清单" name="item">
65+
<SaleOrderItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
66+
</el-tab-pane>
67+
</el-tabs>
68+
</ContentWrap>
69+
<el-row :gutter="20">
70+
<el-col :span="8">
71+
<el-form-item label="优惠率(%)" prop="discountPercent">
72+
<el-input-number
73+
v-model="formData.discountPercent"
74+
controls-position="right"
75+
:min="0"
76+
:precision="2"
77+
placeholder="请输入优惠率"
78+
class="!w-1/1"
79+
/>
80+
</el-form-item>
81+
</el-col>
82+
<el-col :span="8">
83+
<el-form-item label="收款优惠" prop="discountPrice">
84+
<el-input
85+
disabled
86+
v-model="formData.discountPrice"
87+
:formatter="erpPriceInputFormatter"
88+
/>
89+
</el-form-item>
90+
</el-col>
91+
<el-col :span="8">
92+
<el-form-item label="优惠后金额">
93+
<el-input disabled v-model="formData.totalPrice" :formatter="erpPriceInputFormatter" />
94+
</el-form-item>
95+
</el-col>
96+
</el-row>
6197
</el-form>
62-
<!-- 子表的表单 -->
63-
<ContentWrap>
64-
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
65-
<el-tab-pane label="订单产品清单" name="item">
66-
<SaleOrderItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
67-
</el-tab-pane>
68-
</el-tabs>
69-
</ContentWrap>
7098
<template #footer>
7199
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled">
72100
确 定
@@ -79,6 +107,7 @@
79107
import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
80108
import SaleOrderItemForm from './components/SaleOrderItemForm.vue'
81109
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
110+
import { erpPriceInputFormatter, erpPriceMultiply, getSumValue } from '@/utils'
82111
83112
/** ERP 销售订单表单 */
84113
defineOptions({ name: 'SaleOrderForm' })
@@ -96,6 +125,9 @@ const formData = ref({
96125
orderTime: undefined,
97126
remark: undefined,
98127
fileUrl: '',
128+
discountPercent: 0,
129+
discountPrice: 0,
130+
totalPrice: 0,
99131
items: [],
100132
no: undefined // 订单单号,后端返回
101133
})
@@ -110,6 +142,22 @@ const customerList = ref<CustomerVO[]>([]) // 客户列表
110142
const subTabsName = ref('item')
111143
const itemFormRef = ref()
112144
145+
/** 计算 discountPrice、totalPrice 价格 */
146+
watch(
147+
() => formData.value,
148+
(val) => {
149+
if (!val) {
150+
return
151+
}
152+
const totalPrice = val.items.reduce((prev, curr) => prev + curr.totalPrice, 0)
153+
const discountPrice =
154+
val.discountPercent != null ? erpPriceMultiply(totalPrice, val.discountPercent / 100.0) : 0
155+
formData.value.discountPrice = discountPrice
156+
formData.value.totalPrice = totalPrice - discountPrice
157+
},
158+
{ deep: true }
159+
)
160+
113161
/** 打开弹窗 */
114162
const open = async (type: string, id?: number) => {
115163
dialogVisible.value = true
@@ -163,6 +211,9 @@ const resetForm = () => {
163211
orderTime: undefined,
164212
remark: undefined,
165213
fileUrl: undefined,
214+
discountPercent: 0,
215+
discountPrice: 0,
216+
totalPrice: 0,
166217
items: []
167218
}
168219
formRef.value?.resetFields()

src/views/erp/sale/order/components/SaleOrderItemForm.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,7 @@
104104
<template #default="{ row, $index }">
105105
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
106106
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
107-
<el-input-number
108-
v-model="row.taxPrice"
109-
controls-position="right"
110-
:min="0.01"
111-
:precision="2"
112-
class="!w-100%"
113-
/>
107+
<el-input disabled v-model="row.taxPrice" :formatter="erpPriceInputFormatter" />
114108
</el-form-item>
115109
</el-form-item>
116110
</template>

0 commit comments

Comments
 (0)