index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. borderWidth: 0,
  36. borderHeight: 0
  37. }
  38. },
  39. computed: {
  40. url () {
  41. return require('data-room-ui/BorderComponents/GcBorder16/component.png')
  42. },
  43. opacity () {
  44. return this.config.border.opacity || 100
  45. },
  46. borderImageArray () {
  47. const borderArr = this.config.border.borderArray ? this.config.border.borderArray
  48. : [10, 10, 10, 10]
  49. const arr = []
  50. arr[0] = borderArr[0] * this.borderHeight / 100
  51. arr[1] = borderArr[1] * this.borderWidth / 100
  52. arr[2] = borderArr[2] * this.borderHeight / 100
  53. arr[3] = borderArr[3] * this.borderWidth / 100
  54. return arr
  55. }
  56. },
  57. watch: {
  58. 'config.border.imgUrl': {
  59. handler (val) {
  60. if(val){
  61. let ur=val
  62. if(!val.startsWith('http')){
  63. ur = getFileUrl(val)
  64. }
  65. const a =document.getElementById('border'+ this.config.code)
  66. a.style['border-image-source']=`url(${ur})`
  67. }else{
  68. const a =document.getElementById('border'+ this.config.code)
  69. a.style['border-image-source']=`url(${this.url})`
  70. }
  71. }
  72. }
  73. },
  74. mounted () {
  75. // 获取边框大小
  76. const element = document.querySelector('.bs-design-wrap')
  77. this.borderWidth = element.offsetWidth
  78. this.borderHeight = element.offsetHeight
  79. if(this.config.border.imgUrl){
  80. let ur=this.config.border.imgUrl
  81. if(!this.config.border.imgUrl.startsWith('http')){
  82. ur = getFileUrl(this.config.border.imgUrl)
  83. }
  84. const a =document.getElementById('border'+ this.config.code)
  85. a.style['border-image-source']=`url(${ur})`
  86. }else{
  87. const a =document.getElementById('border'+ this.config.code)
  88. a.style['border-image-source']=`url(${this.url})`
  89. }
  90. },
  91. methods: {
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .bs-design-wrap {
  97. // border-image-source:url(component.png);
  98. width: 100%;
  99. height: 100%;
  100. position: absolute;
  101. }
  102. /*滚动条样式*/
  103. ::v-deep ::-webkit-scrollbar {
  104. width: 4px;
  105. border-radius: 4px;
  106. height: 4px;
  107. }
  108. ::v-deep ::-webkit-scrollbar-thumb {
  109. background: #dddddd !important;
  110. border-radius: 10px;
  111. }
  112. </style>