1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <selector-card
- class="time-selector"
- :cardType="selectorType"
- @onConfirm="onConfirm"
- @onCancel="onCancel"
- >
- <div slot="header" :class="{ 's-header': selectorType === 'line' }">
- <slot name="header">选择时间</slot>
- </div>
- <TimeSelectorContent
- ref="content"
- :selectorTime="selectorTime"
- :selectorType="selectorType"
- :defaultSelectedKey="defaultSelectedKey"
- :showExact="showExact"
- @onChange="onChange"
- />
- </selector-card>
- </template>
- <script>
- import SelectorCard from '@/components/selector/SelectorCard.vue'
- import TimeSelectorContent from '@/components/selector/TimeSelectorContent.vue'
- export default {
- name: 'time-selector',
- components: {
- SelectorCard,
- TimeSelectorContent
- },
- props: {
- selectorType: {
- type: String,
- default: 'line'
- },
- selectorTime: {
- type: String,
- default: 'default'
- },
- defaultSelectedKey: String,
- showExact: {
- type: Boolean,
- default: true
- },
- value: {
- type: [Object, String],
- default: () => {
- return {}
- }
- }
- },
- data() {
- return {}
- },
- created() {},
- model: {
- prop: 'value',
- event: 'change'
- },
- watch: {
- value (val) {
- if (val) {
- this.setState(val)
- }
- }
- },
- methods: {
- setState(data) {
- return this.$refs.content.setState(data)
- },
- getState() {
- return this.$refs.content.getState()
- },
- onCancel() {
- this.$emit('onCancel')
- },
- onConfirm() {
- const state = this.getState()
- this.$emit('onConfirm', state)
- },
- onChange(state) {
- this.$emit('onChange', state)
- this.$emit('change', state)
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|