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

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