Commit 0dd7b94a4dc5e1e080324aacd43541ed0d371968
1 parent
d609ba86
update TimePicker
update TimePicker
Showing
3 changed files
with
32 additions
and
29 deletions
Show diff stats
src/components/date-picker/panel/time-range.vue
... | ... | @@ -85,9 +85,8 @@ |
85 | 85 | }, |
86 | 86 | watch: { |
87 | 87 | value (newVal) { |
88 | - if (!newVal) { | |
89 | - return; | |
90 | - } else if (Array.isArray(newVal)) { | |
88 | + if (!newVal) return; | |
89 | + if (Array.isArray(newVal)) { | |
91 | 90 | const valStart = newVal[0] ? toDate(newVal[0]) : false; |
92 | 91 | const valEnd = newVal[1] ? toDate(newVal[1]) : false; |
93 | 92 | ... | ... |
src/components/date-picker/picker.vue
... | ... | @@ -444,15 +444,18 @@ |
444 | 444 | immediate: true, |
445 | 445 | handler (val) { |
446 | 446 | const type = this.type; |
447 | - if ((type === 'time' || type === 'timerange') && !(val instanceof Date)) { | |
448 | - const parser = ( | |
449 | - TYPE_VALUE_RESOLVER_MAP[type] || | |
450 | - TYPE_VALUE_RESOLVER_MAP['default'] | |
451 | - ).parser; | |
452 | - if (type === 'timerange') val = val.join(RANGE_SEPARATOR); | |
447 | + const parser = ( | |
448 | + TYPE_VALUE_RESOLVER_MAP[type] || | |
449 | + TYPE_VALUE_RESOLVER_MAP['default'] | |
450 | + ).parser; | |
453 | 451 | |
452 | + if (type === 'time' && !(val instanceof Date)) { | |
453 | + val = parser(val, this.format || DEFAULT_FORMATS[type]); | |
454 | + } else if (type === 'timerange' && Array.isArray(val) && val.length === 2 && !(val[0] instanceof Date) && !(val[1] instanceof Date)) { | |
455 | + val = val.join(RANGE_SEPARATOR); | |
454 | 456 | val = parser(val, this.format || DEFAULT_FORMATS[type]); |
455 | 457 | } |
458 | + | |
456 | 459 | this.internalValue = val; |
457 | 460 | } |
458 | 461 | }, | ... | ... |
test/routers/date.vue
... | ... | @@ -5,29 +5,30 @@ |
5 | 5 | </style> |
6 | 6 | <template> |
7 | 7 | <row> |
8 | - <i-col span="12"> | |
9 | - <date-picker type="date" placeholder="选择日期" style="width: 200px" @on-ok="ok" confirm @on-clear="clear"></date-picker> | |
10 | - </i-col> | |
11 | - <i-col span="12"> | |
12 | - <date-picker :value="value3" type="daterange" placement="bottom-start" placeholder="选择日期" style="width: 200px"></date-picker> | |
13 | - </i-col> | |
14 | - <i-col span="12"> | |
15 | - <time-picker | |
16 | - :value="value" | |
17 | - placeholder="选择时间" | |
18 | - format="HH:mm:ss" | |
19 | - :hide-disabled-options="false" | |
20 | - :disabled-hours="[1,2,10,11]" | |
21 | - @on-change="c" | |
22 | - @on-ok="ok" | |
23 | - @on-clear="clear" | |
24 | - style="width: 168px"></time-picker> | |
25 | - </i-col> | |
8 | + <!--<i-col span="12">--> | |
9 | + <!--<date-picker type="date" placeholder="选择日期" style="width: 200px" @on-ok="ok" confirm @on-clear="clear"></date-picker>--> | |
10 | + <!--</i-col>--> | |
11 | + <!--<i-col span="12">--> | |
12 | + <!--<date-picker :value="value3" type="daterange" placement="bottom-start" placeholder="选择日期" style="width: 200px"></date-picker>--> | |
13 | + <!--</i-col>--> | |
14 | + <!--<i-col span="12">--> | |
15 | + <!--<time-picker--> | |
16 | + <!--:value="value"--> | |
17 | + <!--placeholder="选择时间"--> | |
18 | + <!--format="HH:mm:ss"--> | |
19 | + <!--:hide-disabled-options="false"--> | |
20 | + <!--:disabled-hours="[1,2,10,11]"--> | |
21 | + <!--@on-change="c"--> | |
22 | + <!--@on-ok="ok"--> | |
23 | + <!--@on-clear="clear"--> | |
24 | + <!--style="width: 168px"></time-picker>--> | |
25 | + <!--</i-col>--> | |
26 | 26 | <i-col span="12"> |
27 | 27 | <time-picker |
28 | 28 | :value="value2" |
29 | 29 | type="timerange" |
30 | 30 | placeholder="选择时间" |
31 | + format="HH:mm:ss" | |
31 | 32 | :hide-disabled-options="false" |
32 | 33 | @on-change="c" |
33 | 34 | @on-ok="ok" |
... | ... | @@ -49,8 +50,8 @@ |
49 | 50 | }, |
50 | 51 | methods: { |
51 | 52 | c (s) { |
52 | - console.log(1,s); | |
53 | - this.value2 = s; | |
53 | +// console.log(1,s); | |
54 | +// this.value2 = s; | |
54 | 55 | }, |
55 | 56 | ok () { |
56 | 57 | console.log('ok'); | ... | ... |