diff --git a/Frontend/_graphManagement.html b/Frontend/_graphManagement.html index 0e37b44..f26c381 100644 --- a/Frontend/_graphManagement.html +++ b/Frontend/_graphManagement.html @@ -164,7 +164,7 @@ { "title": "圖號", "data": "code", - + }, { "title": "圖名", @@ -224,7 +224,7 @@ uploader.graMyDesignDiagram = $("#graMyDesignDiagram").dropzone(option); uploader.graMyAsBuilt = $("#graMyAsBuilt").dropzone(option); - + uploader["graMyDesignDiagram"][0].dropzone.on("addedfile", file => { uploadFiles["graMyDesignDiagram"] = file; }) @@ -237,7 +237,7 @@ // 新增資料 onEvent('click', '#graSendBtn', function () { let cookies = new YourTeam.Utility.Cookie(); - + let url = baseApiUrl + "/GraphManage/SaveGraMan"; let fd = new FormData(); fd.append("code", $("#graPicNum").val()); @@ -247,7 +247,7 @@ fd.append("donOrgName", null); fd.append("oriFile", uploadFiles["graMyDesignDiagram"] ?? null); fd.append("donFile", uploadFiles["graMyAsBuilt"] ?? null); - + $.ajax({ url: url, type: "POST", @@ -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,9 +406,9 @@ $('#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 = []; let curNode = $('#graTree').jstree(true).get_node(data.node); curLayerId = parseInt(data.node.id); @@ -429,26 +431,29 @@ 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(); }); $("#graTree").on('rename_node.jstree', function (e, data) { let main = {} - + main.id = parseInt(data.node.id); main.system_key = data.node.text; 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,19 +462,20 @@ }); $("#graTree").on('delete_node.jstree', function (e, data) { let main = {}; - 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) { - - } else { - getGraCatList((graCatData) => { - data.settings.core.data = graCatData; - data.instance.refresh(true); - }) - } - }, null, "POST").send(); - + 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; + data.instance.refresh(true); + }) + } + }, null, "POST").send(); + } }); onEvent("keyup", "#graCatSearch", function () { diff --git a/FrontendWebApi/ApiControllers/GraphManageController.cs b/FrontendWebApi/ApiControllers/GraphManageController.cs index c7e7dd8..ddd4aa6 100644 --- a/FrontendWebApi/ApiControllers/GraphManageController.cs +++ b/FrontendWebApi/ApiControllers/GraphManageController.cs @@ -79,13 +79,13 @@ namespace FrontendWebApi.ApiControllers try { Dictionary variable = new Dictionary(); - var system_value = backendRepository.GetOneAsync("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("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);