| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <full-link
- class="l-flex__fill"
- :device="device"
- :add-listener="addListener"
- :remove-listener="removeListener"
- @click="onClick"
- >
- <c-dialog
- ref="dialog"
- size="lg"
- :title="title"
- >
- <template #default>
- <component
- :is="activeComponent"
- class="l-flex__auto"
- :device="device"
- :info="receiver"
- />
- </template>
- </c-dialog>
- </full-link>
- </template>
- <script>
- import { ThirdPartyDevice } from '@/constant'
- import {
- addListener,
- removeListener
- } from '@/utils/adapter'
- import SendingCard from './components/SendingCard.vue'
- import ReceivingCard from './components/ReceivingCard'
- import LedCamera from './components/LED.vue'
- import TrafficCamera from './components/Traffic.vue'
- import Gateway from './components/Gateway.vue'
- export default {
- name: 'DeviceExternal',
- components: {
- SendingCard,
- ReceivingCard,
- TrafficCamera,
- LedCamera,
- Gateway
- },
- props: {
- device: {
- type: Object,
- required: true
- }
- },
- data () {
- return {
- title: '',
- activeComponent: null,
- receiver: null
- }
- },
- methods: {
- addListener (cb) {
- addListener(this.device.id, cb)
- },
- removeListener (cb) {
- removeListener(this.device.id, cb)
- },
- onClick ({ key, label }) {
- let activeComponent = null
- switch (key) {
- case ThirdPartyDevice.SENDING_CARD:
- activeComponent = 'SendingCard'
- break
- case ThirdPartyDevice.RECEIVING_CARD:
- activeComponent = 'ReceivingCard'
- break
- case ThirdPartyDevice.LED_CAMERA:
- activeComponent = 'LedCamera'
- break
- case ThirdPartyDevice.TRAFFIC_CAMERA:
- activeComponent = 'TrafficCamera'
- break
- case ThirdPartyDevice.GATEWAY:
- activeComponent = 'Gateway'
- break
- default:
- return
- }
- this.title = label
- this.activeComponent = activeComponent
- this.$refs.dialog.show()
- }
- }
- }
- </script>
|