mobile.jsx 1.2 KB

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