index.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div
  3. class="bs-design-wrap"
  4. :class="`bs-text-${customTheme}`"
  5. >
  6. <div
  7. class="content-box"
  8. :style="{'font-family': config.customize.fontFamily,'font-size': config.customize.fontSize +'px','font-weight': +config.customize.fontWeight,'background-image': `-webkit-linear-gradient(${config.customize.color})`}"
  9. >
  10. {{ config.customize.title }}
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  16. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  17. export default {
  18. name: 'Texts',
  19. components: {},
  20. mixins: [paramsMixins, commonMixins],
  21. props: {
  22. // 卡片的属性
  23. config: {
  24. type: Object,
  25. default: () => ({})
  26. }
  27. },
  28. data () {
  29. return {
  30. customClass: {}
  31. }
  32. },
  33. computed: {
  34. },
  35. mounted () {
  36. this.chartInit()
  37. },
  38. methods: {
  39. // 通过表达式计算得来的值
  40. getDataByExpression (config) {
  41. // 如果表达式是由其他组件的值构成的
  42. // const len = this.config.expressionCodes ? this.config.expressionCodes.length : 0
  43. // const len1 = this.currentComputedDatas ? Object.keys(this.currentComputedDatas).length : 0
  44. // const len2 = this.currentDataset ? Object.keys(this.currentDataset).length : 0
  45. // console.log('len', len, len1, len2)
  46. // if (len && len === len1 + len2) {
  47. // eslint-disable-next-line no-new-func
  48. const result = new Function('dataset', 'computedDatas', this.config.expression)
  49. config.customize.title = result(this.dataset, this.computedDatas)
  50. console.log(result(this.dataset, this.computedDatas))
  51. // 同时将计算得来的值保存到公共的数据存储的地方
  52. this.updateComputedDatas({ code: config.code, name: config.name, data: config.customize.title })
  53. // this.changeChartConfig(config)
  54. // }
  55. },
  56. dataFormatting (config, data) {
  57. // 文本数据配置原则:选择数据集则以后端返回的数据为主,否则以设置面板中标题设置为准
  58. if (config.dataSource.businessKey) {
  59. config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
  60. config.option.data = data && data.data && data.data.length ? data.data : []
  61. }
  62. return config
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. @import "../../assets/fonts/numberFont/stylesheet.css";
  69. .bs-design-wrap{
  70. width: 100%;
  71. display: flex;
  72. align-items: center;
  73. justify-content: center;
  74. }
  75. .content-box{
  76. //text-align: center;
  77. /* 将背景设为渐变 */
  78. /*background-image: -webkit-linear-gradient(left, #6294F7, #C85D14);*/
  79. /* 规定背景绘制区域 */
  80. -webkit-background-clip: text;
  81. /* 将文字隐藏 */
  82. -webkit-text-fill-color: transparent;
  83. }
  84. </style>