立减金组件修复

This commit is contained in:
wangsongsole 2022-08-03 11:22:37 +08:00
parent ac026ca21e
commit 2b41a4b9cd
1 changed files with 35 additions and 3 deletions

View File

@ -430,6 +430,25 @@ export default class addKnockGold extends Component {
}
}
}
/* 处理时间交集 */
detectTimeConflict(arr) {
for (var i = 0; i < arr.length; i++) {
var d1 = arr[i][0]
var d2 = arr[i][1]
for (var j = i + 1; j < arr.length; j++) {
// j=i+1:使
var t1 = arr[j][0]
var t2 = arr[j][1]
if ((d1 >= t1 && d1 < t2) || (d1 < t1 && d2 > t1)) {
return true
} else {
return false
}
}
}
}
/* 数据转换统一处理函数 */
transformDataCode() {
const transformData = {}
@ -580,6 +599,19 @@ export default class addKnockGold extends Component {
}
}
if (this.detectTimeConflict(this.state.model.ruleDate)) {
Notify.error('有效期内,规则时间存在交集')
return false
}
if (this.detectTimeConflict(this.state.model.irregularDate)) {
Notify.error('有效期内,不规则日期存在交集')
return false
}
if (this.detectTimeConflict(this.state.model.irregularTime)) {
Notify.error('有效期内,不规则时间存在交集')
return false
}
const limitBit = /^-?\d+\.?\d{0,2}$/
if (
!limitBit.test(this.state.model.denomination) ||
@ -1068,7 +1100,7 @@ export default class addKnockGold extends Component {
this.onHandleChange(value, 'timer')
}}
width='240px'
disabledDate={this.onDisabledRange}
disabledTime={this.onDisabledRange}
/>
<RadioGroup
onChange={({ target }) => {
@ -1230,7 +1262,7 @@ export default class addKnockGold extends Component {
this.onHandleChange(model, 'ruleDate')
}}
width={158}
disabledDate={this.onDisabledRange}
disabledTime={this.onDisabledRange}
/>
{this.addOrMoveFunction(
index,
@ -1308,7 +1340,7 @@ export default class addKnockGold extends Component {
this.onHandleChange(model, 'irregularTime')
}}
width={158}
disabledDate={this.onDisabledRange}
disabledTime={this.onDisabledRange}
/>
{this.addOrMoveFunction(
index,