Parcourir la source

海康威视设备增加佩戴口罩设置。

zhengqiang il y a 4 ans
Parent
commit
5caed2131a
1 fichiers modifiés avec 82 ajouts et 16 suppressions
  1. 82 16
      src/views/base/deviceInfo-ehome.vue

+ 82 - 16
src/views/base/deviceInfo-ehome.vue

@@ -121,6 +121,28 @@
                 ></el-switch>
             </el-form-item>
           </el-col>
+        </el-row>        
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="是否开启口罩检测">
+                <el-switch
+                    v-model="maskDetection.enable"
+                    active-color="#13ce66"
+                    active-text="是"
+                    inactive-color="#ff4949"
+                    inactive-text="否"
+                ></el-switch>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="检测未带口罩策略">
+              <el-select v-model="maskDetection.noMaskStrategy">
+                <el-option label="提示且开门" value="tipsAndOpenDoor"></el-option>
+                <el-option label="不提示且开门" value="noTipsAndOpenDoor"></el-option>
+                <el-option label="提示且不开门" value="tipsAndNotOpenDoor"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
         </el-row>
       </el-form>
     </div>
@@ -139,11 +161,16 @@ export default {
   data() {
     return {
       formModel: {},
+      maskDetection: {
+        "enable": true,          
+        "noMaskStrategy": ""
+      },
       ruleValidate: {},
       showDialog: true,
       loading: false,
       submitting: false,
-      cfgUrl: "/ISAPI/AccessControl/AcsCfg?format=json"
+      cfgUrl: "/ISAPI/AccessControl/AcsCfg?format=json",
+      maskDetectionUrl: "/ISAPI/AccessControl/maskDetection?format=json"
     }
   },
   methods: {
@@ -154,29 +181,49 @@ export default {
       var self = this;
 
       this.$refs["form"].validate(valid => {
+
+        //保存测温策略
         ehomeApi.putXMLConfig(
             self.deviceNo,self.cfgUrl,{
                 "AcsCfg": self.formModel
             },
-        ).then(function(response) {
-            self.loading = false;
-            var jsonData = response.data;
+        ).then(response=>{
+          var jsonData = response.data;
 
-            if (jsonData.success) {
-              self.$message({
-                message: "保存成功!",
-                type: "success"
-              });
+          if(!jsonData.success){
+            self.$message({
+              message: jsonData.message + "",
+              type: "warning"
+            });
+          }
 
-              self.$emit("close", true);
-            } else {
-              self.$message({
-                message: jsonData.message + "",
-                type: "warning"
-              });
+          //保存口罩设置
+          return  ehomeApi.putXMLConfig(
+            self.deviceNo,
+            self.maskDetectionUrl,
+            {
+                "MaskDetection": self.maskDetection
             }
-          });
+          )
+        }).then(response=>{
+          self.loading = false;
+          var jsonData = response.data;
+
+          if (jsonData.success) {
+            self.$message({
+              message: "保存成功!",
+              type: "success"
+            });
+
+            self.$emit("close", true);
+          } else {
+            self.$message({
+              message: jsonData.message + "",
+              type: "warning"
+            });
+          }
         });
+      });
     },
   },
   mounted: function() {
@@ -184,6 +231,7 @@ export default {
     
     self.loading = true;
 
+    //获取测温策略
     ehomeApi.getXMLConfig(self.deviceNo,self.cfgUrl)
     .then(response => {
         var jsonData = response.data;
@@ -200,6 +248,24 @@ export default {
     .catch(error => {
         self.$message.error(error + "");
     });
+
+    //获取口罩设置
+    ehomeApi.getXMLConfig(self.deviceNo,self.maskDetectionUrl)
+    .then(response => {
+        var jsonData = response.data;
+        self.loading = false;
+
+        if (jsonData.success) {
+            var data = eval('(' + jsonData.data + ')');
+
+            self.maskDetection = data.MaskDetection;
+        } else {
+            self.$message.error(jsonData.message + "");
+        }
+    })
+    .catch(error => {
+        self.$message.error(error + "");
+    });
   }
 };
 </script>