|
@@ -169,14 +169,16 @@ export default {
|
|
|
} = this.sitem;
|
|
|
this.cgd_charge = cgd_charge;
|
|
|
this.price = price;
|
|
|
+ console.log(this.sitem);
|
|
|
+ console.log(this.price);
|
|
|
this.is_determine_price = is_determine_price;
|
|
|
this.ruleForm = {
|
|
|
id: id,
|
|
|
status: "2",
|
|
|
companyCode: companyCode ? [companyCode] : [],
|
|
|
companyName,
|
|
|
- service_charge,
|
|
|
- service_proportion,
|
|
|
+ service_charge: service_charge ? service_charge : "0",
|
|
|
+ service_proportion: service_proportion ? service_proportion : "0",
|
|
|
plat_code,
|
|
|
};
|
|
|
}
|
|
@@ -193,9 +195,6 @@ export default {
|
|
|
this.ruleForm[key] = e + "" || "0";
|
|
|
this.$refs.ruleForm.validateField(key);
|
|
|
await this.num(key);
|
|
|
- console.log(
|
|
|
- this.ruleForm.service_charge + "-----" + this.ruleForm.service_proportion
|
|
|
- );
|
|
|
},
|
|
|
async num(key) {
|
|
|
const is_sale = this.is_determine_price === "1";
|
|
@@ -209,15 +208,22 @@ export default {
|
|
|
cgdAdd = this.cgd_charge * 1;
|
|
|
}
|
|
|
if (key === "service_charge") {
|
|
|
- serAdd = this.ruleForm.service_charge * 1;
|
|
|
+ serAdd = this.ruleForm.service_charge ?? "0" * 1;
|
|
|
}
|
|
|
if (key === "service_proportion") {
|
|
|
- rate = this.ruleForm.service_proportion * 1;
|
|
|
+ rate = this.ruleForm.service_proportion ?? "0" * 1;
|
|
|
}
|
|
|
console.log(cgdAdd + "---" + serAdd + "---" + qrdAdd + "----" + rate);
|
|
|
if (is_sale && key === "service_charge") {
|
|
|
+ if (qrdAdd <= serAdd) {
|
|
|
+ this.$message.error("服务费不能大于等于销售单价!");
|
|
|
+ await this.set_number_change("service_charge", "0");
|
|
|
+ await this.set_number_change("service_proportion", "0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
// cgdAdd = qrdAdd - serAdd;
|
|
|
// rate = (1 - cgdAdd / qrdAdd)*100;
|
|
|
+
|
|
|
cgdAdd = accSub(qrdAdd, serAdd);
|
|
|
rate = accMul(accSub(1, accDiv(cgdAdd, qrdAdd)), 100);
|
|
|
await this.set_number_change("service_proportion", rate);
|
|
@@ -225,6 +231,13 @@ export default {
|
|
|
if (is_sale && key === "service_proportion") {
|
|
|
// cgdAdd = qrdAdd * (100 - rate);
|
|
|
// serAdd = qrdAdd - cgdAdd;
|
|
|
+ if (rate === 100) {
|
|
|
+ this.$message.error("服务费比例不能等于100!");
|
|
|
+ await this.set_number_change("service_charge", "0");
|
|
|
+ await this.set_number_change("service_proportion", "0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
cgdAdd = accMul(qrdAdd, accSub(100, rate));
|
|
|
serAdd = accSub(qrdAdd, cgdAdd);
|
|
|
await this.set_number_change("service_charge", serAdd);
|
|
@@ -232,6 +245,7 @@ export default {
|
|
|
if (!is_sale && key === "service_charge") {
|
|
|
// qrdAdd = cgdAdd + serAdd;
|
|
|
// rate = 1 - cgdAdd / qrdAdd;
|
|
|
+
|
|
|
qrdAdd = add_sum(cgdAdd, serAdd);
|
|
|
rate = accSub(1, accDiv(cgdAdd, qrdAdd));
|
|
|
await this.set_number_change("service_proportion", rate);
|
|
@@ -239,10 +253,17 @@ export default {
|
|
|
if (!is_sale && key === "service_proportion") {
|
|
|
// qrdAdd = cgdAdd / (100 - rate);
|
|
|
// serAdd = qrdAdd - cgdAdd;
|
|
|
+ if (rate === 100) {
|
|
|
+ this.$message.error("服务费比例不能等于100!");
|
|
|
+ await this.set_number_change("service_charge", "0");
|
|
|
+ await this.set_number_change("service_proportion", "0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
qrdAdd = accDiv(cgdAdd, accSub(100, rate));
|
|
|
serAdd = accSub(qrdAdd, cgdAdd);
|
|
|
await this.set_number_change("service_charge", serAdd);
|
|
|
}
|
|
|
+ console.log(cgdAdd + "---" + serAdd + "---" + qrdAdd + "----" + rate);
|
|
|
},
|
|
|
async set_number_change(key, value) {
|
|
|
this.ruleForm[key] = value + "" || "0";
|