Button.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <!--button按钮组件-->
  2. <template>
  3. <div>
  4. <div v-for="item in buttonJson"
  5. :style="{
  6. position:'absolute',
  7. left:item.Left*Scale+'px',
  8. top:item.Top*Scale+'px',
  9. width:item.Width*Scale + 'px',
  10. height:item.Height*Scale + 'px',
  11. zIndex:item.ZIndex,
  12. display:item.IsVisibility ? 'block' : 'none',
  13. fontSize:item.FontSize*Scale + 'px',
  14. backgroundImage:'url('+require(`../../../static/images/${item.BackIcon}`)+')',
  15. backgroundSize:'100% 100%',
  16. backgroundRepeat:'no-repeat',
  17. color:`#${item.ForegroundStr.slice(3)}`,
  18. textAlign:'center',
  19. lineHeight:item.Height*Scale + 'px',
  20. cursor:'default'
  21. }"
  22. :ref="item.ID"
  23. @click="clickBtn(item)"
  24. @mousedown="mouseDown(item)"
  25. @mouseup="mouseUp(item)"
  26. >
  27. {{item.Text}}
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import {mapState} from 'vuex'
  33. export default {
  34. data() {
  35. return {
  36. count: 0, // 音量计数器
  37. count2: 0, // 预案管理模块计数器
  38. count3: 0, // 管理控制按钮计数器
  39. count4: 0, // 3个视频按钮计数器
  40. count5: 0, // 安卓分布式按钮
  41. }
  42. },
  43. mounted() {
  44. // 获取分屏按钮数组(将分屏按钮和其他按钮区分开)
  45. this.arr = this.buttonJson.filter(item => (item.WindowID === '9a0dff23-8633-4e7f-89bf-cc4f68ec88e1' || item.WindowID === '08208721-41cc-4f1e-937b-3a1627389049' || item.WindowID === 'ab842585-0c91-4e65-bfed-a219bcaaeb43'))
  46. // 获取功能按钮涉及到的按钮和label
  47. // 1.电源管理 2.音频管理 3.视频管理 4.环境控制 5.电脑控制
  48. const funcBtnArr = this.buttonJson.filter(item => (item.WindowID === 'd80a8b6e-9f88-41ff-b3a7-1ff8d6ee37a5' || item.WindowID === 'cb2687fd-931a-4b38-a76d-9c3ea171b8d8' || item.WindowID === '027ab76d-6b9c-46ac-abe6-75b8059f786b' || item.WindowID === 'a12b287f-f68c-4efa-b652-d6e5b0a09d0d' || item.WindowID === 'd9868551-b579-4258-9bc7-7c1f733773f5'))
  49. const funcLabArr = this.labelJson.filter(item => (item.WindowID === 'd80a8b6e-9f88-41ff-b3a7-1ff8d6ee37a5' || item.WindowID === 'cb2687fd-931a-4b38-a76d-9c3ea171b8d8' || item.WindowID === '027ab76d-6b9c-46ac-abe6-75b8059f786b' || item.WindowID === 'a12b287f-f68c-4efa-b652-d6e5b0a09d0d' || item.WindowID === 'd9868551-b579-4258-9bc7-7c1f733773f5'))
  50. this.funcObj = {
  51. funcBtnArr,
  52. funcLabArr,
  53. funSliderArr:this.sliderJson
  54. }
  55. // 获取电源管理和电脑控制按钮
  56. this.powerAndCompBtns = this.buttonJson.filter(item => (item.WindowID === 'd80a8b6e-9f88-41ff-b3a7-1ff8d6ee37a5' || item.WindowID === 'd9868551-b579-4258-9bc7-7c1f733773f5') && item.ID !== '19554440-98bc-4644-83a0-d9cefd69153e')
  57. },
  58. computed: {
  59. ...mapState(['buttonJson','labelJson','sliderJson','Scale']),
  60. },
  61. methods: {
  62. // 点击按钮
  63. clickBtn(e) {
  64. // console.log(e)
  65. // 预案管理声音开关
  66. if (e.ID === '355d3c32-1502-40b4-9ddd-663d5b8469e7') {
  67. if (this.count % 2 === 0) {
  68. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  69. ++this.count
  70. } else {
  71. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
  72. ++this.count
  73. }
  74. return
  75. }
  76. // 切换屏幕
  77. if (e.Text === 'LCD屏' || e.Text === 'LED屏' || e.Text === '投影机') {
  78. if (this.count4 === 0) {
  79. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  80. ++this.count4
  81. } else if(e !== this.lastData4) {
  82. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  83. this.lastBtn4.style.backgroundImage = 'url(' + require(`../../../static/images/${this.lastData4.BackIcon}`) + ')'
  84. }
  85. // 保存点过的这个按钮和按钮数据
  86. this.lastBtn4 = this.$refs[e.ID][0]
  87. this.lastData4 = e
  88. // 首先清屏
  89. this.$store.dispatch('clearScreen')
  90. this.arr.forEach(item => {
  91. if (e.MouseDownActionList[0].SourceID === item.WindowID) {
  92. item.IsVisibility = true
  93. } else {
  94. item.IsVisibility = false
  95. }
  96. })
  97. return
  98. }
  99. // 预案管理按钮处理
  100. if (e.Name.includes('V0') && e.Name.slice(7) * 1 > 62 && e.Name.slice(7) * 1 < 72) {
  101. if (this.count2 === 0) {
  102. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  103. ++this.count2
  104. } else if(e !== this.lastData) {
  105. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  106. this.lastBtn.style.backgroundImage = 'url(' + require(`../../../static/images/${this.lastData.BackIcon}`) + ')'
  107. }
  108. // 保存点过的按钮和按钮数据
  109. this.lastBtn = this.$refs[e.ID][0]
  110. this.lastData = e
  111. return
  112. }
  113. // 5个管理控制按钮处理
  114. if (e.Name.includes('V0--Btn6') || e.Name.includes('V0--Btn61') || e.Name.includes('V0--Btn12') || e.Name.includes('V0--Btn58') || e.Name.includes('V0--Btn77')) {
  115. // (1)背景切换
  116. if (this.count3 === 0) {
  117. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  118. ++this.count3
  119. } else if(e !== this.lastData3) {
  120. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  121. this.lastBtn3.style.backgroundImage = 'url(' + require(`../../../static/images/${this.lastData3.BackIcon}`) + ')'
  122. }
  123. // 保存点过的这个按钮和按钮数据
  124. this.lastBtn3 = this.$refs[e.ID][0]
  125. this.lastData3 = e
  126. // (2)界面切换
  127. // 按钮
  128. this.funcObj.funcBtnArr.forEach((item, index) => {
  129. if (e.MouseDownActionList[0].SourceID === item.WindowID) {
  130. item.IsVisibility = true
  131. } else {
  132. item.IsVisibility = false
  133. }
  134. })
  135. // 标签
  136. this.funcObj.funcLabArr.forEach((item, index) => {
  137. if (e.MouseDownActionList[0].SourceID === item.WindowID) {
  138. item.IsVisibility = true
  139. } else {
  140. item.IsVisibility = false
  141. }
  142. })
  143. // 滑块
  144. this.funcObj.funSliderArr.forEach((item, index) => {
  145. if (e.MouseDownActionList[0].SourceID === item.WindowID) {
  146. item.IsVisibility = true
  147. } else {
  148. item.IsVisibility = false
  149. }
  150. })
  151. return
  152. }
  153. // 分屏和清屏操作
  154. if (e.ID === '7775e508-c6a5-4044-8264-24772a24fa97' || e.ID === '95c5d676-46a5-4c46-b550-9bc013a59937' || e.ID === 'f47e84bb-c878-4b22-a9d6-eb2e307283bc') {
  155. // 清屏
  156. this.$store.dispatch('clearScreen')
  157. return
  158. } else if (e.ID === '49653a62-99cb-40e1-a513-60e42893adb7' || e.ID === 'd55c81a8-54d7-4d90-aad7-4f34c3ba3950' || e.ID === '4142ab5b-ce52-4655-a28d-724bfabb24f0') {
  159. // 自由屏
  160. this.$store.dispatch('splitScreen',0)
  161. return
  162. } else if (e.ID === '52de9a2e-d171-423d-860f-3fe2750ec757' || e.ID === '0cabb1ba-bcae-45d9-b019-2b45486f98e3' || e.ID === '9bb5b3e3-9e21-4716-8059-f5b35b24e3fa') {
  163. // 四分屏
  164. this.$store.dispatch('splitScreen',1)
  165. return
  166. } else if (e.ID === 'ac0cc31c-a9b8-4bdf-88cf-928964b93ac5' || e.ID === '201e4bb0-c039-46c7-a55a-049d00de4769') {
  167. // 九分屏
  168. this.$store.dispatch('splitScreen',2)
  169. return
  170. } else if (e.ID === '2d4c49bc-905b-4f96-a65c-9b0a3e057b3f') {
  171. // 16分屏
  172. this.$store.dispatch('splitScreen',3)
  173. return
  174. }
  175. // 安卓和分布式按钮
  176. if (e.Text === '安卓' || e.Text === '分布式') {
  177. if (this.count5 === 0) {
  178. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  179. ++this.count5
  180. } else if(e !== this.lastData5){
  181. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  182. this.lastBtn5.style.backgroundImage = 'url(' + require(`../../../static/images/${this.lastData5.BackIcon}`) + ')'
  183. }
  184. // 保存点过的这个按钮和按钮数据
  185. this.lastBtn5 = this.$refs[e.ID][0]
  186. this.lastData5 = e
  187. return
  188. }
  189. // 电源管理和电脑管理
  190. if(this.powerAndCompBtns.some(item => item.ID === e.ID)){
  191. if(e.ActionType === 2){
  192. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  193. e.ActionType = -2
  194. }else {
  195. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
  196. e.ActionType = 2
  197. }
  198. }
  199. return
  200. },
  201. // 鼠标按下事件
  202. mouseDown(e) {
  203. if (this.arr.some(item => e === item) && e.Text !== '安卓' && e.Text !== '分布式') { // 分屏控制按钮
  204. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  205. }else if(e.WindowID === '027ab76d-6b9c-46ac-abe6-75b8059f786b') { // 视频控制按钮
  206. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  207. }else if(e.WindowID === 'a12b287f-f68c-4efa-b652-d6e5b0a09d0d') { // 环境控制按钮
  208. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  209. }else if(e.ID === '19554440-98bc-4644-83a0-d9cefd69153e'){ // 电脑控制All按钮
  210. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
  211. }
  212. return
  213. },
  214. // 鼠标松开事件
  215. mouseUp(e) {
  216. if (this.arr.some(item => e === item) && e.Text !== '安卓' && e.Text !== '分布式') { // 分屏控制按钮
  217. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
  218. }else if(e.WindowID === '027ab76d-6b9c-46ac-abe6-75b8059f786b') { // 视频控制按钮
  219. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
  220. }else if(e.WindowID === 'a12b287f-f68c-4efa-b652-d6e5b0a09d0d') { // 环境控制按钮
  221. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
  222. }if(e.ID === '19554440-98bc-4644-83a0-d9cefd69153e'){ // 电脑控制All按钮
  223. this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
  224. }
  225. return
  226. },
  227. }
  228. }
  229. </script>
  230. <style scoped>
  231. </style>