MainMultiContentsPopupForm.html 34 KB

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