Showing
1 changed file
with
28 additions
and
9 deletions
@@ -102,13 +102,18 @@ var addMObjType = function (nodeid, name) { | @@ -102,13 +102,18 @@ var addMObjType = function (nodeid, name) { | ||
102 | var doAddType = function () { | 102 | var doAddType = function () { |
103 | var pid = $('#tx_type_id').val(); | 103 | var pid = $('#tx_type_id').val(); |
104 | var name = $('#tx_new_type_name').val(); | 104 | var name = $('#tx_new_type_name').val(); |
105 | - var isleaf = 1; | 105 | + var isleaf = $('#cb_new_type_isleaf').prop("checked") == true ? 1 : 0; |
106 | $.get("type/add", {"pid": pid, "name": name, "isleaf": isleaf}, | 106 | $.get("type/add", {"pid": pid, "name": name, "isleaf": isleaf}, |
107 | function (data, state) { | 107 | function (data, state) { |
108 | - $.toaster('添加成功', '添加', 'info'); | ||
109 | - refreshTypeTree(); | 108 | + if (state == "success" && data.code == 200) { |
109 | + $.toaster('添加成功', '提示', 'info'); | ||
110 | + refreshTypeTree(); | ||
111 | + } else | ||
112 | + $.toaster('添加失败' + data.code, '提示', 'warning'); | ||
110 | } | 113 | } |
111 | - ); | 114 | + ).fail(function () { |
115 | + $.toaster('添加失败:', '提示', 'warning'); | ||
116 | + }); | ||
112 | } | 117 | } |
113 | var doUpdateType = function () { | 118 | var doUpdateType = function () { |
114 | var id = $('#tx_type_id').val(); | 119 | var id = $('#tx_type_id').val(); |
@@ -119,7 +124,9 @@ var doUpdateType = function () { | @@ -119,7 +124,9 @@ var doUpdateType = function () { | ||
119 | $.toaster('更新成功', '更新', 'info'); | 124 | $.toaster('更新成功', '更新', 'info'); |
120 | refreshTypeTree(); | 125 | refreshTypeTree(); |
121 | } | 126 | } |
122 | - ); | 127 | + ).fail(function () { |
128 | + $.toaster('更新失败:', '提示', 'warning'); | ||
129 | + });; | ||
123 | } | 130 | } |
124 | var doDelType = function () { | 131 | var doDelType = function () { |
125 | var id = $('#tx_type_id').val(); | 132 | var id = $('#tx_type_id').val(); |
@@ -128,7 +135,9 @@ var doDelType = function () { | @@ -128,7 +135,9 @@ var doDelType = function () { | ||
128 | function (data, state) { | 135 | function (data, state) { |
129 | $('#jstree').jstree("delete_node", $("#" + id)); | 136 | $('#jstree').jstree("delete_node", $("#" + id)); |
130 | } | 137 | } |
131 | - ); | 138 | + ).fail(function () { |
139 | + $.toaster('删除失败:', '提示', 'warning'); | ||
140 | + });; | ||
132 | } | 141 | } |
133 | 142 | ||
134 | 143 | ||
@@ -216,9 +225,11 @@ $(function () { | @@ -216,9 +225,11 @@ $(function () { | ||
216 | "action": function (obj) { | 225 | "action": function (obj) { |
217 | var inst = jQuery.jstree.reference(obj.reference); | 226 | var inst = jQuery.jstree.reference(obj.reference); |
218 | var clickedNode = inst.get_node(obj.reference); | 227 | var clickedNode = inst.get_node(obj.reference); |
219 | - console.log(obj); | ||
220 | - console.log(clickedNode); | ||
221 | - console.log("add operation--clickedNode's id is:" + clickedNode.id); | 228 | + console.log("add operation--clickedNode's id is:" + clickedNode.id + " " + clickedNode); |
229 | + if (clickedNode.data != 0) { | ||
230 | + $.toaster('叶子节点无法添加子类型', '提示', 'info'); | ||
231 | + return; | ||
232 | + } | ||
222 | addType(clickedNode); | 233 | addType(clickedNode); |
223 | } | 234 | } |
224 | }, "UPDATE": { | 235 | }, "UPDATE": { |
@@ -234,6 +245,10 @@ $(function () { | @@ -234,6 +245,10 @@ $(function () { | ||
234 | var inst = jQuery.jstree.reference(obj.reference); | 245 | var inst = jQuery.jstree.reference(obj.reference); |
235 | var clickedNode = inst.get_node(obj.reference); | 246 | var clickedNode = inst.get_node(obj.reference); |
236 | console.log("del operation--clickedNode's id is:" + clickedNode.id); | 247 | console.log("del operation--clickedNode's id is:" + clickedNode.id); |
248 | + if (clickedNode.chindlen.size() > 0) { | ||
249 | + $.toaster('无法直接删除还有子类型的节点', '提示', 'info'); | ||
250 | + return; | ||
251 | + } | ||
237 | delType(clickedNode.id); | 252 | delType(clickedNode.id); |
238 | } | 253 | } |
239 | }, "ADDM": { | 254 | }, "ADDM": { |
@@ -242,6 +257,10 @@ $(function () { | @@ -242,6 +257,10 @@ $(function () { | ||
242 | var inst = jQuery.jstree.reference(obj.reference); | 257 | var inst = jQuery.jstree.reference(obj.reference); |
243 | var clickedNode = inst.get_node(obj.reference); | 258 | var clickedNode = inst.get_node(obj.reference); |
244 | console.log("add minfo--clickedNode's id is : " + clickedNode.id); | 259 | console.log("add minfo--clickedNode's id is : " + clickedNode.id); |
260 | + if (clickedNode.data != 1) { | ||
261 | + $.toaster('非叶子节点无法添加子类型', '提示', 'info'); | ||
262 | + return; | ||
263 | + } | ||
245 | addMObjType(clickedNode.id, clickedNode.text); | 264 | addMObjType(clickedNode.id, clickedNode.text); |
246 | } | 265 | } |
247 | } | 266 | } |
-
Please register or login to post a comment