index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div slot="header" class="clearfix kind-tab-header">
  3. <div class="float-left">
  4. <a-radio-group v-model="activeTab" @change="radioChange">
  5. <a-radio-button :value="item.key" v-for="item in tabsC" :key="item.key">{{ item.label }}</a-radio-button>
  6. <project-radio :domain.sync="domain" :activeTab.sync="activeTab" />
  7. <tag-radio :label.sync="label" :activeTab.sync="activeTab" :tabs="tabs" />
  8. </a-radio-group>
  9. </div>
  10. <div class="float-right d-flex">
  11. <date-time :getParams.sync="dateParams" :canSelectTodayAfter="false" />
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import i18n from '@/locales'
  17. import { currencyUnitMap } from '@/constants/currency'
  18. const allTabs = {
  19. 'cpu-usage': {
  20. label: i18n.t('common.brand'),
  21. key: 'cpu-usage',
  22. index: 1,
  23. },
  24. 'network-recv': {
  25. label: i18n.t('common.resource_type'),
  26. key: 'network-recv',
  27. index: 2,
  28. },
  29. 'network-send': {
  30. label: i18n.t('common.resource'),
  31. key: 'network-send',
  32. index: 3,
  33. },
  34. 'disk-read': {
  35. label: i18n.t('dictionary.cloudaccount'),
  36. key: 'disk-read',
  37. index: 4,
  38. },
  39. 'disk-write': {
  40. label: i18n.t('dictionary.cloudprovider'),
  41. key: 'disk-write',
  42. index: 5,
  43. },
  44. }
  45. export default {
  46. name: 'KindTabs',
  47. components: {
  48. },
  49. props: {
  50. tabs: {
  51. type: Array,
  52. default: () => Object.values(allTabs),
  53. },
  54. platform: String,
  55. account: String,
  56. envParams: Object,
  57. currencySign: {
  58. type: String,
  59. default: currencyUnitMap.CNY.sign,
  60. },
  61. currencyParams: {
  62. type: Object,
  63. default: () => ({}),
  64. },
  65. },
  66. data () {
  67. return {
  68. activeTab: this.tabs[0].key,
  69. label: undefined,
  70. domain: undefined,
  71. labelLoading: false,
  72. loading: false,
  73. dateParams: {},
  74. }
  75. },
  76. computed: {
  77. tabsC () {
  78. return this.tabs.filter(val => {
  79. if (val.key === 'project') return false
  80. if (val.key === 'tag') return false
  81. if (!this.$store.getters.isAdminMode && val.key === 'domain') return false
  82. return true
  83. }).sort((a, b) => {
  84. return allTabs[a.key].index - allTabs[b.key].index
  85. })
  86. },
  87. },
  88. methods: {
  89. radioChange () {
  90. this.label = ''
  91. },
  92. loadChange (status) {
  93. this.labelLoading = status
  94. },
  95. },
  96. }
  97. </script>
  98. <style lang="less" scoped>
  99. .kind-tab-header {
  100. &::v-deep .ant-calendar-range-picker-input {
  101. width: 86px !important;
  102. }
  103. }
  104. </style>