<template>
  <LabelBox
    :label="formItems.attrs?.label"
    :need-star="formItems.attrs?.needStar"
    :width="formItems.attrs?.width"
  >
    <el-select
      v-model="value"
      size="mini"
      :placeholder="formItems.attrs?.placeholder || '请选择'"
      :clearable="formItems.clearable || true"
      :filterable="formItems.attrs?.filterable || true"
      v-bind="formItems.attrs"
      @change="handleChange"
    >
      <el-option
        v-for="item in formItems.options"
        :key="item.value"
        :label="item[formItems.attrs?.optionLabel]||item.label||item.text"
        :value="item[formItems.attrs?.optionValue]||item.value"
      >
        <span style="float: left">{{ item[formItems.attrs?.optionLabel]||item.label||item.text }}</span>
        <span
          v-if="formItems.attrs?.showValue"
        >（{{ item[formItems.attrs?.optionValue]||item.value }}）</span>
      </el-option>
    </el-select>
  </LabelBox>
</template>

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

export default {
  components: {
    LabelBox,
  },
  props: {
    formItems: {
      type: Object,
      default: () => {},
    },
    value: {
      type: String,
      default: '',
    },
  },
  methods: {
    handleChange(val) {
      this.$emit('input', val);
      this.$emit('outOperation', val);
    },
  },
};
</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;
}
</style>

