MainMultiContentsPopupForm.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  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. </li>
  28. <li class="aR">
  29. <button type="button" class="btn btn btn-base btn-sm" th:if="${contentsLoc == 'SMM007'}" onclick="fnAddBrand(this);">브랜드 추가</button> <!--id="btnBrandAddRow"-->
  30. <button type="button" class="btn btn btn-base btn-sm" th:if="${contentsLoc == 'SMM009' or contentsLoc == 'SMM012'}" onclick="fnAddBrand(this);">MD 탭 추가</button>
  31. <button type="button" class="btn btn btn-dark btn-sm" id="btnMultiPopSave">임시저장</button>
  32. <input type="hidden" name="uploadDefaultUrlMultiPop" id="uploadDefaultUrlMultiPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/'}"/>
  33. <input type="hidden" name="uploadDefaultBrandUrlPop" id="uploadDefaultBrandUrlPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/brand/'}"/>
  34. <input type="hidden" name="uploadDefaultPlanUrlPop" id="uploadDefaultPlanUrlPop" th:value="${@environment.getProperty('upload.image.view') + '/contents/planning/'}"/>
  35. </li>
  36. </ul>
  37. </div>
  38. <form style="height:600px; width:1470px; overflow:auto;" id="multiPopSortable">
  39. <input type="hidden" name="mdTitle">
  40. </form>
  41. </div>
  42. </div>
  43. <script th:inline="javascript">
  44. /*<![CDATA[*/
  45. var cateNo = [[${cateNo}]];
  46. var contentsLoc = [[${contentsLoc}]];
  47. var contentsLocArr = gagajf.convertToArray([[${contentsLocList}]]);
  48. var tdWidth = $("#sortable").find("td").width();
  49. var tdDeleteWidth = parseInt(tdWidth/11, 10);
  50. tdWidth = tdWidth - tdDeleteWidth;
  51. /**
  52. * 컨텐츠 미리보기 리스트
  53. */
  54. var fnGetMultiContentsPreviewList = function (){
  55. $("#multiPopSortable").html('');
  56. $("#multiPopSortable").html('');
  57. var data = {cateNo : cateNo
  58. ,contentsLoc : contentsLoc
  59. };
  60. var jsonData = JSON.stringify(data);
  61. gagajf.ajaxJsonSubmit('/display/contents/preview/list', jsonData, fnCreatePopLayout);
  62. }
  63. var fnCreatePopLayout = function (result){
  64. var html = '';
  65. for(var i=0; i<result.length; i++){
  66. var dispStdt = result[i].dispStdt.split(" ");
  67. var dispEddt = result[i].dispEddt.split(" ");
  68. var brandGroupImg = result[i].brandGroupImg;
  69. html += '<table class="frmStyle tableTest" style="margin-bottom:30px" id="tabTable'+i+'" tableIdx="'+i+'">';
  70. html += '<colgroup>';
  71. html += '<col style="width:10%;"/>';
  72. html += '<col style="width:55%;"/>';
  73. html += '<col/>';
  74. html += '</colgroup>';
  75. 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]+'"/>';
  76. html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
  77. html += fnCreateTimeOption(24, dispStdt[1].split(":")[0]);
  78. html += '</select>';
  79. html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
  80. html += fnCreateTimeOption(60, dispStdt[1].split(":")[1]);
  81. html += '</select>';
  82. html += '<span> ~ </span>';
  83. html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar" value="'+dispEddt[0]+'"/>';
  84. html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
  85. html += fnCreateTimeOption(24, dispEddt[1].split(":")[0]);
  86. html += '</select>';
  87. html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
  88. html += fnCreateTimeOption(60, dispEddt[1].split(":")[1]);
  89. html += '</select>';
  90. html += '<input name="dispOrd" type="text" class="w80"placeholder="전시순서" style="margin-left:5px; text-align:center" value="'+result[i].dispOrd+'"/>';
  91. html += '</td>';
  92. html += '<td class="aL">';
  93. if(contentsLoc=='SMM007') {
  94. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow(\'#\',this);">기획전/배너추가</button>';
  95. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddTitlePopRow(this);">타이틀추가</button>';
  96. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>';
  97. }
  98. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddGoodsRow(this,this,this);">상품추가</button>';
  99. html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteBrandRow(this);">삭제</button></td>';
  100. html += '</tr>';
  101. if(contentsLoc=='SMM009' || contentsLoc=='SMM012'){
  102. html += '<tr>';
  103. html += '<th>MD탭문구</th>';
  104. html += '<td colspan="3"><input type="text" name="mdTitle" id="mdTitle" style="width:30%;" value="' + result[i].mdTitle + '"></td>';
  105. html += '</tr>';
  106. }
  107. if(contentsLoc=='SMM007') {
  108. html += '<tr>';
  109. html += '<th>브랜드코드</th>';
  110. html += '<td colspan="3"><input type="text" name="brandGroupNo" style="width:30%;" value="' + result[i].brandGroupNo + '">';
  111. html += '<button type="button" class="btn btnRight btn-success btn-lg" onclick="fnGetBrandGroup(this);">브랜드조회</button>';
  112. html += '</td>';
  113. html += '</tr>';
  114. /*html += fnAddBrandImgRow(result[i].brandGroupImg);*/
  115. }
  116. html += '</thead><tbody>';
  117. if(contentsLoc=='SMM007') {
  118. for (var j = 1; j < 8; j++) {
  119. var imgPath = eval("result[" + i + "].imgPath" + j);
  120. var strVar = eval("result[" + i + "].strVar" + j);
  121. var strTitle = eval("result["+i+"].strTitle" + j);
  122. var subText = eval("result["+i+"].subText" + j);
  123. if (!gagajf.isNull(strVar) || !gagajf.isNull(imgPath)) {
  124. html += fnAddPlanRow(strVar, imgPath);
  125. }
  126. if(strTitle!=null && strTitle!='null' && strTitle!='' ){
  127. html += fnAddTitlePopRow(strTitle);
  128. }
  129. if(subText!=null && subText!='null' && subText!='' ){
  130. html += fnAddSubTextPopRow(subText);
  131. }
  132. }
  133. }
  134. if(!gagajf.isNull(result[i].goodsCdList)){
  135. html += fnAddGoodsRow(result[i].goodsCdList,result[i].goodsNmList,result[i].goodsImgList);
  136. }
  137. html += '</tbody></table>';
  138. }
  139. $("#multiPopSortable").append(html);
  140. $("#multiPopSortable").sortable();
  141. $(".itemWrap").sortable();
  142. $('.schDate').datepicker("destroy");
  143. $('.schDate').datepicker({
  144. changeMonth: true,
  145. changeYear: true,
  146. defaultDate: $('.schDate').val()
  147. });
  148. }
  149. /**
  150. * 브랜드이미지 불러오기
  151. */
  152. var brandImgIdx = 0;
  153. var fnAddBrandImgRow = function (param){
  154. var src = '';
  155. var imgPath = '';
  156. if(typeof param!='object'){
  157. src = $("#uploadDefaultBrandUrlPop").val().replace('/contents/brand/', '')+param;
  158. imgPath = param;
  159. }
  160. var html = '<tr name="brandImgRow">';
  161. html += '<th>브랜드이미지</th>';
  162. html += '<td colspan="3">';
  163. html += ' <div class="uFile w300">';
  164. html += ' <input id="brandFile_'+brandImgIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnBrandImgFileUpload(this, '+brandImgIdx+')">';
  165. html += ' <label for="brandFile_'+brandImgIdx+'" class="uFileLabel">파일선택</label>';
  166. html += ' <input type="hidden" name="brandImgPath" value="'+imgPath+'">';
  167. html += ' <input type="hidden" name="brandNewImgFile" value="">';
  168. html += ' </div>';
  169. html += ' <div id="brandImgViewPop_'+brandImgIdx+'" class=';
  170. if (src != '') {
  171. html += '"on">';
  172. } else {
  173. html += '"off">';
  174. }
  175. html += ' <img id="brandPreViewUrlPop_'+brandImgIdx+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'brandPreViewUrlPop\',$(this).attr(\'src\'));"/>';
  176. html += ' </div>';
  177. html += '</td>';
  178. html += '</tr>';
  179. return html;
  180. }
  181. /**
  182. * 브랜드 추가 버튼
  183. */
  184. var brandIdx = 0;
  185. var fnAddBrand = function (param) {
  186. var src = '';
  187. var imgPath = '';
  188. if (typeof param != 'object') {
  189. src = $("#uploadDefaultBrandUrlPop").val().replace('/contents/brand', '') + param;
  190. imgPath = param;
  191. }
  192. var html = '<table class="frmStyle tableTest" style="margin-bottom:30px" id="tabTable'+brandIdx+'" tableIdx="'+brandIdx+'">';
  193. html += '<colgroup>';
  194. html += '<col style="width:10%;"/>';
  195. html += '<col style="width:55%;"/>';
  196. html += '<col/>';
  197. html += '</colgroup>';
  198. 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"/>';
  199. html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
  200. html += fnCreateTimeOption(24);
  201. html += '</select>';
  202. html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
  203. html += fnCreateTimeOption(60);
  204. html += '</select>';
  205. html += '<span> ~ </span>';
  206. html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar"/>';
  207. html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
  208. html += fnCreateTimeOption(24, 23);
  209. html += '</select>';
  210. html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
  211. html += fnCreateTimeOption(60, 59);
  212. html += '</select>';
  213. html += '<input name="dispOrd" type="text" class="w80" placeholder="전시순서" style="margin-left:5px; text-align:center"/>';
  214. html += '</td>';
  215. html += '<td class="aL">';
  216. if(contentsLoc=='SMM007') {
  217. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow(\'#\',this);">기획전/배너추가</button>';
  218. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddTitlePopRow(this);">타이틀추가</button>';
  219. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>';
  220. }
  221. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddGoodsRow(this,this,this);">상품추가</button>';
  222. html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteBrandRow(this);">삭제</button></td>';
  223. html += '</tr>';
  224. if(contentsLoc=='SMM009' || contentsLoc=='SMM012'){
  225. html += '<tr>';
  226. html += '<th>MD탭문구</th>';
  227. html += '<td colspan="3"><input type="text" name="mdTitle" id="mdTitle" style="width:30%;"></td>';
  228. html += '</tr>';
  229. }
  230. if(contentsLoc=='SMM007'){
  231. html += '<tr>';
  232. html += '<th>브랜드코드</th>';
  233. html += '<td colspan="3"><input type="text" name="brandGroupNo" style="width:30%;">';
  234. html += '<button type="button" class="btn btnRight btn-success btn-lg" onclick="fnGetBrandGroup(this);">브랜드조회</button>';
  235. html += '</td>';
  236. html += '</tr>';
  237. /* html += '<tr name="brandImgRow">';
  238. html += '<th>브랜드이미지</th>';
  239. html += '<td colspan="3">';
  240. html += ' <div class="uFile w300">';
  241. html += ' <input id="brandFile_' + brandIdx + '" name="file" type="file" class="uFileInput w300" onchange="fnBrandImgFileUpload(this, ' + brandIdx + ')">';
  242. html += ' <label for="brandFile_' + brandIdx + '" class="uFileLabel">파일선택</label>';
  243. html += ' <input type="hidden" name="brandImgPath" value="' + imgPath + '">';
  244. html += ' <input type="hidden" name="brandNewImgFile" value="">';
  245. html += ' </div>';
  246. html += ' <div id="brandImgViewPop_' + brandIdx + '" class=';
  247. if (src != '') {
  248. html += '"on">';
  249. } else {
  250. html += '"off">';
  251. }
  252. html += ' <img id="brandPreViewUrlPop_' + brandIdx + '" src="" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'brandPreViewUrlPop\',$(this).attr(\'src\'));"/>';
  253. html += ' </div>';
  254. html += '</td>';
  255. html += '</tr>';*/
  256. }
  257. html += '</thead><tbody></tbody></table>';
  258. brandIdx++;
  259. $("#multiPopSortable").prepend(html);
  260. $("#multiPopSortable").sortable();
  261. /*$("#multiPopSortable").sortable({
  262. stop : function (event, table){
  263. $(".tableTest").each(function(i){
  264. $(this).attr('id','tabTable'+i);
  265. console.log($(this).attr('id'));
  266. });
  267. }
  268. });*/
  269. $('.schDate').datepicker("destroy");
  270. $('.schDate').datepicker({
  271. changeMonth: true,
  272. changeYear: true,
  273. defaultDate: $('.schDate').val()
  274. });
  275. fnReloadIdx();
  276. }
  277. var fnReloadIdx = function (){
  278. $(".tableTest").each(function(i){
  279. $(this).attr('id','tabTable'+i);
  280. $(this).find("input[name=dispOrd]").val(i+1);
  281. //console.log($(this).attr('id'));
  282. });
  283. }
  284. /**
  285. * 브랜드 이미지 첨부
  286. */
  287. var fnBrandImgFileUpload = function (obj, ind){
  288. var file = obj.files[0];
  289. file.name = 'test';
  290. if (typeof(file) == 'undefined'){
  291. return;
  292. }
  293. // 파일 업로드
  294. gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents/brand/'
  295. , file
  296. , function(result) {
  297. $(obj).closest('div').find('input:hidden[name=brandNewImgFile]').val(result.newFileName);
  298. $("#brandPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultBrandUrlPop").val()+result.newFileName);
  299. $("#brandImgViewPop_"+ind).removeClass("off").addClass("on");
  300. }
  301. , 'image'
  302. );
  303. }
  304. /**
  305. * 브랜드그룹 조회
  306. */
  307. var tblNm;
  308. var fnGetBrandGroup = function (obj){
  309. tblNm = $(obj).closest("table").attr('id');
  310. //console.log('tblNm:::::'+tblNm);
  311. cfnOpenBrandGroupListPopup("callBackBrandGroup", "S", "S");
  312. }
  313. var callBackBrandGroup = function (result){
  314. $("#"+tblNm).find("input[name=brandGroupNo]").val(result[0].brandGroupNo);
  315. }
  316. /**
  317. * 기획전/배너 추가
  318. */
  319. var planImgIndex = 0;
  320. var fnAddPlanRow = function (strvar, param){
  321. var src = '';
  322. var imgPath = '';
  323. if(typeof param!='object'){
  324. src = $("#uploadDefaultPlanUrlPop").val().replace('/contents/planning/', '')+param;
  325. imgPath = param;
  326. }
  327. var html = '<tr name="planRow">';
  328. html += '<th>기획전/배너<br>링크/이미지</th>';
  329. html += '<td><input type="text" name="planLink" id="planLink'+planImgIndex+'" value="'+strvar+'"></td>';
  330. html += '<td><div class="uFile w300">';
  331. html += '<input id="planFile_'+planImgIndex+'" name="file" type="file" class="uFileInput w300" onchange="fnPlanFileUpload(this, '+planImgIndex+')"/>';
  332. html += '<label for="planFile_'+planImgIndex+'" class="uFileLabel">파일선택</label>';
  333. html += '<input type="hidden" name="planImgPath" value="'+imgPath+'"/>';
  334. html += '<input type="hidden" name="planNewImgFile" value="" />';
  335. html += '</div>';
  336. html += '<div id="planImgViewPop_'+planImgIndex+'" class=';
  337. if(src!=''){
  338. html += '"on">';
  339. }else{
  340. html += '"off">';
  341. }
  342. html += '<img id="planPreViewUrlPop_'+planImgIndex+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'planPreimgViewPop\',$(this).attr(\'src\'));"/>';
  343. html += '</div></td>';
  344. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  345. html += '</tr>';
  346. if(typeof param == 'object'){
  347. if($(param).closest("table").find("tbody").find("tr[name=planRow]").length>4){
  348. mcxDialog.alert("기획전/배너는 5개까지 등록 가능합니다");
  349. return;
  350. }
  351. planImgIndex++;
  352. $(param).closest("table").find("tbody").append(html);
  353. }else{
  354. planImgIndex++;
  355. return html;
  356. }
  357. }
  358. // 기획전/배너 파일첨부
  359. var fnPlanFileUpload = function (obj, ind){
  360. var file = obj.files[0];
  361. file.name = 'test';
  362. if (typeof(file) == 'undefined'){
  363. return;
  364. }
  365. // 파일 업로드
  366. gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents/planning'
  367. , file
  368. , function(result) {
  369. $(obj).closest('div').find('input:hidden[name=planNewImgFile]').val(result.newFileName);
  370. $("#planPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultPlanUrlPop").val()+result.newFileName);
  371. $("#planImgViewPop_"+ind).removeClass("off").addClass("on");
  372. }
  373. , 'image'
  374. );
  375. }
  376. /**
  377. * 타이틀추가
  378. */
  379. var fnAddTitlePopRow = function (param){
  380. var val = typeof param=='object'?'':param;
  381. var html = '<tr name="titlePopRow">';
  382. html += '<th>타이틀</th>';
  383. html += '<td><input name="title" type="text" maxlength="200" data-valid-name="타이틀" value="'+val+'"/></td>';
  384. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  385. html += '</tr>';
  386. if(typeof param == 'object'){
  387. if($(param).closest("table").find("tbody").find("tr[name=titlePopRow]").length>3){
  388. mcxDialog.alert("타이틀은 4개까지 등록 가능합니다");
  389. return;
  390. }
  391. $(param).closest("table").find("tbody").append(html);
  392. }else{
  393. return html;
  394. }
  395. }
  396. /**
  397. * 서브텍스트추가
  398. */
  399. var fnAddSubTextPopRow = function (param){
  400. var val = typeof param=='object'?'':param;
  401. var html = '<tr name="subTextPopRow">'
  402. html += '<th>서브텍스트</th>';
  403. html += '<td><input type="text" name="subText" maxlength="200" value="'+val+'"/></td>';
  404. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  405. html += '</tr>';
  406. if(typeof param == 'object'){
  407. if($(param).closest("table").find("tbody").find("tr[name=subTextPopRow]").length>3){
  408. mcxDialog.alert("서브텍스트는 4개까지 등록 가능합니다");
  409. return;
  410. }
  411. $(param).closest("table").find("tbody").append(html);
  412. }else{
  413. return html;
  414. }
  415. }
  416. // 컨텐츠 행삭제
  417. var fnDeleteBrandRow = function (obj){
  418. $(obj).closest("table").remove();
  419. fnReloadIdx();
  420. }
  421. // 행삭제
  422. var fnDeleteTrRow = function (obj){
  423. $(obj).closest("tr").remove();
  424. }
  425. // 컨텐츠 추가 날짜 설정
  426. var fnCreateTimeOption = function(val, sel) {
  427. var html = '';
  428. for(var i=0; i<val; i++){
  429. var time = 0;
  430. if(i<10){
  431. time = '0'+i;
  432. }else {
  433. time = i;
  434. }
  435. var select = false;
  436. if(sel==time){
  437. select = true;
  438. }
  439. if(val==24){
  440. time += '시';
  441. }else if(val==60){
  442. time += '분';
  443. }
  444. html += '<option value="'+time+'"';
  445. if(select){
  446. html += 'selected="selected"';
  447. }
  448. html += '>'+time+'</option>';
  449. }
  450. return html;
  451. }
  452. // 창닫기
  453. var fnMainMultiContentsPopupFormClose = function (){
  454. uifnPopupClose('popupMainMultiContents');
  455. }
  456. /**
  457. * 임시저장
  458. */
  459. var dataArr = [];
  460. $("#btnMultiPopSave").on("click", function(){
  461. if(!gagajf.checkRequired("#multiPopSortable")){
  462. return;
  463. }
  464. dataArr = [];
  465. $("#multiPopSortable .tableTest").each(function(){ //$("#multiPopSortable table").each(function(){
  466. var newImgFileArr = [];
  467. var imgPath1 = '';
  468. var imgPath2 = '';
  469. var imgPath3 = '';
  470. var imgPath4 = '';
  471. var imgPath5 = '';
  472. var imgPath6 = '';
  473. var imgPath7 = '';
  474. var imgPath8 = '';
  475. var strVar1 = '';
  476. var strVar2 = '';
  477. var strVar3 = '';
  478. var strVar4 = '';
  479. var strVar5 = '';
  480. var strVar6 = '';
  481. var strVar7 = '';
  482. var strVar8 = '';
  483. var strTitle1 = '';
  484. var strTitle2 = '';
  485. var strTitle3 = '';
  486. var strTitle4 = '';
  487. var subText1 = '';
  488. var subText2 = '';
  489. var subText3 = '';
  490. var subText4 = '';
  491. var goodsImgArr = [];
  492. var goodsCdArr = [];
  493. var goodsNmArr = [];
  494. var i = 1;
  495. $(this).find('input[name=planImgPath]').each(function(){
  496. eval("imgPath" + i + "='"+$(this).val()+"'");
  497. i++;
  498. });
  499. $(this).find('input[name=planNewImgFile]').each(function(){
  500. newImgFileArr.push($(this).val());
  501. });
  502. i = 1;
  503. $(this).find('input[name=planLink]').each(function(){
  504. _mall = [[${@environment.getProperty('domain.front')}]];
  505. var val = $(this).val();
  506. val = val.replace('https:'+_mall, '');
  507. val = val.replace('http:'+_mall, '');
  508. val = val.replace(_mall, '');
  509. eval("strVar" + i + "='"+val+"'");
  510. i++;
  511. });
  512. i = 1;
  513. $(this).find('input[name=title]').each(function(){
  514. var title = $(this).val().replace(/[\']/gi, "\\'");
  515. eval("strTitle" + i + "='"+title+"'");
  516. i++;
  517. });
  518. i = 1;
  519. $(this).find('input[name=subText]').each(function(){
  520. var subText = $(this).val().replace(/[\']/gi, "\\'");
  521. eval("subText" + i + "='"+subText+"'");
  522. i++;
  523. });
  524. $(this).find('input[name=goodsImgPath]').each(function(){
  525. goodsImgArr.push($(this).val());
  526. });
  527. $(this).find('input[name=goodsCd]').each(function(){
  528. goodsCdArr.push($(this).val());
  529. });
  530. $(this).find('input[name=goodsNm]').each(function(){
  531. goodsNmArr.push($(this).val());
  532. });
  533. var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
  534. var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";
  535. var dispOrd = $(this).find("[name=dispOrd]").val();
  536. var brandGroupNo = $(this).find("[name=brandGroupNo]").val();
  537. var brandGroupImg = $(this).find("[name=brandNewImgFile]").val();
  538. var mdTitle = $(this).find("[name=mdTitle]").val();
  539. var data = {cateNo : cateNo
  540. , contentsLoc : contentsLoc
  541. , dispStdt : dispStdt
  542. , dispEddt : dispEddt
  543. , newImgFileArr : newImgFileArr
  544. , imgPath1 : imgPath1
  545. , imgPath2 : imgPath2
  546. , imgPath3 : imgPath3
  547. , imgPath4 : imgPath4
  548. , imgPath5 : imgPath5
  549. , imgPath6 : imgPath6
  550. , imgPath7 : imgPath7
  551. , imgPath8 : imgPath8
  552. , strVar1 : strVar1
  553. , strVar2 : strVar2
  554. , strVar3 : strVar3
  555. , strVar4 : strVar4
  556. , strVar5 : strVar5
  557. , strVar6 : strVar6
  558. , strVar7 : strVar7
  559. , strVar8 : strVar8
  560. , strTitle1 : strTitle1
  561. , strTitle2 : strTitle2
  562. , strTitle3 : strTitle3
  563. , strTitle4 : strTitle4
  564. , subText1 : subText1
  565. , subText2 : subText2
  566. , subText3 : subText3
  567. , subText4 : subText4
  568. , brandGroupNo : brandGroupNo
  569. , brandGroupImg : brandGroupImg
  570. , mdTitle : mdTitle
  571. , useYn : 'Y'
  572. , dispOrd : dispOrd
  573. , multiContentsYn : 'Y'
  574. , goodsCdArr : goodsCdArr
  575. , goodsNmArr : goodsNmArr
  576. , goodsImgArr : goodsImgArr
  577. };
  578. dataArr.push(data);
  579. });
  580. if(dataArr.length==0){
  581. var data = {cateNo : cateNo
  582. , contentsLoc : contentsLoc
  583. };
  584. dataArr.push(data);
  585. }else{
  586. var dataArrSort = [];
  587. dataArr.forEach(function(item, index){
  588. if(dataArr[index].dispOrd>0){
  589. for(var i=1; i<dataArr.length; i++){
  590. if(i>index){
  591. if(dataArr[index].dispOrd==dataArr[i].dispOrd){
  592. dataArr[i].dispOrd = Number(dataArr[i].dispOrd) + 1;
  593. }
  594. }
  595. }
  596. }
  597. });
  598. dataArr.forEach(function(item, index){
  599. if(dataArr[index].dispOrd != ''){
  600. dataArrSort[dataArr[index].dispOrd-1] = item;
  601. }
  602. });
  603. dataArr.forEach(function(item, index){
  604. if(dataArr[index].dispOrd == ''){
  605. var empty = false;
  606. for(var i=0; i<dataArrSort.length; i++){
  607. if(typeof dataArrSort[i] == 'undefined'){
  608. dataArrSort[i] = item;
  609. empty = true;
  610. break;
  611. }
  612. };
  613. if(!empty){
  614. dataArrSort.push(item);
  615. }
  616. }
  617. });
  618. dataArr = dataArrSort;
  619. }
  620. var jsonData = JSON.stringify(dataArr);
  621. mcxDialog.confirm('컨텐츠를 저장 하시겠습니까?', {
  622. cancelBtnText: "취소",
  623. sureBtnText: "확인",
  624. sureBtnClick: function(){
  625. gagajf.ajaxJsonSubmit('/display/contents/preview/save', jsonData, fnGetMultiContentsPreviewList);
  626. }
  627. });
  628. });
  629. /**
  630. * 상품추가
  631. */
  632. var goodsIdx = 0;
  633. var fnAddGoodsRow = function (param, param2, param3){
  634. var addRow = "goodsListTd"+goodsIdx;
  635. //console.log('addRow::'+addRow);
  636. var html = '<tr name="goodsRow">';
  637. html += '<th>상품추가<br><button type="button" class="btn btn-base btn-lg" onclick="fnSearchGoods(\''+addRow+'\');">상품조회</button>';
  638. html += '<br></br><button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteTrRow(this);">삭제</button>';
  639. html += '</th>';
  640. html += '<td colspan="3">';
  641. //html += '<table style="border-style: solid;border-color: #ac2925; width:100%; height:20px;">';
  642. //html += '<colgroup>';
  643. //html += '<col style="width:90%;"/>';
  644. //html += '<col style="width:10%;"/>';
  645. //html += '<col/>';
  646. //html += '</colgroup>';
  647. //html += '<thead>';
  648. html += '<div class="sortableWrap" data-unit="7" style="overflow-y:scroll;">';
  649. html += '<div class="itemWrap" id="goodsListTd'+goodsIdx+'">';
  650. if(typeof param!='object'){
  651. var goodsCdList = [];
  652. var goodsNmList = [];
  653. var goodsImgList = [];
  654. goodsCdList = param;
  655. goodsNmList = param2;
  656. goodsImgList = param3;
  657. // 여기서 부터 시작! 상품불러오는거 똑같이 html 추가해서 체크
  658. // +) 저장할때 TMP_CONTENTS_GOODS 에 상품코드, 상품명, 상품이미지경로 추가해서 3개다 불러와서 데이터 뿌릴수 있게
  659. $.each(goodsCdList.split(','),function (i){
  660. html += '<ul id="goodsUl'+i+'" class="item ui-state-default goodsClass" style="min-height:120px;"> ';
  661. goodsImg = goodsImgList.split(',')[i];
  662. goodsCd = goodsCdList.split(',')[i];
  663. goodsNm = goodsNmList.split(',')[i];
  664. html += '<li class="img">';
  665. var imgPath = _goodsUrl;
  666. html += '<img src="'+imgPath+ "/" +goodsImg+'" onerror="this.src=\'/image/no.gif\';"/>';
  667. html += '</li>';
  668. html += '<li class="cont">';
  669. html += '<ul>';
  670. html += '<li class="no" name="goodsCdLi"><span>'+goodsCd+'</span>';
  671. html += '<input type="hidden" name="goodsImgPath" value="'+goodsImg+'">';
  672. html += '<input type="hidden" name="goodsCd" value="'+goodsCd+'">';
  673. html += '<input type="hidden" name="goodsNm" value="'+goodsNm+'">';
  674. html += '<span style="margin-left:5px;"><a href="javascript:void(0);" id="delId" onclick="fnRemoveGoods(this,'+i+');">X</a></span>';
  675. html += '</li>';
  676. html += '</li>';
  677. html += '<li class="title">'+goodsNm+'</li>';
  678. html += '</ul>';
  679. html += '</ul>';
  680. });
  681. }
  682. html += '</div>';
  683. html += '</div>';
  684. //html += '</thead>';
  685. //html += '</table>';
  686. html += '</td>';
  687. html += '</tr>';
  688. if(typeof param == 'object'){
  689. if($(param).closest("table").find("tbody").find("tr[name=goodsRow]").length>0){
  690. mcxDialog.alert("상품추가 ROW는 1개 등록 가능합니다");
  691. return;
  692. }
  693. goodsIdx++;
  694. $(param).closest("table").find("tbody").append(html);
  695. }else{
  696. goodsIdx++;
  697. return html;
  698. }
  699. fnReloadIdx();
  700. }
  701. /**
  702. * 상품조회
  703. */
  704. var addRowTd;
  705. var fnSearchGoods = function (obj){
  706. addRowTd = obj;
  707. cfnOpenGoodsPopup('fnAddMultiContentsGoods');
  708. }
  709. var firstOrd = '';
  710. //var uploadGoodsUrl = _goodsUrl [[${@environment.getProperty('upload.goods.view')}]];
  711. var fnAddMultiContentsGoods = function(result){
  712. console.log('goodsRowIdx>>>>'+addRowTd);
  713. var html='';
  714. for(let i = 0 ; i < result.length ; i++) {
  715. if(i==0){
  716. firstOrd = result[i].dispOrd;
  717. }
  718. html+='<ul id="goodsUl'+i+'" class="item ui-state-default goodsClass" style="min-height:120px;" ';
  719. if(result[i].goodsStat!="G008_90" || result[i].currStockQty<1){
  720. html += 'background:#f5f5f5;';
  721. }
  722. html += '">';
  723. html += '<li class="img">';
  724. var imgPath = '';
  725. //if(result[i].imgType=='A'){
  726. imgPath = _goodsUrl;
  727. //}
  728. html += '<img src="'+imgPath+ "/" +result[i].sysImgNm+'" onerror="this.src=\'/image/no.gif\';"/>';
  729. html += '</li>';
  730. html += '<li class="cont">';
  731. html += '<ul>';
  732. html += '<li class="no" name="goodsCdLi"><span>'+result[i].goodsCd+'</span>';
  733. html += '<input type="hidden" name="goodsImgPath" value="'+result[i].sysImgNm+'">';
  734. html += '<input type="hidden" name="goodsCd" value="'+result[i].goodsCd+'">';
  735. html += '<input type="hidden" name="goodsNm" value="'+result[i].goodsNm+'">';
  736. html += '<span style="margin-left:5px;"><a href="javascript:void(0);" id="delId" onclick="fnRemoveGoods(this,'+i+');">X</a></span>';
  737. html += '</li>';
  738. html += '<li class="title">'+result[i].goodsNm+'</li>';
  739. /*html += '<li>';
  740. html += '<span>전시순서 :</span>';
  741. html += '<input type="text" name="dispOrdEdit" value="" />';
  742. html += '<input type="text" name="setDispOrd" value="'+result[i].dispOrd+'"/>';
  743. html += '</li>';*/
  744. html += '</ul>';
  745. html += '</li>';
  746. html += '</ul>';
  747. }
  748. $("#"+addRowTd).append(html);
  749. $("#"+addRowTd).sortable();
  750. /*$("#"+addRowTd).sortable({
  751. stop: function(event, ui) {
  752. if(gagajf.isNull(firstOrd)){
  753. firstOrd = 1;
  754. }else{
  755. firstOrd = Number(firstOrd);
  756. }
  757. $("#"+addRowTd+" .item").each(function(i){
  758. $(this).find("input[name=setDispOrd]").val(i+firstOrd);
  759. });
  760. }
  761. });*/
  762. $("#"+addRowTd).disableSelection();
  763. uifnPopupClose('popupGoods');
  764. fnReloadGoodsListIdx(addRowTd);
  765. }
  766. var fnReloadGoodsListIdx = function (obj){
  767. var tableId = obj
  768. $("#"+tableId +" .goodsClass").each(function (i){
  769. $(this).attr('id','goodsUl'+i);
  770. $(this).find("#delId").attr('onclick','fnRemoveGoods(this,'+i+');');
  771. });
  772. }
  773. var fnRemoveGoods = function (obj , idx){
  774. var divId = $(obj).closest('div').attr('id');
  775. $("#"+divId+" #goodsUl"+idx).remove();
  776. fnReloadGoodsListIdx(divId);
  777. }
  778. $(document).ready(function() {
  779. $("#multiPopTitle").text("["+contentsLoc+"] "+gagaAgGrid.lookupValue(contentsLocArr, contentsLoc));
  780. $("#multiPopSortable").sortable({
  781. stop: function(event, ui) {
  782. fnReloadIdx();
  783. }
  784. });
  785. $("#multiPopSortable").disableSelection();
  786. fnGetMultiContentsPreviewList();
  787. fnReloadIdx();
  788. });
  789. /*]]>*/
  790. </script>
  791. </html>