AInput.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. import { EpPropMergeType } from 'element-plus/es/utils'
  3. import { StrAnyObj } from '@/typings'
  4. const props = withDefaults(
  5. defineProps<{
  6. modelValue: EpPropMergeType<
  7. | (new (...args: any[]) => string | number)
  8. | (() => string | number | null | undefined)
  9. | ((new (...args: any[]) => string | number) | (() => string | number | null | undefined))[],
  10. unknown,
  11. unknown
  12. >
  13. style?: StrAnyObj
  14. placeholder?: string
  15. clearable?: boolean
  16. disabled?: boolean
  17. readonly?: boolean
  18. type?: 'text' | 'textarea' | 'password'
  19. maxlength?: number
  20. minlength?: number
  21. showWordLimit?: boolean
  22. showPassword?: boolean
  23. rows?: number
  24. autosize?: boolean | { minRows?: number; maxRows?: number }
  25. resize?: 'none' | 'both' | 'horizontal' | 'vertical'
  26. change?: (value: any) => void
  27. }>(),
  28. {
  29. clearable: true,
  30. disabled: false,
  31. readonly: false
  32. }
  33. )
  34. const emits = defineEmits(['update:modelValue'])
  35. const computedModelValue = computed({
  36. get() {
  37. return props.modelValue
  38. },
  39. set(newValue) {
  40. emits('update:modelValue', newValue)
  41. }
  42. })
  43. </script>
  44. <template>
  45. <el-input
  46. v-model="computedModelValue"
  47. :placeholder="disabled ? '' : placeholder"
  48. :clearable="clearable"
  49. :disabled="disabled"
  50. :readonly="readonly"
  51. :type="type"
  52. :maxlength="maxlength"
  53. :minlength="minlength"
  54. :show-word-limit="showWordLimit"
  55. :show-password="showPassword"
  56. :rows="rows"
  57. :autosize="autosize"
  58. :resize="resize"
  59. :style="style"
  60. style="width: 100%"
  61. @change="(value: any) => change?.(value)"
  62. />
  63. </template>