storage.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <el-card shadow="none" :body-style="{height:'112px'}">
  3. <div class="flex-align-center flex-between height-full">
  4. <div v-if="data" style="align-self:stretch">
  5. <div class="flex-end height-full">
  6. <div style="flex:1;width:100%">
  7. <p class="info" style="margin-bottom:10px">云存储已使用</p>
  8. <!-- <p class="num">{{data.used > 1073741824?(data.used / Math.pow(1024,3)).toFixed(2)+'GB':data.used > 1048576?(data.used / Math.pow(1024,2)).toFixed(2)+'MB':data.used > 1024?(data.used / Math.pow(1024,1)).toFixed(2)+'KB':data.used+'B'}}</p> -->
  9. <div class="flex-align-center">
  10. <VueCountUp class="data-num" :start-value="0" :end-value="data.used > 1073741824?(data.used / Math.pow(1024,3)).toFixed(2):data.used > 1048576?(data.used / Math.pow(1024,2)).toFixed(2):data.used > 1024?(data.used / Math.pow(1024,1)).toFixed(2):data.used" />
  11. <p class="data-num">{{data.used > 1073741824?'GB':data.used > 1048576?'MB':data.used > 1024?'KB':'B'}}</p>
  12. </div>
  13. </div>
  14. <p class="info" style="width:100%">云存储总容量&emsp;<span style="color:#666">{{data.total}}GB</span></p>
  15. </div>
  16. </div>
  17. <div id="storage"></div>
  18. </div>
  19. </el-card>
  20. </template>
  21. <script>
  22. import { Pie } from '@antv/g2plot';
  23. import VueCountUp from 'vue-countupjs'
  24. export default {
  25. props:['data'],
  26. data () {
  27. return {
  28. piePlot () {},
  29. }
  30. },
  31. components:{
  32. VueCountUp
  33. },
  34. methods:{
  35. renderBar () {
  36. this.piePlot = new Pie('storage', {
  37. appendPadding: 10,
  38. data:[],
  39. width:100,
  40. height:100,
  41. tooltip: {
  42. formatter: (datum) => {
  43. let value = datum.num > 1073741824?(datum.num / Math.pow(1024,3)).toFixed(2)+'GB':datum.num > 1048576?(datum.num / Math.pow(1024,2)).toFixed(2)+'MB':datum.num > 1024?(datum.num / Math.pow(1024,1)).toFixed(2)+'KB':datum.num+'B'
  44. return { name: datum.type, value: value, rate: 20 }
  45. },
  46. },
  47. label:{
  48. type: 'inner',
  49. content:''
  50. },
  51. legend:false,
  52. angleField: 'num',
  53. colorField: 'type',
  54. color: ['#5D76E4', '#51C186'],
  55. radius: 0.9,
  56. interactions: [{ type: 'element-active' }],
  57. });
  58. this.piePlot.render();
  59. }
  60. },
  61. mounted() {
  62. this.renderBar()
  63. }
  64. }
  65. </script>
  66. <style>
  67. .el-card__header {
  68. padding: 10px 16px !important;
  69. }
  70. </style>
  71. <style scoped>
  72. .flex-end {
  73. display: flex;
  74. flex-direction:column;
  75. justify-content: space-between;
  76. }
  77. .info{
  78. font-size: 14px;
  79. text-align:left;
  80. }
  81. .height-full{
  82. height: 100%;
  83. }
  84. .data-num{
  85. font-size: 30px;
  86. font-family: HelveticaNeue-, HelveticaNeue;
  87. font-weight: normal;
  88. color: #333333;
  89. line-height: 38px;
  90. text-align: left;
  91. }
  92. </style>