DelvAddrModifyPopWeb.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <form class="form_wrap form_full" name="deliveryModifyForm" id="deliveryModifyForm">
  2. <input type="hidden" class="form_control" name="custDelvAddrSq" th:value="${deliveryAddrInfo.custDelvAddrSq}">
  3. <div class="modal-header">
  4. <h5 class="modal-title" id="adrsModifyLabel">배송지 수정</h5>
  5. </div>
  6. <div class="modal-body">
  7. <div class="pop_cont">
  8. <div class="area_adrsinfo">
  9. <h6>배송지 정보</h6>
  10. <th:block th:if="${isLogin} == true">
  11. <div class="default_addrs">
  12. <div class="form_field">
  13. <th:block th:if="${deliveryAddrInfo.defaultYn} == 'Y'">
  14. <input id="chk-default-addrs1" type="checkbox" name="defaultYn" checked>
  15. </th:block>
  16. <th:block th:if="${deliveryAddrInfo.defaultYn} == 'N'">
  17. <input id="chk-default-addrs1" type="checkbox" name="defaultYn">
  18. </th:block>
  19. <label for="chk-default-addrs1"><span>기본 배송지로 등록</span></label>
  20. </div>
  21. </div>
  22. </th:block>
  23. <div class="form_field">
  24. <label class="input_label sr-only">받는 분</label>
  25. <div class="ui_col_12">
  26. <div class="input_wrap">
  27. <input type="text" class="form_control" name="recipNm" maxlength="11" placeholder="받는 분" th:value="${deliveryAddrInfo.recipNm}">
  28. </div>
  29. </div>
  30. </div>
  31. <div class="form_field">
  32. <label class="input_label sr-only">휴대폰 번호</label>
  33. <div class="ui_col_12">
  34. <div class="input_wrap">
  35. <input type="text" name="recipPhnno" placeholder="휴대폰 번호" class="form_control" minlength="12" maxlength="13" th:value="${deliveryAddrInfo.recipPhnno}"/>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="form_field">
  40. <label class="input_label sr-only">배송주소</label>
  41. <div class="ui_col_12">
  42. <div class="input_wrap">
  43. <input type="hidden" name="recipZipcode" placeholder="우편번호" th:value="${deliveryAddrInfo.recipZipcode}" readonly="readonly">
  44. <input type="hidden" class="form_control" name="recipBaseAddr" placeholder="기본주소" th:value="${deliveryAddrInfo.recipBaseAddr}" readonly="readonly">
  45. <input type="text" class="form_control" name="recipAddr" placeholder="배송주소" th:value="${deliveryAddrInfo.recipZipcode} + ' '+ ${deliveryAddrInfo.recipBaseAddr}" readonly="readonly">
  46. </div>
  47. <button type="button" class="btn btn_dark btn_sm" onclick="fnOpenDaumAddr();">
  48. <span>우편번호 찾기</span>
  49. </button>
  50. </div>
  51. </div>
  52. <div class="form_field">
  53. <label class="input_label sr-only">상세주소</label>
  54. <div class="ui_col_12">
  55. <div class="input_wrap">
  56. <input type="text" class="form_control" name="recipDtlAddr" maxlength="50" placeholder="상세주소" th:value="${deliveryAddrInfo.recipDtlAddr}">
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="area_request">
  62. <h6>배송요청 사항</h6>
  63. <div class="form_field">
  64. <div>
  65. <input type="radio" name="rdi-request1" id="rdi-request11" value="문 앞">
  66. <label for="rdi-request11"><span>문 앞</span></label>
  67. </div>
  68. <div>
  69. <input type="radio" name="rdi-request1" id="rdi-request12" value="직접 받고 부재 시 문 앞">
  70. <label for="rdi-request12"><span>직접 받고 부재 시 문 앞</span></label>
  71. </div>
  72. <div>
  73. <input type="radio" name="rdi-request1" id="rdi-request13" value="경비실">
  74. <label for="rdi-request13"><span>경비실</span></label>
  75. </div>
  76. <div>
  77. <input type="radio" name="rdi-request1" id="rdi-request14" value="택배함">
  78. <label for="rdi-request14"><span>택배함</span></label>
  79. </div>
  80. <div>
  81. <input type="radio" name="rdi-request1" id="rdi-request15" value="기타사항">
  82. <label for="rdi-request15"><span>기타사항</span></label>
  83. <div class="info_box">
  84. <div class="input_wrap">
  85. <input type="text" name="delvMemoText" class="form_control" maxlength="30" placeholder="보관장소만 입력 (필수)" disabled>
  86. <p>보관 장소 외 다른 내용 입력시 통보없이 삭제 될 수 있습니다.</p>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="modal-footer">
  95. <button type="button" class="btn btn_dark" id="btn_delivery_modi_save"><span>배송지 등록</span></button>
  96. </div>
  97. </form>
  98. <script th:inline="javascript">
  99. var delvMemo = [[${deliveryAddrInfo.delvMemo}]];
  100. //컨텐츠 호출
  101. $(document).ready( function() {
  102. var delvMemoArr = ["문 앞", "직접 받고 부재 시 문 앞", "경비실", "택배함"];
  103. var tempMemo = true;
  104. // 배송요청사항설정
  105. for (i=0 ; i<delvMemoArr.length ; i++) {
  106. if (delvMemoArr[i] == delvMemo) {
  107. tempMemo = false;
  108. }
  109. }
  110. if (tempMemo) {
  111. $("#deliveryModifyForm input[name=rdi-request1]").eq(4).attr("checked", true);
  112. $("#deliveryModifyForm input[name=delvMemoText]").attr("disabled", false);
  113. $("#deliveryModifyForm input[name=delvMemoText]").val(delvMemo);
  114. }
  115. $("#deliveryModifyForm input[name=rdi-request1]").each(function(){
  116. var temp = $(this).parent().find('span').text();
  117. if (delvMemo == temp) {
  118. $(this).attr("checked", true);
  119. }
  120. });
  121. // 배송요청사항 버튼기능
  122. $("#deliveryModifyForm input[name=rdi-request1]").each(function(){
  123. // 버튼기능
  124. $(this).on("click", function(){
  125. var temp = $(this).parent().find('span').text();
  126. $("#deliveryModifyForm input[name=delvMemoText]").val("");
  127. if (temp == "기타사항") {
  128. $("#deliveryModifyForm input[name=delvMemoText]").attr("disabled", false);
  129. } else {
  130. $("#deliveryModifyForm input[name=delvMemoText]").attr("disabled", true);
  131. }
  132. });
  133. });
  134. $(document).on('click','#adrsModifyPop .close-modal',function(e){
  135. $('#adrsModifyPop .modal-dialog .modal-content').html('');
  136. });
  137. });
  138. // 배송지등록버튼
  139. $("#btn_delivery_modi_save").on("click", function(){
  140. // 유효성체크
  141. if (!deliveryModifyFormCheck()){
  142. return false;
  143. }
  144. // 기본배송지여부
  145. var defaultYn = "N";
  146. if ($("#deliveryModifyForm input[name=defaultYn]").is(":checked")) {
  147. defaultYn = "Y";
  148. }
  149. // 기타사항일때 텍스트 등록
  150. var delvMemo = $("#deliveryModifyForm input[name=rdi-request1]:checked").parent().find('span').text();
  151. if ("기타사항" == delvMemo) {
  152. delvMemo = $("#deliveryModifyForm input[name=delvMemoText]").val();
  153. }
  154. // 2021.04.29 추가
  155. if (gagajf.isNull(delvMemo)) {
  156. mcxDialog.alert("기타사항을 입력해주세요.");
  157. $("#deliveryAddForm input[name=delvMemoText]").focus();
  158. return false;
  159. }
  160. // 배송지정보설정
  161. var jsonObj = {
  162. "defaultYn" : defaultYn
  163. , "custDelvAddrSq" : parseInt($("#deliveryModifyForm input[name=custDelvAddrSq]").val())
  164. , "recipNm" : $("#deliveryModifyForm input[name=recipNm]").val()
  165. , "recipPhnno" : $("#deliveryModifyForm input[name=recipPhnno]").val()
  166. , "recipZipcode" : $("#deliveryModifyForm input[name=recipZipcode]").val()
  167. , "recipBaseAddr" : $("#deliveryModifyForm input[name=recipBaseAddr]").val()
  168. , "recipDtlAddr" : $("#deliveryModifyForm input[name=recipDtlAddr]").val()
  169. , "delvMemo" : delvMemo
  170. }
  171. var jsonData = JSON.stringify(jsonObj);
  172. $.ajax( {
  173. type : "POST",
  174. url : '/common/updateCustDeliveryAddr',
  175. data : jsonData,
  176. dataType : 'html',
  177. beforeSend : function(xhr, settings) {
  178. xhr.setRequestHeader("AJAX" , "true");
  179. xhr.setRequestHeader('Accept' , 'application/json');
  180. xhr.setRequestHeader('Content-Type' , 'application/json');
  181. },
  182. success : function(result) {
  183. // custDelvAddrSq 부모창으로 전달
  184. var delvObj = {
  185. "custDelvAddrSq" : parseInt($("#deliveryModifyForm input[name=custDelvAddrSq]").val())
  186. , "dispYn" : "Y"
  187. , "recipNm" : $("#deliveryModifyForm input[name=recipNm]").val()
  188. , "recipPhnno" : $("#deliveryModifyForm input[name=recipPhnno]").val()
  189. , "recipZipcode" : $("#deliveryModifyForm input[name=recipZipcode]").val()
  190. , "recipBaseAddr" : $("#deliveryModifyForm input[name=recipBaseAddr]").val()
  191. , "recipDtlAddr" : $("#deliveryModifyForm input[name=recipDtlAddr]").val()
  192. , "delvMemo" : delvMemo
  193. }
  194. // 부모장으로 값 전닫
  195. delvAddrSet(delvObj);
  196. // 팝업닫기
  197. $(".close-modal").trigger("click");
  198. }
  199. });
  200. });
  201. // 유효성체크 함수
  202. var deliveryModifyFormCheck = function() {
  203. // TODO 유효성 체크 추가
  204. if (gagajf.isNull($("#deliveryModifyForm input[name=recipNm]").val())) {
  205. mcxDialog.alert("받는분을 입력해주세요.");
  206. $('#deliveryModifyForm input[name=custNm]').focus();
  207. return false;
  208. }
  209. if (gagajf.isNull($("#deliveryModifyForm input[name=recipPhnno]").val())) {
  210. mcxDialog.alert("휴대폰번호를 입력해주세요.");
  211. $('#deliveryModifyForm input[name=recipPhnno]').focus();
  212. return false;
  213. }
  214. if ($("#deliveryModifyForm input[name=recipPhnno]").val().length < 12) {
  215. mcxDialog.alert("휴대폰번호를 정확히 입력해주세요.");
  216. $('#deliveryModifyForm input[name=recipPhnno]').focus();
  217. return false;
  218. }
  219. if ($("#deliveryModifyForm input[name=recipPhnno]").val().length > 13) {
  220. mcxDialog.alert("휴대폰번호를 정확히 입력해주세요.");
  221. $('#deliveryModifyForm input[name=recipPhnno]').focus();
  222. return false;
  223. }
  224. if (gagajf.isNull($("#deliveryModifyForm input[name=recipZipcode]").val())) {
  225. mcxDialog.alert("배송주소를 입력해주세요.");
  226. $('#deliveryModifyForm input[name=recipAddr]').focus();
  227. return false;
  228. }
  229. if (gagajf.isNull($("#deliveryModifyForm input[name=recipBaseAddr]").val())) {
  230. mcxDialog.alert("배송주소를 입력해주세요.");
  231. $('#deliveryModifyForm input[name=recipAddr]').focus();
  232. return false;
  233. }
  234. if (gagajf.isNull($("#deliveryModifyForm input[name=recipDtlAddr]").val())) {
  235. mcxDialog.alert("상세주소를 입력해주세요.");
  236. $('#deliveryModifyForm input[name=recipDtlAddr]').focus();
  237. return false;
  238. }
  239. return true;
  240. }
  241. //우편번호 DAUM을 이용한 우편번호 팝업 레이어
  242. var fnOpenDaumAddr = function() {
  243. let daumZip = new daum.Postcode({
  244. oncomplete: function(data) {
  245. $('#deliveryModifyForm input[name=recipAddr]').val(data.zonecode + ' ' + cfnGetDaumRoadAddr(data));
  246. $('#deliveryModifyForm input[name=recipZipcode]').val(data.zonecode);
  247. $('#deliveryModifyForm input[name=recipBaseAddr]').val(cfnGetDaumRoadAddr(data));
  248. $('#deliveryModifyForm input[name=recipDtlAddr]').focus();
  249. cfnCloseDaumAddr();
  250. },
  251. width: '100%'
  252. });
  253. cfnOpenDaumAddr(daumZip);
  254. }
  255. // 2021.04.09 하이픈처리
  256. $(document).on("keyup", "#deliveryModifyForm input[name=recipPhnno]", function() {
  257. $(this).val( $(this).val().replace(/[^0-9]/g, "").replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3").replace("--", "-") );
  258. });
  259. </script>