MainMultiContentsPopupForm.html 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  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" id="addGoodsBtn'+i+'" 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' || contentsLoc=='SOM003'){
  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' || result[i].contentsLoc=='SOM003'){
  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 , i);
  177. }
  178. html += '</tbody></table>';
  179. }
  180. $("#multiPopSortable").append(html);
  181. $("#multiPopSortable").sortable();
  182. $(".itemWrap").sortable({
  183. stop : function (event, table){
  184. $('.tableTest').each(function (i){
  185. $('#goodsListTd'+i).find('.goodsClass').each(function (j){
  186. $(this).find('input[name=dispOrdEdit]').val(j+1);
  187. });
  188. });
  189. }
  190. });
  191. $('.schDate').datepicker("destroy");
  192. $('.schDate').datepicker({
  193. changeMonth: true,
  194. changeYear: true,
  195. defaultDate: $('.schDate').val()
  196. });
  197. tableLen = $(".tableTest").length;
  198. }
  199. /**
  200. * 브랜드이미지 불러오기
  201. */
  202. var brandImgIdx = 0;
  203. var fnAddBrandImgRow = function (param){
  204. var src = '';
  205. var imgPath = '';
  206. if(typeof param!='object'){
  207. src = $("#uploadDefaultBrandUrlPop").val().replace('/contents/brand/', '')+param;
  208. imgPath = param;
  209. }
  210. var html = '<tr name="brandImgRow">';
  211. html += '<th>브랜드이미지</th>';
  212. html += '<td colspan="3">';
  213. html += ' <div class="uFile w300">';
  214. html += ' <input id="brandFile_'+brandImgIdx+'" name="file" type="file" class="uFileInput w300" onchange="fnBrandImgFileUpload(this, '+brandImgIdx+')">';
  215. html += ' <label for="brandFile_'+brandImgIdx+'" class="uFileLabel">파일선택</label>';
  216. html += ' <input type="hidden" name="brandImgPath" value="'+imgPath+'">';
  217. html += ' <input type="hidden" name="brandNewImgFile" value="">';
  218. html += ' </div>';
  219. html += ' <div id="brandImgViewPop_'+brandImgIdx+'" class=';
  220. if (src != '') {
  221. html += '"on">';
  222. } else {
  223. html += '"off">';
  224. }
  225. html += ' <img id="brandPreViewUrlPop_'+brandImgIdx+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'brandPreViewUrlPop\',$(this).attr(\'src\'));"/>';
  226. html += ' </div>';
  227. html += '</td>';
  228. html += '</tr>';
  229. return html;
  230. }
  231. /**
  232. * 브랜드 추가 버튼
  233. */
  234. var brandIdx = 0;
  235. var fnAddBrand = function (param) {
  236. brandIdx = tableLen;
  237. var src = '';
  238. var imgPath = '';
  239. if (typeof param != 'object') {
  240. src = $("#uploadDefaultBrandUrlPop").val().replace('/contents/brand', '') + param;
  241. imgPath = param;
  242. }
  243. var html = '<table class="frmStyle tableTest" style="margin-bottom:30px" id="tabTable'+brandIdx+'" >';
  244. html += '<input type="hidden" name="tableIdx" value="'+brandIdx+'" data-id="'+brandIdx+'">';
  245. html += '<colgroup>';
  246. html += '<col style="width:10%;"/>';
  247. html += '<col style="width:55%;"/>';
  248. html += '<col/>';
  249. html += '</colgroup>';
  250. 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"/>';
  251. html += '<select name="stTimeHour" required="required" data-valid-name="노출기간 시작시간">';
  252. html += fnCreateTimeOption(24);
  253. html += '</select>';
  254. html += '<select name="stTimeMin" required="required" data-valid-name="노출기간 시작시간">';
  255. html += fnCreateTimeOption(60);
  256. html += '</select>';
  257. html += '<span> ~ </span>';
  258. html += '<input name="dispEddt" type="text" class="w80 schDate" maxlength="10" required="required" data-valid-name="노출종료일" data-valid-type="calendar"/>';
  259. html += '<select name="edTimeHour" required="required" data-valid-name="노출기간 종료시간">';
  260. html += fnCreateTimeOption(24, 23);
  261. html += '</select>';
  262. html += '<select name="edTimeMin" required="required" data-valid-name="노출기간 종료시간">';
  263. html += fnCreateTimeOption(60, 59);
  264. html += '</select>';
  265. html += '<input name="dispOrd" type="text" class="w80" placeholder="전시순서" style="margin-left:5px; text-align:center"/>';
  266. html += '</td>';
  267. html += '<td class="aL">';
  268. if(contentsLoc=='SMM007') {
  269. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddPlanRow(\'#\',this);">기획전/배너추가</button>';
  270. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddTitlePopRow(this);">타이틀추가</button>';
  271. html += '<button type="button" class="btn btn-base btn-lg" onclick="fnAddSubTextPopRow(this);">서브텍스트추가</button>';
  272. }
  273. html += '<button type="button" class="btn btn-base btn-lg" id="addGoodsBtn'+brandIdx+'" onclick="fnAddGoodsRow(this);">상품추가</button>';
  274. html += '<button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteBrandRow(this);">삭제</button></td>';
  275. html += '</tr>';
  276. if(contentsLoc=='SMM009' || contentsLoc=='SMM012'){
  277. html += '<tr>';
  278. html += '<th>MD탭문구</th>';
  279. html += '<td colspan="3"><input type="text" name="mdTitle" id="mdTitle" style="width:30%;"></td>';
  280. html += '</tr>';
  281. }
  282. if(contentsLoc=='SMM007'){
  283. html += '<tr>';
  284. html += '<th>브랜드코드</th>';
  285. html += '<td colspan="3"><input type="text" name="brandGroupNo" style="width:30%;">';
  286. html += '<button type="button" class="btn btnRight btn-success btn-lg" onclick="fnGetBrandGroup(this);">브랜드조회</button>';
  287. html += '</td>';
  288. html += '</tr>';
  289. /* html += '<tr name="brandImgRow">';
  290. html += '<th>브랜드이미지</th>';
  291. html += '<td colspan="3">';
  292. html += ' <div class="uFile w300">';
  293. html += ' <input id="brandFile_' + brandIdx + '" name="file" type="file" class="uFileInput w300" onchange="fnBrandImgFileUpload(this, ' + brandIdx + ')">';
  294. html += ' <label for="brandFile_' + brandIdx + '" class="uFileLabel">파일선택</label>';
  295. html += ' <input type="hidden" name="brandImgPath" value="' + imgPath + '">';
  296. html += ' <input type="hidden" name="brandNewImgFile" value="">';
  297. html += ' </div>';
  298. html += ' <div id="brandImgViewPop_' + brandIdx + '" class=';
  299. if (src != '') {
  300. html += '"on">';
  301. } else {
  302. html += '"off">';
  303. }
  304. html += ' <img id="brandPreViewUrlPop_' + brandIdx + '" src="" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'brandPreViewUrlPop\',$(this).attr(\'src\'));"/>';
  305. html += ' </div>';
  306. html += '</td>';
  307. html += '</tr>';*/
  308. }
  309. if(contentsLoc=='SCM002' || contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  310. html += ' <tr>';
  311. html += ' <th>전시 설정</th>';
  312. html += ' <td>';
  313. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+brandIdx+'" value="Y" checked="checked"/>노출</label>';
  314. html += ' <label class="rdoBtn"><input type="radio" name="dispYn'+brandIdx+'" value="N"/>비노출</label>';
  315. html += ' </td>';
  316. if(contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  317. html += ' <th>상품 노출 개수</th>';
  318. html += ' <td>';
  319. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+brandIdx+'" value="10" checked="checked"/>10개</label>';
  320. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+brandIdx+'" value="20"/>20개</label>';
  321. html += ' <label class="rdoBtn"><input type="radio" name="dispCnt'+brandIdx+'" value="30"/>30개</label>';
  322. html += ' </td>';
  323. }
  324. html += ' </tr>';
  325. }
  326. html += '</thead><tbody></tbody></table>';
  327. // brandIdx++;
  328. $("#multiPopSortable").prepend(html);
  329. $("#multiPopSortable").sortable();
  330. /*$("#multiPopSortable").sortable({
  331. stop : function (event, table){
  332. $(".tableTest").each(function(i){
  333. $(this).attr('id','tabTable'+i);
  334. console.log($(this).attr('id'));
  335. });
  336. }
  337. });*/
  338. $('.schDate').datepicker("destroy");
  339. $('.schDate').datepicker({
  340. changeMonth: true,
  341. changeYear: true,
  342. defaultDate: $('.schDate').val()
  343. });
  344. if(contentsLoc == 'SBM007' || contentsLoc == 'SBM008' || contentsLoc == 'SBM009' || contentsLoc == 'SMM003' || contentsLoc == 'SMM007' || contentsLoc == 'SMM009'
  345. || contentsLoc == 'SCM002' || contentsLoc == 'SCM003' || contentsLoc == 'SOM003'){
  346. $("#addGoodsBtn"+brandIdx).click();
  347. }
  348. fnReloadIdx();
  349. tableLen = tableLen+1;
  350. }
  351. var fnReloadIdx = function (){
  352. $(".tableTest").each(function(i){
  353. // $(this).attr('id','tabTable'+i);
  354. $(this).find("input[name=dispOrd]").val(i+1);
  355. //console.log($(this).attr('id'));
  356. // if(contentsLoc == 'SBM007' || contentsLoc == 'SBM008' || contentsLoc == 'SBM009' || contentsLoc == 'SMM003' || contentsLoc == 'SMM007' || contentsLoc == 'SMM009'
  357. // || contentsLoc == 'SCM002' || contentsLoc == 'SCM003' || contentsLoc == 'SOM003'){
  358. // var tableIdx = $(this).find('input[name=tableIdx]').val();
  359. // if(gagajf.isNull(tableIdx)){
  360. // tableIdx = 0;
  361. // }
  362. // goodsIdx = tableIdx;
  363. // console.log('tableIdx>>>'+tableIdx);
  364. // }
  365. });
  366. }
  367. /**
  368. * 브랜드 이미지 첨부
  369. */
  370. var fnBrandImgFileUpload = function (obj, ind){
  371. var file = obj.files[0];
  372. file.name = 'test';
  373. if (typeof(file) == 'undefined'){
  374. return;
  375. }
  376. // 파일 업로드
  377. gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents/brand/'
  378. , file
  379. , function(result) {
  380. $(obj).closest('div').find('input:hidden[name=brandNewImgFile]').val(result.newFileName);
  381. $("#brandPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultBrandUrlPop").val()+result.newFileName);
  382. $("#brandImgViewPop_"+ind).removeClass("off").addClass("on");
  383. }
  384. , 'image'
  385. );
  386. }
  387. /**
  388. * 브랜드그룹 조회
  389. */
  390. var tblNm;
  391. var fnGetBrandGroup = function (obj){
  392. tblNm = $(obj).closest("table").attr('id');
  393. //console.log('tblNm:::::'+tblNm);
  394. cfnOpenBrandGroupListPopup("callBackBrandGroup", "S", "S");
  395. }
  396. var callBackBrandGroup = function (result){
  397. $("#"+tblNm).find("input[name=brandGroupNo]").val(result[0].brandGroupNo);
  398. }
  399. /**
  400. * 기획전/배너 추가
  401. */
  402. var planImgIndex = 0;
  403. var fnAddPlanRow = function (strvar, param){
  404. var src = '';
  405. var imgPath = '';
  406. if(typeof param!='object'){
  407. src = $("#uploadDefaultPlanUrlPop").val().replace('/contents/planning/', '')+param;
  408. imgPath = param;
  409. }
  410. var html = '<tr name="planRow">';
  411. html += '<th>기획전/배너<br>링크/이미지</th>';
  412. html += '<td><input type="text" name="planLink" id="planLink'+planImgIndex+'" value="'+strvar+'"></td>';
  413. html += '<td><div class="uFile w300">';
  414. html += '<input id="planFile_'+planImgIndex+'" name="file" type="file" class="uFileInput w300" onchange="fnPlanFileUpload(this, '+planImgIndex+')"/>';
  415. html += '<label for="planFile_'+planImgIndex+'" class="uFileLabel">파일선택</label>';
  416. html += '<input type="hidden" name="planImgPath" value="'+imgPath+'"/>';
  417. html += '<input type="hidden" name="planNewImgFile" value="" />';
  418. html += '</div>';
  419. html += '<div id="planImgViewPop_'+planImgIndex+'" class=';
  420. if(src!=''){
  421. html += '"on">';
  422. }else{
  423. html += '"off">';
  424. }
  425. html += '<img id="planPreViewUrlPop_'+planImgIndex+'" src="'+src+'" style="height:100px; max-width:500px;" onclick="cfnOpenImagePreViewPopup(\'planPreimgViewPop\',$(this).attr(\'src\'));"/>';
  426. html += '</div></td>';
  427. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  428. html += '</tr>';
  429. if(typeof param == 'object'){
  430. if($(param).closest("table").find("tbody").find("tr[name=planRow]").length>4){
  431. mcxDialog.alert("기획전/배너는 5개까지 등록 가능합니다");
  432. return;
  433. }
  434. planImgIndex++;
  435. $(param).closest("table").find("tbody").append(html);
  436. }else{
  437. planImgIndex++;
  438. return html;
  439. }
  440. }
  441. // 기획전/배너 파일첨부
  442. var fnPlanFileUpload = function (obj, ind){
  443. var file = obj.files[0];
  444. file.name = 'test';
  445. if (typeof(file) == 'undefined'){
  446. return;
  447. }
  448. // 파일 업로드
  449. gagajf.ajaxFileUpload('/common/file/upload?subDir=/contents/planning'
  450. , file
  451. , function(result) {
  452. $(obj).closest('div').find('input:hidden[name=planNewImgFile]').val(result.newFileName);
  453. $("#planPreViewUrlPop_"+ind).attr('src', $("#uploadDefaultPlanUrlPop").val()+result.newFileName);
  454. $("#planImgViewPop_"+ind).removeClass("off").addClass("on");
  455. }
  456. , 'image'
  457. );
  458. }
  459. /**
  460. * 타이틀추가
  461. */
  462. var fnAddTitlePopRow = function (param){
  463. var val = typeof param=='object'?'':param;
  464. var html = '<tr name="titlePopRow">';
  465. html += '<th>타이틀</th>';
  466. html += '<td><input name="title" type="text" maxlength="200" data-valid-name="타이틀" value="'+val+'"/></td>';
  467. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  468. html += '</tr>';
  469. if(typeof param == 'object'){
  470. if($(param).closest("table").find("tbody").find("tr[name=titlePopRow]").length>3){
  471. mcxDialog.alert("타이틀은 4개까지 등록 가능합니다");
  472. return;
  473. }
  474. $(param).closest("table").find("tbody").append(html);
  475. }else{
  476. return html;
  477. }
  478. }
  479. /**
  480. * 서브텍스트추가
  481. */
  482. var fnAddSubTextPopRow = function (param){
  483. var val = typeof param=='object'?'':param;
  484. var html = '<tr name="subTextPopRow">'
  485. html += '<th>서브텍스트</th>';
  486. html += '<td><input type="text" name="subText" maxlength="200" value="'+val+'"/></td>';
  487. html += '<td class="aL"><button type="button" class="btn icn" onclick="fnDeleteTrRow(this);"><i class="fa fa-times" aria-hidden="true"></i></button></td>';
  488. html += '</tr>';
  489. if(typeof param == 'object'){
  490. if($(param).closest("table").find("tbody").find("tr[name=subTextPopRow]").length>3){
  491. mcxDialog.alert("서브텍스트는 4개까지 등록 가능합니다");
  492. return;
  493. }
  494. $(param).closest("table").find("tbody").append(html);
  495. }else{
  496. return html;
  497. }
  498. }
  499. // 컨텐츠 행삭제
  500. var fnDeleteBrandRow = function (obj){
  501. mcxDialog.confirm('삭제시 전시순서가 초기화됩니다. 삭제하시겠습니까?', {
  502. cancelBtnText: "취소",
  503. sureBtnText: "확인",
  504. sureBtnClick: function(){
  505. $(obj).closest("table").remove();
  506. fnReloadIdx();
  507. }
  508. });
  509. }
  510. // 행삭제
  511. var fnDeleteTrRow = function (obj){
  512. $(obj).closest("tr").remove();
  513. }
  514. // 컨텐츠 추가 날짜 설정
  515. var fnCreateTimeOption = function(val, sel) {
  516. var html = '';
  517. for(var i=0; i<val; i++){
  518. var time = 0;
  519. if(i<10){
  520. time = '0'+i;
  521. }else {
  522. time = i;
  523. }
  524. var select = false;
  525. if(sel==time){
  526. select = true;
  527. }
  528. if(val==24){
  529. time += '시';
  530. }else if(val==60){
  531. time += '분';
  532. }
  533. html += '<option value="'+time+'"';
  534. if(select){
  535. html += 'selected="selected"';
  536. }
  537. html += '>'+time+'</option>';
  538. }
  539. return html;
  540. }
  541. // 창닫기
  542. var fnMainMultiContentsPopupFormClose = function (){
  543. uifnPopupClose('popupMainMultiContents');
  544. }
  545. // 전시 일시 체크
  546. function dateValidation(){
  547. var dateBool = true;
  548. $(".tableTest").each(function(i){
  549. var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
  550. var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";
  551. let fromDate = dispStdt.replace(/[^0-9]/g, '');
  552. let toDate = dispEddt.replace(/[^0-9]/g, '');
  553. if(fromDate > toDate){
  554. mcxDialog.alert("시작일자는 종료일자 보다 클 수 없습니다.");
  555. $(this).find('input[name=dispStdt]').focus();
  556. // dateBool = false;
  557. return false;
  558. }
  559. });
  560. // if(!dateBool){
  561. // return false;
  562. // }else{
  563. // return true;
  564. // }
  565. return true;
  566. }
  567. // 몰메인 신상품 : 상품데이터 체크
  568. var goodsArrValidation = function (){
  569. var dataBool = true;
  570. let dupCnt = 0;
  571. $("#multiPopSortable .tableTest").each(function(i){
  572. var thisIdx = $(this).find("input[name=tableIdx]").val();
  573. if($("#tabTable"+thisIdx+" #goodsListTd"+thisIdx).find('ul').find('input[name=goodsCd]').length < 1){
  574. mcxDialog.alert((i+1)+"번째 컨텐츠영역의 상품 정보가 없습니다.");
  575. $(this).focus();
  576. // dataBool = false;
  577. dupCnt++;
  578. return false;
  579. }
  580. });
  581. // if(!dataBool){
  582. // return false;
  583. // }else{
  584. // return true;
  585. // }
  586. if(dupCnt==0){
  587. return true;
  588. }
  589. }
  590. /**
  591. * 임시저장
  592. */
  593. var dataArr = [];
  594. $("#btnMultiPopSave").on("click", function(){
  595. if(!gagajf.checkRequired("#multiPopSortable")){
  596. return;
  597. }
  598. // 전시일시 체크
  599. if(!dateValidation()){
  600. return false;
  601. }
  602. if(contentsLoc == 'SBM007' || contentsLoc == 'SBM008' || contentsLoc == 'SBM009' || contentsLoc == 'SMM003' || contentsLoc == 'SMM007' || contentsLoc == 'SMM009'
  603. || contentsLoc == 'SCM002' || contentsLoc == 'SCM003' || contentsLoc == 'SOM003'){
  604. if(!goodsArrValidation()){
  605. return false;
  606. }
  607. }
  608. dataArr = [];
  609. $("#multiPopSortable .tableTest").each(function(){ //$("#multiPopSortable table").each(function(){
  610. var newImgFileArr = [];
  611. var imgPath1 = '';
  612. var imgPath2 = '';
  613. var imgPath3 = '';
  614. var imgPath4 = '';
  615. var imgPath5 = '';
  616. var imgPath6 = '';
  617. var imgPath7 = '';
  618. var imgPath8 = '';
  619. var strVar1 = '';
  620. var strVar2 = '';
  621. var strVar3 = '';
  622. var strVar4 = '';
  623. var strVar5 = '';
  624. var strVar6 = '';
  625. var strVar7 = '';
  626. var strVar8 = '';
  627. var strTitle1 = '';
  628. var strTitle2 = '';
  629. var strTitle3 = '';
  630. var strTitle4 = '';
  631. var subText1 = '';
  632. var subText2 = '';
  633. var subText3 = '';
  634. var subText4 = '';
  635. // var goodsImgArr = [];
  636. var goodsCdArr = [];
  637. // var goodsNmArr = [];
  638. var goodsDispOrdArr = [];
  639. var i = 1;
  640. $(this).find('input[name=planImgPath]').each(function(){
  641. eval("imgPath" + i + "='"+$(this).val()+"'");
  642. i++;
  643. });
  644. $(this).find('input[name=planNewImgFile]').each(function(){
  645. newImgFileArr.push($(this).val());
  646. });
  647. i = 1;
  648. $(this).find('input[name=planLink]').each(function(){
  649. _mall = [[${@environment.getProperty('domain.front')}]];
  650. var val = $(this).val();
  651. val = val.replace('https:'+_mall, '');
  652. val = val.replace('http:'+_mall, '');
  653. val = val.replace(_mall, '');
  654. eval("strVar" + i + "='"+val+"'");
  655. i++;
  656. });
  657. i = 1;
  658. $(this).find('input[name=title]').each(function(){
  659. var title = $(this).val().replace(/[\']/gi, "\\'");
  660. eval("strTitle" + i + "='"+title+"'");
  661. i++;
  662. });
  663. i = 1;
  664. $(this).find('input[name=subText]').each(function(){
  665. var subText = $(this).val().replace(/[\']/gi, "\\'");
  666. eval("subText" + i + "='"+subText+"'");
  667. i++;
  668. });
  669. // $(this).find('input[name=goodsImgPath]').each(function(){
  670. // goodsImgArr.push($(this).val());
  671. // });
  672. $(this).find('input[name=goodsCd]').each(function(){
  673. goodsCdArr.push($(this).val());
  674. });
  675. // $(this).find('input[name=goodsNm]').each(function(){
  676. // goodsNmArr.push($(this).val());
  677. // });
  678. $(this).find('input[name=dispOrdEdit]').each(function(){
  679. goodsDispOrdArr.push($(this).val());
  680. });
  681. var dispStdt = $(this).find("[name=dispStdt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=stTimeHour]").val().replace('시', '') + "" +$(this).find("[name=stTimeMin]").val().replace('분', '') + "00";
  682. var dispEddt = $(this).find("[name=dispEddt]").val().replace(/[^0-9]/g, '') + "" +$(this).find("[name=edTimeHour]").val().replace('시', '') + "" +$(this).find("[name=edTimeMin]").val().replace('분', '') + "59";
  683. var dispOrd = $(this).find("[name=dispOrd]").val();
  684. var brandGroupNo;
  685. if(contentsLoc=='SBM007'||contentsLoc=='SBM008'||contentsLoc=='SBM009'||contentsLoc=='SBM017'||contentsLoc=='SBM018'||contentsLoc=='SBM019'||contentsLoc=='SOM003'||contentsLoc=='SCM002'||contentsLoc=='SCM003'){
  686. brandGroupNo = [[${brandGroupNo}]];
  687. }else{
  688. brandGroupNo = $(this).find("[name=brandGroupNo]").val();
  689. }
  690. var brandGroupImg = $(this).find("[name=brandNewImgFile]").val();
  691. var mdTitle = $(this).find("[name=mdTitle]").val();
  692. var useYn = 'Y';
  693. if(contentsLoc=='SCM002' || contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  694. var thisIdx = $(this).find("input[name=tableIdx]").val();
  695. useYn = $(this).find("input:radio[name=dispYn"+thisIdx+"]:checked").val();
  696. }else{
  697. useYn = 'Y';
  698. }
  699. if(contentsLoc=='SCM003' || contentsLoc=='SOM003'){
  700. var thisIdx = $(this).find("input[name=tableIdx]").val();
  701. strVar1 = $(this).find("input:radio[name=dispCnt"+thisIdx+"]:checked").val();
  702. }
  703. var data = {cateNo : cateNo
  704. , contentsLoc : contentsLoc
  705. , dispStdt : dispStdt
  706. , dispEddt : dispEddt
  707. , newImgFileArr : newImgFileArr
  708. , imgPath1 : imgPath1
  709. , imgPath2 : imgPath2
  710. , imgPath3 : imgPath3
  711. , imgPath4 : imgPath4
  712. , imgPath5 : imgPath5
  713. , imgPath6 : imgPath6
  714. , imgPath7 : imgPath7
  715. , imgPath8 : imgPath8
  716. , strVar1 : strVar1
  717. , strVar2 : strVar2
  718. , strVar3 : strVar3
  719. , strVar4 : strVar4
  720. , strVar5 : strVar5
  721. , strVar6 : strVar6
  722. , strVar7 : strVar7
  723. , strVar8 : strVar8
  724. , strTitle1 : strTitle1
  725. , strTitle2 : strTitle2
  726. , strTitle3 : strTitle3
  727. , strTitle4 : strTitle4
  728. , subText1 : subText1
  729. , subText2 : subText2
  730. , subText3 : subText3
  731. , subText4 : subText4
  732. , brandGroupNo : brandGroupNo
  733. , brandGroupImg : brandGroupImg
  734. , mdTitle : mdTitle
  735. , useYn : useYn
  736. , dispOrd : dispOrd
  737. , multiContentsYn : 'Y'
  738. , goodsCdArr : goodsCdArr
  739. // , goodsNmArr : goodsNmArr
  740. // , goodsImgArr : goodsImgArr
  741. , goodsDispOrdArr : goodsDispOrdArr
  742. };
  743. dataArr.push(data);
  744. });
  745. if(dataArr.length==0){
  746. var data = {cateNo : cateNo
  747. , contentsLoc : contentsLoc
  748. };
  749. dataArr.push(data);
  750. }else{
  751. var dataArrSort = [];
  752. dataArr.forEach(function(item, index){
  753. if(dataArr[index].dispOrd>0){
  754. for(var i=1; i<dataArr.length; i++){
  755. if(i>index){
  756. if(dataArr[index].dispOrd==dataArr[i].dispOrd){
  757. dataArr[i].dispOrd = Number(dataArr[i].dispOrd) + 1;
  758. }
  759. }
  760. }
  761. }
  762. });
  763. dataArr.forEach(function(item, index){
  764. if(dataArr[index].dispOrd != ''){
  765. dataArrSort[dataArr[index].dispOrd-1] = item;
  766. }
  767. });
  768. dataArr.forEach(function(item, index){
  769. if(dataArr[index].dispOrd == ''){
  770. var empty = false;
  771. for(var i=0; i<dataArrSort.length; i++){
  772. if(typeof dataArrSort[i] == 'undefined'){
  773. dataArrSort[i] = item;
  774. empty = true;
  775. break;
  776. }
  777. };
  778. if(!empty){
  779. dataArrSort.push(item);
  780. }
  781. }
  782. });
  783. dataArr = dataArrSort;
  784. }
  785. var jsonData = JSON.stringify(dataArr);
  786. // console.log(jsonData);
  787. mcxDialog.confirm('컨텐츠를 저장 하시겠습니까?', {
  788. cancelBtnText: "취소",
  789. sureBtnText: "확인",
  790. sureBtnClick: function(){
  791. gagajf.ajaxJsonSubmit('/display/contents/preview/save', jsonData, fnGetMultiContentsPreviewList);
  792. }
  793. });
  794. });
  795. var fnUpBtn = function (obj, idx){
  796. var ind = $(obj).closest('.item').index();
  797. if(ind>0){
  798. $('#goodsListTd'+idx).find(".item").eq(ind-1).before($('#goodsListTd'+idx).find(".item").eq(ind));
  799. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val())+1);
  800. $('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=setDispOrd]").val())-1);
  801. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val())+1);
  802. $('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind-1).find("input[name=dispOrdEdit]").val())-1);
  803. }
  804. }
  805. var fnDownBtn = function (obj, idx){
  806. var ind = $(obj).closest('.item').index();
  807. if(ind<$("#goodsListTd"+idx).find('.goodsClass').length){
  808. $('#goodsListTd'+idx).find(".item").eq(ind+1).after($('#goodsListTd'+idx).find(".item").eq(ind));
  809. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=setDispOrd]").val())-1);
  810. $('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=setDispOrd]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=setDispOrd]").val())+1);
  811. $('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind).find("input[name=dispOrdEdit]").val())-1);
  812. $('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=dispOrdEdit]").val(Number($('#goodsListTd'+idx).find(".item").eq(ind+1).find("input[name=dispOrdEdit]").val())+1);
  813. }
  814. }
  815. var fnUpdownBtn = function (obj, gubun, idx){
  816. if(gubun=='up'){
  817. var ind = $(obj).closest('.item').index();
  818. $('#goodsListTd'+idx).find(".item").eq(0).before($('#goodsListTd'+idx).find(".item").eq(ind));
  819. $('#goodsListTd'+idx).find('.goodsClass').each(function (j){
  820. $(this).find('input[name=dispOrdEdit]').val(j+1);
  821. });
  822. }else{
  823. var ind = $(obj).closest('.item').index();
  824. let lastNum = $("#goodsListTd"+idx).find('.goodsClass').length;
  825. $('#goodsListTd'+idx).find(".item").eq(lastNum-1).after($('#goodsListTd'+idx).find(".item").eq(ind));
  826. $('#goodsListTd'+idx).find('.goodsClass').each(function (j){
  827. $(this).find('input[name=dispOrdEdit]').val(j+1);
  828. });
  829. }
  830. }
  831. /**
  832. * 상품추가
  833. */
  834. var goodsIdx = 0;
  835. var fnAddGoodsRow = function (param , tableIndex){
  836. if(!gagajf.isNull(tableIndex)){
  837. goodsIdx = tableIndex;
  838. }
  839. var addRow = "goodsListTd"+goodsIdx;
  840. var html = '<tr name="goodsRow">';
  841. html += '<th>상품추가<br><button type="button" class="btn btn-base btn-lg" onclick="fnSearchGoods(\''+addRow+'\');">상품조회</button>';
  842. html += '<br></br><button type="button" class="btn btn-danger btn-lg" onclick="fnDeleteTrRow(this);">삭제</button>';
  843. html += '</th>';
  844. html += '<td colspan="3">';
  845. html += '<div class="sortableWrap" data-unit="7" style="overflow-y:scroll;">';
  846. html += '<div class="itemWrap" id="goodsListTd'+goodsIdx+'">';
  847. // if(typeof param!='object'){
  848. var imgPath = _goodsUrl;
  849. for(let i=0; i<param.length; i++){
  850. html += '<ul id="goodsUl'+i+'" class="item ui-state-default goodsClass" style="min-height:200px;"> ';
  851. html += '<li class="img">';
  852. html += '<img src="'+imgPath+ "/" +param[i].sysImgNm+'" onerror="this.src=\'/image/no.png\';"/>';
  853. html += '<div class="btnArea">';
  854. html += '<button type="button" class="icnSm" title="맨위로" onclick="fnUpdownBtn(this, \'up\', \''+goodsIdx+'\');"><i class="fa fa-play-circle fa-rotate-270" aria-hidden="true"></i></button>';
  855. html += '<button type="button" class="icnSm" title="위로" onclick="fnUpBtn(this, \''+goodsIdx+'\');"><i class="fa fa-arrow-up" aria-hidden="true"></i></button>';
  856. html += '<button type="button" class="icnSm" title="맨아래로" onclick="fnUpdownBtn(this, \'down\', \''+goodsIdx+'\');"><i class="fa fa-play-circle fa-rotate-90" aria-hidden="true"></i></button>';
  857. html += '<button type="button" class="icnSm" title="아래로" onclick="fnDownBtn(this, \''+goodsIdx+'\');"><i class="fa fa-arrow-down" aria-hidden="true"></i></button>';
  858. html += '</div>';
  859. html += '</li>';
  860. html += '<li class="cont">';
  861. html += '<ul>';
  862. html += '<li class="no" name="goodsCdLi"><span>'+param[i].goodsCd+'</span>';
  863. // html += '<input type="hidden" name="goodsImgPath" value="'+param[i].sysImgNm+'">';
  864. html += '<input type="hidden" name="goodsCd" value="'+param[i].goodsCd+'">';
  865. // html += '<input type="hidden" name="goodsNm" value="'+param[i].goodsNm+'">';
  866. html += '<span style="margin-left:5px;"><a href="javascript:void(0);" id="delId" onclick="fnRemoveGoods(this,'+i+');">X</a></span>';
  867. html += '</li>';
  868. html += '</li>';
  869. html += '<li class="title">'+param[i].goodsNm+'</li>';
  870. html += '<li>';
  871. html += '<span>전시순서 :</span>';
  872. html += '<input type="text" name="dispOrdEdit" value="'+param[i].contentsDispOrd+'" />';
  873. html += '<input type="hidden" name="setDispOrd" value="'+param[i].contentsDispOrd+'"/>';
  874. html += '</li>';
  875. html += '</ul>';
  876. html += '</ul>';
  877. }
  878. // }
  879. html += '</div>';
  880. html += '</div>';
  881. html += '</td>';
  882. html += '</tr>';
  883. if(typeof param == 'object'){
  884. if($(param).closest("table").find("tbody").find("tr[name=goodsRow]").length>0){
  885. mcxDialog.alert("상품추가 ROW는 1개 등록 가능합니다");
  886. return;
  887. }
  888. goodsIdx++;
  889. $(param).closest("table").find("tbody").append(html);
  890. return html;
  891. }else{
  892. goodsIdx++;
  893. return html;
  894. }
  895. fnReloadIdx();
  896. }
  897. /**
  898. * 상품조회
  899. */
  900. var addRowTd;
  901. var fnSearchGoods = function (obj){
  902. addRowTd = obj;
  903. cfnOpenGoodsPopup('fnAddMultiContentsGoods');
  904. }
  905. var firstOrd = '';
  906. //var uploadGoodsUrl = _goodsUrl [[${@environment.getProperty('upload.goods.view')}]];
  907. var fnAddMultiContentsGoods = function(result){
  908. let thisIdx = $("#"+addRowTd).parent().parent().parent().parent().parent().find('input[name=tableIdx]').val();
  909. // console.log('goodsRowIdx>>>>'+addRowTd);
  910. let goodsCnt = 0;
  911. if($("#"+addRowTd).find('.item').length > 0){
  912. goodsCnt = $("#"+addRowTd).find('.item').length;
  913. }
  914. var html='';
  915. for(let i = 0 ; i < result.length ; i++) {
  916. let dispOrdVal = 0;
  917. dispOrdVal = goodsCnt +(i+1);
  918. if(i==0){
  919. firstOrd = result[i].dispOrd;
  920. }
  921. html+='<ul id="goodsUl'+i+'" class="item ui-state-default goodsClass" style="min-height:200px;" ';
  922. if(result[i].goodsStat!="G008_90" || result[i].currStockQty<1){
  923. html += 'background:#f5f5f5;';
  924. }
  925. html += '">';
  926. html += '<li class="img">';
  927. var imgPath = '';
  928. //if(result[i].imgType=='A'){
  929. imgPath = _goodsUrl;
  930. //}
  931. html += '<img src="'+imgPath+ "/" +result[i].sysImgNm+'" onerror="this.src=\'/image/no.png\';"/>';
  932. html += '<div class="btnArea">';
  933. html += '<button type="button" class="icnSm" title="맨위로" onclick="fnUpdownBtn(this, \'up\', \''+thisIdx+'\');"><i class="fa fa-play-circle fa-rotate-270" aria-hidden="true"></i></button>';
  934. html += '<button type="button" class="icnSm" title="위로" onclick="fnUpBtn(this, \''+thisIdx+'\');"><i class="fa fa-arrow-up" aria-hidden="true"></i></button>';
  935. html += '<button type="button" class="icnSm" title="맨아래로" onclick="fnUpdownBtn(this, \'down\', \''+thisIdx+'\');"><i class="fa fa-play-circle fa-rotate-90" aria-hidden="true"></i></button>';
  936. html += '<button type="button" class="icnSm" title="아래로" onclick="fnDownBtn(this, \''+thisIdx+'\');"><i class="fa fa-arrow-down" aria-hidden="true"></i></button>';
  937. html += '</div>';
  938. html += '</li>';
  939. html += '<li class="cont">';
  940. html += '<ul>';
  941. html += '<li class="no" name="goodsCdLi"><span>'+result[i].goodsCd+'</span>';
  942. // html += '<input type="hidden" name="goodsImgPath" value="'+result[i].sysImgNm+'">';
  943. html += '<input type="hidden" name="goodsCd" value="'+result[i].goodsCd+'">';
  944. // html += '<input type="hidden" name="goodsNm" value="'+result[i].goodsNm+'">';
  945. html += '<span style="margin-left:5px;"><a href="javascript:void(0);" id="delId" onclick="fnRemoveGoods(this,'+i+');">X</a></span>';
  946. html += '</li>';
  947. html += '<li class="title">'+result[i].goodsNm+'</li>';
  948. html += '<li>';
  949. html += '<span>전시순서 :</span>';
  950. html += '<input type="text" name="dispOrdEdit" value="'+dispOrdVal+'" />';
  951. html += '<input type="hidden" name="setDispOrd" value="'+dispOrdVal+'"/>';
  952. html += '</li>';
  953. html += '</ul>';
  954. html += '</li>';
  955. html += '</ul>';
  956. }
  957. $("#"+addRowTd).append(html);
  958. // $("#"+addRowTd).sortable();
  959. $("#"+addRowTd).sortable({
  960. stop: function(event, ui) {
  961. if(gagajf.isNull(firstOrd)){
  962. firstOrd = 1;
  963. }else{
  964. firstOrd = Number(firstOrd);
  965. }
  966. $("#"+addRowTd+" .item").each(function(i){
  967. $(this).find("input[name=dispOrdEdit]").val(i+firstOrd);
  968. });
  969. }
  970. });
  971. $("#"+addRowTd).disableSelection();
  972. uifnPopupClose('popupGoods');
  973. fnReloadGoodsListIdx(addRowTd);
  974. }
  975. var fnReloadGoodsListIdx = function (obj){
  976. var tableId = obj
  977. $("#"+tableId +" .goodsClass").each(function (i){
  978. $(this).attr('id','goodsUl'+i);
  979. $(this).find("#delId").attr('onclick','fnRemoveGoods(this,'+i+');');
  980. $(this).find("input[name=dispOrdEdit]").val(i+1);
  981. $(this).find("input[name=setDispOrd]").val(i+1);
  982. });
  983. }
  984. var fnRemoveGoods = function (obj , idx){
  985. var divId = $(obj).closest('div').attr('id');
  986. $("#"+divId+" #goodsUl"+idx).remove();
  987. fnReloadGoodsListIdx(divId);
  988. }
  989. $(document).ready(function() {
  990. $("#multiPopTitle").text("["+contentsLoc+"] "+gagaAgGrid.lookupValue(contentsLocArr, contentsLoc));
  991. $("#multiPopSortable").sortable({
  992. stop: function(event, ui) {
  993. fnReloadIdx();
  994. }
  995. });
  996. $("#multiPopSortable").disableSelection();
  997. fnGetMultiContentsPreviewList();
  998. fnReloadIdx();
  999. });
  1000. /*]]>*/
  1001. </script>
  1002. </html>