index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div
  3. style="width: 100%;height: 100%"
  4. class="bs-design-wrap"
  5. >
  6. <dv-border-box-7
  7. :id="'dataV' + config.code"
  8. :key="updateKey"
  9. :background-color="(config.border.gradientColor&&(config.border.gradientColor[0]||config.border.gradientColor[1]))?`url(#${borderBgId})`:'transparent'"
  10. :color="borderColor"
  11. >
  12. <div
  13. v-if="config.border.isTitle"
  14. class="element"
  15. :style="`
  16. color:${color};
  17. font-size:${config.border.fontSize}px;
  18. line-height:${config.border.titleHeight}px;
  19. height:${config.border.titleHeight};
  20. padding:0 0 0 20px`"
  21. >
  22. {{ config.title }}
  23. </div>
  24. </dv-border-box-7>
  25. </div>
  26. </template>
  27. <script>
  28. import { refreshComponentMixin } from 'data-room-ui/js/mixins/refreshComponent'
  29. import DvBorderBox7 from '@jiaminghi/data-view/lib/components/borderBox7/src/main.vue'
  30. import '@jiaminghi/data-view/lib/components/borderBox7/src/main.css'
  31. export default {
  32. name: 'Border7',
  33. components: {
  34. DvBorderBox7
  35. },
  36. mixins: [refreshComponentMixin],
  37. props: {
  38. // 卡片的属性
  39. config: {
  40. type: Object,
  41. default: () => ({})
  42. }
  43. },
  44. data () {
  45. return {
  46. borderBgId: `borderBg${this.config.code}`
  47. }
  48. },
  49. computed: {
  50. borderColor () {
  51. return this.config.border.borderMainColor ||
  52. this.config.border.borderSecondaryColor
  53. ? [
  54. this.config.border.borderMainColor,
  55. this.config.border.borderSecondaryColor
  56. ]
  57. : null
  58. },
  59. color () {
  60. return this.config.border.fontColor ? this.config.border.fontColor
  61. : '#fff'
  62. }
  63. },
  64. watch: {
  65. updateKey: {
  66. handler (val) {
  67. this.$nextTick(() => {
  68. this.changeColor()
  69. })
  70. },
  71. deep: true
  72. },
  73. 'config.border.gradientColor': {
  74. handler (val) {
  75. this.changeColor()
  76. },
  77. immediate: true
  78. },
  79. 'config.border.gradientDirection': {
  80. handler (val) {
  81. this.changeColor()
  82. },
  83. immediate: true
  84. },
  85. 'config.border.opacity': {
  86. handler (val) {
  87. this.changeColor()
  88. },
  89. immediate: true
  90. }
  91. },
  92. mounted () {
  93. this.changeColor()
  94. },
  95. methods: {
  96. changeColor () {
  97. if (!this.config.border.opacity) {
  98. this.config.border.opacity = 100
  99. }
  100. if (!this.config.border.gradientColor) return
  101. if (document.querySelector(`#dataV${this.config.code}`)) {
  102. const borderElement = document.querySelector(`#dataV${this.config.code}`).querySelector('.border') || document.querySelector(`#dataV${this.config.code}`)?.querySelector('.dv-border-svg-container')
  103. if (borderElement) {
  104. borderElement.style.opacity = (this.config.border.opacity / 100)
  105. borderElement.style.background = `linear-gradient(${this.config.border.gradientDirection},${this.config.border.gradientColor[0] ? this.config.border.gradientColor[0] : this.config.border.gradientColor[1]}, ${this.config.border.gradientColor[1] ? this.config.border.gradientColor[1] : this.config.border.gradientColor[0]})`
  106. }
  107. }
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .bs-design-wrap {
  114. position: absolute;
  115. width: 100%;
  116. height: 100%;
  117. // padding: 0 16px;
  118. background-color: transparent;
  119. border-radius: 4px;
  120. box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1);
  121. box-sizing: border-box;
  122. }
  123. /*滚动条样式*/
  124. ::v-deep ::-webkit-scrollbar {
  125. width: 4px;
  126. border-radius: 4px;
  127. height: 4px;
  128. }
  129. ::v-deep ::-webkit-scrollbar-thumb {
  130. background: #dddddd !important;
  131. border-radius: 10px;
  132. }
  133. </style>