|
|
@@ -101,7 +101,7 @@
|
|
|
<div
|
|
|
v-else
|
|
|
class="l-flex__auto l-flex--row u-font-size u-bold u-text--center"
|
|
|
- v-html="warningTip"
|
|
|
+ v-html="statusInfo"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="l-flex__none l-flex--row c-sibling-item--v o-device__next u-color--black light u-font-size--xs u-text--center">
|
|
|
@@ -124,16 +124,13 @@
|
|
|
<script>
|
|
|
import {
|
|
|
ONE_DAY,
|
|
|
- ThirdPartyDevice,
|
|
|
EventPriority,
|
|
|
EventPriorityInfo
|
|
|
} from '@/constant'
|
|
|
import { parseTime } from '@/utils'
|
|
|
import {
|
|
|
Status,
|
|
|
- Power,
|
|
|
- addListener,
|
|
|
- removeListener
|
|
|
+ Power
|
|
|
} from '@/utils/adapter'
|
|
|
import { ScreenshotCache } from '@/utils/cache'
|
|
|
import {
|
|
|
@@ -143,16 +140,13 @@ import {
|
|
|
getStartDate,
|
|
|
toDate
|
|
|
} from '@/utils/event'
|
|
|
-import { parseVolume } from '@/utils/control/volume'
|
|
|
import { getTimelineByRange } from '@/api/device'
|
|
|
+import deviceMixin from './mixins/device.js'
|
|
|
|
|
|
export default {
|
|
|
name: 'DeviceCard',
|
|
|
+ mixins: [deviceMixin],
|
|
|
props: {
|
|
|
- device: {
|
|
|
- type: Object,
|
|
|
- required: true
|
|
|
- },
|
|
|
flag: {
|
|
|
type: Number,
|
|
|
default: null
|
|
|
@@ -169,42 +163,12 @@ export default {
|
|
|
shot: null,
|
|
|
timelineOptions: { loading: false },
|
|
|
current: null,
|
|
|
- next: null,
|
|
|
- timestamp: '',
|
|
|
- powerStatus: Status.LOADING,
|
|
|
- switchStatus: Power.LOADING,
|
|
|
- hasPower: true,
|
|
|
- hasPowerRealStatus: false,
|
|
|
- volume: -1
|
|
|
+ next: null
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- name () {
|
|
|
- return this.device.name
|
|
|
- },
|
|
|
- address () {
|
|
|
- return this.device.address
|
|
|
- },
|
|
|
- warningTip () {
|
|
|
- return this.isOnline
|
|
|
- ? this.powerStatus === Status.WARNING
|
|
|
- ? `电源状态异常,${this.switchStatus === Power.LOADING ? '检测' : '最后上报'}时间<br/><br/>${this.timestamp}`
|
|
|
- : '屏幕未开启'
|
|
|
- : this.device.lastOnline
|
|
|
- ? `${this.device.lastOnline} 离线`
|
|
|
- : '当前播控器离线了'
|
|
|
- },
|
|
|
- isOnline () {
|
|
|
- return this.device.onlineStatus === 1
|
|
|
- },
|
|
|
- hasStatus () {
|
|
|
- return !this.isOnline || !this.hasPower || this.hasPowerRealStatus
|
|
|
- },
|
|
|
- isPowerOpened () {
|
|
|
- return !this.hasPower || this.hasPowerRealStatus && (this.powerStatus === Status.OK && this.switchStatus !== Power.OFF)
|
|
|
- },
|
|
|
isRealOnline () {
|
|
|
- return this.hasStatus && this.isOnline && this.isPowerOpened
|
|
|
+ return this.isOnline && (!this.hasPower || this.isPowerOpened)
|
|
|
},
|
|
|
isRealOffline () {
|
|
|
return this.hasStatus && !this.isRealOnline
|
|
|
@@ -212,9 +176,9 @@ export default {
|
|
|
switchStatusClass () {
|
|
|
return this.powerStatus === Status.WARNING
|
|
|
? 'el-icon-warning u-color--warning u-font-size--2xl'
|
|
|
- : this.switchStatus === Power.ON
|
|
|
+ : this.powerSwitchStatus === Power.ON
|
|
|
? 'on'
|
|
|
- : this.switchStatus === Power.OFF
|
|
|
+ : this.powerSwitchStatus === Power.OFF
|
|
|
? 'off'
|
|
|
: 'other'
|
|
|
},
|
|
|
@@ -232,12 +196,6 @@ export default {
|
|
|
},
|
|
|
needCheck () {
|
|
|
return this.isInView && this.isRealOnline
|
|
|
- },
|
|
|
- volumeTip () {
|
|
|
- if (this.volume > -1) {
|
|
|
- return parseVolume(this.volume)
|
|
|
- }
|
|
|
- return ''
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -248,19 +206,6 @@ export default {
|
|
|
}
|
|
|
this.getTimeline(true)
|
|
|
},
|
|
|
- isOnline: {
|
|
|
- handler (val, old) {
|
|
|
- if (val) {
|
|
|
- addListener(this.device.id, this.onMessage)
|
|
|
- } else {
|
|
|
- if (old == null) {
|
|
|
- return
|
|
|
- }
|
|
|
- removeListener(this.device.id, this.onMessage)
|
|
|
- }
|
|
|
- },
|
|
|
- immediate: true
|
|
|
- },
|
|
|
isInView (val) {
|
|
|
if (!val) {
|
|
|
this.onReset()
|
|
|
@@ -280,7 +225,7 @@ export default {
|
|
|
immediate: true
|
|
|
}
|
|
|
},
|
|
|
- // 因为inOnline的watch使用了immediate,会先于created
|
|
|
+ // inOnline的watch使用了immediate,会先于created
|
|
|
beforeCreate () {
|
|
|
this.$timer = -1
|
|
|
this.$refreshTimer = -1
|
|
|
@@ -292,9 +237,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
beforeDestroy () {
|
|
|
- if (this.isOnline) {
|
|
|
- removeListener(this.device.id, this.onMessage)
|
|
|
- }
|
|
|
this.onReset(true)
|
|
|
this.$observer?.disconnect()
|
|
|
this.$observer = null
|
|
|
@@ -317,18 +259,6 @@ export default {
|
|
|
}
|
|
|
this.$observer.observe(this.$el)
|
|
|
},
|
|
|
- onMessage (value) {
|
|
|
- if (value.screen) {
|
|
|
- this.volume = value.screen.volume
|
|
|
- }
|
|
|
- const multiCard = value[ThirdPartyDevice.MULTI_FUNCTION_CARD]
|
|
|
- const powerStatus = multiCard.status
|
|
|
- this.powerStatus = powerStatus
|
|
|
- this.timestamp = multiCard.timestamp ? parseTime(multiCard.timestamp, '{y}-{m}-{d} {h}:{i}:{s}') : ''
|
|
|
- this.hasPower = powerStatus > Status.NONE
|
|
|
- this.hasPowerRealStatus = powerStatus !== Status.LOADING
|
|
|
- this.switchStatus = multiCard.switchStatus
|
|
|
- },
|
|
|
checkStatus () {
|
|
|
if (!this.$firstView) {
|
|
|
ScreenshotCache.watch(this.device, this.onScreenshotUpdate)
|
|
|
@@ -362,12 +292,6 @@ export default {
|
|
|
this.isShotting = waiting
|
|
|
this.shot = waiting ? null : base64
|
|
|
},
|
|
|
- onClick () {
|
|
|
- this.$router.push({
|
|
|
- name: 'device-detail',
|
|
|
- params: { id: this.device.id }
|
|
|
- })
|
|
|
- },
|
|
|
getTimeline (force) {
|
|
|
if (!force && this.timelineOptions.loading) {
|
|
|
return
|