<!--
 * @Author: your name
 * @Date: 2021-10-18 14:14:56
 * @LastEditTime: 2021-11-25 13:51:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \Foshan4A\src\layout\components\dateType\index.vue
-->
<template>
  <div class="date-type">
    <div v-for="(item,index) in arrs" @click="checkType(item,index)" :class="active===index?'active':''" :key="index" class="date-type-list">{{item.name}}</div>
  </div>
</template>

<script>
export default {
  name: 'DateType',
  props: {
    arrs: {
      type: Array,
      default: () => [
        {
          name: '日',
          value: 1
        },
        {
          name: '月',
          value: 2
        },
        {
          name: '年',
          value: 3
        }
      ]
    }
  },
  data () {
    return {
      active: 0
    }
  },
  methods: {
    checkType (item, index) {
      this.active = index
      this.$emit('getTypeData', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.date-type {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #606266;
  background: #f5f7fa;
  border-radius: 4px;
  display: flex;
  height: 36px;
  line-height: 36px;
  padding: 0 3px;
  .date-type-list {
    flex: 1;
    text-align: center;
    padding: 0 20px;
    cursor: pointer;
  }
  .active {
    background-color: #fff;
    box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    height: 30px;
    line-height: 30px;
    margin-top: 3px;
  }
}
</style>