<template>
|
<GlobalWindow title="设备锁定设置" :visible.sync="visible" width="520px" @confirm="save" :confirm-working="isSaving">
|
<div class="lock-form" v-if="device.id">
|
<p class="device-info">{{ device.name || device.code }} · {{ device.wgMac }}</p>
|
<div class="lock-section">
|
<div class="lock-label">开关状态</div>
|
<el-radio-group v-model="form.pwr" size="small">
|
<el-radio-button :label="-1">不限</el-radio-button>
|
<el-radio-button :label="0">关</el-radio-button>
|
<el-radio-button :label="1">开</el-radio-button>
|
</el-radio-group>
|
</div>
|
<div class="lock-section">
|
<div class="lock-label">模式锁定</div>
|
<el-radio-group v-model="form.mode" size="small">
|
<el-radio-button :label="-1">不限</el-radio-button>
|
<el-radio-button v-for="item in modeOptions" :key="item.value" :label="item.value">{{ item.label }}</el-radio-button>
|
</el-radio-group>
|
</div>
|
<div class="lock-section">
|
<div class="lock-label">风速锁定</div>
|
<el-radio-group v-model="form.fan" size="small">
|
<el-radio-button :label="-1">不限</el-radio-button>
|
<el-radio-button v-for="item in fanOptions" :key="item.value" :label="item.value">{{ item.label }}</el-radio-button>
|
</el-radio-group>
|
</div>
|
<div class="lock-section">
|
<div class="lock-label">温度范围 (°C)</div>
|
<div class="temp-range">
|
<el-input-number v-model="form.minTemp" :min="-1" :max="35" :step="1" size="small" controls-position="right" />
|
<span class="range-sep">~</span>
|
<el-input-number v-model="form.maxTemp" :min="-1" :max="35" :step="1" size="small" controls-position="right" />
|
</div>
|
<p class="hint">设为 -1 表示不限制(保存时未填则传 -1)</p>
|
</div>
|
</div>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import { lock } from '@/api/business/ywconditioner'
|
|
const MODE_OPTIONS = [
|
{ value: 0, label: '自动' },
|
{ value: 1, label: '制冷' },
|
{ value: 2, label: '制热' },
|
{ value: 3, label: '送风' },
|
{ value: 4, label: '除湿' }
|
]
|
|
const FAN_OPTIONS = [
|
{ value: 0, label: '自动' },
|
{ value: 1, label: '低速' },
|
{ value: 2, label: '中速' },
|
{ value: 3, label: '高速' }
|
]
|
|
export default {
|
name: 'YwConditionerLockWindow',
|
components: { GlobalWindow },
|
data () {
|
return {
|
visible: false,
|
isSaving: false,
|
device: {},
|
form: {
|
pwr: -1,
|
mode: -1,
|
fan: -1,
|
minTemp: 17,
|
maxTemp: 32
|
},
|
modeOptions: MODE_OPTIONS,
|
fanOptions: FAN_OPTIONS
|
}
|
},
|
methods: {
|
open (row) {
|
this.device = { ...row }
|
this.form = {
|
pwr: 1,
|
mode: 2,
|
fan: 0,
|
minTemp: 17,
|
maxTemp: 32
|
}
|
this.visible = true
|
},
|
save () {
|
this.isSaving = true
|
lock({
|
id: this.device.id,
|
lockPwr: 1,
|
pwr: this.form.pwr,
|
mode: this.form.mode,
|
fan: this.form.fan,
|
minTemp: this.form.minTemp != null ? this.form.minTemp : -1,
|
maxTemp: this.form.maxTemp != null ? this.form.maxTemp : -1,
|
source: 'admin'
|
})
|
.then(res => {
|
this.$tip.apiSuccess(res || '锁定成功')
|
this.visible = false
|
this.$emit('success')
|
})
|
.catch(e => this.$tip.apiFailed(e))
|
.finally(() => { this.isSaving = false })
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.device-info { margin-bottom: 16px; color: #606266; }
|
.lock-section { margin-bottom: 18px; }
|
.lock-label { font-size: 13px; color: #303133; margin-bottom: 8px; font-weight: 500; }
|
.temp-range { display: flex; align-items: center; gap: 8px; }
|
.range-sep { color: #909399; }
|
.hint { font-size: 12px; color: #909399; margin-top: 6px; }
|
</style>
|