|
|
@ -2,22 +2,22 @@
|
|
|
|
<view class="uni-date">
|
|
|
|
<view class="uni-date">
|
|
|
|
<view class="uni-date-editor" @click="show">
|
|
|
|
<view class="uni-date-editor" @click="show">
|
|
|
|
<slot>
|
|
|
|
<slot>
|
|
|
|
<view
|
|
|
|
<view class="uni-date-editor--x"
|
|
|
|
class="uni-date-editor--x"
|
|
|
|
:class="{'uni-date-editor--x__disabled': disabled,'uni-date-x--border': border}">
|
|
|
|
:class="{'uni-date-editor--x__disabled': disabled,'uni-date-x--border': border}"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<view v-if="!isRange" class="uni-date-x uni-date-single">
|
|
|
|
<view v-if="!isRange" class="uni-date-x uni-date-single">
|
|
|
|
<uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
|
|
|
|
<uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
|
|
|
|
<view class="uni-date__x-input">{{ displayValue || singlePlaceholderText }}</view>
|
|
|
|
<view class="uni-date__x-input">{{ displayValue || singlePlaceholderText }}</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view v-else class="uni-date-x uni-date-range">
|
|
|
|
<view v-else class="uni-date-x uni-date-range">
|
|
|
|
<uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
|
|
|
|
<uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
|
|
|
|
<view class="uni-date__x-input text-center">{{ displayRangeValue.startDate || startPlaceholderText }}</view>
|
|
|
|
<view class="uni-date__x-input text-center">
|
|
|
|
|
|
|
|
{{ displayRangeValue.startDate || startPlaceholderText }}</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="range-separator">{{rangeSeparator}}</view>
|
|
|
|
<view class="range-separator">{{rangeSeparator}}</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="uni-date__x-input text-center">{{ displayRangeValue.endDate || endPlaceholderText }}</view>
|
|
|
|
<view class="uni-date__x-input text-center">
|
|
|
|
|
|
|
|
{{ displayRangeValue.endDate || endPlaceholderText }}</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear">
|
|
|
|
<view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear">
|
|
|
@ -38,16 +38,16 @@
|
|
|
|
:placeholder="selectDateText" />
|
|
|
|
:placeholder="selectDateText" />
|
|
|
|
|
|
|
|
|
|
|
|
<time-picker type="time" v-model="pickerTime" :border="false" :disabled="!inputDate"
|
|
|
|
<time-picker type="time" v-model="pickerTime" :border="false" :disabled="!inputDate"
|
|
|
|
:start="timepickerStartTime" :end="timepickerEndTime" :hideSecond="hideSecond" style="width: 100%;">
|
|
|
|
:start="timepickerStartTime" :end="timepickerEndTime" :hideSecond="hideSecond"
|
|
|
|
<input class="uni-date__input text-center" type="text" v-model="pickerTime" :placeholder="selectTimeText"
|
|
|
|
style="width: 100%;">
|
|
|
|
:disabled="!inputDate" />
|
|
|
|
<input class="uni-date__input text-center" type="text" v-model="pickerTime"
|
|
|
|
|
|
|
|
:placeholder="selectTimeText" :disabled="!inputDate" />
|
|
|
|
</time-picker>
|
|
|
|
</time-picker>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<Calendar ref="pcSingle" :showMonth="false" :start-date="calendarRange.startDate"
|
|
|
|
<Calendar ref="pcSingle" :showMonth="false" :start-date="calendarRange.startDate"
|
|
|
|
:end-date="calendarRange.endDate" :date="calendarDate" @change="singleChange"
|
|
|
|
:end-date="calendarRange.endDate" :date="calendarDate" @change="singleChange"
|
|
|
|
:default-value="defaultValue"
|
|
|
|
:default-value="defaultValue" style="padding: 0 8px;" />
|
|
|
|
style="padding: 0 8px;" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<view v-if="hasTime" class="popup-x-footer">
|
|
|
|
<view v-if="hasTime" class="popup-x-footer">
|
|
|
|
<text class="confirm-text" @click="confirmSingleChange">{{okText}}</text>
|
|
|
|
<text class="confirm-text" @click="confirmSingleChange">{{okText}}</text>
|
|
|
@ -58,18 +58,18 @@
|
|
|
|
<view class="uni-popper__arrow"></view>
|
|
|
|
<view class="uni-popper__arrow"></view>
|
|
|
|
<view v-if="hasTime" class="popup-x-header uni-date-changed">
|
|
|
|
<view v-if="hasTime" class="popup-x-header uni-date-changed">
|
|
|
|
<view class="popup-x-header--datetime">
|
|
|
|
<view class="popup-x-header--datetime">
|
|
|
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
|
|
|
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
|
|
|
|
:placeholder="startDateText" />
|
|
|
|
:placeholder="startDateText" />
|
|
|
|
|
|
|
|
|
|
|
|
<time-picker type="time" v-model="tempRange.startTime" :start="timepickerStartTime" :border="false"
|
|
|
|
<time-picker type="time" v-model="tempRange.startTime" :start="timepickerStartTime"
|
|
|
|
:disabled="!tempRange.startDate" :hideSecond="hideSecond">
|
|
|
|
:border="false" :disabled="!tempRange.startDate" :hideSecond="hideSecond">
|
|
|
|
<input class="uni-date__input uni-date-range__input" type="text"
|
|
|
|
<input class="uni-date__input uni-date-range__input" type="text"
|
|
|
|
v-model="tempRange.startTime" :placeholder="startTimeText"
|
|
|
|
v-model="tempRange.startTime" :placeholder="startTimeText"
|
|
|
|
:disabled="!tempRange.startDate" />
|
|
|
|
:disabled="!tempRange.startDate" />
|
|
|
|
</time-picker>
|
|
|
|
</time-picker>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons>
|
|
|
|
<uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="popup-x-header--datetime">
|
|
|
|
<view class="popup-x-header--datetime">
|
|
|
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate"
|
|
|
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate"
|
|
|
@ -85,8 +85,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
<view class="popup-x-body">
|
|
|
|
<view class="popup-x-body">
|
|
|
|
<Calendar ref="left" :showMonth="false" :start-date="calendarRange.startDate"
|
|
|
|
<Calendar ref="left" :showMonth="false" :start-date="calendarRange.startDate"
|
|
|
|
:end-date="calendarRange.endDate" :range="true" :pleStatus="endMultipleStatus"
|
|
|
|
:end-date="calendarRange.endDate" :range="true" :pleStatus="endMultipleStatus"
|
|
|
|
@change="leftChange" @firstEnterCale="updateRightCale" style="padding: 0 8px;" />
|
|
|
|
@change="leftChange" @firstEnterCale="updateRightCale" style="padding: 0 8px;" />
|
|
|
|
<Calendar ref="right" :showMonth="false" :start-date="calendarRange.startDate"
|
|
|
|
<Calendar ref="right" :showMonth="false" :start-date="calendarRange.startDate"
|
|
|
|
:end-date="calendarRange.endDate" :range="true" @change="rightChange"
|
|
|
|
:end-date="calendarRange.endDate" :range="true" @change="rightChange"
|
|
|
|
:pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale"
|
|
|
|
:pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale"
|
|
|
@ -102,8 +102,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
<Calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="calendarDate" :defTime="mobileCalendarTime"
|
|
|
|
<Calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="calendarDate" :defTime="mobileCalendarTime"
|
|
|
|
:start-date="calendarRange.startDate" :end-date="calendarRange.endDate" :selectableTimes="mobSelectableTime"
|
|
|
|
:start-date="calendarRange.startDate" :end-date="calendarRange.endDate" :selectableTimes="mobSelectableTime"
|
|
|
|
:startPlaceholder="startPlaceholder" :endPlaceholder="endPlaceholder"
|
|
|
|
:startPlaceholder="startPlaceholder" :endPlaceholder="endPlaceholder" :default-value="defaultValue"
|
|
|
|
:default-value="defaultValue"
|
|
|
|
|
|
|
|
:pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :hasTime="hasTime" :insert="false"
|
|
|
|
:pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :hasTime="hasTime" :insert="false"
|
|
|
|
:hideSecond="hideSecond" @confirm="mobileChange" @maskClose="close" />
|
|
|
|
:hideSecond="hideSecond" @confirm="mobileChange" @maskClose="close" />
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
@ -133,9 +132,19 @@
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
import Calendar from './calendar.vue'
|
|
|
|
import Calendar from './calendar.vue'
|
|
|
|
import TimePicker from './time-picker.vue'
|
|
|
|
import TimePicker from './time-picker.vue'
|
|
|
|
import { initVueI18n } from '@dcloudio/uni-i18n'
|
|
|
|
import {
|
|
|
|
|
|
|
|
initVueI18n
|
|
|
|
|
|
|
|
} from '@dcloudio/uni-i18n'
|
|
|
|
import i18nMessages from './i18n/index.js'
|
|
|
|
import i18nMessages from './i18n/index.js'
|
|
|
|
import { getDateTime, getDate, getTime, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat } from './util'
|
|
|
|
import {
|
|
|
|
|
|
|
|
getDateTime,
|
|
|
|
|
|
|
|
getDate,
|
|
|
|
|
|
|
|
getTime,
|
|
|
|
|
|
|
|
getDefaultSecond,
|
|
|
|
|
|
|
|
dateCompare,
|
|
|
|
|
|
|
|
checkDate,
|
|
|
|
|
|
|
|
fixIosDateFormat
|
|
|
|
|
|
|
|
} from './util'
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: 'UniDatetimePicker',
|
|
|
|
name: 'UniDatetimePicker',
|
|
|
@ -188,7 +197,7 @@
|
|
|
|
isEmitValue: false,
|
|
|
|
isEmitValue: false,
|
|
|
|
isPhone: false,
|
|
|
|
isPhone: false,
|
|
|
|
isFirstShow: true,
|
|
|
|
isFirstShow: true,
|
|
|
|
i18nT: () => {}
|
|
|
|
i18nT: () => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
@ -221,7 +230,7 @@
|
|
|
|
default: ''
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
startPlaceholder: {
|
|
|
|
startPlaceholder: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
endPlaceholder: {
|
|
|
|
endPlaceholder: {
|
|
|
@ -248,16 +257,16 @@
|
|
|
|
type: [Boolean],
|
|
|
|
type: [Boolean],
|
|
|
|
default: false
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
defaultValue: {
|
|
|
|
defaultValue: {
|
|
|
|
type: [String, Object, Array],
|
|
|
|
type: [String, Object, Array],
|
|
|
|
default: ''
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
type: {
|
|
|
|
type: {
|
|
|
|
immediate: true,
|
|
|
|
immediate: true,
|
|
|
|
handler(newVal) {
|
|
|
|
handler(newVal) {
|
|
|
|
this.hasTime = newVal.indexOf('time') !== -1
|
|
|
|
this.hasTime = newVal.indexOf('time') !== -1
|
|
|
|
this.isRange = newVal.indexOf('range') !== -1
|
|
|
|
this.isRange = newVal.indexOf('range') !== -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -348,9 +357,9 @@
|
|
|
|
selectDateText() {
|
|
|
|
selectDateText() {
|
|
|
|
return this.i18nT("uni-datetime-picker.selectDate")
|
|
|
|
return this.i18nT("uni-datetime-picker.selectDate")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selectDateTimeText() {
|
|
|
|
selectDateTimeText() {
|
|
|
|
return this.i18nT("uni-datetime-picker.selectDateTime")
|
|
|
|
return this.i18nT("uni-datetime-picker.selectDateTime")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selectTimeText() {
|
|
|
|
selectTimeText() {
|
|
|
|
return this.i18nT("uni-datetime-picker.selectTime")
|
|
|
|
return this.i18nT("uni-datetime-picker.selectTime")
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -373,18 +382,19 @@
|
|
|
|
return this.i18nT("uni-datetime-picker.clear")
|
|
|
|
return this.i18nT("uni-datetime-picker.clear")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
showClearIcon() {
|
|
|
|
showClearIcon() {
|
|
|
|
return this.clearIcon && !this.disabled && (this.displayValue || (this.displayRangeValue.startDate && this.displayRangeValue.endDate))
|
|
|
|
return this.clearIcon && !this.disabled && (this.displayValue || (this.displayRangeValue.startDate && this
|
|
|
|
|
|
|
|
.displayRangeValue.endDate))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
created() {
|
|
|
|
this.initI18nT()
|
|
|
|
this.initI18nT()
|
|
|
|
this.platform()
|
|
|
|
this.platform()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
initI18nT() {
|
|
|
|
initI18nT() {
|
|
|
|
const vueI18n = initVueI18n(i18nMessages)
|
|
|
|
const vueI18n = initVueI18n(i18nMessages)
|
|
|
|
this.i18nT = vueI18n.t
|
|
|
|
this.i18nT = vueI18n.t
|
|
|
|
},
|
|
|
|
},
|
|
|
|
initPicker(newVal) {
|
|
|
|
initPicker(newVal) {
|
|
|
|
if ((!newVal && !this.defaultValue) || Array.isArray(newVal) && !newVal.length) {
|
|
|
|
if ((!newVal && !this.defaultValue) || Array.isArray(newVal) && !newVal.length) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$nextTick(() => {
|
|
|
@ -394,26 +404,26 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!Array.isArray(newVal) && !this.isRange) {
|
|
|
|
if (!Array.isArray(newVal) && !this.isRange) {
|
|
|
|
if(newVal){
|
|
|
|
if (newVal) {
|
|
|
|
this.displayValue = this.inputDate = this.calendarDate = getDate(newVal)
|
|
|
|
this.displayValue = this.inputDate = this.calendarDate = getDate(newVal)
|
|
|
|
if (this.hasTime) {
|
|
|
|
if (this.hasTime) {
|
|
|
|
this.pickerTime = getTime(newVal, this.hideSecond)
|
|
|
|
this.pickerTime = getTime(newVal, this.hideSecond)
|
|
|
|
this.displayValue = `${this.displayValue} ${this.pickerTime}`
|
|
|
|
this.displayValue = `${this.displayValue} ${this.pickerTime}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(this.defaultValue){
|
|
|
|
} else if (this.defaultValue) {
|
|
|
|
this.inputDate = this.calendarDate = getDate(this.defaultValue)
|
|
|
|
this.inputDate = this.calendarDate = getDate(this.defaultValue)
|
|
|
|
if(this.hasTime){
|
|
|
|
if (this.hasTime) {
|
|
|
|
this.pickerTime = getTime(this.defaultValue, this.hideSecond)
|
|
|
|
this.pickerTime = getTime(this.defaultValue, this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const [before, after] = newVal
|
|
|
|
const [before, after] = newVal
|
|
|
|
if (!before && !after) return
|
|
|
|
if (!before && !after) return
|
|
|
|
const beforeDate = getDate(before)
|
|
|
|
const beforeDate = getDate(before)
|
|
|
|
const beforeTime = getTime(before, this.hideSecond)
|
|
|
|
const beforeTime = getTime(before, this.hideSecond)
|
|
|
|
|
|
|
|
|
|
|
|
const afterDate = getDate(after)
|
|
|
|
const afterDate = getDate(after)
|
|
|
|
const afterTime = getTime(after, this.hideSecond)
|
|
|
|
const afterTime = getTime(after, this.hideSecond)
|
|
|
|
const startDate = beforeDate
|
|
|
|
const startDate = beforeDate
|
|
|
|
const endDate = afterDate
|
|
|
|
const endDate = afterDate
|
|
|
|
this.displayRangeValue.startDate = this.tempRange.startDate = startDate
|
|
|
|
this.displayRangeValue.startDate = this.tempRange.startDate = startDate
|
|
|
@ -450,11 +460,13 @@
|
|
|
|
right.setDate(this.$refs.right.nowDate.fullDate)
|
|
|
|
right.setDate(this.$refs.right.nowDate.fullDate)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
platform() {
|
|
|
|
platform() {
|
|
|
|
if(typeof navigator !== "undefined"){
|
|
|
|
if (typeof navigator !== "undefined") {
|
|
|
|
this.isPhone = navigator.userAgent.toLowerCase().indexOf('mobile') !== -1
|
|
|
|
this.isPhone = navigator.userAgent.toLowerCase().indexOf('mobile') !== -1
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const { windowWidth } = uni.getSystemInfoSync()
|
|
|
|
const {
|
|
|
|
|
|
|
|
windowWidth
|
|
|
|
|
|
|
|
} = uni.getSystemInfoSync()
|
|
|
|
this.isPhone = windowWidth <= 500
|
|
|
|
this.isPhone = windowWidth <= 500
|
|
|
|
this.windowWidth = windowWidth
|
|
|
|
this.windowWidth = windowWidth
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -465,8 +477,8 @@
|
|
|
|
this.platform()
|
|
|
|
this.platform()
|
|
|
|
if (this.isPhone) {
|
|
|
|
if (this.isPhone) {
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.$refs.mobile.open()
|
|
|
|
this.$refs.mobile.open()
|
|
|
|
}, 0);
|
|
|
|
}, 0);
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.pickerPositionStyle = {
|
|
|
|
this.pickerPositionStyle = {
|
|
|
@ -544,52 +556,52 @@
|
|
|
|
this.confirmSingleChange()
|
|
|
|
this.confirmSingleChange()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
confirmSingleChange() {
|
|
|
|
confirmSingleChange() {
|
|
|
|
if(!checkDate(this.inputDate)){
|
|
|
|
if (!checkDate(this.inputDate)) {
|
|
|
|
const now = new Date()
|
|
|
|
const now = new Date()
|
|
|
|
this.calendarDate = this.inputDate = getDate(now)
|
|
|
|
this.calendarDate = this.inputDate = getDate(now)
|
|
|
|
this.pickerTime = getTime(now, this.hideSecond)
|
|
|
|
this.pickerTime = getTime(now, this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let startLaterInputDate = false
|
|
|
|
let startLaterInputDate = false
|
|
|
|
let startDate, startTime
|
|
|
|
let startDate, startTime
|
|
|
|
if(this.start) {
|
|
|
|
if (this.start) {
|
|
|
|
let startString = this.start
|
|
|
|
let startString = this.start
|
|
|
|
if(typeof this.start === 'number'){
|
|
|
|
if (typeof this.start === 'number') {
|
|
|
|
startString = getDateTime(this.start, this.hideSecond)
|
|
|
|
startString = getDateTime(this.start, this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[startDate, startTime] = startString.split(' ')
|
|
|
|
[startDate, startTime] = startString.split(' ')
|
|
|
|
if(this.start && !dateCompare(startDate, this.inputDate)) {
|
|
|
|
if (this.start && !dateCompare(startDate, this.inputDate)) {
|
|
|
|
startLaterInputDate = true
|
|
|
|
startLaterInputDate = true
|
|
|
|
this.inputDate = startDate
|
|
|
|
this.inputDate = startDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let endEarlierInputDate = false
|
|
|
|
let endEarlierInputDate = false
|
|
|
|
let endDate, endTime
|
|
|
|
let endDate, endTime
|
|
|
|
if(this.end) {
|
|
|
|
if (this.end) {
|
|
|
|
let endString = this.end
|
|
|
|
let endString = this.end
|
|
|
|
if(typeof this.end === 'number'){
|
|
|
|
if (typeof this.end === 'number') {
|
|
|
|
endString = getDateTime(this.end, this.hideSecond)
|
|
|
|
endString = getDateTime(this.end, this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[endDate, endTime] = endString.split(' ')
|
|
|
|
[endDate, endTime] = endString.split(' ')
|
|
|
|
if(this.end && !dateCompare(this.inputDate, endDate)) {
|
|
|
|
if (this.end && !dateCompare(this.inputDate, endDate)) {
|
|
|
|
endEarlierInputDate = true
|
|
|
|
endEarlierInputDate = true
|
|
|
|
this.inputDate = endDate
|
|
|
|
this.inputDate = endDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.hasTime) {
|
|
|
|
if (this.hasTime) {
|
|
|
|
if(startLaterInputDate){
|
|
|
|
if (startLaterInputDate) {
|
|
|
|
this.pickerTime = startTime || getDefaultSecond(this.hideSecond)
|
|
|
|
this.pickerTime = startTime || getDefaultSecond(this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(endEarlierInputDate){
|
|
|
|
if (endEarlierInputDate) {
|
|
|
|
this.pickerTime = endTime || getDefaultSecond(this.hideSecond)
|
|
|
|
this.pickerTime = endTime || getDefaultSecond(this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!this.pickerTime){
|
|
|
|
if (!this.pickerTime) {
|
|
|
|
this.pickerTime = getTime(Date.now(), this.hideSecond)
|
|
|
|
this.pickerTime = getTime(Date.now(), this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.displayValue = `${this.inputDate} ${this.pickerTime}`
|
|
|
|
this.displayValue = `${this.inputDate} ${this.pickerTime}`
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.displayValue = this.inputDate
|
|
|
|
this.displayValue = this.inputDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setEmit(this.displayValue)
|
|
|
|
this.setEmit(this.displayValue)
|
|
|
|
this.pickerVisible = false
|
|
|
|
this.pickerVisible = false
|
|
|
@ -624,11 +636,14 @@
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mobileChange(e) {
|
|
|
|
mobileChange(e) {
|
|
|
|
if (this.isRange) {
|
|
|
|
if (this.isRange) {
|
|
|
|
const {before, after} = e.range
|
|
|
|
const {
|
|
|
|
|
|
|
|
before,
|
|
|
|
|
|
|
|
after
|
|
|
|
|
|
|
|
} = e.range
|
|
|
|
|
|
|
|
|
|
|
|
if(!before || !after){
|
|
|
|
if (!before || !after) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.handleStartAndEnd(before, after, true)
|
|
|
|
this.handleStartAndEnd(before, after, true)
|
|
|
|
if (this.hasTime) {
|
|
|
|
if (this.hasTime) {
|
|
|
@ -661,79 +676,79 @@
|
|
|
|
this.pickerVisible = false
|
|
|
|
this.pickerVisible = false
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!checkDate(this.tempRange.startDate)){
|
|
|
|
if (!checkDate(this.tempRange.startDate)) {
|
|
|
|
this.tempRange.startDate = getDate(Date.now())
|
|
|
|
this.tempRange.startDate = getDate(Date.now())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!checkDate(this.tempRange.endDate)){
|
|
|
|
if (!checkDate(this.tempRange.endDate)) {
|
|
|
|
this.tempRange.endDate = getDate(Date.now())
|
|
|
|
this.tempRange.endDate = getDate(Date.now())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let start, end
|
|
|
|
let start, end
|
|
|
|
|
|
|
|
|
|
|
|
let startDateLaterRangeStartDate = false
|
|
|
|
let startDateLaterRangeStartDate = false
|
|
|
|
let startDateLaterRangeEndDate = false
|
|
|
|
let startDateLaterRangeEndDate = false
|
|
|
|
let startDate, startTime
|
|
|
|
let startDate, startTime
|
|
|
|
if(this.start) {
|
|
|
|
if (this.start) {
|
|
|
|
let startString = this.start
|
|
|
|
let startString = this.start
|
|
|
|
if(typeof this.start === 'number'){
|
|
|
|
if (typeof this.start === 'number') {
|
|
|
|
startString = getDateTime(this.start, this.hideSecond)
|
|
|
|
startString = getDateTime(this.start, this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[startDate,startTime] = startString.split(' ')
|
|
|
|
[startDate, startTime] = startString.split(' ')
|
|
|
|
if(this.start && !dateCompare(this.start, this.tempRange.startDate)) {
|
|
|
|
if (this.start && !dateCompare(this.start, this.tempRange.startDate)) {
|
|
|
|
startDateLaterRangeStartDate = true
|
|
|
|
startDateLaterRangeStartDate = true
|
|
|
|
this.tempRange.startDate = startDate
|
|
|
|
this.tempRange.startDate = startDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.start && !dateCompare(this.start, this.tempRange.endDate)) {
|
|
|
|
if (this.start && !dateCompare(this.start, this.tempRange.endDate)) {
|
|
|
|
startDateLaterRangeEndDate = true
|
|
|
|
startDateLaterRangeEndDate = true
|
|
|
|
this.tempRange.endDate = startDate
|
|
|
|
this.tempRange.endDate = startDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let endDateEarlierRangeStartDate = false
|
|
|
|
let endDateEarlierRangeStartDate = false
|
|
|
|
let endDateEarlierRangeEndDate = false
|
|
|
|
let endDateEarlierRangeEndDate = false
|
|
|
|
let endDate, endTime
|
|
|
|
let endDate, endTime
|
|
|
|
if(this.end) {
|
|
|
|
if (this.end) {
|
|
|
|
let endString = this.end
|
|
|
|
let endString = this.end
|
|
|
|
if(typeof this.end === 'number'){
|
|
|
|
if (typeof this.end === 'number') {
|
|
|
|
endString = getDateTime(this.end, this.hideSecond)
|
|
|
|
endString = getDateTime(this.end, this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[endDate,endTime] = endString.split(' ')
|
|
|
|
[endDate, endTime] = endString.split(' ')
|
|
|
|
|
|
|
|
|
|
|
|
if(this.end && !dateCompare(this.tempRange.startDate, this.end)) {
|
|
|
|
if (this.end && !dateCompare(this.tempRange.startDate, this.end)) {
|
|
|
|
endDateEarlierRangeStartDate = true
|
|
|
|
endDateEarlierRangeStartDate = true
|
|
|
|
this.tempRange.startDate = endDate
|
|
|
|
this.tempRange.startDate = endDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.end && !dateCompare(this.tempRange.endDate, this.end)) {
|
|
|
|
if (this.end && !dateCompare(this.tempRange.endDate, this.end)) {
|
|
|
|
endDateEarlierRangeEndDate = true
|
|
|
|
endDateEarlierRangeEndDate = true
|
|
|
|
this.tempRange.endDate = endDate
|
|
|
|
this.tempRange.endDate = endDate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!this.hasTime) {
|
|
|
|
if (!this.hasTime) {
|
|
|
|
start = this.displayRangeValue.startDate = this.tempRange.startDate
|
|
|
|
start = this.displayRangeValue.startDate = this.tempRange.startDate
|
|
|
|
end = this.displayRangeValue.endDate = this.tempRange.endDate
|
|
|
|
end = this.displayRangeValue.endDate = this.tempRange.endDate
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if(startDateLaterRangeStartDate){
|
|
|
|
if (startDateLaterRangeStartDate) {
|
|
|
|
this.tempRange.startTime = startTime || getDefaultSecond(this.hideSecond)
|
|
|
|
this.tempRange.startTime = startTime || getDefaultSecond(this.hideSecond)
|
|
|
|
}else if(endDateEarlierRangeStartDate){
|
|
|
|
} else if (endDateEarlierRangeStartDate) {
|
|
|
|
this.tempRange.startTime = endTime || getDefaultSecond(this.hideSecond)
|
|
|
|
this.tempRange.startTime = endTime || getDefaultSecond(this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!this.tempRange.startTime){
|
|
|
|
if (!this.tempRange.startTime) {
|
|
|
|
this.tempRange.startTime = getTime(Date.now(), this.hideSecond)
|
|
|
|
this.tempRange.startTime = getTime(Date.now(), this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(startDateLaterRangeEndDate){
|
|
|
|
if (startDateLaterRangeEndDate) {
|
|
|
|
this.tempRange.endTime = startTime || getDefaultSecond(this.hideSecond)
|
|
|
|
this.tempRange.endTime = startTime || getDefaultSecond(this.hideSecond)
|
|
|
|
}else if(endDateEarlierRangeEndDate){
|
|
|
|
} else if (endDateEarlierRangeEndDate) {
|
|
|
|
this.tempRange.endTime = endTime || getDefaultSecond(this.hideSecond)
|
|
|
|
this.tempRange.endTime = endTime || getDefaultSecond(this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!this.tempRange.endTime){
|
|
|
|
if (!this.tempRange.endTime) {
|
|
|
|
this.tempRange.endTime = getTime(Date.now(), this.hideSecond)
|
|
|
|
this.tempRange.endTime = getTime(Date.now(), this.hideSecond)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
start = this.displayRangeValue.startDate = `${this.tempRange.startDate} ${this.tempRange.startTime}`
|
|
|
|
start = this.displayRangeValue.startDate = `${this.tempRange.startDate} ${this.tempRange.startTime}`
|
|
|
|
end = this.displayRangeValue.endDate = `${this.tempRange.endDate} ${this.tempRange.endTime}`
|
|
|
|
end = this.displayRangeValue.endDate = `${this.tempRange.endDate} ${this.tempRange.endTime}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!dateCompare(start,end)){
|
|
|
|
if (!dateCompare(start, end)) {
|
|
|
|
[start, end] = [end, start]
|
|
|
|
[start, end] = [end, start]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.displayRangeValue.startDate = start
|
|
|
|
this.displayRangeValue.startDate = start
|
|
|
|
this.displayRangeValue.endDate = end
|
|
|
|
this.displayRangeValue.endDate = end
|
|
|
|
const displayRange = [start, end]
|
|
|
|
const displayRange = [start, end]
|
|
|
@ -744,10 +759,10 @@
|
|
|
|
if (!(before && after)) return
|
|
|
|
if (!(before && after)) return
|
|
|
|
|
|
|
|
|
|
|
|
const type = temp ? 'tempRange' : 'range'
|
|
|
|
const type = temp ? 'tempRange' : 'range'
|
|
|
|
const isStartEarlierEnd = dateCompare(before, after)
|
|
|
|
const isStartEarlierEnd = dateCompare(before, after)
|
|
|
|
this[type].startDate = isStartEarlierEnd ? before : after
|
|
|
|
this[type].startDate = isStartEarlierEnd ? before : after
|
|
|
|
this[type].endDate = isStartEarlierEnd ? after : before
|
|
|
|
this[type].endDate = isStartEarlierEnd ? after : before
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 比较时间大小
|
|
|
|
* 比较时间大小
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -818,6 +833,7 @@
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
flex: 1;
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.uni-date-x {
|
|
|
|
.uni-date-x {
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
flex-direction: row;
|
|
|
@ -829,16 +845,17 @@
|
|
|
|
font-size: 14px;
|
|
|
|
font-size: 14px;
|
|
|
|
flex: 1;
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
|
|
|
|
.icon-calendar{
|
|
|
|
.icon-calendar {
|
|
|
|
padding-left: 3px;
|
|
|
|
padding-left: 3px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.range-separator{
|
|
|
|
|
|
|
|
height: 35px;
|
|
|
|
.range-separator {
|
|
|
|
/* #ifndef MP */
|
|
|
|
height: 35px;
|
|
|
|
padding: 0 2px;
|
|
|
|
/* #ifndef MP */
|
|
|
|
/* #endif */
|
|
|
|
padding: 0 2px;
|
|
|
|
|
|
|
|
/* #endif */
|
|
|
|
line-height: 35px;
|
|
|
|
line-height: 35px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.uni-date-x--border {
|
|
|
|
.uni-date-x--border {
|
|
|
@ -865,9 +882,9 @@
|
|
|
|
.uni-date__x-input {
|
|
|
|
.uni-date__x-input {
|
|
|
|
width: auto;
|
|
|
|
width: auto;
|
|
|
|
height: 35px;
|
|
|
|
height: 35px;
|
|
|
|
/* #ifndef MP */
|
|
|
|
/* #ifndef MP */
|
|
|
|
padding-left: 5px;
|
|
|
|
padding-left: 5px;
|
|
|
|
/* #endif */
|
|
|
|
/* #endif */
|
|
|
|
position: relative;
|
|
|
|
position: relative;
|
|
|
|
flex: 1;
|
|
|
|
flex: 1;
|
|
|
|
line-height: 35px;
|
|
|
|
line-height: 35px;
|
|
|
|