<template>
  <a-card :loading="loading" :bordered="false" :body-style="{ padding: '0' }">
    <div class="salesCard">
      <a-tabs default-active-key="1" size="large" :tab-bar-style="{ marginBottom: '24px', paddingLeft: '16px' }">
        <template #rightExtra>
          <div class="extra-wrapper">
            <div class="extra-item" style="position: relative">
<!--              <div>-->
<!--                <a-radio-group v-model:value="value1" button-style="solid" @change="value1Change">-->
<!--                  <a-radio-button value="today">本日</a-radio-button>-->
<!--                  <a-radio-button value="days">按天</a-radio-button>-->
<!--                  <a-radio-button value="month">按月</a-radio-button>-->
<!--                  <a-radio-button value="year">按年</a-radio-button>-->
<!--                </a-radio-group>-->
<!--              </div>-->
            </div>
<!--            <a-range-picker @change="rangePickerChange" v-if="value1 == 'month'" v-model:value="rangePickerData" picker="month" :style="{ width: '256px' }" />-->
            <a-range-picker v-if="value1 == 'days'" @change="rangePickerChange" v-model:value="rangePickerData" :style="{ width: '256px' }" />
          </div>
        </template>
        <a-tab-pane loading="true" tab="销售额" key="1">
          <a-row>
            <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
              <Bar :chartData="barData" :option="{ title: { text: '', textStyle: { fontWeight: 'lighter' } } }" height="40vh" />
            </a-col>
<!--            <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">-->
<!--              <RankList title="门店销售排行榜" :list="rankList" />-->
<!--            </a-col>-->
          </a-row>
        </a-tab-pane>
<!--        <a-tab-pane tab="销售趋势" key="2">
          <a-row>
            <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
              <Bar :chartData="barData.reverse()" :option="{ title: { text: '销售额排行', textStyle: { fontWeight: 'lighter' } } }" height="40vh" />
            </a-col>
            <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
              <RankList title="门店销售排行榜" :list="rankList" />
            </a-col>
          </a-row>
        </a-tab-pane>-->
      </a-tabs>
    </div>
  </a-card>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import type { Dayjs } from 'dayjs';
  import { getLogStatistics } from '../api';
  import Bar from '/@/components/chart/Bar.vue';
  type RangeValue = [Dayjs, Dayjs];
  const dateFormat = 'YYYY/MM/DD';
  const value1 = ref<string>('days');
  const rangePickerData = ref<RangeValue>();
  defineProps({
    loading: {
      type: Boolean,
    },
  });
  const rankList = [];
  for (let i = 0; i < 7; i++) {
    rankList.push({
      name: '白鹭岛 ' + (i + 1) + ' 号店',
      total: 1234.56 - i * 100,
    });
  }

  const barData = [];
  for (let i = 0; i < 12; i += 1) {
    barData.push({
      name: `${i + 1}月`,
      value: Math.floor(Math.random() * 1000) + 200,
    });
  }

  function value1Change(){
    console.log(rangePickerData);
  }
  function rangePickerChange(data){
    console.log(data);
    console.log(data[0].format(dateFormat));
    data[1].format(dateFormat);

    console.log(data[0]);
  }
  function fff() {
    const params = {
      type:'day',
      dayStart:'2024-08-29',
      dayEnd:'2024-08-29',
    };
    getLogStatistics(params).then((res) => {
      if (res.success) {
        console.log(res);
      }
    });
  }

  fff();
</script>

<style lang="less" scoped>
  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  }
</style>
