<template>
  <div class="p-4">
    <!-- <GrowCard :loading="loading" :list="growCardList" class="enter-y" /> -->
    <div class="md:flex !my-4 enter-y">
      <pieEchart class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4"></pieEchart>
      <lineEcharts title="管理中心用户活跃度统计" class="md:w-2/3 mx-4 w-full" />
    </div>
    <orderEchart title="作品趋势分析" class="!my-4 enter-y" @change="Search" :echartData="worksData" :loading="loading" />
    <lineEcharts title="云容量趋势分析" class="!my-4 enter-y" />
  </div>
</template>
<script lang="ts" setup>
import { ref, onMounted, reactive } from 'vue';
import { workTrend, sceneTrend } from '/@/api/statistics/index';
import orderEchart from './orderEchart.vue';
import pieEchart from './pieEchart.vue'
import sceneEchart from '../components/sceneEchart.vue';
import lineEcharts from './lineEcharts.vue';
const loading = ref(true);
// const growCardList = ref<GrowCardItem[]>([]);
const worksData = reactive({
  xdata:[],
  downOrder:[],
  incrementOrder:[],
  partOrder:[],
  echartTypr:'bar',
});
const SearchData = reactive({
  startTime: '',
  endTime: '',
  timeType: 'month',
  infoType: 'add',
});
onMounted(() => {
  getData();
  getList();
});
async function getList() {
  let downlist = [], xdata = [], downOrder = [], partOrder = [], incrementOrder = [];
  let res =  await workTrend(SearchData);
  res = res.reverse()
  res.map((ele) => {
    xdata.push(ele.groupKey);
    // downlist.push(ele.count);
    downOrder.push(ele.pano);
    partOrder.push(ele.mix);
    incrementOrder.push(ele.age);
  });
  worksData.xdata = xdata
  worksData.downOrder = downOrder
  worksData.incrementOrder = incrementOrder
  worksData.partOrder = partOrder
}
function Search(val) {
  console.log('infoType',val)
  const { startTime, endTime, dataType, type } = val;
  let timeStr = {
      0:'day',
      1:'week',
      2:'month',
    }
  SearchData.startTime = startTime;
  SearchData.endTime = endTime;
  SearchData.infoType = type == '0'?'add':'all';
  SearchData.timeType = timeStr[dataType] || 'month'
  getList();
}
async function getData() {
}
</script>

