|
@ -2,10 +2,8 @@ |
|
|
<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> |
|
@ -13,11 +11,15 @@ |
|
|
|
|
|
|
|
|
<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 +40,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> |
|
@ -61,8 +63,8 @@ |
|
|
<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" /> |
|
@ -102,8 +104,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 +134,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', |
|
@ -373,7 +384,8 @@ |
|
|
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() { |
|
@ -454,7 +466,9 @@ |
|
|
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 |
|
|
}, |
|
|
}, |
|
@ -492,7 +506,9 @@ |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.$refs.right.changeMonth('next') |
|
|
this.$refs.right.changeMonth('next') |
|
|
this.$refs.right.cale.lastHover = false |
|
|
if (this.isPhone) { |
|
|
|
|
|
this.$refs.right.cale.lastHover = false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -624,7 +640,10 @@ |
|
|
}, |
|
|
}, |
|
|
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 |
|
@ -818,6 +837,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; |
|
@ -832,6 +852,7 @@ |
|
|
.icon-calendar { |
|
|
.icon-calendar { |
|
|
padding-left: 3px; |
|
|
padding-left: 3px; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.range-separator { |
|
|
.range-separator { |
|
|
height: 35px; |
|
|
height: 35px; |
|
|
/* #ifndef MP */ |
|
|
/* #ifndef MP */ |
|
@ -871,7 +892,7 @@ |
|
|
position: relative; |
|
|
position: relative; |
|
|
flex: 1; |
|
|
flex: 1; |
|
|
line-height: 35px; |
|
|
line-height: 35px; |
|
|
font-size: 14px; |
|
|
font-size: 12px; |
|
|
overflow: hidden; |
|
|
overflow: hidden; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|