222
schangxiang@126.com
2025-04-30 9bec4dcae002f36aa23231da11cb03a156b40110
PipeLineLems/web/src/components/BaseInput/BaseInput.tsx
@@ -1,9 +1,10 @@
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],
@@ -13,8 +14,24 @@
      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
@@ -27,16 +44,24 @@
      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 ? (