<template>
  <div class="card">
    <div class="header sa-flex sa-row-between sa-m-b-8">
      <span class="label">
        <img :src="`./static/images/shop/dashboard/${type}.png`" />
      </span>
      <span class="value sa-flex" @click="onOpen">
        <el-button v-auth="'shop.admin.order.order.list'" type="info" link size="small"
          >详情</el-button
        >
        <el-icon class="sa-m-l-4"><ArrowRight /></el-icon>
      </span>
    </div>

    <div class="num sa-m-b-8">{{ data.num }}</div>
    <div class="footer sa-flex sa-row-between">
      <span class="label">{{ data.text }}</span>
      <span class="value">
        <el-popover popper-class="sa-popper" placement="top" trigger="hover" :content="data.tip">
          <template #reference>
            <el-icon><Warning /></el-icon>
          </template>
        </el-popover>
      </span>
    </div>
  </div>
</template>

<script setup>
  import { useRouter } from 'vue-router';
  const router = useRouter();

  const props = defineProps(['type', 'data', 'dateTime']);

  function onOpen() {
    router.push({
      path: '/shop/admin/order/order',
      query: { status: props.data.status, create_time: props.dateTime },
    });
  }
</script>

<style lang="scss" scoped>
  .card {
    padding: 14px var(--sa-padding) !important;
    line-height: 1;
    &:hover {
      transform: scale(1.05);
      transition: all 0.2s;
    }
    .header {
      .label {
        width: 24px;
        height: 24px;
      }
      img {
        width: inherit;
        height: inherit;
        border-radius: 8px;
      }
      .value {
        font-size: 12px;
        color: var(--sa-subfont);
        cursor: pointer;
        .el-icon {
          font-size: 12px;
        }
      }
    }
    .num {
      font-size: 24px;
      color: var(--sa-subtitle);
    }
    .footer {
      color: var(--sa-subfont);
      font-size: 12px;
    }
  }
</style>
