index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // 设计态点击不进行跳转,预览态进行跳转
  50. if (this.isPreview){
  51. if (this.config.customize.url) {
  52. if (this.config.customize.openType === 'dialog') {
  53. if (this.isPreview) {
  54. this.$refs.iframeDialogPreview.dialogVisible = true
  55. } else {
  56. this.changeIframeDialog(true)
  57. }
  58. } else {
  59. window.open(this.config.customize.url, this.config.customize.openType)
  60. }
  61. }
  62. }
  63. },
  64. dataFormatting (config, data) {
  65. // 文本数据配置原则:选择数据集则以后端返回的数据为主,否则以设置面板中标题设置为准
  66. if (config.dataSource.businessKey) {
  67. config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
  68. }
  69. return config
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .bs-design-wrap{
  76. width: 100%;
  77. display: flex;
  78. align-items: center;
  79. justify-content: center;
  80. }
  81. .content-box{
  82. //text-align: center;
  83. /* 将背景设为渐变 */
  84. /*background-image: -webkit-linear-gradient(left, #6294F7, #C85D14);*/
  85. /* 规定背景绘制区域 */
  86. -webkit-background-clip: text;
  87. /* 将文字隐藏 */
  88. -webkit-text-fill-color: transparent;
  89. }
  90. </style>