percent-card-2.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="percent-card">
  3. <div class="card-chart">
  4. <percent-bar width="5.926vh" height="5.926vh" :value="percent" :color="color" />
  5. <div class="card-title gray">{{ title }}</div>
  6. </div>
  7. <div class="card-info">
  8. <div class="card-value">
  9. <span class="value-text gray">{{ TotalText }}</span>
  10. <span class="white">{{ TotalValue }}</span>
  11. </div>
  12. <div class="card-value">
  13. <span class="value-text gray">{{ ActualText }}</span>
  14. <span class="white">{{ ActualValue }}</span>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. // 百分比card2
  21. // 使用位置 驾驶舱首页 计划电量完成情况 中的百分比卡片
  22. import PercentBar from "../../chart/bar/percent-bar.vue";
  23. export default {
  24. components: {
  25. PercentBar,
  26. },
  27. props: {
  28. title: {
  29. type: String,
  30. default: "月计划完成率",
  31. },
  32. TotalText: {
  33. type: String,
  34. default: "实际",
  35. },
  36. TotalValue: {
  37. type: Number,
  38. default: 0,
  39. },
  40. ActualText: {
  41. type: String,
  42. default: "计划",
  43. },
  44. ActualValue: {
  45. type: Number,
  46. default: 100,
  47. },
  48. color: {
  49. type: String,
  50. default: "green",
  51. }
  52. },
  53. computed: {
  54. percent() {
  55. // return parseInt((this.ActualValue / this.TotalValue) * 100);
  56. return parseInt((this.TotalValue / this.ActualValue) * 100);
  57. },
  58. },
  59. };
  60. </script>
  61. <style lang="less" scoped>
  62. .percent-card {
  63. display: flex;
  64. .card-chart {
  65. flex: 1 1 5.926vh;
  66. }
  67. .card-title {
  68. text-align: center;
  69. width: 100%;
  70. margin-top: 1.481vh;
  71. font-size: @fontsize-s;
  72. }
  73. .card-info {
  74. flex: auto;
  75. align-self: center;
  76. margin-left: 0.741vh;
  77. margin-top: -2.2222vh;
  78. .card-value {
  79. font-size: @fontsize-s;
  80. font-weight: 600;
  81. margin-bottom: 1.1111vh;
  82. .value-text {
  83. margin-right: 0.741vh;
  84. }
  85. }
  86. .card-text {
  87. font-size: @fontsize;
  88. }
  89. }
  90. }
  91. </style>