<template>
  <el-input :placeholder="placeholder" v-model="value" class="input-with-select" size="mini" @input="input">
    <el-select v-model="select" slot="append" placeholder="请选择" @change="change">
      <el-option v-for="(item,index) of options" :key="index" :label="item.label" :value="item.value"></el-option>
    </el-select>
  </el-input>
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
@Component
export default class InputSelect extends Vue {
  value='';
  select='';
  placeholder='';

  @Prop()
  options!:Array<any>

  mounted(){
    if(this.options){
      this.select = this.options[0].value;
      this.placeholder = this.options[0].label;
    }
  }

  change(v:any){
    for(const item of this.options){
      if(item.value == v){
        this.placeholder = item.label
      }
    }
  }
  input(v:any){
    this.$emit('input',{
      value:this.value,
      code:this.select
    })
  }
}
</script>

<style lang="scss" scoped>
.input-with-select{
  padding-bottom: 4px;
  width: 100%;
}
</style>

<style lang="scss">
.input-with-select{
  .el-input-group__append{
    background-color: #fff !important;
    width: 110px !important;
  }  
}
</style>