CouponPopupForm.html 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : CouponPopupForm.html
  7. * @desc : 쿠폰 등록 팝업 화면
  8. *============================================================================
  9. * ISTYLE24
  10. * Copyright(C) 2020 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2020.12.23 xyzp1539 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div class="modalPopup" data-width="1200">
  18. <div class="panelStyle" >
  19. <div class="panelTitle">
  20. <h2 th:text="${'쿠폰 ' + (mode == 'N' ? '등록' : '수정')}">쿠폰등록</h2>
  21. <button type="button" class="close" onclick="uifnPopupClose('CouponRegForm')"><i class="fa fa-times"></i></button>
  22. </div>
  23. <div class="panelContent">
  24. <form id="CouponForm" name="CouponForm" action="#" th:action="@{'/marketing/coupon/save'}" >
  25. <input type="hidden" name="supplyCompList" id="supplyCompList">
  26. <input type="hidden" name="brandList" id="brandList">
  27. <input type="hidden" name="applyGoodsList" id="applyGoodsList">
  28. <input type="hidden" name="exceptGoodsList" id="excepGoodsList">
  29. <input type="hidden" name="burdenList" id="burdenList">
  30. <input type="hidden" name="cateList" id="cateList">
  31. <input type="hidden" name="cpnId2" id="cpnId2" th:if="${cpnDetail}" th:value="${cpnDetail.cpnId}">
  32. <div class="tabs">
  33. <div class="tabsNav">
  34. <ul>
  35. <li class="on"><a href="#coupontab1">기본정보</a></li>
  36. <li><a href="#coupontab2">적용대상</a></li>
  37. <li><a href="#coupontab3">입점업체분담율</a></li>
  38. </ul>
  39. </div>
  40. <ul class="tabsCont">
  41. <li class="tab on" id="coupontab1">
  42. <div class="panelStyle">
  43. <table class="frmStyle">
  44. <colgroup>
  45. <col style="width:10%">
  46. <col style="width:40%;">
  47. <col style="width:10%">
  48. <col style="width:40%;">
  49. </colgroup>
  50. <tbody>
  51. <tr>
  52. <th>쿠폰번호<em class="required" title="필수"></em></th>
  53. <td colspan="5">
  54. <input type="hidden" name="copyCpnId" maxlength="50" value="">
  55. <input type="text" name="cpnId" id="cpnId" maxlength="50" style="width:70%;" disabled="true" readonly="readonly" placeholder="자동생성" data-valid-name="쿠폰번호">
  56. <label class="chkBox checked" onclick="clickCreateChk(this);">
  57. <input type="checkbox" name="cpnCreateType" value="true" class="type-check" checked />쿠폰번호 자동생성
  58. </label>
  59. </td>
  60. </tr>
  61. <tr>
  62. <th>쿠폰명<em class="required" title="필수"></em></th>
  63. <td colspan="5">
  64. <input type="text" name="cpnNm" id="cpnNm" style="width: 70%;" required="required" data-valid-name="쿠폰명">
  65. </td>
  66. </tr>
  67. <tr>
  68. <th>쿠폰유형<em class="required" title="필수"></em></th>
  69. <td colspan="5">
  70. <input type="hidden" id="cpnType" name="cpnType" required="required" data-valid-name="쿠폰유형">
  71. <label class="rdoBtn" th:if="${cpnTypeList}" th:each="oneData, status : ${cpnTypeList}"> <input type="radio" name="rdoCpnType" th:text="${oneData.cdNm}" th:value="${oneData.cd}"/></label>
  72. </td>
  73. </tr>
  74. <tr>
  75. <th>사용가능고객구분<em class="required" title="필수"></em></th>
  76. <td>
  77. <select name="usableCustGb" id="usableCustGb" required="required" data-valid-name="사용가능고객구분">
  78. <option th:if="${usableCustGbList}" th:each="oneData , status : ${usableCustGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  79. </select>
  80. </td>
  81. <th>사이트<em class="required" title="필수"></em></th>
  82. <td>
  83. <select name="siteCd" id="siteCd" required="required" data-valid-name="사이트">
  84. <option th:if="${siteCdList}" th:each="oneData , status : ${siteCdList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  85. </select>
  86. </td>
  87. </tr>
  88. <tr>
  89. <th>사용고객등급구분<em class="required" title="필수"></em></th>
  90. <td>
  91. <select name="usableCustGrade" id="usableCustGrade" required="required" data-valid-name="사용고객등급구분">
  92. <option value="ALL">[전체]</option>
  93. <option th:if="${usableCustGradeList}" th:each="oneData , status : ${usableCustGradeList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  94. </select>
  95. </td>
  96. <th>만료알림여부<em class="required" title="필수"></em></th>
  97. <td>
  98. <select name="endAlimYn" id="endAlimYn" required="required" data-valid-name="만료알림여부">
  99. <option value="Y">Y</option>
  100. <option value="N" selected="selected">N</option>
  101. </select>
  102. </td>
  103. </tr>
  104. <tr>
  105. <th>할인방식<em class="required" title="필수"></em></th>
  106. <td>
  107. <input type="hidden" name="dcWay" id="dcWay" required="required" data-valid-name="할인방식">
  108. <label class="rdoBtn" th:if="${dcWayList}" th:each="oneData, status : ${dcWayList}"> <input type="radio" name="rdoDcWay" th:text="${oneData.cdNm}" th:value="${oneData.cd}"/></label>
  109. </td>
  110. <th>구매제한금액<em class="required" title="필수"></em></th>
  111. <td>
  112. <input type="text" id="buyLimitAmt" name="buyLimitAmt" class="w200" required="required" value="0" style="text-align: right;" data-valid-name="구매제한금액" data-valid-type="numeric">원
  113. </td>
  114. </tr>
  115. <tr>
  116. <th>할인값(PC)<em class="required" title="필수"></em></th>
  117. <td>
  118. <input type="text" class="w200" id="dcPval" name="dcPval" value="0" required="required" data-valid-name="할인값(PC)" data-valid-type="numeric" style="text-align: right"><span id="dcPvalSpan">원</span>
  119. </td>
  120. <th>할인값(모바일웹)<em class="required" title="필수"></em></th>
  121. <td>
  122. <input type="text" class="w200" id="dcMval" name="dcMval" value="0" required="required" data-valid-name="할인값(모바일웹)" data-valid-type="numeric" style="text-align: right"><span id="dcMvalSpan">원</span>
  123. </td>
  124. </tr>
  125. <tr>
  126. <th>할인값(모바일앱)<em class="required" title="필수"></em></th>
  127. <td>
  128. <input type="text" class="w200" id="dcAval" name="dcAval" value="0" required="required" data-valid-name="할인값(모바일앱)" data-valid-type="numeric" style="text-align: right"><span id="dcAvalSpan">원</span>
  129. </td>
  130. <th>최대할인금액<em class="required" title="필수"></em></th>
  131. <td>
  132. <input type="text" class="w200" id="maxDcAmt" name="maxDcAmt" value="0" required="required" data-valid-name="최대할인금액" data-valid-type="numeric" style="text-align: right;"><span id="maxDcAmtSpan">원</span>
  133. </td>
  134. </tr>
  135. <tr>
  136. <th>다운로드시작일시<em class="required" title="필수"></em></th>
  137. <td>
  138. <input type="hidden" name="downStdt" id="downStdt" required="required" data-valid-name="다운로드시작일시">
  139. <input type="text" class="schDate w100" name="downStDay" id="downStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  140. <select name="downStHH" id="downStHH">
  141. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  142. </select>
  143. <select name="downStMM" id="downStMM">
  144. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  145. </select>
  146. <th>다운로드종료일시<em class="required" title="필수"></em></th>
  147. <td>
  148. <input type="hidden" id="downEddt" name="downEddt" required="required" data-valid-name="다운로드종료일시">
  149. <input type="text" class="schDate w100" name="downEdDay" id="downEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  150. <select name="downEdHH" id="downEdHH">
  151. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  152. </select>
  153. <select name="downEdMM" id="downEdMM">
  154. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  155. </select>
  156. </td>
  157. </tr>
  158. <tr>
  159. <th>기간/일수구분<em class="required" title="필수"></em></th>
  160. <td>
  161. <select name="pdGb" id="pdGb" onchange="pdGbChange(this)" required="required" data-valid-name="기간/일수구분">
  162. <option value="P">기간</option>
  163. <option value="D">일수</option>
  164. </select>
  165. </td>
  166. <th>적용범위<em class="required" title="필수"></em></th>
  167. <td>
  168. <input type="hidden" name="applyScope" id="applyScope" required="required" data-valid-name="적용범위">
  169. <label class="rdoBtn"> <input type="radio" name="rdoApplyScope" value="A"/>전체</label>
  170. <label class="rdoBtn"> <input type="radio" name="rdoApplyScope" value="I"/>개별</label>
  171. </td>
  172. </tr>
  173. <tr class="availDayTr" style="display: none;">
  174. <th>유효기간일수<em class="required" title="필수"></em></th>
  175. <td>
  176. <input type="text" name="availDays" id="availDays" class="w200" data-valid-name="유효기간일수">
  177. </td>
  178. </tr>
  179. <tr>
  180. <th class="availDateTr">유효기간시작일시<em class="required" title="필수"></em></th>
  181. <td class="availDateTr">
  182. <input type="hidden" name="availStdt" id="availStdt" data-valid-name="유효기간시작일시">
  183. <input type="text" class="schDate w100" name="availStDay" id="availStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  184. <select name="availStHH" id="availStHH">
  185. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  186. </select>
  187. <select name="availStMM" id="availStMM">
  188. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  189. </select>
  190. <th class="availDateTr">유효기간종료일시<em class="required" title="필수"></em></th>
  191. <td class="availDateTr">
  192. <input type="hidden" id="availEddt" name="availEddt" data-valid-name="유효기간종료일시">
  193. <input type="text" class="schDate w100" name="availEdDay" id="availEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  194. <select name="availEdHH" id="availEdHH">
  195. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  196. </select>
  197. <select name="availEdMM" id="availEdMM">
  198. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  199. </select>
  200. </td>
  201. </tr>
  202. <tr>
  203. <th>첫구매여부<em class="required" title="필수"></em></th>
  204. <td>
  205. <select name="firstYn" id="firstYn" onchange="firstYnChange(this)" required="required" data-valid-name="첫구매여부">
  206. <option value="Y">Y</option>
  207. <option value="N" selected="selected">N</option>
  208. </select>
  209. </td>
  210. <th>다운로드가능여부<em class="required" title="필수"></em></th>
  211. <td>
  212. <select name="downYn" id="downYn" required="required" data-valid-name="다운로드가능여부">
  213. <option value="Y">Y</option>
  214. <option value="Y" selected="selected">N</option>
  215. </select>
  216. </td>
  217. </tr>
  218. <tr>
  219. <th class="buyDateTr">첫구매기간시작일시<em class="required" title="필수"></em></th>
  220. <td class="buyDateTr">
  221. <input type="hidden" id="buyEddt" name="buyEddt" data-valid-name="첫구매기간종료일시">
  222. <input type="text" class="schDate w100" name="buyStDay" id="buyStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  223. <select name="buyStHH" id="buyStHH">
  224. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  225. </select>
  226. <select name="buyStMM" id="buyStMM">
  227. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  228. </select>
  229. <th class="buyDateTr">첫구매기간종료일시<em class="required" title="필수"></em></th>
  230. <td class="buyDateTr">
  231. <input type="hidden" name="buyStdt" id="buyStdt" data-valid-name="첫구매기간시작일시">
  232. <input type="text" class="schDate w100" name="buyEdDay" id="buyEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  233. <select name="buyEdHH" id="buyEdHH">
  234. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  235. </select>
  236. <select name="buyEdMM" id="buyEdMM">
  237. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  238. </select>
  239. </td>
  240. </tr>
  241. <tr>
  242. <th>신규회원여부<em class="required" title="필수"></em></th>
  243. <td>
  244. <select name="custJoinYn" id="custJoinYn" onchange="custJoinYnChange(this)" required="required" data-valid-name="신규회원여부">
  245. <option value="Y">Y</option>
  246. <option value="N" selected="selected">N</option>
  247. </select>
  248. </td>
  249. <th>총발행제한수량<em class="required" title="필수"></em></th>
  250. <td>
  251. <input type="text" class="w200" name="totPubLimitQty" id="totPubLimitQty" value="0" required="required" data-valid-name="총발행제한수량" data-valid-type="numeric" style="text-align: right;">개<span class="cRed" id="totPubLimitQtySpan"> *제한없음</span>
  252. </td>
  253. </tr>
  254. <tr>
  255. <th class="custJoinDateTr">신규회원기간시작일시<em class="required" title="필수"></em></th>
  256. <td class="custJoinDateTr">
  257. <input type="hidden" name="custJoinStdt" id="custJoinStdt" data-valid-name="신규회원기간시작일시">
  258. <input type="text" class="schDate w100" name="custJoinStDay" id="custJoinStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  259. <select name="custJoinStHH" id="custJoinStHH">
  260. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  261. </select>
  262. <select name="custJoinStMM" id="custJoinStMM">
  263. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  264. </select>
  265. <th class="custJoinDateTr">신규회원기간종료일시<em class="required" title="필수"></em></th>
  266. <td class="custJoinDateTr">
  267. <input type="hidden" id="custJoinEddt" name="custJoinEddt" data-valid-name="신규회원기간종료일시">
  268. <input type="text" class="schDate w100" name="custJoinEdDay" id="custJoinEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  269. <select name="custJoinEdHH" id="custJoinEdHH">
  270. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  271. </select>
  272. <select name="custJoinEdMM" id="custJoinEdMM">
  273. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  274. </select>
  275. </td>
  276. </tr>
  277. <tr>
  278. <th>1인당발행제한수량<em class="required" title="필수"></em></th>
  279. <td>
  280. <input type="text" class="w200" name="custPubLimitQty" id="custPubLimitQty" value="0" required="required" data-valid-name="1인당발행제한수량" data-valid-type="numeric" style="text-align: right;">개<span class="cRed" id="custPubLimitQtySpan"> *제한없음</span>
  281. </td>
  282. <th>1회발행수량<em class="required" title="필수"></em></th>
  283. <td><input type="text" class="w200" name="onePubQty" id="onePubQty" value="1" required="required" data-valid-name="1회발행수량" data-valid-type="numeric" style="text-align: right;">개</td>
  284. </tr>
  285. <tr>
  286. <th>재발급여부<em class="required" title="필수"></em></th>
  287. <td>
  288. <select name="reissuance" id="reissuance" required="required" data-valid-name="재발급여부" >
  289. <option th:if="${reissuanceList}" th:each="oneData , status : ${reissuanceList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  290. </select>
  291. </td>
  292. <th>다운로드구분<em class="required" title="필수"></em></th>
  293. <td>
  294. <select name="dnGb" id="dnGb" required="required" data-valid-name="다운로드구분">
  295. <option th:if="${dnGbList}" th:each="oneData , status:${dnGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  296. </select>
  297. </td>
  298. </tr>
  299. <tr class="payTypeTr" style="display: none;">
  300. <th>결제수단<em class="required" title="필수"></em></th>
  301. <td colspan="5">
  302. <select name="payType" id="payType" data-valid-name="결제수단">
  303. <option value="">[전체]</option>
  304. <option th:if="${payTypeList}" th:each="oneData , status : ${payTypeList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  305. </select>
  306. </td>
  307. </tr>
  308. <tr>
  309. <th>쿠폰상태<em class="required" title="필수"></em></th>
  310. <td>
  311. <select name="cpnStat" id="cpnStat" data-valid-name="쿠폰상태" required="required">
  312. <option th:if="${cpnStatList}" th:each="oneData , status : ${cpnStatList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  313. </select>
  314. </td>
  315. <th>제휴링크코드<em class="required" title="필수"></em></th>
  316. <td>
  317. <select name="afChannel" id="afChannel" onchange="fnChangeAfLinkCdList()" data-valid-name="제휴링크코드" required="required">
  318. <option th:if="${upperAfLinkCdList}" th:each="oneData , status : ${upperAfLinkCdList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  319. </select>
  320. <select name="afLinkCd" id="afLinkCd">
  321. </select>
  322. </td>
  323. </tr>
  324. </tbody>
  325. </table>
  326. <div class="mdPopBtnB aR">
  327. <button type="button" class="btn btn-info btn-lg" onclick="fnCustomerIssuePopUp();" th:if="${mode == 'U'}">쿠폰발행</button>
  328. <button type="button" class="btn btn-info btn-lg" onclick="fnCouponCreate();" th:if="${mode == 'N'}">등록</button>
  329. <button type="button" class="btn btn-info btn-lg" onclick="fnCouponUpdate();" th:if="${mode == 'U'}">수정</button>
  330. </div>
  331. </div>
  332. </li>
  333. <!-- 쿠폰적용대상-->
  334. <li class="tab" id="coupontab2" >
  335. <div class="panelStyle">
  336. <div class="inner-panelContent">
  337. <div class="panelContent">
  338. <div class="panelBar">
  339. <h4>적용 대상 상품 등록</h4>
  340. </div>
  341. <table class="frmStyle">
  342. <colgroup>
  343. <col style="width:15%;">
  344. <col style="width:85%;">
  345. </colgroup>
  346. <tbody>
  347. <tr>
  348. <th>공급처</th>
  349. <td>
  350. <div class="padding10 inner-tb-solid">
  351. <button type="button" class="btn btnRight btn-success btn-lg" id="btnSupplyAdd">공급처 추가</button>
  352. <button type="button" class="btn btnRight btn-success btn-lg" id="btnSupplyDel">선택삭제</button>
  353. <br/>
  354. <div id="supplyGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  355. </div>
  356. </td>
  357. </tr>
  358. <tr>
  359. <th>브랜드</th>
  360. <td>
  361. <div class="padding10 inner-tb-solid">
  362. <button type="button" class="btn btnRight btn-success btn-lg" id="btnBrandAdd">브랜드 추가</button>
  363. <button type="button" class="btn btnRight btn-success btn-lg" id="btnBrandDel">선택삭제</button>
  364. <br/>
  365. <div id="brandGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  366. </div>
  367. </td>
  368. </tr>
  369. <tr>
  370. <th>카테고리</th>
  371. <td>
  372. <div class="padding10 inner-tb-solid">
  373. <button type="button" class="btn btnRight btn-success btn-lg" id="btnCateAdd">카테고리 추가</button>
  374. <button type="button" class="btn btnRight btn-success btn-lg" id="btnCateDel">선택삭제</button>
  375. <br/>
  376. <div id="cateGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  377. </div>
  378. </td>
  379. </tr>
  380. <tr>
  381. <th>적용상품</th>
  382. <td>
  383. <div class="padding10 inner-tb-solid">
  384. <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsAdd">상품 추가</button>
  385. <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDel">선택삭제</button>
  386. <br/>
  387. <div id="goodsGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  388. </div>
  389. </td>
  390. </tr>
  391. </tbody>
  392. </table>
  393. </div>
  394. </div>
  395. <div class="inner-panelContent">
  396. <div class="panelContent">
  397. <div class="panelBar">
  398. <h4>적용 대상 상품 등록</h4>
  399. </div>
  400. <table class="frmStyle">
  401. <colgroup>
  402. <col style="width:15%;">
  403. <col style="width:85%;">
  404. </colgroup>
  405. <tbody>
  406. <tr>
  407. <th>제외상품</th>
  408. <td>
  409. <div class="padding10 inner-tb-solid">
  410. <button type="button" class="btn btnRight btn-success btn-lg" id="btnExcepGoodsAdd">제외상품 추가</button>
  411. <button type="button" class="btn btnRight btn-success btn-lg" id="btnExcepGoodsDel">선택삭제</button>
  412. <br/>
  413. <div id="excepGoodsGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  414. </div>
  415. </td>
  416. </tr>
  417. </tbody>
  418. </table>
  419. </div>
  420. </div>
  421. </div>
  422. </li>
  423. <!-- 쿠폰적용대상끝-->
  424. <!-- 입점업체분담율-->
  425. <li class="tab" id="coupontab3">
  426. <div class="panelStyle">
  427. <ul class="panelBar">
  428. <li class="left">
  429. <button type="button" class="btn btn-warning btn-lg" id="btnAddRow">행추가</button>
  430. <button type="button" class="btn btn-danger btn-lg" id="btnDelRow">행삭제</button>
  431. </li>
  432. </ul>
  433. <div id="inComGridList" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
  434. </div>
  435. </li>
  436. <!-- 입점업체분담끝-->
  437. </ul>
  438. </div>
  439. </form>
  440. </div>
  441. </div>
  442. </div>
  443. <script th:inline="javascript">
  444. /*<![CDATA[*/
  445. // 상세조회 리스트
  446. var mode = [[${mode}]];
  447. var cpnDetail = [[${cpnDetail}]];
  448. var cpnDtlRefvalSupplyCompList = [[${cpnDtlRefvalSupplyCompList}]];
  449. var cpnDtlRefvalApplyGoodsList = [[${cpnDtlRefvalApplyGoodsList}]];
  450. var cpnDtlRefvalCateList = [[${cpnDtlRefvalCateList}]];
  451. var cpnDtlRefvalBrandList = [[${cpnDtlRefvalBrandList}]];
  452. var cpnDtlRefvalExceptGoodsList = [[${cpnDtlRefvalExceptGoodsList}]];
  453. var cpnDtlBurdenList = [[${cpnDtlBurdenList}]];
  454. var issueCnt = [[${issueCnt}]];
  455. // 공통코드 리스트
  456. var ibSupplyComList = gagajf.convertToArray([[${ibSupplyCompList}]]);
  457. var formalGbList = gagajf.convertToArray([[${formalGbList}]]);
  458. var cateGbList = gagajf.convertToArray([[${cateGbList}]]);
  459. var delYnList = { "Y":"Yes", "N":"No" };
  460. var siteCdList = gagajf.convertToArray([[${siteCdList}]]);
  461. var selfBrandList = gagajf.convertToArray([[${selfBrandList}]]);
  462. // ag-grid 입점업체분담율 컬럼
  463. var columnDefs = [
  464. { headerName: "입점업체" , field:"supplyCompCd" , width:150, cellClass:"text-center" ,
  465. cellEditor: 'agRichSelectCellEditor',
  466. cellEditorParams: { values: gagaAgGrid.extractValues(ibSupplyComList) },
  467. valueFormatter: function (params) { return gagaAgGrid.lookupValue(ibSupplyComList, params.value); },
  468. valueParser: function (params) { return gagaAgGrid.lookupKey(ibSupplyComList, params.newValue);}
  469. } ,
  470. { headerName: "쿠폰분담율(%)", field:"burdenRate" , width:150, cellClass: "text-center" ,
  471. cellEditorParams: { maxlength: 10, required: true }
  472. } ,
  473. { headerName: "삭제여부" , field: "delYn" , width:150, cellClass: "text-center" ,
  474. cellEditor: 'agRichSelectCellEditor',
  475. cellEditorParams: { values: gagaAgGrid.extractValues(delYnList) },
  476. valueFormatter: function (params) { return gagaAgGrid.lookupValue(delYnList, params.value); },
  477. valueParser: function (params) { return gagaAgGrid.lookupKey(delYnList, params.newValue); }
  478. } ,
  479. { headerName: "쿠폰번호" , field: "cpnId" , width: 120 , cellClass: 'text-center' , hide:true}
  480. ];
  481. // ag-grid 공급처 컬럼
  482. var supplyColumnDefs = [
  483. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  484. { headerName : "공급업체코드" , field: "supplyCompCd" , width:150, cellClass: 'text-center'} ,
  485. { headerName: "공급업체명" , field: "supplyCompNm" , width:150, cellClass: 'text-center'},
  486. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  487. ];
  488. // ag-grid 브랜드 컬럼
  489. var brandSelColumnDefs = [
  490. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  491. { headerName : "브랜드ID" , field: "brandCd" , width: 120, cellClass : 'text-center'} ,
  492. { headerName : "브랜드명" , field: "brandEnm" , width: 120, cellClass: 'text-center'} ,
  493. { headerName : "공급업체명", field: "supplyCompNm" , width: 150, cellClass: 'text-center' } ,
  494. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  495. ];
  496. // ag-grid 적용상품 컬럼
  497. var goodsSelColumnDefs = [
  498. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  499. { headerName: "상품구분" , field: "goodsGb" , width: 100, cellClass: 'text-center'} ,
  500. { headerName: "Product ID" , field: "goodsCd" , width: 120, cellClass: 'text-center'},
  501. { headerName: "상품명" , field: "goodsNm" , width: 250 , cellClass: 'text-center'} ,
  502. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  503. ];
  504. // ag-grid 카테고리 컬럼
  505. var cateSelColumnDefs = [
  506. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  507. { headerName: "사이트" , field: "siteCd" , width: 100 , cellClass: 'text-center' ,
  508. cellEditor: 'agRichSelectCellEditor',
  509. cellEditorParams: { values: gagaAgGrid.extractValues(siteCdList) },
  510. valueFormatter: function (params) { return gagaAgGrid.lookupValue(siteCdList, params.value); },
  511. valueParser: function (params) { return gagaAgGrid.lookupKey(siteCdList, params.newValue); }
  512. },
  513. { headerName: "카테고리구분" , field: "cateGb" , width: 100 , cellClass: 'text-center' ,
  514. cellEditor: 'agRichSelectCellEditor',
  515. cellEditorParams: { values: gagaAgGrid.extractValues(cateGbList) },
  516. valueFormatter: function (params) { return gagaAgGrid.lookupValue(cateGbList, params.value); },
  517. valueParser: function (params) { return gagaAgGrid.lookupKey(cateGbList, params.newValue); }
  518. },
  519. { headerName: "카테고리코드" , field: "cateNo" , width: 100 , cellClass: 'text-center'} ,
  520. { headerName: "카테고리명" , field: "cateNm" , width: 120 , cellClass: 'text-center'},
  521. { headerName: "이월/정상구분" , field: "formalGb" , width: 120 , cellClass: 'text-center',
  522. cellEditor: 'agRichSelectCellEditor',
  523. cellEditorParams: { values: gagaAgGrid.extractValues(formalGbList) },
  524. valueFormatter: function (params) { return gagaAgGrid.lookupValue(formalGbList, params.value); },
  525. valueParser: function (params) { return gagaAgGrid.lookupKey(formalGbList, params.newValue); }
  526. },
  527. { headerName: "브랜드명" , field:"brandCd" , width:150, cellClass: "text-center", required: true ,
  528. editable: true, cellEditor: 'agRichSelectCellEditor',
  529. cellEditorParams: { values: gagaAgGrid.extractValues(selfBrandList) },
  530. valueFormatter: function (params) { return gagaAgGrid.lookupValue(selfBrandList, params.value); },
  531. valueParser: function (params) { return gagaAgGrid.lookupKey(selfBrandList, params.newValue); }
  532. },
  533. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  534. ];
  535. // ag-grid 제외상품 컬럼
  536. var excepGoodsColumnDefs = [
  537. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  538. { headerName: "상품구분" , field: "goodsGb" , width: 100, cellClass: 'text-center'} ,
  539. { headerName: "Product ID" , field: "goodsCd" , width: 120, cellClass: 'text-center'},
  540. { headerName: "상품명" , field: "goodsNm" , width: 250 , cellClass: 'text-center'} ,
  541. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  542. ];
  543. var inComGridOptions = gagaAgGrid.getGridOptions(columnDefs);
  544. var cateGridOptions = gagaAgGrid.getGridOptions(cateSelColumnDefs);
  545. var goodsGridOptions = gagaAgGrid.getGridOptions(goodsSelColumnDefs);
  546. var brandGridOptions = gagaAgGrid.getGridOptions(brandSelColumnDefs);
  547. var supplyGridOptions = gagaAgGrid.getGridOptions(supplyColumnDefs);
  548. var excepGoodsGridOptions = gagaAgGrid.getGridOptions(excepGoodsColumnDefs);
  549. inComGridOptions.defaultColDef.editable = true;
  550. inComGridOptions.rowSelection = "multiple";
  551. goodsGridOptions.rowSelection = "multiple";
  552. supplyGridOptions.rowSelection = "multiple";
  553. excepGoodsGridOptions.rowSelection = "multiple";
  554. cateGridOptions.rowSelection = "multiple";
  555. brandGridOptions.rowSelection = "multiple";
  556. inComGridOptions.stopEditingWhenGridLosesFocus = true;
  557. // 쿠폰 등록 버튼 클릭시
  558. function fnCouponCreate(){
  559. mcxDialog.confirm('저장하시겠습니까?' , {
  560. cancelBtnText:"취소",
  561. sureBtnText:"확인",
  562. sureBtnClick: function () {
  563. gagajf.removeCommaAtNumberFormattedInput('#CouponForm');
  564. // 필수값들 셋팅
  565. setReqValue();
  566. // 필수값 validation 체크
  567. if (!gagajf.validation('#CouponForm')) {
  568. return false;
  569. }
  570. checkValidation();
  571. gagajf.ajaxFormSubmit($('#CouponForm').prop('action'), '#CouponForm', function() {
  572. uifnPopupClose('CouponRegForm');
  573. $('#btnSearch').trigger('click');
  574. });
  575. }
  576. });
  577. }
  578. // 쿠폰 수정 시
  579. function fnCouponUpdate(){
  580. mcxDialog.confirm('수정하시겠습니까?' , {
  581. cancelBtnText:"취소",
  582. sureBtnText:"확인",
  583. sureBtnClick: function () {
  584. gagajf.removeCommaAtNumberFormattedInput('#CouponForm');
  585. // disabled 해제
  586. $("#CouponForm * ").attr("readonly" , false);
  587. $("#CouponForm * ").prop("disabled" , false);
  588. // 필수값들 셋팅
  589. setReqValue();
  590. // 필수값 validation 체크
  591. if (!gagajf.validation('#CouponForm')) {
  592. return false;
  593. }
  594. checkValidation();
  595. gagajf.ajaxFormSubmit($('#CouponForm').prop('action'), '#CouponForm', function() {
  596. uifnPopupClose('CouponRegForm');
  597. $('#btnSearch').trigger('click');
  598. });
  599. }
  600. });
  601. }
  602. // disabled 해제
  603. function setDisabledFalse(){ debugger;
  604. }
  605. function checkValidation(){
  606. //신규가입 지급한다면 validation 체크
  607. if( $('#custJoinYn option:selected').val() == "Y" ){
  608. var fromDate = $('#CouponForm input[name=custJoinStdt]').val();
  609. var toDate = $('#CouponForm input[name=custJoinEddt]').val();
  610. if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
  611. mcxDialog.alertC("신규가입기간 시작일자와 종료일자를 입력하세요.", {
  612. sureBtnText: "확인",
  613. sureBtnClick: function() {
  614. $('#CouponForm input[name=custJoinStdt]').focus();
  615. }
  616. });
  617. return false;
  618. }
  619. if (fromDate > toDate) {
  620. mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
  621. sureBtnText: "확인",
  622. sureBtnClick: function() {
  623. $('#CouponForm input[name=custJoinEddt]').focus();
  624. }
  625. });
  626. return false;
  627. }
  628. }
  629. // 첫구매 지급하면 validation 체크
  630. if( $('#firstYn option:selected').val() == "Y" ){
  631. var fromDate = $('#CouponForm input[name=buyStdt]').val();
  632. var toDate = $('#CouponForm input[name=buyEddt]').val();
  633. if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
  634. mcxDialog.alertC("신규가입기간 시작일자와 종료일자를 입력하세요.", {
  635. sureBtnText: "확인",
  636. sureBtnClick: function() {
  637. $('#CouponForm input[name=buyStdt]').focus();
  638. }
  639. });
  640. return false;
  641. }
  642. if (fromDate > toDate) {
  643. mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
  644. sureBtnText: "확인",
  645. sureBtnClick: function() {
  646. $('#CouponForm input[name=buyEddt]').focus();
  647. }
  648. });
  649. return false;
  650. }
  651. }
  652. // 할인율 validation 체크 (100을 넘길수없음)
  653. if($('#dcWay').val() == 'G240_11') {
  654. if($('#dcPval').val() > 100) {
  655. mcxDialog.alert('PC할인율은 100을 초과할수없습니다.');
  656. $('#dcPval').focus();
  657. return false;
  658. } else if( $('#dcMval').val() > 100) {
  659. mcxDialog.alert('모바일(웹)할인율은 100을 초과할수없습니다.');
  660. $('#dcMval').focus();
  661. return false;
  662. } else if( $('#dcAval').val() > 100) {
  663. mcxDialog.alert('모바일(앱)할인율은 100을 초과할수없습니다.');
  664. $('#dcAval').focus();
  665. return false;
  666. }
  667. }
  668. }
  669. // 할인방식 변경
  670. $("#CouponForm input[name=rdoDcWay]").bind('click change', function () {
  671. var radioValue = $(this).val();
  672. //발급이력이있으면 수정안됨
  673. if(issueCnt > 0 ) {
  674. return false;
  675. }
  676. if(radioValue == 'G240_10') {
  677. $('#dcPvalSpan').text("원");
  678. $('#dcMvalSpan').text("원");
  679. $('#dcAvalSpan').text("원");
  680. } else {
  681. $('#dcPvalSpan').text("%");
  682. $('#dcMvalSpan').text("%");
  683. $('#dcAvalSpan').text("%");
  684. }
  685. });
  686. // 쿠폰 상태 변경
  687. $("#CouponForm input[name=rdoCpnType]").bind('click change', function () {
  688. var radioValue = $(this).val();
  689. if(mode == "U") {
  690. radioValue = cpnDetail.cpnType;
  691. }
  692. // 상품쿠폰 선택시 적용범위 개별로 변경 나머진 전체
  693. if(radioValue == 'G230_11') {
  694. $("input:radio[name='rdoApplyScope']:radio[value='I']").prop('checked', true);
  695. } else {
  696. $("input:radio[name='rdoApplyScope']:radio[value='A']").prop('checked', true);
  697. }
  698. // 주문서 쿠폰 선택시 결제수단 노출
  699. if(radioValue == 'G230_20') {
  700. $('.payTypeTr').css('display' , '');
  701. $('#CouponForm #payType').attr('required' , true);
  702. } else {
  703. $('.payTypeTr').css('display' , 'none');
  704. $('#CouponForm #payType').attr('required' , false );
  705. }
  706. $('#CouponForm #cpnType').val(radioValue);
  707. });
  708. // 적용대상 - 브랜드 추가 버튼시
  709. $('#btnBrandAdd').on('click' , function(){
  710. cfnOpenBrandListPopup("fnSetPopupBrandInfo", "M");
  711. });
  712. // 브랜드 설정 / 브랜드 추가 콜백함수 (단수로 가져오므로 복수일 경우에 수정 확인 필요)
  713. var fnSetPopupBrandInfo = function(result) {
  714. for(let i = 0 ; i < result.length ; i++) {
  715. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(brandGridOptions); // 받아온 모든 데이터
  716. // 받아온 data for
  717. for(let j = 0 ; j < gridListValue.length ; j++) {
  718. if(gridListValue[j].brandCd == result[i].brandCd) { addChk = false; } // 중복체크
  719. }
  720. // 중복되지 않은 데이터 리스트에 추가
  721. if(addChk) {
  722. gagaAgGrid.addRowData(brandGridOptions, {"brandCd" : result[i].brandCd, "brandEnm" : result[i].brandEnm, "supplyCompNm" : result[i].supplyCompNm});
  723. }
  724. }
  725. };
  726. // 적용대상 - 브랜드 삭제 버튼시
  727. $('#btnBrandDel').on('click' , function(){
  728. var selectVal = brandGridOptions.api.getSelectedRows();
  729. if(selectVal.length == 0) {
  730. mcxDialog.alert("선택된 행이 없습니다");
  731. return;
  732. }
  733. if(cpnDetail != null ) {
  734. mcxDialog.confirm('삭제하시겠습니까?', {
  735. cancelBtnText: "취소",
  736. sureBtnText: "확인",
  737. sureBtnClick: function(){
  738. gagaAgGrid.removeRowData(brandGridOptions , false);
  739. var cpnRefvalSqArr = [];
  740. $.each(selectVal , function(idx , item){
  741. cpnRefvalSqArr.push(item.cpnRefvalSq);
  742. });
  743. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  744. ,cpnId : cpnDetail.cpnId
  745. };
  746. var jsonData = JSON.stringify(data);
  747. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  748. }
  749. });
  750. } else {
  751. // 신규화면이면 그리드상 삭제
  752. brandGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(brandGridOptions)});
  753. }
  754. });
  755. // 적용대상 - 공급처 추가 버튼시
  756. $('#btnSupplyAdd').on('click' , function (){
  757. cfnOpenCompanyListPopup("fnSetPopupComapnyInfo" , "M");
  758. });
  759. // 공급업체 설정 / 업체 추가 콜백함수
  760. var fnSetPopupComapnyInfo = function(result) {
  761. // 기존 리스트 데이터 for
  762. for(let i = 0 ; i < result.length ; i++) {
  763. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(supplyGridOptions); // 받아온 모든 데이터
  764. // 받아온 data for
  765. for(let j = 0 ; j < gridListValue.length ; j++) {
  766. // 동일한 data는 추가하지 않음
  767. if(gridListValue[j].supplyCompCd == result[i].supplyCompCd) { addChk = false; } // 중복체크
  768. }
  769. // 중복되지 않은 데이터 리스트에 추가
  770. if(addChk) {
  771. gagaAgGrid.addRowData(supplyGridOptions, {"supplyCompCd" : result[i].supplyCompCd, "supplyCompNm" : result[i].supplyCompNm});
  772. }
  773. }
  774. };
  775. // 적용대상 - 공급처 삭제시시
  776. $('#btnSupplyDel').on('click' , function () {
  777. var selectVal = supplyGridOptions.api.getSelectedRows();
  778. if(selectVal.length == 0) {
  779. mcxDialog.alert("선택된 행이 없습니다");
  780. return;
  781. }
  782. if(cpnDetail != null ) {
  783. mcxDialog.confirm('삭제하시겠습니까?', {
  784. cancelBtnText: "취소",
  785. sureBtnText: "확인",
  786. sureBtnClick: function(){
  787. gagaAgGrid.removeRowData(supplyGridOptions , false);
  788. var cpnRefvalSqArr = [];
  789. $.each(selectVal , function(idx , item){
  790. cpnRefvalSqArr.push(item.cpnRefvalSq);
  791. });
  792. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  793. ,cpnId : $('#CouponForm #cpnId').val()
  794. };
  795. var jsonData = JSON.stringify(data);
  796. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  797. }
  798. });
  799. } else {
  800. // 신규화면이면 그리드상 삭제
  801. supplyGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(supplyGridOptions)});
  802. }
  803. });
  804. // 적용대상 - 카테고리 추가시
  805. $('#btnCateAdd').on('click' , function () {
  806. cfnOpenCategoryPopup("fnSetPopupCategoryInfo");
  807. });
  808. // 카테고리 추가 콜백 함수
  809. var fnSetPopupCategoryInfo = function (result) {
  810. // 기존 리스트 데이터 for
  811. for(let i = 0 ; i < result.length ; i++) {
  812. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(cateGridOptions); // 받아온 모든 데이터
  813. // 받아온 data for
  814. for(let j = 0 ; j < gridListValue.length ; j++) {
  815. // 동일한 data는 추가하지 않음
  816. if(gridListValue[j].cateNo == result[i].cateNo) { addChk = false; } // 중복체크
  817. }
  818. // 중복되지 않은 데이터 리스트에 추가
  819. if(addChk) {
  820. gagaAgGrid.addRowData(cateGridOptions, {"siteCd":result[i].siteCd , "cateGb":result[i].cateGb , "cateNo":result[i].cateNo, "cateNm":result[i].cateNm , "formalGb":result[i].formalGb , "brandEnm":null});
  821. }
  822. }
  823. }
  824. // 적용대상 - 카테고리 삭제시
  825. $('#btnCateDel').on('click' , function () {
  826. var selectVal = cateGridOptions.api.getSelectedRows();
  827. if(selectVal.length == 0) {
  828. mcxDialog.alert("선택된 행이 없습니다");
  829. return;
  830. }
  831. if(cpnDetail != null) {
  832. mcxDialog.confirm('삭제하시겠습니까?', {
  833. cancelBtnText: "취소",
  834. sureBtnText: "확인",
  835. sureBtnClick: function(){
  836. gagaAgGrid.removeRowData(cateGridOptions , false);
  837. var cpnRefvalSqArr = [];
  838. $.each(selectVal , function(idx , item){
  839. cpnRefvalSqArr.push(item.cpnRefvalSq);
  840. });
  841. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  842. ,cpnId : $('#CouponForm #cpnId').val()
  843. };
  844. var jsonData = JSON.stringify(data);
  845. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  846. }
  847. });
  848. } else {
  849. cateGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(cateGridOptions)});
  850. }
  851. });
  852. // 적용대상 - 상품 추가시
  853. $('#btnGoodsAdd').on('click' , function () {
  854. cfnOpenGoodsPopup("fnSetPopupApplyGoodsInfo");
  855. });
  856. // 적용 상품 리스트 콜백함수
  857. var fnSetPopupApplyGoodsInfo = function(result) {
  858. gridAddGoodsList(goodsGridOptions, result , "apply");
  859. };
  860. // 적용대상 - 상품 삭제 시
  861. $('#btnGoodsDel').on('click' , function () {
  862. var selectVal = goodsGridOptions.api.getSelectedRows();
  863. if(selectVal.length == 0) {
  864. mcxDialog.alert("선택된 행이 없습니다");
  865. return;
  866. }
  867. if(cpnDetail != null ) {
  868. mcxDialog.confirm('삭제하시겠습니까?', {
  869. cancelBtnText: "취소",
  870. sureBtnText: "확인",
  871. sureBtnClick: function(){
  872. gagaAgGrid.removeRowData(goodsGridOptions , false);
  873. var cpnRefvalSqArr = [];
  874. $.each(selectVal , function(idx , item){
  875. cpnRefvalSqArr.push(item.cpnRefvalSq);
  876. });
  877. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  878. ,cpnId : $('#CouponForm #cpnId').val()
  879. };
  880. var jsonData = JSON.stringify(data);
  881. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  882. }
  883. });
  884. } else {
  885. goodsGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(goodsGridOptions)});
  886. }
  887. });
  888. // 적용대상 - 제외상품 추가시
  889. $('#btnExcepGoodsAdd').on('click' , function(){
  890. cfnOpenGoodsPopup("fnSetPopupExceptGoodsInfo");
  891. });
  892. // 적용 상품 리스트 콜백함수
  893. var fnSetPopupExceptGoodsInfo = function(result) {
  894. gridAddGoodsList(excepGoodsGridOptions, result , "except");
  895. };
  896. // 적용대상 - 제외상품 삭제시
  897. $('#btnExcepGoodsDel').on('click' , function () {
  898. var selectVal = excepGoodsGridOptions.api.getSelectedRows();
  899. if(selectVal.length == 0) {
  900. mcxDialog.alert("선택된 행이 없습니다");
  901. return;
  902. }
  903. if(cpnDetail != null ) {
  904. mcxDialog.confirm('삭제하시겠습니까?', {
  905. cancelBtnText: "취소",
  906. sureBtnText: "확인",
  907. sureBtnClick: function(){
  908. gagaAgGrid.removeRowData(excepGoodsGridOptions , false);
  909. var cpnRefvalSqArr = [];
  910. $.each(selectVal , function(idx , item){
  911. cpnRefvalSqArr.push(item.cpnRefvalSq);
  912. });
  913. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  914. ,cpnId : $('#CouponForm #cpnId').val()
  915. };
  916. var jsonData = JSON.stringify(data);
  917. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  918. }
  919. });
  920. } else {
  921. excepGoodsGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(excepGoodsGridOptions)});
  922. }
  923. });
  924. // ag-grid 상품관련 list 콜백함수
  925. function gridAddGoodsList(OriginGridListOption, result, gubun) {
  926. var goodsGbVal = "G800_10";
  927. if(gubun == 'except'){
  928. goodsGbVal = "G800_30";
  929. }
  930. for(let i = 0 ; i < result.length ; i++) {
  931. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(OriginGridListOption); // 받아온 모든 데이터
  932. // 받아온 data for
  933. for(let j = 0 ; j < gridListValue.length ; j++) {
  934. if(gridListValue[j].goodsCd == result[i].goodsCd) { addChk = false; } // 중복체크
  935. }
  936. // 중복되지 않은 데이터 리스트에 추가
  937. if(addChk) {
  938. gagaAgGrid.addRowData(OriginGridListOption, {"goodsGb": goodsGbVal, "goodsCd" : result[i].goodsCd, "goodsNm" : result[i].goodsNm});
  939. }
  940. }
  941. }
  942. // 기간 일수 변경시
  943. function pdGbChange(pThis){
  944. var selectVal = $(pThis).val();
  945. if(typeof selectVal == "undefined") {
  946. if(mode == "U") {
  947. selectVal = cpnDetail.pdGb;
  948. } else {
  949. selectVal = "P";
  950. }
  951. }
  952. if(selectVal == "P") {
  953. $('.availDateTr').css('display' , '');
  954. $('.availDayTr').css('display' , 'none');
  955. $('#CouponForm #availDays').attr('required' , false);
  956. $('#CouponForm #availStDay').attr('required' , true);
  957. $('#CouponForm #availEdDay').attr('required' , true);
  958. $('#CouponForm #availStdt').attr('required' , true);
  959. $('#CouponForm #availEddt').attr('required' , true);
  960. } else {
  961. $('.availDateTr').css('display' , 'none');
  962. $('.availDayTr').css('display' , '');
  963. $('#CouponForm #availDays').attr('required' , true);
  964. $('#CouponForm #availStDay').attr('required' , false);
  965. $('#CouponForm #availEdDay').attr('required' , false);
  966. $('#CouponForm #availStdt').attr('required' , false);
  967. $('#CouponForm #availEddt').attr('required' , false);
  968. }
  969. }
  970. // 첫구매여부 변경시
  971. function firstYnChange(pThis){
  972. var selectVal = $(pThis).val();
  973. if(typeof selectVal == "undefined") {
  974. if(mode == "U") {
  975. selectVal = cpnDetail.firstYn;
  976. } else {
  977. selectVal = "N";
  978. }
  979. }
  980. if(selectVal == "Y" ) {
  981. $('.buyDateTr').css('display' , '');
  982. $('#buyStdt').attr('required' , true);
  983. $('#buyEddt').attr('required' , true);
  984. } else {
  985. $('.buyDateTr').css('display' , 'none');
  986. $('#buyStdt').attr('required' , false);
  987. $('#buyEddt').attr('required' , false);
  988. }
  989. }
  990. // 신규회원여부 변경시
  991. function custJoinYnChange(pThis){
  992. var selectVal = $(pThis).val();
  993. if(typeof selectVal == "undefined") {
  994. if(mode == "U") {
  995. selectVal = cpnDetail.custJoinYn;
  996. } else {
  997. selectVal = "N";
  998. }
  999. }
  1000. if(selectVal == "Y" ) {
  1001. $('.custJoinDateTr').css('display' , '');
  1002. $('#custJoinStdt').attr('required' , true);
  1003. $('#custJoinEddt').attr('required' , true);
  1004. } else {
  1005. $('.custJoinDateTr').css('display' , 'none');
  1006. $('#custJoinStdt').attr('required' , false);
  1007. $('#custJoinEddt').attr('required' , false);
  1008. }
  1009. }
  1010. // 행추가시
  1011. $('#btnAddRow').on('click' , function(){
  1012. var data = { supplyCompCd: null , burdenRate : null , delYn : null};
  1013. gagaAgGrid.addRowData(inComGridOptions , data , "supplyCompCd" );
  1014. });
  1015. // 행삭제시
  1016. $('#btnDelRow').on('click' , function(){
  1017. inComGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(inComGridOptions)});
  1018. });
  1019. // 쿠폰번호 자동생성 클릭시
  1020. function clickCreateChk(){
  1021. var flag = $('#CouponForm input[name=cpnCreateType]').prop("checked");
  1022. // 발급받은 이력이 있으면 수정 안됨
  1023. if(issueCnt > 0 ) {
  1024. return false;
  1025. }
  1026. if(!flag) {
  1027. $("#CouponForm input[name=cpnId]").prop("disabled", true);
  1028. $("#CouponForm input[name=cpnId]").attr("required", false);
  1029. $("#CouponForm input[name=cpnId]").attr("readonly", true);
  1030. $("#CouponForm input[name=cpnId]").attr("placeholder", "자동생성");
  1031. $('#CouponForm input[name=cpnCreateType]').prop("checked" , false);
  1032. } else{
  1033. $("#CouponForm input[name=cpnId]").prop("disabled", false);
  1034. $("#CouponForm input[name=cpnId]").attr("required", true);
  1035. $("#CouponForm input[name=cpnId]").attr("placeholder", "");
  1036. $("#CouponForm input[name=cpnId]").attr("readonly", false);
  1037. $('#CouponForm input[name=cpnCreateType]').prop("checked" , true);
  1038. }
  1039. }
  1040. // 제휴링크채널 수정 (제휴링크가 꼭필요한지 확인필요)
  1041. function fnChangeAfLinkCdList(){
  1042. var actionUrl = "/business/aflink/list" + '?' + $('#afChannel').serialize();
  1043. var tag = "";
  1044. $("#CouponForm #afLinkCd").children('option').remove();
  1045. gagajf.ajaxJsonSubmit(actionUrl, '', function(data) {
  1046. for (let i = 0; i < data.length; i++) {
  1047. if (data[i].useYn == 'Y') {
  1048. tag += '<option value="' + data[i].afLinkCd + '">[' + data[i].afLinkCd + '] ' + data[i].afLinkNm + '</option>';
  1049. }
  1050. }
  1051. $("#CouponForm #afLinkCd").append(tag);
  1052. $("#CouponForm #afLinkCd option:first").attr("selected" , "selected");
  1053. });
  1054. }
  1055. // 쿠폰발행팝업
  1056. function fnCustomerIssuePopUp(){
  1057. cfnCpnPubForCustPopup();
  1058. };
  1059. // 전송시 값 세팅
  1060. function setReqValue(){
  1061. // 쿠폰유형값 세팅
  1062. $('#CouponForm #cpnType').val($('#CouponForm input:radio[name="rdoCpnType"]:checked').val());
  1063. // 할인방식값 세팅
  1064. $('#CouponForm #dcWay').val($('#CouponForm input:radio[name="rdoDcWay"]:checked').val());
  1065. // 적용범위값 세팅
  1066. $('#CouponForm #applyScope').val($('#CouponForm input:radio[name="rdoApplyScope"]:checked').val());
  1067. // 다운로드기간 세팅
  1068. $('#CouponForm #downStdt').val($('#CouponForm #downStDay').val() + " " + $('#CouponForm #downStHH').val() + ":" + $('#CouponForm #downStMM').val() + ":00");
  1069. $('#CouponForm #downEddt').val($('#CouponForm #downEdDay').val() + " " + $('#CouponForm #downEdHH').val() + ":" + $('#CouponForm #downEdMM').val() + ":59");
  1070. // 유효기간 세팅
  1071. if($("#CouponForm #pdGb").val() == 'P') {
  1072. $('#CouponForm #availStdt').val($('#CouponForm #availStDay').val() + " " + $('#CouponForm #availStHH').val() + ":" + $('#CouponForm #availStMM').val() + ":00");
  1073. $('#CouponForm #availEddt').val($('#CouponForm #availEdDay').val() + " " + $('#CouponForm #availEdHH').val() + ":" + $('#CouponForm #availEdMM').val() + ":59");
  1074. $('#CouponForm #availDays').val('');
  1075. } else {
  1076. $('#CouponForm #availStdt').val('');
  1077. $('#CouponForm #availEddt').val('');
  1078. }
  1079. // 첫구매기간세팅
  1080. $('#CouponForm #buyStdt').val($('#CouponForm #buyStDay').val() + " " + $('#CouponForm #buyStHH').val() + ":" + $('#CouponForm #buyStMM').val() + ":00");
  1081. $('#CouponForm #buyEddt').val($('#CouponForm #buyEdDay').val() + " " + $('#CouponForm #buyEdHH').val() + ":" + $('#CouponForm #buyEdMM').val() + ":59");
  1082. // 신규회원기간 세팅
  1083. $('#CouponForm #custJoinStdt').val($('#CouponForm #custJoinStDay').val() + " " + $('#CouponForm #custJoinStHH').val() + ":" + $('#CouponForm #custJoinStMM').val() + ":00");
  1084. $('#CouponForm #custJoinEddt').val($('#CouponForm #custJoinEdDay').val() + " " + $('#CouponForm #custJoinEdHH').val() + ":" + $('#CouponForm #custJoinEdMM').val() + ":59");
  1085. // 적용대상 - 공급처 그리드 전체값 세팅
  1086. var supplyAllData = gagaAgGrid.getAllRowData(supplyGridOptions);
  1087. var jsonSupplyCompData = JSON.stringify(supplyAllData);
  1088. $('#CouponForm #supplyCompList').val(jsonSupplyCompData);
  1089. // 적용대상 - 브랜드 그리드 전체값 세팅
  1090. var brandAllData = gagaAgGrid.getAllRowData(brandGridOptions);
  1091. var jsonBrandData = JSON.stringify(brandAllData);
  1092. $('#CouponForm #brandList').val(jsonBrandData);
  1093. // // 적용대상 - 카테고리 그리드 전체값 세팅
  1094. var cateAllData = gagaAgGrid.getAllRowData(cateGridOptions);
  1095. var jsonCateData = JSON.stringify(cateAllData);
  1096. $('#CouponForm #cateList').val(jsonCateData);
  1097. // 적용대상 - 적용상품 그리드 전체값 세팅
  1098. var goodsAllData = gagaAgGrid.getAllRowData(goodsGridOptions);
  1099. var jsonGoodsData = JSON.stringify(goodsAllData);
  1100. $('#CouponForm #applyGoodsList').val(jsonGoodsData);
  1101. // 적용대상 - 제외상품 그리드 전체값 세팅
  1102. var exceptGoodsAllData = gagaAgGrid.getAllRowData(excepGoodsGridOptions);
  1103. var jsonExceptGoodsData = JSON.stringify(exceptGoodsAllData);
  1104. $('#CouponForm #excepGoodsList').val(jsonExceptGoodsData);
  1105. // 입점업체분담율 그리드 전체값 세팅
  1106. var inCompBurdenAllData = gagaAgGrid.getAllRowData(inComGridOptions);
  1107. var jsonInCompBurdenData = JSON.stringify(inCompBurdenAllData);
  1108. $('#CouponForm #burdenList').val(jsonInCompBurdenData);
  1109. }
  1110. $(document).ready(function() {
  1111. gagaAgGrid.createGrid('inComGridList', inComGridOptions);
  1112. gagaAgGrid.createGrid('brandGridList', brandGridOptions);
  1113. gagaAgGrid.createGrid('cateGridList', cateGridOptions);
  1114. gagaAgGrid.createGrid('supplyGridList', supplyGridOptions);
  1115. gagaAgGrid.createGrid('goodsGridList', goodsGridOptions);
  1116. gagaAgGrid.createGrid('excepGoodsGridList', excepGoodsGridOptions);
  1117. // 초기화시 데이터 세팅
  1118. if (mode == "N") {
  1119. $('input[name=rdoCpnType]').eq(0).attr("checked", true);
  1120. $('input[name=rdoDcWay]').eq(0).attr("checked", true);
  1121. $('input[name=rdoApplyScope]').eq(0).attr("checked", true)
  1122. $('#CouponForm #availEdHH option:last').attr("selected", "selected");
  1123. $('#CouponForm #availEdMM option:last').attr("selected", "selected");
  1124. $('#downEdHH option:last').attr("selected", "selected");
  1125. $('#downEdMM option:last').attr("selected", "selected");
  1126. $('#custJoinEdHH option:last').attr("selected", "selected");
  1127. $('#custJoinEdMM option:last').attr("selected", "selected");
  1128. $('#buyEdHH option:last').attr("selected", "selected");
  1129. $('#buyEdMM option:last').attr("selected", "selected");
  1130. $("#CouponForm #afChannel option:first").attr("selected" , "selected");
  1131. } else {
  1132. // 수정모드시 그리드 세팅
  1133. inComGridOptions.api.setRowData(cpnDtlBurdenList);
  1134. supplyGridOptions.api.setRowData(cpnDtlRefvalSupplyCompList);
  1135. goodsGridOptions.api.setRowData(cpnDtlRefvalApplyGoodsList);
  1136. excepGoodsGridOptions.api.setRowData(cpnDtlRefvalExceptGoodsList);
  1137. brandGridOptions.api.setRowData(cpnDtlRefvalBrandList);
  1138. cateGridOptions.api.setRowData(cpnDtlRefvalCateList);
  1139. // 기본정보 세팅
  1140. $("#CouponForm input:radio[name='rdoDcWay']:radio[value=" + cpnDetail.dcWay + "]").prop('checked', true);
  1141. $("#CouponForm input:radio[name='rdoCpnType']:radio[value=" + cpnDetail.cpnType + "]").prop('checked', true);
  1142. $("#CouponForm input:radio[name='rdoApplyScope']:radio[value=" + cpnDetail.applyScope + "]").prop('checked', true);
  1143. $("#CouponForm #dcPval").val(cpnDetail.dcPval);
  1144. $("#CouponForm #dcMval").val(cpnDetail.dcMval);
  1145. $("#CouponForm #dcAval").val(cpnDetail.dcAval);
  1146. $("#CouponForm #maxDcAmt").val(cpnDetail.maxDcAmt);
  1147. $("#CouponForm #totPubLimitQty").val(cpnDetail.totPubLimitQty);
  1148. $("#CouponForm #custPubLimitQty").val(cpnDetail.custPubLimitQty);
  1149. $("#CouponForm #onePubQty").val(cpnDetail.onePubQty);
  1150. $("#CouponForm #usableCustGb").val(cpnDetail.usableCustGb).prop("selected", true);
  1151. $("#CouponForm #usableCustGrade").val(cpnDetail.usableCustGrade).prop("selected", true);
  1152. $("#CouponForm #endAlimYn").val(cpnDetail.endAlimYn).prop("selected", true);
  1153. $("#CouponForm #firstYn").val(cpnDetail.firstYn).prop("selected", true);
  1154. $("#CouponForm #reissuance").val(cpnDetail.reissuance).prop("selected", true);
  1155. $("#CouponForm #dnGb").val(cpnDetail.dnGb).prop("selected", true);
  1156. $("#CouponForm #cpnStat").val(cpnDetail.cpnStat).prop("selected", true);
  1157. $("#CouponForm #custJoinYn").val(cpnDetail.custJoinYn).prop("selected", true);
  1158. $("#CouponForm #pdGb").val(cpnDetail.pdGb).prop("selected", true);
  1159. $("#CouponForm #siteCd").val(cpnDetail.siteCd).prop("selected", true);
  1160. $("#CouponForm #afChannel").val(cpnDetail.afChannel).prop("selected", true);
  1161. $("#CouponForm #cpnNm").val(cpnDetail.cpnNm);
  1162. $("#CouponForm #downYn").val(cpnDetail.downYn);
  1163. $("#CouponForm #buyLimitAmt").val(cpnDetail.buyLimitAmt);
  1164. $("#CouponForm #cpnId").val(cpnDetail.cpnId);
  1165. /*
  1166. $("#CouponForm input:checkbox[name='cpnCreateType']").parent("label").addClass("formControl");
  1167. $("#CouponForm input:checkbox[name='cpnCreateType']").parent("label").prop('disabled', true);
  1168. $("#CouponForm input:checkbox[name='cpnCreateType']").addClass("formControl");
  1169. $("#CouponForm input:checkbox[name='cpnCreateType']").prop('disabled', true);
  1170. */
  1171. // 만약 쿠폰 발급한 내역이 있으면 쿠폰수정못하게 readonly , disabled 속성 추가
  1172. if (issueCnt > 0) {
  1173. $("#CouponForm #usableCustGb").attr('readonly', true);
  1174. $("#CouponForm #usableCustGb").attr('disabled', true);
  1175. $("#CouponForm #afChannel").attr('readonly', true);
  1176. $("#CouponForm #afChannel").attr('disabled', true);
  1177. $("#CouponForm #usableCustGrade").attr('readonly', true);
  1178. $("#CouponForm #usableCustGrade").attr('disabled', true);
  1179. $("#CouponForm #endAlimYn").attr('readonly', true);
  1180. $("#CouponForm #endAlimYn").attr('disabled', true);
  1181. $("#CouponForm #firstYn").attr('readonly', true);
  1182. $("#CouponForm #firstYn").attr('disabled', true);
  1183. $("#CouponForm #reissuance").attr('readonly', true);
  1184. $("#CouponForm #reissuance").attr('disabled', true);
  1185. $("#CouponForm #dnGb").attr('readonly', true);
  1186. $("#CouponForm #dnGb").attr('disabled', true);
  1187. $("#CouponForm #custJoinYn").attr('readonly', true);
  1188. $("#CouponForm #custJoinYn").attr('disabled', true);
  1189. $("#CouponForm #pdGb").attr('readonly', true);
  1190. $("#CouponForm #pdGb").attr('disabled', true);
  1191. $("#CouponForm #downYn").attr('readonly', true);
  1192. $("#CouponForm #downYn").attr('disabled', true);
  1193. $("#CouponForm #siteCd").attr('readonly', true);
  1194. $("#CouponForm #siteCd").attr('disabled', true);
  1195. $("#CouponForm #cpnNm").attr('readonly', true);
  1196. $("#CouponForm #cpnNm").attr('disabled', true);
  1197. $("#CouponForm #dcPval").attr('readonly', true);
  1198. $("#CouponForm #dcPval").attr('disabled', true);
  1199. $("#CouponForm #dcMval").attr('readonly', true);
  1200. $("#CouponForm #dcMval").attr('disabled', true);
  1201. $("#CouponForm #dcAval").attr('readonly', true);
  1202. $("#CouponForm #dcAval").attr('disabled', true);
  1203. $("#CouponForm #maxDcAmt").attr('readonly', true);
  1204. $("#CouponForm #maxDcAmt").attr('disabled', true);
  1205. $("#CouponForm #totPubLimitQty").attr('readonly', true);
  1206. $("#CouponForm #totPubLimitQty").attr('disabled', true);
  1207. $("#CouponForm #custPubLimitQty").attr('readonly', true);
  1208. $("#CouponForm #custPubLimitQty").attr('disabled', true);
  1209. $("#CouponForm #onePubQty").attr('readonly', true);
  1210. $("#CouponForm #onePubQty").attr('disabled', true);
  1211. $("#CouponForm #downStDay").attr('readonly', true);
  1212. $("#CouponForm #downStDay").attr('disabled', true);
  1213. $("#CouponForm #downStHH").attr('readonly', true);
  1214. $("#CouponForm #downStHH").attr('disabled', true);
  1215. $("#CouponForm #downStMM").attr('readonly', true);
  1216. $("#CouponForm #downStMM").attr('disabled', true);
  1217. $("#CouponForm #buyLimitAmt").attr('readonly', true);
  1218. $("#CouponForm input:radio[name='rdoDcWay']").attr('readonly', true);
  1219. $("#CouponForm input:radio[name='rdoCpnType']").attr('readonly', true);
  1220. $("#CouponForm input:radio[name='rdoApplyScope']").attr('readonly', true);
  1221. $("#CouponForm .rdoBtn").css('cursor', 'auto');
  1222. $("#CouponForm #cpnId").attr('readonly', true);
  1223. $("#CouponForm #cpnId").attr('disabled', true);
  1224. $("#CouponForm input:checkbox[name='cpnCreateType']").attr('readonly', true);
  1225. $("#CouponForm input:checkbox[name='cpnCreateType']").attr('disabled', true);
  1226. $("#CouponForm input:checkbox[name=cpnCreateType]").attr('checked', true);
  1227. $("#CouponForm input:checkbox[name=cpnCreateType]").parent().addClass('checked');
  1228. }
  1229. // 다운로드기간 세팅
  1230. splitDate("start", cpnDetail.downStdt, "down");
  1231. splitDate("end", cpnDetail.downEddt, "down");
  1232. // 유효기간이 날짜인경우 날짜 세팅
  1233. if (cpnDetail.pdGb == "P") {
  1234. splitDate("start", cpnDetail.availStdt, "avail");
  1235. splitDate("end", cpnDetail.availEddt, "avail");
  1236. if(issueCnt > 0) {
  1237. $("#CouponForm #availStDay").attr('readonly', true);
  1238. $("#CouponForm #availStDay").attr('disabled', true);
  1239. $("#CouponForm #availStHH").attr('readonly', true);
  1240. $("#CouponForm #availStHH").attr('disabled', true);
  1241. $("#CouponForm #availStMM").attr('readonly', true);
  1242. $("#CouponForm #availStMM").attr('disabled', true);
  1243. }
  1244. } else {
  1245. $("#CouponForm #availDays").val(cpnDetail.availDays);
  1246. $('#CouponForm #availEdHH option:last').attr("selected", "selected");
  1247. $('#CouponForm #availEdMM option:last').attr("selected", "selected");
  1248. }
  1249. // 첫구매여부 적용하는 경우 날짜 세팅
  1250. if (cpnDetail.firstYn == "Y") {
  1251. splitDate("start", cpnDetail.buyStdt, "buy");
  1252. splitDate("end", cpnDetail.buyEddt, "buy");
  1253. if(issueCnt > 0) {
  1254. $("#CouponForm #buyStDay").attr('readonly', true);
  1255. $("#CouponForm #buyStDay").attr('disabled', true);
  1256. $("#CouponForm #buyStHH").attr('readonly', true);
  1257. $("#CouponForm #buyStHH").attr('disabled', true);
  1258. $("#CouponForm #buyStMM").attr('readonly', true);
  1259. $("#CouponForm #buyStMM").attr('disabled', true);
  1260. }
  1261. }
  1262. // 신규회원여부 적용하는 경우 날짜 세팅
  1263. if (cpnDetail.custJoinYn == "Y") {
  1264. splitDate("start", cpnDetail.custJoinStdt, "custJoin");
  1265. splitDate("end", cpnDetail.custJoinEddt, "custJoin");
  1266. if(issueCnt > 0) {
  1267. $("#CouponForm #custJoinStDay").attr('readonly', true);
  1268. $("#CouponForm #custJoinStDay").attr('disabled', true);
  1269. $("#CouponForm #custJoinStHH").attr('readonly', true);
  1270. $("#CouponForm #custJoinStHH").attr('disabled', true);
  1271. $("#CouponForm #custJoinStMM").attr('readonly', true);
  1272. $("#CouponForm #custJoinStMM").attr('disabled', true);
  1273. }
  1274. }
  1275. }
  1276. // 기본세팅
  1277. pdGbChange();
  1278. firstYnChange();
  1279. custJoinYnChange();
  1280. fnChangeAfLinkCdList();
  1281. // 제휴채널2뎁스 기본세팅
  1282. if(cpnDetail != null ) {
  1283. $("#CouponForm #afLinkCd").val(cpnDetail.afLinkCd).prop("selected", true);
  1284. if(issueCnt > 0 ) {
  1285. $("#CouponForm #afLinkCd").attr('readonly', true);
  1286. $("#CouponForm #afLinkCd").attr('disabled', true);
  1287. }
  1288. }
  1289. });
  1290. // 날짜분리 ( 시작/종료날짜구분(start , end) , 날짜String , 적용타겟대상 )
  1291. function splitDate(stedGb , date , targetGb ){
  1292. var str = date;
  1293. var dateStr = str.split(' ');
  1294. var timeArr = dateStr[1].split(':');
  1295. if(stedGb == "start") {
  1296. $("#CouponForm #"+targetGb+"StDay").val(dateStr[0]);
  1297. $("#CouponForm #"+targetGb+"StHH").val(timeArr[0]);
  1298. $("#CouponForm #"+targetGb+"StMM").val(timeArr[1]);
  1299. } else {
  1300. $("#CouponForm #"+targetGb+"EdDay").val(dateStr[0]);
  1301. $("#CouponForm #"+targetGb+"EdHH").val(timeArr[0]);
  1302. $("#CouponForm #"+targetGb+"EdMM").val(timeArr[1]);
  1303. }
  1304. }
  1305. // 제한없음 문구 변경
  1306. $("input[name=totPubLimitQty],input[name=custPubLimitQty],input[name=buyLimitAmt],input[name=onePubQty]").change(function(){
  1307. if($(this).val() == "0"){
  1308. $("#"+$(this).attr("name")+"Span").html("*제한없음");
  1309. }else{
  1310. $("#"+$(this).attr("name")+"Span").html("");
  1311. }
  1312. $("#"+$(this).attr("name")+"Span").css("color", "red");
  1313. });
  1314. setTimeout(function(){
  1315. $("input[name=totPubLimitQty],input[name=custPubLimitQty],input[name=buyLimitAmt],input[name=onePubQty]").change();
  1316. }, 1);
  1317. // 콤마 찍어주기
  1318. $(function(){
  1319. setComma("CouponForm" , true);
  1320. });
  1321. function setComma(formId, pBoolean){
  1322. setTimeout(function(){
  1323. //숫자타입 콤마 찍어주기
  1324. $("#"+formId+" [data-valid-type=numeric]").each(function(){
  1325. $(this).change(function(){
  1326. if(pBoolean){
  1327. $(this).val($(this).val().addComma());
  1328. }else{
  1329. $(this).val($(this).val().removeComma());
  1330. }
  1331. });
  1332. if(pBoolean){
  1333. $(this).val($(this).val().addComma());
  1334. }else{
  1335. $(this).val($(this).val().removeComma());
  1336. }
  1337. });
  1338. }, 300);
  1339. }
  1340. /*]]>*/
  1341. </script>
  1342. </html>