Commit d609ba86825d727544bb66b8ea4680916c0ebc14

Authored by 梁灏
1 parent 456877a1

update TimePicker

update TimePicker
src/components/date-picker/picker.vue
@@ -417,7 +417,6 @@ @@ -417,7 +417,6 @@
417 417
418 let newDate = formatter(date, format); 418 let newDate = formatter(date, format);
419 if (type === 'daterange' || type === 'timerange') { 419 if (type === 'daterange' || type === 'timerange') {
420 - console.log(newDate);  
421 newDate = [newDate.split(RANGE_SEPARATOR)[0], newDate.split(RANGE_SEPARATOR)[1]]; 420 newDate = [newDate.split(RANGE_SEPARATOR)[0], newDate.split(RANGE_SEPARATOR)[1]];
422 } 421 }
423 422
@@ -445,12 +444,13 @@ @@ -445,12 +444,13 @@
445 immediate: true, 444 immediate: true,
446 handler (val) { 445 handler (val) {
447 const type = this.type; 446 const type = this.type;
448 - if (type === 'time' || type === 'timerange') { 447 + if ((type === 'time' || type === 'timerange') && !(val instanceof Date)) {
449 const parser = ( 448 const parser = (
450 TYPE_VALUE_RESOLVER_MAP[type] || 449 TYPE_VALUE_RESOLVER_MAP[type] ||
451 TYPE_VALUE_RESOLVER_MAP['default'] 450 TYPE_VALUE_RESOLVER_MAP['default']
452 ).parser; 451 ).parser;
453 if (type === 'timerange') val = val.join(RANGE_SEPARATOR); 452 if (type === 'timerange') val = val.join(RANGE_SEPARATOR);
  453 +
454 val = parser(val, this.format || DEFAULT_FORMATS[type]); 454 val = parser(val, this.format || DEFAULT_FORMATS[type]);
455 } 455 }
456 this.internalValue = val; 456 this.internalValue = val;
test/routers/date.vue
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <template> 6 <template>
7 <row> 7 <row>
8 <i-col span="12"> 8 <i-col span="12">
9 - <!--<date-picker type="date" placeholder="选择日期" style="width: 200px" @on-ok="ok" confirm @on-clear="clear"></date-picker>--> 9 + <date-picker type="date" placeholder="选择日期" style="width: 200px" @on-ok="ok" confirm @on-clear="clear"></date-picker>
10 </i-col> 10 </i-col>
11 <i-col span="12"> 11 <i-col span="12">
12 <date-picker :value="value3" type="daterange" placement="bottom-start" placeholder="选择日期" style="width: 200px"></date-picker> 12 <date-picker :value="value3" type="daterange" placement="bottom-start" placeholder="选择日期" style="width: 200px"></date-picker>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 export default { 40 export default {
41 data () { 41 data () {
42 return { 42 return {
43 -// value: '2016-12-12 03:03:03' 43 +// value: '2016-12-12 03:03:03',
44 value: '15:12:01', 44 value: '15:12:01',
45 value2: ['08:40:00', '09:40:00'], 45 value2: ['08:40:00', '09:40:00'],
46 // value2: [new Date(), new Date()], 46 // value2: [new Date(), new Date()],
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 methods: { 50 methods: {
51 c (s) { 51 c (s) {
52 console.log(1,s); 52 console.log(1,s);
53 - this.value = s; 53 + this.value2 = s;
54 }, 54 },
55 ok () { 55 ok () {
56 console.log('ok'); 56 console.log('ok');