From 57c4cb6d1f82b74d8e927eda0450111b0ddae855 Mon Sep 17 00:00:00 2001
From: 15820893422 <1978476055@qq.com>
Date: Fri, 17 May 2024 16:55:51 +0800
Subject: [PATCH] edit
---
src/views/product/productExamine/editAttr.vue | 79 ++++++++++++-------
1 file changed, 50 insertions(+), 29 deletions(-)
diff --git a/src/views/product/productExamine/editAttr.vue b/src/views/product/productExamine/editAttr.vue
index 4a4c180..4859120 100644
--- a/src/views/product/productExamine/editAttr.vue
+++ b/src/views/product/productExamine/editAttr.vue
@@ -45,7 +45,7 @@
-
+
@@ -60,20 +60,20 @@
-
+
+ -->
+
-
+
@@ -123,15 +123,15 @@
-
+
+
@@ -170,15 +170,15 @@
-
-
+
+
@@ -249,7 +249,7 @@ const defaultObj = {
cost: 0,
ot_price: 0,
proportion:0.6,
- coupon:'',
+ coupon:0,
stock: 0,
growth:0,
bar_code: '',
@@ -396,7 +396,7 @@ export default {
price: 0,
cost: 0,
proportion:0.6,
- coupon:'',
+ coupon:0,
growth:0,
ot_price: 0,
stock: 0,
@@ -412,7 +412,7 @@ export default {
image: '',
price: 0,
proportion:0.6,
- coupon:'',
+ coupon:0,
growth:0,
cost: 0,
ot_price: 0,
@@ -461,22 +461,32 @@ export default {
this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth)
},
handleOnform(type){
- if(type=='ot_price'){
- this.oneFormBatch[0].ot_price = this.oneFormBatch[0].ot_price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
- }else if(type=='cost'){
- this.oneFormBatch[0].cost = this.oneFormBatch[0].cost.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ switch (type) {
+ case 'ot_price':
+ this.oneFormBatch[0].ot_price = this.oneFormBatch[0].ot_price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ break;
+ case 'cost':
+ this.oneFormBatch[0].proportion = toFixedNoRounding(this.oneFormBatch[0].cost/this.oneFormBatch[0].price)
+ this.oneFormBatch[0].cost = this.oneFormBatch[0].cost.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ break;
+ case 'price':
+ this.oneFormBatch[0].price = this.oneFormBatch[0].price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion)
+ break;
+ case 'proportion':
+ this.oneFormBatch[0].proportion = this.oneFormBatch[0].proportion.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion)
+ break;
+ }
// this.oneFormBatch[0].growth = parseInt( this.oneFormBatch[0].price*(0.9-( this.oneFormBatch[0].cost/ this.oneFormBatch[0].price)))
// this.oneFormBatch[0].proportion = (this.oneFormBatch[0].cost/this.oneFormBatch[0].price).toFixed(2)
- }else{
- this.oneFormBatch[0].price = this.oneFormBatch[0].price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
- this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion)
- let obj = this.proportionList.find(item=>item.value==this.oneFormBatch[0].proportion)
- this.oneFormBatch[0].coupon = Math.floor(this.oneFormBatch[0].price*obj.coupon)
- this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth)
+ // let obj = this.proportionList.find(item=>item.value==this.oneFormBatch[0].proportion)
+ // this.oneFormBatch[0].coupon = Math.floor(this.oneFormBatch[0].price*obj.coupon)
+ // this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth)
// this.oneFormBatch[0].growth = parseInt( this.oneFormBatch[0].price*(0.9-( this.oneFormBatch[0].cost/ this.oneFormBatch[0].price)))
// this.oneFormBatch[0].proportion = (this.oneFormBatch[0].cost/this.oneFormBatch[0].price).toFixed(2)
- }
+
},
calculatePercentage(number) {
// 假设输入的是0.6,50%
@@ -491,6 +501,7 @@ export default {
switch(i){
case 'cost':
val.cost=val.cost.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ val.proportion = toFixedNoRounding(val.cost/val.price)
// val.proportion = (val.cost/val.price).toFixed(2)
// val.growth = parseInt(val.price*(0.9-(val.cost/val.price)))
break;
@@ -502,26 +513,36 @@ export default {
break;
case 'price':
val.price=val.price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
- let obj = this.proportionList.find(item=>item.value==val.proportion)
+ // let obj = this.proportionList.find(item=>item.value==val.proportion)
val.cost = toFixedNoRounding(val.price * val.proportion)
- val.coupon = Math.floor(val.price*obj.coupon)
- val.growth = Math.floor(val.price*obj.growth)
+ // val.coupon = Math.floor(val.price*obj.coupon)
+ // val.growth = Math.floor(val.price*obj.growth)
break;
case 'growth':
val.growth=val.growth.replace(/[^\d]/g,'')
break;
+ case 'proportion':
+ val.proportion=val.proportion.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
+ val.cost = toFixedNoRounding(val.price * val.proportion)
+ break;
case 'bar_code':
val.bar_code = val.bar_code.replace(/[\W]/g,'')
break;
+ case 'coupon':
+ val.coupon = val.coupon.replace(/[\W]/g,'')
+ break;
}
},
+ batchInput(e){
+ this.oneFormBatch[0].coupon = e.replace(/[\W]/g,'')
+ },
batchDel() {
this.oneFormBatch = [
{
image: '',
price: 0,
proportion:0.6,
- coupon:'',
+ coupon:0,
growth:0,
cost: 0,
ot_price: 0,