longyvfengyun
2024-08-14 a37c0febb90efd7aa25855f25cabf9ddc6a92c31
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<template>
  <el-form
    ref="ruleForm"
    size="mini"
    label-position="top"
    :model="params"
    :rules="rules"
    class="params-dialog"
  >
    <el-row :gutter="layout.gutter">
      <el-col :span="layout.span">
        <el-form-item label="整流模块限流点(A)" prop="rectifyCurrLimit">
          <el-input v-model="params.rectifyCurrLimit"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="整流模块过压点(V)" prop="rectifyOvervol">
          <el-input v-model="params.rectifyOvervol"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="节能功能启动" prop="energyFunct">
          <el-select
            v-model="params.energyFunct"
            :disabled="pReadOnly"
            placeholder="请选择"
          >
            <el-option label="关闭" :value="0"></el-option>
            <el-option label="启动" :value="1"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="模块休眠系数(%)" prop="dormantRatio">
          <el-input v-model="params.dormantRatio"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="模块唤醒系数(%)" prop="awakenRatio">
          <el-input v-model="params.awakenRatio"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="轮换周期(时)" prop="rotationCycle">
          <el-input v-model="params.rotationCycle"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="模块基数设置" prop="modelBase">
          <el-input v-model="params.modelBase"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="节能测试功能启动" prop="energyTest">
          <el-select
            v-model="params.energyTest"
            :disabled="pReadOnly"
            placeholder="请选择"
          >
            <el-option label="关闭" :value="0"></el-option>
            <el-option label="启动" :value="1"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="layout.span">
        <el-form-item label="整流模块额定数量" prop="modelRatedCnt">
          <el-input v-model="params.modelRatedCnt"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <div class="form-footer">
      <template v-if="!pReadOnly">
        <three-btn @click="getParams()">读取</three-btn>
        <three-btn :disabled="!setTestFlag" @click="submitFrom">设定</three-btn>
      </template>
      <three-btn v-else @click="$emit('close')">关闭</three-btn>
    </div>
    <el-dialog
      title="人脸校验"
      width="480px"
      :visible.sync="setFaceShow"
      :close-on-click-modal="false"
      top="0"
      :modal="false"
      class="dialog-center"
      :modal-append-to-body="false"
      :destroy-on-close="true"
    >
      <check-face
        v-if="setFaceShow"
        @checkSuccess="setFaceSuccess"
      ></check-face>
    </el-dialog>
    <el-dialog
      title="人脸校验"
      width="480px"
      :visible.sync="startFaceShow"
      :close-on-click-modal="false"
      top="0"
      :modal="false"
      class="dialog-center"
      :modal-append-to-body="false"
      :destroy-on-close="true"
    >
      <check-face
        v-if="startFaceShow"
        @checkSuccess="startFaceSuccess"
      ></check-face>
    </el-dialog>
  </el-form>
</template>
 
<script>
import const_61590 from "@/assets/js/const/const_61590";
 
import { testVal } from "@/assets/js/tools";
import CheckFace from "@/components/checkFace";
 
import config from "@/assets/js/config";
import { setDev6159RectifierParam, getDev6159RectifierParam } from "../js/realTime";
 
import { checkUserPwd } from "@/views/login/js/api";
 
export default {
  components: { CheckFace },
  props: {
    devId: {
      type: [String, Number],
      required: true,
    },
    // 只读模式 显示参数用
    pReadOnly: {
      type: Boolean,
      default: false,
    },
    isRequest: {
      type: Number,
      default: 0,
    },
    paramData: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    let rules = const_61590.moduleParamsRules;
    function getRule(prop) {
      return [
        {
          validator(rule, value, callback) {
            testVal(rule, value, callback, rules[prop]);
          },
          trigger: "change",
        },
      ];
    }
    let rulesObj = {};
    [
      "rectifyCurrLimit",
      "rectifyOvervol",
      "dormantRatio",
      "awakenRatio",
      "rotationCycle",
      "modelBase",
      "modelRatedCnt",
    ].forEach((v) => {
      rulesObj[v] = getRule(v);
    });
    return {
      layout: {
        gutter: 16,
        span: 12,
      },
      reason: "",
      setFaceShow: false,
      startFaceShow: false,
      setTestFlag: false, // 设置参数的状态
      readOnly: false,
      params: {
        rectifyCurrLimit: 0,
        rectifyOvervol: 0,
        dormantRatio: 0,
        awakenRatio: 0,
        rotationCycle: 0,
        modelBase: 0,
        modelRatedCnt: 0,
        energyFunct: 0,
        energyTest: 0,
        devId: this.devId,
      },
      rules: rulesObj,
    };
  },
  watch: {
  },
  methods: {
    initParams() {
      // 初始化参数
      this.params = {
        rectifyCurrLimit: 0,
        rectifyOvervol: 0,
        dormantRatio: 0,
        awakenRatio: 0,
        rotationCycle: 0,
        modelBase: 0,
        modelRatedCnt: 0,
        energyFunct: 0,
        energyTest: 0,
        devId: this.devId,
      };
    },
    // 获取参数
    getParams() {
      // 定义等待框
      let loading = this.$layer.loading(1);
      // 启动按钮不可点击
      this.startTestFlag = false;
 
      // 查询后台
      getDev6159RectifierParam(this.devId)
        .then((res) => {
          res = res.data;
          if (res.code && res.data) {
            let fsparam = res.data2;
            // 遍历参数属性并赋值
            for (let key in this.params) {
              this.params[key] = fsparam[key];
            }
            if (res.data2) {
              this.$layer.msg("读取成功!");
              // 设置按钮可点击
              this.setTestFlag = true;
            }
          } else {
            // 初始化参数
            this.initParams();
            // 设置按钮不可点击
            this.setTestFlag = false;
            this.$layer.msg("读取失败!");
          }
          // 关闭等待框
          this.$layer.close(loading);
        })
        .catch((error) => {
          console.log(error);
          // 初始化参数
          this.initParams();
          // 设置按钮不可点击
          this.setTestFlag = false;
          // 关闭等待框
          this.$layer.close(loading);
          this.$layer.msg("读取失败,读取请求异常!");
        });
    },
    // 提交表单设置参数
    submitFrom() {
      this.$refs.ruleForm.validate((valid) => {
        // 校验通过
        if (valid) {
          // 设置参数
          this.setParamsCheck();
        } else {
          this.$layer.msg("存在校验未通过的数据!");
          return false;
        }
      });
    },
    setParamsCheck() {
      if (config.setParamsByFace.value) {
        this.setFaceShow = true;
      } else {
        this.setParams(true);
      }
    },
    // 设置参数
    setParams() {
      // 等待框
      let loading = this.$layer.loading(1);
      // 请求后台
      setDev6159RectifierParam(this.params)
        .then((res) => {
          res = res.data;
          if (res.code && res.data) {
            // 启动按钮可点击
            this.startTestFlag = true;
            // 提示信息
            this.$layer.msg("设置成功");
          } else {
            // 启动按钮不可点击
            this.startTestFlag = false;
            // 提示信息
            this.$layer.msg("设置失败!");
          }
          // 关闭等待框
          this.$layer.close(loading);
        })
        .catch((error) => {
          console.log(error);
          // 关闭等待框
          this.$layer.close(loading);
          // 启动按钮不可点击
          this.startTestFlag = false;
          // 提示信息
          this.$layer.msg("设置失败,设置请求异常!");
        });
    },
    setFaceSuccess() {
      this.setFaceShow = false;
      this.setParams();
    },
  },
  computed: {},
  mounted() {
    // 获取数据
    if (this.pReadOnly) {
      this.initParams();
      this.params = {
        ...this.params,
        ...this.paramData,
      };
    } else {
      this.getParams();
    }
  },
};
</script>
 
<style scoped>
.params-dialog {
  background: #f0f0f0;
  padding: 20px 20px 1px;
  width: 600px;
}
.form-footer {
  margin-top: 16px;
  margin-bottom: 16px;
  text-align: right;
}
 
.form-footer .three-btn {
  margin-left: 12px;
}
</style>