From f2c56cc45dd95478d835336079f53a5e8e90869d Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Thu, 29 Aug 2024 10:29:03 +0800 Subject: [PATCH] =?UTF-8?q?[Backend]=E4=BF=AE=E6=94=B9=E5=8D=80=E5=9F=9F?= =?UTF-8?q?=E9=81=B8=E5=96=AE=E7=AE=A1=E7=90=86=E8=A8=AD=E5=AE=9A=E8=A6=96?= =?UTF-8?q?=E7=AA=97=E5=A4=A7=E5=B0=8F=E7=9A=84=E9=82=8F=E8=BC=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/BuildMenuController.cs | 26 +++- Backend/Views/BuildMenu/Index.cshtml | 161 ++++++++++++++++----- 2 files changed, 145 insertions(+), 42 deletions(-) diff --git a/Backend/Controllers/BuildMenuController.cs b/Backend/Controllers/BuildMenuController.cs index 8d407cc..46e2601 100644 --- a/Backend/Controllers/BuildMenuController.cs +++ b/Backend/Controllers/BuildMenuController.cs @@ -167,7 +167,11 @@ namespace Backend.Controllers buildMenu.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url); } - + if (buildMenu.left_planimetric_click == 1) + { + dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width); + dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height); + } dictionary.Add("@left_system_url", buildMenu.left_system_url); } else if (buildMenu.left_drawing == 4) @@ -184,8 +188,11 @@ namespace Backend.Controllers dictionary.Add("@left_riser_diagram_url", buildMenu.left_riser_diagram_url); dictionary.Add("@left_icon_click", buildMenu.left_icon_click); dictionary.Add("@left_icon_click_url", buildMenu.left_icon_click_url); - dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width); - dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height); + if (buildMenu.left_icon_click == 1 || buildMenu.left_planimetric_click == 1) + { + dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width); + dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height); + } } else if (buildMenu.left_drawing == 1) { @@ -293,7 +300,11 @@ namespace Backend.Controllers buildMenu.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url); } - + if (buildMenu.left_planimetric_click == 1) + { + dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width); + dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height); + } dictionary.Add("@left_system_url", buildMenu.left_system_url); } else if (buildMenu.left_drawing == 4) @@ -310,8 +321,11 @@ namespace Backend.Controllers dictionary.Add("@left_riser_diagram_url", buildMenu.left_riser_diagram_url); dictionary.Add("@left_icon_click", buildMenu.left_icon_click); dictionary.Add("@left_icon_click_url", buildMenu.left_icon_click_url); - dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width); - dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height); + if (buildMenu.left_icon_click == 1 || buildMenu.left_planimetric_click == 1) + { + dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width); + dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height); + } } else if (buildMenu.left_drawing == 1) { diff --git a/Backend/Views/BuildMenu/Index.cshtml b/Backend/Views/BuildMenu/Index.cshtml index d3323a1..e533c8a 100644 --- a/Backend/Views/BuildMenu/Index.cshtml +++ b/Backend/Views/BuildMenu/Index.cshtml @@ -869,15 +869,16 @@ changebuild_menu_drawing_modal(this); }); //#endregion - $('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () { - if ($(this).prop("checked") && $(this).val() == 1) { - //$('#build_menu_icon_click_url_modal_div').show(); - $('#build_menu_icon_click_url_width_height_modal_div').show(); - } else { - //$('#build_menu_icon_click_url_modal_div').hide(); - $('#build_menu_icon_click_url_width_height_modal_div').hide(); - } - }); + + // $('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () { + // if ($(this).prop("checked") && $(this).val() == 1) { + // $('#build_menu_icon_click_url_modal_div').show(); + // $('#build_menu_icon_click_url_width_height_modal_div').show(); + // } else { + // $('#build_menu_icon_click_url_modal_div').hide(); + // $('#build_menu_icon_click_url_width_height_modal_div').hide(); + // } + // }); $('#build_menu_icon_click_onoff_modal_div_r').on("click", "input[type=checkbox]", function () { if ($(this).prop("checked") && $(this).val() == 1) { @@ -1057,43 +1058,131 @@ }, 'json'); }); //#endregion - function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") { + function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") { $(selector).each(function (index, value) { - let drawingParent = $(value).parents("[id^=build_menu_position]") + let drawingParent = $(value).parents("[id^=build_menu_position]"); + + // 重置所有相關的 modal $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').hide(); - //$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').show(); - if ($(value).val() == 2) { - $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false); - $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show(); - } else if ($(value).val() == 4) { - $(drawingParent).find('[id^="planimetric_click"]').attr("disabled", false); - $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show(); - if ($(drawingParent).find("[id^=icon_click_url]").prop('checked')) { - //$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show(); - $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show(); - } - } else if ($(value).val() == 1) { - $(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true); - $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show(); - } else if ($(value).val() == 5) { - $(drawingParent).find('[id^=planimetric_click]').prop("checked", false); - $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show(); - } else if ($(value).val() == 3) { - $(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true); - } else { - $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide(); + + // 根據 input 的值設定顯示/隱藏邏輯 + switch ($(value).val()) { + case '2': + $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false); + $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show(); + + function toggleModalVisibilityCase2() { + const planimetricChecked = $(drawingParent).find('#build_menu_planimetric_modal_div input[type=checkbox]').is(":checked"); + if (planimetricChecked) { + $(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').show(); + } else { + $(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').hide(); + } + } + + $(drawingParent).find('#build_menu_planimetric_modal_div').on("click", "input[type=checkbox]", function () { + toggleModalVisibilityCase2(); + }); + + toggleModalVisibilityCase2(); // 初始化時也要檢查一次 + break; + + case '4': + $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false); + $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show(); + + function toggleModalVisibilityCase4() { + const planimetricChecked = $(drawingParent).find('#build_menu_planimetric_modal_div input[type=checkbox]').is(":checked"); + const onoffChecked = $(drawingParent).find('#build_menu_icon_click_onoff_modal_div input[type=checkbox]').is(":checked"); + + if (planimetricChecked || onoffChecked) { + $(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').show(); + } else { + $(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').hide(); + } + } + + $(drawingParent).find('#build_menu_planimetric_modal_div').on("click", "input[type=checkbox]", function () { + toggleModalVisibilityCase4(); + }); + + $(drawingParent).find('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () { + toggleModalVisibilityCase4(); + }); + + toggleModalVisibilityCase4(); // 初始化時也要檢查一次 + break; + + case '1': + $(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true); + $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show(); + break; + + case '5': + $(drawingParent).find('[id^=planimetric_click]').prop("checked", false); + $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show(); + break; + + case '3': + $(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true); + break; + + default: + $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide(); + break; } - - }) - - + }); } + + + + + // function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") { + + // $(selector).each(function (index, value) { + // let drawingParent = $(value).parents("[id^=build_menu_position]") + // $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').hide(); + // $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').hide(); + // $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide(); + // $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide(); + // $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide(); + // $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide(); + // $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').show(); + // if ($(value).val() == 2) { + // $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false); + // $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show(); + // if ($(drawingParent).find("[id^=planimetric_click]").prop('checked')) { + // $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show(); + // } + // } else if ($(value).val() == 4) { + // $(drawingParent).find('[id^="planimetric_click"]').attr("disabled", false); + // $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show(); + // if ($(drawingParent).find("[id^=icon_click_url]").prop('checked')) { + // $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show(); + // $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show(); + // } + // } else if ($(value).val() == 1) { + // $(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true); + // $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show(); + // } else if ($(value).val() == 5) { + // $(drawingParent).find('[id^=planimetric_click]').prop("checked", false); + // $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show(); + // } else if ($(value).val() == 3) { + // $(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true); + // } else { + // $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide(); + // } + + // }) + + + // } $('#buildMenu_table').on("click", "button.del-btn", function () { var send_data = {