|
|
@@ -118,24 +118,6 @@
|
|
|
:text="address"
|
|
|
/>
|
|
|
</div>
|
|
|
- <confirm-dialog
|
|
|
- ref="volumeDialog"
|
|
|
- title="音量设置"
|
|
|
- size="mini"
|
|
|
- append-to-body
|
|
|
- @confirm="onConfirmVolume"
|
|
|
- >
|
|
|
- <div class="l-flex--row center">
|
|
|
- <el-input-number
|
|
|
- v-model="editVolume"
|
|
|
- class="c-sibling-item"
|
|
|
- :min="0"
|
|
|
- :max="100"
|
|
|
- step-strictly
|
|
|
- />
|
|
|
- <span class="c-sibling-item nearer u-font-size--sm">%</span>
|
|
|
- </div>
|
|
|
- </confirm-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -147,7 +129,6 @@ import {
|
|
|
EventPriorityInfo
|
|
|
} from '@/constant'
|
|
|
import { parseTime } from '@/utils'
|
|
|
-import { publish } from '@/utils/mqtt'
|
|
|
import {
|
|
|
Status,
|
|
|
Power,
|
|
|
@@ -162,7 +143,6 @@ import {
|
|
|
getStartDate,
|
|
|
toDate
|
|
|
} from '@/utils/event'
|
|
|
-import { saveBoxLogger } from '@/api/platform'
|
|
|
import { getTimelineByRange } from '@/api/device'
|
|
|
|
|
|
export default {
|
|
|
@@ -260,10 +240,13 @@ export default {
|
|
|
this.getTimeline(true)
|
|
|
},
|
|
|
isOnline: {
|
|
|
- handler (val) {
|
|
|
+ handler (val, old) {
|
|
|
if (val) {
|
|
|
addListener(this.device.id, this.onMessage)
|
|
|
} else {
|
|
|
+ if (old == null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
removeListener(this.device.id, this.onMessage)
|
|
|
}
|
|
|
},
|
|
|
@@ -517,38 +500,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onVolume () {
|
|
|
- this.editVolume = this.volume
|
|
|
- this.$refs.volumeDialog.show()
|
|
|
- },
|
|
|
- onConfirmVolume (done) {
|
|
|
- const volume = this.editVolume
|
|
|
- if (volume === this.volume) {
|
|
|
- done()
|
|
|
- } else {
|
|
|
- const { id, productId, name } = this.device
|
|
|
- const timestamp = `${Date.now()}`
|
|
|
- const messageId = `volume_${timestamp}`
|
|
|
- publish(`${productId}/${id}/function/invoke`, JSON.stringify({
|
|
|
- messageId,
|
|
|
- timestamp,
|
|
|
- 'function': 'volumeControl',
|
|
|
- inputs: [{
|
|
|
- name: 'volume',
|
|
|
- value: `${volume}`
|
|
|
- }]
|
|
|
- }), true).then(() => {
|
|
|
- saveBoxLogger({
|
|
|
- description: `将【${name}】音量设置为${volume}%`,
|
|
|
- method: '音量设置',
|
|
|
- params: `${id} ${name} ${volume}%`
|
|
|
- })
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '配置下发中...'
|
|
|
- })
|
|
|
- done()
|
|
|
- })
|
|
|
- }
|
|
|
+ const { id, productId, name } = this.device
|
|
|
+ this.$emit('volume', {
|
|
|
+ value: this.volume,
|
|
|
+ device: { id, productId, name }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|