<!--
 * @Author: zhp
 * @Date: 2024-06-27 09:12:54
 * @LastEditTime: 2024-06-27 09:14:21
 * @LastEditors: zhp
 * @Description:
-->

<template>
  <div class="progress-bar" :data-title="title" :data-rate="previous + '%'">
    <div class="progress-bar__rate" :style="{ width: dataRate == '-' ? 0 : dataRate }"></div>
  </div>
</template>

<script>
export default {
  name: "ProgressBar",
  components: {},
  props: {
    value: {
      type: Number,
      default: 0,
    },
    target: {
      type: Number,
      default: 0,
    },
    previous: {
      type: Number,
      default: 0,
    },
    current: {
      type: Number,
      default: 0,
    },
    // total: {
    //   type: Number,
    //   default: 0,
    // },
    title: {
      type: String,
      default: "",
    },
  },
  data() {
    return {};
  },
  computed: {
    dataRate() {
      // if (this.current != 0 && this.target != 0) {
        // console.log( '1111111111', this.current, this.target,this.previous);
      return this.previous >=100 ? 100 + '%' : this.previous + '%';
      // } else if(this.previous != 0) {
      //   return this.previous + '%'
      // }
    },
  },
  methods: {},
};
</script>

<style scoped lang="scss">
.progress-bar {
  height: 10px;
  background-color: #002f6b;
  border-radius: 4px;
  margin-bottom: 12px;
  position: relative;

  &:before {
    content: attr(data-title);
    display: inline-block;
    color: #fff;
    position: absolute;
    bottom: -200%;
    font-size: 12px;
  }

  &:after {
    content: attr(data-rate);
    display: inline-block;
    color: #fff;
    position: absolute;
    bottom: -200%;
    right: 0;
    font-size: 12px;
  }

  &:first-child {
    &:after {
      color: #11eae3;
    }
  }

  &:nth-child(2) {
    &:after {
      color: #0e65fd;
    }
  }

  .progress-bar__rate {
    position: absolute;
    display: inline-block;
    height: 100%;
    width: 0;
    border-radius: 4px;
     background: linear-gradient(to right,
          #004c5e11 10%,
          #004c5e,
          #0ac0c0,
          #11eae3);
  }

  &:first-child {
    .progress-bar__rate {
      background: linear-gradient(to right,
          #004c5e11 10%,
          #004c5e,
          #0ac0c0,
          #11eae3);
    }
  }

  &:nth-child(2) {
    .progress-bar__rate {
      background: linear-gradient(to right, #0048a811, #0048a8, #0e65fd);
    }
  }
}
</style>
