index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <full-link
  3. class="l-flex__fill"
  4. :device="device"
  5. :add-listener="addListener"
  6. :remove-listener="removeListener"
  7. @click="onClick"
  8. >
  9. <c-dialog
  10. ref="dialog"
  11. size="lg"
  12. :title="title"
  13. >
  14. <template #default>
  15. <component
  16. :is="activeComponent"
  17. class="l-flex__auto"
  18. :device="device"
  19. :info="receiver"
  20. />
  21. </template>
  22. </c-dialog>
  23. </full-link>
  24. </template>
  25. <script>
  26. import { ThirdPartyDevice } from '@/constant'
  27. import {
  28. addListener,
  29. removeListener
  30. } from '@/utils/adapter'
  31. import SendingCard from './components/SendingCard.vue'
  32. import ReceivingCard from './components/ReceivingCard'
  33. import LedCamera from './components/LED.vue'
  34. import TrafficCamera from './components/Traffic.vue'
  35. import Gateway from './components/Gateway.vue'
  36. export default {
  37. name: 'DeviceExternal',
  38. components: {
  39. SendingCard,
  40. ReceivingCard,
  41. TrafficCamera,
  42. LedCamera,
  43. Gateway
  44. },
  45. props: {
  46. device: {
  47. type: Object,
  48. required: true
  49. }
  50. },
  51. data () {
  52. return {
  53. title: '',
  54. activeComponent: null,
  55. receiver: null
  56. }
  57. },
  58. methods: {
  59. addListener (cb) {
  60. addListener(this.device.id, cb)
  61. },
  62. removeListener (cb) {
  63. removeListener(this.device.id, cb)
  64. },
  65. onClick ({ key, label }) {
  66. let activeComponent = null
  67. switch (key) {
  68. case ThirdPartyDevice.SENDING_CARD:
  69. activeComponent = 'SendingCard'
  70. break
  71. case ThirdPartyDevice.RECEIVING_CARD:
  72. activeComponent = 'ReceivingCard'
  73. break
  74. case ThirdPartyDevice.LED_CAMERA:
  75. activeComponent = 'LedCamera'
  76. break
  77. case ThirdPartyDevice.TRAFFIC_CAMERA:
  78. activeComponent = 'TrafficCamera'
  79. break
  80. case ThirdPartyDevice.GATEWAY:
  81. activeComponent = 'Gateway'
  82. break
  83. default:
  84. return
  85. }
  86. this.title = label
  87. this.activeComponent = activeComponent
  88. this.$refs.dialog.show()
  89. }
  90. }
  91. }
  92. </script>