From fa5b2de53dfb31eead93e64673f180d3f4ca1c0c Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Mon, 13 Jun 2022 16:16:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/knockGold/index.jsx | 59 ++++++++++++++++++++++++++++-- src/pages/plan/add/step1.js | 14 +++++++ 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/components/knockGold/index.jsx b/src/components/knockGold/index.jsx index 97ba2d7d..8cf1a471 100644 --- a/src/components/knockGold/index.jsx +++ b/src/components/knockGold/index.jsx @@ -242,8 +242,47 @@ export default class addKnockGold extends Component { return isdisabled } + /* x时间控件禁用 */ + onDisabledRange2 = (date, type) => { + let isdisabled = false + let str = moment(date).format('YYYY-MM-DD HH:mm:ss') + if (type == 'start') { + isdisabled = + moment(str).isBefore(this.state.model.entry_time[0]) || + moment(str).isAfter(this.state.model.entry_time[1]) + } + + if (type == 'end') { + isdisabled = + moment(str).add(1, 'days').isBefore(this.state.model.entry_time[0]) || + moment(str).isAfter(this.state.model.entry_time[1]) + } + return isdisabled + } + onDisabledTime = (date, type) => { - const min = new Date() + let step1 = JSON.parse(sessionStorage.getItem('knockGold_effectDate')) + const min = new Date(step1.begin_time) + const hour = min.getHours() + const minute = min.getMinutes() + const second = min.getSeconds() + const isSame = isSameDay(date, min) + + return isSame + ? { + disabledHours: () => initArray(hour), + disabledMinutes: (hourValue) => + hourValue === hour ? initArray(minute) : [], + disabledSeconds: (hourValue, minuteValue) => + hourValue === hour && minuteValue === minute + ? initArray(second) + : [] + } + : {} + } + + onDisabledTime1 = (date, type) => { + const min = new Date(this.state.model.entry_time[0]) const hour = min.getHours() const minute = min.getMinutes() const second = min.getSeconds() @@ -422,7 +461,7 @@ export default class addKnockGold extends Component { this.state.model.denomination - 0 < this.state.model.reduce_amount - 0 ) { - Notify.error('面额必须大于立减金额') + Notify.error('面额必须小于满减金额') return false } @@ -439,6 +478,19 @@ export default class addKnockGold extends Component { return false } + if (this.state.model.all_budget - 0 < this.state.model.day_budget - 0) { + Notify.error('单天预算发放上限必须小于总预算') + return false + } + + if ( + this.state.model.all_budget / this.state.model.reduce_amount < + this.state.model.receive_number - 0 + ) { + Notify.error('用户可领个数必须小于库存(总预算/面额)') + return false + } + /* 生效时间段 */ if (this.setTime(this.state.model.entry_time)) { Notify.error('请选择结束时间或开始时间') @@ -920,7 +972,8 @@ export default class addKnockGold extends Component { onChange={(value) => { this.onHandleChange(value, 'fixed_time') }} - disabledDate={this.onDisabledRange} + disabledDate={this.onDisabledRange2} + disabledTime={this.onDisabledTime1} /> diff --git a/src/pages/plan/add/step1.js b/src/pages/plan/add/step1.js index 5afad204..fe497b39 100644 --- a/src/pages/plan/add/step1.js +++ b/src/pages/plan/add/step1.js @@ -55,6 +55,13 @@ export default class acclist extends React.Component { model.date_time = [data.begin_time, data.end_time] sessionStorage.setItem('datetime', JSON.stringify(model.date_time)) + sessionStorage.setItem( + 'knockGold_effectDate', + JSON.stringify({ + begin_time: model.date_time[0], + end_time: model.date_time[1] + }) + ) this.setState({ model: model, lodshow: true }) } @@ -187,6 +194,13 @@ export default class acclist extends React.Component { }) sessionStorage.setItem('datetime', JSON.stringify(model2.date_time)) + sessionStorage.setItem( + 'knockGold_effectDate', + JSON.stringify({ + begin_time: model2.date_time[0], + end_time: model2.date_time[1] + }) + ) } onDisabledRange = (date, type) => { console.log(type)