mobile.jsx 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { computed } from 'vue'
  2. import BasicDate from '../../basic/date-picker/mobile'
  3. import { useFormInput } from '../../../hooks/form-input'
  4. import { formInputProps, fromInputEmits } from '../../form-input-props'
  5. export default {
  6. props: formInputProps,
  7. emits: [...fromInputEmits],
  8. setup (props, context) {
  9. const { emitModelValue, emitOtherValue } = useFormInput(props, context)
  10. // 时间区间
  11. const currentYear = new Date().getFullYear()
  12. const minDate = computed(() => {
  13. return props.config?.minDate ?? new Date(currentYear - 10, 0, 1)
  14. })
  15. const maxDate = computed(() => {
  16. return props.config?.maxDate ?? new Date(currentYear + 10, 11, 31)
  17. })
  18. return () => <div style="display: flex;flex: 1">
  19. <BasicDate modelValue={props.modelValue}
  20. onUpdate:modelValue={emitModelValue}
  21. config={{ ...props.config, minDate: minDate.value, maxDate: props.otherValue }}
  22. />
  23. <span style="padding: 0px 8px;">至</span>
  24. <BasicDate modelValue={props.otherValue}
  25. onUpdate:modelValue={emitOtherValue}
  26. config={{ ...props.config, minDate: props.modelValue, maxDate: maxDate.value }}
  27. />
  28. </div>
  29. }
  30. }