index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div
  3. class="bs-design-wrap"
  4. :class="`bs-text-${customTheme}`"
  5. @click="linkHandle"
  6. >
  7. <div
  8. class="content-box"
  9. :style="{'font-size': config.customize.fontSize +'px','font-weight': +config.customize.fontWeight,'background-image': `-webkit-linear-gradient(${config.customize.color})`}"
  10. >
  11. {{ config.customize.title }}
  12. </div>
  13. <iframeDialogPreview
  14. v-if="isPreview"
  15. ref="iframeDialogPreview"
  16. :config="config"
  17. />
  18. </div>
  19. </template>
  20. <script>
  21. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  22. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  23. import { mapMutations } from 'vuex'
  24. import iframeDialogPreview from './iframeDialogPreview'
  25. export default {
  26. name: 'LinkChart',
  27. components: { iframeDialogPreview },
  28. mixins: [paramsMixins, commonMixins],
  29. props: {
  30. // 卡片的属性
  31. config: {
  32. type: Object,
  33. default: () => ({})
  34. }
  35. },
  36. data () {
  37. return {
  38. customClass: {}
  39. }
  40. },
  41. watch: {
  42. },
  43. mounted () {
  44. this.chartInit()
  45. },
  46. methods: {
  47. ...mapMutations('bigScreen', ['changeIframeDialog']),
  48. linkHandle () {
  49. if (this.config.customize.url) {
  50. if (this.config.customize.openType === 'dialog') {
  51. if (this.isPreview) {
  52. this.$refs.iframeDialogPreview.dialogVisible = true
  53. } else {
  54. this.changeIframeDialog(true)
  55. }
  56. } else {
  57. window.open(this.config.customize.url, this.config.customize.openType)
  58. }
  59. }
  60. },
  61. dataFormatting (config, data) {
  62. // 文本数据配置原则:选择数据集则以后端返回的数据为主,否则以设置面板中标题设置为准
  63. if (config.dataSource.businessKey) {
  64. config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
  65. }
  66. return config
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .bs-design-wrap{
  73. width: 100%;
  74. padding: 0 16px;
  75. }
  76. .content-box{
  77. text-align: center;
  78. /* 将背景设为渐变 */
  79. /*background-image: -webkit-linear-gradient(left, #6294F7, #C85D14);*/
  80. /* 规定背景绘制区域 */
  81. -webkit-background-clip: text;
  82. /* 将文字隐藏 */
  83. -webkit-text-fill-color: transparent;
  84. }
  85. </style>