uu
This commit is contained in:
parent
a5d7623a4a
commit
762bba38b7
@ -59,8 +59,25 @@
|
||||
import { setClipboardData } from "@/common/untool"
|
||||
import { numberToChinese } from "@/common/util"
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
let dayFormat = 'YYYY-MM-DD'
|
||||
let dateTimeFormat = 'YYYY-MM-DD HH:mm:ss'
|
||||
|
||||
export default {
|
||||
watch:{
|
||||
show: {
|
||||
handler: function(cval, oval) {
|
||||
cval && this.initData()
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
modelInfo: {
|
||||
get(){
|
||||
return this.value
|
||||
}
|
||||
},
|
||||
timeFilterList() {
|
||||
const _this = this
|
||||
let list = []
|
||||
@ -77,9 +94,9 @@
|
||||
},
|
||||
value: {
|
||||
default () {
|
||||
return ''
|
||||
return { }
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -106,15 +123,20 @@
|
||||
methods: {
|
||||
initData() {
|
||||
this.makeList()
|
||||
let { pickStartDate, pickFinishDate } = this.modelInfo || {}
|
||||
// 默认值
|
||||
this.model.date = this.dayList[0].val
|
||||
if(pickStartDate && pickFinishDate) {
|
||||
this.model.date = dayjs(pickStartDate).format(dayFormat)
|
||||
this.model.time = `${pickStartDate}~${pickFinishDate}`
|
||||
}
|
||||
},
|
||||
makeList() {
|
||||
const _this = this
|
||||
const now = dayjs(new Date())
|
||||
const nowDate = dayjs(now).format('YYYY-MM-DD')
|
||||
const plus1Date = dayjs(nowDate).add(1, 'day').format('YYYY-MM-DD')
|
||||
const plus2Date = dayjs(nowDate).add(2, 'day').format('YYYY-MM-DD')
|
||||
const nowDate = dayjs(now).format(dayFormat)
|
||||
const plus1Date = dayjs(nowDate).add(1, 'day').format(dayFormat)
|
||||
const plus2Date = dayjs(nowDate).add(2, 'day').format(dayFormat)
|
||||
const nowHour = now.get("hours")
|
||||
let dayList = [
|
||||
{ title: '今天', val: nowDate },
|
||||
@ -129,17 +151,16 @@
|
||||
start = nowHour + 1
|
||||
}
|
||||
for(var tIndex = start; tIndex <= end; tIndex ++) {
|
||||
let cTlt = '', cVal
|
||||
let timeStr = `${tIndex < 10?'0':''}${tIndex}:00`
|
||||
let timeNextStr = `${(tIndex + 1) < 10?'0':''}${(tIndex + 1)}:00`
|
||||
cVal = timeStr
|
||||
cTlt = `${timeStr}-${timeNextStr}`
|
||||
let tItem = {}
|
||||
tItem.startTime = dayjs(`${dItem.val} ${tIndex}`).format(dateTimeFormat)
|
||||
tItem.endTime = dayjs(`${dItem.val} ${tIndex + 1}`).format(dateTimeFormat)
|
||||
|
||||
tItem.val = `${tItem.startTime}~${tItem.endTime}`
|
||||
tItem.title = `${dayjs(tItem.startTime).format("HH:mm")}-${dayjs(tItem.endTime).format("HH:mm")}`
|
||||
if(dIndex == 0 && tIndex == start) {
|
||||
cTlt = `${numberToChinese(start - nowHour)}小时内`
|
||||
tItem.title = `${numberToChinese(start - nowHour)}小时内`
|
||||
}
|
||||
timeList.push({
|
||||
title: cTlt , val: cVal
|
||||
})
|
||||
timeList.push(tItem)
|
||||
}
|
||||
dItem.timeList = timeList
|
||||
})
|
||||
@ -152,8 +173,21 @@
|
||||
handleEditItem() {
|
||||
const { date, time } = this.model
|
||||
const value = `${date} ${time}`
|
||||
this.$emit('onChange', this.model)
|
||||
this.$emit('update:value', value)
|
||||
let curItem
|
||||
this.dayList.map(d=> {
|
||||
if(d.val == date) {
|
||||
d.timeList.map(t=> {
|
||||
if(t.val == time) {
|
||||
curItem = t
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
this.$emit('onChange', curItem)
|
||||
if(curItem){
|
||||
this.modelInfo.pickStartDate = curItem.startTime
|
||||
this.modelInfo.pickFinishDate = curItem.endTime
|
||||
}
|
||||
this.handleCloseModal()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user