diff --git a/src/views/erp/sale/order/SaleOrderForm.vue b/src/views/erp/sale/order/SaleOrderForm.vue
index 59bd3137..0f553aa3 100644
--- a/src/views/erp/sale/order/SaleOrderForm.vue
+++ b/src/views/erp/sale/order/SaleOrderForm.vue
@@ -58,15 +58,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
确 定
@@ -79,6 +107,7 @@
import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
import SaleOrderItemForm from './components/SaleOrderItemForm.vue'
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
+import { erpPriceInputFormatter, erpPriceMultiply, getSumValue } from '@/utils'
/** ERP 销售订单表单 */
defineOptions({ name: 'SaleOrderForm' })
@@ -96,6 +125,9 @@ const formData = ref({
orderTime: undefined,
remark: undefined,
fileUrl: '',
+ discountPercent: 0,
+ discountPrice: 0,
+ totalPrice: 0,
items: [],
no: undefined // 订单单号,后端返回
})
@@ -110,6 +142,22 @@ const customerList = ref([]) // 客户列表
const subTabsName = ref('item')
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) => {
dialogVisible.value = true
@@ -163,6 +211,9 @@ const resetForm = () => {
orderTime: undefined,
remark: undefined,
fileUrl: undefined,
+ discountPercent: 0,
+ discountPrice: 0,
+ totalPrice: 0,
items: []
}
formRef.value?.resetFields()
diff --git a/src/views/erp/sale/order/components/SaleOrderItemForm.vue b/src/views/erp/sale/order/components/SaleOrderItemForm.vue
index 1c388c70..dd71b062 100644
--- a/src/views/erp/sale/order/components/SaleOrderItemForm.vue
+++ b/src/views/erp/sale/order/components/SaleOrderItemForm.vue
@@ -104,13 +104,7 @@
-
+