<template>
  <div class="select">
    <div class="year">
      <span>年度:</span>
      <el-date-picker 
        v-model="year" 
        type="year" 
        placeholder="选择年" 
        size="small"
        @change="yearChange">
      </el-date-picker>
    </div>
    <Search @searchActive="searchActive" @clearData="clearData" />
    <div class="target">
      <span>考核指标:</span>
      <el-select placeholder="请选择" v-model="target" size="small" @change="change" clearable @clear="$emit('clearTarget')">
        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
      </el-select>
    </div>
  </div>
</template>

<script>
import Search from '@/components/search/index'
export default {
  name: '',
  data () {
    return {
      year: String(new Date().getFullYear()),
      target:'',
      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(data) {
      this.$emit('searchActive',data)
    },
    clearData() {
      this.$emit('clearData')
    },
    change(data) {
      this.$emit('targetChange',data)      
    }
  },
};
</script>

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