<template>
  <LabelBox
    :label="formItems.attrs?.label"
    :need-star="formItems.attrs?.needStar"
    :width="formItems.attrs?.width"
  >
    <div class="input-select">
      <el-input
        v-model="value[0]"
        size="mini"
        :placeholder="formItems.attrs?.placeholder || '请填写'"
        v-bind="formItems.attrs"
        @input="handleChange"
      >
        <!-- 前文字 -->
        <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>
      <el-select
        v-model="value[1]"
        size="mini"
        style="margin-left:5px;"
        :placeholder="formItems.attrs2?.placeholder || '请选择'"
        :clearable="formItems.clearable || true"
        :filterable="formItems.attrs2?.filterable || true"
        v-bind="formItems.attrs2"
        @change="handleChange1"
      >
        <el-option
          v-for="item in formItems.options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
    </div>
  </LabelBox>
</template>

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

export default {
  components: {
    LabelBox,
  },
  props: {
    formItems: {
      type: Object,
      default: () => {},
    },
    value: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    handleChange(val) {
      this.value[0] = val;
      this.$emit('input', this.value);
      this.$emit('outOperation', val, 0);
    },
    handleChange1(val) {
      this.value[1] = val;
      this.$emit('input', this.value);
      this.$emit('outOperation', val, 1);
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep.el-select {
  width: 100%;
  height: 24px;
  line-height: 24px;
}

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

::v-deep.el-select .el-input__icon {
  height: 24px;
  line-height: 25px;
}

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

::v-deep.el-select .el-input__inner {
  height: 24px;
  line-height: 24px;
}
.input-select {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
}
::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>

