|
|
@@ -172,18 +172,16 @@ export default {
|
|
|
methods: {
|
|
|
onMessage (topic) {
|
|
|
const result = /^(\d+)\/(\d+)\/(online|offline)$/.exec(topic)
|
|
|
- if (result) {
|
|
|
- if (this.product === result[1] && this.deviceOptions.loaded) {
|
|
|
- const deviceId = result[2]
|
|
|
- const device = this.deviceOptions.find(({ id }) => id === deviceId)
|
|
|
- if (device && device.activate === 2) {
|
|
|
- const status = result[3]
|
|
|
- if (status === 'online' && device.onlineStatus === 1 || status === 'offline' && device.onlineStatus !== 1) {
|
|
|
- return
|
|
|
- }
|
|
|
+ if (result && (!this.product || this.product === result[1]) && this.deviceOptions.loaded) {
|
|
|
+ const deviceId = result[2]
|
|
|
+ const device = this.deviceOptions.list.find(({ id }) => id === deviceId)
|
|
|
+ if (device && device.activate === 2) {
|
|
|
+ const status = result[3]
|
|
|
+ if (status === 'online' && device.onlineStatus === 1 || status === 'offline' && device.onlineStatus !== 1) {
|
|
|
+ return
|
|
|
}
|
|
|
}
|
|
|
- this.refreshDevices(true)
|
|
|
+ this.refresh()
|
|
|
}
|
|
|
},
|
|
|
_getProducts () {
|
|
|
@@ -194,9 +192,7 @@ export default {
|
|
|
options.firstLoadSize = totalCount
|
|
|
this._getProducts()
|
|
|
} else {
|
|
|
- options.list = options.list.concat(data.map(({ id, name }) => {
|
|
|
- return { value: id, label: name }
|
|
|
- }))
|
|
|
+ options.list = options.list.concat(data.map(({ id, name }) => ({ value: id, label: name })))
|
|
|
options.fetching = false
|
|
|
options.loaded = true
|
|
|
}
|
|
|
@@ -256,10 +252,7 @@ export default {
|
|
|
this.deviceOptions = { list: [], loaded: true }
|
|
|
return
|
|
|
}
|
|
|
- const options = {
|
|
|
- list: [],
|
|
|
- loaded: false
|
|
|
- }
|
|
|
+ const options = { list: [], loaded: false }
|
|
|
this.deviceOptions = options
|
|
|
getDevices({
|
|
|
pageSize: total,
|