[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

@ -164,7 +164,7 @@
{ {
"title": "圖號", "title": "圖號",
"data": "code", "data": "code",
}, },
{ {
"title": "圖名", "title": "圖名",
@ -224,7 +224,7 @@
uploader.graMyDesignDiagram = $("#graMyDesignDiagram").dropzone(option); uploader.graMyDesignDiagram = $("#graMyDesignDiagram").dropzone(option);
uploader.graMyAsBuilt = $("#graMyAsBuilt").dropzone(option); uploader.graMyAsBuilt = $("#graMyAsBuilt").dropzone(option);
uploader["graMyDesignDiagram"][0].dropzone.on("addedfile", file => { uploader["graMyDesignDiagram"][0].dropzone.on("addedfile", file => {
uploadFiles["graMyDesignDiagram"] = file; uploadFiles["graMyDesignDiagram"] = file;
}) })
@ -237,7 +237,7 @@
// 新增資料 // 新增資料
onEvent('click', '#graSendBtn', function () { onEvent('click', '#graSendBtn', function () {
let cookies = new YourTeam.Utility.Cookie(); let cookies = new YourTeam.Utility.Cookie();
let url = baseApiUrl + "/GraphManage/SaveGraMan"; let url = baseApiUrl + "/GraphManage/SaveGraMan";
let fd = new FormData(); let fd = new FormData();
fd.append("code", $("#graPicNum").val()); fd.append("code", $("#graPicNum").val());
@ -247,7 +247,7 @@
fd.append("donOrgName", null); fd.append("donOrgName", null);
fd.append("oriFile", uploadFiles["graMyDesignDiagram"] ?? null); fd.append("oriFile", uploadFiles["graMyDesignDiagram"] ?? null);
fd.append("donFile", uploadFiles["graMyAsBuilt"] ?? null); fd.append("donFile", uploadFiles["graMyAsBuilt"] ?? null);
$.ajax({ $.ajax({
url: url, url: url,
type: "POST", type: "POST",
@ -338,7 +338,7 @@
treeEvent(); treeEvent();
let option = { let option = {
core: { core: {
check_callback: true, "check_callback": true,
data: data, data: data,
themes: { themes: {
name: "default-dark" name: "default-dark"
@ -347,11 +347,11 @@
types: { types: {
default: { default: {
max_depth: 3, max_depth: 3,
valid_children: "default", /*valid_children: "default",*/
icon: "fas fa-folder text-warning" icon: "fas fa-folder text-warning"
}, },
}, },
plugins: ["themes", "contextmenu", "sort", "search", "types"], plugins: ["themes", "contextmenu", "sort", "conditionalselect", "search", "types"],
search: { search: {
case_insensitive: true, case_insensitive: true,
@ -368,12 +368,14 @@
if (depth >= 3) { if (depth >= 3) {
return true; //第五層後無法新增 return true; //第五層後無法新增
} }
return false;
}, },
action: function (obj) { action: function (obj) {
$node = tree.create_node($node, { text: '新類別', type: 'default' }); $node = tree.create_node($node, { text: '新類別', type: 'default' });
tree.deselect_all(); tree.deselect_all();
tree.select_node($node); tree.select_node($node);
tree.edit($node); tree.edit($node);
} }
}, },
Rename: { Rename: {
@ -404,9 +406,9 @@
$('#graTree').jstree(true).select_node(topNode.children[0]); $('#graTree').jstree(true).select_node(topNode.children[0]);
}) })
$('#graTree').on("select_node.jstree", function (e, data) { $('#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(); graTable.ajax.reload();
let names = []; let names = [];
let curNode = $('#graTree').jstree(true).get_node(data.node); let curNode = $('#graTree').jstree(true).get_node(data.node);
curLayerId = parseInt(data.node.id); curLayerId = parseInt(data.node.id);
@ -429,26 +431,29 @@
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/SaveVar", objSendData, function (res) { ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/SaveVar", objSendData, function (res) {
if (!res || res.code != "0000") { if (!res || res.code != "0000") {
data.instance.delete_node(data.node);
toast_error(res.msg || common.SysErr);
} else { } else {
data.instance.set_id(data.node, res.data); data.instance.set_id(data.node, res.data);
} }
}, null, "POST").send(); }, null, "POST").send();
}); });
$("#graTree").on('rename_node.jstree', function (e, data) { $("#graTree").on('rename_node.jstree', function (e, data) {
let main = {} let main = {}
main.id = parseInt(data.node.id); main.id = parseInt(data.node.id);
main.system_key = data.node.text; main.system_key = data.node.text;
objSendData.Data = main; objSendData.Data = main;
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/EditVar", objSendData, function (res) { ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/EditVar", objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
toast_error(res.msg || common.SysErr);
} else { } else {
getGraCatList((graCatData) => { getGraCatList((graCatData) => {
data.settings.core.data = graCatData; data.instance.settings.core.data = graCatData;
data.instance.refresh(true); data.instance.refresh(true);
}) })
} }
@ -457,19 +462,20 @@
}); });
$("#graTree").on('delete_node.jstree', function (e, data) { $("#graTree").on('delete_node.jstree', function (e, data) {
let main = {}; let main = {};
main.id = parseInt(data.node.id); if (!isNaN(parseInt(data.node.id))) {
objSendData.Data = main; main.id = parseInt(data.node.id);
ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/DelVar", objSendData, function (res) { objSendData.Data = main;
if (!res || res.code != "0000" || !res.data) { ytAjax = new YourTeam.Ajax(baseApiUrl + "/GraphManage/DelVar", objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else { toast_error(res.msg || common.SysErr);
getGraCatList((graCatData) => { } else {
data.settings.core.data = graCatData; getGraCatList((graCatData) => {
data.instance.refresh(true); data.settings.core.data = graCatData;
}) data.instance.refresh(true);
} })
}, null, "POST").send(); }
}, null, "POST").send();
}
}); });
onEvent("keyup", "#graCatSearch", function () { onEvent("keyup", "#graCatSearch", function () {

View File

@ -79,13 +79,13 @@ namespace FrontendWebApi.ApiControllers
try try
{ {
Dictionary<string, object> variable = new Dictionary<string, object>(); 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("@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_key", gv.system_key);
variable.Add("@system_parent_id", gv.system_parent_id); variable.Add("@system_parent_id", gv.system_parent_id);
variable.Add("@system_remark", "圖資管理-" + gv.system_key); 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_by", myUser.userinfo_guid);
variable.Add("@created_at", DateTime.Now); variable.Add("@created_at", DateTime.Now);