index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <full-link
  3. :device="device"
  4. :online="online"
  5. @click="onClick"
  6. >
  7. <el-dialog
  8. :visible.sync="showDetail"
  9. custom-class="c-dialog--detail"
  10. :title="title"
  11. :close-on-click-modal="false"
  12. >
  13. <component
  14. :is="activeComponent"
  15. v-if="showDetail"
  16. class="l-flex__auto"
  17. :device="device"
  18. />
  19. </el-dialog>
  20. </full-link>
  21. </template>
  22. <script>
  23. import { ThirdPartyDevice } from '@/constant'
  24. import SendingCard from './external/SendingCard'
  25. import ReceivingCard from './external/ReceivingCard'
  26. import TrafficCamera from './external/Camera/traffic.vue'
  27. import LedCamera from './external/Camera/led.vue'
  28. import Gateway from './external/Gateway'
  29. export default {
  30. name: 'DeviceExternal',
  31. components: {
  32. SendingCard,
  33. ReceivingCard,
  34. TrafficCamera,
  35. LedCamera,
  36. Gateway
  37. },
  38. props: {
  39. device: {
  40. type: Object,
  41. required: true
  42. },
  43. online: {
  44. type: [Boolean, String],
  45. default: false
  46. }
  47. },
  48. data () {
  49. return {
  50. showDetail: false,
  51. activeComponent: null,
  52. title: ''
  53. }
  54. },
  55. methods: {
  56. onClick ({ key, label }) {
  57. let activeComponent = null
  58. switch (key) {
  59. case ThirdPartyDevice.SENDING_CARD:
  60. activeComponent = 'SendingCard'
  61. break
  62. case ThirdPartyDevice.RECEIVING_CARD:
  63. activeComponent = 'ReceivingCard'
  64. break
  65. case ThirdPartyDevice.TRAFFIC_CAMERA:
  66. activeComponent = 'TrafficCamera'
  67. break
  68. case ThirdPartyDevice.LED_CAMERA:
  69. activeComponent = 'LedCamera'
  70. break
  71. case ThirdPartyDevice.GATEWAY:
  72. activeComponent = 'Gateway'
  73. break
  74. default:
  75. return
  76. }
  77. this.title = label
  78. this.activeComponent = activeComponent
  79. this.showDetail = true
  80. }
  81. }
  82. }
  83. </script>