对接可用时间字段

This commit is contained in:
wangsongsole 2022-08-02 16:53:26 +08:00
parent f91249159d
commit d5d3ce3c43
1 changed files with 36 additions and 11 deletions

View File

@ -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 {
<FormItem labelname='卷模板编号' prop='temp_no' id='batch_number'>
<Ipt
onChange={(value) => {
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')
}}>
<Radio value='ruleDate'>有效期内规则日期可用</Radio>
<Radio value='week'>有效期内规则日期可用</Radio>
</RadioGroup>
<Checkbox.Group
value={this.state.model.ruleWeek}
@ -1232,7 +1257,7 @@ export default class addKnockGold extends Component {
this.onHandleChange([[]], 'ruleWeek')
this.onHandleChange([[]], 'ruleDate')
}}>
<Radio value='irregularDate'>有效期内不规则日期可用</Radio>
<Radio value='irregular'>有效期内不规则日期可用</Radio>
</RadioGroup>
<p className='notice' style={{ width: '600px' }}>
可在有效期内任意选择时间天数以及可用时段