update DateTimePicker

update DateTimePicker
This commit is contained in:
梁灏 2016-12-30 17:54:27 +08:00
parent 2dc2771349
commit a2a78c382f
4 changed files with 34 additions and 12 deletions

View file

@ -117,7 +117,8 @@
<time-picker
v-ref:time-picker
v-show="isTime"
@on-pick="handleTimePick"></time-picker>
@on-pick="handleTimePick"
@on-pick-click="handlePickClick"></time-picker>
</div>
<Confirm
v-if="confirm"
@ -145,6 +146,7 @@
const datePrefixCls = 'ivu-date-picker';
export default {
name: 'DatePicker',
mixins: [Mixin],
components: { Icon, DateTable, YearTable, MonthTable, TimePicker, Confirm },
data () {
@ -287,12 +289,14 @@
this.handleConfirm();
if (this.showTime) this.$refs.timePicker.handleClear();
},
resetView() {
resetView(reset = false) {
this.leftCurrentView = 'date';
this.rightCurrentView = 'date';
this.leftTableYear = this.leftYear;
this.rightTableYear = this.rightYear;
if (reset) this.isTime = false;
},
prevYear (direction) {
if (this[`${direction}CurrentView`] === 'year') {
@ -394,6 +398,7 @@
},
compiled () {
if (this.showTime) {
// todo
this.$refs.timePicker.date = this.minDate;
this.$refs.timePicker.dateEnd = this.maxDate;
this.$refs.timePicker.value = this.value;

View file

@ -63,7 +63,8 @@
v-ref:time-picker
show-date
v-show="currentView === 'time'"
@on-pick="handleTimePick"></time-picker>
@on-pick="handleTimePick"
@on-pick-click="handlePickClick"></time-picker>
</div>
<Confirm
v-if="confirm"
@ -91,6 +92,7 @@
const datePrefixCls = 'ivu-date-picker';
export default {
name: 'DatePicker',
mixins: [Mixin],
components: { Icon, DateTable, YearTable, MonthTable, TimePicker, Confirm },
data () {

View file

@ -2,7 +2,10 @@
<div :class="classes">
<div :class="[prefixCls + '-body']">
<div :class="[prefixCls + '-content', prefixCls + '-content-left']">
<div :class="[timePrefixCls + '-header']">开始时间</div>
<div :class="[timePrefixCls + '-header']">
<template v-if="showDate">{{ visibleDate }}</template>
<template v-else>开始时间</template>
</div>
<time-spinner
v-ref:time-spinner
:show-seconds="showSeconds"
@ -17,7 +20,10 @@
@on-pick-click="handlePickClick"></time-spinner>
</div>
<div :class="[prefixCls + '-content', prefixCls + '-content-right']">
<div :class="[timePrefixCls + '-header']">结束时间</div>
<div :class="[timePrefixCls + '-header']">
<template v-if="showDate">{{ visibleDateEnd }}</template>
<template v-else>结束时间</template>
</div>
<time-spinner
v-ref:time-spinner-end
:show-seconds="showSeconds"
@ -57,6 +63,7 @@
prefixCls: prefixCls,
timePrefixCls: timePrefixCls,
format: 'HH:mm:ss',
showDate: false,
date: initTimeDate(),
dateEnd: initTimeDate(),
value: '',
@ -85,6 +92,14 @@
},
showSeconds () {
return (this.format || '').indexOf('ss') !== -1;
},
visibleDate () {
const date = this.date || initTimeDate();
return `${date.getFullYear()}${date.getMonth() + 1}`;
},
visibleDateEnd () {
const date = this.dateEnd || initTimeDate();
return `${date.getFullYear()}${date.getMonth() + 1}`;
}
},
watch: {
@ -177,6 +192,9 @@
this.$refs.timeSpinner.updateScroll();
this.$refs.timeSpinnerEnd.updateScroll();
}
},
compiled () {
if (this.$parent && this.$parent.$options.name === 'DatePicker') this.showDate = true;
}
};
</script>

View file

@ -37,19 +37,13 @@
export default {
mixins: [Mixin],
components: { TimeSpinner, Confirm },
props: {
showDate: {
type: Boolean,
default: false
}
},
data () {
return {
prefixCls: prefixCls,
timePrefixCls: timePrefixCls,
date: initTimeDate(),
value: '',
// showDate: false,
showDate: false,
format: 'HH:mm:ss',
hours: '',
minutes: '',
@ -109,6 +103,9 @@
updateScroll () {
this.$refs.timeSpinner.updateScroll();
}
},
compiled () {
if (this.$parent && this.$parent.$options.name === 'DatePicker') this.showDate = true;
}
};
</script>