秒杀成本价计算售价和让利

This commit is contained in:
faiz 2024-11-21 15:39:51 +08:00
parent c0ef2f8f6b
commit 878581b6f7
1 changed files with 54 additions and 30 deletions

View File

@ -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 = {