| | |
| | | import { defineComponent, SetupContext, ref, computed } from 'vue' |
| | | import styles from './BaseInput.module.scss' |
| | | import { getScopeT, Language } from '@/libs/Language/Language' |
| | | |
| | | export default defineComponent({ |
| | | name: 'BaseInput', |
| | | emits: ['update:modelValue', 'click'], |
| | | emits: ['update:modelValue', 'click', 'change', 'enter'], |
| | | props: { |
| | | modelValue: { |
| | | type: [String, Number], |
| | |
| | | type: String, |
| | | default: '请输入', |
| | | }, |
| | | readOnly: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | LanguageScopeKey: { |
| | | type: String, |
| | | default: '', |
| | | }, |
| | | onChange: { |
| | | type: Function, |
| | | }, |
| | | onEnter: { |
| | | type: Function, |
| | | }, |
| | | }, |
| | | setup(props, { attrs, slots, emit }: SetupContext) { |
| | | const _t = getScopeT(props.LanguageScopeKey) |
| | | |
| | | const input = computed({ |
| | | get() { |
| | | return props.modelValue |
| | |
| | | evt?.stopPropagation() |
| | | emit('click', evt) |
| | | } |
| | | const onKeypress = (event: KeyboardEvent) => { |
| | | if (event.keyCode === 13) { |
| | | emit('enter') |
| | | } |
| | | } |
| | | return () => { |
| | | return ( |
| | | <div class={styles.baseInput} onClick={onClick}> |
| | | <input |
| | | placeholder={props.placeholder} |
| | | {...attrs} |
| | | placeholder={_t(props.placeholder)} |
| | | class={{ |
| | | [styles.input]: true, |
| | | [styles.hover]: true, |
| | | }} |
| | | v-model={input.value} |
| | | onInput={() => emit('change')} |
| | | onKeypress={onKeypress} |
| | | /> |
| | | {/* <span class={styles.hasHover}> |
| | | {input.value ? ( |