MainMultiContentsPopupForm.html 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : MainMultiContentsPopupForm.html
  7. * @desc : 메인전시 컨텐츠 멀티 팝업 Page
  8. *============================================================================
  9. * STYLE24
  10. * Copyright(C) 2020 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2021.2.24 bin2107 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div class="modalPopup" data-width="1500" >
  18. <div class="panelStyle">
  19. <div class="panelTitle">
  20. <h2 id="multiPopTitle" th:text="${contentsLoc}">Multi</h2>
  21. <button type="button" class="close" onclick="fnMainMultiContentsPopupFormClose()"><i class="fa fa-times"></i></button>
  22. </div>
  23. <div class="panelContent">
  24. <ul class="panelBar">
  25. <li class="aL">
  26. <span class="cBlue">* 상단으로 드래그&amp;드랍하여 순서 변경 가능합니다.</span>
  27. <br th:if="${contentsLoc=='SMM003' or contentsLoc=='SMM007' or contentsLoc=='SMM009' or contentsLoc=='SBM007' or contentsLoc=='SBM008' or contentsLoc=='SBM009' or contentsLoc=='SBM017' or contentsLoc=='SBM018' or contentsLoc=='SBM019' or contentsLoc=='SCM002' or contentsLoc=='SCM003' or contentsLoc=='SOM002' or contentsLoc=='SOM003'}">
  28. <span class="cRed" th:if="${contentsLoc=='SMM003' or contentsLoc=='SBM007' or contentsLoc=='SCM002'}">* 신상품 최대 20개(수동설정 20개 미만일시, 수동 설정 + 최신 등록 상품)</span>
  29. <span class="cRed" th:if="${contentsLoc=='SMM007'}">* 배너 최대 5개(수동설정 + 브랜드 룩북1개 + 진행중인 기획전)</span><br th:if="${contentsLoc=='SMM007'}">
  30. <span class="cRed" th:if="${contentsLoc=='SMM007'}">* 상품 최대 3개(수동설정 3개 미만일시, 수동설정 + 브랜드 최신 등록 상품)</span>
  31. <span class="cRed" th:if="${contentsLoc=='SMM009'}">* 키워드 최대 5개(수동설정 5개 미만일시, 추천솔루션 데이터 노출(키워드별 상품 7개))</span>
  32. <span class="cRed" th:if="${contentsLoc=='SBM008'}">* 상품 최대 10개(수동설정 10개 미만일시, 수동설정 + 추천솔루션 데이터 노출)</span>
  33. <span class="cRed" th:if="${contentsLoc=='SBM009' or contentsLoc=='SBM017' or contentsLoc=='SBM018' or contentsLoc=='SBM019' or contentsLoc=='SOM002'}">* 상품 최대 20개(수동설정 20개 미만일시, 수동설정 + 추천솔루션 데이터 노출)</span>
  34. <span class="cRed" th:if="${contentsLoc=='SCM003' or contentsLoc=='SOM003'}">* 상품 최대 수동설정한 노출 갯수(수동설정 갯수 미만일시, 수동설정 + 추천솔루션 데이터 노출)</span>
  35. </li>
  36. <li class="aR">
  37. <button type="button" class="btn btn btn-base btn-sm" th:if="${contentsLoc == 'SMM007'}" onclick="fnAddBrand(this);">브랜드 추가</button> <!--id="btnBrandAddRow"-->
  38. <button type="button" class="btn btn btn-base btn-sm" th:if="${contentsLoc == 'SMM009' or contentsLoc == 'SMM012'}" onclick="fnAddBrand(this);">MD 탭 추가</button>
  39. <button type="button" class="btn btn btn-base btn-sm"
  40. th:if="${contentsLoc == 'SMM003' or contentsLoc == 'SBM007' or contentsLoc == 'SBM008' or contentsLoc == 'SBM009' or contentsLoc == 'SBM017' or contentsLoc == 'SBM018' or contentsLoc == 'SBM019' or contentsLoc == 'SOM002' or contentsLoc == 'SOM003' or contentsLoc == 'SCM002' or contentsLoc == 'SCM003'}"
  41. onclick="fnAddBrand(this);">컨텐츠 추가</button>
  42. <button type="button" class="btn btn btn-dark btn-sm" id="btnMultiPopSave">임시저장</button>
  43. <input type="hidden" name="uploadDefaultUrlMultiPop" id="uploadDefaultUrlMultiPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/'}"/>
  44. <input type="hidden" name="uploadDefaultBrandUrlPop" id="uploadDefaultBrandUrlPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/brand/'}"/>
  45. <input type="hidden" name="uploadDefaultPlanUrlPop" id="uploadDefaultPlanUrlPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/planning/'}"/>
  46. </li>
  47. </ul>
  48. </div>
  49. <form style="height:600px; width:1470px; overflow:auto;" id="multiPopSortable">
  50. <input type="hidden" name="mdTitle">
  51. </form>
  52. </div>
  53. </div>
  54. <script th:inline="javascript">
  55. /*<![CDATA[*/
  56. var cateNo = [[${cateNo}]];
  57. var contentsLoc = [[${contentsLoc}]];
  58. var brandGroupNo = [[${brandGroupNo}]];
  59. var contentsLocArr = gagajf.convertToArray([[${contentsLocList}]]);
  60. var tdWidth = $("#sortable").find("td").width();
  61. var tdDeleteWidth = parseInt(tdWidth/11, 10);
  62. tdWidth = tdWidth - tdDeleteWidth;
  63. let tableLen = 0; // 테이블 ID
  64. console.log('brandGroupNo:'+brandGroupNo);
  65. /**
  66. * 컨텐츠 미리보기 리스트
  67. */
  68. var fnGetMultiContentsPreviewList = function (){
  69. $("#multiPopSortable").html('');
  70. $("#multiPopSortable").html('');
  71. var data = {cateNo : cateNo
  72. ,contentsLoc : contentsLoc
  73. ,brandGroupNo : brandGroupNo
  74. };
  75. var jsonData = JSON.stringify(data);
  76. gagajf.ajaxJsonSubmit('/display/contents/preview/list', jsonData, fnCreatePopLayout);
  77. }
  78. var fnCreatePopLayout = function (result){
  79. var html = '';
  80. for(var i=0; i<result.length; i++){
  81. var dispStdt = result[i].dispStdt.split(" ");
  82. var dispEddt = result[i].dispEddt.split(" ");
  83. var brandGroupImg = result[i].brandGroupImg;
  84. html += '<table class="frmStyle tableTest" style="margin-bottom:30px" id="tabTable'+i+'">';
  85. html += '<input type="hidden" name="tableIdx" value="'+i+'" data-id="'+i+'">';
  86. html += '<colgroup>';
  87. html += '<col style="width:10%;"/>';
  88. html += '<col style="width:55%;"/>';
  89. html += '<col/>';
  90. html += '</colgroup>';
  91. html += '<thead><tr><th>전시일시</th><td><input name="dispStdt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출시작일" data-valid-type="calendar" value="'+dispStdt[0]+'"/>';
  92. html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
  93. html += fnCreateTimeOption(24, dispStdt[1].split(":")[0]);
  94. html += '</select>';
  95. html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
  96. html += fnCreateTimeOption(60, dispStdt[1].split(":")[1]);
  97. html += '</select>';
  98. html += '<span> ~ </span>';
  99. html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar" value="'+dispEddt[0]+'"/>';
  100. html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
  101. html += fnCreateTimeOption(24, dispEddt[1].split(":")[0]);
  102. html += '</select>';
  103. html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
  104. html += fnCreateTimeOption(60, dispEddt[1].split(":")[1]);
  105. html += '</select>';
  106. html += '<input name="dispOrd" type="text" class="w80"placeholder="전시순서" maxlength="4" style="margin-left:5px; text-align:center" value="'+result[i].dispOrd+'"/>';
  107. html += '</td>';
  108. html += '<td class="aL">';
  109. if(contentsLoc=='SMM007') {
  110. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow2(\'#\',this, '+i+');">기획전/배너추가</button>';
  111. // html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow(\'#\',this);">기획전/배너추가</button>';
  112. // html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddTitlePopRow(this);">타이틀추가</button>';
  113. // html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>';
  114. }
  115. html += '<button type="button" class="btn btn-base btn-lg" id="addGoodsBtn'+i+'" onclick="fnAddGoodsRow(this, '+i+');">상품추가</button>';
  116. html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteBrandRow(this);">삭제</button></td>';
  117. html += '</tr>';
  118. if(contentsLoc=='SMM009' || contentsLoc=='SMM012'){
  119. html += '<tr>';
  120. html += '<th>MD탭문구</th>';
  121. html += '<td colspan="3"><input type="text" name="mdTitle" id="mdTitle" style="width:30%;" value="' + result[i].mdTitle + '"></td>';
  122. html += '</tr>';
  123. }
  124. if(contentsLoc=='SMM007') {
  125. html += '<tr>';
  126. html += '<th>브랜드코드</th>';
  127. html += '<td colspan="3"><input type="text" name="brandGroupNo" required="required" data-valid-name="브랜드코드" style="width:30%;" value="' + result[i].brandGroupNo + '">';
  128. html += '<button type="button" class="btn btnRight btn-success btn-lg" onclick="fnGetBrandGroup(this);">브랜드조회</button>';
  129. html += '</td>';
  130. html += '</tr>';
  131. /*html += fnAddBrandImgRow(result[i].brandGroupImg);*/
  132. }
  133. if(contentsLoc=='SCM002' || contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  134. html += ' <tr>';
  135. html += ' <th>전시 설정</th>';
  136. html += ' <td>';
  137. if(result[i].useYn=='Y'){
  138. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+i+'" value="Y" checked="checked"/>노출</label>';
  139. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+i+'" value="N"/>비노출</label>';
  140. }else{
  141. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+i+'" value="Y"/>노출</label>';
  142. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+i+'" value="N" checked="checked"/>비노출</label>';
  143. }
  144. html += ' </td>';
  145. if(result[i].contentsLoc=='SCM003' || result[i].contentsLoc=='SOM003'){
  146. html += ' <th>상품 노출 개수</th>';
  147. html += ' <td>';
  148. if(result[i].strVar1=='10'){
  149. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="10" checked="checked"/>10개</label>';
  150. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="20"/>20개</label>';
  151. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="30"/>30개</label>';
  152. }else if(result[i].strVar1=='20'){
  153. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="10"/>10개</label>';
  154. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="20" checked="checked"/>20개</label>';
  155. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="30"/>30개</label>';
  156. }else{
  157. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="10"/>10개</label>';
  158. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="20"/>20개</label>';
  159. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+i+'" value="30" checked="checked"/>30개</label>';
  160. }
  161. html += ' </td>';
  162. }
  163. html += ' </tr>';
  164. }
  165. html += '</thead><tbody>';
  166. if(contentsLoc=='SMM007') {
  167. for (var j = 1; j < 8; j++) {
  168. var imgPath = eval("result[" + i + "].imgPath" + j);
  169. var strVar = eval("result[" + i + "].strVar" + j);
  170. var strTitle = eval("result["+i+"].strTitle" + j);
  171. var subText = eval("result["+i+"].subText" + j);
  172. if (!gagajf.isNull(strVar) || !gagajf.isNull(imgPath)) {
  173. // html += fnAddPlanRow(strVar, imgPath);
  174. }
  175. if(strTitle!=null && strTitle!='null' && strTitle!='' ){
  176. // html += fnAddTitlePopRow(strTitle);
  177. }
  178. if(subText!=null && subText!='null' && subText!='' ){
  179. // html += fnAddSubTextPopRow(subText);
  180. }
  181. if(!gagajf.isNull(strVar) || !gagajf.isNull(imgPath) || (strTitle!=null && strTitle!='null' && strTitle!='') || (subText!=null && subText!='null' && subText!='')){
  182. var src = '';
  183. var img_Path = '';
  184. if(!gagajf.isNull(imgPath)){
  185. src = $("#uploadDefaultPlanUrlPop").val().replace('/contents/planning/', '')+imgPath;
  186. img_Path = imgPath;
  187. }
  188. html += '<tr name="planRow" class="planTr'+i+'">';
  189. html += '<th rowspan="3">링크/이미지 <br> 타이틀 <br> 서브텍스트</th>';
  190. html += '<td><input type="text" name="planLink" id="planLink'+i+'" value="'+strVar+'" placeholder="링크"></td>';
  191. html += '<td><div class="uFile w300">';
  192. html += '<input id="planFile_'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnPlanFileUpload(this, '+i+')"/>';
  193. html += '<label for="planFile_'+i+'" class="uFileLabel">파일선택</label>';
  194. html += '<input type="hidden" name="planImgPath" value="'+img_Path+'"/>';
  195. html += '<input type="hidden" name="planNewImgFile" value="" />';
  196. html += '</div>';
  197. html += '<div id="planImgViewPop_'+i+'" class=';
  198. if(src!=''){
  199. html += '"on">';
  200. }else{
  201. html += '"off">';
  202. }
  203. html += '<img id="planPreViewUrlPop_'+i+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'planPreimgViewPop\',$(this).attr(\'src\'));"/>';
  204. html += '</div></td>';
  205. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnBrandPickDeleteTrRow(this,'+i+', '+i+');"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  206. html += '</tr>';
  207. html += '<tr class="planTr'+i+'">';
  208. html += '<td><input name="title" type="text" maxlength="200" placeholder="타이틀" value="'+strTitle+'"/></td>';
  209. html += '</tr>';
  210. html += '<tr class="planTr'+i+'">';
  211. html += '<td><input type="text" name="subText" maxlength="200" placeholder="서브텍스트" value="'+subText+'"/></td>';
  212. html += '</tr>';
  213. }
  214. }
  215. }
  216. if(!gagajf.isNull(result[i].contentsGoodsList)){
  217. // console.log(fnAddGoodsRow(result[i].contentsGoodsList));
  218. html += fnAddGoodsRow(result[i].contentsGoodsList , i);
  219. }
  220. // var src = '';
  221. // var imgPath = '';
  222. // if(!gagajf.isNull(result[i].imgPath1)){
  223. // src = $("#uploadDefaultPlanUrlPop").val().replace('/contents/planning/', '')+result[i].imgPath1;
  224. // imgPath = result[i].imgPath1;
  225. // }
  226. // html += '<tr name="planRow" class="planTr'+i+'">';
  227. //
  228. // html += '<th rowspan="3">링크/이미지 <br> 타이틀 <br> 서브텍스트</th>';
  229. // html += '<td><input type="text" name="planLink" id="planLink'+i+'" value="'+result[i].strVar1+'" placeholder="링크"></td>';
  230. // html += '<td><div class="uFile w300">';
  231. // html += '<input id="planFile_'+i+'" name="file" type="file" class="uFileInput w300" onchange="fnPlanFileUpload(this, '+i+')"/>';
  232. // html += '<label for="planFile_'+i+'" class="uFileLabel">파일선택</label>';
  233. // html += '<input type="hidden" name="planImgPath" value="'+imgPath+'"/>';
  234. // html += '<input type="hidden" name="planNewImgFile" value="" />';
  235. // html += '</div>';
  236. // html += '<div id="planImgViewPop_'+i+'" class=';
  237. // if(src!=''){
  238. // html += '"on">';
  239. // }else{
  240. // html += '"off">';
  241. // }
  242. // html += '<img id="planPreViewUrlPop_'+i+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'planPreimgViewPop\',$(this).attr(\'src\'));"/>';
  243. // html += '</div></td>';
  244. // html += '<td class="aL"><button type="button" class="btn icn" onclick="fnBrandPickDeleteTrRow(this,'+i+', '+i+');"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  245. // html += '</tr>';
  246. // html += '<tr class="planTr'+i+'">';
  247. // html += '<td><input name="title" type="text" maxlength="200" placeholder="타이틀" value="'+result[i].strTitle1+'"/></td>';
  248. // html += '</tr>';
  249. // html += '<tr class="planTr'+i+'">';
  250. // html += '<td><input type="text" name="subText" maxlength="200" placeholder="서브텍스트" value="'+result[i].subText1+'"/></td>';
  251. // html += '</tr>';
  252. html += '</tbody></table>';
  253. }
  254. $("#multiPopSortable").append(html);
  255. $("#multiPopSortable").sortable();
  256. $(".itemWrap").sortable({
  257. stop : function (event, table){
  258. $('.tableTest').each(function (i){
  259. $('#goodsListTd'+i).find('.goodsClass').each(function (j){
  260. $(this).find('input[name=dispOrdEdit]').val(j+1);
  261. });
  262. });
  263. }
  264. });
  265. $('.schDate').datepicker("destroy");
  266. $('.schDate').datepicker({
  267. changeMonth: true,
  268. changeYear: true,
  269. defaultDate: $('.schDate').val()
  270. });
  271. tableLen = $(".tableTest").length;
  272. planImgIndex2 = $(".tableTest").length;
  273. }
  274. /**
  275. * 브랜드이미지 불러오기
  276. */
  277. var brandImgIdx = 0;
  278. var fnAddBrandImgRow = function (param){
  279. var src = '';
  280. var imgPath = '';
  281. if(typeof param!='object'){
  282. src = $("#uploadDefaultBrandUrlPop").val().replace('/contents/brand/', '')+param;
  283. imgPath = param;
  284. }
  285. var html = '<tr name="brandImgRow">';
  286. html += '<th>브랜드이미지</th>';
  287. html += '<td colspan="3">';
  288. html += ' <div class="uFile w300">';
  289. html += ' <input id="brandFile_'+brandImgIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnBrandImgFileUpload(this, '+brandImgIdx+')">';
  290. html += ' <label for="brandFile_'+brandImgIdx+'" class="uFileLabel">파일선택</label>';
  291. html += ' <input type="hidden" name="brandImgPath" value="'+imgPath+'">';
  292. html += ' <input type="hidden" name="brandNewImgFile" value="">';
  293. html += ' </div>';
  294. html += ' <div id="brandImgViewPop_'+brandImgIdx+'" class=';
  295. if (src != '') {
  296. html += '"on">';
  297. } else {
  298. html += '"off">';
  299. }
  300. html += ' <img id="brandPreViewUrlPop_'+brandImgIdx+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'brandPreViewUrlPop\',$(this).attr(\'src\'));"/>';
  301. html += ' </div>';
  302. html += '</td>';
  303. html += '</tr>';
  304. return html;
  305. }
  306. /**
  307. * 브랜드 추가 버튼
  308. */
  309. var brandIdx = 0;
  310. var fnAddBrand = function (param) {
  311. brandIdx = tableLen;
  312. var src = '';
  313. var imgPath = '';
  314. if (typeof param != 'object') {
  315. src = $("#uploadDefaultBrandUrlPop").val().replace('/contents/brand', '') + param;
  316. imgPath = param;
  317. }
  318. var html = '<table class="frmStyle tableTest" style="margin-bottom:30px" id="tabTable'+brandIdx+'" >';
  319. html += '<input type="hidden" name="tableIdx" value="'+brandIdx+'" data-id="'+brandIdx+'">';
  320. html += '<colgroup>';
  321. html += '<col style="width:10%;"/>';
  322. html += '<col style="width:55%;"/>';
  323. html += '<col/>';
  324. html += '</colgroup>';
  325. html += '<thead><tr><th>전시일시</th><td><input name="dispStdt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출시작일" data-valid-type="calendar"/>';
  326. html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
  327. html += fnCreateTimeOption(24);
  328. html += '</select>';
  329. html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
  330. html += fnCreateTimeOption(60);
  331. html += '</select>';
  332. html += '<span> ~ </span>';
  333. html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar"/>';
  334. html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
  335. html += fnCreateTimeOption(24, 23);
  336. html += '</select>';
  337. html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
  338. html += fnCreateTimeOption(60, 59);
  339. html += '</select>';
  340. html += '<input name="dispOrd" type="text" class="w80" placeholder="전시순서" maxlength="4" style="margin-left:5px; text-align:center"/>';
  341. html += '</td>';
  342. html += '<td class="aL">';
  343. if(contentsLoc=='SMM007') {
  344. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow2(\'#\',this, '+brandIdx+');">기획전/배너추가</button>';
  345. // html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow(\'#\',this);">기획전/배너추가</button>';
  346. // html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddTitlePopRow(this);">타이틀추가</button>';
  347. // html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>';
  348. }
  349. html += '<button type="button" class="btn btn-base btn-lg" id="addGoodsBtn'+brandIdx+'" onclick="fnAddGoodsRow(this, '+brandIdx+');">상품추가</button>';
  350. html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteBrandRow(this);">삭제</button></td>';
  351. html += '</tr>';
  352. if(contentsLoc=='SMM009' || contentsLoc=='SMM012'){
  353. html += '<tr>';
  354. html += '<th>MD탭문구</th>';
  355. html += '<td colspan="3"><input type="text" name="mdTitle" id="mdTitle" style="width:30%;"></td>';
  356. html += '</tr>';
  357. }
  358. if(contentsLoc=='SMM007'){
  359. html += '<tr>';
  360. html += '<th>브랜드코드</th>';
  361. html += '<td colspan="3"><input type="text" name="brandGroupNo" style="width:30%;" required="required" data-valid-name="브랜드코드">';
  362. html += '<button type="button" class="btn btnRight btn-success btn-lg" onclick="fnGetBrandGroup(this);">브랜드조회</button>';
  363. html += '</td>';
  364. html += '</tr>';
  365. /* html += '<tr name="brandImgRow">';
  366. html += '<th>브랜드이미지</th>';
  367. html += '<td colspan="3">';
  368. html += ' <div class="uFile w300">';
  369. html += ' <input id="brandFile_' + brandIdx + '" name="file" type="file" class="uFileInput w300" onchange="fnBrandImgFileUpload(this, ' + brandIdx + ')">';
  370. html += ' <label for="brandFile_' + brandIdx + '" class="uFileLabel">파일선택</label>';
  371. html += ' <input type="hidden" name="brandImgPath" value="' + imgPath + '">';
  372. html += ' <input type="hidden" name="brandNewImgFile" value="">';
  373. html += ' </div>';
  374. html += ' <div id="brandImgViewPop_' + brandIdx + '" class=';
  375. if (src != '') {
  376. html += '"on">';
  377. } else {
  378. html += '"off">';
  379. }
  380. html += ' <img id="brandPreViewUrlPop_' + brandIdx + '" src="" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'brandPreViewUrlPop\',$(this).attr(\'src\'));"/>';
  381. html += ' </div>';
  382. html += '</td>';
  383. html += '</tr>';*/
  384. }
  385. if(contentsLoc=='SCM002' || contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  386. html += ' <tr>';
  387. html += ' <th>전시 설정</th>';
  388. html += ' <td>';
  389. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+brandIdx+'" value="Y" checked="checked"/>노출</label>';
  390. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+brandIdx+'" value="N"/>비노출</label>';
  391. html += ' </td>';
  392. if(contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  393. html += ' <th>상품 노출 개수</th>';
  394. html += ' <td>';
  395. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+brandIdx+'" value="10" checked="checked"/>10개</label>';
  396. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+brandIdx+'" value="20"/>20개</label>';
  397. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+brandIdx+'" value="30"/>30개</label>';
  398. html += ' </td>';
  399. }
  400. html += ' </tr>';
  401. }
  402. html += '</thead><tbody></tbody></table>';
  403. // brandIdx++;
  404. $("#multiPopSortable").prepend(html);
  405. $("#multiPopSortable").sortable();
  406. /*$("#multiPopSortable").sortable({
  407. stop : function (event, table){
  408. $(".tableTest").each(function(i){
  409. $(this).attr('id','tabTable'+i);
  410. console.log($(this).attr('id'));
  411. });
  412. }
  413. });*/
  414. $('.schDate').datepicker("destroy");
  415. $('.schDate').datepicker({
  416. changeMonth: true,
  417. changeYear: true,
  418. defaultDate: $('.schDate').val()
  419. });
  420. if(contentsLoc == 'SBM007' || contentsLoc == 'SBM008' || contentsLoc == 'SBM009' || contentsLoc == 'SBM017'|| contentsLoc == 'SBM018'|| contentsLoc == 'SBM019' || contentsLoc == 'SMM003' || contentsLoc == 'SMM007' || contentsLoc == 'SMM009'
  421. || contentsLoc == 'SCM002' || contentsLoc == 'SCM003' || contentsLoc == 'SOM002' || contentsLoc == 'SOM003'){
  422. $("#addGoodsBtn"+brandIdx).click();
  423. }
  424. fnReloadIdx();
  425. tableLen = tableLen+1;
  426. }
  427. var fnReloadIdx = function (){
  428. $(".tableTest").each(function(i){
  429. // $(this).attr('id','tabTable'+i);
  430. $(this).find("input[name=dispOrd]").val(i+1);
  431. //console.log($(this).attr('id'));
  432. // if(contentsLoc == 'SBM007' || contentsLoc == 'SBM008' || contentsLoc == 'SBM009' || contentsLoc == 'SMM003' || contentsLoc == 'SMM007' || contentsLoc == 'SMM009'
  433. // || contentsLoc == 'SCM002' || contentsLoc == 'SCM003' || contentsLoc == 'SOM003'){
  434. // var tableIdx = $(this).find('input[name=tableIdx]').val();
  435. // if(gagajf.isNull(tableIdx)){
  436. // tableIdx = 0;
  437. // }
  438. // goodsIdx = tableIdx;
  439. // console.log('tableIdx>>>'+tableIdx);
  440. // }
  441. });
  442. }
  443. /**
  444. * 브랜드 이미지 첨부
  445. */
  446. var fnBrandImgFileUpload = function (obj, ind){
  447. var file = obj.files[0];
  448. file.name = 'test';
  449. if (typeof(file) == 'undefined'){
  450. return;
  451. }
  452. // 파일 업로드
  453. gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents/brand/'
  454. , file
  455. , function(result) {
  456. $(obj).closest('div').find('input:hidden[name=brandNewImgFile]').val(result.newFileName);
  457. $("#brandPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultBrandUrlPop").val()+result.newFileName);
  458. $("#brandImgViewPop_"+ind).removeClass("off").addClass("on");
  459. }
  460. , 'image'
  461. );
  462. }
  463. /**
  464. * 브랜드그룹 조회
  465. */
  466. var tblNm;
  467. var fnGetBrandGroup = function (obj){
  468. tblNm = $(obj).closest("table").attr('id');
  469. //console.log('tblNm:::::'+tblNm);
  470. cfnOpenBrandGroupListPopup("callBackBrandGroup", "S", "S");
  471. }
  472. var callBackBrandGroup = function (result){
  473. $("#"+tblNm).find("input[name=brandGroupNo]").val(result[0].brandGroupNo);
  474. }
  475. /**
  476. * 기획전/배너 추가
  477. */
  478. var planImgIndex2 = 0;
  479. var fnAddPlanRow2 = function (strvar, param , tableIdx){
  480. var src = '';
  481. var imgPath = '';
  482. if(typeof param!='object'){
  483. src = $("#uploadDefaultPlanUrlPop").val().replace('/contents/planning/', '')+param;
  484. imgPath = param;
  485. }
  486. var html = '<tr name="planRow" class="planTr'+planImgIndex2+'">';
  487. html += '<th rowspan="3">링크/이미지 <br> 타이틀 <br> 서브텍스트</th>';
  488. html += '<td><input type="text" name="planLink" id="planLink'+planImgIndex2+'" value="'+strvar+'" placeholder="링크"></td>';
  489. html += '<td><div class="uFile w300">';
  490. html += '<input id="planFile_'+planImgIndex2+'" name="file" type="file" class="uFileInput w300" onchange="fnPlanFileUpload(this, '+planImgIndex2+')"/>';
  491. html += '<label for="planFile_'+planImgIndex2+'" class="uFileLabel">파일선택</label>';
  492. html += '<input type="hidden" name="planImgPath" value="'+imgPath+'"/>';
  493. html += '<input type="hidden" name="planNewImgFile" value="" />';
  494. html += '</div>';
  495. html += '<div id="planImgViewPop_'+planImgIndex2+'" class=';
  496. if(src!=''){
  497. html += '"on">';
  498. }else{
  499. html += '"off">';
  500. }
  501. html += '<img id="planPreViewUrlPop_'+planImgIndex2+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'planPreimgViewPop\',$(this).attr(\'src\'));"/>';
  502. html += '</div></td>';
  503. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnBrandPickDeleteTrRow(this,'+planImgIndex2+', '+tableIdx+');"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  504. html += '</tr>';
  505. html += '<tr class="planTr'+planImgIndex2+'">';
  506. html += '<td><input name="title" type="text" maxlength="200" placeholder="타이틀" value=""/></td>';
  507. html += '</tr>';
  508. html += '<tr class="planTr'+planImgIndex2+'">';
  509. html += '<td><input type="text" name="subText" maxlength="200" placeholder="서브텍스트" value=""/></td>';
  510. html += '</tr>';
  511. if(typeof param == 'object'){
  512. if($(param).closest("table").find("tbody").find("tr[name=planRow]").length>4){
  513. mcxDialog.alert("기획전/배너는 5개까지 등록 가능합니다");
  514. return;
  515. }
  516. planImgIndex2++;
  517. $(param).closest("table").find("tbody").append(html);
  518. }else{
  519. planImgIndex2++;
  520. return html;
  521. }
  522. }
  523. /**
  524. * 기획전/배너 추가
  525. */
  526. var planImgIndex = 0;
  527. var fnAddPlanRow = function (strvar, param){
  528. var src = '';
  529. var imgPath = '';
  530. if(typeof param!='object'){
  531. src = $("#uploadDefaultPlanUrlPop").val().replace('/contents/planning/', '')+param;
  532. imgPath = param;
  533. }
  534. var html = '<tr name="planRow">';
  535. html += '<th>기획전/배너<br>링크/이미지</th>';
  536. html += '<td><input type="text" name="planLink" id="planLink'+planImgIndex+'" value="'+strvar+'"></td>';
  537. html += '<td><div class="uFile w300">';
  538. html += '<input id="planFile_'+planImgIndex+'" name="file" type="file" class="uFileInput w300" onchange="fnPlanFileUpload(this, '+planImgIndex+')"/>';
  539. html += '<label for="planFile_'+planImgIndex+'" class="uFileLabel">파일선택</label>';
  540. html += '<input type="hidden" name="planImgPath" value="'+imgPath+'"/>';
  541. html += '<input type="hidden" name="planNewImgFile" value="" />';
  542. html += '</div>';
  543. html += '<div id="planImgViewPop_'+planImgIndex+'" class=';
  544. if(src!=''){
  545. html += '"on">';
  546. }else{
  547. html += '"off">';
  548. }
  549. html += '<img id="planPreViewUrlPop_'+planImgIndex+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'planPreimgViewPop\',$(this).attr(\'src\'));"/>';
  550. html += '</div></td>';
  551. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  552. html += '</tr>';
  553. if(typeof param == 'object'){
  554. if($(param).closest("table").find("tbody").find("tr[name=planRow]").length>4){
  555. mcxDialog.alert("기획전/배너는 5개까지 등록 가능합니다");
  556. return;
  557. }
  558. planImgIndex++;
  559. $(param).closest("table").find("tbody").append(html);
  560. }else{
  561. planImgIndex++;
  562. return html;
  563. }
  564. }
  565. // 기획전/배너 파일첨부
  566. var fnPlanFileUpload = function (obj, ind){
  567. var file = obj.files[0];
  568. file.name = 'test';
  569. if (typeof(file) == 'undefined'){
  570. return;
  571. }
  572. // 파일 업로드
  573. gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents/planning'
  574. , file
  575. , function(result) {
  576. $(obj).closest('div').find('input:hidden[name=planNewImgFile]').val(result.newFileName);
  577. $("#planPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultPlanUrlPop").val()+result.newFileName);
  578. $("#planImgViewPop_"+ind).removeClass("off").addClass("on");
  579. }
  580. , 'image'
  581. );
  582. }
  583. /**
  584. * 타이틀추가
  585. */
  586. var fnAddTitlePopRow = function (param){
  587. var val = typeof param=='object'?'':param;
  588. var html = '<tr name="titlePopRow">';
  589. html += '<th>타이틀</th>';
  590. html += '<td><input name="title" type="text" maxlength="200" data-valid-name="타이틀" value="'+val+'"/></td>';
  591. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  592. html += '</tr>';
  593. if(typeof param == 'object'){
  594. if($(param).closest("table").find("tbody").find("tr[name=titlePopRow]").length>3){
  595. mcxDialog.alert("타이틀은 4개까지 등록 가능합니다");
  596. return;
  597. }
  598. $(param).closest("table").find("tbody").append(html);
  599. }else{
  600. return html;
  601. }
  602. }
  603. /**
  604. * 서브텍스트추가
  605. */
  606. var fnAddSubTextPopRow = function (param){
  607. var val = typeof param=='object'?'':param;
  608. var html = '<tr name="subTextPopRow">'
  609. html += '<th>서브텍스트</th>';
  610. html += '<td><input type="text" name="subText" maxlength="200" value="'+val+'"/></td>';
  611. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  612. html += '</tr>';
  613. if(typeof param == 'object'){
  614. if($(param).closest("table").find("tbody").find("tr[name=subTextPopRow]").length>3){
  615. mcxDialog.alert("서브텍스트는 4개까지 등록 가능합니다");
  616. return;
  617. }
  618. $(param).closest("table").find("tbody").append(html);
  619. }else{
  620. return html;
  621. }
  622. }
  623. // 컨텐츠 행삭제
  624. var fnDeleteBrandRow = function (obj){
  625. mcxDialog.confirm('삭제시 전시순서가 초기화됩니다. 삭제하시겠습니까?', {
  626. cancelBtnText: "취소",
  627. sureBtnText: "확인",
  628. sureBtnClick: function(){
  629. $(obj).closest("table").remove();
  630. fnReloadIdx();
  631. }
  632. });
  633. }
  634. // 행삭제
  635. var fnDeleteTrRow = function (obj){
  636. $(obj).closest("tr").remove();
  637. }
  638. var fnBrandPickDeleteTrRow = function (obj, planIdx, tableIdx){
  639. $("#tabTable"+tableIdx).find('.planTr'+planIdx).each(function (i){
  640. $(this).remove();
  641. });
  642. }
  643. // 컨텐츠 추가 날짜 설정
  644. var fnCreateTimeOption = function(val, sel) {
  645. var html = '';
  646. for(var i=0; i<val; i++){
  647. var time = 0;
  648. if(i<10){
  649. time = '0'+i;
  650. }else {
  651. time = i;
  652. }
  653. var select = false;
  654. if(sel==time){
  655. select = true;
  656. }
  657. if(val==24){
  658. time += '시';
  659. }else if(val==60){
  660. time += '분';
  661. }
  662. html += '<option value="'+time+'"';
  663. if(select){
  664. html += 'selected="selected"';
  665. }
  666. html += '>'+time+'</option>';
  667. }
  668. return html;
  669. }
  670. // 창닫기
  671. var fnMainMultiContentsPopupFormClose = function (){
  672. uifnPopupClose('popupMainMultiContents');
  673. }
  674. // 전시 일시 체크
  675. function dateValidation(){
  676. var dateBool = true;
  677. let dupCnt = 0;
  678. $(".tableTest").each(function(i){
  679. var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
  680. var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";
  681. let fromDate = dispStdt.replace(/[^0-9]/g, '');
  682. let toDate = dispEddt.replace(/[^0-9]/g, '');
  683. if(fromDate > toDate){
  684. mcxDialog.alert("시작일자는 종료일자 보다 클 수 없습니다.");
  685. $(this).find('input[name=dispStdt]').focus();
  686. // dateBool = false;
  687. dupCnt++;
  688. return false;
  689. }
  690. });
  691. // if(!dateBool){
  692. // return false;
  693. // }else{
  694. // return true;
  695. // }
  696. if(dupCnt==0){
  697. return true;
  698. }
  699. }
  700. // 몰메인 신상품 : 상품데이터 체크
  701. var goodsArrValidation = function (){
  702. var dataBool = true;
  703. let dupCnt = 0;
  704. $("#multiPopSortable .tableTest").each(function(i){
  705. var thisIdx = $(this).find("input[name=tableIdx]").val();
  706. if($("#tabTable"+thisIdx+" #goodsListTd"+thisIdx).find('ul').find('input[name=goodsCd]').length < 1){
  707. mcxDialog.alert((i+1)+"번째 컨텐츠영역의 상품 정보가 없습니다.");
  708. $(this).focus();
  709. // dataBool = false;
  710. dupCnt++;
  711. return false;
  712. }
  713. });
  714. // if(!dataBool){
  715. // return false;
  716. // }else{
  717. // return true;
  718. // }
  719. if(dupCnt==0){
  720. return true;
  721. }
  722. }
  723. /**
  724. * 임시저장
  725. */
  726. var dataArr = [];
  727. $("#btnMultiPopSave").on("click", function(){
  728. if(!gagajf.checkRequired("#multiPopSortable")){
  729. return;
  730. }
  731. // 전시일시 체크
  732. if(!dateValidation()){
  733. return false;
  734. }
  735. if(contentsLoc == 'SBM007' || contentsLoc == 'SBM008' || contentsLoc == 'SBM009'|| contentsLoc == 'SBM017'|| contentsLoc == 'SBM018'|| contentsLoc == 'SBM019' || contentsLoc == 'SMM003' || contentsLoc == 'SMM007' || contentsLoc == 'SMM009'
  736. || contentsLoc == 'SCM002' || contentsLoc == 'SCM003' || contentsLoc == 'SOM002' || contentsLoc == 'SOM003'){
  737. if(!goodsArrValidation()){
  738. return false;
  739. }
  740. }
  741. dataArr = [];
  742. $("#multiPopSortable .tableTest").each(function(){ //$("#multiPopSortable table").each(function(){
  743. var newImgFileArr = [];
  744. var imgPath1 = '';
  745. var imgPath2 = '';
  746. var imgPath3 = '';
  747. var imgPath4 = '';
  748. var imgPath5 = '';
  749. var imgPath6 = '';
  750. var imgPath7 = '';
  751. var imgPath8 = '';
  752. var strVar1 = '';
  753. var strVar2 = '';
  754. var strVar3 = '';
  755. var strVar4 = '';
  756. var strVar5 = '';
  757. var strVar6 = '';
  758. var strVar7 = '';
  759. var strVar8 = '';
  760. var strTitle1 = '';
  761. var strTitle2 = '';
  762. var strTitle3 = '';
  763. var strTitle4 = '';
  764. var subText1 = '';
  765. var subText2 = '';
  766. var subText3 = '';
  767. var subText4 = '';
  768. // var goodsImgArr = [];
  769. var goodsCdArr = [];
  770. // var goodsNmArr = [];
  771. var goodsDispOrdArr = [];
  772. var i = 1;
  773. $(this).find('input[name=planImgPath]').each(function(){
  774. eval("imgPath" + i + "='"+$(this).val()+"'");
  775. i++;
  776. });
  777. $(this).find('input[name=planNewImgFile]').each(function(){
  778. newImgFileArr.push($(this).val());
  779. });
  780. i = 1;
  781. $(this).find('input[name=planLink]').each(function(){
  782. _mall = [[${@environment.getProperty('domain.front')}]];
  783. var val = $(this).val();
  784. val = val.replace('https:'+_mall, '');
  785. val = val.replace('http:'+_mall, '');
  786. val = val.replace(_mall, '');
  787. eval("strVar" + i + "='"+val+"'");
  788. i++;
  789. });
  790. i = 1;
  791. $(this).find('input[name=title]').each(function(){
  792. var title = $(this).val().replace(/[\']/gi, "\\'");
  793. eval("strTitle" + i + "='"+title+"'");
  794. i++;
  795. });
  796. i = 1;
  797. $(this).find('input[name=subText]').each(function(){
  798. var subText = $(this).val().replace(/[\']/gi, "\\'");
  799. eval("subText" + i + "='"+subText+"'");
  800. i++;
  801. });
  802. // $(this).find('input[name=goodsImgPath]').each(function(){
  803. // goodsImgArr.push($(this).val());
  804. // });
  805. $(this).find('input[name=goodsCd]').each(function(){
  806. goodsCdArr.push($(this).val());
  807. });
  808. // $(this).find('input[name=goodsNm]').each(function(){
  809. // goodsNmArr.push($(this).val());
  810. // });
  811. $(this).find('input[name=dispOrdEdit]').each(function(){
  812. goodsDispOrdArr.push($(this).val());
  813. });
  814. var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
  815. var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";
  816. var dispOrd = $(this).find("[name=dispOrd]").val();
  817. var brandGroupNo;
  818. if(contentsLoc=='SBM007'||contentsLoc=='SBM008'||contentsLoc=='SBM009'||contentsLoc=='SBM017'||contentsLoc=='SBM018'||contentsLoc=='SBM019'||contentsLoc=='SOM003'||contentsLoc=='SCM002'||contentsLoc=='SCM003'){
  819. brandGroupNo = [[${brandGroupNo}]];
  820. }else{
  821. brandGroupNo = $(this).find("[name=brandGroupNo]").val();
  822. }
  823. var brandGroupImg = $(this).find("[name=brandNewImgFile]").val();
  824. var mdTitle = $(this).find("[name=mdTitle]").val();
  825. var useYn = 'Y';
  826. if(contentsLoc=='SCM002' || contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  827. var thisIdx = $(this).find("input[name=tableIdx]").val();
  828. useYn = $(this).find("input:radio[name=dispYn"+thisIdx+"]:checked").val();
  829. }else{
  830. useYn = 'Y';
  831. }
  832. if(contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  833. var thisIdx = $(this).find("input[name=tableIdx]").val();
  834. strVar1 = $(this).find("input:radio[name=dispCnt"+thisIdx+"]:checked").val();
  835. }
  836. var data = {cateNo : cateNo
  837. , contentsLoc : contentsLoc
  838. , dispStdt : dispStdt
  839. , dispEddt : dispEddt
  840. , newImgFileArr : newImgFileArr
  841. , imgPath1 : imgPath1
  842. , imgPath2 : imgPath2
  843. , imgPath3 : imgPath3
  844. , imgPath4 : imgPath4
  845. , imgPath5 : imgPath5
  846. , imgPath6 : imgPath6
  847. , imgPath7 : imgPath7
  848. , imgPath8 : imgPath8
  849. , strVar1 : strVar1
  850. , strVar2 : strVar2
  851. , strVar3 : strVar3
  852. , strVar4 : strVar4
  853. , strVar5 : strVar5
  854. , strVar6 : strVar6
  855. , strVar7 : strVar7
  856. , strVar8 : strVar8
  857. , strTitle1 : strTitle1
  858. , strTitle2 : strTitle2
  859. , strTitle3 : strTitle3
  860. , strTitle4 : strTitle4
  861. , subText1 : subText1
  862. , subText2 : subText2
  863. , subText3 : subText3
  864. , subText4 : subText4
  865. , brandGroupNo : brandGroupNo
  866. , brandGroupImg : brandGroupImg
  867. , mdTitle : mdTitle
  868. , useYn : useYn
  869. , dispOrd : dispOrd
  870. , multiContentsYn : 'Y'
  871. , goodsCdArr : goodsCdArr
  872. // , goodsNmArr : goodsNmArr
  873. // , goodsImgArr : goodsImgArr
  874. , goodsDispOrdArr : goodsDispOrdArr
  875. };
  876. dataArr.push(data);
  877. });
  878. if(dataArr.length==0){
  879. var data = {cateNo : cateNo
  880. , contentsLoc : contentsLoc
  881. };
  882. dataArr.push(data);
  883. }else{
  884. var dataArrSort = [];
  885. dataArr.forEach(function(item, index){
  886. if(dataArr[index].dispOrd>0){
  887. for(var i=1; i<dataArr.length; i++){
  888. if(i>index){
  889. if(dataArr[index].dispOrd==dataArr[i].dispOrd){
  890. dataArr[i].dispOrd = Number(dataArr[i].dispOrd) + 1;
  891. }
  892. }
  893. }
  894. }
  895. });
  896. dataArr.forEach(function(item, index){
  897. if(dataArr[index].dispOrd != ''){
  898. dataArrSort[dataArr[index].dispOrd-1] = item;
  899. }
  900. });
  901. dataArr.forEach(function(item, index){
  902. if(dataArr[index].dispOrd == ''){
  903. var empty = false;
  904. for(var i=0; i<dataArrSort.length; i++){
  905. if(typeof dataArrSort[i] == 'undefined'){
  906. dataArrSort[i] = item;
  907. empty = true;
  908. break;
  909. }
  910. };
  911. if(!empty){
  912. dataArrSort.push(item);
  913. }
  914. }
  915. });
  916. dataArr = dataArrSort;
  917. }
  918. var jsonData = JSON.stringify(dataArr);
  919. // console.log(jsonData);
  920. mcxDialog.confirm('컨텐츠를 저장 하시겠습니까?', {
  921. cancelBtnText: "취소",
  922. sureBtnText: "확인",
  923. sureBtnClick: function(){
  924. gagajf.ajaxJsonSubmit('/display/contents/preview/save', jsonData, fnGetMultiContentsPreviewList);
  925. }
  926. });
  927. });
  928. var fnUpBtn = function (obj, idx){
  929. var ind = $(obj).closest('.item').index();
  930. if(ind>0){
  931. $('#goodsListTd'+idx).find(".item").eq(ind-1).before($('#goodsListTd'+idx).find(".item").eq(ind));
  932. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val())+1);
  933. $('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=setDispOrd]").val())-1);
  934. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val())+1);
  935. $('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=dispOrdEdit]").val())-1);
  936. }
  937. }
  938. var fnDownBtn = function (obj, idx){
  939. var ind = $(obj).closest('.item').index();
  940. if(ind<$("#goodsListTd"+idx).find('.goodsClass').length){
  941. $('#goodsListTd'+idx).find(".item").eq(ind+1).after($('#goodsListTd'+idx).find(".item").eq(ind));
  942. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val())-1);
  943. $('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=setDispOrd]").val())+1);
  944. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val())-1);
  945. $('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=dispOrdEdit]").val())+1);
  946. }
  947. }
  948. var fnUpdownBtn = function (obj, gubun, idx){
  949. if(gubun=='up'){
  950. var ind = $(obj).closest('.item').index();
  951. $('#goodsListTd'+idx).find(".item").eq(0).before($('#goodsListTd'+idx).find(".item").eq(ind));
  952. $('#goodsListTd'+idx).find('.goodsClass').each(function (j){
  953. $(this).find('input[name=dispOrdEdit]').val(j+1);
  954. });
  955. }else{
  956. var ind = $(obj).closest('.item').index();
  957. let lastNum = $("#goodsListTd"+idx).find('.goodsClass').length;
  958. $('#goodsListTd'+idx).find(".item").eq(lastNum-1).after($('#goodsListTd'+idx).find(".item").eq(ind));
  959. $('#goodsListTd'+idx).find('.goodsClass').each(function (j){
  960. $(this).find('input[name=dispOrdEdit]').val(j+1);
  961. });
  962. }
  963. }
  964. /**
  965. * 상품추가
  966. */
  967. var goodsIdx = 0;
  968. var fnAddGoodsRow = function (param , tableIndex){
  969. if(!gagajf.isNull(tableIndex)){
  970. goodsIdx = tableIndex;
  971. }
  972. var addRow = "goodsListTd"+goodsIdx;
  973. var html = '<tr name="goodsRow">';
  974. html += '<th>상품추가<br><button type="button" class="btn btn-base btn-lg" onclick="fnSearchGoods(\''+addRow+'\');">상품조회</button>';
  975. html += '<br></br><button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteTrRow(this);">삭제</button>';
  976. html += '</th>';
  977. html += '<td colspan="3">';
  978. html += '<div class="sortableWrap" data-unit="7" style="overflow-y:scroll;">';
  979. html += '<div class="itemWrap" id="goodsListTd'+goodsIdx+'">';
  980. // if(typeof param!='object'){
  981. var imgPath = _goodsUrl;
  982. for(let i=0; i<param.length; i++){
  983. html += '<ul id="goodsUl'+i+'" class="item ui-state-default goodsClass" style="min-height:200px;"> ';
  984. html += '<li class="img">';
  985. html += '<img src="'+imgPath+ "/" +param[i].sysImgNm+'" onerror="this.src=\'/image/no.png\';"/>';
  986. html += '<div class="btnArea">';
  987. html += '<button type="button" class="icnSm" title="맨위로" onclick="fnUpdownBtn(this, \'up\', \''+goodsIdx+'\');"><i class="fa fa-play-circle fa-rotate-270" aria-hidden="true"></i></button>';
  988. html += '<button type="button" class="icnSm" title="위로" onclick="fnUpBtn(this, \''+goodsIdx+'\');"><i class="fa fa-arrow-up" aria-hidden="true"></i></button>';
  989. html += '<button type="button" class="icnSm" title="맨아래로" onclick="fnUpdownBtn(this, \'down\', \''+goodsIdx+'\');"><i class="fa fa-play-circle fa-rotate-90" aria-hidden="true"></i></button>';
  990. html += '<button type="button" class="icnSm" title="아래로" onclick="fnDownBtn(this, \''+goodsIdx+'\');"><i class="fa fa-arrow-down" aria-hidden="true"></i></button>';
  991. html += '</div>';
  992. html += '</li>';
  993. html += '<li class="cont">';
  994. html += '<ul>';
  995. html += '<li class="no" name="goodsCdLi"><span>'+param[i].goodsCd+'</span>';
  996. // html += '<input type="hidden" name="goodsImgPath" value="'+param[i].sysImgNm+'">';
  997. html += '<input type="hidden" name="goodsCd" value="'+param[i].goodsCd+'">';
  998. // html += '<input type="hidden" name="goodsNm" value="'+param[i].goodsNm+'">';
  999. html += '<span style="margin-left:5px;"><a href="javascript:void(0);" id="delId" onclick="fnRemoveGoods(this,'+i+');">X</a></span>';
  1000. html += '</li>';
  1001. html += '</li>';
  1002. html += '<li class="title">'+param[i].goodsNm+'</li>';
  1003. html += '<li>';
  1004. html += '<span>전시순서 :</span>';
  1005. html += '<input type="text" name="dispOrdEdit" value="'+param[i].contentsDispOrd+'" />';
  1006. html += '<input type="hidden" name="setDispOrd" value="'+param[i].contentsDispOrd+'"/>';
  1007. html += '</li>';
  1008. html += '</ul>';
  1009. html += '</ul>';
  1010. }
  1011. // }
  1012. html += '</div>';
  1013. html += '</div>';
  1014. html += '</td>';
  1015. html += '</tr>';
  1016. if(typeof param == 'object'){
  1017. if($(param).closest("table").find("tbody").find("tr[name=goodsRow]").length>0){
  1018. mcxDialog.alert("상품추가 ROW는 1개 등록 가능합니다");
  1019. return;
  1020. }
  1021. goodsIdx++;
  1022. $(param).closest("table").find("tbody").append(html);
  1023. return html;
  1024. }else{
  1025. goodsIdx++;
  1026. return html;
  1027. }
  1028. fnReloadIdx();
  1029. }
  1030. /**
  1031. * 상품조회
  1032. */
  1033. var addRowTd;
  1034. var fnSearchGoods = function (obj){
  1035. addRowTd = obj;
  1036. cfnOpenGoodsPopup('fnAddMultiContentsGoods');
  1037. }
  1038. var firstOrd = '';
  1039. //var uploadGoodsUrl = _goodsUrl [[${@environment.getProperty('upload.goods.view')}]];
  1040. var fnAddMultiContentsGoods = function(result){
  1041. let thisIdx = $("#"+addRowTd).parent().parent().parent().parent().parent().find('input[name=tableIdx]').val();
  1042. // console.log('goodsRowIdx>>>>'+addRowTd);
  1043. let goodsCnt = 0;
  1044. if($("#"+addRowTd).find('.item').length > 0){
  1045. goodsCnt = $("#"+addRowTd).find('.item').length;
  1046. }
  1047. var html='';
  1048. for(let i = 0 ; i < result.length ; i++) {
  1049. let dispOrdVal = 0;
  1050. dispOrdVal = goodsCnt +(i+1);
  1051. if(i==0){
  1052. firstOrd = result[i].dispOrd;
  1053. }
  1054. html+='<ul id="goodsUl'+i+'" class="item ui-state-default goodsClass" style="min-height:200px;" ';
  1055. if(result[i].goodsStat!="G008_90" || result[i].currStockQty<1){
  1056. html += 'background:#f5f5f5;';
  1057. }
  1058. html += '">';
  1059. html += '<li class="img">';
  1060. var imgPath = '';
  1061. //if(result[i].imgType=='A'){
  1062. imgPath = _goodsUrl;
  1063. //}
  1064. html += '<img src="'+imgPath+ "/" +result[i].sysImgNm+'" onerror="this.src=\'/image/no.png\';"/>';
  1065. html += '<div class="btnArea">';
  1066. html += '<button type="button" class="icnSm" title="맨위로" onclick="fnUpdownBtn(this, \'up\', \''+thisIdx+'\');"><i class="fa fa-play-circle fa-rotate-270" aria-hidden="true"></i></button>';
  1067. html += '<button type="button" class="icnSm" title="위로" onclick="fnUpBtn(this, \''+thisIdx+'\');"><i class="fa fa-arrow-up" aria-hidden="true"></i></button>';
  1068. html += '<button type="button" class="icnSm" title="맨아래로" onclick="fnUpdownBtn(this, \'down\', \''+thisIdx+'\');"><i class="fa fa-play-circle fa-rotate-90" aria-hidden="true"></i></button>';
  1069. html += '<button type="button" class="icnSm" title="아래로" onclick="fnDownBtn(this, \''+thisIdx+'\');"><i class="fa fa-arrow-down" aria-hidden="true"></i></button>';
  1070. html += '</div>';
  1071. html += '</li>';
  1072. html += '<li class="cont">';
  1073. html += '<ul>';
  1074. html += '<li class="no" name="goodsCdLi"><span>'+result[i].goodsCd+'</span>';
  1075. // html += '<input type="hidden" name="goodsImgPath" value="'+result[i].sysImgNm+'">';
  1076. html += '<input type="hidden" name="goodsCd" value="'+result[i].goodsCd+'">';
  1077. // html += '<input type="hidden" name="goodsNm" value="'+result[i].goodsNm+'">';
  1078. html += '<span style="margin-left:5px;"><a href="javascript:void(0);" id="delId" onclick="fnRemoveGoods(this,'+i+');">X</a></span>';
  1079. html += '</li>';
  1080. html += '<li class="title">'+result[i].goodsNm+'</li>';
  1081. html += '<li>';
  1082. html += '<span>전시순서 :</span>';
  1083. html += '<input type="text" name="dispOrdEdit" value="'+dispOrdVal+'" />';
  1084. html += '<input type="hidden" name="setDispOrd" value="'+dispOrdVal+'"/>';
  1085. html += '</li>';
  1086. html += '</ul>';
  1087. html += '</li>';
  1088. html += '</ul>';
  1089. }
  1090. $("#"+addRowTd).append(html);
  1091. // $("#"+addRowTd).sortable();
  1092. $("#"+addRowTd).sortable({
  1093. stop: function(event, ui) {
  1094. if(gagajf.isNull(firstOrd)){
  1095. firstOrd = 1;
  1096. }else{
  1097. firstOrd = Number(firstOrd);
  1098. }
  1099. $("#"+addRowTd+" .item").each(function(i){
  1100. $(this).find("input[name=dispOrdEdit]").val(i+firstOrd);
  1101. });
  1102. }
  1103. });
  1104. $("#"+addRowTd).disableSelection();
  1105. uifnPopupClose('popupGoods');
  1106. fnReloadGoodsListIdx(addRowTd);
  1107. }
  1108. var fnReloadGoodsListIdx = function (obj){
  1109. var tableId = obj
  1110. $("#"+tableId +" .goodsClass").each(function (i){
  1111. $(this).attr('id','goodsUl'+i);
  1112. $(this).find("#delId").attr('onclick','fnRemoveGoods(this,'+i+');');
  1113. $(this).find("input[name=dispOrdEdit]").val(i+1);
  1114. $(this).find("input[name=setDispOrd]").val(i+1);
  1115. });
  1116. }
  1117. var fnRemoveGoods = function (obj , idx){
  1118. var divId = $(obj).closest('div').attr('id');
  1119. $("#"+divId+" #goodsUl"+idx).remove();
  1120. fnReloadGoodsListIdx(divId);
  1121. }
  1122. $(document).ready(function() {
  1123. $("#multiPopTitle").text("["+contentsLoc+"] "+gagaAgGrid.lookupValue(contentsLocArr, contentsLoc));
  1124. $("#multiPopSortable").sortable({
  1125. stop: function(event, ui) {
  1126. fnReloadIdx();
  1127. }
  1128. });
  1129. $("#multiPopSortable").disableSelection();
  1130. fnGetMultiContentsPreviewList();
  1131. fnReloadIdx();
  1132. });
  1133. /*]]>*/
  1134. </script>
  1135. </html>