index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <overview-card-layout :card_style="isTemplate ? 'no-border' : ''">
  3. <template #header>
  4. <div :class="{ 'position-hidden': isTemplate && !isTemplateEdit}">
  5. <filter-form
  6. ref="filterForm"
  7. :is-template="isTemplate"
  8. :is-template-edit="isTemplateEdit"
  9. :template-params="templateParams"
  10. :scopeParams="scopeParams"
  11. @updateTable="handleUpdateTable"
  12. @updateChart="handleUpdateChart"
  13. @changeNav="handleChangeNav"
  14. @dataLoading="handleOnDataLoading"
  15. @showTable="handleShowTable"
  16. @changeLimit="handleChangeLimit"
  17. @updateFucType="handleUpdateFucType"
  18. :scope="scope"
  19. :extraParams="extraParams" />
  20. </div>
  21. </template>
  22. <component v-if="chart.chartType && limit && !isTemplate" :is="chart.chartType" :chartData="chart.chartData" :yAxisFormat="chart.metric.format" :loading="chart.loading || tableLoading" id="monitor-overview-resource" :exportName="exportName" />
  23. <template #footer>
  24. <overview-table :table-data="table" :loading="tableLoading" v-if="showTable" :is-template="isTemplate" :fuc-type="fucType" />
  25. </template>
  26. </overview-card-layout>
  27. </template>
  28. <script>
  29. import OverviewCardLayout from '../layout'
  30. import OverviewLine from '../sections/chart/line'
  31. import OverviewHistogram from '../sections/chart/histogram'
  32. import OverviewRing from '../sections/chart/ring'
  33. import OverviewTable from '../sections/table'
  34. import filterForm from './filterForm'
  35. export default {
  36. name: 'index',
  37. components: {
  38. OverviewCardLayout,
  39. filterForm,
  40. OverviewLine,
  41. OverviewHistogram,
  42. OverviewRing,
  43. OverviewTable,
  44. },
  45. props: {
  46. scope: {
  47. type: String,
  48. required: true,
  49. },
  50. extraParams: {
  51. type: Object,
  52. required: false,
  53. default: () => ({}),
  54. },
  55. isTemplate: {
  56. type: Boolean,
  57. default: false,
  58. },
  59. isTemplateEdit: {
  60. type: Boolean,
  61. default: false,
  62. },
  63. templateParams: {
  64. type: Object,
  65. default: () => ({}),
  66. },
  67. scopeParams: {
  68. type: Object,
  69. default: () => ({}),
  70. },
  71. },
  72. data () {
  73. return {
  74. chart: { loading: true },
  75. table: {},
  76. showTable: false,
  77. tableLoading: false,
  78. limit: this.templateParams?.limit || 10,
  79. fucType: this.templateParams?.fucType || [],
  80. }
  81. },
  82. computed: {
  83. exportName () {
  84. return this.chart.metric?.label || 'Export'
  85. },
  86. },
  87. methods: {
  88. handleShowTable (v) {
  89. this.showTable = v
  90. },
  91. handleOnDataLoading (v) {
  92. this.tableLoading = v
  93. },
  94. handleUpdateTable (v) {
  95. this.table = v
  96. },
  97. handleUpdateChart (v) {
  98. this.chart = v
  99. },
  100. handleChangeNav (v) {
  101. this.$emit('changeNav', v)
  102. },
  103. handleChangeLimit (v) {
  104. this.limit = v || 0
  105. },
  106. handleUpdateFucType (v) {
  107. this.fucType = v || []
  108. },
  109. // 导出作为报表模板时参数
  110. getTemplateParams () {
  111. return {
  112. fucType: this.fucType,
  113. measurement: this.metric?.measurement || this.chart?.metric?.measurement,
  114. field: this.metric?.field || this.chart?.metric?.field,
  115. limit: this.limit,
  116. from: this.$refs.filterForm.from,
  117. }
  118. },
  119. },
  120. }
  121. </script>
  122. <style lang="less" scoped>
  123. .position-hidden {
  124. position: absolute;
  125. top: 0;
  126. left: 0;
  127. width: 100%;
  128. height: 100%;
  129. z-index: -1;
  130. }
  131. </style>