From 1ad5d51b9394f0f74cd214710414f21ebec6ae23 Mon Sep 17 00:00:00 2001 From: SeoJin Kim Date: Wed, 31 Mar 2021 17:30:06 +0900 Subject: [PATCH] =?UTF-8?q?[Spring][=EC=87=BC=ED=95=91=EB=AA=B0=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8][18]=20=EC=83=81=ED=92=88?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D=20-=20=EC=9E=85=EB=A0=A5=EB=9E=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95&=20=EC=99=B8=EB=9E=98=ED=82=A4=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://kimvampa.tistory.com/201 --- .../WEB-INF/views/admin/goodsEnroll.jsp | 48 ++++++++++++++++-- .../resources/css/admin/goodsEnroll.css | 6 +++ .../maven/com.vam/controller/pom.properties | 2 +- .../WEB-INF/views/admin/goodsEnroll.jsp | 50 +++++++++++++++++-- .../resources/css/admin/goodsEnroll.css | 6 +++ .../maven/com.vam/controller/pom.properties | 2 +- 6 files changed, 103 insertions(+), 11 deletions(-) diff --git a/VamPa/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp b/VamPa/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp index 012170a..a3294bd 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp @@ -111,8 +111,10 @@
- - 상품 할인율을 입력해주세요. + + + 할인 가격 : + 1~99 숫자를 입력해주세요.
@@ -179,7 +181,7 @@ $("#enrollBtn").on("click",function(e){ let cateCode = $("select[name='cateCode']").val(); let bookPrice = $("input[name='bookPrice']").val(); let bookStock = $("input[name='bookStock']").val(); - let bookDiscount = $("input[name='bookDiscount']").val(); + let bookDiscount = $("#discount_interface").val(); let bookIntro = $(".bit p").html(); let bookContents = $(".bct p").html(); @@ -240,7 +242,7 @@ $("#enrollBtn").on("click",function(e){ stockCk = false; } - if(bookDiscount < 1 && bookDiscount != ''){ + if(!isNaN(bookDiscount)){ $(".bookDiscount_warn").css('display','none'); discountCk = true; } else { @@ -414,6 +416,44 @@ $("#enrollBtn").on("click",function(e){ }); + /* 할인율 Input 설정 */ + + $("#discount_interface").on("propertychange change keyup paste input", function(){ + + let userInput = $("#discount_interface"); + let discountInput = $("input[name='bookDiscount']"); + + let discountRate = userInput.val(); // 사용자가 입력한 할인값 + let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값 + let goodsPrice = $("input[name='bookPrice']").val(); // 원가 + let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격 + + if(!isNaN(discountRate)){ + $(".span_discount").html(discountPrice); + discountInput.val(sendDiscountRate); + } + + + }); + + $("input[name='bookPrice']").on("change", function(){ + + let userInput = $("#discount_interface"); + let discountInput = $("input[name='bookDiscount']"); + + let discountRate = userInput.val(); // 사용자가 입력한 할인값 + let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값 + let goodsPrice = $("input[name='bookPrice']").val(); // 원가 + let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격 + + if(!isNaN(discountRate)){ + $(".span_discount").html(discountPrice); + } + + + }); + + diff --git a/VamPa/src/main/webapp/resources/css/admin/goodsEnroll.css b/VamPa/src/main/webapp/resources/css/admin/goodsEnroll.css index 3b94d93..16ab02b 100644 --- a/VamPa/src/main/webapp/resources/css/admin/goodsEnroll.css +++ b/VamPa/src/main/webapp/resources/css/admin/goodsEnroll.css @@ -194,6 +194,12 @@ input[name='publeYear'] { font-weight: 300; } +.step_val{ /* 할인 가격 문구 */ + display: block; + padding-top: 5px; + font-weight: 500; +} + /* 버튼 영역 */ .btn_section{ diff --git a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index 291a3f1..6898e53 100644 --- a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Mon Mar 29 18:10:20 KST 2021 +#Wed Mar 31 15:59:23 KST 2021 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa m2e.projectName=VamPa groupId=com.vam diff --git a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp index 8f40160..a3294bd 100644 --- a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp +++ b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp @@ -111,8 +111,10 @@
- - 상품 할인율을 입력해주세요. + + + 할인 가격 : + 1~99 숫자를 입력해주세요.
@@ -179,7 +181,7 @@ $("#enrollBtn").on("click",function(e){ let cateCode = $("select[name='cateCode']").val(); let bookPrice = $("input[name='bookPrice']").val(); let bookStock = $("input[name='bookStock']").val(); - let bookDiscount = $("input[name='bookDiscount']").val(); + let bookDiscount = $("#discount_interface").val(); let bookIntro = $(".bit p").html(); let bookContents = $(".bct p").html(); @@ -240,7 +242,7 @@ $("#enrollBtn").on("click",function(e){ stockCk = false; } - if(bookDiscount < 1 && bookDiscount != ''){ + if(!isNaN(bookDiscount)){ $(".bookDiscount_warn").css('display','none'); discountCk = true; } else { @@ -264,7 +266,7 @@ $("#enrollBtn").on("click",function(e){ contentsCk = false; } - /* 최종확인 */ + /* 최종 확인 */ if(bookNameCk && authorIdCk && publeYearCk && publisherCk && cateCodeCk && priceCk && stockCk && discountCk && introCk && contentsCk ){ //alert('통과'); enrollForm.submit(); @@ -414,6 +416,44 @@ $("#enrollBtn").on("click",function(e){ }); + /* 할인율 Input 설정 */ + + $("#discount_interface").on("propertychange change keyup paste input", function(){ + + let userInput = $("#discount_interface"); + let discountInput = $("input[name='bookDiscount']"); + + let discountRate = userInput.val(); // 사용자가 입력한 할인값 + let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값 + let goodsPrice = $("input[name='bookPrice']").val(); // 원가 + let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격 + + if(!isNaN(discountRate)){ + $(".span_discount").html(discountPrice); + discountInput.val(sendDiscountRate); + } + + + }); + + $("input[name='bookPrice']").on("change", function(){ + + let userInput = $("#discount_interface"); + let discountInput = $("input[name='bookDiscount']"); + + let discountRate = userInput.val(); // 사용자가 입력한 할인값 + let sendDiscountRate = discountRate / 100; // 서버에 전송할 할인값 + let goodsPrice = $("input[name='bookPrice']").val(); // 원가 + let discountPrice = goodsPrice * (1 - sendDiscountRate); // 할인가격 + + if(!isNaN(discountRate)){ + $(".span_discount").html(discountPrice); + } + + + }); + + diff --git a/VamPa_MySQL/src/main/webapp/resources/css/admin/goodsEnroll.css b/VamPa_MySQL/src/main/webapp/resources/css/admin/goodsEnroll.css index 3b94d93..16ab02b 100644 --- a/VamPa_MySQL/src/main/webapp/resources/css/admin/goodsEnroll.css +++ b/VamPa_MySQL/src/main/webapp/resources/css/admin/goodsEnroll.css @@ -194,6 +194,12 @@ input[name='publeYear'] { font-weight: 300; } +.step_val{ /* 할인 가격 문구 */ + display: block; + padding-top: 5px; + font-weight: 500; +} + /* 버튼 영역 */ .btn_section{ diff --git a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index 871b8a0..3ffd3a0 100644 --- a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Mon Mar 29 18:10:21 KST 2021 +#Wed Mar 31 15:59:24 KST 2021 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa_MySQL m2e.projectName=VamPa_MySQL groupId=com.vam