index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <a-row type="flex" justify="start">
  3. <a-col :span="5" style="text-align: center;">
  4. <icon :type="card.icon" style="font-size: 48px;" />
  5. <div>{{ card.title }}</div>
  6. <div style="font-weight: bold; font-size: 24px;">{{ card.total }}<span v-if="card.unit" style="font-size: 12px;margin-left: 5px">{{ card.unit }}</span></div>
  7. </a-col>
  8. <a-col :span="11">
  9. <div v-for="(v, k) in card.items" :key="k" class="col d-flex align-items-center" style="padding-top: 8px;" @click="handleResClick(card, k)">
  10. <status :status="k" statusModule="monitorresources" style="display: inline-grid;" />
  11. <span :class="(['guest','host'].includes(card.resType)?'asA':'')">{{ (card.items[k] || 0) }}</span>
  12. </div>
  13. </a-col>
  14. <a-col v-if="card.total > 0">
  15. <div v-for="(v, k) in card.items" :key="'percent' + k" style="padding-top: 6px;">
  16. <a-tag color="blue">
  17. {{ (v * 100 / card.total).toFixed(0) + '%' }}
  18. </a-tag>
  19. </div>
  20. </a-col>
  21. </a-row>
  22. </template>
  23. <script>
  24. import Status from '@/components/Status'
  25. export default {
  26. name: 'OverviewSummaryCard',
  27. components: { Status },
  28. props: {
  29. card: {
  30. type: Object,
  31. required: true,
  32. },
  33. },
  34. methods: {
  35. handleResClick (res, alert_state) {
  36. this.$emit('resourceClick', { resType: res.resType, alert_state })
  37. },
  38. },
  39. }
  40. </script>
  41. <style scoped>
  42. .asA {
  43. cursor: pointer;
  44. color: var(--antd-wave-shadow-color);
  45. }
  46. </style>