From c2a36b585d1f00aa400c761e03d80535a4c7c6cb Mon Sep 17 00:00:00 2001
From: hanbaoshan <hanbaoshan@aiotlink.com>
Date: 星期二, 29 十二月 2020 18:31:33 +0800
Subject: [PATCH] 关联摄像机交互优化

---
 src/pages/panoramicView/components/RelateCamera.vue |   86 +++++++++++++++++++++++++++++++++---------
 1 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/src/pages/panoramicView/components/RelateCamera.vue b/src/pages/panoramicView/components/RelateCamera.vue
index caf3ada..f7dd219 100644
--- a/src/pages/panoramicView/components/RelateCamera.vue
+++ b/src/pages/panoramicView/components/RelateCamera.vue
@@ -58,7 +58,7 @@
         </div>
       </div>
       <div class="relative-list">
-        <div class="relative-item" v-for="item in relativeList" :key="item.id">
+        <div class="relative-item" v-for="(item,index) in relativeList" :key="item.id">
           <div class="left">
             <el-select v-model="item.sourceObj" value-key="polygonId" size="small">
               <el-option
@@ -80,9 +80,18 @@
           </div>
           <div class="right">
             <el-button type="text" @click="saveRelativePolygon(item)">淇濆瓨</el-button>
-            <div class="btn-del" @click="delRelation(item)">
-              <i class="el-icon-delete"></i>
-            </div>
+
+            <el-popconfirm title="纭畾鍒犻櫎璇ラ厤缃悧?" @onConfirm="delRelation(item)" v-if="item.id">
+              <el-button class="btn-del" slot="reference" type="text" icon="el-icon-delete"></el-button>
+            </el-popconfirm>
+            <el-button
+              @click="delRelation(item,index)"
+              class="btn-del"
+              slot="reference"
+              type="text"
+              icon="el-icon-delete"
+              v-else
+            ></el-button>
           </div>
         </div>
       </div>
@@ -170,17 +179,22 @@
     polygonUpdate () {
       this.getAllGroups();
     },
-    delRelation (item) {
+    delRelation (item, index) {
       let _this = this;
-      delRelation(item.id).then(res => {
-        if (res.success) {
-          this.$notify({
-            type: 'success',
-            message: res.data
-          });
-          _this.findRelationByGroup();
-        }
-      })
+      if (item.id) {
+        delRelation(item.id).then(res => {
+          if (res.success) {
+            this.$notify({
+              type: 'success',
+              message: res.data
+            });
+            _this.findRelationByGroup();
+          }
+        })
+      }else{
+        this.relativeList.splice(index,1);
+      }
+
     },
     findRelationByGroup () {
       let _this = this;
@@ -201,6 +215,20 @@
     },
     saveRelativePolygon (item) {
       debugger
+      if (!item.sourceObj || !item.targetObj) {
+        this.$notify({
+          type: 'warning',
+          message: '璇峰畬鍠勫叧鑱斿尯鍩熶俊鎭�!'
+        });
+        return;
+      }
+      if (item.sourceObj.cameraId == item.targetObj.cameraId) {
+        this.$notify({
+          type: 'warning',
+          message: '鐩稿悓鎽勫儚鏈轰笉瀛樺湪鍏宠仈鍖哄煙锛岃閲嶆柊閫夋嫨!'
+        });
+        return;
+      }
       let _this = this;
       let params = {
         groupId: this.curGroup.id,
@@ -282,8 +310,20 @@
         groups[i].cameras = await _this.findPolygonByIds(groups[i].cameras)
       }
       this.groupList = groups;
-      //閫変腑绗竴涓�
-      this.groupList.length && this.checkCurrentGroup(_this.groupList[0]);
+      this.groupList.reverse();
+      //濡傛灉鍒氭柊寤哄垯閫変腑绗竴涓�,缂栬緫鍒欓�変腑缂栬緫鐨勯偅鏉�
+      if (!this.groupForm.id) {
+        this.groupList.length && this.checkCurrentGroup(_this.groupList[0]);
+      } else {
+        let group = this.groupList.find(one => one.id == this.groupForm.id);
+        if(group){
+          this.groupList.length && this.checkCurrentGroup(group);
+        }else{
+          this.groupList.length && this.checkCurrentGroup(_this.groupList[0]);
+        }
+        
+      }
+
 
     },
 
@@ -293,6 +333,7 @@
     },
 
     editGroup (group) {
+      debugger
       this.groupModelVisible = true;
       //this.$refs['groupForm'].resetFields();
       //this.groupForm = group;
@@ -307,8 +348,9 @@
     checkCurrentGroup (group) {
       this.groupList.forEach(group => {
         group.checked = false;
-      })
+      });
       this.curGroup = group;
+      this.groupForm = JSON.parse(JSON.stringify(group));
       this.curGroup.checked = true;
       this.findRelationByGroup();
       //鏌ヨ绗竴涓垎缁勪笅鎽勫儚鏈哄尯鍩�
@@ -371,6 +413,12 @@
       })
       //this.groupList.push(this.groupForm);
       saveCameraGroupInfo(params).then(res => {
+        if(res.success){
+          this.$notify({
+            type: 'success',
+            message: '淇濆瓨鎴愬姛!'
+          })
+        }
         _this.getAllGroups();
       })
       this.groupModelVisible = false;
@@ -441,8 +489,8 @@
       .details {
         display: -webkit-box;
         overflow: hidden;
-        text-overflow:ellipsis;
-        word-break:break-all;
+        text-overflow: ellipsis;
+        word-break: break-all;
         -webkit-box-orient: vertical;
         -webkit-line-clamp: 2;
         //flex-wrap: wrap;

--
Gitblit v1.8.0