Content.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="position-relative h-100 w-100 overflow-auto dashboard_box">
  3. <template v-for="(item, key) of data">
  4. <div
  5. v-if="!['Quota', 'ProjectQuota'].includes(item.layout.component) || (['Quota', 'ProjectQuota'].includes(item.layout.component) && globalConfig.enable_quota_check)"
  6. class="item"
  7. :key="key"
  8. :style="getItemStyles(item.layout)">
  9. <component
  10. ref="children"
  11. :chartId="key"
  12. :is="item.layout.component"
  13. :options="item.layout"
  14. :params="item.params"
  15. :dataRangeParams="dataRangeParams" />
  16. </div>
  17. </template>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapGetters } from 'vuex'
  22. import * as R from 'ramda'
  23. import getExtendsComponents from '@scope/extends'
  24. import { clear as clearCache } from '@Dashboard/utils/cache'
  25. const extendsComponents = R.is(Function, getExtendsComponents) ? getExtendsComponents() : getExtendsComponents
  26. export default {
  27. name: 'DashboardContent',
  28. components: {
  29. ...extendsComponents,
  30. },
  31. props: {
  32. // 卡片配置
  33. data: {
  34. type: [Array, Object],
  35. required: true,
  36. },
  37. dataRangeParams: {
  38. type: Object,
  39. },
  40. },
  41. computed: {
  42. ...mapGetters(['globalConfig']),
  43. },
  44. methods: {
  45. refresh () {
  46. clearCache()
  47. const children = this.$refs.children
  48. if (R.is(Array, children)) {
  49. for (let i = 0, len = children.length; i < len; i++) {
  50. children[i].refresh()
  51. }
  52. } else {
  53. children.refresh()
  54. }
  55. },
  56. setTransform (top, left, width, height) {
  57. const translate = `translate3d(${left}px, ${top}px, 0)`
  58. return {
  59. transform: translate,
  60. WebkitTransform: translate,
  61. MozTransform: translate,
  62. msTransform: translate,
  63. OTransform: translate,
  64. width: width + 'px',
  65. height: height + 'px',
  66. position: 'absolute',
  67. }
  68. },
  69. getItemStyles (layout) {
  70. const { x, y, w, h } = layout
  71. const rowHeight = 30
  72. const margin = [15, 7.5]
  73. return {
  74. width: `calc(${w / 80 * 100}% - 15px)`,
  75. margin: `0px ${margin[1]}px`,
  76. height: `calc(${rowHeight * h + Math.max(0, h - 1) * margin[0]}px)`,
  77. left: `calc(${(x / 80 * 100)}%`,
  78. top: Math.round(rowHeight * y) + (y + 1) * margin[0] + 'px',
  79. position: 'absolute',
  80. }
  81. },
  82. },
  83. }
  84. </script>
  85. <style lang="less" scoped>
  86. .dashboard_box{
  87. min-width: 1008px;
  88. background: rgb(245, 247, 254);
  89. }
  90. .item {
  91. border-radius: 5px;
  92. &:hover{
  93. box-shadow: 0px 0px 8px 3px #a3a0a02e;
  94. border: 0 none;
  95. }
  96. .dashboard-card-wrap{
  97. border-radius: 4px;
  98. }
  99. border: 1px solid #E7E8EB;
  100. }
  101. </style>