ViewDate.vue 2.35 KB
<!--
 * @Description: 内容页面统计年份组件
 * @Author: huyue
 * @Date: 2023-07-05 10:35:43
 * @LastEditors: huyue
 * @LastEditTime: 2023-07-17 18:13:20
-->
<template>
  <div class="view-date">统计年份:
    <div class="year-plugin">
      <div class="year" @click.stop="switchYear">
        {{$store.state.app.solarYear ? $store.state.app.solarYear : '全部'}}
        <img class="arrow-down" src="@/assets/images/arrow-down.png" alt="">
      </div>
      <SelectBox :isShow="isShow" isObject :defaultValue="defaultYear" @clickOutside="clickOutside" :dataList="dataList" :boxWidth="'8.61vw'" @selectVal="selectVal"></SelectBox>
    </div>
    <span class="businessTime">
      业务开始时间:{{businessTime ? new Date(businessTime).format('yyyy-MM-dd') : ''}}
    </span>
  </div>
</template>
<script type='text/ecmascript-6'>
// import datas from '@/utils/data'
import { mapActions } from 'vuex'
export default {
  name: 'ViewDate',
  props: {
    businessTime: String,
    dataList: {
      type: Array,
      default: () => []
    },
    defaultYear: String
  },
  data() {
    return {
      isShow: false,
      // dataList: datas.DefaultData.yearList,
      year: ''
    }
  },
  mounted() {
    const { defaultYear } = this
    if (defaultYear) this.setSolarYear(defaultYear)
    // this.year = this.$store.state.app.solarYear
  },
  methods: {
    ...mapActions(['setSolarYear']),
    switchYear() {
      this.isShow = !this.isShow
    },
    selectVal(val) {
      this.setSolarYear(val.value)
      this.switchYear()
    },
    clickOutside() {
      this.isShow = false
    }
  }
}
</script>
<style scoped lang='scss'>
.view-date {
  display: flex;
  align-items: center;
  // width: 100%;
  height: 6.67vh;
  color: #C9C9C9;
  font-size: 14px;
  padding: 0 1.33vh;
  background-color: #091C40;
  .year-plugin {
    position: relative;
  }
  .year {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 8.61vw;
    height: 4vh;
    padding: 0 0.56vw;
    box-sizing: border-box;
    background-image: linear-gradient(270deg, #6578FF 0%, #079FF1 100%);
    margin-right: 0.56vw;
    color: #FFFFFF;
    .arrow-down {
      width: 0.69vw;
      height: 0.67vh;
    }
  }
}
.businessTime {
  color: #536079;
  font-size: 14px;
}
</style>