doum
7 天以前 074bcb8394fab66ce531c219e1e7de7c142ff2d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<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>