From 0175cda6150656bc74b34c6f6c71edd1e1fc653c Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期四, 04 二月 2021 18:22:54 +0800
Subject: [PATCH] treee, 修复tab切换时树的选中状态.添加区域

---
 src/pages/shuohuangMonitorAnalyze/components/videoAnalyze.vue |   80 ++++++++++++++++++++++++++-------------
 1 files changed, 53 insertions(+), 27 deletions(-)

diff --git a/src/pages/shuohuangMonitorAnalyze/components/videoAnalyze.vue b/src/pages/shuohuangMonitorAnalyze/components/videoAnalyze.vue
index 33cca4f..5cba441 100644
--- a/src/pages/shuohuangMonitorAnalyze/components/videoAnalyze.vue
+++ b/src/pages/shuohuangMonitorAnalyze/components/videoAnalyze.vue
@@ -58,6 +58,7 @@
               :ref="`gridVideoItem_${index}`"
               v-for="(item,index) in videoWrapArr"
               :key="index"
+              @click="checkCurVideo(index)"
             >
               <template v-if="index<=videoArrs.length-1">
                 <div :class="{'currentPlayer':curVideo.ID==videoArrs[index].ID}">
@@ -96,7 +97,7 @@
             <el-radio :label="0">鏃犲紓甯�</el-radio>
             <el-radio :label="1">鏈夊紓甯�</el-radio>
           </el-radio-group>
-          
+
           <el-button
             icon="el-icon-plus"
             size="mini"
@@ -203,15 +204,15 @@
     }
   },
   watch: {
-    'curVideo.LableLst':{
-      handler(n,o){
-        if(n.length>0){
+    'curVideo.LableLst': {
+      handler (n, o) {
+        if (n.length > 0) {
           this.isUnusual = 1
-        }else{
+        } else {
           this.isUnusual = 0
         }
       },
-      deep:true
+      deep: true
     },
     videoDetails: {
       handler (newVal, oldVal) {
@@ -221,16 +222,22 @@
     },
   },
   mounted () {
+    console.log('analyze mount')
     this.renderLabelOpts();
     this.setGuid(1);
     this.getVideos(this.videoDetails);
   },
   methods: {
+    checkCurVideo (index) {
+      if (this.relativeVideos[index]) {
+        this.curVideo = this.relativeVideos[index];
+        this.refreshCurVideoLabel(this.curVideo);
+      }
+    },
     getVideos (video) {
       let _this = this;
       getRelatedVideoInfo({ UniqeID: video.UniqeID }).then(res => {
         console.log(res)
-        
         res.data.forEach(element => {
           element.marks = _this.mergeMarks(element)
           console.log(element.marks)
@@ -238,7 +245,9 @@
         _this.curVideo = res.data[0];
         _this.videoArrs = res.data;
         _this.relativeVideos = res.data;
-        debugger
+        this.$nextTick(() => {
+          _this.$refs[`player_${_this.curVideo.ID}`][0].init();
+        })
 
       })
     },
@@ -248,11 +257,24 @@
         _this.labelOptions = res.data
       })
     },
+    refreshCurVideoLabel (video) {
+      getRelatedVideoInfo({ UniqeID: video.UniqeID }).then(res => {
+        res.data.forEach(d => {
+          if(d.ID === video.ID){
+            video.LableLst = d.LableLst
+          }
+          // let someVideo = _this.videoArrs.find(video => video.ID === d.ID);
+          // someVideo.LableLst = d.LableLst
+        })
+      })
+    },
     checkVideo (video, index) {
+      this.refreshCurVideoLabel(video);
       this.curVideo = video;
-      if (index > 0 && this.guid == 1) {
-        //this.videoWrapArr = 
-      }
+      this.$nextTick(() => {
+        this.$refs[`player_${this.curVideo.ID}`][0].init();
+      })
+
     },
 
     setGuid (guid) {
@@ -266,12 +288,10 @@
       //     }
       // }
       this.videoWrapArr = Math.pow(guid, 2);
-
       this.$nextTick(() => {
         for (var i = 0; i < Math.pow(guid, 2); i++) {
           this.$refs[`gridVideoItem_${i}`][0].style.width = this.$refs['playerWrap'].offsetWidth / guid + 'px';
           this.$refs[`gridVideoItem_${i}`][0].style.height = this.$refs['playerWrap'].offsetHeight / guid + 'px';
-
         }
       })
     },
@@ -292,28 +312,32 @@
           }
         }
       })
-      
+
       let query = {
         ID: this.selectedLabelId,
         ParentID: this.isCheckAllVideo ? tempArr.join(',') : this.curVideo.ID + '',
         Time: Math.round(this.setLabelTime) + '',
         Codes: this.labelCheckedList.join(','),
-        Desc: desc.join(',')
+        Desc: desc.join('锛�')
       };
       editLabel(query).then(rsp => {
         if (rsp && rsp.success) {
           _this.labelDialogVisible = false;
-
-          _this.videoArrs.forEach(video=>{
-            video.LableLst = []
-          });
+          this.$set(_this.curVideo,'LableLst',[]);
+          //_this.curVideo.LableLst = [];
           rsp.data.forEach(label=>{
-            let someVideo = _this.videoArrs.find(video=>video.ID === label.ParentID);
-            someVideo.LableLst.push(label);
+            if(label.ParentID == _this.curVideo.ID){
+               _this.curVideo.LableLst.push(label)
+            }
           })
-          _this.curVideo.LableLst = rsp.data;
-          this.$message.success("娣诲姞鎴愬姛")
+          // getRelatedVideoInfo({ UniqeID: _this.videoDetails.UniqeID }).then(res => {
+          //   res.data.forEach(d => {
+          //     let someVideo = _this.videoArrs.find(video => video.ID === d.ID);
+          //     someVideo.LableLst = d.LableLst
+          //   })
+          // })
 
+          this.$message.success("娣诲姞鎴愬姛")
           // 鏍囨敞
           _this.setMarks(this.curVideo)
         } else {
@@ -331,16 +355,18 @@
     },
     editCurLabel (mark) {
       this.selectedLabelId = mark.ID;
-      this.labelCheckedList = mark.Codes.split(",");
+      this.labelCheckedList = mark.Codes.split(" ,");
       this.labelDialogVisible = true;
     },
     removeCurLabel (mark) {
+      let _this = this;
       delLabel({ ID: mark.ID, ParentID: this.curVideo.ID }).then(rsp => {
         if (rsp && rsp.success) {
-          this.curVideo.LableLst = rsp.data;
+          _this.curVideo.LableLst = rsp.data;
           this.$message.success("鍒犻櫎鎴愬姛")
           // 鏍囨敞
-          this.setMarks(this.curVideo)
+          debugger
+          _this.setMarks(_this.curVideo)
         } else {
           this.$message.warning(rsp.msg)
         }
@@ -456,7 +482,7 @@
           }
         }
       }
-      .fixed-height-box{
+      .fixed-height-box {
         height: 200px;
         overflow-y: auto;
       }

--
Gitblit v1.8.0