9d844d53
梁灏
fixed Layout bug
|
1
2
3
|
<template>
<div :class="[prefixCls + '-body-wrapper']">
<div :class="[prefixCls + '-body']">
|
a8571a5f
梁灏
update DateTimePi...
|
4
|
<div :class="[timePrefixCls + '-header']" v-if="showDate">{{ visibleDate }}</div>
|
9d844d53
梁灏
fixed Layout bug
|
5
6
|
<div :class="[prefixCls + '-content']">
<time-spinner
|
5cc9b892
梁灏
update DateTimePi...
|
7
|
v-ref:time-spinner
|
9d844d53
梁灏
fixed Layout bug
|
8
9
10
11
|
:show-seconds="showSeconds"
:hours="hours"
:minutes="minutes"
:seconds="seconds"
|
36628aca
梁灏
update TimePicker
|
12
13
14
15
|
:disabled-hours="disabledHours"
:disabled-minutes="disabledMinutes"
:disabled-seconds="disabledSeconds"
:hide-disabled-options="hideDisabledOptions"
|
9d844d53
梁灏
fixed Layout bug
|
16
17
18
19
|
@on-change="handleChange"
@on-pick-click="handlePickClick"></time-spinner>
</div>
<Confirm
|
d596b9e4
梁灏
update TimePicker
|
20
|
v-if="confirm"
|
9d844d53
梁灏
fixed Layout bug
|
21
22
23
24
25
26
27
28
29
30
31
|
@on-pick-clear="handlePickClear"
@on-pick-success="handlePickSuccess"></Confirm>
</div>
</div>
</template>
<script>
import TimeSpinner from '../base/time-spinner.vue';
import Confirm from '../base/confirm.vue';
import Mixin from './mixin';
|
2dbbd7de
梁灏
update TimePicker
|
32
33
|
import { initTimeDate } from '../util';
|
9d844d53
梁灏
fixed Layout bug
|
34
35
36
37
38
39
|
const prefixCls = 'ivu-picker-panel';
const timePrefixCls = 'ivu-time-picker';
export default {
mixins: [Mixin],
components: { TimeSpinner, Confirm },
|
5cc9b892
梁灏
update DateTimePi...
|
40
41
42
|
props: {
date: {
default () {
|
62c7f997
梁灏
update DateTimePi...
|
43
|
return initTimeDate();
|
5cc9b892
梁灏
update DateTimePi...
|
44
45
46
47
|
}
},
value: {
default: ''
|
a8571a5f
梁灏
update DateTimePi...
|
48
49
50
51
|
},
showDate: {
type: Boolean,
default: false
|
acde7262
梁灏
update DateTimePi...
|
52
53
54
55
|
},
format: {
type: String,
default: 'HH:mm:ss'
|
5cc9b892
梁灏
update DateTimePi...
|
56
57
|
}
},
|
9d844d53
梁灏
fixed Layout bug
|
58
59
60
61
|
data () {
return {
prefixCls: prefixCls,
timePrefixCls: timePrefixCls,
|
acde7262
梁灏
update DateTimePi...
|
62
|
// format: 'HH:mm:ss',
|
2dbbd7de
梁灏
update TimePicker
|
63
64
65
|
hours: '',
minutes: '',
seconds: '',
|
c1abaed9
梁灏
update TimePicker
|
66
67
68
|
disabledHours: [],
disabledMinutes: [],
disabledSeconds: [],
|
d596b9e4
梁灏
update TimePicker
|
69
70
|
hideDisabledOptions: false,
confirm: false
|
9d844d53
梁灏
fixed Layout bug
|
71
72
73
74
75
|
};
},
computed: {
showSeconds () {
return (this.format || '').indexOf('ss') !== -1;
|
a8571a5f
梁灏
update DateTimePi...
|
76
77
78
79
|
},
visibleDate () {
const date = this.date;
return `${date.getFullYear()}年 ${date.getMonth() + 1}月`;
|
9d844d53
梁灏
fixed Layout bug
|
80
81
82
83
84
85
86
|
}
},
watch: {
value (newVal) {
if (!newVal) return;
newVal = new Date(newVal);
if (!isNaN(newVal)) {
|
603e437b
梁灏
update TimePicker
|
87
|
this.date = newVal;
|
9d844d53
梁灏
fixed Layout bug
|
88
|
this.handleChange({
|
c1abaed9
梁灏
update TimePicker
|
89
90
91
|
hours: newVal.getHours(),
minutes: newVal.getMinutes(),
seconds: newVal.getSeconds()
|
603e437b
梁灏
update TimePicker
|
92
|
}, false);
|
9d844d53
梁灏
fixed Layout bug
|
93
94
95
96
|
}
}
},
methods: {
|
2dbbd7de
梁灏
update TimePicker
|
97
98
99
100
101
|
handleClear() {
this.date = initTimeDate();
this.hours = '';
this.minutes = '';
this.seconds = '';
|
2dbbd7de
梁灏
update TimePicker
|
102
|
},
|
603e437b
梁灏
update TimePicker
|
103
|
handleChange (date, emit = true) {
|
9d844d53
梁灏
fixed Layout bug
|
104
105
106
107
108
109
110
111
112
113
114
115
|
if (date.hours !== undefined) {
this.date.setHours(date.hours);
this.hours = this.date.getHours();
}
if (date.minutes !== undefined) {
this.date.setMinutes(date.minutes);
this.minutes = this.date.getMinutes();
}
if (date.seconds !== undefined) {
this.date.setSeconds(date.seconds);
this.seconds = this.date.getSeconds();
}
|
603e437b
梁灏
update TimePicker
|
116
|
if (emit) this.$emit('on-pick', this.date, true);
|
5cc9b892
梁灏
update DateTimePi...
|
117
118
119
|
},
updateScroll () {
this.$refs.timeSpinner.updateScroll();
|
9d844d53
梁灏
fixed Layout bug
|
120
121
122
123
|
}
}
};
</script>
|