From 1e649c4f203dc6ffbc7b0b65418618b89ceccf5c Mon Sep 17 00:00:00 2001 From: SeoJin Kim Date: Wed, 28 Apr 2021 18:46:49 +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][24]=20=EC=83=81=ED=92=88?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=97=85=EB=A1=9C=EB=93=9C(?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=84=9C=EB=B2=84=20=EC=A0=84=EC=86=A1)?= =?UTF-8?q?=20-=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://kimvampa.tistory.com/213 --- .../WEB-INF/views/admin/goodsEnroll.jsp | 63 +++++++++++++++++++ .../WEB-INF/views/admin/goodsEnroll.jsp | 43 +++++++++++++ 2 files changed, 106 insertions(+) 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 a3294bd..1e1d098 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/admin/goodsEnroll.jsp @@ -135,6 +135,16 @@ 책 목차를 입력해주세요. + +
+
+ +
+
+ +
+
+
@@ -452,7 +462,60 @@ $("#enrollBtn").on("click",function(e){ }); + + /* 이미지 업로드 */ + $("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); + } + + + }); + + /* 이미지 업로드 */ + $("input[type='file']").on("change", function(e){ + + let fileInput = $('input[name="uploadFile"]'); + let fileList = fileInput[0].files; + let fileObj = fileList[0]; + + if(!fileCheck(fileObj.name, fileObj.size)){ + return false; + } + + alert("통과"); + + }); + + /* var, method related with attachFile */ + let regex = new RegExp("(.*?)\.(jpg|png)$"); + let maxSize = 1048576; //1MB + + function fileCheck(fileName, fileSize){ + + if(fileSize >= maxSize){ + alert("파일 사이즈 초과"); + return false; + } + + if(!regex.test(fileName)){ + alert("해당 종류의 파일은 업로드할 수 없습니다."); + return false; + } + + return true; + + } + 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 a3294bd..f8d64e7 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 @@ -135,6 +135,14 @@ 책 목차를 입력해주세요.
+
+
+ +
+
+ +
+
@@ -436,6 +444,7 @@ $("#enrollBtn").on("click",function(e){ }); + /* 이미지 업로드 */ $("input[name='bookPrice']").on("change", function(){ let userInput = $("#discount_interface"); @@ -452,7 +461,41 @@ $("#enrollBtn").on("click",function(e){ }); + + /* 이미지 업로드 */ + $("input[type='file']").on("change", function(e){ + let fileInput = $('input[name="uploadFile"]'); + let fileList = fileInput[0].files; + let fileObj = fileList[0]; + + if(!fileCheck(fileObj.name, fileObj.size)){ + return false; + } + + alert("통과"); + + }); + + /* var, method related with attachFile */ + let regex = new RegExp("(.*?)\.(jpg|png)$"); + let maxSize = 1048576; //1MB + + function fileCheck(fileName, fileSize){ + + if(fileSize >= maxSize){ + alert("파일 사이즈 초과"); + return false; + } + + if(!regex.test(fileName)){ + alert("해당 종류의 파일은 업로드할 수 없습니다."); + return false; + } + + return true; + + }