MainMultiContentsPopupForm.html 28 KB

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