立减金新增 有效时间段
This commit is contained in:
parent
f5eb05a523
commit
d1f8366b67
|
@ -6,7 +6,7 @@ import Form from '@/components/form/main'
|
|||
import FormItem from '@/components/form-item/main'
|
||||
import rules from './rules'
|
||||
import moment from 'moment'
|
||||
import { deWeightThree } from '@/utils'
|
||||
import { deWeightThree, timeDiff } from '@/utils'
|
||||
import { isSameDay } from 'date-fns'
|
||||
import Bus from '@/assets/eventBus.js'
|
||||
import {
|
||||
|
@ -31,8 +31,7 @@ import AddNewDialog from './Dialog'
|
|||
import MobileComponent from './mobileCmponent'
|
||||
const getTimeList = [
|
||||
{ key: '0', text: '立即生效' },
|
||||
{ key: '1', text: '次日生效' },
|
||||
{ key: '2', text: '自定义时间' }
|
||||
{ key: '1', text: '次日生效' }
|
||||
]
|
||||
const cardTypeList = [
|
||||
{ key: '1', text: '借记卡' },
|
||||
|
@ -149,11 +148,9 @@ export default class addKnockGold extends Component {
|
|||
|
||||
if (this.props.data.time_limit.use_time.effect_day) {
|
||||
model.effect_date_type =
|
||||
Number(this.props.data.time_limit.use_time.effect_day) < 2
|
||||
? getTimeList[
|
||||
Number(this.props.data.time_limit.use_time.effect_day)
|
||||
]
|
||||
: getTimeList[2]
|
||||
getTimeList[
|
||||
Number(this.props.data.time_limit.use_time.effect_date_type)
|
||||
]
|
||||
} else {
|
||||
model.effect_date_type = ''
|
||||
}
|
||||
|
@ -420,7 +417,8 @@ export default class addKnockGold extends Component {
|
|||
start_time: this.state.model.fixed_time[0],
|
||||
end_time: this.state.model.fixed_time[1]
|
||||
},
|
||||
effect_day: this.state.model.effect_date
|
||||
effect_day: this.state.model.effect_date,
|
||||
effect_date_type: this.state.model.effect_date_type.key
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -454,6 +452,18 @@ export default class addKnockGold extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
const TimeDiffer = timeDiff(
|
||||
this.state.model.entry_time[0],
|
||||
this.state.model.entry_time[1]
|
||||
)
|
||||
if (TimeDiffer < Number(this.state.model.effect_date)) {
|
||||
Notify.error(
|
||||
`有限期不允许大于生效时间段
|
||||
注:当前有效期最大时间为 ${TimeDiffer} 天`
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (
|
||||
this.state.model.usable_time === 'fiexd' &&
|
||||
this.setTime(this.state.model.fixed_time)
|
||||
|
@ -941,18 +951,15 @@ export default class addKnockGold extends Component {
|
|||
placeholder='选择一项'
|
||||
onChange={(value) => {
|
||||
this.onHandleChange(value, 'effect_date_type')
|
||||
this.onHandleChange(value?.key, 'effect_date')
|
||||
if (value?.key !== '2') {
|
||||
this.onHandleChange(value?.key, 'effect_date')
|
||||
} else {
|
||||
this.onHandleChange('', 'effect_date')
|
||||
}
|
||||
}}
|
||||
value={this.state.model.effect_date_type}
|
||||
className='select-basic'
|
||||
disabled={this.props?.data?.id ? true : false}
|
||||
width='195px'
|
||||
popupWidth='195px'
|
||||
/>
|
||||
</div>
|
||||
<span className='effect_dates'>有效期</span>
|
||||
<Ipt
|
||||
onChange={(value) => {
|
||||
this.onHandleChange(value, 'effect_date')
|
||||
|
@ -960,12 +967,7 @@ export default class addKnockGold extends Component {
|
|||
onClearItem={() => {
|
||||
this.onHandleChange('', 'effect_date')
|
||||
}}
|
||||
disabled={
|
||||
this.props?.data?.id ||
|
||||
this.state.model?.effect_date_type?.key !== '2'
|
||||
? true
|
||||
: false
|
||||
}
|
||||
disabled={this.props?.data?.id ? true : false}
|
||||
value={this.state.model.effect_date}
|
||||
placeholder={'请输入'}
|
||||
labelWidth={'0px'}
|
||||
|
|
|
@ -189,11 +189,15 @@
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.boxTime:first-child {
|
||||
.iptfillself {
|
||||
margin-left: 20px;
|
||||
.effect_dates {
|
||||
margin: 0 10px 0 15px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.zent-select-v2-visible {
|
||||
.zent-select-v2-popup {
|
||||
width: 195px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -291,6 +295,8 @@
|
|||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.dialog_p {
|
||||
|
|
|
@ -1,25 +1,30 @@
|
|||
.zent-form-horizontal[data-zv="9.11.0"] .zent-form-label {
|
||||
flex-basis: 118px!important;
|
||||
justify-content: flex-start!important;
|
||||
flex-basis: 118px !important;
|
||||
justify-content: flex-start !important;
|
||||
}
|
||||
.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content{
|
||||
|
||||
.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.adddistributor .iptfillself .label {
|
||||
margin-right:66px;
|
||||
margin-right: 66px;
|
||||
}
|
||||
.zent-select-v2-popup{
|
||||
width: 250px !important;
|
||||
}
|
||||
.zent-btn-info[data-zv="9.11.0"]{
|
||||
|
||||
// .zent-select-v2-popup{
|
||||
// width: 250px !important;
|
||||
// }
|
||||
.zent-btn-info[data-zv="9.11.0"] {
|
||||
width: 120px;
|
||||
color: #296bef!important;
|
||||
border: none!important;
|
||||
color: #296bef !important;
|
||||
border: none !important;
|
||||
}
|
||||
.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"]{
|
||||
margin-top: -180px;
|
||||
|
||||
.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"] {
|
||||
margin-top: -180px;
|
||||
}
|
||||
.tip-reseller{
|
||||
|
||||
.tip-reseller {
|
||||
color: red;
|
||||
font-size: 12px;
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
.zent-form-horizontal[data-zv="9.11.0"] .zent-form-label {
|
||||
flex-basis: 118px!important;
|
||||
justify-content: flex-start!important;
|
||||
flex-basis: 118px !important;
|
||||
justify-content: flex-start !important;
|
||||
}
|
||||
.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content{
|
||||
|
||||
.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.adddistributor .iptfillself .label {
|
||||
margin-right:66px;
|
||||
}
|
||||
.zent-select-v2-popup{
|
||||
width: 250px !important;
|
||||
margin-right: 66px;
|
||||
}
|
||||
|
||||
// .zent-select-v2-popup{
|
||||
// width: 250px !important;
|
||||
// }
|
27
src/utils.js
27
src/utils.js
|
@ -40,3 +40,30 @@ export function uuid(len, radix) {
|
|||
|
||||
return uuid.join('')
|
||||
}
|
||||
|
||||
//计算两个时间差 返回天
|
||||
export function timeDiff(begin_time, end_time) {
|
||||
//年月日时分秒转换为时间戳
|
||||
let beginTime = new Date(begin_time).getTime() / 1000
|
||||
let endTime = new Date(end_time).getTime() / 1000
|
||||
var starttime = ''
|
||||
var endtime = ''
|
||||
if (beginTime < endTime) {
|
||||
starttime = beginTime
|
||||
endtime = endTime
|
||||
} else {
|
||||
starttime = endTime
|
||||
endtime = beginTime
|
||||
}
|
||||
//计算天数
|
||||
var timediff = endtime - starttime
|
||||
var days = parseInt(timediff / 86400)
|
||||
//计算小时数
|
||||
var remain = timediff % 86400
|
||||
var hours = parseInt(remain / 3600)
|
||||
//计算分钟数
|
||||
var remain = remain % 3600
|
||||
var mins = parseInt(remain / 60)
|
||||
var res = Number((days + hours / 24).toFixed(1))
|
||||
return res
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue