From d4abee757fcbe3dd679b9e10fdc2448b4481e443 Mon Sep 17 00:00:00 2001
From: FengRuwei <fruwei@163.com>
Date: Fri, 17 Jun 2016 13:32:22 +0800
Subject: [PATCH] 同步更新页面

---
 monitor-ui-web/src/main/webapp/script/yoho.type.tree.js | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/monitor-ui-web/src/main/webapp/script/yoho.type.tree.js b/monitor-ui-web/src/main/webapp/script/yoho.type.tree.js
index 9c10557..9f9dfe3 100644
--- a/monitor-ui-web/src/main/webapp/script/yoho.type.tree.js
+++ b/monitor-ui-web/src/main/webapp/script/yoho.type.tree.js
@@ -105,11 +105,21 @@ var doAddType = function () {
     var isleaf = $('#cb_new_type_isleaf').prop("checked") == true ? 1 : 0;
     $.get("type/add", {"pid": pid, "name": name, "isleaf": isleaf},
         function (data, state) {
-            if (state == "success" && data.code == 200) {
+            var repjson = JSON.parse(data);
+            if (state == "success" && repjson.code == 200) {
                 $.toaster('添加成功', '提示', 'info');
-                refreshTypeTree();
+                console.log(repjson.data);
+                var newNode = repjson.data;
+                $('#jstree').jstree().create_node("#node_" + newNode.typeParentId,
+                    {
+                        'id': "node_" + newNode.typeId,
+                        'text': newNode.typeName,
+                        'parent': "#node_" + newNode.typeParentId,
+                        'data':newNode.typeIsLeaf
+                    }
+                    , 'last');
             } else
-                $.toaster('添加失败' + data.code, '提示', 'warning');
+                $.toaster('添加失败' + repjson.code, '提示', 'warning');
         }
     ).fail(function () {
             $.toaster('添加失败:', '提示', 'warning');
@@ -122,11 +132,12 @@ var doUpdateType = function () {
     $.get("type/update", {"id": id, "name": name},
         function (data, state) {
             $.toaster('更新成功', '更新', 'info');
-            refreshTypeTree();
+            $("#jstree").jstree('set_text', '#node_' + id, name);
         }
     ).fail(function () {
             $.toaster('更新失败:', '提示', 'warning');
-        });;
+        });
+    ;
 }
 var doDelType = function () {
     var id = $('#tx_type_id').val();
@@ -137,7 +148,8 @@ var doDelType = function () {
         }
     ).fail(function () {
             $.toaster('删除失败:', '提示', 'warning');
-        });;
+        });
+    ;
 }
 
 
@@ -212,6 +224,7 @@ $(function () {
         "plugins": ["themes", "checkbox", "contextmenu", "ui", "types", "crrm", "core", "status"],
         'core': {
             "themes": {
+                "theme": "proton",
                 "icons": false
             },
             'data': treeData,
@@ -245,7 +258,8 @@ $(function () {
                         var inst = jQuery.jstree.reference(obj.reference);
                         var clickedNode = inst.get_node(obj.reference);
                         console.log("del operation--clickedNode's id is:" + clickedNode.id);
-                        if (clickedNode.chindlen.size() > 0) {
+                        console.log(clickedNode.children);
+                        if (clickedNode.children.length > 0) {
                             $.toaster('无法直接删除还有子类型的节点', '提示', 'info');
                             return;
                         }
--
libgit2 0.24.0