58
58
</el-form-item >
59
59
</el-col >
60
60
</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 >
61
97
</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 >
70
98
<template #footer >
71
99
<el-button @click =" submitForm" type =" primary" :disabled =" formLoading" v-if =" !disabled" >
72
100
确 定
79
107
import { SaleOrderApi , SaleOrderVO } from ' @/api/erp/sale/order'
80
108
import SaleOrderItemForm from ' ./components/SaleOrderItemForm.vue'
81
109
import { CustomerApi , CustomerVO } from ' @/api/erp/sale/customer'
110
+ import { erpPriceInputFormatter , erpPriceMultiply , getSumValue } from ' @/utils'
82
111
83
112
/** ERP 销售订单表单 */
84
113
defineOptions ({ name: ' SaleOrderForm' })
@@ -96,6 +125,9 @@ const formData = ref({
96
125
orderTime: undefined ,
97
126
remark: undefined ,
98
127
fileUrl: ' ' ,
128
+ discountPercent: 0 ,
129
+ discountPrice: 0 ,
130
+ totalPrice: 0 ,
99
131
items: [],
100
132
no: undefined // 订单单号,后端返回
101
133
})
@@ -110,6 +142,22 @@ const customerList = ref<CustomerVO[]>([]) // 客户列表
110
142
const subTabsName = ref (' item' )
111
143
const itemFormRef = ref ()
112
144
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
+
113
161
/** 打开弹窗 */
114
162
const open = async (type : string , id ? : number ) => {
115
163
dialogVisible .value = true
@@ -163,6 +211,9 @@ const resetForm = () => {
163
211
orderTime: undefined ,
164
212
remark: undefined ,
165
213
fileUrl: undefined ,
214
+ discountPercent: 0 ,
215
+ discountPrice: 0 ,
216
+ totalPrice: 0 ,
166
217
items: []
167
218
}
168
219
formRef .value ?.resetFields ()
0 commit comments