From a3f357e8a60443b74b64c7479113c68eb35ce1f5 Mon Sep 17 00:00:00 2001
From: ZZJ <10913410+zzj2100@user.noreply.gitee.com>
Date: 星期五, 15 七月 2022 19:44:57 +0800
Subject: [PATCH] 控制轮询

---
 src/pages/cameraAccess/components/SeparateRules.vue |  101 ++++++++++++++++++++++----------------------------
 1 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/src/pages/cameraAccess/components/SeparateRules.vue b/src/pages/cameraAccess/components/SeparateRules.vue
index 61eff5d..fe51cc4 100644
--- a/src/pages/cameraAccess/components/SeparateRules.vue
+++ b/src/pages/cameraAccess/components/SeparateRules.vue
@@ -2,7 +2,7 @@
   <div class="s-separate-rules">
     <div class="ai">
       <div class="check-area">
-        <div class="ai-select">
+        <div class="ai-select" v-if="TreeDataPool.selectedNode.type !== 'MENU'">
           <div v-show="cameraType === 'camera'">
             <span>
               <span class="label">瑙嗛鍒嗘瀽澶勭悊</span>
@@ -16,7 +16,7 @@
           </div>
 
           <div
-            v-if="Camera.analytics"
+            v-if="Camera.analytics && isShowPolling === 'show'"
             class="flex-box"
             v-show="cameraType === 'camera'"
           >
@@ -34,7 +34,13 @@
               @change="changePoll"
             />
           </div>
-
+          <div
+            v-if="Camera.analytics"
+            class="flex-box"
+            v-show="cameraType === 'camera'"
+          >
+            <span class="label">澶勭悊鐘舵��: {{ camStatus }}</span>
+          </div>
           <div
             v-if="Camera.analytics"
             class="flex-box"
@@ -154,6 +160,7 @@
                   :loading="Camera.loading"
                   :canvasWidth="canvasWidth"
                   :canvasHeight="canvasHeight"
+                  :isGB28181="Camera.gb28181"
                   @fromCanvas="getCanvasData"
                   @changeLoading="changeLoading"
                   @refresh="refresh"
@@ -256,7 +263,7 @@
 import { savePolygon } from "@/api/polygon";
 
 import { pasteRules } from "@/api/task";
-
+import { getCameraInfo } from "@/api/camera";
 import { saveCameraScene } from "@/api/scene";
 
 import { changeRunType } from "@/api/pollConfig";
@@ -293,6 +300,7 @@
   },
   data() {
     return {
+      isShowPolling: sessionStorage.getItem("isShowPolling"),
       mockSceneData: [],
       loading: false,
       Camera: new VideoRuleData(),
@@ -309,20 +317,8 @@
           prevEl: ".swiper-local-prev",
         },
       },
-      // swiperOption: {
-      //   slidesPerView: 5,
-      //   spaceBetween: 8,
-      //   pagination: {
-      //     el: ".swiper-pagination",
-      //     clickable: true
-      //   },
-      //   navigation: {
-      //     nextEl: ".swiper-next-border",
-      //     prevEl: ".swiper-pre-border"
-      //   }
-      // },
       tableRuleList: [],
-
+      camStatus: "",
       cameraId: "",
       showSysInfo: false,
       showCanvas: true,
@@ -336,7 +332,6 @@
     };
   },
   mounted() {
-    this.mockAsync();
     this.PollData.statistics();
   },
   watch: {
@@ -357,6 +352,29 @@
     },
   },
   methods: {
+    getStatus() {
+      getCameraInfo(this.Camera.cameraId).then((res) => {
+        if (res.success) {
+          switch (res.data.status) {
+            case 0:
+              this.camStatus = "鏈厤瑙勫垯";
+              return;
+            case 1:
+              this.camStatus = "绛夊緟杞澶勭悊";
+              return;
+            case 2:
+              this.camStatus = "姝e湪鎵ц鍒嗘瀽澶勭悊";
+              return;
+            case -1:
+              this.camStatus = "鍏朵粬鎯呭喌瀵艰嚧鏈鐞�";
+              return;
+            case -2:
+              this.camStatus = "鏁呴殰瀵艰嚧鏈鐞�";
+              return;
+          }
+        }
+      });
+    },
     prevClick() {
       if (this.swiperIndex == 0) {
         if (this.stackFilesPage > 1) {
@@ -430,41 +448,14 @@
     swiperSlideChange() {
       this.swiperIndex = this.$refs.swiper.swiper.activeIndex;
     },
-    mockAsync() {
-      setTimeout(() => {
-        this.mockSceneData = [
-          {
-            scenename: "name1",
-            id: 1,
-            icon: ["iconrenlianjiance", "icongetijingzhi"],
-          },
-          { scenename: "name2", id: 2, icon: ["iconchouyan-copy"] },
-          {
-            scenename: "name3",
-            id: 3,
-            icon: [
-              "iconrenshukouzhao",
-              "iconchouyan-copy",
-              "iconrenlianjiance",
-              "icongetijingzhi",
-            ],
-          },
-          {
-            scenename: "name4",
-            id: 4,
-            icon: ["iconchouyan-copy", "iconrenlianjiance", "icongetijingzhi"],
-          },
-          { scenename: "name5", id: 5, icon: ["icongetijingzhi"] },
-          {
-            scenename: "name6",
-            id: 6,
-            icon: ["iconrenshukouzhao", "icongetijingzhi"],
-          },
-          { scenename: "name7", id: 7, icon: ["iconrenlianjiance"] },
-        ];
-      }, 3000);
-    },
     drawBaseImg() {
+      if (!this.Camera.cameraId) {
+        this.$notify({
+          type: "warning",
+          message: "璇峰厛閫夋嫨鎽勫儚鏈�",
+        });
+        return;
+      }
       if (Array.isArray(this.$refs.canvas)) {
         if (this.$refs.canvas.length > 0) {
           this.$refs.canvas[0].showModal();
@@ -488,12 +479,10 @@
     async initCameraData(id, type) {
       this.Camera = new VideoRuleData();
 
-      console.log("121212");
-      console.log(type);
-
       if (id && id !== "") {
         this.loading = false;
         this.Camera.cameraId = id;
+        this.Camera.gb28181 = type === 1;
         if (type === 1) {
           await this.Camera.update(true);
         } else {
@@ -550,11 +539,11 @@
         val = -1;
       }
       if (this.Camera.cameraId && this.Camera.cameraId !== undefined) {
-        debugger;
         changeRunType({
           camera_ids: [this.Camera.cameraId],
           run_type: val,
         }).then((rsp) => {
+          this.getStatus();
           if (rsp && rsp.success) {
             this.$notify({
               type: "success",

--
Gitblit v1.8.0