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
<template>
  <div class="s-video-manage">
    <el-tabs class="video-tab" v-model="activeName" type="border-card" @tab-click="handleClick">
      <el-tab-pane
        :label="firstLabeName"
        name="camera-info"
        v-if="this.TreeDataPool.treeActiveName == 'camera' && isShow('VIDEOCAMERA:camera:info')"
      >
        <camera-info ref="cameraInfo" />
      </el-tab-pane>
      <el-tab-pane
        :label="firstLabeName"
        name="camera-info"
        v-if="this.TreeDataPool.treeActiveName == 'dataStack' && isShow('VIDEOCAMERA:dataStack:stackInfo')"
      >
        <data-stack-info ref="dataStackInfo" />
      </el-tab-pane>
      <el-tab-pane
        label="独立场景"
        name="separate-rule"
        v-if="this.TreeDataPool.treeActiveName == 'camera' && isShow('VIDEOCAMERA:camera:selfRule')"
      >
        <separate-rules ref="sepRule" />
        <!-- <local-separate ref="localSeparate" v-else></local-separate> -->
      </el-tab-pane>
      <el-tab-pane
        label="独立场景"
        name="separate-rule"
        v-if="this.TreeDataPool.treeActiveName == 'dataStack' && isShow('VIDEOCAMERA:dataStack:selfRule')"
      >
        <separate-rules ref="sepRule" />
        <!-- <local-separate ref="localSeparate" v-else></local-separate> -->
      </el-tab-pane>
      <el-tab-pane
        label="联动场景"
        name="linkage-rule"
        v-if="(isShow('VIDEOCAMERA:camera:linkRule') || isShow('VIDEOCAMERA:dataStack:linkRule')) && this.TreeDataPool.treeActiveName == 'camera'"
      >
        <linkage-rule ref="linkRule" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
 
<script>
import CameraInfo from "../components/CameraInfo";
import DataStackInfo from "../components/DataStackInfo"
import SeparateRules from "../components/SeparateRules";
import LinkageRule from "../components/LinkageRule";
// import fTemplate from "@/components/common/fTemplate";
// import localSeparate from "@/components/camera/localSeparate";
 
//import bus from "@/main";
//import TreeDataPool from "@/Pool/TreeData";
 
export default {
  components: {
    CameraInfo,
    DataStackInfo,
    SeparateRules,
    LinkageRule  },
  data() {
    return {
      activeName: "camera-info",
      buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [],
      intervalTimer: null
    };
  },
  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) {
      if (this.activeName == "camera-info") {
        if (this.TreeDataPool.treeActiveName == 'camera') {
          this.$refs.cameraInfo.selectCamera(node);
        }
      } else if (this.activeName === "separate-rule") {
        this.$refs.sepRule.Camera = {}
        this.$refs.sepRule.initCameraData(node.id);
      }
    },
    "TreeDataPool.selectedNodes": {
      handler(nodes) {
        if (this.activeName == "linkage-rule") {
          this.$refs.linkRule.initCameraData();
        }
      },
      deep: true
    },
    "DataStackPool.selectedDir": {
      handler(node, oldNode) {
        console.log(this.activeName)
        console.log(node, '勾选本地视频')
        if (this.TreeDataPool.treeActiveName !== 'dataStack') {
          return
        }
        this.$nextTick(() => {
          if (this.activeName == "camera-info") {
            console.log("dataStackInfo.selectDir(node)")
            this.$refs.dataStackInfo.selectDir(node);
          } else if (this.activeName == "separate-rule" && node.length !== 0) {
            this.$refs.sepRule.initCameraData(node.id);
          }
        })
      },
      deep: true
    }
  },
  created() {
    if (this.TreeDataPool.treeActiveName == 'camera') {
      if (this.isShow('VIDEOCAMERA:camera:info')) {
        this.activeName = "camera-info"
      } else if (this.isShow('VIDEOCAMERA:camera:selfRule') || this.isShow('VIDEOCAMERA:datastack:selfRule')) {
        this.activeName = "separate-rule"
      } else if (this.isShow('VIDEOCAMERA:camera:linkRule') || this.isShow('VIDEOCAMERA:datastack:linkRule')) {
        this.activeName = "linkage-rule"
      } else if (this.isShow('VIDEOCAMERA:camera:resourceCalc') || this.isShow('VIDEOCAMERA:datastack:resourceCalc')) {
        this.activeName = "poll-setting"
      }
    } else {
      if (this.isShow('VIDEOCAMERA:camera:info')) {
        this.activeName = "camera-info"
      } else if (this.isShow('VIDEOCAMERA:camera:selfRule') || this.isShow('VIDEOCAMERA:datastack:selfRule')) {
        this.activeName = "separate-rule"
      } else if (this.isShow('VIDEOCAMERA:camera:linkRule') || this.isShow('VIDEOCAMERA:datastack:linkRule')) {
        this.activeName = "linkage-rule"
      } else if (this.isShow('VIDEOCAMERA:camera:resourceCalc') || this.isShow('VIDEOCAMERA:datastack:resourceCalc')) {
        this.activeName = "poll-setting"
      }
    }
    this.TreeDataPool.readonly = true;
    this.TreeDataPool.gbReadonly = true;
    this.TreeDataPool.multiple = false;
    this.TreeDataPool.selectedNode = "";
    this.selectedNodes = [];
    this.VideoManageData.init();
  },
  beforeDestroy() {
    clearInterval(this.intervalTimer);
    //this.TreeDataPool.treeActiveName = "camera";
  },
  mounted() {
    this.$nextTick(() => {
      //   bus.$on("addCameraOnTree", node => {
      //     this.handAddDevice(node);
      //   });
      //   bus.$on("addDirOnTree", node => {
      //     this.handAddDIr(node);
      //   });
      //   this.TreeDataPool.clean();
    });
 
    let _this = this
    this.intervalTimer = setInterval(() => {
      _this.PollData.statisticTaskInfo();
    }, 10000)
  },
  methods: {
    isShow(authority) {
      if (this.isAdmin) {
        return true;
      } else if (this.buttonAuthority.indexOf("," + authority + ",") > -1) {
        return true;
      } else if ("videoCamera:pollSetting" === authority) {
        return true;
      } else {
        return false;
      }
    },
    handAddDevice(node) {
      let _this = this;
      setTimeout(() => {
        _this.$refs.cameraInfo.addDevice(node);
        _this.activeName = "camera-info";
      }, 100);
    },
    handAddDIr(node) {
      let _this = this;
      setTimeout(() => {
        _this.$refs.dataStackInfo.addDir(node);
        _this.activeName = "camera-info";
      }, 100);
    },
    handleClick(tab, event) {
      this.TreeDataPool.multiple = tab.name === "linkage-rule";
      if (tab.name === "camera-info") {
        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") {
        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();
        })
      }
    }
  }
};
</script>
<style lang="scss">
.s-video-manage {
  width: 100%;
  height: 100%;
  float: right;
  box-sizing: border-box;
  .el-tabs--border-card {
    box-shadow: none;
    -webkit-box-shadow: none;
    border: none;
  }
  // .s-video-manage-breadcrumb {
  //   height: 5%;
  //   -webkit-box-sizing: border-box;
  //   border: 1px solid #e4e7ed;
  //   -webkit-box-shadow: #e4e7ed 0px 0px 9px inset;
  //   box-shadow: #e4e7ed 0px 0px 9px inset;
  //   border-radius: 5px;
  // }
  .el-tabs--border-card {
    height: 100%;
    width: 100%;
    &.video-tab{
      &>.el-tabs__header{
        position: fixed;
        top:0;
        width:100%;
        z-index:9;
      }
    }
    .el-tabs__header {
       
      .is-active {
        color: #3d68e1 !important;
      }
      .el-tabs__item:not(.is-disabled):hover {
        color: #3d68e1 !important;
      }
      height: 52px;
      border-bottom: none;
      background-color: #f8f9fb;
      .el-tabs__nav-wrap,
      .el-tabs__nav-scroll,
      .el-tabs__nav,
      .el-tabs__item {
        height: calc(100% + 1px);
      }
      .el-tabs__item {
        line-height: 52px;
        width: 144px;
        border-right-color: transparent;
        border-left-color: transparent;
        font-family: PingFangSC-Medium;
        font-size: 14px;
        color: #222222;
      }
    }
  }
  .el-tabs__content {
    width: 100%;
    margin-top: 52px;
    //height: calc(100% - 52px);
    box-sizing: border-box;
    padding: 13px 0;
  }
  .el-tab-pane {
    width: 100%;
    height: 100%;
  }
}
</style>