秒杀成本价计算售价和让利
This commit is contained in:
parent
c0ef2f8f6b
commit
878581b6f7
|
@ -742,6 +742,7 @@ export default {
|
||||||
volume: 0,
|
volume: 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
give_discount_rate: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -956,37 +957,59 @@ export default {
|
||||||
return percentage + "%";
|
return percentage + "%";
|
||||||
},
|
},
|
||||||
handleBlue(val, i) {
|
handleBlue(val, i) {
|
||||||
if ("price" == i && this.is_shengTian_mer) {
|
// if ("price" == i && this.is_shengTian_mer) {
|
||||||
// 后台占比 (协议价 + 最终售价 * 0.05) / 最终售价
|
// // 后台占比 (协议价 + 最终售价 * 0.05) / 最终售价
|
||||||
let ratio =
|
// let ratio =
|
||||||
(Number(val.third_agreement_price) + Number(val.price) * 0.05) /
|
// (Number(val.third_agreement_price) + Number(val.price) * 0.05) /
|
||||||
Number(val.price);
|
// Number(val.price);
|
||||||
console.log(ratio);
|
// console.log(ratio);
|
||||||
// 判断计算结果是否在指定范围内
|
// // 判断计算结果是否在指定范围内
|
||||||
if (ratio <= 0.2 || ratio > 0.8) {
|
// if (ratio <= 0.2 || ratio > 0.8) {
|
||||||
this.$message.error("占比价格比例不在有效范围内(0.2-0.8)");
|
// this.$message.error("占比价格比例不在有效范围内(0.2-0.8)");
|
||||||
val.price = "";
|
// val.price = "";
|
||||||
} else {
|
// } else {
|
||||||
// 如果在范围内,可以执行其他操作或什么都不做
|
// // 如果在范围内,可以执行其他操作或什么都不做
|
||||||
val.proportion = toFixedNoRounding(ratio);
|
// val.proportion = toFixedNoRounding(ratio);
|
||||||
|
// }
|
||||||
|
// // 折扣 最终售价 * 0.9 - (协议价 + 最终售价 * 0.05)
|
||||||
|
// let discount = toFixedNoRounding(
|
||||||
|
// Number(val.price) * 0.9 -
|
||||||
|
// (Number(val.third_agreement_price) + Number(val.price) * 0.05)
|
||||||
|
// );
|
||||||
|
// if (!parseInt(discount)) {
|
||||||
|
// this.$message.error("折扣必须大于0");
|
||||||
|
// val.price = "";
|
||||||
|
// }
|
||||||
|
// //折扣
|
||||||
|
// val.coupon = parseInt(discount);
|
||||||
|
// //成本
|
||||||
|
// val.cost = toFixedNoRounding(
|
||||||
|
// Number(val.third_agreement_price) + Number(val.price) * 0.05
|
||||||
|
// );
|
||||||
|
// // 市场价
|
||||||
|
// val.ot_price = val.price;
|
||||||
|
// }
|
||||||
|
// console.log(i);
|
||||||
|
if (i == "cost") {
|
||||||
|
if (
|
||||||
|
toFixedNoRounding(1 - Number(val.cost) / Number(val.original_cost)) <
|
||||||
|
this.give_discount_rate
|
||||||
|
) {
|
||||||
|
return this.$message.warning("成本价过高请重新调整!!!");
|
||||||
}
|
}
|
||||||
// 折扣 最终售价 * 0.9 - (协议价 + 最终售价 * 0.05)
|
// console.log(
|
||||||
let discount = toFixedNoRounding(
|
// toFixedNoRounding(1 - Number(val.cost) / Number(val.original_cost))
|
||||||
Number(val.price) * 0.9 -
|
// );
|
||||||
(Number(val.third_agreement_price) + Number(val.price) * 0.05)
|
val.give_discount = toFixedNoRounding(
|
||||||
|
1 - Number(val.cost) / Number(val.original_cost)
|
||||||
);
|
);
|
||||||
if (!parseInt(discount)) {
|
val.price = toFixedNoRounding(
|
||||||
this.$message.error("折扣必须大于0");
|
val.original_price *
|
||||||
val.price = "";
|
(1 -
|
||||||
}
|
toFixedNoRounding(
|
||||||
//折扣
|
1 - Number(val.cost) / Number(val.original_cost)
|
||||||
val.coupon = parseInt(discount);
|
))
|
||||||
//成本
|
|
||||||
val.cost = toFixedNoRounding(
|
|
||||||
Number(val.third_agreement_price) + Number(val.price) * 0.05
|
|
||||||
);
|
);
|
||||||
// 市场价
|
|
||||||
val.ot_price = val.price;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleCost(val, i) {
|
handleCost(val, i) {
|
||||||
|
@ -1037,7 +1060,7 @@ export default {
|
||||||
if (this.is_shengTian_mer) return;
|
if (this.is_shengTian_mer) return;
|
||||||
val.price = val.price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/, "$1");
|
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.cost = toFixedNoRounding(val.price * val.proportion);
|
||||||
// val.coupon = Math.floor(val.price*obj.coupon)
|
// val.coupon = Math.floor(val.price*obj.coupon)
|
||||||
// val.growth = Math.floor(val.price*obj.growth)
|
// val.growth = Math.floor(val.price*obj.growth)
|
||||||
break;
|
break;
|
||||||
|
@ -1052,7 +1075,7 @@ export default {
|
||||||
/^([0-9-]\d*\.?\d{0,2})?.*$/,
|
/^([0-9-]\d*\.?\d{0,2})?.*$/,
|
||||||
"$1"
|
"$1"
|
||||||
);
|
);
|
||||||
val.cost = toFixedNoRounding(val.price * val.proportion);
|
// val.cost = toFixedNoRounding(val.price * val.proportion);
|
||||||
break;
|
break;
|
||||||
case "bar_code":
|
case "bar_code":
|
||||||
val.bar_code = val.bar_code.replace(/[\W]/g, "");
|
val.bar_code = val.bar_code.replace(/[\W]/g, "");
|
||||||
|
@ -1239,6 +1262,7 @@ export default {
|
||||||
productDetailApi(id)
|
productDetailApi(id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const info = res.data;
|
const info = res.data;
|
||||||
|
this.give_discount_rate = res.data?.sce_give_discount_rate || 0;
|
||||||
// console.log(res.data);
|
// console.log(res.data);
|
||||||
this.is_shengTian_mer = info.is_shengTian_mer;
|
this.is_shengTian_mer = info.is_shengTian_mer;
|
||||||
this.formValidate = {
|
this.formValidate = {
|
||||||
|
|
Loading…
Reference in New Issue