MSI\liwei 3 ani în urmă
părinte
comite
9cdbebff07
2 a modificat fișierele cu 48 adăugiri și 56 ștergeri
  1. 11 22
      src/views/qdtl/video/index.vue
  2. 37 34
      src/views/qdtl/video/video.vue

+ 11 - 22
src/views/qdtl/video/index.vue

@@ -11,7 +11,7 @@
                 lazy
                 show-checkbox
                 node-key="id"
-                :default-expanded-keys="[2, 3]"
+                :default-expanded-keys="expandedKeys"
                 :default-checked-keys="[5]"
                 :props="defaultProps"
                 :filter-node-method="filterNode"
@@ -38,6 +38,7 @@ export default {
     data() {
       return {
         videoData:[],
+        expandedKeys:[],
         data: [{
           id: 1,
           label: '一级 1',
@@ -105,23 +106,6 @@ export default {
     },
     methods:{
         loadNode(node, resolve){
-             console.log(node.data.indexCode);
-            //  this.regionIndexCode = node.data.indexCode;
-        //       setTimeout(() => {
-        //       var data;
-        //       if (hasChild) {
-        //         data = [{
-        //           name: 'zone' + this.count++
-        //         }, {
-        //           name: 'zone' + this.count++
-        //         }];
-        //       } else {
-        //         data = [];
-        //       }
-
-        //   resolve(data);
-        // }, 500);
-
         if (node.level > 3) return resolve([]);
         if(node.level <3){
               var childrens = []
@@ -151,7 +135,6 @@ export default {
                         resolve(childerns);
                   });
         }
-          
         },
         getvideo(){
            httpRequest(this.queryParams).then(response => {
@@ -169,11 +152,17 @@ export default {
                     obj.data = obj;
                     this.jsonArry.push(obj);
                     if(obj.parentIndexCode == -1){
-                           this.videoData.push(obj)
+                           this.videoData.push(obj);
+                           this.expandedKeys.push(obj.id);
                     }
+                    // this.expandedKeys.push(obj.id);
+                    if(this.videoData.length > 0){
+                          if(obj.parentIndexCode == this.videoData[0].id){
+                            this.expandedKeys.push(obj.id);
+                          }
+                    }
+                  
                }
-               console.log(this.jsonArry);
-
            });
         },
       getTreeChildren(obj,data){

+ 37 - 34
src/views/qdtl/video/video.vue

@@ -11,7 +11,7 @@
                 lazy
                 show-checkbox
                 node-key="id"
-                :default-expanded-keys="[2, 3]"
+                :default-expanded-keys="expandedKeys"
                 :default-checked-keys="[5]"
                 :props="defaultProps"
                 :filter-node-method="filterNode"
@@ -39,6 +39,7 @@ export default {
     data() {
       return {
         videoData:[],
+        expandedKeys:[],
         data: [{
           id: 1,
           label: '一级 1',
@@ -80,6 +81,7 @@ export default {
         },
         filterText:'',
         ccode:'',
+        jsonArry:[],
         pointIdArry:[],
         regionIndexCode:'',
         queryParams:{
@@ -106,30 +108,22 @@ export default {
     },
     methods:{
         loadNode(node, resolve){
-             console.log(node.data.indexCode);
-            //  this.regionIndexCode = node.data.indexCode;
-        //       setTimeout(() => {
-        //       var data;
-        //       if (hasChild) {
-        //         data = [{
-        //           name: 'zone' + this.count++
-        //         }, {
-        //           name: 'zone' + this.count++
-        //         }];
-        //       } else {
-        //         data = [];
-        //       }
-
-        //   resolve(data);
-        // }, 500);
-
-        if (node.level > 1) return resolve([]);
+        if (node.level > 3) return resolve([]);
+        if(node.level <3){
+              var childrens = []
+              for(var index in this.jsonArry){
+                      if(node.data.id == this.jsonArry[index].parentIndexCode){
+                           childrens.push(this.jsonArry[index]);
+                      }
+              }
+                 resolve(childrens);
+        }
 
-        if(node.level === 1){
+        if(node.level === 3){
              this.videoParams.params = '{"httpMethod":"POST","path":"/api/resource/v1/regions/regionIndexCode/cameras","headers":{},"query":{},"parameter":{},"body":{"pageNo": 1,"pageSize": 200,"regionIndexCode": "'+node.data.indexCode+'"},"contentType":"application/json;charset=UTF-8","mock":false,"appKey":"27794545","appSecret":"5Xi27Gl7JrbHHF1MpdaB"}'
                   httpRequest(this.videoParams).then(data =>{
                         var json = JSON.parse(data.data);
-                        console.log(json);
+                        // console.log(json);
                         var childerns = [];
                         for(var index in json.data.list){
                           // console.log();
@@ -143,25 +137,34 @@ export default {
                         resolve(childerns);
                   });
         }
-          
         },
         getvideo(){
-           httpRequest(this.queryParams).then(response => {
-               console.log(response);
+          httpRequest(this.queryParams).then(response => {
+              //  console.log(response);
                var json = JSON.parse(response.data);
                console.log(json);
                for(var index in json.data.list){
-                  var obj = json.data.list[index]
-                  obj.id = obj.indexCode;
-                  obj.label = obj.name;
-                  obj.data = obj;
-                  this.videoData.push(obj);
-                  // this.regionIndexCode = obj.indexCode;
-                  // httpRequest(this.videoParams).then(data =>{
-                  //        console.log(data);
-                  // });
+                    obj = json.data.list[index]
+                    obj.id = obj.indexCode;
+                    obj.label = obj.name;
+                    obj.data = obj;
+                    var obj = json.data.list[index]
+                    obj.id = obj.indexCode;
+                    obj.label = obj.name;
+                    obj.data = obj;
+                    this.jsonArry.push(obj);
+                    if(obj.parentIndexCode == -1){
+                           this.videoData.push(obj);
+                           this.expandedKeys.push(obj.id);
+                    }
+                    // this.expandedKeys.push(obj.id);
+                    if(this.videoData.length > 0){
+                          if(obj.parentIndexCode == this.videoData[0].id){
+                            this.expandedKeys.push(obj.id);
+                          }
+                    }
+                  
                }
-
            });
         },
        getList() {