<template>
  <div class="data-range-container">
    <el-button type="primary" @click="previous">前一天</el-button>
    <el-date-picker
      v-model="datePrivate"
      format="yyyy-MM-dd"
      value-format="yyyy-MM-dd"
      :picker-options="dateOption"
      type="date"
      placeholder="选择日期">
    </el-date-picker>
    <el-button type="primary" @click="next">后一天</el-button>
  </div>
</template>

<script>
import {GetDateStr} from '@/utils/util'
export default {
  name: 'date-signal',
  props: {
    value:{ // 必须要使用value
      default: '',
    },
  },
  data() {
    return {
      datePrivate: this.value,
      dateOption:{
        disabledDate: (time) => {
          return time.getTime() > this.today;
        }
      },
    }
  },
  computed: {
    today: {
      get: function(){
        return (new Date()).getTime()
      },
    },
    dateN: {
      get: function(){
        let date=this.datePrivate
        date=date.replace(/-/g,'/')
        return date
      },
    },
  },
  watch:{
    datePrivate(val) {
      this.$emit('input', val)
    },
  },
  mounted(){
    // console.log(this.total)
  },
  methods: {
    next(){
      this.datePrivate=GetDateStr(this.dateN,1)
    },
    previous(){
      this.datePrivate=GetDateStr(this.dateN,-1)
    }
  },
}
</script>

<style scoped>
.page-container{
  padding:30px 10px
}
</style>
