From 13e7aaa31747db6df428104534aeb4836034d23f Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Tue, 26 Jul 2022 15:53:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/knockGold/index.jsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/knockGold/index.jsx b/src/components/knockGold/index.jsx index b2032927..efad648b 100644 --- a/src/components/knockGold/index.jsx +++ b/src/components/knockGold/index.jsx @@ -470,6 +470,10 @@ export default class addKnockGold extends Component { return transformData } + testDateFunction(arr) { + return arr.map((item) => this.setTime(item)).filter((item) => item) + } + /* 校验表单function */ limitFunction() { if (!this.state.model.card_type) { @@ -518,27 +522,23 @@ export default class addKnockGold extends Component { } /* 验证有效期内,规则日期可用 */ - let isArray = this.state.model.ruleDate - .map((item) => this.setTime(item)) - .filter((item) => item) if (this.state.model.usable_time === 'ruleDate') { - if (isArray.length > 0 || this.state.model.ruleWeek.length < 1) { + if ( + this.testDateFunction(this.state.model.ruleDate).length > 0 || + this.state.model.ruleWeek.length < 1 + ) { Notify.error('请完整的选择规则日期和时间') return false } } /* 有效期内,不规则日期可用 */ - let isArray1 = this.state.model.irregularDate - .map((item) => this.setTime(item)) - .filter((item) => item) - let isArray2 = this.state.model.irregularTime - .map((item) => this.setTime(item)) - .filter((item) => item) - if (this.state.model.usable_time === 'irregularDate') { - if (isArray1.length > 0 || isArray2.length > 0) { + if ( + this.testDateFunction(this.state.model.irregularDate).length > 0 || + this.testDateFunction(this.state.model.irregularTime).length > 0 + ) { Notify.error('请完整的选择不规则日期和时间') return false }