mobile.jsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { computed } from 'vue'
  2. import { Field as VanField } from 'vant'
  3. import { useFormInput } from '../../../hooks/form-input'
  4. import { formInputProps, fromInputEmits } from '../../form-input-props'
  5. import { useCipConfig } from '@cip/components/hooks/use-cip-config'
  6. import { getUsingConfig } from '@cip/utils/util'
  7. export default {
  8. props: formInputProps,
  9. emits: [...fromInputEmits],
  10. setup (props, context) {
  11. const cipConfig = useCipConfig()
  12. const { proxyValue, clearable, placeholder, securityConfig } = useFormInput(props, context)
  13. const limit = computed(() => {
  14. return getUsingConfig(securityConfig.value.limit, cipConfig.limit.textarea) // props.config?.limit ?? cipConfig?.limit?.textarea ?? ''
  15. })
  16. const autosize = computed(() => {
  17. if (props.config?.autosize) {
  18. const { minRows, maxRows } = props.config?.autosize
  19. return { minHeight: minRows * 30, maxHeight: maxRows * 30 }
  20. }
  21. return { minHeight: 60, maxHeight: 100 }
  22. })
  23. /* vant中clear使用的是touchStart事件,浏览器中click无效 */
  24. return () => <VanField
  25. v-model={proxyValue.value}
  26. type="textarea"
  27. clearable={clearable.value}
  28. placeholder={placeholder.value}
  29. autosize={autosize.value}
  30. maxlength={limit.value}
  31. show-word-limit={!!limit.value}
  32. />
  33. }
  34. }