0
篇帖子
<a-row type="flex" justify="center">
<a-col :span="10">
<a-form-model-item ref="PickerValue" label="直播时间起 " prop="PickerValue">
<!-- v-model="form.PickerValue" -->
<a-time-picker :open.sync="StartTime" :disabled="isEdit== true ? false : true" style="flex: 1;width: 100%;" v-model="form.PickerValue" format="HH:mm" @change="(val,dateStrings)=>changeTime(val,dateStrings,'startTime')">
<div slot="addon" slot-scope="panel" style="display: flex;align-items: center;justify-content: flex-end;">
<a-button size="small" type="primary" @click="handleClose">
确定
</a-button>
</div>
</a-time-picker>
</a-form-model-item>
</a-col>
<a-col :span="10">
<a-form-model-item ref="PickerValueTwo" label="直播时间止 " prop="PickerValueTwo">
<!-- v-model="form.PickerValueTwo" moment(this.form.PickerValue, 'HH:mm:ss')-->
<a-time-picker :open.sync="EndTime" :disabledHours="getDisabledHours" :disabledMinutes="getDisabledMinutes" :disabledSeconds="getDisabledSeconds" v-model="form.PickerValueTwo" @change="(val,dateStrings)=>changeTime(val,dateStrings,'endTime')" format="HH:mm" :disabled="isEdit== true ? false : true" style="flex: 1;width: 100%;">
<div slot="addon" slot-scope="panel" style="display: flex;align-items: center;justify-content: flex-end;">
<a-button size="small" type="primary" @click="handleClose">
确定
</a-button>
</div>
</a-time-picker>
</a-form-model-item>
</a-col>
</a-row>
data() {
return {
form: {
PickerValue: '', //开始时间
PickerValueTwo: '', //结束时间
},
}
}
handleClose() {
this.StartTime = false;
this.EndTime = false;
},
changeTime(val, dateStrings, type) {
// console.log(dateStrings);
if (type === 'startTime') {
if (dateStrings !== '') {
this.form.PickerValue = moment(dateStrings, 'HH:mm')
} else {
this.form.PickerValue = ''
}
} else if (type === 'endTime') {
if (dateStrings !== '') {
this.form.PickerValueTwo = moment(dateStrings, 'HH:mm')
} else {
this.form.PickerValueTwo = ''
}
}
},
getDisabledHours() {
let hours = []
let time = moment(this.form.PickerValue, 'HH:mm').format('HH:mm')
// console.log(time);
let timeArr = time.split(':')
for (var i = 0; i < parseInt(timeArr[0]); i++) {
hours.push(i)
}
return hours
},
getDisabledMinutes(selectedHour) {
let time = moment(this.form.PickerValue, 'HH:mm:ss').format('HH:mm')
// console.log(time);
let timeArr = time.split(':')
let minutes = []
if (selectedHour == parseInt(timeArr[0])) {
for (var i = 0; i < parseInt(timeArr[1]); i++) {
minutes.push(i)
}
}
return minutes
},
getDisabledSeconds(selectedHour, selectedMinute) {
let time = moment(this.form.PickerValue, 'HH:mm').format('HH:mm')
// console.log(time);
let timeArr = time.split(':')
let second = []
if (selectedHour == parseInt(timeArr[0]) && selectedMinute == parseInt(timeArr[1])) {
for (var i = 0; i <= parseInt(timeArr[2]); i++) {
second.push(i)
}
}
return second
},
本博客内所有原创和翻译的文章的版权归本人所有,允许第三方转载,但转载时请务必保留作者名,并注明出处链接,否则本人将保留追究其法律责任的权利。
「人生在世,留句话给我吧」