码迷,mamicode.com
首页 > 其他好文 > 详细

iview TimePicker实现选择时间段

时间:2020-06-03 16:05:08      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:type   orm   int   get   时间   otto   选择   nic   mep   


<FormItem label="拜访时间" prop="fromHospital">
<TimePicker
v-model="value"
format="HH:mm"
:value="value"
type="timerange"
placement="bottom-start"
placeholder="Select time"
style="width:310px"
@on-change="getDuration"></TimePicker>
</FormItem>




getDuration () {
var startTime = this.value[0].split(‘:‘)
var endTime = this.value[1].split(‘:‘)
console.log(this.value[0])
console.log(this.value[1])
this.formItem.clinicalStartTimeStr = this.value[0]
this.formItem.clinicalEndTimeStr = this.value[1]
var time = (parseInt(endTime[0]) * 60 + parseInt(endTime[1])) - (parseInt(startTime[0]) * 60 + parseInt(startTime[1]))
// 小时数
var hour = parseInt(time / 60)
var minute = time % 60
if (hour > 0) {
// return hour+"小时"+minute+"分钟"
if (hour) {
this.formValidate.duration = hour + ‘小时‘ + minute + ‘分钟‘
} else {
this.formValidate.duration = ‘‘
}
} else {
if (!isNaN(minute)) {
this.formValidate.duration = minute + ‘分钟‘
} else {
this.formValidate.duration = ‘‘
}
}
},

iview TimePicker实现选择时间段

标签:type   orm   int   get   时间   otto   选择   nic   mep   

原文地址:https://www.cnblogs.com/nlovestudy/p/13037430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!