优化代码

This commit is contained in:
wangsongsole 2022-07-26 15:53:19 +08:00
parent ce023b0eac
commit 13e7aaa317
1 changed files with 12 additions and 12 deletions

View File

@ -470,6 +470,10 @@ export default class addKnockGold extends Component {
return transformData return transformData
} }
testDateFunction(arr) {
return arr.map((item) => this.setTime(item)).filter((item) => item)
}
/* 校验表单function */ /* 校验表单function */
limitFunction() { limitFunction() {
if (!this.state.model.card_type) { 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 (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('请完整的选择规则日期和时间') Notify.error('请完整的选择规则日期和时间')
return false 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 (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('请完整的选择不规则日期和时间') Notify.error('请完整的选择不规则日期和时间')
return false return false
} }