BigShow.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!--大屏显示组件-->
  2. <template>
  3. <div>
  4. <draggable
  5. :class="['split_screen', splitScreenStatus === 0 ? 'split_screen_one' : splitScreenStatus === 1 ? 'split_screen_four' : splitScreenStatus === 2 ? 'split_screen_nine' : 'split_screen_sixteen']"
  6. v-for="item in bigScreenJson"
  7. element="div"
  8. v-model="signalPreList"
  9. :options="dragOptions2"
  10. :move="onMove"
  11. @start="isDragging=true"
  12. @end="isDragging=false"
  13. :style="{
  14. width:item.Width + 'px',
  15. height:item.Height + 'px',
  16. left:item.Left+'px',
  17. top:item.Top+'px',
  18. zIndex:item.ZIndex,
  19. display:item.IsVisibility ? 'black' : 'none',
  20. }"
  21. >
  22. <div v-for="(item,key) in signalPreList" :key="key" class="item" ref="signal">
  23. {{item.showName}}
  24. </div>
  25. </draggable>
  26. </div>
  27. </template>
  28. <script>
  29. import {mapState} from 'vuex'
  30. import draggable from 'vuedraggable'
  31. import '../assets/less/splitscreen.less'
  32. import {getElementLeft, getElementTop} from "../../utils/tools"
  33. import {reqRefreshView} from "../api"
  34. export default {
  35. data() {
  36. return {
  37. isDragging: false, // 是否可拖动标志
  38. }
  39. },
  40. components: {
  41. draggable,
  42. },
  43. methods: {
  44. // 移动信号源
  45. onMove({relatedContext, draggedContext}) {
  46. const relatedElement = relatedContext.element
  47. const draggedElement = draggedContext.element
  48. return (
  49. (!relatedElement || !relatedElement.fixed) && !draggedElement.fixed
  50. )
  51. }
  52. },
  53. computed: {
  54. ...mapState(['bigScreenJson','splitScreenStatus']),
  55. signalPreList: {
  56. get() {
  57. return this.$store.state.signalPreList
  58. },
  59. set(arr) {
  60. // 流动屏数组
  61. const streamWindows = []
  62. setTimeout(() => {
  63. const elementArr = this.$refs.signal
  64. elementArr.forEach(async (item,index) => {
  65. // 获取元素绝对位置的横坐标和纵坐标
  66. const left = getElementLeft(item)
  67. const top = getElementTop(item)
  68. streamWindows.push({
  69. left,
  70. top,
  71. width:this.bigScreenJson[0].Width/(this.splitScreenStatus+1),
  72. height:this.bigScreenJson[0].Height/(this.splitScreenStatus+1),
  73. id:0,
  74. sourceId:arr[index].sourceId,
  75. widthScale:1/(this.splitScreenStatus+1),
  76. heightScale:1/(this.splitScreenStatus+1),
  77. orginRect:{}
  78. })
  79. console.log(streamWindows)
  80. const data = {
  81. bigScreenId:this.bigScreenJson[0].ID,
  82. streamWindows
  83. }
  84. // 调用大屏开窗接口
  85. const res = await reqRefreshView(data)
  86. console.log(res)
  87. })
  88. })
  89. this.$store.dispatch('updateSignalPreList',arr)
  90. }
  91. },
  92. dragOptions1() {
  93. return {
  94. animation: 0,
  95. group: {
  96. name: "description",
  97. pull: 'clone',
  98. put: false
  99. },
  100. ghostClass: "ghost",
  101. }
  102. },
  103. dragOptions2() {
  104. return {
  105. animation: 0,
  106. group: "description",
  107. }
  108. },
  109. }
  110. }
  111. </script>
  112. <style scoped>
  113. </style>