
export default{
  data() {
    return {
      //周数之差
      weekDiff:0,
      tableTheadColumns:['本周','下一周'],
      BaseDate:'',
      weekQuery:0
    }
  },
  methods: {
    toogelDate(type){
      this.weekQuery=type
      if(this.weekQuery==0){
        this.BaseDate=''
        this.tableTheadColumns=['本周','下一周']
        this.weekDiff=0
      }else{
        let prePeriodDate,nextPeriodDate;
        this.weekDiff=this.weekQuery==1?this.weekDiff-2:this.weekDiff+2
        if(this.weekDiff==0){
          // 为0代表本期
          prePeriodDate='本周'
          nextPeriodDate='下一周'
        }else if(this.weekQuery==1){
          // 往前推两周
          prePeriodDate = this.$moment(this.BaseDate).subtract(14,'days').format('YYYY-MM-DD')+
          '——'+this.$moment(this.BaseDate).subtract(8,'days').format('YYYY-MM-DD')
          nextPeriodDate = this.$moment(this.BaseDate).subtract(7,'days').format('YYYY-MM-DD')+
          '——'+this.$moment(this.BaseDate).subtract(1,'days').format('YYYY-MM-DD')
        }else{
          // 往后推两周
          prePeriodDate = this.$moment(this.BaseDate).add(14,'days').format('YYYY-MM-DD')+
          '——'+this.$moment(this.BaseDate).add(20,'days').format('YYYY-MM-DD')
          nextPeriodDate = this.$moment(this.BaseDate).add(21,'days').format('YYYY-MM-DD')+
          '——'+this.$moment(this.BaseDate).add(27,'days').format('YYYY-MM-DD')
        }
        this.tableTheadColumns=[prePeriodDate,nextPeriodDate]
        console.log(this.weekDiff,prePeriodDate,nextPeriodDate);
      }
      this.getTableData()
    },
  },
}