|
|
@@ -31,10 +31,11 @@
|
|
|
:device="led"
|
|
|
autoplay
|
|
|
retry
|
|
|
+ keep
|
|
|
/>
|
|
|
<i
|
|
|
- class="o-link-item__warning"
|
|
|
- :class="led.status"
|
|
|
+ v-if="led.powerOff"
|
|
|
+ class="o-link-item__off"
|
|
|
/>
|
|
|
</template>
|
|
|
</div>
|
|
|
@@ -52,6 +53,12 @@
|
|
|
|
|
|
<script>
|
|
|
import { ThirdPartyDevice } from '@/constant'
|
|
|
+import {
|
|
|
+ Power,
|
|
|
+ Status,
|
|
|
+ transformToPowers,
|
|
|
+ parsePowerSwitchStatus
|
|
|
+} from '@/utils/adapter/nova'
|
|
|
import { getThirdPartyDevicesByThirdPartyDevice } from '@/api/mesh'
|
|
|
import { getStatusReport } from '@/api/device'
|
|
|
|
|
|
@@ -114,7 +121,8 @@ const LineFromeTo = {
|
|
|
3: [ThirdPartyDevice.SENDING_CARD, { key: ThirdPartyDevice.RECEIVING_CARD, enable: 1 }],
|
|
|
4: [ThirdPartyDevice.RECEIVING_CARD, { key: 'led', enable: 1 }],
|
|
|
5: ['msr', { key: ThirdPartyDevice.GATEWAY, enable: 1 }],
|
|
|
- 6: ['msr', { key: ThirdPartyDevice.LED_CAMERA, enable: 1 }, { key: ThirdPartyDevice.TRAFFIC_CAMERA, enable: 1 }],
|
|
|
+ 6: ['msr', { key: ThirdPartyDevice.LED_CAMERA, enable: 1 }],
|
|
|
+ 15: ['msr', { key: ThirdPartyDevice.TRAFFIC_CAMERA, enable: 1 }],
|
|
|
7: ['msr', { key: ThirdPartyDevice.TRAFFIC_CAMERA, enable: 1 }],
|
|
|
8: ['msr', { key: ThirdPartyDevice.TRAFFIC_CAMERA, enable: 1 }],
|
|
|
9: ['msr', { key: ThirdPartyDevice.LED_CAMERA, enable: 1 }],
|
|
|
@@ -175,38 +183,37 @@ export default {
|
|
|
return {
|
|
|
key, label, status, canClick,
|
|
|
className: [
|
|
|
- status === -2
|
|
|
+ status === Status.NONE
|
|
|
? 'u-hidden'
|
|
|
- : status === -1
|
|
|
+ : status === Status.LOADING
|
|
|
? 'loading'
|
|
|
- : status === 0
|
|
|
+ : status === Status.ERROR
|
|
|
? 'tip el-icon-error u-color--error'
|
|
|
- : status === 1
|
|
|
+ : status === Status.OK
|
|
|
? ''
|
|
|
: 'tip el-icon-warning u-color--warning',
|
|
|
alias || key,
|
|
|
- canClick && status !== -2 ? 'u-pointer' : ''
|
|
|
+ canClick && status !== Status.NONE ? 'u-pointer' : ''
|
|
|
].join(' ')
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
lines () {
|
|
|
- console.log('line', this.linkDeviceMap)
|
|
|
const state = this.linkState
|
|
|
return Object.keys(LineFromeTo).map(key => {
|
|
|
const from = LineFromeTo[key][0]
|
|
|
const to = LineFromeTo[key].slice(1)
|
|
|
- const enable = state[from] != null && state[from] > -2 && to.some(
|
|
|
- ({ key, enable }) => enable && state[key] != null && state[key] > -2
|
|
|
+ const enable = state[from] > Status.NONE && !to.some(
|
|
|
+ ({ key, enable }) => enable && state[key] === Status.NONE
|
|
|
) && !to.some(
|
|
|
- ({ key, enable }) => !enable && state[key] != null && state[key] > -2
|
|
|
+ ({ key, enable }) => !enable && state[key] > Status.NONE
|
|
|
)
|
|
|
return {
|
|
|
key: `line${key}`,
|
|
|
className: [
|
|
|
`l${key}`,
|
|
|
enable
|
|
|
- ? state[from] > 0 && to.some(({ key, enable }) => enable && state[key] > 0)
|
|
|
+ ? this.hasLink(state[from]) && !to.some(({ key, enable }) => enable && !this.hasLink(state[key]))
|
|
|
? 'linked'
|
|
|
: ''
|
|
|
: 'u-hidden'
|
|
|
@@ -239,17 +246,25 @@ export default {
|
|
|
clearInterval(this.$timer)
|
|
|
},
|
|
|
methods: {
|
|
|
+ hasLink (status) {
|
|
|
+ return status > Status.LOADING && status !== Status.ERROR
|
|
|
+ },
|
|
|
onMessage (value) {
|
|
|
- console.log('power', value)
|
|
|
- this.$powerStatus = value[ThirdPartyDevice.MULTI_FUNCTION_CARD]
|
|
|
- if (this.linkDeviceMap && this.$powerStatus.length) {
|
|
|
- const switchStatus = this.$powerStatus[0].switchStatus
|
|
|
- this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] = switchStatus === 255 ? 0 : 1
|
|
|
- this.led.status = switchStatus === 255 ? 'off' : switchStatus === 0 ? 'on' : 'half'
|
|
|
+ console.log('full link', value)
|
|
|
+ this.$receiverStatus = value[ThirdPartyDevice.RECEIVING_CARD].status
|
|
|
+ const powerStatus = value[ThirdPartyDevice.MULTI_FUNCTION_CARD]
|
|
|
+ if (powerStatus.length && powerStatus.switchStatus > Status.LOADING) {
|
|
|
+ this.$powerStatus = powerStatus
|
|
|
}
|
|
|
- this.$receiverStatus = value[ThirdPartyDevice.RECEIVING_CARD]?.status
|
|
|
- if (this.linkDeviceMap && this.$receiverStatus >= 0) {
|
|
|
- this.linkDeviceMap[ThirdPartyDevice.RECEIVING_CARD] = this.$receiverStatus
|
|
|
+ if (this.linkDeviceMap) {
|
|
|
+ if (this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] > Status.NONE && powerStatus.length) {
|
|
|
+ const switchStatus = powerStatus[0].switchStatus
|
|
|
+ this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] = switchStatus === Power.ON ? Status.OK : switchStatus === Power.OFF ? Status.ERROR : Status.WARNING
|
|
|
+ }
|
|
|
+ if (this.linkDeviceMap[ThirdPartyDevice.RECEIVING_CARD] > Status.NONE && this.$receiverStatus >= Status.OK) {
|
|
|
+ this.linkDeviceMap[ThirdPartyDevice.RECEIVING_CARD] = this.$receiverStatus
|
|
|
+ }
|
|
|
+ this.onUpdateLed()
|
|
|
}
|
|
|
},
|
|
|
checkScale () {
|
|
|
@@ -281,61 +296,57 @@ export default {
|
|
|
ThirdPartyDevice.BOX,
|
|
|
ThirdPartyDevice.MULTI_FUNCTION_CARD
|
|
|
], { custom: true }),
|
|
|
- this.$powerStatus
|
|
|
- ? Promise.resolve({ data: this.$powerStatus })
|
|
|
- : getStatusReport([this.targetId])
|
|
|
+ getStatusReport([this.targetId])
|
|
|
]).then(([{ data: nodes }, { data }]) => {
|
|
|
this.$deviceTypes = []
|
|
|
- const map = {
|
|
|
- msr: 1,
|
|
|
- led: 0,
|
|
|
- [ThirdPartyDevice.BOX]: -2,
|
|
|
- [ThirdPartyDevice.GATEWAY]: -2,
|
|
|
- [ThirdPartyDevice.LED_CAMERA]: -2,
|
|
|
- [ThirdPartyDevice.TRAFFIC_CAMERA]: -2,
|
|
|
- [ThirdPartyDevice.SENDING_CARD]: -2,
|
|
|
- [ThirdPartyDevice.RECEIVING_CARD]: -2,
|
|
|
- [ThirdPartyDevice.MULTI_FUNCTION_CARD]: -2
|
|
|
- }
|
|
|
+ const linkDeviceMap = {}
|
|
|
const by = [ThirdPartyDevice.BOX]
|
|
|
- let statusKey = ''
|
|
|
nodes.forEach(({ nodeType, instance }) => {
|
|
|
if (nodeType === ThirdPartyDevice.RECEIVING_CARD) {
|
|
|
- // 需对接接收卡
|
|
|
- map[nodeType] = this.$receiverStatus ?? -1
|
|
|
- by.push(ThirdPartyDevice.RECEIVING_CARD)
|
|
|
+ linkDeviceMap[nodeType] = this.$receiverStatus ?? Status.LOADING
|
|
|
+ by.push(nodeType)
|
|
|
} else if (nodeType === ThirdPartyDevice.MULTI_FUNCTION_CARD) {
|
|
|
if (instance) {
|
|
|
- by.push(ThirdPartyDevice.MULTI_FUNCTION_CARD)
|
|
|
- if (data[0] && data[0].switchStatus >= 0) {
|
|
|
- map[ThirdPartyDevice.MULTI_FUNCTION_CARD] = data[0].switchStatus === 255 ? 0 : 1
|
|
|
- statusKey = data[0].switchStatus === 255 ? 'off' : data[0].switchStatus === 0 ? 'on' : 'half'
|
|
|
+ if (data[0] && data[0].switchStatus > Power.LOADING) {
|
|
|
+ const switchStatus = parsePowerSwitchStatus(transformToPowers(data[0].switchStatus, JSON.parse(data[0].typeArray)))
|
|
|
+ linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] = switchStatus === Power.OFF ? Status.ERROR : Status.OK
|
|
|
} else {
|
|
|
- map[ThirdPartyDevice.MULTI_FUNCTION_CARD] = -1
|
|
|
+ linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] = Status.LOADING
|
|
|
}
|
|
|
}
|
|
|
} else if (nodeType === ThirdPartyDevice.SENDING_CARD) {
|
|
|
- map[nodeType] = 1
|
|
|
+ linkDeviceMap[nodeType] = Status.OK
|
|
|
} else if (requiredMap[nodeType]) {
|
|
|
if (instance) {
|
|
|
- const onlineStatus = instance.onlineStatus === 1 ? 1 : 0
|
|
|
- if (map[nodeType] >= 0 && map[nodeType] !== onlineStatus) {
|
|
|
- map[nodeType] = 2
|
|
|
+ const status = instance.onlineStatus === 1 ? Status.OK : Status.ERROR
|
|
|
+ if (linkDeviceMap[nodeType] > Status.LOADING && linkDeviceMap[nodeType] !== status) {
|
|
|
+ linkDeviceMap[nodeType] = Status.WARNING
|
|
|
} else {
|
|
|
- map[nodeType] = onlineStatus
|
|
|
+ linkDeviceMap[nodeType] = status
|
|
|
}
|
|
|
this.$deviceTypes.push(nodeType)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+ this.linkDeviceMap = {
|
|
|
+ msr: Status.OK,
|
|
|
+ led: Status.ERROR,
|
|
|
+ [ThirdPartyDevice.BOX]: Status.NONE,
|
|
|
+ [ThirdPartyDevice.GATEWAY]: Status.NONE,
|
|
|
+ [ThirdPartyDevice.LED_CAMERA]: Status.NONE,
|
|
|
+ [ThirdPartyDevice.TRAFFIC_CAMERA]: Status.NONE,
|
|
|
+ [ThirdPartyDevice.SENDING_CARD]: Status.NONE,
|
|
|
+ [ThirdPartyDevice.RECEIVING_CARD]: Status.NONE,
|
|
|
+ [ThirdPartyDevice.MULTI_FUNCTION_CARD]: Status.NONE,
|
|
|
+ ...linkDeviceMap
|
|
|
+ }
|
|
|
this.led = {
|
|
|
id: this.targetId,
|
|
|
- onlineStatus: by.reduce((curr, key) => Math.min(curr, map[key]), 1),
|
|
|
- status: statusKey,
|
|
|
+ onlineStatus: 0,
|
|
|
+ powerOff: true,
|
|
|
by
|
|
|
}
|
|
|
- map.led = this.led.onlineStatus
|
|
|
- this.linkDeviceMap = map
|
|
|
+ this.onUpdateLed()
|
|
|
this.loaded = true
|
|
|
}).finally(() => {
|
|
|
this.loading = false
|
|
|
@@ -352,36 +363,49 @@ export default {
|
|
|
}
|
|
|
Promise.all([
|
|
|
getThirdPartyDevicesByThirdPartyDevice(this.targetId, this.$deviceTypes, { custom: true }),
|
|
|
- this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] === -2
|
|
|
+ this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] === Status.NONE
|
|
|
? Promise.resolve({ data: [] })
|
|
|
: this.$powerStatus
|
|
|
? Promise.resolve({ data: this.$powerStatus })
|
|
|
: getStatusReport([this.targetId])
|
|
|
]).then(([{ data: nodes }, { data }]) => {
|
|
|
- const map = {}
|
|
|
+ const linkDeviceMap = {}
|
|
|
nodes.forEach(({ nodeType, instance }) => {
|
|
|
- const onlineStatus = instance.onlineStatus === 1 ? 1 : 0
|
|
|
- if (map[nodeType] >= 0 && map[nodeType] !== onlineStatus) {
|
|
|
- map[nodeType] = 2
|
|
|
+ const onlineStatus = instance.onlineStatus === 1 ? Status.OK : Status.ERROR
|
|
|
+ if (linkDeviceMap[nodeType] > Status.LOADING && linkDeviceMap[nodeType] !== onlineStatus) {
|
|
|
+ linkDeviceMap[nodeType] = Status.WARNING
|
|
|
} else {
|
|
|
- map[nodeType] = onlineStatus
|
|
|
+ linkDeviceMap[nodeType] = onlineStatus
|
|
|
}
|
|
|
})
|
|
|
- if (data.length && data[0].switchStatus >= 0) {
|
|
|
- map[ThirdPartyDevice.MULTI_FUNCTION_CARD] = data[0].switchStatus === 255 ? 0 : 1
|
|
|
- this.led.label = map[ThirdPartyDevice.MULTI_FUNCTION_CARD] ? '' : '电源未开启'
|
|
|
+ if (data.length) {
|
|
|
+ const switchStatus = data[0].switchStatus
|
|
|
+ if (switchStatus > Power.LOADING) {
|
|
|
+ linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD] = switchStatus === Power.OFF ? Status.ERROR : Status.OK
|
|
|
+ }
|
|
|
}
|
|
|
- const linkDeviceMap = {
|
|
|
+ this.linkDeviceMap = {
|
|
|
...this.linkDeviceMap,
|
|
|
- ...map
|
|
|
+ ...linkDeviceMap
|
|
|
}
|
|
|
- linkDeviceMap.led = this.led.by.reduce((curr, key) => Math.min(curr, linkDeviceMap[key]), 1)
|
|
|
- this.led.onlineStatus = linkDeviceMap.led
|
|
|
- this.linkDeviceMap = linkDeviceMap
|
|
|
+ this.onUpdateLed()
|
|
|
}).finally(() => {
|
|
|
this.loading = false
|
|
|
})
|
|
|
},
|
|
|
+ onUpdateLed () {
|
|
|
+ const linkDeviceMap = this.linkDeviceMap
|
|
|
+ const by = this.led.by
|
|
|
+ const mutliStatus = this.linkDeviceMap[ThirdPartyDevice.MULTI_FUNCTION_CARD]
|
|
|
+ const hasPower = mutliStatus === Status.NONE || mutliStatus > Status.LOADING && mutliStatus !== Status.ERROR
|
|
|
+ this.led.onlineStatus = hasPower && !by.some(key => linkDeviceMap[key] !== Status.OK && linkDeviceMap[key] !== Status.WARNING) ? 1 : 0
|
|
|
+ this.led.powerOff = !hasPower
|
|
|
+ this.linkDeviceMap.led = this.led.onlineStatus
|
|
|
+ ? by.some(key => linkDeviceMap[key] !== Status.OK)
|
|
|
+ ? Status.WARNING
|
|
|
+ : Status.OK
|
|
|
+ : Status.ERROR
|
|
|
+ },
|
|
|
onClick (item) {
|
|
|
if (!item.canClick) {
|
|
|
return
|
|
|
@@ -503,7 +527,8 @@ export default {
|
|
|
transform: rotate(90deg);
|
|
|
}
|
|
|
|
|
|
- &.l6 {
|
|
|
+ &.l6,
|
|
|
+ &.l15 {
|
|
|
top: 334px;
|
|
|
left: 122px;
|
|
|
width: 120px;
|
|
|
@@ -633,10 +658,12 @@ export default {
|
|
|
&.loading::after {
|
|
|
content: "\e6cf";
|
|
|
position: absolute;
|
|
|
- top: 42%;
|
|
|
- left: 46%;
|
|
|
+ top: calc(50% - $font-size--3xl / 2);
|
|
|
+ left: calc(50% - $font-size--3xl / 2);
|
|
|
+ width: $font-size--3xl;
|
|
|
+ height: $font-size--3xl;
|
|
|
color: #fff;
|
|
|
- font-size: 32px;
|
|
|
+ font-size: $font-size--3xl;
|
|
|
font-family: element-icons !important;
|
|
|
animation: rotating 2s linear infinite;
|
|
|
}
|
|
|
@@ -659,29 +686,14 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- &__warning {
|
|
|
+ &__off {
|
|
|
position: absolute;
|
|
|
top: 6px;
|
|
|
right: 8px;
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ background: url("~@/assets/icon_off.svg") 0 0 / 100% 100% no-repeat;
|
|
|
z-index: 9;
|
|
|
-
|
|
|
- &.on {
|
|
|
- width: 24px;
|
|
|
- height: 24px;
|
|
|
- background: url("~@/assets/icon_on.svg") 0 0 / 100% 100% no-repeat;
|
|
|
- }
|
|
|
-
|
|
|
- &.off {
|
|
|
- width: 24px;
|
|
|
- height: 24px;
|
|
|
- background: url("~@/assets/icon_off.svg") 0 0 / 100% 100% no-repeat;
|
|
|
- }
|
|
|
-
|
|
|
- &.half {
|
|
|
- width: 54px;
|
|
|
- height: 24px;
|
|
|
- background: url("~@/assets/icon_on_2.svg") 0 0 / 100% 100% no-repeat;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -728,10 +740,15 @@ export default {
|
|
|
transform-origin: left;
|
|
|
}
|
|
|
|
|
|
- &.l6 {
|
|
|
+ &.l6,
|
|
|
+ &.l15 {
|
|
|
@include getPosition(230px, 208px, 200px, 2px);
|
|
|
}
|
|
|
|
|
|
+ &.l6.linked ~ &.l15 {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
&.l7 {
|
|
|
@include getPosition(428px, 208px, 96px, 2px);
|
|
|
transform: rotate(90deg);
|