<template>
  <LabelBox
    :label="formItems.attrs?.label"
    :need-star="formItems.attrs?.needStar"
    :width="formItems.attrs?.width"
  >
    <el-input
      size="mini"
      :value="value"
      :placeholder="formItems.attrs?.placeholder || '请填写'"
      v-bind="formItems.attrs"
      v-on="formItems.events"
      @input="handleInput"
    >
      <!-- 前文字 -->
      <template
        v-if="formItems.attrs?.prepend"
        slot="prepend"
      >{{
        formItems.attrs.prepend
      }}</template>
      <!-- 后文字 -->
      <template
        v-if="formItems.attrs?.append"
        slot="append"
      >{{
        formItems.attrs.append
      }}</template>
    </el-input>
  </LabelBox>
</template>

<script>
import LabelBox from '../labelBox/index.vue';

export default {
  components: {
    LabelBox,
  },
  props: {
    formItems: {
      type: Object,
      default: () => {},
    },
    value: {
      type: String,
      default: '',
    },
  },
  methods: {
    handleInput(val) {
      this.$emit('input', val);
      this.$emit('outOperation', val);
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep.el-input {
  height: 24px;
  line-height: 24px;
}

::v-deep.input-box {
  height: 24px;
}

::v-deep.el-input .el-input__icon {
  height: 24px;
  line-height: 25px;
  margin-left: -6px;
}

::v-deep.el-input .el-input-group__prepend {
  box-sizing: border-box;
  padding: 0 10px;
  height: 24px;
  line-height: 24px;
  border: none;
}

::v-deep.el-input .el-input__inner {
  height: 24px;
  line-height: 24px;
}

::v-deep.el-input--prefix .el-input__inner {
  padding-left: 19px;
}
</style>

