From ad0cc4829b36f7b12809e4f13b52e667950c0e1f Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Thu, 19 May 2022 09:58:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A=20?= =?UTF-8?q?=E5=B0=81=E8=A3=85=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/plan/knockGold/index.jsx | 140 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/src/pages/plan/knockGold/index.jsx b/src/pages/plan/knockGold/index.jsx index bb990e13..4241ef9a 100644 --- a/src/pages/plan/knockGold/index.jsx +++ b/src/pages/plan/knockGold/index.jsx @@ -182,76 +182,10 @@ export default class addKnockGold extends Component { return true } } else { - if (!this.state.model.card_type) { - Notify.error('请选择卡种') + /* 校验表单 */ + if (!this.limitFunction()) { return false } - - if (this.state.model.early_per.length < 1) { - Notify.error('请选预警百分比') - return false - } - - if (!this.state.model.usable_time) { - Notify.error('请选择可用时间段类型') - return false - } - - /* 可用时间段 */ - if (this.state.model.usable_time === '1') { - if ( - !this.state.model.effect_date_type || - !this.state.model.effect_date - ) { - Notify.error('请完整的填写或选择可用时间段') - return false - } - } - - if ( - this.state.model.usable_time === '2' && - this.setTime(this.state.model.fixed_time) - ) { - Notify.error('请完整的选择固定时间段') - return false - } - - if ( - this.state.model.denomination - 0 < - this.state.model.reduce_amount - 0 - ) { - Notify.error('面额必须大于立减金额') - return false - } - - if (this.state.model.money - 0 > this.state.model.all_budget - 0) { - Notify.error('批次充值金额必须小于总预算') - return false - } - - if ( - this.state.model.denomination - 0 > - this.state.model.all_budget - 0 - ) { - Notify.error('面额必须小于总预算') - return false - } - - /* 生效时间段 */ - if (this.setTime(this.state.model.entry_time)) { - Notify.error('请选择结束时间或开始时间') - return false - } - - /* 领取时间段 */ - if ( - this.setTime(this.state.model.timer) && - this.state.model.timer_type === '2' - ) { - Notify.error('请选择结束时间或开始时间') - return false - } - //缓存 let temp = [] if (sessionStorage.getItem('knockGoldData')) { @@ -267,6 +201,73 @@ export default class addKnockGold extends Component { } } + /* 校验表单function */ + limitFunction() { + if (!this.state.model.card_type) { + Notify.error('请选择卡种') + return false + } + + if (this.state.model.early_per.length < 1) { + Notify.error('请选预警百分比') + return false + } + + if (!this.state.model.usable_time) { + Notify.error('请选择可用时间段类型') + return false + } + + /* 可用时间段 */ + if (this.state.model.usable_time === '1') { + if (!this.state.model.effect_date_type || !this.state.model.effect_date) { + Notify.error('请完整的填写或选择可用时间段') + return false + } + } + + if ( + this.state.model.usable_time === '2' && + this.setTime(this.state.model.fixed_time) + ) { + Notify.error('请完整的选择固定时间段') + return false + } + + if ( + this.state.model.denomination - 0 < + this.state.model.reduce_amount - 0 + ) { + Notify.error('面额必须大于立减金额') + return false + } + + if (this.state.model.money - 0 > this.state.model.all_budget - 0) { + Notify.error('批次充值金额必须小于总预算') + return false + } + + if (this.state.model.denomination - 0 > this.state.model.all_budget - 0) { + Notify.error('面额必须小于总预算') + return false + } + + /* 生效时间段 */ + if (this.setTime(this.state.model.entry_time)) { + Notify.error('请选择结束时间或开始时间') + return false + } + + /* 领取时间段 */ + if ( + this.setTime(this.state.model.timer) && + this.state.model.timer_type === '2' + ) { + Notify.error('请选择结束时间或开始时间') + return false + } + } + //限制时间 setTime(data) { if (!isArray(data) || data.length === 0) return true @@ -278,6 +279,7 @@ export default class addKnockGold extends Component { debugger return blr } + // onProductChange(e) { // console.log('e ===>', e) // this.setState({ cur_product: e }) @@ -308,7 +310,7 @@ export default class addKnockGold extends Component { // }) // } - //输入框或选择器change事件 + /* 输入事件和选择事件统一处理 */ onHandleChange(value, key) { let model2 = this.state.model model2[key] = value