ZZJ
2022-03-25 52ad37fba37a1ae72f124106627227a09836be5b
src/views/hashrate/CameraManage/index.vue
File was renamed from src/views/hashrate/components/CameraManage.vue
@@ -19,14 +19,14 @@
          <div
            class="tab"
            :class="{ active: activeTab === '信息维护' }"
            @click="activeTab = '信息维护'"
            @click="handleClick('信息维护')"
          >
            信息维护
          </div>
          <div
            class="tab"
            :class="{ active: activeTab === '场景配置' }"
            @click="activeTab = '场景配置'"
            @click="handleClick('场景配置')"
          >
            场景配置
          </div>
@@ -34,22 +34,28 @@
        <CameraInfo
          ref="cameraInfo"
          v-if="activeTab === '信息维护'"
          v-show="activeTab === '信息维护'"
        ></CameraInfo>
        <CameraRules
          v-show="activeTab === '场景配置'"
          ref="sepRule"
        ></CameraRules>
      </div>
    </div>
  </div>
</template>
<script>
import CameraLeft from "@/views/hashrate/components/CameraLeft";
import CameraInfo from "@/views/hashrate/components/CameraInfo";
import CameraLeft from "@/components/CameraLeft";
import CameraInfo from "./CameraInfo";
import CameraRules from "./CameraRules";
import bus from "@/plugin/bus";
export default {
  components: {
    CameraLeft,
    CameraInfo,
    CameraRules,
  },
  data() {
@@ -66,58 +72,30 @@
        },
      ],
      cluster: "",
      activeName: "camera-info",
      buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [],
      intervalTimer: null,
      leftWith: 0,
      screenHeight: 0,
    };
  },
  destroyed() {
    this.TreeDataPool.readonly = true;
  },
  computed: {
    isAdmin() {
      if (
        sessionStorage.getItem("userInfo") &&
        sessionStorage.getItem("userInfo") !== ""
      ) {
        let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username;
        return loginName === "superadmin" || loginName === "basic";
      }
      return false;
    },
    firstLabeName() {
      return this.TreeDataPool.treeActiveName === "camera"
        ? "摄像机信息"
        : "数据栈信息";
    },
  },
  watch: {
    // 数据栈不显示联动规则,防止在选中联动规则tab中切换到数据栈
    "TreeDataPool.treeActiveName": function (val) {
      if (val === "dataStack" && this.activeName === "linkage-rule") {
        this.activeName = "camera-info";
      }
    },
    "TreeDataPool.selectedNode": function (node) {
      console.log("00000000000000");
      if (this.activeName == "camera-info") {
        console.log("111111111111111");
      if (this.activeTab == "信息维护") {
        if (this.TreeDataPool.treeActiveName == "camera") {
          console.log("2222222222222");
          this.$refs.cameraInfo.selectCamera(node);
        }
      } else if (this.activeName === "separate-rule") {
        this.$refs.sepRule.Camera = {};
      } else if (this.activeTab === "场景配置") {
        this.$refs.sepRule.initCameraData(node.id);
      }
    },
    "TreeDataPool.selectedNodes": {
      handler(nodes) {
        if (this.activeName == "linkage-rule") {
          this.$refs.linkRule.initCameraData();
        if (this.activeTab == "场景配置") {
          // this.$refs.sepRule.initCameraData();
        }
      },
      deep: true,
@@ -128,9 +106,9 @@
          return;
        }
        this.$nextTick(() => {
          if (this.activeName == "camera-info") {
            this.$refs.dataStackInfo.selectDir(node);
          } else if (this.activeName == "separate-rule" && node.length !== 0) {
          if (this.activeTab == "信息维护") {
            //   this.$refs.dataStackInfo.selectDir(node);
          } else if (this.activeTab == "场景配置" && node.length !== 0) {
            this.$refs.sepRule.initCameraData(node.id);
          }
        });
@@ -141,22 +119,6 @@
  created() {
    this.PollData.statistics();
    this.TreeDataPool.readonly = false;
    if (this.TreeDataPool.treeActiveName == "camera") {
      if (this.isShow("cameraAccess:cameraInfo")) {
        this.activeName = "camera-info";
      } else if (this.isShow("cameraAccess:selfRule")) {
        this.activeName = "separate-rule";
      } else if (this.isShow("cameraAccess:linkRule")) {
        this.activeName = "linkage-rule";
      }
    } else {
      if (this.isShow("dataStack:cameraInfo")) {
        this.activeName = "camera-info";
      } else if (this.isShow("dataStack:selfRule")) {
        this.activeName = "separate-rule";
      }
    }
    //  this.TreeDataPool.readonly = true;
    //this.TreeDataPool.gbReadonly = true;
@@ -187,46 +149,36 @@
    }, 10000);
  },
  methods: {
    isShow(authority) {
      return (
        this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1
      );
    },
    handAddDevice(node) {
      let _this = this;
      setTimeout(() => {
        _this.$refs.cameraInfo.addDevice(node);
        _this.activeName = "camera-info";
        _this.activeTab = "信息维护";
      }, 100);
    },
    handAddDIr(node) {
      let _this = this;
      setTimeout(() => {
        _this.$refs.dataStackInfo.addDir(node);
        _this.activeName = "camera-info";
        _this.activeTab = "信息维护";
      }, 100);
    },
    handleClick(tab, event) {
      console.log(this.TreeDataPool);
      this.TreeDataPool.multiple = tab.name === "linkage-rule";
      if (tab.name === "camera-info") {
    handleClick(tab) {
      //这个控制是否多选
      //    this.TreeDataPool.multiple = tab.name === "场景配置";
      this.activeTab = tab;
      if (tab === "信息维护") {
        if (this.TreeDataPool.treeActiveName == "camera") {
          this.$refs.cameraInfo.selectCamera(this.TreeDataPool.selectedNode);
        } else if (this.TreeDataPool.treeActiveName == "dataStack") {
          this.$refs.dataStackInfo.selectDir(this.DataStackPool.selectedDir);
        }
      } else if (tab.name === "separate-rule") {
      } else if (tab === "场景配置") {
        if (this.TreeDataPool.treeActiveName == "camera") {
          this.$refs.sepRule.initCameraData(this.TreeDataPool.selectedNode.id);
        } else if (this.TreeDataPool.treeActiveName == "dataStack") {
          this.$refs.sepRule.initCameraData(this.DataStackPool.selectedDir.id);
        }
      } else if (this.activeName == "linkage-rule") {
        this.$refs.linkRule.initCameraData();
      } else if (this.activeName == "poll-setting") {
        this.$nextTick(() => {
          this.$refs.pullSetting.initLineChart();
        });
      }
    },
  },
@@ -279,6 +231,7 @@
  }
  .content {
    box-sizing: border-box;
    margin-bottom: 60px;
    display: flex;
    align-items: stretch;