[Frontend][圖資管理] jsTree新增 node 程序調整

This commit is contained in:
dev01 2022-12-14 09:54:29 +08:00
parent ff31936174
commit 909f528e11
2 changed files with 35 additions and 29 deletions

View File

@ -338,7 +338,7 @@
treeEvent();
let option = {
core: {
check_callback: true,
"check_callback": true,
data: data,
themes: {
name: "default-dark"
@ -347,11 +347,11 @@
types: {
default: {
max_depth: 3,
valid_children: "default",
/*valid_children: "default",*/
icon: "fas fa-folder text-warning"
},
},
plugins: ["themes", "contextmenu", "sort", "search", "types"],
plugins: ["themes", "contextmenu", "sort", "conditionalselect", "search", "types"],
search: {
case_insensitive: true,
@ -368,12 +368,14 @@
if (depth >= 3) {
return true; //第五層後無法新增
}
return false;
},
action: function (obj) {
$node = tree.create_node($node, { text: '新類別', type: 'default' });
tree.deselect_all();
tree.select_node($node);
tree.edit($node);
}
},
Rename: {
@ -404,7 +406,7 @@
$('#graTree').jstree(true).select_node(topNode.children[0]);
})
$('#graTree').on("select_node.jstree", function (e, data) {
dtAjaxResetSendData(graTable, { layer_id: parseInt(data.node.id)});
dtAjaxResetSendData(graTable, { layer_id: parseInt(data.node.id) });
graTable.ajax.reload();
let names = [];
@ -429,9 +431,12 @@
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/SaveVar", objSendData, function (res) {
if (!res || res.code != "0000") {
data.instance.delete_node(data.node);
toast_error(res.msg || common.SysErr);
} else {
data.instance.set_id(data.node, res.data);
}
}, null, "POST").send();
@ -445,10 +450,10 @@
objSendData.Data = main;
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/EditVar", objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
toast_error(res.msg || common.SysErr);
} else {
getGraCatList((graCatData) => {
data.settings.core.data = graCatData;
data.instance.settings.core.data = graCatData;
data.instance.refresh(true);
})
}
@ -457,11 +462,12 @@
});
$("#graTree").on('delete_node.jstree', function (e, data) {
let main = {};
if (!isNaN(parseInt(data.node.id))) {
main.id = parseInt(data.node.id);
objSendData.Data = main;
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/DelVar", objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
toast_error(res.msg || common.SysErr);
} else {
getGraCatList((graCatData) => {
data.settings.core.data = graCatData;
@ -469,7 +475,7 @@
})
}
}, null, "POST").send();
}
});
onEvent("keyup", "#graCatSearch", function () {

View File

@ -79,13 +79,13 @@ namespace FrontendWebApi.ApiControllers
try
{
Dictionary<string, object> variable = new Dictionary<string, object>();
var system_value = backendRepository.GetOneAsync<string>("select system_priority from variable where system_type = @graph_manage_layer and deleted = 0 order by system_priority desc limit 1", new { @system_type = graph_manage_layer }).Result;
var system_priority = backendRepository.GetOneAsync<string>("select system_priority from variable where system_type = @graph_manage_layer and deleted = 0 order by system_priority desc limit 1", new { graph_manage_layer = graph_manage_layer }).Result;
variable.Add("@deleted", 0);
variable.Add("@graph_manage_layer", graph_manage_layer);
variable.Add("@system_type", graph_manage_layer);
variable.Add("@system_key", gv.system_key);
variable.Add("@system_parent_id", gv.system_parent_id);
variable.Add("@system_remark", "圖資管理-" + gv.system_key);
variable.Add("@system_priority", Int32.Parse(system_value) + 1);
variable.Add("@system_priority", Int32.Parse(system_priority) + 1);
variable.Add("@created_by", myUser.userinfo_guid);
variable.Add("@created_at", DateTime.Now);