Просмотр исходного кода

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 11 месяцев назад
Родитель
Сommit
b84d36346c

+ 11 - 2
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/relatedProducts/relatedProducts.vue

@@ -57,11 +57,11 @@
         </el-table>
 
         <div class="flex w-full justify-between pt-2 pb-1">
-            <div>整单折扣率(%)</div>
+            <div>整单折扣率(<span class="text-[red]">{{ discountEfficiency }}</span>)</div>
             <div class="flex">
                 <div>已选中产品:<span class="text-[red] pr-2">{{ selectedQuantity }}</span>个</div>
                 <div class="pl-4">
-                    总金额:<span class="pr-1">{{ totalAmount }}</span> 元
+                    总金额:<span class="pr-1 text-[red]">{{ totalAmount }}</span> 元
                 </div>
             </div>
         </div>
@@ -158,6 +158,15 @@ const totalAmount = computed(() => {
     }, 0)
 })
 
+const discountEfficiency = computed(() => {
+    const newProductTable = productTable.value.filter((item: any) => item.productId && item.sellingPrice && item.quantity && item.discount && item.totalPrice)
+    const list = JSON.parse(JSON.stringify(newProductTable || []))
+    const totalAmount = list.reduce((pre: number, cur: any) => { return pre + (cur.totalPrice || 0) }, 0)
+    const totalPrice = list.reduce((pre: number, cur: any) => { return pre + (cur.price * cur.quantity || 0) }, 0)
+    const num = totalAmount / totalPrice * 100
+    return num > 0 ? Number(num.toFixed(2)) + '%' : ''
+})
+
 watchEffect(() => {
     const { productTableList, height, productTableListValue = [] } = props
     console.log(productTableListValue, '<==== 数据')