index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <el-input v-model="proxyValue"
  3. ref="inputRef"
  4. :placeholder="placeholder"
  5. :disabled="disabled"
  6. :style="{width}"
  7. :maxlength="limit"
  8. :show-word-limit="showWordLimit && !!limit"
  9. show-password
  10. :clearable="clearable"></el-input>
  11. </template>
  12. <script>
  13. import { ElInput } from 'element-plus'
  14. import { useFormInput } from '@cip/components/hooks/form-input'
  15. import { formInputProps, fromInputEmits } from '../../form-input-props'
  16. import { computed } from 'vue'
  17. export default {
  18. name: 'BasicInput',
  19. components: { ElInput },
  20. props: formInputProps,
  21. emits: [...fromInputEmits],
  22. setup (props, context) {
  23. const { inputRef, proxyValue, ...formInput } = useFormInput(props, context)
  24. const placeholder = computed(() => {
  25. return props.config?.placeholder ?? ''
  26. })
  27. const limit = computed(() => {
  28. return props.config?.limit ?? ''
  29. })
  30. const showWordLimit = computed(() => {
  31. return props.config?.showWordLimit ?? true
  32. })
  33. return {
  34. ...formInput,
  35. inputRef,
  36. proxyValue,
  37. placeholder,
  38. limit,
  39. showWordLimit
  40. }
  41. }
  42. }
  43. </script>