<style lang="scss" scoped>
.search-bar {
  display: flex;
  align-items: center;
}
.search-box p {
  display: inline-block;
  border: 1px solid #f2f2f2;
  border-radius: 5px;
  margin-right: 10px;
  padding: 5px 10px;
  cursor: pointer;
}
</style>
<style>
/* .data-display-statistics .ant-card-body {
  padding: 0 15px;
} */
.data-display-statistics .ant-col-6 {
  margin: 10px 0;
}
.data-display-statistics .ant-col-6 .ant-card-body {
  display: flex;
  justify-content: center;
}
.data-display-statistics .ant-col-6 p,
.data-display-statistics .ant-col-6 span {
  text-align: center;
  line-height: 40px;
  font-size: 30px;
  font-weight: 600;
  color: red;
  margin: 0;
}
.search-box .ant-card-body {
  padding: 5px 15px;
}
.data-display-statistics .ant-col-6 .ant-card-body .styleElse {
  line-height: 60px;
  height: 40px;
  font-size: 16px;
  font-weight: 400;
  margin-left: 10px;
}
/* .ant-table-thead div {
  font-weight: 700;
} */
.tool-tip {
  position: absolute;
  top: 65px;
  right: 10px;
}

#mybtn{
    position: relative;
    top: 0;
    right: 0;
}
.btndiv{
    display: flex;
    justify-content: space-between;
}
.timeDiv{
    margin-bottom: 15px;
}

</style>
<template>
  <div >
     
        <a-card
          style="width:100%"
          :tabList="tabListNoTitle"
          :activeTabKey="noTitleKey"
          @tabChange="key => onTabChange(key, 'noTitleKey')"
        >
            <keep-alive>
                <component :is="currentTabComponent"></component>
            
            </keep-alive>
            
        </a-card>
      
  </div>
</template>





<script>

import countTo from 'vue-count-to'
import moment from 'moment'
import { getDailyReport } from '@api/statistics'
import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
import axios from 'axios'
import lifting from '../components/lifting'
import timeCheck from '../components/timeCheck'
import Treeselect from '../components/Treeselect.vue'
import { mapGetters } from 'vuex'
import { JeecgListMixin } from '@/mixins/ipagination'

//引入视频总日周月组件
import videoSummary from './vSummary';
import videoDay from './vDay';
import videoWeek from './vWeek';
import videoMonth from './vMonth';

var length = 0
var active = 1




export default {
  name: 'data-display-statistics',
  components: {
   
    countTo,
    lifting,
    timeCheck,
    Treeselect,
    videoSummary,
    videoDay,
    videoWeek,
    videoMonth

  },
  mixins: [JeecgListMixin],
  data: function() {
    return {
      // this.timeRange[1] = moment().add(1, 'months')
      
      statDate: moment().subtract(1, 'day'),
      title: '账户数据展示',
      show: true,
      data: [],
      dataAll: null,
    
      options: [],
      list: [],
      appId: [],
      tabListNoTitle: [
        {
          key: 'videoSummary',
          tab: '视频汇总'
        },
        {
          key: 'videoDay',
          tab: '视频分日'
        },
        {
          key: 'videoWeek',
          tab: '视频分周'
        },
        {
          key: 'videoMonth',
          tab: '视频分月'
        }
      ],
      noTitleKey: 'videoSummary',
      currentTabComponent:'videoSummary',
      discount: 1.06,
      date: '',
      loading: false,
      dataElse: [],
      projectId: 50
    }
  },
  filters: {
    formatDate: function(value) {
      let date = new Date(value)
      let y = date.getFullYear()
      let MM = date.getMonth() + 1
      MM = MM < 10 ? '0' + MM : MM
      let d = date.getDate()
      d = d < 10 ? '0' + d : d
      let h = date.getHours()
      h = h < 10 ? '0' + h : h
      let m = date.getMinutes()
      m = m < 10 ? '0' + m : m
      let s = date.getSeconds()
      s = s < 10 ? '0' + s : s
      return y + '-' + MM + '-' + d
    },
    toFixtwo: function(value) {
      if (value) {
        return value.toFixed(2)
      } else {
        return 0.0
      }
    },
    getBo: function(value) {
      if (value) {
        return (value * 100).toFixed(2) + '%'
      } else {
        return '0.00%'
      }
    }
  },
  methods: {
    moment,
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },
    ...mapGetters(['nickname', 'avatar', 'userInfo']),
    getParticipateList() {
      getAction('/ctop/projectMember/participateList', {
        userId: this.userInfo().id
      }).then(res => {
        if (res.code == 0) {
          this.dataElse = res.result
        }
      })
    },
    onTabChange(key, type) {
        console.log(key, type)
        this.currentTabComponent=key;
        this.noTitleKey=key;
        console.log(this.currentTabComponent)
    },
    
    getDataReset() {
      this.addUser()
    },
    addUser() {
      var that = this
      //   if (this.appId.length > 0 && this.date != '') {
      that.getDailyReport()
      //   } else {
      //     this.$message.error('请选择账户及时间')
      //   }
    },
    getDailyReport() {
      var params = {}
      params.projectId = this.projectId
      params.disCount = this.discount
      params.statDate = this.statDate.format('YYYY-MM-DD')
      this.data = []
      this.loading = true
      postAction('/ctop/yiche/report/dailyReport', params).then(res => {
        if (res.success) {
          this.loading = false
          this.dataAll = res.result
          console.log(res)
          if (this.noTitleKey == 'day') {
            this.columns = columnsThree
            this.data.push({ ...res.result.android, key: 1 })
          } else if (this.noTitleKey == 'group') {
            this.columns = columnsThree
            this.data.push({ ...res.result.ios, key: 1 })
          } else if (this.noTitleKey == 'application') {
            this.columns = columnsThree
            this.data.push({ ...res.result.directApplication, key: 1 })
          } else if (this.noTitleKey == 'channel') {
            this.columns = columns
            this.data = res.result.channelSubcontracting.map((item, index) => {
              return {
                ...item,
                key: index
              }
            })
          }
          this.ipagination.total = this.data.length
        }
      })
    },
    getDate(value) {
      if (value) {
        let date = new Date(value)
        let y = date.getFullYear()
        let MM = date.getMonth() + 1
        MM = MM < 10 ? '0' + MM : MM
        let d = date.getDate()
        d = d < 10 ? '0' + d : d
        this.date = y + '-' + MM + '-' + d
      } else {
        let date = new Date()
        let y = date.getFullYear()
        let MM = date.getMonth() + 1
        MM = MM < 10 ? '0' + MM : MM
        let d = date.getDate()
        d = d < 10 ? '0' + d : d
        this.date = y + '-' + MM + '-' + d
      }
    },
    
   
  },
  watch: {},
  distoryed() {},
  mounted: function() {
    this.getParticipateList()
    this.statDate = moment().subtract(1, 'day')
    // moment().format('YYYY-MM-DD_HH:mm')
    this.currentTabComponent=this.noTitleKey
  }
}
</script>
