index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div
  3. class="bs-design-wrap"
  4. :class="`bs-chart-tab-${customTheme}`"
  5. >
  6. <div
  7. v-if="config.customize.tabList.length"
  8. class="tab-title-box"
  9. :style="{'justify-content':config.customize.position}"
  10. >
  11. <div
  12. v-for="(tab,index) in config.customize.tabList"
  13. :key="index"
  14. class="tab-title-item"
  15. :class="{active:currentIndex === index}"
  16. :style="
  17. 'font-size:' +
  18. config.customize.fontSize +
  19. 'px;color:' +
  20. config.customize.color +
  21. ';font-weight:' +
  22. config.customize.fontWeight
  23. "
  24. @click="changeTab(index)"
  25. >
  26. {{ tab.name }}
  27. </div>
  28. </div>
  29. <div
  30. v-if="config.customize.tabList &&config.customize.tabList.length"
  31. class="line-box"
  32. :style="{'background-color':config.customize.lineColor}"
  33. />
  34. <div
  35. v-if="config.customize.tabList &&config.customize.tabList.length"
  36. class="chart-item-box"
  37. >
  38. <!-- <Configuration-->
  39. <!-- :config="config.customize.tabList[currentIndex].chart"-->
  40. <!-- @openRightPanel="openRightPanel"-->
  41. <!-- >-->
  42. <div
  43. class="configuration-wrap"
  44. :class="{
  45. 'active': activeCodes.includes(config.customize.tabList[currentIndex].chartCode),
  46. 'hover': hoverCode === config.customize.tabList[currentIndex].chartCode
  47. }"
  48. @mouseenter.stop="changeHover(config.customize.tabList[currentIndex].chartCode)"
  49. @mouseleave="changeHover('')"
  50. @click.stop="changeActive(config.customize.tabList[currentIndex].chartCode)"
  51. >
  52. <RenderCardInner
  53. :ref="'RenderCard' + config.customize.tabList[currentIndex].chartCode"
  54. :config="config.customize.tabList[currentIndex].chart"
  55. @click.native="currentChartHandler"
  56. />
  57. </div>
  58. <!-- </Configuration>-->
  59. </div>
  60. <el-empty
  61. v-else-if="!config.customize.tabList.length"
  62. description="请在右侧面板选择图表加入"
  63. />
  64. </div>
  65. </template>
  66. <script>
  67. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  68. import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
  69. import cloneDeep from 'lodash/cloneDeep'
  70. import { mapMutations, mapState } from 'vuex'
  71. import RenderCardInner from 'data-room-ui/Render/RenderCard2.vue'
  72. import Configuration from 'data-room-ui/Render/Configuration.vue'
  73. import { EventBus } from 'data-room-ui/js/utils/eventBus'
  74. export default {
  75. name: 'ChartTab',
  76. components: { Configuration, RenderCardInner },
  77. mixins: [paramsMixins],
  78. props: {
  79. config: {
  80. type: Object,
  81. default: () => ({})
  82. }
  83. },
  84. computed: {
  85. ...mapState({
  86. pageCode: state => state.bigScreen.pageInfo.code,
  87. customTheme: state => state.bigScreen.pageInfo.pageConfig.customTheme,
  88. activeCode: state => state.bigScreen.activeCode,
  89. activeCodes: state => state.bigScreen.activeCodes,
  90. hoverCode: state => state.bigScreen.hoverCode,
  91. chartList: (state) => state.bigScreen.pageInfo.chartList
  92. })
  93. },
  94. data () {
  95. return {
  96. // currentChart: null
  97. currentIndex: 0
  98. }
  99. },
  100. mounted () {
  101. },
  102. // 销毁定时器
  103. destroyed () {
  104. if (this.timer) {
  105. clearInterval(this.timer) // 关闭
  106. }
  107. },
  108. methods: {
  109. ...mapMutations({
  110. changeChartConfig: 'bigScreen/changeChartConfig',
  111. changeActiveItemConfig: 'bigScreen/changeActiveItemConfig',
  112. changeActiveCode: 'bigScreen/changeActiveCode',
  113. changeHoverCode: 'bigScreen/changeHoverCode'
  114. }),
  115. changeStyle (config) {
  116. config = { ...this.config, ...config }
  117. // 样式改变时更新主题配置
  118. config.theme = settingToTheme(cloneDeep(config), this.customTheme)
  119. this.changeChartConfig(config)
  120. if (config.code === this.activeCode) {
  121. this.changeActiveItemConfig(config)
  122. }
  123. },
  124. // 切换tab页
  125. changeTab (index) {
  126. this.currentIndex = index
  127. },
  128. // 点击Tab中的某个组件
  129. currentChartHandler () {
  130. this.changeActiveCode(this.config.customize.tabList[this.currentIndex]?.chartCode)
  131. this.changeActiveItemConfig(this.config.customize.tabList[this.currentIndex]?.chart)
  132. },
  133. // 改变hover的组件
  134. changeHover (code) {
  135. this.changeHoverCode(code)
  136. },
  137. // 改变激活的组件
  138. changeActive (code) {
  139. this.changeActiveCode(code)
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .bs-design-wrap{
  146. width: 100%;
  147. .tab-title-box{
  148. height: 40px;
  149. display: flex;
  150. &:hover{
  151. cursor: pointer;
  152. }
  153. .tab-title-item{
  154. padding:10px;
  155. }
  156. }
  157. .chart-item-box{
  158. width: 100%;
  159. height: calc(100% - 40px);
  160. &:hover{
  161. cursor: pointer;
  162. }
  163. .configuration-wrap{
  164. width: 100%;
  165. height: calc(100% - 40px);
  166. }
  167. }
  168. .active{
  169. color: var(--bs-el-color-primary) !important;
  170. }
  171. .line-box{
  172. width: 98%;
  173. height: 1px;
  174. margin: 0 auto;
  175. //background-color: #d0d2d6;
  176. }
  177. }
  178. </style>