Browse Source

事件分类设置BUG

seimin 3 years ago
parent
commit
570d6d6049

+ 18 - 0
assets/js/controllers/system/processdesign/incidentplan/incidentSetUpCtrl.js

@@ -75,10 +75,27 @@ app.controller('incidentSetUp', ["$rootScope", "$scope", "$state", "$timeout", "
75 75
     //   })    
76 76
     // }
77 77
     // $scope.refreshListData();
78
+    $scope.filterTree = function (data,id) {
79
+        data = angular.copy(data);
80
+        var newTree = data.filter(x => x.id !== id)
81
+        newTree.forEach(x => x.children && (x.children = $scope.filterTree(x.children,id)))
82
+        return newTree
83
+    }
78 84
     var childdata = {};
79 85
     $scope.thisParent={};//当前点击节点的父节点
80 86
     $scope.userOrGroupType={};//当前节点运维组/运维人员
87
+    $scope.dataSave = [];//储存$scope.tree_data
81 88
     $scope.my_tree_handler = function(branch) {
89
+        console.log($scope.dataSave)
90
+        if($scope.dataSave.length === 0){
91
+            $scope.dataSave = angular.copy($scope.tree_data);
92
+        }
93
+        console.log(branch)
94
+        if(branch.parent){
95
+            $scope.tree_data = $scope.filterTree($scope.dataSave,branch.id);
96
+            console.log($scope.tree_data,'过滤后');
97
+        }
98
+
82 99
         $scope.changecate = true;
83 100
         $scope.addcate = false;
84 101
         filterData.treeIds = branch.id;
@@ -138,6 +155,7 @@ app.controller('incidentSetUp', ["$rootScope", "$scope", "$state", "$timeout", "
138 155
     };
139 156
    
140 157
     $scope.addType = function(element) {
158
+            $scope.tree_data = angular.copy($scope.dataSave);
141 159
             $scope.addcate = true
142 160
             $scope.changecate = false
143 161
                 // var modalInstance = $modal.open({