Authored by FengRuwei

同步更新页面

... ... @@ -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;
}
... ...