mobile.jsx 1.1 KB

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