DelvAddrModifyPopMob.html 11 KB

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