|
|
@@ -59,6 +59,7 @@
|
|
|
title="发送消息"
|
|
|
:visible.sync="mqtt.show"
|
|
|
custom-class="c-dialog mini"
|
|
|
+ :close-on-click-modal="false"
|
|
|
>
|
|
|
<div class="c-grid-form u-align-self--center">
|
|
|
<span class="c-grid-form__label required">topic</span>
|
|
|
@@ -118,6 +119,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ messageProxy () {
|
|
|
+ const id = this.device
|
|
|
+ return this.deviceMessage.find(item => item.id === id)
|
|
|
+ },
|
|
|
messages () {
|
|
|
if (this.device === 'all') {
|
|
|
return this.deviceMessage.map(item => {
|
|
|
@@ -127,7 +132,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- return this.deviceMessage.find(item => item.id === this.device).list
|
|
|
+ return this.messageProxy?.list || []
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -142,10 +147,14 @@ export default {
|
|
|
clear()
|
|
|
},
|
|
|
publish () {
|
|
|
+ const messageProxy = this.messageProxy
|
|
|
this.mqtt = {
|
|
|
show: true,
|
|
|
- topic: '',
|
|
|
- message: '',
|
|
|
+ topic: messageProxy && messageProxy.productId ? `${messageProxy.productId}/${this.device}/` : '',
|
|
|
+ message: JSON.stringify({
|
|
|
+ messageId: `${this.device}_${Math.random().toString(16).slice(2)}`,
|
|
|
+ timestamp: `${Date.now()}`
|
|
|
+ }, null, 2),
|
|
|
encode: true
|
|
|
}
|
|
|
},
|