update DateTimePicker
update DateTimePicker
This commit is contained in:
parent
3693144258
commit
2dc2771349
8 changed files with 92 additions and 36 deletions
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="[prefixCls + '-confirm']">
|
<div :class="[prefixCls + '-confirm']">
|
||||||
<span v-if="showTime" @click="handleToggleTime">
|
<span :class="timeClasses" v-if="showTime" @click="handleToggleTime">
|
||||||
<template v-if="isTime">选择日期</template>
|
<template v-if="isTime">选择日期</template>
|
||||||
<template v-else>选择时间</template>
|
<template v-else>选择时间</template>
|
||||||
</span>
|
</span>
|
||||||
|
@ -17,13 +17,21 @@
|
||||||
components: { iButton },
|
components: { iButton },
|
||||||
props: {
|
props: {
|
||||||
showTime: false,
|
showTime: false,
|
||||||
isTime: false
|
isTime: false,
|
||||||
|
timeDisabled: false
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefixCls: prefixCls
|
prefixCls: prefixCls
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
timeClasses () {
|
||||||
|
return {
|
||||||
|
[`${prefixCls}-confirm-time-disabled`]: this.timeDisabled
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClear () {
|
handleClear () {
|
||||||
this.$emit('on-pick-clear');
|
this.$emit('on-pick-clear');
|
||||||
|
@ -32,6 +40,7 @@
|
||||||
this.$emit('on-pick-success');
|
this.$emit('on-pick-success');
|
||||||
},
|
},
|
||||||
handleToggleTime () {
|
handleToggleTime () {
|
||||||
|
if (this.timeDisabled) return;
|
||||||
this.$emit('on-pick-toggle-time');
|
this.$emit('on-pick-toggle-time');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</div>
|
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-body']">
|
<div :class="[prefixCls + '-body']">
|
||||||
<div :class="[prefixCls + '-content', prefixCls + '-content-left']">
|
<div :class="[prefixCls + '-content', prefixCls + '-content-left']" v-show="!isTime">
|
||||||
<div :class="[datePrefixCls + '-header']" v-show="leftCurrentView !== 'time'">
|
<div :class="[datePrefixCls + '-header']" v-show="leftCurrentView !== 'time'">
|
||||||
<span
|
<span
|
||||||
:class="iconBtnCls('prev', '-double')"
|
:class="iconBtnCls('prev', '-double')"
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
@on-pick="handleLeftMonthPick"
|
@on-pick="handleLeftMonthPick"
|
||||||
@on-pick-click="handlePickClick"></month-table>
|
@on-pick-click="handlePickClick"></month-table>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-content', prefixCls + '-content-right']">
|
<div :class="[prefixCls + '-content', prefixCls + '-content-right']" v-show="!isTime">
|
||||||
<div :class="[datePrefixCls + '-header']" v-show="rightCurrentView !== 'time'">
|
<div :class="[datePrefixCls + '-header']" v-show="rightCurrentView !== 'time'">
|
||||||
<span
|
<span
|
||||||
:class="iconBtnCls('prev', '-double')"
|
:class="iconBtnCls('prev', '-double')"
|
||||||
|
@ -113,8 +113,18 @@
|
||||||
@on-pick="handleRightMonthPick"
|
@on-pick="handleRightMonthPick"
|
||||||
@on-pick-click="handlePickClick"></month-table>
|
@on-pick-click="handlePickClick"></month-table>
|
||||||
</div>
|
</div>
|
||||||
|
<div :class="[prefixCls + '-content']" v-show="isTime">
|
||||||
|
<time-picker
|
||||||
|
v-ref:time-picker
|
||||||
|
v-show="isTime"
|
||||||
|
@on-pick="handleTimePick"></time-picker>
|
||||||
|
</div>
|
||||||
<Confirm
|
<Confirm
|
||||||
v-if="confirm"
|
v-if="confirm"
|
||||||
|
:show-time="showTime"
|
||||||
|
:is-time="isTime"
|
||||||
|
:time-disabled="timeDisabled"
|
||||||
|
@on-pick-toggle-time="handleToggleTime"
|
||||||
@on-pick-clear="handlePickClear"
|
@on-pick-clear="handlePickClear"
|
||||||
@on-pick-success="handlePickSuccess"></Confirm>
|
@on-pick-success="handlePickSuccess"></Confirm>
|
||||||
</div>
|
</div>
|
||||||
|
@ -125,6 +135,7 @@
|
||||||
import DateTable from '../base/date-table.vue';
|
import DateTable from '../base/date-table.vue';
|
||||||
import YearTable from '../base/year-table.vue';
|
import YearTable from '../base/year-table.vue';
|
||||||
import MonthTable from '../base/month-table.vue';
|
import MonthTable from '../base/month-table.vue';
|
||||||
|
import TimePicker from './time-range.vue';
|
||||||
import Confirm from '../base/confirm.vue';
|
import Confirm from '../base/confirm.vue';
|
||||||
import { toDate, prevMonth, nextMonth, initTimeDate } from '../util';
|
import { toDate, prevMonth, nextMonth, initTimeDate } from '../util';
|
||||||
|
|
||||||
|
@ -135,7 +146,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [Mixin],
|
mixins: [Mixin],
|
||||||
components: { Icon, DateTable, YearTable, MonthTable, Confirm },
|
components: { Icon, DateTable, YearTable, MonthTable, TimePicker, Confirm },
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefixCls: prefixCls,
|
prefixCls: prefixCls,
|
||||||
|
@ -156,7 +167,9 @@
|
||||||
rightCurrentView: 'date',
|
rightCurrentView: 'date',
|
||||||
selectionMode: 'range',
|
selectionMode: 'range',
|
||||||
leftTableYear: null,
|
leftTableYear: null,
|
||||||
rightTableYear: null
|
rightTableYear: null,
|
||||||
|
isTime: false,
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -231,6 +244,9 @@
|
||||||
newDate.setMonth(month + 1);
|
newDate.setMonth(month + 1);
|
||||||
}
|
}
|
||||||
return newDate;
|
return newDate;
|
||||||
|
},
|
||||||
|
timeDisabled () {
|
||||||
|
return !(this.minDate && this.maxDate);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -243,6 +259,19 @@
|
||||||
this.maxDate = newVal[1] ? toDate(newVal[1]) : null;
|
this.maxDate = newVal[1] ? toDate(newVal[1]) : null;
|
||||||
if (this.minDate) this.date = new Date(this.minDate);
|
if (this.minDate) this.date = new Date(this.minDate);
|
||||||
}
|
}
|
||||||
|
if (this.showTime) this.$refs.timePicker.value = newVal;
|
||||||
|
},
|
||||||
|
minDate (val) {
|
||||||
|
if (this.showTime) this.$refs.timePicker.date = val;
|
||||||
|
},
|
||||||
|
maxDate (val) {
|
||||||
|
if (this.showTime) this.$refs.timePicker.dateEnd = val;
|
||||||
|
},
|
||||||
|
format (val) {
|
||||||
|
if (this.showTime) this.$refs.timePicker.format = val;
|
||||||
|
},
|
||||||
|
isTime (val) {
|
||||||
|
if (val) this.$refs.timePicker.updateScroll();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -256,6 +285,7 @@
|
||||||
this.maxDate = null;
|
this.maxDate = null;
|
||||||
this.date = new Date();
|
this.date = new Date();
|
||||||
this.handleConfirm();
|
this.handleConfirm();
|
||||||
|
if (this.showTime) this.$refs.timePicker.handleClear();
|
||||||
},
|
},
|
||||||
resetView() {
|
resetView() {
|
||||||
this.leftCurrentView = 'date';
|
this.leftCurrentView = 'date';
|
||||||
|
@ -343,14 +373,32 @@
|
||||||
this.maxDate = val.maxDate;
|
this.maxDate = val.maxDate;
|
||||||
|
|
||||||
if (!close) return;
|
if (!close) return;
|
||||||
if (!this.showTime) {
|
// if (!this.showTime) {
|
||||||
this.handleConfirm(false);
|
// this.handleConfirm(false);
|
||||||
}
|
// }
|
||||||
|
this.handleConfirm(false);
|
||||||
},
|
},
|
||||||
handleChangeRange (val) {
|
handleChangeRange (val) {
|
||||||
this.minDate = val.minDate;
|
this.minDate = val.minDate;
|
||||||
this.maxDate = val.maxDate;
|
this.maxDate = val.maxDate;
|
||||||
this.rangeState = val.rangeState;
|
this.rangeState = val.rangeState;
|
||||||
|
},
|
||||||
|
handleToggleTime () {
|
||||||
|
this.isTime = !this.isTime;
|
||||||
|
},
|
||||||
|
handleTimePick (date) {
|
||||||
|
this.minDate = date[0];
|
||||||
|
this.maxDate = date[1];
|
||||||
|
this.handleConfirm(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
compiled () {
|
||||||
|
if (this.showTime) {
|
||||||
|
this.$refs.timePicker.date = this.minDate;
|
||||||
|
this.$refs.timePicker.dateEnd = this.maxDate;
|
||||||
|
this.$refs.timePicker.value = this.value;
|
||||||
|
this.$refs.timePicker.format = this.format;
|
||||||
|
this.$refs.timePicker.showDate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,11 +61,8 @@
|
||||||
@on-pick-click="handlePickClick"></month-table>
|
@on-pick-click="handlePickClick"></month-table>
|
||||||
<time-picker
|
<time-picker
|
||||||
v-ref:time-picker
|
v-ref:time-picker
|
||||||
v-show="currentView === 'time'"
|
|
||||||
:date="date"
|
|
||||||
:value="value"
|
|
||||||
:format="format"
|
|
||||||
show-date
|
show-date
|
||||||
|
v-show="currentView === 'time'"
|
||||||
@on-pick="handleTimePick"></time-picker>
|
@on-pick="handleTimePick"></time-picker>
|
||||||
</div>
|
</div>
|
||||||
<Confirm
|
<Confirm
|
||||||
|
@ -276,6 +273,7 @@
|
||||||
this.month = this.date.getMonth();
|
this.month = this.date.getMonth();
|
||||||
}
|
}
|
||||||
if (this.showTime) {
|
if (this.showTime) {
|
||||||
|
// todo 这里可能有问题,并不能进入到这里,但不影响正常使用
|
||||||
this.$refs.timePicker.date = this.date;
|
this.$refs.timePicker.date = this.date;
|
||||||
this.$refs.timePicker.value = this.value;
|
this.$refs.timePicker.value = this.value;
|
||||||
this.$refs.timePicker.format = this.format;
|
this.$refs.timePicker.format = this.format;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<div :class="[prefixCls + '-content', prefixCls + '-content-left']">
|
<div :class="[prefixCls + '-content', prefixCls + '-content-left']">
|
||||||
<div :class="[timePrefixCls + '-header']">开始时间</div>
|
<div :class="[timePrefixCls + '-header']">开始时间</div>
|
||||||
<time-spinner
|
<time-spinner
|
||||||
|
v-ref:time-spinner
|
||||||
:show-seconds="showSeconds"
|
:show-seconds="showSeconds"
|
||||||
:hours="hours"
|
:hours="hours"
|
||||||
:minutes="minutes"
|
:minutes="minutes"
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
<div :class="[prefixCls + '-content', prefixCls + '-content-right']">
|
<div :class="[prefixCls + '-content', prefixCls + '-content-right']">
|
||||||
<div :class="[timePrefixCls + '-header']">结束时间</div>
|
<div :class="[timePrefixCls + '-header']">结束时间</div>
|
||||||
<time-spinner
|
<time-spinner
|
||||||
|
v-ref:time-spinner-end
|
||||||
:show-seconds="showSeconds"
|
:show-seconds="showSeconds"
|
||||||
:hours="hoursEnd"
|
:hours="hoursEnd"
|
||||||
:minutes="minutesEnd"
|
:minutes="minutesEnd"
|
||||||
|
@ -170,6 +172,10 @@
|
||||||
},
|
},
|
||||||
handleEndChange (date) {
|
handleEndChange (date) {
|
||||||
this.handleChange({}, date);
|
this.handleChange({}, date);
|
||||||
|
},
|
||||||
|
updateScroll () {
|
||||||
|
this.$refs.timeSpinner.updateScroll();
|
||||||
|
this.$refs.timeSpinnerEnd.updateScroll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,31 +37,19 @@
|
||||||
export default {
|
export default {
|
||||||
mixins: [Mixin],
|
mixins: [Mixin],
|
||||||
components: { TimeSpinner, Confirm },
|
components: { TimeSpinner, Confirm },
|
||||||
// props: {
|
props: {
|
||||||
// date: {
|
showDate: {
|
||||||
// default () {
|
type: Boolean,
|
||||||
// return initTimeDate();
|
default: false
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// value: {
|
|
||||||
// default: ''
|
|
||||||
// },
|
|
||||||
// showDate: {
|
|
||||||
// type: Boolean,
|
|
||||||
// default: false
|
|
||||||
// },
|
|
||||||
// format: {
|
|
||||||
// type: String,
|
|
||||||
// default: 'HH:mm:ss'
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefixCls: prefixCls,
|
prefixCls: prefixCls,
|
||||||
timePrefixCls: timePrefixCls,
|
timePrefixCls: timePrefixCls,
|
||||||
date: initTimeDate(),
|
date: initTimeDate(),
|
||||||
value: '',
|
value: '',
|
||||||
showDate: false,
|
// showDate: false,
|
||||||
format: 'HH:mm:ss',
|
format: 'HH:mm:ss',
|
||||||
hours: '',
|
hours: '',
|
||||||
minutes: '',
|
minutes: '',
|
||||||
|
|
|
@ -258,5 +258,9 @@
|
||||||
color: @link-active-color;
|
color: @link-active-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
& > span&-time-disabled{
|
||||||
|
color: @btn-disable-color;
|
||||||
|
cursor: @cursor-disabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -93,7 +93,8 @@
|
||||||
top: 31px;
|
top: 31px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: -2px;
|
right: -2px;
|
||||||
background: @border-color-split
|
background: @border-color-split;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-right{
|
&-right{
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<template>
|
<template>
|
||||||
<row>
|
<row>
|
||||||
<i-col span="12">
|
<i-col span="12">
|
||||||
|
<Date-picker format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 300px" @on-change="c"></Date-picker>
|
||||||
<Time-picker :value="value" type="time" placeholder="选择时间" style="width: 168px"></Time-picker>
|
<Time-picker :value="value" type="time" placeholder="选择时间" style="width: 168px"></Time-picker>
|
||||||
</i-col>
|
</i-col>
|
||||||
<!--<i-col span="12">-->
|
<!--<i-col span="12">-->
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
<!--style="width: 168px"></time-picker>-->
|
<!--style="width: 168px"></time-picker>-->
|
||||||
<!--</i-col>-->
|
<!--</i-col>-->
|
||||||
<i-col span="12">
|
<i-col span="12">
|
||||||
<Date-picker :value="value1" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px" @on-change="c"></Date-picker>
|
<Date-picker format="yyyy-MM-dd HH:mm:ss" type="datetimerange" placeholder="选择日期时间" style="width: 300px" @on-change="c"></Date-picker>
|
||||||
<!--<time-picker-->
|
<!--<time-picker-->
|
||||||
<!--:value="value2"-->
|
<!--:value="value2"-->
|
||||||
<!--type="timerange"-->
|
<!--type="timerange"-->
|
||||||
|
@ -44,11 +45,12 @@
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
// value: '2016-12-12 03:03:03',
|
// value: '2016-12-12 03:03:03',
|
||||||
value1: '2015-12-12 09:41',
|
value1: '2015-12-12 09:41:00',
|
||||||
value: '03:12:01',
|
value: '03:12:01',
|
||||||
value2: ['08:40:00', '09:40:00'],
|
value2: ['08:40:00', '09:40:00'],
|
||||||
// value2: [new Date(), new Date()],
|
// value2: [new Date(), new Date()],
|
||||||
value3: ['2016-12-01', '2016-12-25']
|
value3: ['2016-12-01', '2016-12-25'],
|
||||||
|
val4: ['2016-12-01 09:41:12', '2016-12-25 12:23:32']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue