index.vue 5.0 KB

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