💊 fix: 修复红包表达校验
This commit is contained in:
parent
9fca5fad96
commit
3c607b1e3f
|
@ -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 "请输入"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -65,7 +65,6 @@ export function model({ data }) {
|
|||
userSelectList: [] /* 预警人数据 */,
|
||||
form_data: {},
|
||||
isEdit: !!data?.id /* 是否为编辑 */,
|
||||
computeMax: "" /* 随机最大面额 */,
|
||||
computeMin: "" /* 随机最小面额 */
|
||||
computeMax: "" /* 随机最大面额 */
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue