<template>
  <div class="stat-cards-container">
    <div class="stat-card" v-for="(item, idx) in numberList" :key="idx">
      <div class="stat-card__title">{{ item.title }}</div>
      <div class="stat-card__value">{{ item.value }}</div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, reactive, watch, ref } from "vue";

const props = defineProps({
  currentName: {
    type: String,
    default: "立项",
  },
});

const numberList = ref([]);

// 根据currentName设置不同的数据
const setNumberList = (name) => {
  if (name === "立项") {
    numberList.value = [
      { title: "总个数（个）", value: "59" },
      { title: "总投资（亿元）", value: "2733.35" },
      { title: "总规模（公里）", value: "5116.72" },
    ];
  } else {
    numberList.value = [
      { title: "总个数（个）", value: "59" },
      { title: "总投资（亿元）", value: "2733.35" },
      { title: "总规模（公里）", value: "5116.72" },
      { title: "累计完成投资（亿元）", value: "3116.44" },
    ];
  }
};

watch(
  () => props.currentName,
  (newVal) => {
    setNumberList(newVal);
  },
  {
    immediate: true,
    deep: true,
  }
);

onMounted(() => {
  setNumberList(props.currentName);
});
</script>

<style scoped lang="less">
.stat-cards-container {
  display: flex;
  justify-content: center;
  align-items: center;
  .stat-card {
    .vw(width, 180);
    .vh(height, 80);
    .vw(border-radius, 5);
    .vw(padding, 10);
    .vw(padding, 10);
    .vw(margin,10);
    background-image: url("../assets/images/total.png");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    .stat-card__title {
      .font(14);
    }
    .stat-card__value {
      .vh(margin-top, 20);
      .font(20);
    }
  }
}
</style>
