From 3c607b1e3f0f93bb808110fc30666ebcf02d99c6 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Thu, 29 Jun 2023 15:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=8A=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BA=A2=E5=8C=85=E8=A1=A8=E8=BE=BE=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/redPackets/index.jsx | 18 +++++++------- src/components/redPackets/rules.js | 37 +++++++++++++++++------------ src/components/redPackets/static.js | 3 +-- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/components/redPackets/index.jsx b/src/components/redPackets/index.jsx index bc54831c..0d79eefe 100644 --- a/src/components/redPackets/index.jsx +++ b/src/components/redPackets/index.jsx @@ -375,7 +375,7 @@ export default class addKnockGold extends Component { return item.cash_activity_id === this.props.data.cash_activity_id }) /* 校验表单 */ - if (additionalRules(this.state) === false) { + if (additionalRules(this.state, this.computeMin(), this.computeMax_Min(false)) === false) { return false } /* 兼容老数据 */ @@ -390,7 +390,7 @@ export default class addKnockGold extends Component { return true } else { /* 校验表单 */ - if (additionalRules(this.state) === false) { + if (additionalRules(this.state, this.computeMin(), this.computeMax_Min(false)) === false) { return false } //缓存 @@ -450,7 +450,7 @@ export default class addKnockGold extends Component { } /* 计算随机最大面额中的最大值 */ - computeMax_Min() { + computeMax_Min(is = true) { const { min_denomination, num, all_budget } = this.state.model const b = this.state.model.channel === 1 ? 0.01 : 0.1 const max = all_budget - (num - 1) * min_denomination @@ -465,12 +465,13 @@ export default class addKnockGold extends Component { this.setState({ computeMax: a.toFixed(2) }) - this.onHandleChange("", "max_denomination") + is && this.onHandleChange("", "max_denomination") + return a.toFixed(2) } /* 计算随机最大面额中的最小值 */ computeMin() { - let data = "" + let data = 0 const b = this.state.model.channel === 1 ? 0.01 : 0.1 if (isFinite(this.state.model.all_budget / this.state.model.num)) { const a = this.state.model.all_budget / this.state.model.num @@ -484,10 +485,7 @@ export default class addKnockGold extends Component { } else { data = b } - this.setState({ - computeMin: data.toFixed(2) - }) - this.onHandleChange("", "max_denomination") + return data.toFixed(2) } //tag关闭 @@ -504,7 +502,7 @@ export default class addKnockGold extends Component { return "请输入" } if (this.state.computeMax) { - return `最大面额为${this.state.computeMin} ~ ${this.state.computeMax}` + return `最大面额为${this.computeMin()} ~ ${this.state.computeMax}` } return "请输入" } diff --git a/src/components/redPackets/rules.js b/src/components/redPackets/rules.js index 436eeb53..4a2a73cd 100644 --- a/src/components/redPackets/rules.js +++ b/src/components/redPackets/rules.js @@ -44,7 +44,7 @@ export default { } /* 额外验证规则 */ -export function additionalRules(params) { +export function additionalRules(params, computeMin, computeMax) { const model = cloneDeep(params.model) model.all_budget = Number(model.all_budget) model.day_budget = Number(model.day_budget) @@ -159,11 +159,14 @@ export function additionalRules(params) { if (model.cash_amount_type === "2") { /* TODO: 2:微信 1:支付宝 */ if (model.channel === 2) { - return rulesRandom(model, 0.1) + if (!rulesRandom(model, 0.1)) { + } } if (model.channel === 1) { - return rulesRandom(model, 0.01) + if (!rulesRandom(model, 0.01)) { + return false + } } if (model.all_budget < model.min_denomination * model.num) { @@ -176,6 +179,16 @@ export function additionalRules(params) { return false } + if (computeMax < model.max_denomination) { + Notify.error("随机最大面额不得大于计算最大面额") + return false + } + + if (computeMin > model.max_denomination) { + Notify.error("随机最大面额不得小于计算最小面额") + return false + } + if (model.all_budget < model.all_budget / model.num) { Notify.error("最大面额不得小于最大面额中的最小值") return false @@ -196,11 +209,15 @@ export function additionalRules(params) { if (model.cash_amount_type === "1") { /* TODO: 2:微信 1:支付宝 */ if (model.channel === 2) { - return rulesFixed(model, 0.1) + if (!rulesFixed(model, 0.1)) { + return false + } } if (model.channel === 1) { - return rulesFixed(model, 0.01) + if (!rulesFixed(model, 0.01)) { + return false + } } if (model.all_budget < model.denomination || model.day_budget < model.denomination) { @@ -208,16 +225,6 @@ export function additionalRules(params) { return false } - if (params.computeMax < model.max_denomination) { - Notify.error("随机最大面额不得大于计算最大面额") - return false - } - - if (params.computeMin < model.min_denomination) { - Notify.error("随机最小面额不得大于计算最小面额") - return false - } - if (model.day_budget < model.denomination || model.day_budget > model.all_budget) { Notify.error("单日发放预算不得小于面额且不大于总预算") return false diff --git a/src/components/redPackets/static.js b/src/components/redPackets/static.js index f3d4249f..b7dad267 100644 --- a/src/components/redPackets/static.js +++ b/src/components/redPackets/static.js @@ -65,7 +65,6 @@ export function model({ data }) { userSelectList: [] /* 预警人数据 */, form_data: {}, isEdit: !!data?.id /* 是否为编辑 */, - computeMax: "" /* 随机最大面额 */, - computeMin: "" /* 随机最小面额 */ + computeMax: "" /* 随机最大面额 */ } }