<template>
  <div class="percent-card">
    <div class="card-chart">
      <percent-bar width="5.926vh" height="5.926vh" :value="percent" :color="color" />
      <div class="card-title gray">{{ title }}</div>
    </div>
    <div class="card-info">
      <div class="card-value">
        <span class="value-text gray">{{ TotalText }}</span>
        <span class="white">{{ TotalValue }}</span>
      </div>
      <div class="card-value">
        <span class="value-text gray">{{ ActualText }}</span>
        <span class="white">{{ ActualValue }}</span>
      </div>
    </div>
  </div>
</template>

<script>
// 百分比card2
// 使用位置 驾驶舱首页 计划电量完成情况 中的百分比卡片
import PercentBar from "../../chart/bar/percent-bar.vue";
export default {
  components: {
    PercentBar,
  },
  props: {
    title: {
      type: String,
      default: "月计划完成率",
    },
    TotalText: {
      type: String,
      default: "实际",
    },
    TotalValue: {
      type: Number,
      default: 0,
    },
    ActualText: {
      type: String,
      default: "计划",
    },
    ActualValue: {
      type: Number,
      default: 100,
    },
    color: {
      type: String,
      default: "green",
    }
  },
  computed: {
    percent() {
      // return parseInt((this.ActualValue / this.TotalValue) * 100);
      return parseInt((this.TotalValue / this.ActualValue) * 100);
    },
  },
};
</script>

<style lang="less" scoped>
.percent-card {
  display: flex;

  .card-chart {
    flex: 1 1 5.926vh;
  }

  .card-title {
    text-align: center;
    width: 100%;
    margin-top: 1.481vh;
    font-size: 12px;
  }

  .card-info {
    flex: auto;
    align-self: center;
    margin-left: 0.741vh;
    margin-top: -2.2222vh;

    .card-value {
      font-size: @fontsize-s;
      font-weight: 600;
      margin-bottom: 1.1111vh;
      white-space: nowrap;

      .value-text {
        margin-right: 0.741vh;
        font-family: @font-family-num;
      }
    }

    .card-text {
      font-size: @fontsize;
    }
  }
}
</style>
