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