|
|
@@ -6,9 +6,15 @@
|
|
|
>
|
|
|
<i
|
|
|
class="o-icon lg u-pointer"
|
|
|
- @click="invoke"
|
|
|
+ @click="onTrigger"
|
|
|
/>
|
|
|
- <div class="has-padding u-color--black u-bold">{{ type }}</div>
|
|
|
+ <div class="has-padding u-color--black u-bold">
|
|
|
+ <i
|
|
|
+ v-if="loading"
|
|
|
+ class="el-icon-loading"
|
|
|
+ />
|
|
|
+ {{ type }}
|
|
|
+ </div>
|
|
|
</slot>
|
|
|
<c-dialog
|
|
|
ref="dialog"
|
|
|
@@ -22,19 +28,13 @@
|
|
|
/>
|
|
|
<template v-if="isImmediate">
|
|
|
<div class="l-flex__auto l-flex--col jcenter center has-bottom-padding">
|
|
|
- <div class="c-sibling-item--v c-grid-form auto">
|
|
|
- <span class="c-grid-form__label u-required">{{ tip }}</span>
|
|
|
- <div class="l-flex--row">
|
|
|
- <el-input-number
|
|
|
- v-model="taskValue"
|
|
|
- :min="0"
|
|
|
- :max="100"
|
|
|
- step-strictly
|
|
|
- /> %
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <el-slider
|
|
|
+ v-model="volume"
|
|
|
+ class="c-sibling-item--v u-width--lg"
|
|
|
+ v-bind="sliderOptions"
|
|
|
+ />
|
|
|
<button
|
|
|
- class="c-sibling-item--v o-button"
|
|
|
+ class="c-sibling-item--v farther o-button"
|
|
|
@click="onInvoke"
|
|
|
>
|
|
|
应用
|
|
|
@@ -55,14 +55,12 @@
|
|
|
@confirm="onSave"
|
|
|
>
|
|
|
<template #default>
|
|
|
- <span class="c-grid-form__label u-required">{{ tip }}</span>
|
|
|
- <div class="l-flex--row">
|
|
|
- <el-input-number
|
|
|
- v-model="task"
|
|
|
- :min="0"
|
|
|
- :max="100"
|
|
|
- step-strictly
|
|
|
- /> %
|
|
|
+ <div class="l-flex--row center c-grid-form__row">
|
|
|
+ <el-slider
|
|
|
+ v-model="task.value"
|
|
|
+ class="u-width--md"
|
|
|
+ v-bind="sliderOptions"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
</task-dialog>
|
|
|
@@ -70,7 +68,15 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import simpleTaskMixin from './mixins/simple-task'
|
|
|
+import {
|
|
|
+ DEFAULT_VOLUME_LEVEL,
|
|
|
+ SLIDER_OPTIONS,
|
|
|
+ transformLevelVolumeToPercentVolume,
|
|
|
+ transformPercentVolumeToLevelVolume,
|
|
|
+ parseVolume,
|
|
|
+ sendVolumeToDevice
|
|
|
+} from '@/utils/control/volume.js'
|
|
|
+import simpleTaskMixin from './mixins/simple-task.js'
|
|
|
|
|
|
export default {
|
|
|
name: 'ScreenVolumn',
|
|
|
@@ -81,8 +87,10 @@ export default {
|
|
|
functionKey: 'volumeControl',
|
|
|
valueKey: 'volume',
|
|
|
schema: this.createSchema([
|
|
|
- { label: '音量值(%)', render ({ inputs }) { return inputs[0]?.value } }
|
|
|
- ])
|
|
|
+ { label: '音量', render ({ inputs }) { return parseVolume(transformPercentVolumeToLevelVolume(inputs[0]?.value)) } }
|
|
|
+ ]),
|
|
|
+ volume: 0,
|
|
|
+ sliderOptions: SLIDER_OPTIONS
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -90,6 +98,48 @@ export default {
|
|
|
return this.$scopedSlots.trigger
|
|
|
? ''
|
|
|
: 'l-flex--col center has-border radius has-padding'
|
|
|
+ },
|
|
|
+ loading () {
|
|
|
+ return isNaN(this.device.volume)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onTrigger () {
|
|
|
+ this.volume = this.loading ? DEFAULT_VOLUME_LEVEL : this.device.volume
|
|
|
+ this.invoke()
|
|
|
+ },
|
|
|
+ onInvoke () {
|
|
|
+ const volume = this.volume
|
|
|
+ this.$confirm(
|
|
|
+ `将音量设置为Lv.${volume}?`,
|
|
|
+ '操作确认',
|
|
|
+ { type: 'warning' }
|
|
|
+ ).then(() => {
|
|
|
+ sendVolumeToDevice(this.device, volume).then(() => {
|
|
|
+ this.$set(this.device, this.valueKey, volume)
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '配置下发中...'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ createTask (task) {
|
|
|
+ console.log(task)
|
|
|
+ if (task && task.inputs) {
|
|
|
+ const valueKey = this.valueKey
|
|
|
+ const prop = task.inputs.find(item => item.name === valueKey)
|
|
|
+ if (prop) {
|
|
|
+ return { value: transformPercentVolumeToLevelVolume(prop.value) }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return { value: this.createDefaultValue() }
|
|
|
+ },
|
|
|
+ createDefaultValue () {
|
|
|
+ return DEFAULT_VOLUME_LEVEL
|
|
|
+ },
|
|
|
+ getTaskValue () {
|
|
|
+ return transformLevelVolumeToPercentVolume(this.task.value)
|
|
|
}
|
|
|
}
|
|
|
}
|