index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div
  3. style="width: 100%;height: 100%;object-fit: cover"
  4. class="bs-design-wrap"
  5. :id="'border'+ config.code"
  6. :style="{
  7. opacity: opacity,
  8. borderImageSlice:`${borderImageArray[0]} ${borderImageArray[1]} ${borderImageArray[2]} ${borderImageArray[3]} fill`,
  9. borderImageWidth:`${borderImageArray[0]}px ${borderImageArray[1]}px ${borderImageArray[2]}px ${borderImageArray[3]}px`,
  10. }"
  11. >
  12. </div>
  13. </template>
  14. <script>
  15. import { refreshComponentMixin } from 'data-room-ui/js/mixins/refreshComponent'
  16. import { getFileUrl } from 'data-room-ui/js/utils/file'
  17. export default {
  18. name: 'Border14',
  19. components: {
  20. },
  21. mixins: [refreshComponentMixin],
  22. props: {
  23. id:{
  24. type: String,
  25. default: 'name'
  26. },
  27. // 卡片的属性
  28. config: {
  29. type: Object,
  30. default: () => ({})
  31. }
  32. },
  33. data () {
  34. return {
  35. }
  36. },
  37. computed: {
  38. url () {
  39. return require('data-room-ui/BorderComponents/GcBorder16/component.png')
  40. },
  41. opacity () {
  42. return this.config.border.opacity || 100
  43. },
  44. borderImageArray () {
  45. const borderArr = this.config.border.borderArray ? this.config.border.borderArray
  46. : [10, 10, 10, 10]
  47. const arr = []
  48. arr[0] = borderArr[0] * 3.2
  49. arr[1] = borderArr[1] * 4.5
  50. arr[2] = borderArr[2] * 3.2
  51. arr[3] = borderArr[3] * 4.5
  52. return arr
  53. }
  54. },
  55. watch: {
  56. 'config.border.imgUrl': {
  57. handler (val) {
  58. if(val){
  59. let ur=val
  60. if(!val.startsWith('http')){
  61. ur = getFileUrl(val)
  62. }
  63. const a =document.getElementById('border'+ this.config.code)
  64. a.style['border-image-source']=`url(${ur})`
  65. }else{
  66. const a =document.getElementById('border'+ this.config.code)
  67. a.style['border-image-source']=`url(${this.url})`
  68. }
  69. }
  70. }
  71. },
  72. mounted () {
  73. if(this.config.border.imgUrl){
  74. let ur=this.config.border.imgUrl
  75. if(!this.config.border.imgUrl.startsWith('http')){
  76. ur = getFileUrl(this.config.border.imgUrl)
  77. }
  78. const a =document.getElementById('border'+ this.config.code)
  79. a.style['border-image-source']=`url(${ur})`
  80. }else{
  81. const a =document.getElementById('border'+ this.config.code)
  82. a.style['border-image-source']=`url(${this.url})`
  83. }
  84. },
  85. methods: {
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .bs-design-wrap {
  91. // border-image-source:url(component.png);
  92. width: 100%;
  93. height: 100%;
  94. position: absolute;
  95. }
  96. /*滚动条样式*/
  97. ::v-deep ::-webkit-scrollbar {
  98. width: 4px;
  99. border-radius: 4px;
  100. height: 4px;
  101. }
  102. ::v-deep ::-webkit-scrollbar-thumb {
  103. background: #dddddd !important;
  104. border-radius: 10px;
  105. }
  106. </style>