CouponPopupForm.html 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220
  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" style="height: 750px">
  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="rdCpnNm" id="rdCpnNm">
  32. <input type="hidden" name="cpnId" id="cpnId" th:if="${cpnDetail}" th:value="${cpnDetail.cpnId}">
  33. <div class="tabs">
  34. <div class="tabsNav">
  35. <ul>
  36. <li class="on"><a href="#coupontab1">기본정보</a></li>
  37. <li><a href="#coupontab2">적용대상</a></li>
  38. <li><a href="#coupontab3">입점업체분담율</a></li>
  39. <li class="randomCpnTab" style="display:none;"><a href="#coupontab4">시리얼및난수</a></li>
  40. <li class="limitedTimeCpnTab" style="display:none;"><a href="#coupontab5">선착순쿠폰</a></li> <!--style="display:none;"-->
  41. </ul>
  42. </div>
  43. <ul class="tabsCont">
  44. <li class="tab on" id="coupontab1">
  45. <div class="panelStyle">
  46. <table class="frmStyle">
  47. <colgroup>
  48. <col style="width:10%">
  49. <col style="width:45%;">
  50. <col style="width:10%">
  51. <col style="width:35%;">
  52. </colgroup>
  53. <tbody>
  54. <tr th:if="${cpnDetail}">
  55. <th>쿠폰번호</th>
  56. <td colspan="5">
  57. <span th:if="${cpnDetail}" th:text="${cpnDetail.cpnId}"></span>
  58. </td>
  59. </tr>
  60. <tr>
  61. <th>쿠폰명<em class="required" title="필수"></em></th>
  62. <td colspan="5">
  63. <input type="text" name="cpnNm" id="cpnNm" style="width: 70%;" required="required" data-valid-name="쿠폰명">
  64. </td>
  65. </tr>
  66. <tr>
  67. <th>쿠폰유형<em class="required" title="필수"></em></th>
  68. <td>
  69. <input type="hidden" id="cpnType" name="cpnType" required="required" data-valid-name="쿠폰유형">
  70. <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>
  71. </td>
  72. <th class="limitedTimeCpnArea" style="display: none;">선착순쿠폰</th>
  73. <td class="limitedTimeCpnArea" style="display: none;">
  74. <label class="chkBox limitedTimeCpnBox" id="limitedTimeCpnBox"><input type="checkbox" name="limitedTimeCpnYn" id="limitedTimeCpnYn" value="N"/>선착순쿠폰</label>
  75. </td>
  76. </tr>
  77. <tr class="dcCdGb" style="display:none;">
  78. <th>할인쿠폰유형<em class="required" title="필수"></em></th>
  79. <td class="normalCol">
  80. <input type="hidden" id="dcCd" data-valid-name="할인쿠폰유형">
  81. <label class="rdoBtn" th:if="${dcCdList}" th:each="oneData, status : ${dcCdList}"> <input type="radio" name="dcCdGb" th:text="${oneData.cdNm}" th:value="${oneData.cd}"/></label>
  82. </td>
  83. <th class="randomCpnArea">난수생성수량<em class="required" title="필수"></em></th>
  84. <td class="randomCpnArea">
  85. <input type="text" name="randomCpnQty" class="w300" data-valid-name="난수생성수량" data-valid-type="numeric">
  86. </td>
  87. </tr>
  88. <tr class="serialCpnArea" style="display:none;">
  89. <th>시리얼쿠폰키워드<em class="required" title="필수"></em></th>
  90. <td>
  91. <input type="text" name="serialCpnNm" class="w300" maxlength="10" data-valid-name="시리얼쿠폰키워드">
  92. </td>
  93. <th>시리얼쿠폰발급수량<em class="required" title="필수"></em></th>
  94. <td>
  95. <input type="text" name="serialCpnQty" class="w300" data-valid-name="시리얼쿠폰발급수량" data-valid-type="numeric">
  96. </td>
  97. </tr>
  98. <tr>
  99. <th>사용가능고객구분<em class="required" title="필수"></em></th>
  100. <td>
  101. <label class="chkBox" th:if="${usableCustGbList}" th:each="oneData, status : ${usableCustGbList}">
  102. <input type="checkbox" name="usableCustGbArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
  103. </label>
  104. </td>
  105. <th>사이트<em class="required" title="필수"></em></th>
  106. <td>
  107. <select name="siteCd" id="siteCd" required="required" data-valid-name="사이트">
  108. <option th:if="${siteCdList}" th:each="oneData , status : ${siteCdList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  109. </select>
  110. </td>
  111. </tr>
  112. <tr>
  113. <th>사용고객등급구분<em class="required" title="필수"></em></th>
  114. <td>
  115. <label class="chkBox" th:if="${usableCustGradeList}" th:each="oneData, status : ${usableCustGradeList}">
  116. <input type="checkbox" name="usableCustGradeArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
  117. </label>
  118. </td>
  119. <th>만료알림여부<em class="required" title="필수"></em></th>
  120. <td>
  121. <select name="endAlimYn" id="endAlimYn" required="required" data-valid-name="만료알림여부">
  122. <option value="Y">Y</option>
  123. <option value="N" selected="selected">N</option>
  124. </select>
  125. </td>
  126. </tr>
  127. <tr>
  128. <th>할인방식<em class="required" title="필수"></em></th>
  129. <td>
  130. <input type="hidden" name="dcWay" id="dcWay" required="required" data-valid-name="할인방식">
  131. <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>
  132. </td>
  133. <th>구매제한금액<em class="required" title="필수"></em></th>
  134. <td>
  135. <input type="text" id="buyLimitAmt" name="buyLimitAmt" class="w200" required="required" value="0" style="text-align: right;" data-valid-name="구매제한금액" data-valid-type="numeric">원
  136. </td>
  137. </tr>
  138. <tr>
  139. <th>할인값(PC)<em class="required" title="필수"></em></th>
  140. <td>
  141. <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" onkeyup="fnDcValOnkeyUp(this);"><span id="dcPvalSpan">원</span>
  142. <button type="button" class="btn btn-default btn-lg" id="applySameValueBtn">동일적용</button>
  143. </td>
  144. <th>할인값(모바일웹)<em class="required" title="필수"></em></th>
  145. <td>
  146. <input type="text" class="w200" id="dcMval" name="dcMval" value="0" required="required" data-valid-name="할인값(모바일웹)" data-valid-type="numeric" style="text-align: right" onkeyup="fnDcValOnkeyUp(this);"><span id="dcMvalSpan">원</span>
  147. </td>
  148. </tr>
  149. <tr>
  150. <th>할인값(모바일앱)<em class="required" title="필수"></em></th>
  151. <td>
  152. <input type="text" class="w200" id="dcAval" name="dcAval" value="0" required="required" data-valid-name="할인값(모바일앱)" data-valid-type="numeric" style="text-align: right" onkeyup="fnDcValOnkeyUp(this);"><span id="dcAvalSpan">원</span>
  153. </td>
  154. <th class="maxDcAmtArea">최대할인금액<em class="required" title="필수"></em></th>
  155. <td class="maxDcAmtArea">
  156. <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>
  157. </td>
  158. </tr>
  159. <tr>
  160. <th>다운로드시작일시<em class="required" title="필수"></em></th>
  161. <td>
  162. <input type="hidden" name="downStdt" id="downStdt" required="required" data-valid-name="다운로드시작일시">
  163. <input type="text" class="schDate w100" name="downStDay" id="downStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  164. <select name="downStHH" id="downStHH">
  165. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  166. </select>
  167. <select name="downStMM" id="downStMM">
  168. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  169. </select>
  170. <th>다운로드종료일시<em class="required" title="필수"></em></th>
  171. <td>
  172. <input type="hidden" id="downEddt" name="downEddt" required="required" data-valid-name="다운로드종료일시">
  173. <input type="text" class="schDate w100" name="downEdDay" id="downEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  174. <select name="downEdHH" id="downEdHH" onclick="fnChangeEdHH(this);">
  175. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  176. <option th:text="24시" th:value="24"></option>
  177. </select>
  178. <select name="downEdMM" id="downEdMM">
  179. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  180. </select>
  181. </td>
  182. </tr>
  183. <tr>
  184. <th>기간/일수구분<em class="required" title="필수"></em></th>
  185. <td>
  186. <select name="pdGb" id="pdGb" onchange="pdGbChange(this)" required="required" data-valid-name="기간/일수구분">
  187. <option value="P">기간</option>
  188. <option value="D">일수</option>
  189. </select>
  190. </td>
  191. <th>적용범위<em class="required" title="필수"></em></th>
  192. <td>
  193. <input type="hidden" name="applyScope" id="applyScope" required="required" data-valid-name="적용범위">
  194. <label class="rdoBtn"> <input type="radio" name="rdoApplyScope" value="A"/>전체</label>
  195. <label class="rdoBtn"> <input type="radio" name="rdoApplyScope" value="I"/>개별</label>
  196. </td>
  197. </tr>
  198. <tr class="availDayTr" style="display: none;">
  199. <th>유효기간일수<em class="required" title="필수"></em></th>
  200. <td>
  201. <input type="text" name="availDays" id="availDays" class="w200" data-valid-name="유효기간일수">
  202. </td>
  203. </tr>
  204. <tr>
  205. <th class="availDateTr">유효기간시작일시<em class="required" title="필수"></em></th>
  206. <td class="availDateTr">
  207. <input type="hidden" name="availStdt" id="availStdt" data-valid-name="유효기간시작일시">
  208. <input type="text" class="schDate w100" name="availStDay" id="availStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  209. <select name="availStHH" id="availStHH">
  210. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  211. </select>
  212. <select name="availStMM" id="availStMM">
  213. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  214. </select>
  215. <th class="availDateTr">유효기간종료일시<em class="required" title="필수"></em></th>
  216. <td class="availDateTr">
  217. <input type="hidden" id="availEddt" name="availEddt" data-valid-name="유효기간종료일시">
  218. <input type="text" class="schDate w100" name="availEdDay" id="availEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  219. <select name="availEdHH" id="availEdHH" onclick="fnChangeEdHH(this);">
  220. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  221. <option th:text="24시" th:value="24"></option>
  222. </select>
  223. <select name="availEdMM" id="availEdMM">
  224. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  225. </select>
  226. </td>
  227. </tr>
  228. <tr class="firstBuyTr">
  229. <th>첫구매여부<em class="required" title="필수"></em></th>
  230. <td>
  231. <select name="firstOrdYn" id="firstOrdYn" onchange="firstOrdYnChange(this)" required="required" data-valid-name="첫구매여부">
  232. <option value="Y">Y</option>
  233. <option value="N" selected="selected">N</option>
  234. </select>
  235. </td>
  236. </tr>
  237. <tr>
  238. <th class="buyDateTr">첫구매기간시작일시<em class="required" title="필수"></em></th>
  239. <td class="buyDateTr">
  240. <input type="hidden" name="buyStdt" id="buyStdt" data-valid-name="첫구매기간시작일시">
  241. <input type="text" class="schDate w100" name="buyStDay" id="buyStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  242. <select name="buyStHH" id="buyStHH">
  243. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  244. </select>
  245. <select name="buyStMM" id="buyStMM">
  246. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  247. </select>
  248. <th class="buyDateTr">첫구매기간종료일시<em class="required" title="필수"></em></th>
  249. <td class="buyDateTr">
  250. <input type="hidden" id="buyEddt" name="buyEddt" data-valid-name="첫구매기간종료일시">
  251. <input type="text" class="schDate w100" name="buyEdDay" id="buyEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  252. <select name="buyEdHH" id="buyEdHH" onclick="fnChangeEdHH(this);">
  253. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  254. <option th:text="24시" th:value="24"></option>
  255. </select>
  256. <select name="buyEdMM" id="buyEdMM">
  257. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  258. </select>
  259. </td>
  260. </tr>
  261. <tr class="custJoinTr">
  262. <th>신규회원여부<em class="required" title="필수"></em></th>
  263. <td>
  264. <select name="newCustYn" id="newCustYn" onchange="newCustYnChange(this)" required="required" data-valid-name="신규회원여부">
  265. <option value="Y">Y</option>
  266. <option value="N" selected="selected">N</option>
  267. </select>
  268. </td>
  269. </tr>
  270. <tr>
  271. <th class="custJoinDateTr">신규회원기간시작일시<em class="required" title="필수"></em></th>
  272. <td class="custJoinDateTr">
  273. <input type="hidden" name="custJoinStdt" id="custJoinStdt" data-valid-name="신규회원기간시작일시">
  274. <input type="text" class="schDate w100" name="custJoinStDay" id="custJoinStDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  275. <select name="custJoinStHH" id="custJoinStHH">
  276. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  277. </select>
  278. <select name="custJoinStMM" id="custJoinStMM">
  279. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  280. </select>
  281. <th class="custJoinDateTr">신규회원기간종료일시<em class="required" title="필수"></em></th>
  282. <td class="custJoinDateTr">
  283. <input type="hidden" id="custJoinEddt" name="custJoinEddt" data-valid-name="신규회원기간종료일시">
  284. <input type="text" class="schDate w100" name="custJoinEdDay" id="custJoinEdDay" maxlength="10" th:value="${#calendars.format(#calendars.createNow(), 'yyyy-MM-dd')}"/>
  285. <select name="custJoinEdHH" id="custJoinEdHH" onclick="fnChangeEdHH(this);">
  286. <option th:if="${hhList}" th:each="oneData , status : ${hhList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  287. <option th:text="24시" th:value="24"></option>
  288. </select>
  289. <select name="custJoinEdMM" id="custJoinEdMM">
  290. <option th:if="${mmList}" th:each="oneData , status : ${mmList}" th:text="${oneData.cdNm}" th:value="${oneData.cd}"></option>
  291. </select>
  292. </td>
  293. </tr>
  294. <tr class="dcCdCheck1">
  295. <th>총발행제한수량<em class="required" title="필수"></em></th>
  296. <td>
  297. <input type="text" class="w200" name="totPubLimitQty" id="totPubLimitQty" value="0" required="required" data-valid-name="총발행제한수량" data-valid-type="numeric" style="text-align: right;">개
  298. <label class="chkBox" id="chkBoxTotPubQty"><input type="checkbox" id="chkNoLimitTotPubLimitQty"/>제한없음</label>
  299. </td>
  300. <th>1인당발행제한수량<em class="required" title="필수"></em></th>
  301. <td>
  302. <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;">개
  303. <label class="chkBox" id="chkBoxCustPubQty"><input type="checkbox" id="chkNoLimitCustPubLimitQty"/>제한없음</label>
  304. </td>
  305. </tr>
  306. <tr>
  307. <th class="dcCdCheck2">1회발행수량<em class="required" title="필수"></em></th>
  308. <td class="dcCdCheck2">
  309. <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;">개
  310. </td>
  311. <th>다운로드가능여부<em class="required" title="필수"></em></th>
  312. <td>
  313. <select name="downAblYn" id="downAblYn" required="required" data-valid-name="다운로드가능여부">
  314. <option value="Y">Y</option>
  315. <option value="Y" selected="selected">N</option>
  316. </select>
  317. </td>
  318. </tr>
  319. <!--<tr>
  320. <th>재발급여부<em class="required" title="필수"></em></th>
  321. <td>
  322. <select name="reissuance" id="reissuance" required="required" data-valid-name="재발급여부" >
  323. <option th:if="${reissuanceList}" th:each="oneData , status : ${reissuanceList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  324. </select>
  325. </td>
  326. <th>다운로드구분<em class="required" title="필수"></em></th>
  327. <td>
  328. <select name="dnGb" id="dnGb" required="required" data-valid-name="다운로드구분">
  329. <option th:if="${dnGbList}" th:each="oneData , status:${dnGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  330. </select>
  331. </td>
  332. </tr>-->
  333. <tr class="payTypeTr" style="display: none;">
  334. <th>결제수단<em class="required" title="필수"></em></th>
  335. <td colspan="5">
  336. <label class="chkBox" th:if="${payTypeList}" th:each="oneData, status : ${payTypeList}">
  337. <input type="checkbox" name="payTypeArr" th:value="${oneData.cd}" th:text="${oneData.cdNm}"/>
  338. </label>
  339. </td>
  340. </tr>
  341. <tr>
  342. <th>쿠폰상태<em class="required" title="필수"></em></th>
  343. <td>
  344. <label class="rdoBtn" th:if="${cpnStatList}" th:each="oneData, status : ${cpnStatList}" >
  345. <input type="radio" id="disCpnStat" name="disCpnStat" th:value="${oneData.cd}" th:text="${oneData.cdNm}" data-valid-name="상태" disabled="disabled"/>
  346. </label>
  347. <input type="hidden" id="cpnStat" name="cpnStat"/>
  348. </td>
  349. <th>제휴링크코드<em class="required" title="필수"></em></th>
  350. <td>
  351. <select name="afChannel" id="afChannel" onchange="fnChangeAfLinkCdList()" data-valid-name="제휴링크코드" required="required">
  352. <option th:if="${upperAfLinkCdList}" th:each="oneData , status : ${upperAfLinkCdList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
  353. </select>
  354. <select name="afLinkCd" id="afLinkCd">
  355. </select>
  356. </td>
  357. </tr>
  358. </tbody>
  359. </table>
  360. <!--<div class="mdPopBtnB aR">
  361. <button type="button" class="btn btn-info btn-lg" onclick="fnPubCustListPopUp();" th:if="${mode == 'U'}">발급받은회원</button>
  362. <button type="button" class="btn btn-info btn-lg" onclick="fnCustomerIssuePopUp();" th:if="${mode == 'U' && cpnDetail.dcCdGb == 'G233_00'}">쿠폰발행</button>
  363. <button type="button" class="btn btn-info btn-lg" onclick="fnCouponCreate();" th:if="${mode == 'N'}">등록</button>
  364. <button type="button" class="btn btn-info btn-lg" onclick="fnCouponUpdate();" th:if="${mode == 'U'}">수정</button>
  365. </div>-->
  366. </div>
  367. </li>
  368. <!-- 쿠폰적용대상-->
  369. <li class="tab" id="coupontab2" >
  370. <div class="panelStyle">
  371. <div class="inner-panelContent">
  372. <div class="panelContent">
  373. <div class="panelBar">
  374. <h4>적용 대상 상품 등록</h4>
  375. </div>
  376. <table class="frmStyle">
  377. <colgroup>
  378. <col style="width:15%;">
  379. <col style="width:85%;">
  380. </colgroup>
  381. <tbody>
  382. <tr>
  383. <th>공급처</th>
  384. <td>
  385. <div class="padding10 inner-tb-solid">
  386. <button type="button" class="btn btnRight btn-success btn-lg" id="btnSupplyAdd">공급처 추가</button>
  387. <button type="button" class="btn btnRight btn-success btn-lg" id="btnSupplyDel">선택삭제</button>
  388. <br/>
  389. <div id="supplyGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  390. </div>
  391. </td>
  392. </tr>
  393. <tr>
  394. <th>브랜드</th>
  395. <td>
  396. <div class="padding10 inner-tb-solid">
  397. <button type="button" class="btn btnRight btn-success btn-lg" id="btnBrandAdd">브랜드 추가</button>
  398. <button type="button" class="btn btnRight btn-success btn-lg" id="btnBrandDel">선택삭제</button>
  399. <br/>
  400. <div id="brandGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  401. </div>
  402. </td>
  403. </tr>
  404. <tr>
  405. <th>카테고리</th>
  406. <td>
  407. <div class="padding10 inner-tb-solid">
  408. <button type="button" class="btn btnRight btn-success btn-lg" id="btnCateAdd">카테고리 추가</button>
  409. <button type="button" class="btn btnRight btn-success btn-lg" id="btnCateDel">선택삭제</button>
  410. <br/>
  411. <div id="cateGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  412. </div>
  413. </td>
  414. </tr>
  415. <tr>
  416. <th>적용상품</th>
  417. <td>
  418. <div class="padding10 inner-tb-solid">
  419. <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsAdd">상품 추가</button>
  420. <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDel">선택삭제</button>
  421. <br/>
  422. <div id="goodsGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  423. </div>
  424. </td>
  425. </tr>
  426. </tbody>
  427. </table>
  428. </div>
  429. </div>
  430. <div class="inner-panelContent">
  431. <div class="panelContent">
  432. <div class="panelBar">
  433. <h4>적용 대상 상품 등록</h4>
  434. </div>
  435. <table class="frmStyle">
  436. <colgroup>
  437. <col style="width:15%;">
  438. <col style="width:85%;">
  439. </colgroup>
  440. <tbody>
  441. <tr>
  442. <th>제외상품</th>
  443. <td>
  444. <div class="padding10 inner-tb-solid">
  445. <button type="button" class="btn btnRight btn-success btn-lg" id="btnExcepGoodsAdd">제외상품 추가</button>
  446. <button type="button" class="btn btnRight btn-success btn-lg" id="btnExcepGoodsDel">선택삭제</button>
  447. <br/>
  448. <div id="excepGoodsGridList" style="width:100%; height:200px;" class="ag-theme-balham"></div>
  449. </div>
  450. </td>
  451. </tr>
  452. </tbody>
  453. </table>
  454. </div>
  455. </div>
  456. </div>
  457. </li>
  458. <!-- 쿠폰적용대상끝-->
  459. <!-- 입점업체분담율-->
  460. <li class="tab" id="coupontab3">
  461. <div class="panelStyle">
  462. <ul class="panelBar">
  463. <li class="left">
  464. <button type="button" class="btn btn-warning btn-lg" id="btnAddRow">행추가</button>
  465. <button type="button" class="btn btn-danger btn-lg" id="btnDelRow">행삭제</button>
  466. </li>
  467. </ul>
  468. <div id="inComGridList" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
  469. </div>
  470. </li>
  471. <!-- 입점업체분담끝-->
  472. <!-- 난수 및 네임쿠폰 설정 -->
  473. <li class="tab" id="coupontab4">
  474. <div class="panelStyle">
  475. <span>
  476. <div id="randomCpnList" style="width: 100%; height: 500px" class="ag-theme-balham"></div>
  477. </span>
  478. </div>
  479. </li>
  480. <!-- 난수 및 네임쿠폰 설정-->
  481. <!-- 선착순 쿠폰 설정 START -->
  482. <li class="tab" id="coupontab5">
  483. <div class="panelStyle">
  484. <span class="limitedTimeCpnSpan">
  485. <button type="button" class="btn btnRight btn-success btn-lg" id="btnAddLimitedTimeCpnRow">행추가</button>
  486. <button type="button" class="btn btnRight btn-success btn-lg" id="btnDelLimitedTimeCpnRow">행삭제</button>
  487. </span>
  488. <br/>
  489. <div id="limitedTimeCpnList" style="width: 100%; height: 500px" class="ag-theme-balham"></div>
  490. </div>
  491. </li>
  492. <!-- 선착순 쿠폰 설정 END -->
  493. </ul>
  494. </div>
  495. <div class="mdPopBtnB aR">
  496. <button type="button" class="btn btn-info btn-lg" onclick="fnPubCustListPopUp();" th:if="${mode == 'U'}">발급받은회원</button>
  497. <button type="button" class="btn btn-info btn-lg" onclick="fnCustomerIssuePopUp();" th:if="${mode == 'U' && cpnDetail.dcCdGb == 'G233_00'}">쿠폰발행</button> <!-- 난수유형과 시리얼 유형에서는 쿠폰발행기능 X -->
  498. <button type="button" class="btn btnRight btn-success btn-lg couponButton" id="btnCouponSave" onclick="fnCouponCreate();" th:if="${mode == 'N'}">등록</button>
  499. <button type="button" class="btn btn-info btn-lg" onclick="fnCouponUpdate();" th:if="${mode == 'U'}">수정</button>
  500. <button type="button" class="btn btnRight btn-success btn-lg couponButton" id="btnChangeStatIng" style="display: none;">진행</button>
  501. <button type="button" class="btn btnRight btn-success btn-lg couponButton" id="btnCouponDelete" style="display: none;">삭제</button>
  502. <button type="button" class="btn btnRight btn-success btn-lg couponButton" id="btnCouponStop" style="display: none;">중지</button>
  503. </div>
  504. </form>
  505. </div>
  506. </div>
  507. </div>
  508. <script th:inline="javascript">
  509. /*<![CDATA[*/
  510. // 상세조회 리스트
  511. var mode = [[${mode}]];
  512. var cpnDetail = [[${cpnDetail}]];
  513. var cpnDtlRefvalSupplyCompList = [[${cpnDtlRefvalSupplyCompList}]];
  514. var cpnDtlRefvalApplyGoodsList = [[${cpnDtlRefvalApplyGoodsList}]];
  515. var cpnDtlRefvalCateList = [[${cpnDtlRefvalCateList}]];
  516. var cpnDtlRefvalBrandList = [[${cpnDtlRefvalBrandList}]];
  517. var cpnDtlRefvalExceptGoodsList = [[${cpnDtlRefvalExceptGoodsList}]];
  518. var cpnDtlBurdenList = [[${cpnDtlBurdenList}]];
  519. var randomCpnList = [[${randomCpnList}]];
  520. var issueCnt = [[${issueCnt}]];
  521. var cpnCustGbList = [[${cpnCustGbList}]];
  522. var cpnCustGradeList = [[${cpnCustGradeList}]];
  523. var cpnPayTypeList = [[${cpnPayTypeList}]];
  524. var limitedTimeCpnList = [[${limitedTimeCpnList}]];
  525. // 공통코드 리스트
  526. var ibSupplyComList = gagajf.convertToArray([[${ibSupplyCompList}]]);
  527. var formalGbList = gagajf.convertToArray([[${formalGbList}]]);
  528. var cateGbList = gagajf.convertToArray([[${cateGbList}]]);
  529. var delYnList = { "Y":"Yes", "N":"No" };
  530. var siteCdList = gagajf.convertToArray([[${siteCdList}]]);
  531. var selfBrandList = gagajf.convertToArray([[${selfBrandList}]]);
  532. // ag-grid 입점업체분담율 컬럼
  533. var columnDefs = [
  534. { headerName: "입점업체" , field:"supplyCompCd" , width:150, cellClass:"text-center" ,
  535. cellEditor: 'agRichSelectCellEditor',
  536. cellEditorParams: { values: gagaAgGrid.extractValues(ibSupplyComList) },
  537. valueFormatter: function (params) { return gagaAgGrid.lookupValue(ibSupplyComList, params.value); },
  538. valueParser: function (params) { return gagaAgGrid.lookupKey(ibSupplyComList, params.newValue);}
  539. } ,
  540. { headerName: "쿠폰분담율(%)", field:"burdenRate" , width:150, cellClass: "text-center" ,
  541. cellEditorParams: { maxlength: 10, required: true }
  542. } ,
  543. { headerName: "삭제여부" , field: "delYn" , width:150, cellClass: "text-center" ,
  544. cellEditor: 'agRichSelectCellEditor',
  545. cellEditorParams: { values: gagaAgGrid.extractValues(delYnList) },
  546. valueFormatter: function (params) { return gagaAgGrid.lookupValue(delYnList, params.value); },
  547. valueParser: function (params) { return gagaAgGrid.lookupKey(delYnList, params.newValue); }
  548. } ,
  549. { headerName: "쿠폰번호" , field: "cpnId" , width: 120 , cellClass: 'text-center' , hide:true}
  550. ];
  551. // ag-grid 공급처 컬럼
  552. var supplyColumnDefs = [
  553. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  554. { headerName : "공급업체코드" , field: "supplyCompCd" , width:150, cellClass: 'text-center'} ,
  555. { headerName: "공급업체명" , field: "supplyCompNm" , width:150, cellClass: 'text-center'},
  556. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  557. ];
  558. // ag-grid 브랜드 컬럼
  559. var brandSelColumnDefs = [
  560. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  561. { headerName : "브랜드ID" , field: "brandCd" , width: 120, cellClass : 'text-center'} ,
  562. { headerName : "브랜드명" , field: "brandEnm" , width: 120, cellClass: 'text-center'} ,
  563. //{ headerName : "공급업체명", field: "supplyCompNm" , width: 150, cellClass: 'text-center' } ,
  564. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  565. ];
  566. // ag-grid 적용상품 컬럼
  567. var goodsSelColumnDefs = [
  568. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  569. { headerName: "상품구분" , field: "goodsGb" , width: 100, cellClass: 'text-center'} ,
  570. { headerName: "Product ID" , field: "goodsCd" , width: 120, cellClass: 'text-center'},
  571. { headerName: "상품명" , field: "goodsNm" , width: 250 , cellClass: 'text-center'} ,
  572. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  573. ];
  574. // ag-grid 카테고리 컬럼
  575. var cateSelColumnDefs = [
  576. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  577. { headerName: "사이트" , field: "siteCd" , width: 100 , cellClass: 'text-center' ,
  578. cellEditor: 'agRichSelectCellEditor',
  579. cellEditorParams: { values: gagaAgGrid.extractValues(siteCdList) },
  580. valueFormatter: function (params) { return gagaAgGrid.lookupValue(siteCdList, params.value); },
  581. valueParser: function (params) { return gagaAgGrid.lookupKey(siteCdList, params.newValue); }
  582. },
  583. { headerName: "카테고리구분" , field: "cateGb" , width: 100 , cellClass: 'text-center' ,
  584. cellEditor: 'agRichSelectCellEditor',
  585. cellEditorParams: { values: gagaAgGrid.extractValues(cateGbList) },
  586. valueFormatter: function (params) { return gagaAgGrid.lookupValue(cateGbList, params.value); },
  587. valueParser: function (params) { return gagaAgGrid.lookupKey(cateGbList, params.newValue); }
  588. },
  589. { headerName: "카테고리코드" , field: "cateNo" , width: 100 , cellClass: 'text-center'} ,
  590. { headerName: "카테고리명" , field: "cateNm" , width: 120 , cellClass: 'text-center'},
  591. { headerName: "이월/정상구분" , field: "formalGb" , width: 120 , cellClass: 'text-center',
  592. cellEditor: 'agRichSelectCellEditor',
  593. cellEditorParams: { values: gagaAgGrid.extractValues(formalGbList) },
  594. valueFormatter: function (params) { return gagaAgGrid.lookupValue(formalGbList, params.value); },
  595. valueParser: function (params) { return gagaAgGrid.lookupKey(formalGbList, params.newValue); }
  596. },
  597. { headerName: "브랜드명" , field:"brandCd" , width:150, cellClass: "text-center", required: true ,
  598. editable: true, cellEditor: 'agRichSelectCellEditor',
  599. cellEditorParams: { values: gagaAgGrid.extractValues(selfBrandList) },
  600. valueFormatter: function (params) { return gagaAgGrid.lookupValue(selfBrandList, params.value); },
  601. valueParser: function (params) { return gagaAgGrid.lookupKey(selfBrandList, params.newValue); }
  602. },
  603. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  604. ];
  605. // ag-grid 제외상품 컬럼
  606. var excepGoodsColumnDefs = [
  607. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  608. { headerName: "상품구분" , field: "goodsGb" , width: 100, cellClass: 'text-center'} ,
  609. { headerName: "Product ID" , field: "goodsCd" , width: 120, cellClass: 'text-center'},
  610. { headerName: "상품명" , field: "goodsNm" , width: 250 , cellClass: 'text-center'} ,
  611. { headerName: "쿠폰대상일련번호" , field: "cpnRefvalSq" , width: 120 , cellClass: 'text-center' , hide:true}
  612. ];
  613. // ag-grid 시리얼 및 난수 리스트
  614. var randomCouponDefs = [
  615. { headerName : "생성쿠폰키워드" , field: "rdCpnNm" , width:150, cellClass: 'text-center'} ,
  616. { headerName: "지급고객번호" , field: "custNm" , width:150, cellClass: 'text-center'},
  617. { headerName: "고객아이디" , field: "custId" , width:150, cellClass: 'text-center'},
  618. { headerName: "고객명" , field: "custNm" , width:150, cellClass: 'text-center'},
  619. { headerName: "지급일" , field: "regDt" , width:150, cellClass: 'text-center'},
  620. { headerName: "쿠폰사용일" , field: "usedDt" , width:150, cellClass: 'text-center'}
  621. ];
  622. // 선착순 쿠폰 리스트
  623. var limitedTimeCpnDefs = [
  624. {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  625. { headerName: "쿠폰시퀀스", field: "cpnId", width: 150, cellClass: 'text-center'}, //, hide: true
  626. { headerName: "선착순쿠폰명" , field: "limitCpnNm" , width: 200, cellClass: 'text-center'
  627. ,cellEditorParams: { maxlength: 20}
  628. } ,
  629. { headerName: "시작일시" , field: "downStdt" , width: 200, cellClass: 'text-center'
  630. ,cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
  631. },
  632. { headerName: "종료일시" , field: "downEddt" , width: 200 , cellClass: 'text-center'
  633. ,cellRenderer: function (params) { return gagaAgGrid.toDateTimeFormat(params.value); }
  634. } ,
  635. { headerName: "다운로드가능수량" , field: "downLimitQty" , width: 150 , cellClass: 'text-center'
  636. ,cellEditorParams: { maxlength: 4, validType: 'numeric'}
  637. },
  638. { headerName: "선착순시퀀스", field: "limitCpnId", width: 150, cellClass: 'text-center'} //, hide: true
  639. ];
  640. var inComGridOptions = gagaAgGrid.getGridOptions(columnDefs);
  641. var cateGridOptions = gagaAgGrid.getGridOptions(cateSelColumnDefs);
  642. var goodsGridOptions = gagaAgGrid.getGridOptions(goodsSelColumnDefs);
  643. var brandGridOptions = gagaAgGrid.getGridOptions(brandSelColumnDefs);
  644. var supplyGridOptions = gagaAgGrid.getGridOptions(supplyColumnDefs);
  645. var excepGoodsGridOptions = gagaAgGrid.getGridOptions(excepGoodsColumnDefs);
  646. var randomCouponGridOptions = gagaAgGrid.getGridOptions(randomCouponDefs);
  647. var limitedTimeCpnGridOptions = gagaAgGrid.getGridOptions(limitedTimeCpnDefs);
  648. inComGridOptions.defaultColDef.editable = true;
  649. inComGridOptions.rowSelection = "multiple";
  650. goodsGridOptions.rowSelection = "multiple";
  651. supplyGridOptions.rowSelection = "multiple";
  652. excepGoodsGridOptions.rowSelection = "multiple";
  653. cateGridOptions.rowSelection = "multiple";
  654. brandGridOptions.rowSelection = "multiple";
  655. inComGridOptions.stopEditingWhenGridLosesFocus = true;
  656. limitedTimeCpnGridOptions.defaultColDef.editable = true;
  657. limitedTimeCpnGridOptions.rowSelection = "multiple";
  658. // 선착순 쿠폰 행추가
  659. $('#btnAddLimitedTimeCpnRow').on('click', function() {
  660. var data = { cpnId: 1 ,limitCpnNm: null, downStdt: null, downEddt: null, downLimitQty: null, limitCpnId: null };
  661. gagaAgGrid.addRowData(limitedTimeCpnGridOptions, data, "limitCpnNm");
  662. });
  663. // 선착순 쿠폰 행삭제
  664. $('#btnDelLimitedTimeCpnRow').on('click', function() {
  665. var selectedData = limitedTimeCpnGridOptions.api.getSelectedRows();
  666. if (selectedData.length == 0) {
  667. mcxDialog.alert('선택된 행이 없습니다.');
  668. return;
  669. }
  670. var removedData = gagaAgGrid.removeRowData(limitedTimeCpnGridOptions, false);
  671. var arrLimitCpnId = [];
  672. $.each(selectedData, function(idx, item) {
  673. arrLimitCpnId.push(item.limitCpnId);
  674. });
  675. if (removedData.length > 0) {
  676. mcxDialog.confirm('삭제하시겠습니까?', {
  677. cancelBtnText: "취소",
  678. sureBtnText: "확인",
  679. sureBtnClick: function(){
  680. var data = { arrLimitCpnId : arrLimitCpnId
  681. ,cpnId : $('#CouponForm input[name=cpnId]').val()
  682. };
  683. var jsonData = JSON.stringify(data);
  684. gagajf.ajaxJsonSubmit('/marketing/coupon/limitedtime/coupon/update', jsonData);
  685. }
  686. });
  687. }
  688. });
  689. // 선착순 쿠폰 체크박스 클릭시
  690. $("#CouponForm #limitedTimeCpnBox").bind('click', function (){
  691. var chkBox= document.getElementById('limitedTimeCpnYn').checked;
  692. if(chkBox){ //true 체크가 되어있었는데 해제됐어 -> 탭을 숨겨
  693. $("#CouponForm .limitedTimeCpnTab").hide();
  694. $("#limitedTimeCpnYn").val("N");
  695. $("#CouponForm #totPubLimitQty").val(0);
  696. $("#CouponForm input[id=chkBoxTotPubQty]").prop("disabled", false);
  697. $("#CouponForm input[id=totPubLimitQty]").prop("disabled", false);
  698. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").parent("label").removeClass("checked");
  699. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").attr('readonly', false);
  700. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").prop('disabled', false);
  701. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").parent().prop('disabled', false);
  702. }else{ //false 체크가 안되어있었는데 체크됐어 -> 탭을 보여줘
  703. $("#CouponForm .limitedTimeCpnTab").show();
  704. $("#limitedTimeCpnYn").val("Y");
  705. $("#CouponForm #totPubLimitQty").val(0);
  706. $("#CouponForm input[id=chkBoxTotPubQty]").prop("disabled", true);
  707. $("#CouponForm input[id=totPubLimitQty]").prop("disabled", true);
  708. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").parent("label").addClass("checked");
  709. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").attr('readonly', true);
  710. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").prop('disabled', true);
  711. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").parent().prop('disabled', true);
  712. }
  713. });
  714. // 종료시간 클릭시
  715. var fnChangeEdHH = function (obj){
  716. var selectId = obj.id;
  717. var changeId = "";
  718. if(selectId == "downEdHH"){
  719. changeId = "downEdMM";
  720. }else if(selectId == "availEdHH"){
  721. changeId = "availEdMM";
  722. }else if(selectId == "buyEdHH"){
  723. changeId = "buyEdMM";
  724. }else{
  725. changeId = "custJoinEdMM";
  726. }
  727. if(obj.value == 24) {
  728. $("#CouponForm #"+changeId+" option").hide();
  729. $('#CouponForm #'+changeId+' option:first').show().prop("selected", true);
  730. } else {
  731. $("#CouponForm #"+changeId+" option").show();
  732. }
  733. };
  734. // 총발행 제한수량 -> 제한없음 처리
  735. $("#CouponForm #chkBoxTotPubQty").bind('click', function (){
  736. var chkBox= document.getElementById('chkNoLimitTotPubLimitQty').checked;
  737. if(chkBox){ //true 체크가 되어있었는데 해제됐어 -> 값0 inputbox disabled 해제
  738. $("#CouponForm #totPubLimitQty").val(0);
  739. $("#CouponForm input[id=totPubLimitQty]").prop("disabled", false);
  740. }else{ //false 체크가 안되어있었는데 체크됐어 -> 값0 inputbox disabled
  741. $("#CouponForm #totPubLimitQty").val(0);
  742. $("#CouponForm input[id=totPubLimitQty]").prop("disabled", true);
  743. }
  744. });
  745. // 1인당발행 제한수량 -> 제한없음 처리
  746. $("#CouponForm #chkBoxCustPubQty").bind('click', function (){
  747. var chkBox= document.getElementById('chkNoLimitCustPubLimitQty').checked;
  748. if(chkBox){ //true 체크가 되어있었는데 해제됐어 -> 값0 inputbox disabled 해제
  749. $("#CouponForm #custPubLimitQty").val(0);
  750. $("#CouponForm input[id=custPubLimitQty]").prop("disabled", false);
  751. }else{ //false 체크가 안되어있었는데 체크됐어 -> 값0 inputbox disabled
  752. $("#CouponForm #custPubLimitQty").val(0);
  753. $("#CouponForm input[id=custPubLimitQty]").prop("disabled", true);
  754. }
  755. });
  756. // 할인방식 할인율 일때, 할인값 체크
  757. var fnDcValOnkeyUp = function (obj){
  758. var inputName = $(obj).attr("name");
  759. var rdoDcWay = $('#CouponForm input:radio[name="rdoDcWay"]:checked').val();
  760. var dcVal = $("#CouponForm input[name="+inputName+"]").val();
  761. if(rdoDcWay == "G240_11"){
  762. if(dcVal > 100){
  763. mcxDialog.alert('할인율은 100을 넘을수 없습니다.');
  764. $("#CouponForm input[name="+inputName+"]").val('');
  765. $("#CouponForm input[name="+inputName+"]").focus();
  766. return;
  767. }
  768. }
  769. }
  770. // 할인값 동일적용
  771. $("#applySameValueBtn").bind('click change', function () {
  772. var cdPval = $("#CouponForm input[name=dcPval]").val();
  773. $("#CouponForm input[name=dcMval]").val(cdPval);
  774. $("#CouponForm input[name=dcAval]").val(cdPval);
  775. });
  776. // 쿠폰 등록 버튼 클릭시
  777. function fnCouponCreate(){
  778. mcxDialog.confirm('저장하시겠습니까?' , {
  779. cancelBtnText:"취소",
  780. sureBtnText:"확인",
  781. sureBtnClick: function () {
  782. gagajf.removeCommaAtNumberFormattedInput('#CouponForm');
  783. // 필수값들 셋팅
  784. setReqValue();
  785. // 필수값 validation 체크
  786. if (!gagajf.validation('#CouponForm')) {
  787. return false;
  788. }
  789. // 데이터 validation 체크
  790. if(!checkValidation()) {
  791. return false;
  792. }
  793. var usableCustGbArr = [];
  794. var chkCustGb = $('#CouponForm input:checkbox[name=usableCustGbArr]:checked');
  795. for(let i=0; i< chkCustGb.length; i++){
  796. usableCustGbArr.push(chkCustGb.eq(i).val());
  797. }
  798. var usableCustGradeArr = [];
  799. var chkCustGrade = $('#CouponForm input:checkbox[name=usableCustGradeArr]:checked');
  800. for(let i=0; i< chkCustGrade.length; i++){
  801. usableCustGradeArr.push(chkCustGrade.eq(i).val());
  802. }
  803. var payTypeArr = [];
  804. var chkPayType = $('#CouponForm input:checkbox[name=payTypeArr]:checked');
  805. for(let i=0; i< chkPayType.length; i++){
  806. payTypeArr.push(chkPayType.eq(i).val());
  807. }
  808. var data = {
  809. cpnId : $('#CouponForm input[name=cpnId]').val()
  810. ,cpnNm : $('#CouponForm input[name=cpnNm]').val()
  811. ,siteCd : $('#CouponForm select[name=siteCd]').val()
  812. ,afLinkCd : $('#CouponForm select[name=afLinkCd]').val()
  813. ,cpnType : $('input:radio[name="rdoCpnType"]:checked').val()
  814. ,applyScope : $('input:radio[name="rdoApplyScope"]:checked').val()
  815. ,dcWay : $('input:radio[name="rdoDcWay"]:checked').val()
  816. ,dcPval : $('#CouponForm input[name=dcPval]').val()
  817. ,dcMval : $('#CouponForm input[name=dcMval]').val()
  818. ,dcAval : $('#CouponForm input[name=dcAval]').val()
  819. ,maxDcAmt : $('#CouponForm input[name=maxDcAmt]').val()
  820. ,pdGb : $('#CouponForm select[name=pdGb]').val()
  821. ,availStdt : $('#CouponForm input[name=availStdt]').val()
  822. ,availEddt : $('#CouponForm input[name=availEddt]').val()
  823. ,availDays : $('#CouponForm input[name=availDays]').val()
  824. ,custPubLimitQty : $('#CouponForm input[name=custPubLimitQty]').val()
  825. ,totPubLimitQty : $('#CouponForm input[name=totPubLimitQty]').val()
  826. ,onePubQtyy : $('#CouponForm input[name=onePubQtyy]').val()
  827. ,downStdt : $('#CouponForm input[name=downStdt]').val()
  828. ,downEddt : $('#CouponForm input[name=downEddt]').val()
  829. ,buyLimitAmt : $('#CouponForm input[name=buyLimitAmt]').val()
  830. ,cpnStat : $('input:radio[name="disCpnStat"]:checked').val()
  831. ,endAlimYn : $('#CouponForm select[name=endAlimYn]').val()
  832. ,firstOrdYn : $('#CouponForm select[name=firstOrdYn]').val()
  833. ,downAblYn : $('#CouponForm select[name=downAblYn]').val()
  834. ,custJoinStdt : $('#CouponForm input[name=custJoinStdt]').val()
  835. ,custJoinEddt : $('#CouponForm input[name=custJoinEddt]').val()
  836. ,buyStdt : $('#CouponForm input[name=buyStdt]').val()
  837. ,buyEddt : $('#CouponForm input[name=buyEddt]').val()
  838. ,newCustYn : $('#CouponForm select[name=newCustYn]').val()
  839. ,afChannel : $('#CouponForm select[name=afChannel]').val()
  840. ,dcCdGb : $('input:radio[name="dcCdGb"]:checked').val()
  841. ,rdCpnNm : $('input:radio[name="rdCpnNm"]:checked').val()
  842. ,supplyCompList : gagaAgGrid.getAllRowData(supplyGridOptions)
  843. ,brandList : gagaAgGrid.getAllRowData(brandGridOptions)
  844. ,applyGoodsList : gagaAgGrid.getAllRowData(goodsGridOptions)
  845. ,exceptGoodsList : gagaAgGrid.getAllRowData(excepGoodsGridOptions)
  846. ,cateList : gagaAgGrid.getAllRowData(cateGridOptions)
  847. ,burdenList : gagaAgGrid.getAllRowData(inComGridOptions)
  848. ,usableCustGbArr : usableCustGbArr
  849. ,usableCustGradeArr : usableCustGradeArr
  850. ,payTypeArr : payTypeArr
  851. ,limitedTimeCpnList : gagaAgGrid.getAllRowData(limitedTimeCpnGridOptions)
  852. };
  853. var jsonData = JSON.stringify(data);
  854. gagajf.ajaxJsonSubmit($('#CouponForm').prop('action'), jsonData, fnCouponSaveCollback);
  855. }
  856. });
  857. }
  858. var fnCouponSaveCollback = function (result){
  859. uifnPopupClose('CouponRegForm');
  860. $('#btnSearch').trigger('click');
  861. }
  862. // 쿠폰 수정 시
  863. function fnCouponUpdate(){
  864. mcxDialog.confirm('수정하시겠습니까?' , {
  865. cancelBtnText:"취소",
  866. sureBtnText:"확인",
  867. sureBtnClick: function () {
  868. gagajf.removeCommaAtNumberFormattedInput('#CouponForm');
  869. // disabled 해제
  870. $("#CouponForm * ").attr("readonly" , false);
  871. $("#CouponForm * ").prop("disabled" , false);
  872. // 필수값들 셋팅
  873. setReqValue();
  874. // 필수값 validation 체크
  875. if (!gagajf.validation('#CouponForm')) {
  876. return false;
  877. }
  878. if(!checkValidation()) {
  879. return false;
  880. }
  881. gagajf.ajaxFormSubmit($('#CouponForm').prop('action'), '#CouponForm', function() {
  882. uifnPopupClose('CouponRegForm');
  883. $('#btnSearch').trigger('click');
  884. });
  885. }
  886. });
  887. }
  888. // disabled 해제
  889. function setDisabledFalse(){ debugger;
  890. }
  891. function checkValidation(){
  892. // 사용가능고객구분 체크박스 체크
  893. var usableCustGbCnt = $('#CouponForm input:checkbox[name=usableCustGbArr]').length;
  894. if(usableCustGbCnt<1){
  895. mcxDialog.alert("사용가능고객구분을 체크해주세요.");
  896. $('#CouponForm input:checkbox[name=usableCustGbArr]').focus();
  897. return false;
  898. }
  899. // 사용가능고객등급 체크박스 체크
  900. var usableCustGradeCnt = $('#CouponForm input:checkbox[name=usableCustGradeArr]').length;
  901. if(usableCustGradeCnt<1){
  902. mcxDialog.alert("사용가능고객등급을 체크해주세요.");
  903. $('#CouponForm input:checkbox[name=usableCustGradeArr]').focus();
  904. return false;
  905. }
  906. // 결제수단 체크박스 체크
  907. var payTypeCnt = $('#CouponForm input:checkbox[name=payTypeArr]').length;
  908. if(payTypeCnt<1){
  909. mcxDialog.alert("사용가능고객등급을 체크해주세요.");
  910. $('#CouponForm input:checkbox[name=payTypeArr]').focus();
  911. return false;
  912. }
  913. //신규가입 지급한다면 validation 체크
  914. if( $('#newCustYn option:selected').val() == "Y" ){
  915. var fromDate = $('#CouponForm input[name=custJoinStdt]').val();
  916. var toDate = $('#CouponForm input[name=custJoinEddt]').val();
  917. if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
  918. mcxDialog.alertC("신규가입기간 시작일자와 종료일자를 입력하세요.", {
  919. sureBtnText: "확인",
  920. sureBtnClick: function() {
  921. $('#CouponForm input[name=custJoinStdt]').focus();
  922. }
  923. });
  924. return false;
  925. }
  926. if (fromDate > toDate) {
  927. mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
  928. sureBtnText: "확인",
  929. sureBtnClick: function() {
  930. $('#CouponForm input[name=custJoinEddt]').focus();
  931. }
  932. });
  933. return false;
  934. }
  935. }
  936. // 첫구매 지급하면 validation 체크
  937. if( $('#firstOrdYn option:selected').val() == "Y" ){
  938. var fromDate = $('#CouponForm input[name=buyStdt]').val();
  939. var toDate = $('#CouponForm input[name=buyEddt]').val();
  940. if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
  941. mcxDialog.alertC("신규가입기간 시작일자와 종료일자를 입력하세요.", {
  942. sureBtnText: "확인",
  943. sureBtnClick: function() {
  944. $('#CouponForm input[name=buyStdt]').focus();
  945. }
  946. });
  947. return false;
  948. }
  949. if (fromDate > toDate) {
  950. mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
  951. sureBtnText: "확인",
  952. sureBtnClick: function() {
  953. $('#CouponForm input[name=buyEddt]').focus();
  954. }
  955. });
  956. return false;
  957. }
  958. }
  959. // 할인율 validation 체크 (100을 넘길수없음)
  960. if($('#dcWay').val() == 'G240_11') {
  961. if($('#dcPval').val() > 100) {
  962. mcxDialog.alert('PC할인율은 100을 초과할수없습니다.');
  963. $('#dcPval').focus();
  964. return false;
  965. } else if( $('#dcMval').val() > 100) {
  966. mcxDialog.alert('모바일(웹)할인율은 100을 초과할수없습니다.');
  967. $('#dcMval').focus();
  968. return false;
  969. } else if( $('#dcAval').val() > 100) {
  970. mcxDialog.alert('모바일(앱)할인율은 100을 초과할수없습니다.');
  971. $('#dcAval').focus();
  972. return false;
  973. }
  974. }
  975. // 할인쿠폰 유형에 따른 총 발행수량 수정 (주문서 쿠폰이고 난수쿠폰일 경우)
  976. if($('#CouponForm #cpnType').val() == "G230_20" && $('#CouponForm input:radio[name="dcCdGb"]:checked').val() == "G233_20") {
  977. if($("#CouponForm input[name=randomCpnQty]").val() == "" || $("#CouponForm input[name=randomCpnQty]").val() < 1) {
  978. mcxDialog.alert('쿠폰의 발급 수량을 입력해주세요.');
  979. $("#CouponForm input[name=randomCpnQty]").focus();
  980. return false;
  981. }
  982. if($("#CouponForm input[name=randomCpnQty]").val() > 10000) {
  983. mcxDialog.alert('쿠폰의 발급 수량은 10000장을 초과할 수 없습니다.');
  984. $("#CouponForm input[name=randomCpnQty]").focus();
  985. return false;
  986. }
  987. } else if ($('#CouponForm #cpnType').val() == "G230_20" && $('#CouponForm input:radio[name="dcCdGb"]:checked').val() == "G233_10") { // 주문서 쿠폰이고 시리얼 유형일 경우
  988. if($("#CouponForm input[name=serialCpnNm]").val().length > 10) {
  989. mcxDialog.alert('시리얼쿠폰키워드는 10글자를 넘을 수 없습니다.');
  990. $("#CouponForm input[name=serialCpnNm]").focus();
  991. return false;
  992. }
  993. if($("#CouponForm input[name=serialCpnQty]").val() == "" || $("#CouponForm input[name=serialCpnQty]").val() < 1) {
  994. mcxDialog.alert('쿠폰의 발급 수량을 입력해주세요.');
  995. $("#CouponForm input[name=serialCpnQty]").focus();
  996. return false;
  997. }
  998. if($("#CouponForm input[name=randomCpnQty]").val() > 10000) {
  999. mcxDialog.alert('쿠폰의 발급 수량은 10000장을 초과할 수 없습니다.');
  1000. $("#CouponForm input[name=serialCpnQty]").focus();
  1001. return false;
  1002. }
  1003. } else if ($('#CouponForm #cpnType').val() == "G230_11" && $("#limitedTimeCpnYn").val() == "Y") { // 상품쿠폰이고 선착순쿠폰 체크되어 있을때
  1004. let cpnData = gagaAgGrid.getAllRowData(limitedTimeCpnGridOptions);
  1005. if(cpnData.length < 1){
  1006. mcxDialog.alert("선착순 쿠폰을 설정해주세요.");
  1007. return false;
  1008. }else{
  1009. for(i=0; i<cpnData.length; i++){
  1010. if(gagajf.isNull(cpnData[i].limitCpnNm)){
  1011. mcxDialog.alert(i+1 + "번 행의 선착순 쿠폰명을 입력해주세요.");
  1012. return false;
  1013. }
  1014. if(gagajf.isNull(cpnData[i].downStdt)){
  1015. mcxDialog.alert(i+1 + "번 행의 선착순쿠폰 다운로드시작일을 입력해주세요.");
  1016. return false;
  1017. }
  1018. if(gagajf.isNull(cpnData[i].downEddt)){
  1019. mcxDialog.alert(i+1 + "번 행의 선착순쿠폰 다운로드종료일을 입력해주세요.");
  1020. return false;
  1021. }else{
  1022. var tempEddt = cpnData[i].downEddt.replace(/[^0-9]/g, '');
  1023. if(tempEddt.substr(8,14) == '000000'){
  1024. tempEddt = tempEddt.substr(0,8)+'235959';
  1025. cpnData[i].downEddt = tempEddt;
  1026. }
  1027. }
  1028. if(gagajf.isNull(cpnData[i].downLimitQty)){
  1029. mcxDialog.alert(i+1 + "번 행의 선착순쿠폰 다운로드가능수량을 입력해주세요.");
  1030. return false;
  1031. }else{
  1032. if(cpnData[i].downLimitQty<1){
  1033. mcxDialog.alert(i+1 + "번 행의 선착순쿠폰 다운로드가능수량을 1개이상 입력해주세요.");
  1034. return false;
  1035. }
  1036. }
  1037. }
  1038. limitedTimeCpnGridOptions.api.setRowData(cpnData);
  1039. }
  1040. }
  1041. return true;
  1042. }
  1043. // 할인방식 변경
  1044. $("#CouponForm input[name=rdoDcWay]").bind('click change', function () {
  1045. var radioValue = $(this).val();
  1046. //발급이력이있으면 수정안됨
  1047. if(issueCnt > 0 ) {
  1048. return false;
  1049. }
  1050. if(radioValue == 'G240_10') {
  1051. $('#dcPvalSpan').text("원");
  1052. $('#dcMvalSpan').text("원");
  1053. $('#dcAvalSpan').text("원");
  1054. $('#dcPval').val(0);
  1055. $('#dcMval').val(0);
  1056. $('#dcAval').val(0);
  1057. $('#maxDcAmt').val(0);
  1058. $("#CouponForm .maxDcAmtArea").hide();
  1059. } else {
  1060. $('#dcPvalSpan').text("%");
  1061. $('#dcMvalSpan').text("%");
  1062. $('#dcAvalSpan').text("%");
  1063. $('#dcPval').val(0);
  1064. $('#dcMval').val(0);
  1065. $('#dcAval').val(0);
  1066. $('#maxDcAmt').val(0);
  1067. $("#CouponForm .maxDcAmtArea").show();
  1068. }
  1069. });
  1070. // 쿠폰 상태 변경
  1071. $("#CouponForm input[name=rdoCpnType]").bind('click change', function () {
  1072. var radioValue = $(this).val();
  1073. if(mode == "U") {
  1074. radioValue = cpnDetail.cpnType;
  1075. }
  1076. // 즉시할인 쿠폰일때
  1077. if(radioValue == 'G230_10'){
  1078. $('#CouponForm .custJoinTr').hide();
  1079. $('#CouponForm .custJoinDateTr').hide();
  1080. $('#CouponForm .firstBuyTr').hide();
  1081. $('#CouponForm .buyDateTr').hide();
  1082. $('#CouponForm .dcCdCheck1').hide();
  1083. $('#CouponForm .limitedTimeCpnArea').hide();
  1084. }else{
  1085. if(radioValue == 'G230_11'){ // 상품쿠폰일때 선착순쿠폰 등록 가능
  1086. $('#CouponForm .limitedTimeCpnArea').show();
  1087. }else{
  1088. $('#CouponForm .limitedTimeCpnArea').hide();
  1089. }
  1090. $('#CouponForm .custJoinTr').show();
  1091. $('#CouponForm .firstBuyTr').show();
  1092. $('#CouponForm .dcCdCheck1').show();
  1093. }
  1094. // 상품쿠폰 선택시 적용범위 개별로 변경 나머진 전체
  1095. if(radioValue == 'G230_11') {
  1096. $("input:radio[name='rdoApplyScope']:radio[value='I']").prop('checked', true);
  1097. } else {
  1098. $("input:radio[name='rdoApplyScope']:radio[value='A']").prop('checked', true);
  1099. }
  1100. // 주문서 쿠폰 선택시 결제수단 노출
  1101. if(radioValue == 'G230_20') {
  1102. $('#CouponForm .payTypeTr').show();
  1103. $('#CouponForm #payType').attr('required' , true);
  1104. $("#CouponForm .dcCdGb").show(); // 할인쿠폰유형 노출
  1105. } else {
  1106. $('#CouponForm .payTypeTr').hide();
  1107. $('#CouponForm #payType').attr('required' , false );
  1108. $("#CouponForm .dcCdGb").hide(); // 할인쿠폰유형 숨김
  1109. $("#CouponForm input:radio[name='dcCdGb']:radio[value='G233_00']").prop('checked', true); // 주문서 쿠폰이 아닐 경우 일반 쿠폰으로 설정
  1110. }
  1111. $('#CouponForm #cpnType').val(radioValue);
  1112. });
  1113. // 할인 쿠폰 유형 변경
  1114. $("#CouponForm input[name=dcCdGb]").bind('click change', function () {
  1115. if(this.value == "G233_00") { // 일반 유형
  1116. $("#CouponForm .dcCdCheck1").show();
  1117. $("#CouponForm .dcCdCheck2").show();
  1118. $("#CouponForm .serialCpnArea").hide();
  1119. $("#CouponForm .randomCpnArea").hide();
  1120. $("#CouponForm #newCustYn").parent().attr("colspan", "");
  1121. $("#CouponForm .normalCol").attr("colspan", "5");
  1122. $('#CouponForm input[name="serialCpnNm"]').attr('required' , false);
  1123. $('#CouponForm input[name="serialCpnQty"]').attr('required' , false);
  1124. $('#CouponForm input[name="randomCpnQty"]').attr('required' , false);
  1125. } else {
  1126. if(this.value == "G233_10") { // 시리얼 유형
  1127. $("#CouponForm .serialCpnArea").show();
  1128. $("#CouponForm .randomCpnArea").hide();
  1129. $("#CouponForm .normalCol").attr("colspan", "5");
  1130. $('#CouponForm input[name="serialCpnNm"]').attr('required' , true);
  1131. $('#CouponForm input[name="serialCpnQty"]').attr('required' , true);
  1132. $('#CouponForm input[name="randomCpnQty"]').attr('required' , false);
  1133. } else { // 난수 유형
  1134. $("#CouponForm .serialCpnArea").hide();
  1135. $("#CouponForm .randomCpnArea").show();
  1136. $("#CouponForm .normalCol").attr("colspan", "");
  1137. $('#CouponForm input[name="serialCpnNm"]').attr('required' , false);
  1138. $('#CouponForm input[name="serialCpnQty"]').attr('required' , false);
  1139. $('#CouponForm input[name="randomCpnQty"]').attr('required' , true);
  1140. }
  1141. $("#CouponForm .dcCdCheck1").hide(); // 총발행제한수량, 1회발행수량, 1인당발행제한수량 숨김
  1142. $("#CouponForm .dcCdCheck2").hide(); // 총발행제한수량, 1회발행수량, 1인당발행제한수량 숨김
  1143. $("#CouponForm #newCustYn").parent().attr("colspan", "5"); // 총발행제한 수량을 없애면서 신규회원여부 colspan 수정
  1144. }
  1145. });
  1146. // 적용대상 - 브랜드 추가 버튼시
  1147. $('#btnBrandAdd').on('click' , function(){
  1148. cfnOpenBrandListPopup("fnSetPopupBrandInfo", "M");
  1149. });
  1150. // 브랜드 설정 / 브랜드 추가 콜백함수 (단수로 가져오므로 복수일 경우에 수정 확인 필요)
  1151. var fnSetPopupBrandInfo = function(result) {
  1152. for(let i = 0 ; i < result.length ; i++) {
  1153. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(brandGridOptions); // 받아온 모든 데이터
  1154. // 받아온 data for
  1155. for(let j = 0 ; j < gridListValue.length ; j++) {
  1156. if(gridListValue[j].brandCd == result[i].brandCd) { addChk = false; } // 중복체크
  1157. }
  1158. // 중복되지 않은 데이터 리스트에 추가
  1159. if(addChk) {
  1160. gagaAgGrid.addRowData(brandGridOptions, {"brandCd" : result[i].brandCd, "brandEnm" : result[i].brandEnm, "supplyCompNm" : result[i].supplyCompNm});
  1161. }
  1162. }
  1163. };
  1164. // 적용대상 - 브랜드 삭제 버튼시
  1165. $('#btnBrandDel').on('click' , function(){
  1166. var selectVal = brandGridOptions.api.getSelectedRows();
  1167. if(selectVal.length == 0) {
  1168. mcxDialog.alert("선택된 행이 없습니다");
  1169. return;
  1170. }
  1171. if(cpnDetail != null ) {
  1172. mcxDialog.confirm('삭제하시겠습니까?', {
  1173. cancelBtnText: "취소",
  1174. sureBtnText: "확인",
  1175. sureBtnClick: function(){
  1176. gagaAgGrid.removeRowData(brandGridOptions , false);
  1177. var cpnRefvalSqArr = [];
  1178. $.each(selectVal , function(idx , item){
  1179. cpnRefvalSqArr.push(item.cpnRefvalSq);
  1180. });
  1181. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  1182. ,cpnId : cpnDetail.cpnId
  1183. };
  1184. var jsonData = JSON.stringify(data);
  1185. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  1186. }
  1187. });
  1188. } else {
  1189. // 신규화면이면 그리드상 삭제
  1190. brandGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(brandGridOptions)});
  1191. }
  1192. });
  1193. // 적용대상 - 공급처 추가 버튼시
  1194. $('#btnSupplyAdd').on('click' , function (){
  1195. cfnOpenCompanyListPopup("fnSetPopupComapnyInfo" , "M");
  1196. });
  1197. // 공급업체 설정 / 업체 추가 콜백함수
  1198. var fnSetPopupComapnyInfo = function(result) {
  1199. // 기존 리스트 데이터 for
  1200. for(let i = 0 ; i < result.length ; i++) {
  1201. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(supplyGridOptions); // 받아온 모든 데이터
  1202. // 받아온 data for
  1203. for(let j = 0 ; j < gridListValue.length ; j++) {
  1204. // 동일한 data는 추가하지 않음
  1205. if(gridListValue[j].supplyCompCd == result[i].supplyCompCd) { addChk = false; } // 중복체크
  1206. }
  1207. // 중복되지 않은 데이터 리스트에 추가
  1208. if(addChk) {
  1209. gagaAgGrid.addRowData(supplyGridOptions, {"supplyCompCd" : result[i].supplyCompCd, "supplyCompNm" : result[i].supplyCompNm});
  1210. }
  1211. }
  1212. };
  1213. // 적용대상 - 공급처 삭제시시
  1214. $('#btnSupplyDel').on('click' , function () {
  1215. var selectVal = supplyGridOptions.api.getSelectedRows();
  1216. if(selectVal.length == 0) {
  1217. mcxDialog.alert("선택된 행이 없습니다");
  1218. return;
  1219. }
  1220. if(cpnDetail != null ) {
  1221. mcxDialog.confirm('삭제하시겠습니까?', {
  1222. cancelBtnText: "취소",
  1223. sureBtnText: "확인",
  1224. sureBtnClick: function(){
  1225. gagaAgGrid.removeRowData(supplyGridOptions , false);
  1226. var cpnRefvalSqArr = [];
  1227. $.each(selectVal , function(idx , item){
  1228. cpnRefvalSqArr.push(item.cpnRefvalSq);
  1229. });
  1230. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  1231. ,cpnId : $('#CouponForm #cpnId').val()
  1232. };
  1233. var jsonData = JSON.stringify(data);
  1234. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  1235. }
  1236. });
  1237. } else {
  1238. // 신규화면이면 그리드상 삭제
  1239. supplyGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(supplyGridOptions)});
  1240. }
  1241. });
  1242. // 적용대상 - 카테고리 추가시
  1243. $('#btnCateAdd').on('click' , function () {
  1244. cfnOpenCategoryPopup("fnSetPopupCategoryInfo");
  1245. });
  1246. // 카테고리 추가 콜백 함수
  1247. var fnSetPopupCategoryInfo = function (result) {
  1248. // 기존 리스트 데이터 for
  1249. for(let i = 0 ; i < result.length ; i++) {
  1250. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(cateGridOptions); // 받아온 모든 데이터
  1251. // 받아온 data for
  1252. for(let j = 0 ; j < gridListValue.length ; j++) {
  1253. // 동일한 data는 추가하지 않음
  1254. if(gridListValue[j].cateNo == result[i].cateNo) { addChk = false; } // 중복체크
  1255. }
  1256. // 중복되지 않은 데이터 리스트에 추가
  1257. if(addChk) {
  1258. 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});
  1259. }
  1260. }
  1261. }
  1262. // 적용대상 - 카테고리 삭제시
  1263. $('#btnCateDel').on('click' , function () {
  1264. var selectVal = cateGridOptions.api.getSelectedRows();
  1265. if(selectVal.length == 0) {
  1266. mcxDialog.alert("선택된 행이 없습니다");
  1267. return;
  1268. }
  1269. if(cpnDetail != null) {
  1270. mcxDialog.confirm('삭제하시겠습니까?', {
  1271. cancelBtnText: "취소",
  1272. sureBtnText: "확인",
  1273. sureBtnClick: function(){
  1274. gagaAgGrid.removeRowData(cateGridOptions , false);
  1275. var cpnRefvalSqArr = [];
  1276. $.each(selectVal , function(idx , item){
  1277. cpnRefvalSqArr.push(item.cpnRefvalSq);
  1278. });
  1279. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  1280. ,cpnId : $('#CouponForm #cpnId').val()
  1281. };
  1282. var jsonData = JSON.stringify(data);
  1283. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  1284. }
  1285. });
  1286. } else {
  1287. cateGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(cateGridOptions)});
  1288. }
  1289. });
  1290. // 적용대상 - 상품 추가시
  1291. $('#btnGoodsAdd').on('click' , function () {
  1292. cfnOpenGoodsPopup("fnSetPopupApplyGoodsInfo");
  1293. });
  1294. // 적용 상품 리스트 콜백함수
  1295. var fnSetPopupApplyGoodsInfo = function(result) {
  1296. gridAddGoodsList(goodsGridOptions, result , "apply");
  1297. };
  1298. // 적용대상 - 상품 삭제 시
  1299. $('#btnGoodsDel').on('click' , function () {
  1300. var selectVal = goodsGridOptions.api.getSelectedRows();
  1301. if(selectVal.length == 0) {
  1302. mcxDialog.alert("선택된 행이 없습니다");
  1303. return;
  1304. }
  1305. if(cpnDetail != null ) {
  1306. mcxDialog.confirm('삭제하시겠습니까?', {
  1307. cancelBtnText: "취소",
  1308. sureBtnText: "확인",
  1309. sureBtnClick: function(){
  1310. gagaAgGrid.removeRowData(goodsGridOptions , false);
  1311. var cpnRefvalSqArr = [];
  1312. $.each(selectVal , function(idx , item){
  1313. cpnRefvalSqArr.push(item.cpnRefvalSq);
  1314. });
  1315. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  1316. ,cpnId : $('#CouponForm #cpnId').val()
  1317. };
  1318. var jsonData = JSON.stringify(data);
  1319. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  1320. }
  1321. });
  1322. } else {
  1323. goodsGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(goodsGridOptions)});
  1324. }
  1325. });
  1326. // 적용대상 - 제외상품 추가시
  1327. $('#btnExcepGoodsAdd').on('click' , function(){
  1328. cfnOpenGoodsPopup("fnSetPopupExceptGoodsInfo");
  1329. });
  1330. // 적용 상품 리스트 콜백함수
  1331. var fnSetPopupExceptGoodsInfo = function(result) {
  1332. gridAddGoodsList(excepGoodsGridOptions, result , "except");
  1333. };
  1334. // 적용대상 - 제외상품 삭제시
  1335. $('#btnExcepGoodsDel').on('click' , function () {
  1336. var selectVal = excepGoodsGridOptions.api.getSelectedRows();
  1337. if(selectVal.length == 0) {
  1338. mcxDialog.alert("선택된 행이 없습니다");
  1339. return;
  1340. }
  1341. if(cpnDetail != null ) {
  1342. mcxDialog.confirm('삭제하시겠습니까?', {
  1343. cancelBtnText: "취소",
  1344. sureBtnText: "확인",
  1345. sureBtnClick: function(){
  1346. gagaAgGrid.removeRowData(excepGoodsGridOptions , false);
  1347. var cpnRefvalSqArr = [];
  1348. $.each(selectVal , function(idx , item){
  1349. cpnRefvalSqArr.push(item.cpnRefvalSq);
  1350. });
  1351. var data = { cpnRefvalSqArr : cpnRefvalSqArr
  1352. ,cpnId : $('#CouponForm #cpnId').val()
  1353. };
  1354. var jsonData = JSON.stringify(data);
  1355. gagajf.ajaxJsonSubmit('/marketing/coupon/refval/update', jsonData);
  1356. }
  1357. });
  1358. } else {
  1359. excepGoodsGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(excepGoodsGridOptions)});
  1360. }
  1361. });
  1362. // ag-grid 상품관련 list 콜백함수
  1363. function gridAddGoodsList(OriginGridListOption, result, gubun) {
  1364. var goodsGbVal = "G800_10";
  1365. if(gubun == 'except'){
  1366. goodsGbVal = "G800_30";
  1367. }
  1368. for(let i = 0 ; i < result.length ; i++) {
  1369. let addChk = true, gridListValue = gagaAgGrid.getAllRowData(OriginGridListOption); // 받아온 모든 데이터
  1370. // 받아온 data for
  1371. for(let j = 0 ; j < gridListValue.length ; j++) {
  1372. if(gridListValue[j].goodsCd == result[i].goodsCd) { addChk = false; } // 중복체크
  1373. }
  1374. // 중복되지 않은 데이터 리스트에 추가
  1375. if(addChk) {
  1376. gagaAgGrid.addRowData(OriginGridListOption, {"goodsGb": goodsGbVal, "goodsCd" : result[i].goodsCd, "goodsNm" : result[i].goodsNm});
  1377. }
  1378. }
  1379. }
  1380. // 기간 일수 변경시
  1381. function pdGbChange(pThis){
  1382. var selectVal = $(pThis).val();
  1383. if(typeof selectVal == "undefined") {
  1384. if(mode == "U") {
  1385. selectVal = cpnDetail.pdGb;
  1386. } else {
  1387. selectVal = "P";
  1388. }
  1389. }
  1390. if(selectVal == "P") {
  1391. $('.availDateTr').css('display' , '');
  1392. $('.availDayTr').css('display' , 'none');
  1393. $('#CouponForm #availDays').attr('required' , false);
  1394. $('#CouponForm #availStDay').attr('required' , true);
  1395. $('#CouponForm #availEdDay').attr('required' , true);
  1396. $('#CouponForm #availStdt').attr('required' , true);
  1397. $('#CouponForm #availEddt').attr('required' , true);
  1398. } else {
  1399. $('.availDateTr').css('display' , 'none');
  1400. $('.availDayTr').css('display' , '');
  1401. $('#CouponForm #availDays').attr('required' , true);
  1402. $('#CouponForm #availStDay').attr('required' , false);
  1403. $('#CouponForm #availEdDay').attr('required' , false);
  1404. $('#CouponForm #availStdt').attr('required' , false);
  1405. $('#CouponForm #availEddt').attr('required' , false);
  1406. }
  1407. }
  1408. // 첫구매여부 변경시
  1409. function firstOrdYnChange(pThis){
  1410. var selectVal = $(pThis).val();
  1411. if(typeof selectVal == "undefined") {
  1412. if(mode == "U") {
  1413. selectVal = cpnDetail.firstOrdYn;
  1414. } else {
  1415. selectVal = "N";
  1416. }
  1417. }
  1418. if(selectVal == "Y" ) {
  1419. $('.buyDateTr').css('display' , '');
  1420. $('#buyStdt').attr('required' , true);
  1421. $('#buyEddt').attr('required' , true);
  1422. } else {
  1423. $('.buyDateTr').css('display' , 'none');
  1424. $('#buyStdt').attr('required' , false);
  1425. $('#buyEddt').attr('required' , false);
  1426. }
  1427. }
  1428. // 신규회원여부 변경시
  1429. function newCustYnChange(pThis){
  1430. var selectVal = $(pThis).val();
  1431. if(typeof selectVal == "undefined") {
  1432. if(mode == "U") {
  1433. selectVal = cpnDetail.newCustYn;
  1434. } else {
  1435. selectVal = "N";
  1436. }
  1437. }
  1438. if(selectVal == "Y" ) {
  1439. $('.custJoinDateTr').css('display' , '');
  1440. $('#custJoinStdt').attr('required' , true);
  1441. $('#custJoinEddt').attr('required' , true);
  1442. } else {
  1443. $('.custJoinDateTr').css('display' , 'none');
  1444. $('#custJoinStdt').attr('required' , false);
  1445. $('#custJoinEddt').attr('required' , false);
  1446. }
  1447. }
  1448. // 행추가시
  1449. $('#btnAddRow').on('click' , function(){
  1450. var data = { supplyCompCd: null , burdenRate : null , delYn : null};
  1451. gagaAgGrid.addRowData(inComGridOptions , data , "supplyCompCd" );
  1452. });
  1453. // 행삭제시
  1454. $('#btnDelRow').on('click' , function(){
  1455. inComGridOptions.api.updateRowData({remove:gagaAgGrid.selectedRowData(inComGridOptions)});
  1456. });
  1457. // 제휴링크채널 수정 (제휴링크가 꼭필요한지 확인필요)
  1458. function fnChangeAfLinkCdList(){
  1459. var actionUrl = "/business/aflink/list" + '?' + $('#afChannel').serialize();
  1460. var tag = "";
  1461. $("#CouponForm #afLinkCd").children('option').remove();
  1462. gagajf.ajaxJsonSubmit(actionUrl, '', function(data) {
  1463. for (let i = 0; i < data.length; i++) {
  1464. if (data[i].useYn == 'Y') {
  1465. tag += '<option value="' + data[i].afLinkCd + '">[' + data[i].afLinkCd + '] ' + data[i].afLinkNm + '</option>';
  1466. }
  1467. }
  1468. $("#CouponForm #afLinkCd").append(tag);
  1469. $("#CouponForm #afLinkCd option:first").attr("selected" , "selected");
  1470. });
  1471. }
  1472. // 발급받은회원 팝업
  1473. var fnPubCustListPopUp = function (){
  1474. let cpnId = $("#CouponForm #cpnId").val();
  1475. var actionUrl = "/marketing/coupon/pubCust/popup/form?cpnId=" + cpnId;
  1476. cfnOpenModalPopup(actionUrl, 'CpnPubCustListPopup');
  1477. };
  1478. // 쿠폰발행팝업
  1479. function fnCustomerIssuePopUp(){
  1480. cfnCpnPubForCustPopup();
  1481. };
  1482. // 전송시 값 세팅
  1483. function setReqValue(){
  1484. // 쿠폰유형값 세팅
  1485. $('#CouponForm #cpnType').val($('#CouponForm input:radio[name="rdoCpnType"]:checked').val());
  1486. // 할인방식값 세팅
  1487. $('#CouponForm #dcWay').val($('#CouponForm input:radio[name="rdoDcWay"]:checked').val());
  1488. // 적용범위값 세팅
  1489. $('#CouponForm #applyScope').val($('#CouponForm input:radio[name="rdoApplyScope"]:checked').val());
  1490. // 쿠폰상태
  1491. $('#CouponForm input[name=cpnStat]').val($('input:radio[name="disCpnStat"]:checked').val());
  1492. // 다운로드기간 세팅
  1493. let downStdt = "";
  1494. let downEddt = "";
  1495. downStdt = $('#CouponForm input[name=downStDay]').val()+$('#CouponForm select[name=downStHH]').val()+$('#CouponForm select[name=downStMM]').val()+'00';
  1496. if($('#CouponForm select[name=downEdHH]').val() == "24"){
  1497. downEddt = $('#CouponForm input[name=downEdDay]').val()+'235959';
  1498. }else{
  1499. downEddt = $('#CouponForm input[name=downEdDay]').val()+$('#CouponForm select[name=downEdHH]').val()+$('#CouponForm select[name=downEdMM]').val()+'00';
  1500. }
  1501. downStdt = downStdt.replace(/[^0-9]/g, '');
  1502. downEddt = downEddt.replace(/[^0-9]/g, '');
  1503. $('#CouponForm #downStdt').val(downStdt);
  1504. $('#CouponForm #downEddt').val(downEddt);
  1505. // 유효기간 세팅
  1506. let availStdt = "";
  1507. let availEddt = "";
  1508. if($("#CouponForm #pdGb").val() == 'P') {
  1509. availStdt = $('#CouponForm input[name=availStDay]').val()+$('#CouponForm select[name=availStHH]').val()+$('#CouponForm select[name=availStMM]').val()+'00';
  1510. if($('#CouponForm select[name=availEdHH]').val() == "24"){
  1511. availEddt = $('#CouponForm input[name=availEdDay]').val()+'235959';
  1512. }else{
  1513. availEddt = $('#CouponForm input[name=availEdDay]').val()+$('#CouponForm select[name=availEdHH]').val()+$('#CouponForm select[name=availEdMM]').val()+'00';
  1514. }
  1515. availStdt = availStdt.replace(/[^0-9]/g, '');
  1516. availEddt = availEddt.replace(/[^0-9]/g, '');
  1517. $('#CouponForm #availStdt').val(availStdt);
  1518. $('#CouponForm #availEddt').val(availEddt);
  1519. $('#CouponForm #availDays').val('');
  1520. } else {
  1521. $('#CouponForm #availStdt').val('');
  1522. $('#CouponForm #availEddt').val('');
  1523. }
  1524. // 첫구매기간세팅
  1525. let buyStdt = "";
  1526. let buyEddt = "";
  1527. buyStdt = $('#CouponForm input[name=buyStDay]').val()+$('#CouponForm select[name=buyStHH]').val()+$('#CouponForm select[name=buyStMM]').val()+'00';
  1528. if($('#CouponForm select[name=buyEdHH]').val() == "24"){
  1529. buyEddt = $('#CouponForm input[name=buyEdDay]').val()+'235959';
  1530. }else{
  1531. buyEddt = $('#CouponForm input[name=buyEdDay]').val()+$('#CouponForm select[name=buyEdHH]').val()+$('#CouponForm select[name=buyEdMM]').val()+'00';
  1532. }
  1533. buyStdt = buyStdt.replace(/[^0-9]/g, '');
  1534. buyEddt = buyEddt.replace(/[^0-9]/g, '');
  1535. $('#CouponForm #buyStdt').val(buyStdt);
  1536. $('#CouponForm #buyEddt').val(buyEddt);
  1537. // 신규회원기간 세팅
  1538. let custJoinStdt = "";
  1539. let custJoinEddt = "";
  1540. custJoinStdt = $('#CouponForm input[name=custJoinStDay]').val()+$('#CouponForm select[name=custJoinStHH]').val()+$('#CouponForm select[name=custJoinStMM]').val()+'00';
  1541. if($('#CouponForm select[name=custJoinEdHH]').val() == "24"){
  1542. custJoinEddt = $('#CouponForm input[name=custJoinEdDay]').val()+'235959';
  1543. }else{
  1544. custJoinEddt = $('#CouponForm input[name=custJoinEdDay]').val()+$('#CouponForm select[name=custJoinEdHH]').val()+$('#CouponForm select[name=custJoinEdMM]').val()+'00';
  1545. }
  1546. custJoinStdt = custJoinStdt.replace(/[^0-9]/g, '');
  1547. custJoinEddt = custJoinEddt.replace(/[^0-9]/g, '');
  1548. $('#CouponForm #custJoinStdt').val(custJoinStdt);
  1549. $('#CouponForm #custJoinEddt').val(custJoinEddt);
  1550. // 할인쿠폰 유형에 따른 총 발행수량 수정 (주문서 쿠폰이고 난수쿠폰일 경우)
  1551. if($('#CouponForm #cpnType').val() == "G230_20" && $('#CouponForm input:radio[name="dcCdGb"]:checked').val() == "G233_20") {
  1552. $('#CouponForm input[name="totPubLimitQty"]').val($('#CouponForm input[name="randomCpnQty"]').val()); // 총 발행수량 난수 생성수량으로 변경
  1553. $('#CouponForm input[name="custPubLimitQty"]').val(1); // 1인당 발행제한수량 1개 고정
  1554. $('#CouponForm input[name="onePubQty"]').val(1); // 1회발행수량 1개 고정
  1555. } else if ($('#CouponForm #cpnType').val() == "G230_20" && $('#CouponForm input:radio[name="dcCdGb"]:checked').val() == "G233_10") { // 주문서 쿠폰이고 시리얼 유형일 경우
  1556. $('#CouponForm input[name="rdCpnNm"]').val($('#CouponForm input[name="serialCpnNm"]').val()); // 시리얼유형쿠폰명 저장
  1557. $('#CouponForm input[name="totPubLimitQty"]').val($('#CouponForm input[name="serialCpnQty"]').val()); // 총 발행수량 랜덤쿠폰발급수량으로 변경
  1558. $('#CouponForm input[name="custPubLimitQty"]').val(1); // 1인당 발행제한수량 1개 고정
  1559. $('#CouponForm input[name="onePubQty"]').val(1); // 1회발행수량 1개 고정
  1560. }
  1561. // 적용대상 - 공급처 그리드 전체값 세팅
  1562. /*var supplyAllData = gagaAgGrid.getAllRowData(supplyGridOptions);
  1563. var jsonSupplyCompData = JSON.stringify(supplyAllData);
  1564. $('#CouponForm #supplyCompList').val(jsonSupplyCompData);*/
  1565. $('#CouponForm #supplyCompList').val(gagaAgGrid.getAllRowData(supplyGridOptions));
  1566. // 적용대상 - 브랜드 그리드 전체값 세팅
  1567. /*var brandAllData = gagaAgGrid.getAllRowData(brandGridOptions);
  1568. var jsonBrandData = JSON.stringify(brandAllData);
  1569. $('#CouponForm #brandList').val(jsonBrandData);*/
  1570. $('#CouponForm #brandList').val(gagaAgGrid.getAllRowData(brandGridOptions));
  1571. // // 적용대상 - 카테고리 그리드 전체값 세팅
  1572. /*var cateAllData = gagaAgGrid.getAllRowData(cateGridOptions);
  1573. var jsonCateData = JSON.stringify(cateAllData);
  1574. $('#CouponForm #cateList').val(jsonCateData);*/
  1575. $('#CouponForm #cateList').val(gagaAgGrid.getAllRowData(cateGridOptions));
  1576. // 적용대상 - 적용상품 그리드 전체값 세팅
  1577. /*var goodsAllData = gagaAgGrid.getAllRowData(goodsGridOptions);
  1578. var jsonGoodsData = JSON.stringify(goodsAllData);
  1579. $('#CouponForm #applyGoodsList').val(jsonGoodsData);*/
  1580. $('#CouponForm #applyGoodsList').val(gagaAgGrid.getAllRowData(goodsGridOptions));
  1581. // 적용대상 - 제외상품 그리드 전체값 세팅
  1582. /*var exceptGoodsAllData = gagaAgGrid.getAllRowData(excepGoodsGridOptions);
  1583. var jsonExceptGoodsData = JSON.stringify(exceptGoodsAllData);
  1584. $('#CouponForm #excepGoodsList').val(jsonExceptGoodsData);*/
  1585. $('#CouponForm #excepGoodsList').val(gagaAgGrid.getAllRowData(excepGoodsGridOptions));
  1586. // 입점업체분담율 그리드 전체값 세팅
  1587. /*var inCompBurdenAllData = gagaAgGrid.getAllRowData(inComGridOptions);
  1588. var jsonInCompBurdenData = JSON.stringify(inCompBurdenAllData);
  1589. $('#CouponForm #burdenList').val(jsonInCompBurdenData);*/
  1590. $('#CouponForm #burdenList').val(gagaAgGrid.getAllRowData(inComGridOptions));
  1591. }
  1592. $(document).ready(function() {
  1593. gagaAgGrid.createGrid('inComGridList', inComGridOptions);
  1594. gagaAgGrid.createGrid('brandGridList', brandGridOptions);
  1595. gagaAgGrid.createGrid('cateGridList', cateGridOptions);
  1596. gagaAgGrid.createGrid('supplyGridList', supplyGridOptions);
  1597. gagaAgGrid.createGrid('goodsGridList', goodsGridOptions);
  1598. gagaAgGrid.createGrid('excepGoodsGridList', excepGoodsGridOptions);
  1599. gagaAgGrid.createGrid('randomCpnList', randomCouponGridOptions);
  1600. gagaAgGrid.createGrid('limitedTimeCpnList', limitedTimeCpnGridOptions);
  1601. // 일단 버튼 숨김
  1602. $(".couponButton").hide();
  1603. // 초기화시 데이터 세팅
  1604. if (mode == "N") {
  1605. $('input[name=rdoCpnType]').eq(0).attr("checked", true);
  1606. $('input[name=dcCdGb]').eq(0).attr("checked", true);
  1607. $('input[name=rdoDcWay]').eq(0).attr("checked", true);
  1608. $('input[name=rdoApplyScope]').eq(0).attr("checked", true)
  1609. $('#CouponForm #availEdHH option:last').attr("selected", "selected");
  1610. $('#CouponForm #availEdMM option').hide();
  1611. $('#CouponForm #availEdMM option:first').show().prop("selected", true);
  1612. $('#downEdHH option:last').attr("selected", "selected");
  1613. $('#downEdMM option').hide();
  1614. $('#downEdMM option:first').show().prop("selected", true);
  1615. $('#custJoinEdHH option:last').attr("selected", "selected");
  1616. $('#custJoinEdMM option').hide();
  1617. $('#custJoinEdMM option:first').show().prop("selected", true);
  1618. $('#buyEdHH option:last').attr("selected", "selected");
  1619. $('#buyEdMM option').hide();
  1620. $('#buyEdMM option:first').show().prop("selected", true);
  1621. $("#CouponForm #afChannel option:first").attr("selected" , "selected");
  1622. $("#CouponForm .normalCol").attr("colspan", "5");
  1623. $("#CouponForm .randomCpnArea").hide();
  1624. $("#CouponForm .maxDcAmtArea").hide();
  1625. $("input:radio[name='disCpnStat']:radio[value='G232_10']").prop('checked', true); // 선택하기
  1626. if($('input:radio[name="rdoCpnType"]:checked').val() == 'G230_10'){
  1627. $('#CouponForm .custJoinTr').hide();
  1628. $('#CouponForm .custJoinDateTr').hide();
  1629. $('#CouponForm .firstBuyTr').hide();
  1630. $('#CouponForm .buyDateTr').hide();
  1631. $('#CouponForm .dcCdCheck1').hide();
  1632. }
  1633. $("#btnCouponSave").show(); // 저장버튼
  1634. $("#CouponForm .buttonSpan").show();
  1635. } else {
  1636. if(cpnDetail.cpnStat == "G232_10"){
  1637. $("#btnCouponSave").show(); // 저장버튼
  1638. $("#btnChangeStatIng").show(); // 진행버튼
  1639. $("#btnCouponDelete").show(); // 삭제버튼
  1640. $("#CouponForm .buttonSpan").show(); //행추가,삭제버튼
  1641. }else if(cpnDetail.cpnStat == "G232_10"){
  1642. $("#btnCouponSave").hide(); // 저장버튼
  1643. $("#btnCouponStop").show(); // 중지버튼
  1644. $("#btnCouponDelete").show(); // 삭제버튼
  1645. $("#CouponForm .buttonSpan").hide(); //행추가,삭제버튼
  1646. }else{
  1647. $("#CouponForm .buttonSpan").hide(); //행추가,삭제버튼
  1648. }
  1649. if(cpnCustGbList.length > 0){
  1650. var chkboxCnt = $('#CouponForm input:checkbox[name=usableCustGbArr]').length;
  1651. var dataCnt = cpnCustGbList.length;
  1652. for(let i=0; i<chkboxCnt; i++){
  1653. for(let j=0; j<dataCnt; j++){
  1654. var data = cpnCustGbList[j].usableCustGb;
  1655. if($('#CouponForm input:checkbox[name=usableCustGbArr]').eq(i).val() == data){
  1656. $('#CouponForm input:checkbox[name=usableCustGbArr]').eq(i).prop('checked', true);
  1657. $("#CouponForm input:checkbox[name=usableCustGbArr]").eq(i).parent().addClass('checked');
  1658. }
  1659. }
  1660. }
  1661. }
  1662. if(cpnCustGradeList.length > 0){
  1663. var chkboxCnt = $('#CouponForm input:checkbox[name=usableCustGradeArr]').length;
  1664. var dataCnt = cpnCustGradeList.length;
  1665. for(let i=0; i<chkboxCnt; i++){
  1666. for(let j=0; j<dataCnt; j++){
  1667. var data = cpnCustGradeList[j].usableCustGrade;
  1668. if($('#CouponForm input:checkbox[name=usableCustGradeArr]').eq(i).val() == data){
  1669. $('#CouponForm input:checkbox[name=usableCustGradeArr]').eq(i).prop('checked', true);
  1670. $("#CouponForm input:checkbox[name=usableCustGradeArr]").eq(i).parent().addClass('checked');
  1671. }
  1672. }
  1673. }
  1674. }
  1675. if(cpnPayTypeList.length > 0){
  1676. var chkboxCnt = $('#CouponForm input:checkbox[name=payTypeArr]').length;
  1677. var dataCnt = cpnPayTypeList.length;
  1678. for(let i=0; i<chkboxCnt; i++){
  1679. for(let j=0; j<dataCnt; j++){
  1680. var data = cpnPayTypeList[j].payType;
  1681. if($('#CouponForm input:checkbox[name=payTypeArr]').eq(i).val() == data){
  1682. $('#CouponForm input:checkbox[name=payTypeArr]').eq(i).prop('checked', true);
  1683. $("#CouponForm input:checkbox[name=payTypeArr]").eq(i).parent().addClass('checked');
  1684. }
  1685. }
  1686. }
  1687. }
  1688. // 수정모드시 그리드 세팅
  1689. inComGridOptions.api.setRowData(cpnDtlBurdenList);
  1690. supplyGridOptions.api.setRowData(cpnDtlRefvalSupplyCompList);
  1691. goodsGridOptions.api.setRowData(cpnDtlRefvalApplyGoodsList);
  1692. excepGoodsGridOptions.api.setRowData(cpnDtlRefvalExceptGoodsList);
  1693. brandGridOptions.api.setRowData(cpnDtlRefvalBrandList);
  1694. cateGridOptions.api.setRowData(cpnDtlRefvalCateList);
  1695. randomCouponGridOptions.api.setRowData(randomCpnList);
  1696. limitedTimeCpnGridOptions.api.setRowData(limitedTimeCpnList);
  1697. // 기본정보 세팅
  1698. $("#CouponForm input:radio[name='rdoDcWay']:radio[value=" + cpnDetail.dcWay + "]").prop('checked', true);
  1699. $("#CouponForm input:radio[name='rdoCpnType']:radio[value=" + cpnDetail.cpnType + "]").prop('checked', true);
  1700. $("#CouponForm input:radio[name='rdoApplyScope']:radio[value=" + cpnDetail.applyScope + "]").prop('checked', true);
  1701. $("#CouponForm #dcPval").val(cpnDetail.dcPval);
  1702. $("#CouponForm #dcMval").val(cpnDetail.dcMval);
  1703. $("#CouponForm #dcAval").val(cpnDetail.dcAval);
  1704. $("#CouponForm #maxDcAmt").val(cpnDetail.maxDcAmt);
  1705. $("#CouponForm #totPubLimitQty").val(cpnDetail.totPubLimitQty);
  1706. $("#CouponForm #custPubLimitQty").val(cpnDetail.custPubLimitQty);
  1707. $("#CouponForm #onePubQty").val(cpnDetail.onePubQty);
  1708. $("#CouponForm #usableCustGb").val(cpnDetail.usableCustGb).prop("selected", true);
  1709. $("#CouponForm #usableCustGrade").val(cpnDetail.usableCustGrade).prop("selected", true);
  1710. $("#CouponForm #endAlimYn").val(cpnDetail.endAlimYn).prop("selected", true);
  1711. $("#CouponForm #firstOrdYn").val(cpnDetail.firstOrdYn).prop("selected", true);
  1712. $("#CouponForm #reissuance").val(cpnDetail.reissuance).prop("selected", true);
  1713. $("#CouponForm #dnGb").val(cpnDetail.dnGb).prop("selected", true);
  1714. //$("#CouponForm #cpnStat").val(cpnDetail.cpnStat).prop("selected", true);
  1715. $("input:radio[name='disCpnStat']:radio[value="+cpnDetail.cpnStat+"]").prop('checked', true); // 선택하기
  1716. $("#CouponForm #newCustYn").val(cpnDetail.newCustYn).prop("selected", true);
  1717. $("#CouponForm #pdGb").val(cpnDetail.pdGb).prop("selected", true);
  1718. $("#CouponForm #siteCd").val(cpnDetail.siteCd).prop("selected", true);
  1719. $("#CouponForm #afChannel").val(cpnDetail.afChannel).prop("selected", true);
  1720. $("#CouponForm #cpnNm").val(cpnDetail.cpnNm);
  1721. $("#CouponForm #downAblYn").val(cpnDetail.downAblYn);
  1722. $("#CouponForm #buyLimitAmt").val(cpnDetail.buyLimitAmt);
  1723. $("#CouponForm #cpnId").val(cpnDetail.cpnId);
  1724. if(limitedTimeCpnList.length>0 && cpnDetail.cpnType == "G230_11"){ //상품쿠폰이고 선착순쿠폰일때
  1725. $("#CouponForm #limitedTimeCpnYn").val("Y");
  1726. $("#CouponForm .limitedTimeCpnTab").show();
  1727. $('#CouponForm .limitedTimeCpnArea').show();
  1728. $("#CouponForm input[id=limitedTimeCpnYn]").parent("label").addClass("checked");
  1729. $("#CouponForm input[id=limitedTimeCpnYn]").attr('readonly', true);
  1730. $("#CouponForm input[id=limitedTimeCpnYn]").prop('disabled', true);
  1731. $("#CouponForm input[id=limitedTimeCpnYn]").parent().prop('disabled', true);
  1732. $("#CouponForm input[id=totPubLimitQty]").prop("disabled", true);
  1733. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").parent("label").addClass("checked");
  1734. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").attr('readonly', true);
  1735. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").prop('disabled', true);
  1736. $("#CouponForm input[id=chkNoLimitTotPubLimitQty]").parent().prop('disabled', true);
  1737. }else{
  1738. $("#CouponForm #limitedTimeCpnYn").val("N");
  1739. $("#CouponForm .limitedTimeCpnTab").hide();
  1740. $('#CouponForm .limitedTimeCpnArea').hide();
  1741. }
  1742. // 한번 저장되면 쿠폰유형, 할인쿠폰유형, 난수 생성수량, 시리얼명, 시리얼쿠폰발급수량 수정 불가 처리
  1743. $("#CouponForm input:radio[name='rdoCpnType']").attr('readonly', true);
  1744. $("#CouponForm input:radio[name='rdoCpnType']").prop('disabled', true);
  1745. $("#CouponForm input:radio[name='rdoCpnType']").parent().prop('disabled', true);
  1746. $("#CouponForm input:radio[name='dcCdGb']").attr('readonly', true);
  1747. $("#CouponForm input:radio[name='dcCdGb']").prop('disabled', true);
  1748. $("#CouponForm input:radio[name='dcCdGb']").parent().prop('disabled', true);
  1749. $("#CouponForm input:radio[name='dcCdGb']:radio[value=" + cpnDetail.dcCdGb + "]").prop('checked', true);
  1750. $("#CouponForm input[name='serialCpnNm']").prop("disabled", true);
  1751. $("#CouponForm input[name='serialCpnQty']").prop("disabled", true);
  1752. $("#CouponForm input[name='randomCpnQty']").prop("disabled", true);
  1753. // 즉시할인 쿠폰이면
  1754. if(cpnDetail.cpnType == "G230_10") {
  1755. $('#CouponForm .custJoinTr').hide();
  1756. $('#CouponForm .custJoinDateTr').hide();
  1757. $('#CouponForm .firstBuyTr').hide();
  1758. $('#CouponForm .buyDateTr').hide();
  1759. $('#CouponForm .dcCdCheck1').hide();
  1760. }else{
  1761. $('#CouponForm .custJoinTr').show();
  1762. $('#CouponForm .custJoinDateTr').show();
  1763. $('#CouponForm .firstBuyTr').show();
  1764. $('#CouponForm .buyDateTr').show();
  1765. $('#CouponForm .dcCdCheck1').show();
  1766. }
  1767. // 할인방식이 할인율이면 최대할인금액 노출
  1768. if(cpnDetail.dcWay == "G240_11"){
  1769. $("#CouponForm .maxDcAmtArea").show();
  1770. }
  1771. // 주문서 쿠폰이면 할인쿠폰유형 노출
  1772. if(cpnDetail.cpnType == "G230_20") {
  1773. $("#CouponForm .dcCdGb").show();
  1774. }
  1775. // 할인코드유형이 일반유형이 아니면
  1776. if(cpnDetail.dcCdGb != "G233_00" ) {
  1777. $("#CouponForm .randomCpnTab").show(); // 시리얼 및 난수 TAB 노출
  1778. $("#CouponForm .dcCdCheck1").hide(); // 총발행제한수량, 1회발행수량, 1인당발행제한수량 숨김
  1779. $("#CouponForm .dcCdCheck2").hide(); // 총발행제한수량, 1회발행수량, 1인당발행제한수량 숨김
  1780. if(cpnDetail.dcCdGb == "G233_10") { // 시리얼 유형
  1781. $("#CouponForm input[name='serialCpnQty']").val(cpnDetail.totPubLimitQty);
  1782. $("#CouponForm input[name='serialCpnNm']").val(cpnDetail.rdCpnNm);
  1783. $("#CouponForm .normalCol").attr("colspan", "5");
  1784. $("#CouponForm .serialCpnArea").show();
  1785. $("#CouponForm .randomCpnArea").hide();
  1786. } else if (cpnDetail.dcCdGb == "G233_20") {
  1787. $("#CouponForm input[name='randomCpnQty']").val(cpnDetail.totPubLimitQty);
  1788. $("#CouponForm .normalCol").attr("colspan", "");
  1789. $("#CouponForm .randomCpnArea").show();
  1790. $("#CouponForm .serialCpnArea").hide();
  1791. }
  1792. }
  1793. // 쿠폰다운 날짜
  1794. let edDtArr;
  1795. if(!gagajf.isNull(cpnDetail.downEddt)){
  1796. edDtArr = cpnDetail.downEddt.split(" ");
  1797. if(edDtArr[1] == "23:59:59") {
  1798. edHour = "24";
  1799. edMinute = "00";
  1800. $("#CouponForm #downEdMM option").hide();
  1801. $('#CouponForm #downEdMM option:first').show().prop("selected", true);
  1802. }
  1803. }
  1804. // 유효 날짜
  1805. let availEdDtArr;
  1806. if(!gagajf.isNull(cpnDetail.availEddt)){
  1807. availEdDtArr = cpnDetail.availEddt.split(" ");
  1808. if(availEdDtArr[1] == "23:59:59") {
  1809. edHour = "24";
  1810. edMinute = "00";
  1811. $("#CouponForm #availEdMM option").hide();
  1812. $('#CouponForm #availEdMM option:first').show().prop("selected", true);
  1813. }
  1814. }
  1815. // 첫구매 날짜
  1816. let firstBuyEdDtArr;
  1817. if(!gagajf.isNull(cpnDetail.buyEddt)){
  1818. firstBuyEdDtArr = cpnDetail.buyEddt.split(" ");
  1819. if(firstBuyEdDtArr[1] == "23:59:59") {
  1820. edHour = "24";
  1821. edMinute = "00";
  1822. $("#CouponForm #buyEdMM option").hide();
  1823. $('#CouponForm #buyEdMM option:first').show().prop("selected", true);
  1824. }
  1825. }
  1826. // 신규가입 날짜
  1827. let custJoinEdDtArr;
  1828. if(!gagajf.isNull(cpnDetail.custJoinEddt)){
  1829. custJoinEdDtArr = cpnDetail.custJoinEddt.split(" ");
  1830. if(custJoinEdDtArr[1] == "23:59:59") {
  1831. edHour = "24";
  1832. edMinute = "00";
  1833. $("#CouponForm #custJoinEdMM option").hide();
  1834. $('#CouponForm #custJoinEdMM option:first').show().prop("selected", true);
  1835. }
  1836. }
  1837. /*
  1838. $("#CouponForm input:checkbox[name='cpnCreateType']").parent("label").addClass("formControl");
  1839. $("#CouponForm input:checkbox[name='cpnCreateType']").parent("label").prop('disabled', true);
  1840. $("#CouponForm input:checkbox[name='cpnCreateType']").addClass("formControl");
  1841. $("#CouponForm input:checkbox[name='cpnCreateType']").prop('disabled', true);
  1842. */
  1843. // 만약 쿠폰 발급한 내역이 있으면 쿠폰수정못하게 readonly , disabled 속성 추가
  1844. if (issueCnt > 0) {
  1845. $("#CouponForm #usableCustGb").attr('readonly', true);
  1846. $("#CouponForm #usableCustGb").attr('disabled', true);
  1847. $("#CouponForm #afChannel").attr('readonly', true);
  1848. $("#CouponForm #afChannel").attr('disabled', true);
  1849. $("#CouponForm #usableCustGrade").attr('readonly', true);
  1850. $("#CouponForm #usableCustGrade").attr('disabled', true);
  1851. $("#CouponForm #endAlimYn").attr('readonly', true);
  1852. $("#CouponForm #endAlimYn").attr('disabled', true);
  1853. $("#CouponForm #firstOrdYn").attr('readonly', true);
  1854. $("#CouponForm #firstOrdYn").attr('disabled', true);
  1855. $("#CouponForm #reissuance").attr('readonly', true);
  1856. $("#CouponForm #reissuance").attr('disabled', true);
  1857. $("#CouponForm #dnGb").attr('readonly', true);
  1858. $("#CouponForm #dnGb").attr('disabled', true);
  1859. $("#CouponForm #newCustYn").attr('readonly', true);
  1860. $("#CouponForm #newCustYn").attr('disabled', true);
  1861. $("#CouponForm #pdGb").attr('readonly', true);
  1862. $("#CouponForm #pdGb").attr('disabled', true);
  1863. $("#CouponForm #downAblYn").attr('readonly', true);
  1864. $("#CouponForm #downAblYn").attr('disabled', true);
  1865. $("#CouponForm #siteCd").attr('readonly', true);
  1866. $("#CouponForm #siteCd").attr('disabled', true);
  1867. $("#CouponForm #cpnNm").attr('readonly', true);
  1868. $("#CouponForm #cpnNm").attr('disabled', true);
  1869. $("#CouponForm #dcPval").attr('readonly', true);
  1870. $("#CouponForm #dcPval").attr('disabled', true);
  1871. $("#CouponForm #dcMval").attr('readonly', true);
  1872. $("#CouponForm #dcMval").attr('disabled', true);
  1873. $("#CouponForm #dcAval").attr('readonly', true);
  1874. $("#CouponForm #dcAval").attr('disabled', true);
  1875. $("#CouponForm #maxDcAmt").attr('readonly', true);
  1876. $("#CouponForm #maxDcAmt").attr('disabled', true);
  1877. $("#CouponForm #totPubLimitQty").attr('readonly', true);
  1878. $("#CouponForm #totPubLimitQty").attr('disabled', true);
  1879. $("#CouponForm #custPubLimitQty").attr('readonly', true);
  1880. $("#CouponForm #custPubLimitQty").attr('disabled', true);
  1881. $("#CouponForm #onePubQty").attr('readonly', true);
  1882. $("#CouponForm #onePubQty").attr('disabled', true);
  1883. $("#CouponForm #downStDay").attr('readonly', true);
  1884. $("#CouponForm #downStDay").attr('disabled', true);
  1885. $("#CouponForm #downStHH").attr('readonly', true);
  1886. $("#CouponForm #downStHH").attr('disabled', true);
  1887. $("#CouponForm #downStMM").attr('readonly', true);
  1888. $("#CouponForm #downStMM").attr('disabled', true);
  1889. $("#CouponForm #buyLimitAmt").attr('readonly', true);
  1890. $("#CouponForm input:radio[name='rdoDcWay']").attr('readonly', true);
  1891. $("#CouponForm input:radio[name='rdoApplyScope']").attr('readonly', true);
  1892. $("#CouponForm .rdoBtn").css('cursor', 'auto');
  1893. $("#CouponForm #cpnId").attr('readonly', true);
  1894. $("#CouponForm #cpnId").attr('disabled', true);
  1895. $("#CouponForm input:checkbox[name='cpnCreateType']").attr('readonly', true);
  1896. $("#CouponForm input:checkbox[name='cpnCreateType']").attr('disabled', true);
  1897. $("#CouponForm input:checkbox[name=cpnCreateType]").attr('checked', true);
  1898. $("#CouponForm input:checkbox[name=cpnCreateType]").parent().addClass('checked');
  1899. }
  1900. // 다운로드기간 세팅
  1901. splitDate("start", cpnDetail.downStdt, "down");
  1902. splitDate("end", cpnDetail.downEddt, "down");
  1903. // 유효기간이 날짜인경우 날짜 세팅
  1904. if (cpnDetail.pdGb == "P") {
  1905. splitDate("start", cpnDetail.availStdt, "avail");
  1906. splitDate("end", cpnDetail.availEddt, "avail");
  1907. if(issueCnt > 0) {
  1908. $("#CouponForm #availStDay").attr('readonly', true);
  1909. $("#CouponForm #availStDay").attr('disabled', true);
  1910. $("#CouponForm #availStHH").attr('readonly', true);
  1911. $("#CouponForm #availStHH").attr('disabled', true);
  1912. $("#CouponForm #availStMM").attr('readonly', true);
  1913. $("#CouponForm #availStMM").attr('disabled', true);
  1914. }
  1915. } else {
  1916. $("#CouponForm #availDays").val(cpnDetail.availDays);
  1917. $('#CouponForm #availEdHH option:last').attr("selected", "selected");
  1918. $('#CouponForm #availEdMM option:last').attr("selected", "selected");
  1919. }
  1920. // 첫구매여부 적용하는 경우 날짜 세팅
  1921. if (cpnDetail.firstOrdYn == "Y") {
  1922. splitDate("start", cpnDetail.buyStdt, "buy");
  1923. splitDate("end", cpnDetail.buyEddt, "buy");
  1924. if(issueCnt > 0) {
  1925. $("#CouponForm #buyStDay").attr('readonly', true);
  1926. $("#CouponForm #buyStDay").attr('disabled', true);
  1927. $("#CouponForm #buyStHH").attr('readonly', true);
  1928. $("#CouponForm #buyStHH").attr('disabled', true);
  1929. $("#CouponForm #buyStMM").attr('readonly', true);
  1930. $("#CouponForm #buyStMM").attr('disabled', true);
  1931. }
  1932. }
  1933. // 신규회원여부 적용하는 경우 날짜 세팅
  1934. if (cpnDetail.newCustYn == "Y") {
  1935. splitDate("start", cpnDetail.custJoinStdt, "custJoin");
  1936. splitDate("end", cpnDetail.custJoinEddt, "custJoin");
  1937. if(issueCnt > 0) {
  1938. $("#CouponForm #custJoinStDay").attr('readonly', true);
  1939. $("#CouponForm #custJoinStDay").attr('disabled', true);
  1940. $("#CouponForm #custJoinStHH").attr('readonly', true);
  1941. $("#CouponForm #custJoinStHH").attr('disabled', true);
  1942. $("#CouponForm #custJoinStMM").attr('readonly', true);
  1943. $("#CouponForm #custJoinStMM").attr('disabled', true);
  1944. }
  1945. }
  1946. }
  1947. // 기본세팅
  1948. pdGbChange();
  1949. firstOrdYnChange();
  1950. newCustYnChange();
  1951. fnChangeAfLinkCdList();
  1952. // 제휴채널2뎁스 기본세팅
  1953. if(cpnDetail != null ) {
  1954. $("#CouponForm #afLinkCd").val(cpnDetail.afLinkCd).prop("selected", true);
  1955. if(issueCnt > 0 ) {
  1956. $("#CouponForm #afLinkCd").attr('readonly', true);
  1957. $("#CouponForm #afLinkCd").attr('disabled', true);
  1958. }
  1959. }
  1960. });
  1961. // 날짜분리 ( 시작/종료날짜구분(start , end) , 날짜String , 적용타겟대상 )
  1962. function splitDate(stedGb , date , targetGb ){
  1963. var str = date;
  1964. var dateStr = str.split(' ');
  1965. var timeArr = dateStr[1].split(':');
  1966. if(stedGb == "start") {
  1967. $("#CouponForm #"+targetGb+"StDay").val(dateStr[0]);
  1968. $("#CouponForm #"+targetGb+"StHH").val(timeArr[0]);
  1969. $("#CouponForm #"+targetGb+"StMM").val(timeArr[1]);
  1970. } else {
  1971. $("#CouponForm #"+targetGb+"EdDay").val(dateStr[0]);
  1972. $("#CouponForm #"+targetGb+"EdHH").val(timeArr[0]);
  1973. $("#CouponForm #"+targetGb+"EdMM").val(timeArr[1]);
  1974. }
  1975. }
  1976. // 제한없음 문구 변경
  1977. $("input[name=totPubLimitQty],input[name=custPubLimitQty],input[name=buyLimitAmt],input[name=onePubQty]").change(function(){
  1978. if($(this).val() == "0"){
  1979. $("#"+$(this).attr("name")+"Span").html("*제한없음");
  1980. }else{
  1981. $("#"+$(this).attr("name")+"Span").html("");
  1982. }
  1983. $("#"+$(this).attr("name")+"Span").css("color", "red");
  1984. });
  1985. setTimeout(function(){
  1986. $("input[name=totPubLimitQty],input[name=custPubLimitQty],input[name=buyLimitAmt],input[name=onePubQty]").change();
  1987. }, 1);
  1988. // 콤마 찍어주기
  1989. $(function(){
  1990. setComma("CouponForm" , true);
  1991. });
  1992. function setComma(formId, pBoolean){
  1993. setTimeout(function(){
  1994. //숫자타입 콤마 찍어주기
  1995. $("#"+formId+" [data-valid-type=numeric]").each(function(){
  1996. $(this).change(function(){
  1997. if(pBoolean){
  1998. $(this).val($(this).val().addComma());
  1999. }else{
  2000. $(this).val($(this).val().removeComma());
  2001. }
  2002. });
  2003. if(pBoolean){
  2004. $(this).val($(this).val().addComma());
  2005. }else{
  2006. $(this).val($(this).val().removeComma());
  2007. }
  2008. });
  2009. }, 300);
  2010. }
  2011. // 진행 버튼 클릭
  2012. $("#btnChangeStatIng").on("click", function() {
  2013. mcxDialog.confirmC("쿠폰을 진행하시겠습니까?<br/>진행 후에는 수정이 제한될 수 있습니다.", {
  2014. btn: confirmBtnText,
  2015. btnClick: function(index) {
  2016. if(index == 1) {
  2017. let data = { cpnStat : "G232_11" // 진행
  2018. , cpnId : $('#CouponForm input[name=cpnId]').val()
  2019. }
  2020. var jsonData = JSON.stringify(data);
  2021. gagajf.ajaxJsonSubmit('/marketing/coupon/changeStat', jsonData, fnCouponSaveCollback);
  2022. }
  2023. }
  2024. });
  2025. });
  2026. // 중지 버튼 클릭
  2027. $("#btnCouponStop").on("click", function() {
  2028. mcxDialog.confirmC("쿠폰 진행을 중지하시겠습니까?<br/>중지 후에는 진행으로 복원하실 수 없습니다.", {
  2029. btn: confirmBtnText,
  2030. btnClick: function(index) {
  2031. if(index == 1) {
  2032. let data = { cpnStat : "G232_12" // 중지
  2033. , cpnId : $('#CouponForm input[name=cpnId]').val()
  2034. }
  2035. var jsonData = JSON.stringify(data);
  2036. gagajf.ajaxJsonSubmit('/marketing/coupon/changeStat', jsonData, fnCouponSaveCollback);
  2037. }
  2038. }
  2039. });
  2040. });
  2041. // 삭제 버튼 클릭
  2042. $("#btnCouponDelete").on("click", function() {
  2043. mcxDialog.confirmC("쿠폰을 삭제하시겠습니까?<br/>삭제한 프로모션은 복원하실 수 없습니다.", {
  2044. btn: confirmBtnText,
  2045. btnClick: function(index) {
  2046. if(index == 1) {
  2047. let data = { cpnStat: "G232_14" // 삭제
  2048. , cpnId : $('#CouponForm input[name=cpnId]').val()
  2049. }
  2050. var jsonData = JSON.stringify(data);
  2051. gagajf.ajaxJsonSubmit('/marketing/coupon/changeStat', jsonData, fnCouponSaveCollback);
  2052. }
  2053. }
  2054. });
  2055. });
  2056. /*]]>*/
  2057. </script>
  2058. </html>