diff --git a/src/components/knockGold/index.jsx b/src/components/knockGold/index.jsx index db34758a..99b0b1ea 100644 --- a/src/components/knockGold/index.jsx +++ b/src/components/knockGold/index.jsx @@ -135,6 +135,15 @@ export default class addKnockGold extends Component { this.props.data.time_limit.use_time.fiexd_time?.start_time model.fixed_time[1] = this.props.data.time_limit.use_time.fiexd_time?.end_time + if (this.props.data.time_limit.use_time.type === 'week') { + model.ruleWeek = this.props.data.time_limit.use_time?.week + model.ruleDate = this.props.data.time_limit.use_time?.time + } + if (this.props.data.time_limit.use_time.type === 'irregular') { + model.irregularDate = this.props.data.time_limit.use_time?.day + model.irregularTime = this.props.data.time_limit.use_time?.time + } + this.setState({ model: model }) } this.getUserSelectList() @@ -357,7 +366,6 @@ export default class addKnockGold extends Component { /* 提交 */ async submit() { - console.log(this.state.model) if ( this.refs.form.validator() && this.refs.form1.validator() && @@ -467,10 +475,7 @@ export default class addKnockGold extends Component { use_time: { type: this.state.model.usable_time, - fiexd_time: { - start_time: this.state.model.fixed_time[0], - end_time: this.state.model.fixed_time[1] - }, + ...this.withTimeFunction(this.state.model.usable_time), effect_day: this.state.model.effect_date, effect_date_type: this.state.model.effect_date_type?.key } @@ -479,6 +484,28 @@ export default class addKnockGold extends Component { return transformData } + /* 处理可用时间段 */ + withTimeFunction(type) { + let obj = {} + switch (type) { + case 'week': + obj.time = this.state.model.ruleDate + obj.week = this.state.model.ruleWeek + break + case 'irregular': + obj.time = this.state.model.irregularTime + obj.day = this.state.model.irregularDate + break + default: + obj.fiexd_time = { + start_time: this.state.model.fixed_time[0], + end_time: this.state.model.fixed_time[1] + } + break + } + return obj + } + testDateFunction(arr) { return arr.map((item) => this.setTime(item)).filter((item) => item) } @@ -532,7 +559,7 @@ export default class addKnockGold extends Component { /* 验证有效期内,规则日期可用 */ - if (this.state.model.usable_time === 'ruleDate') { + if (this.state.model.usable_time === 'week') { if ( this.testDateFunction(this.state.model.ruleDate).length > 0 || this.state.model.ruleWeek.length < 1 @@ -543,7 +570,7 @@ export default class addKnockGold extends Component { } /* 有效期内,不规则日期可用 */ - if (this.state.model.usable_time === 'irregularDate') { + if (this.state.model.usable_time === 'irregular') { if ( this.testDateFunction(this.state.model.irregularDate).length > 0 || this.testDateFunction(this.state.model.irregularTime).length > 0 @@ -628,7 +655,6 @@ export default class addKnockGold extends Component { //限制时间 setTime(data) { - console.log(data) if (!isArray(data) || data?.length === 0) return true const newData = data.map((item) => Boolean(item)) let blr = null @@ -726,7 +752,6 @@ export default class addKnockGold extends Component { { - console.log(value) this.onHandleChange(value, 'temp_no') }} onClearItem={() => { @@ -1174,7 +1199,7 @@ export default class addKnockGold extends Component { this.onHandleChange([[]], 'irregularDate') this.onHandleChange([[]], 'irregularTime') }}> - 有效期内,规则日期可用 + 有效期内,规则日期可用 - 有效期内,不规则日期可用 + 有效期内,不规则日期可用

可在有效期内任意选择时间天数,以及可用时段。