mobile.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import SelectTime from '../../basic/time-select/mobile'
  2. import { useFormInput } from '../../../hooks/form-input'
  3. import { formInputProps } from '../../form-input-props'
  4. import { computed } from 'vue'
  5. import { compareTime } from '../../basic/time-select/utils'
  6. export default {
  7. props: formInputProps,
  8. setup (props, context) {
  9. const { emitModelValue, emitOtherValue } = useFormInput(props, context)
  10. const end = computed(() => {
  11. if (props.otherValue) {
  12. return compareTime(props.otherValue, props.config?.end ?? '20:00') ? props.otherValue : props.config?.end
  13. }
  14. return props.config?.end
  15. })
  16. const start = computed(() => {
  17. if (props.modelValue) {
  18. return compareTime(props.modelValue, props.config?.start ?? '08:00') ? props.modelValue : props.config?.start
  19. }
  20. return props.config?.start
  21. })
  22. return () => <div style="display: flex; flex: 1">
  23. <SelectTime modelValue={props.modelValue}
  24. onUpdate:modelValue={emitModelValue}
  25. config={{ ...props.config, end: end.value }} />
  26. <span style="padding: 0px 8px;">至</span>
  27. <SelectTime modelValue={props.otherValue}
  28. onUpdate:modelValue={emitOtherValue}
  29. config={{ ...props.config, start: start.value }} />
  30. </div>
  31. }
  32. }