456877a1
梁灏
update TimePicker
|
1
|
<template>
|
030a522d
Sergio Crisostomo
make picker close...
|
2
|
<div :class="classes" @mousedown.prevent>
|
456877a1
梁灏
update TimePicker
|
3
4
|
<div :class="[prefixCls + '-body']">
<div :class="[prefixCls + '-content', prefixCls + '-content-left']">
|
a2a78c38
梁灏
update DateTimePi...
|
5
|
<div :class="[timePrefixCls + '-header']">
|
2537c26d
Sergio Crisostomo
add dateLabel to ...
|
6
|
<template v-if="showDate">{{ leftDatePanelLabel }}</template>
|
4ab11811
梁灏
some component su...
|
7
|
<template v-else>{{ t('i.datepicker.startTime') }}</template>
|
a2a78c38
梁灏
update DateTimePi...
|
8
|
</div>
|
456877a1
梁灏
update TimePicker
|
9
|
<time-spinner
|
531cd165
梁灏
support DatePicke...
|
10
|
ref="timeSpinner"
|
e6029f1d
Graham Fairweather
Fix: Missing step...
|
11
|
:steps="steps"
|
456877a1
梁灏
update TimePicker
|
12
|
:show-seconds="showSeconds"
|
29a91fbb
Sergio Crisostomo
Correct passing o...
|
13
14
15
|
:hours="value[0] && dateStart.getHours()"
:minutes="value[0] && dateStart.getMinutes()"
:seconds="value[0] && dateStart.getSeconds()"
|
456877a1
梁灏
update TimePicker
|
16
17
18
19
20
21
22
23
|
:disabled-hours="disabledHours"
:disabled-minutes="disabledMinutes"
:disabled-seconds="disabledSeconds"
:hide-disabled-options="hideDisabledOptions"
@on-change="handleStartChange"
@on-pick-click="handlePickClick"></time-spinner>
</div>
<div :class="[prefixCls + '-content', prefixCls + '-content-right']">
|
a2a78c38
梁灏
update DateTimePi...
|
24
|
<div :class="[timePrefixCls + '-header']">
|
2537c26d
Sergio Crisostomo
add dateLabel to ...
|
25
|
<template v-if="showDate">{{ rightDatePanelLabel }}</template>
|
4ab11811
梁灏
some component su...
|
26
|
<template v-else>{{ t('i.datepicker.endTime') }}</template>
|
a2a78c38
梁灏
update DateTimePi...
|
27
|
</div>
|
456877a1
梁灏
update TimePicker
|
28
|
<time-spinner
|
531cd165
梁灏
support DatePicke...
|
29
|
ref="timeSpinnerEnd"
|
e6029f1d
Graham Fairweather
Fix: Missing step...
|
30
|
:steps="steps"
|
456877a1
梁灏
update TimePicker
|
31
|
:show-seconds="showSeconds"
|
29a91fbb
Sergio Crisostomo
Correct passing o...
|
32
33
34
|
:hours="value[1] && dateEnd.getHours()"
:minutes="value[1] && dateEnd.getMinutes()"
:seconds="value[1] && dateEnd.getSeconds()"
|
456877a1
梁灏
update TimePicker
|
35
36
37
38
39
40
41
42
|
:disabled-hours="disabledHours"
:disabled-minutes="disabledMinutes"
:disabled-seconds="disabledSeconds"
:hide-disabled-options="hideDisabledOptions"
@on-change="handleEndChange"
@on-pick-click="handlePickClick"></time-spinner>
</div>
<Confirm
|
d596b9e4
梁灏
update TimePicker
|
43
|
v-if="confirm"
|
456877a1
梁灏
update TimePicker
|
44
45
46
47
48
49
|
@on-pick-clear="handlePickClear"
@on-pick-success="handlePickSuccess"></Confirm>
</div>
</div>
</template>
<script>
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
50
51
52
|
import TimeSpinner from '../../base/time-spinner.vue';
import Confirm from '../../base/confirm.vue';
import Options from '../../time-mixins';
|
456877a1
梁灏
update TimePicker
|
53
|
|
456877a1
梁灏
update TimePicker
|
54
|
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
55
56
57
58
|
import Mixin from '../panel-mixin';
import Locale from '../../../../mixins/locale';
import { initTimeDate, formatDateLabels } from '../../util';
|
456877a1
梁灏
update TimePicker
|
59
60
61
62
|
const prefixCls = 'ivu-picker-panel';
const timePrefixCls = 'ivu-time-picker';
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
63
64
|
const capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
456877a1
梁灏
update TimePicker
|
65
|
export default {
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
66
67
|
name: 'RangeTimePickerPanel',
mixins: [ Mixin, Locale, Options ],
|
456877a1
梁灏
update TimePicker
|
68
|
components: { TimeSpinner, Confirm },
|
e6029f1d
Graham Fairweather
Fix: Missing step...
|
69
70
71
72
|
props: {
steps: {
type: Array,
default: () => []
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
73
74
75
76
77
78
79
80
81
|
},
format: {
type: String,
default: 'HH:mm:ss'
},
value: {
type: Array,
required: true
},
|
e6029f1d
Graham Fairweather
Fix: Missing step...
|
82
|
},
|
456877a1
梁灏
update TimePicker
|
83
|
data () {
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
84
|
const [dateStart, dateEnd] = this.value.slice();
|
456877a1
梁灏
update TimePicker
|
85
86
87
|
return {
prefixCls: prefixCls,
timePrefixCls: timePrefixCls,
|
a2a78c38
梁灏
update DateTimePi...
|
88
|
showDate: false,
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
89
|
dateStart: dateStart || initTimeDate(),
|
29a91fbb
Sergio Crisostomo
Correct passing o...
|
90
|
dateEnd: dateEnd || initTimeDate()
|
3a435d65
梁灏
update TimePicker
|
91
|
};
|
456877a1
梁灏
update TimePicker
|
92
93
94
95
96
97
98
99
100
101
102
103
|
},
computed: {
classes () {
return [
`${prefixCls}-body-wrapper`,
`${timePrefixCls}-with-range`,
{
[`${timePrefixCls}-with-seconds`]: this.showSeconds
}
];
},
showSeconds () {
|
22ff9a62
Sergio Crisostomo
fix showSeconds f...
|
104
|
return !(this.format || '').match(/mm$/);
|
a2a78c38
梁灏
update DateTimePi...
|
105
|
},
|
2537c26d
Sergio Crisostomo
add dateLabel to ...
|
106
107
|
leftDatePanelLabel () {
return this.panelLabelConfig(this.date);
|
a2a78c38
梁灏
update DateTimePi...
|
108
|
},
|
2537c26d
Sergio Crisostomo
add dateLabel to ...
|
109
110
|
rightDatePanelLabel () {
return this.panelLabelConfig(this.dateEnd);
|
456877a1
梁灏
update TimePicker
|
111
112
113
|
}
},
watch: {
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
114
115
116
117
|
value (dates) {
const [dateStart, dateEnd] = dates.slice();
this.dateStart = dateStart || initTimeDate();
this.dateEnd = dateEnd || initTimeDate();
|
456877a1
梁灏
update TimePicker
|
118
119
120
|
}
},
methods: {
|
2537c26d
Sergio Crisostomo
add dateLabel to ...
|
121
122
123
124
125
126
|
panelLabelConfig (date) {
const locale = this.t('i.locale');
const datePanelLabel = this.t('i.datepicker.datePanelLabel');
const { labels, separator } = formatDateLabels(locale, datePanelLabel, date || initTimeDate());
return [labels[0].label, separator, labels[1].label].join('');
},
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
127
128
129
130
131
132
133
|
handleChange (start, end, emit = true) {
const dateStart = new Date(this.dateStart);
let dateEnd = new Date(this.dateEnd);
// set dateStart
Object.keys(start).forEach(type => {
|
5426dcf9
Sergio Crisostomo
fix specs, fix me...
|
134
|
dateStart[`set${capitalize(type)}`](start[type]);
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
135
136
137
138
139
140
|
});
// set dateEnd
Object.keys(end).forEach(type => {
dateEnd[`set${capitalize(type)}`](end[type]);
});
|
db9985a9
梁灏
update TimePicker
|
141
|
|
964582b3
梁灏
update TimePicker
|
142
|
// judge endTime > startTime?
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
143
|
if (dateEnd < dateStart) dateEnd = dateStart;
|
db9985a9
梁灏
update TimePicker
|
144
|
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
145
|
if (emit) this.$emit('on-pick', [dateStart, dateEnd], true);
|
456877a1
梁灏
update TimePicker
|
146
147
148
149
150
151
|
},
handleStartChange (date) {
this.handleChange(date, {});
},
handleEndChange (date) {
this.handleChange({}, date);
|
2dc27713
梁灏
update DateTimePi...
|
152
153
154
155
|
},
updateScroll () {
this.$refs.timeSpinner.updateScroll();
this.$refs.timeSpinnerEnd.updateScroll();
|
456877a1
梁灏
update TimePicker
|
156
|
}
|
a2a78c38
梁灏
update DateTimePi...
|
157
|
},
|
531cd165
梁灏
support DatePicke...
|
158
|
mounted () {
|
a2a78c38
梁灏
update DateTimePi...
|
159
|
if (this.$parent && this.$parent.$options.name === 'DatePicker') this.showDate = true;
|
456877a1
梁灏
update TimePicker
|
160
161
|
}
};
|
030a522d
Sergio Crisostomo
make picker close...
|
162
|
</script>
|