<template>
  <div class="select">
<!--    <div class="year">
      <span class="search__label">年度:</span>
      <el-date-picker 
        v-model="year" 
        type="year" 
        placeholder="选择年" 
        size="small"
        @change="yearChange"
        :clearable="false">
      </el-date-picker>
    </div>-->
    <div class="year">
      <span class="search__label">年度:</span>
      <el-select placeholder="请选择" v-model="year" size="small" @change="yearChange"  >
        <el-option v-for="item in yearData" :key="item.year" :label="item.year" :value="item.year">
        </el-option>
      </el-select>
    </div>
    <div class="target">
      <span class="search__label">考核指标:</span>
      <el-select placeholder="请选择" v-model="target" size="small" @change="change"  >
        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
      </el-select>
    </div>
<!--    <Search @searchActive="searchActive" @clearData="clearData" />-->
    <el-input :placeholder=placeholder suffix-icon="el-icon-search" @input="searchActive" v-model="search" @keyup.native.enter="searchActive" @clear="clearData" style="width:280px" size="small" class="input-with-select inline-16" clearable>
    </el-input>
  </div>
</template>

<script>
import Search from '@/components/search/index1'
export default {
  name: '',
  props:["placeholder","yearData"],
  data () {
    return {
      year: String(new Date().getFullYear()),
      target:'1',
      search:'',
      yearOptions:[],
      options: [
        { label: '开票金额', value: '1' },
        { label: '订单金额', value: '2' },
        { label: '出货金额', value: '3' },
      ]
    };
  },
  components: { Search, },
  computed: {
  },
  watch: {
  },
  methods: {
    /*yearChange(time) {
      this.$emit('yearChange',time == null ? '' : time.getFullYear())
    },*/
    searchActive() {
      this.$emit('searchActive',this.search)
    },
    clearData() {
      this.$emit('clearData')
    },
    change(data) {
      this.$emit('targetChange',data)      
    },
    yearChange(data){
      this.$emit('yearChange',data)
    }
  },
  mounted() {
    console.log(this.yearData,"年份可选数据")
  }
};
</script>

<style scoped>
.select {
  font-size: 14px;
  display: flex;
  align-items: center;
}
.select .year,
.target {
  display: flex;
  align-items: center;
  margin-right: 24px;
}
.select span,
.target span {
  margin-right: 8px;
}
</style>
