Commit 36931442588617d7feb7dce0ef431df6332f505f
1 parent
acde7262
update DateTimePicker
update DateTimePicker
Showing
4 changed files
with
39 additions
and
26 deletions
Show diff stats
src/components/date-picker/panel/date.vue
| ... | ... | @@ -60,8 +60,8 @@ |
| 60 | 60 | @on-pick="handleMonthPick" |
| 61 | 61 | @on-pick-click="handlePickClick"></month-table> |
| 62 | 62 | <time-picker |
| 63 | - v-show="currentView === 'time'" | |
| 64 | 63 | v-ref:time-picker |
| 64 | + v-show="currentView === 'time'" | |
| 65 | 65 | :date="date" |
| 66 | 66 | :value="value" |
| 67 | 67 | :format="format" |
| ... | ... | @@ -142,6 +142,13 @@ |
| 142 | 142 | this.year = newVal.getFullYear(); |
| 143 | 143 | this.month = newVal.getMonth(); |
| 144 | 144 | } |
| 145 | + if (this.showTime) this.$refs.timePicker.value = newVal; | |
| 146 | + }, | |
| 147 | + date (val) { | |
| 148 | + if (this.showTime) this.$refs.timePicker.date = val; | |
| 149 | + }, | |
| 150 | + format (val) { | |
| 151 | + if (this.showTime) this.$refs.timePicker.format = val; | |
| 145 | 152 | }, |
| 146 | 153 | currentView (val) { |
| 147 | 154 | if (val === 'time') this.$refs.timePicker.updateScroll(); |
| ... | ... | @@ -268,6 +275,12 @@ |
| 268 | 275 | this.year = this.date.getFullYear(); |
| 269 | 276 | this.month = this.date.getMonth(); |
| 270 | 277 | } |
| 278 | + if (this.showTime) { | |
| 279 | + this.$refs.timePicker.date = this.date; | |
| 280 | + this.$refs.timePicker.value = this.value; | |
| 281 | + this.$refs.timePicker.format = this.format; | |
| 282 | + this.$refs.timePicker.showDate = true; | |
| 283 | + } | |
| 271 | 284 | } |
| 272 | 285 | }; |
| 273 | 286 | </script> | ... | ... |
src/components/date-picker/panel/time.vue
| ... | ... | @@ -37,29 +37,32 @@ |
| 37 | 37 | export default { |
| 38 | 38 | mixins: [Mixin], |
| 39 | 39 | components: { TimeSpinner, Confirm }, |
| 40 | - props: { | |
| 41 | - date: { | |
| 42 | - default () { | |
| 43 | - return initTimeDate(); | |
| 44 | - } | |
| 45 | - }, | |
| 46 | - value: { | |
| 47 | - default: '' | |
| 48 | - }, | |
| 49 | - showDate: { | |
| 50 | - type: Boolean, | |
| 51 | - default: false | |
| 52 | - }, | |
| 53 | - format: { | |
| 54 | - type: String, | |
| 55 | - default: 'HH:mm:ss' | |
| 56 | - } | |
| 57 | - }, | |
| 40 | +// props: { | |
| 41 | +// date: { | |
| 42 | +// default () { | |
| 43 | +// return initTimeDate(); | |
| 44 | +// } | |
| 45 | +// }, | |
| 46 | +// value: { | |
| 47 | +// default: '' | |
| 48 | +// }, | |
| 49 | +// showDate: { | |
| 50 | +// type: Boolean, | |
| 51 | +// default: false | |
| 52 | +// }, | |
| 53 | +// format: { | |
| 54 | +// type: String, | |
| 55 | +// default: 'HH:mm:ss' | |
| 56 | +// } | |
| 57 | +// }, | |
| 58 | 58 | data () { |
| 59 | 59 | return { |
| 60 | 60 | prefixCls: prefixCls, |
| 61 | 61 | timePrefixCls: timePrefixCls, |
| 62 | -// format: 'HH:mm:ss', | |
| 62 | + date: initTimeDate(), | |
| 63 | + value: '', | |
| 64 | + showDate: false, | |
| 65 | + format: 'HH:mm:ss', | |
| 63 | 66 | hours: '', |
| 64 | 67 | minutes: '', |
| 65 | 68 | seconds: '', | ... | ... |
src/components/date-picker/picker.vue
| ... | ... | @@ -398,13 +398,10 @@ |
| 398 | 398 | this.handleClear(); |
| 399 | 399 | }); |
| 400 | 400 | this.picker.$on('on-pick-success', () => { |
| 401 | -// this.emitChange(this.value); | |
| 402 | 401 | this.visible = false; |
| 403 | 402 | this.$emit('on-ok'); |
| 404 | 403 | }); |
| 405 | 404 | this.picker.$on('on-pick-click', () => this.disableClickOutSide = true); |
| 406 | - | |
| 407 | - // todo $on('on-time-range') | |
| 408 | 405 | } |
| 409 | 406 | if (this.internalValue instanceof Date) { |
| 410 | 407 | this.picker.date = new Date(this.internalValue.getTime()); | ... | ... |
test/routers/date.vue
| ... | ... | @@ -5,9 +5,9 @@ |
| 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>--> | |
| 8 | + <i-col span="12"> | |
| 9 | + <Time-picker :value="value" type="time" placeholder="选择时间" style="width: 168px"></Time-picker> | |
| 10 | + </i-col> | |
| 11 | 11 | <!--<i-col span="12">--> |
| 12 | 12 | <!--<date-picker :value="value3" type="daterange" placement="bottom-start" placeholder="选择日期" style="width: 200px"></date-picker>--> |
| 13 | 13 | <!--</i-col>--> | ... | ... |