he wei
2024-09-21 70edda3b00f2528a473c28ec5a50b739ed160f0f
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<script>
import {
  getParamsApi,
  setParamsApi,
} from "@/views/dataTest/js/devAlaramParams";
 
export default {
  name: "DevAlarmParams",
  props: {
    batt: {
      type: Object,
      default() {
        return {};
      },
    },
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      isCanSet: false,
      layout: {
        span: 12,
        gutter: 16,
      },
      params: {
        devId: 0, // 设备ID
        groupvolHighVal: 0, // 组端电压高阈值
        groupvolLowVal: 0, // 组端电压低阈值
        moncapHighVal: 0, // 单体容量高阈值
        moncapLowVal: 0, // 单体容量低阈值
        monresHighVal: 0, // 单体内阻高阈值
        monresLowVal: 0, // 单体内阻低阈值
        montmpHighVal: 0, // 单体温度高阈值
        montmpLowVal: 0, // 单体温度低阈值
        monvolHighVal: 0, // 单体电压高阈值
        monvolLowVal: 0, // 单体电压低阈值
        num: 0,
        opCmd: 0, // 操作命令
      },
      rules: {},
    };
  },
  methods: {
    async getParams() {
      let batt = this.batt;
      this.isCanSet = false;
      let loading = this.$layer.loading();
      try {
        let res = await getParamsApi(batt.fbsdeviceId);
        this.$layer.close(loading);
        let rs = res.data;
        if (rs.code === 1 && rs.data) {
          this.isCanSet = true;
          this.$message.success("读取成功");
          this.params = rs.data2;
        } else {
          this.isCanSet = false;
          this.$message.warning("读取异常");
        }
      } catch (e) {
        this.$layer.close(loading);
        this.isCanSet = false;
        console.log(e);
        this.$message.error(e);
      }
    },
    async setParams() {
      let params = { ...this.params };
      let loading = this.$layer.loading();
      try {
        let res = await setParamsApi(params);
        this.$layer.close(loading);
        let rs = res.data;
        if (rs.code === 1 && rs.data) {
          this.$message.success("设置成功");
        } else {
          this.$message.warning("设置失败");
        }
      } catch (e) {
        this.$layer.close(loading);
        console.log(e);
        this.$message.error(e);
      }
    },
    close() {
      this.$emit("update:visible", false);
    },
  },
  mounted() {
    this.getParams();
  },
};
</script>
 
<template>
  <div class="dev-alarm-params">
    <el-form
      ref="ruleForm"
      size="mini"
      label-position="top"
      :model="params"
      :rules="rules"
      class="params-dialog"
    >
      <el-form-item label="机房名称" prop="stationName">
        <el-input
          placeholder="请输入机房名称"
          v-model="batt.stationName"
          readonly="readonly"
        >
        </el-input>
      </el-form-item>
      <el-row :gutter="layout.gutter">
        <el-col :span="layout.span">
          <el-form-item label="组端电压高阈值" prop="groupvolHighVal">
            <el-input
              placeholder="请输入组端电压高阈值"
              v-model="params.groupvolHighVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="组端电压低阈值" prop="groupvolLowVal">
            <el-input
              placeholder="请输入组端电压低阈值"
              v-model="params.groupvolLowVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体容量高阈值" prop="moncapHighVal">
            <el-input
              placeholder="请输入单体容量高阈值"
              v-model="params.moncapHighVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体容量低阈值" prop="moncapLowVal">
            <el-input
              placeholder="请输入单体容量低阈值"
              v-model="params.moncapLowVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体内阻高阈值" prop="monresHighVal">
            <el-input
              placeholder="请输入单体内阻高阈值"
              v-model="params.monresHighVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体内阻低阈值" prop="monresLowVal">
            <el-input
              placeholder="请输入单体内阻低阈值"
              v-model="params.monresLowVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体温度高阈值" prop="montmpHighVal">
            <el-input
              placeholder="请输入单体温度高阈值"
              v-model="params.montmpHighVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体温度低阈值" prop="montmpLowVal">
            <el-input
              placeholder="请输入单体温度低阈值"
              v-model="params.montmpLowVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体电压高阈值" prop="monvolHighVal">
            <el-input
              placeholder="请输入单体电压高阈值"
              v-model="params.monvolHighVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="layout.span">
          <el-form-item label="单体电压低阈值" prop="monvolLowVal">
            <el-input
              placeholder="请输入单体电压低阈值"
              v-model="params.monvolLowVal"
            >
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <div class="form-footer">
        <el-button type="primary" size="mini" @click="getParams"
          >读取
        </el-button>
        <el-button
          type="success"
          size="mini"
          :disabled="!isCanSet"
          @click="setParams"
          >设定
        </el-button>
      </div>
    </el-form>
  </div>
</template>
 
<style scoped>
.dev-alarm-params {
  width: 560px;
  background-color: #ffffff;
  padding: 8px;
}
.form-footer {
  text-align: right;
  margin-bottom: 0;
}
</style>