$(document).on('click', '#addMajorBtn', function (){ getEditModal(null) }) $(document).on('click', '.tr', function (){ $(".trChkBox").prop("checked", false); $(this).find(".trChkBox").prop("checked", true); getViewModal(Number($(this).find(".majorKey").val())); }) // $(document).on('click', '.tr', function (event){ // const target = event.target; // if(!(target.className === "cpChk" ||$(target).parents("td").length>0)){ // const phoneKey = (Number($(this).find(".phoneKey").val())); // showModal(phoneKey); // } // }); $(document).on('click', '#saveBtn', function (){ saveContent("boardEditForm") }) $(document).on('click', '#editBtn', function (){ $("#MajorViewModal").modal('hide') getEditModal($(this).attr("data-majorkey")); }) $(function(){ $("#dateSelectorDiv").datepicker({ format: "yyyy-mm-dd", language: "ko", autoclose: true }); }) $(document).on('click', '#delectMajorBtn', function (){ if(confirm("선택한 대상을 삭제처리 하시겠습니까?")){ const checkArr = []; $('input:checkbox[name=equChk]:checked').each(function (idx, el){ checkArr.push({}); const target = $(el); checkArr[idx].equKey = Number(target.parents('tr').find('.majorKey').val()); }) deleteMajor(checkArr); } }) // $(document).on('click', '#deleteEquip', function (){ // if(confirm("선택한 대상을 삭제처리 하시겠습니까?")){ // const checkArr = []; // checkArr.push({}); // checkArr[0].equKey = Number($('#mEquKey').val()); // deleteEquip(checkArr); // } // }) function deleteMajor(checkArr){ $.ajax({ type : 'POST', url : "/ivsgt/deleteContent", data : JSON.stringify(checkArr), contentType: 'application/json', beforeSend: function (xhr){ xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); }, success : function() { alert("삭제처리 되었습니다."); location.reload(); }, error : function(xhr, status) { alert("삭제처리에 실패하였습니다"); } }) } function getEditModal(majorKey){ $.ajax({ url: '/ivsgt/majorEditModal', data: {majorKey: majorKey}, type: 'GET', dataType:"html", success: function(html){ $("#editContent").empty().append(html); setUploadDiv(); setEditor('editor', '570'); $("#MajorEditModal").modal('show'); }, error:function(){ } }); } function getViewModal(majorKey){ $.ajax({ url: '/ivsgt/majorViewModal', data: {majorKey: majorKey}, type: 'GET', dataType:"html", success: function(html){ $("#viewContent").empty().append(html) $("#MajorViewModal").modal('show'); }, error:function(){ } }); } function saveContent(formId, majorType){ if(contentCheck(formId)){ if(confirm("저장하시겠습니까?")){ contentFade("in"); $("#content").val(""); const formData = new FormData($("#"+formId)[0]); for(const file of files) { if(!file.isDelete) formData.append('uploadFiles', file, file.name); } $(".text-decoration-line-through").each(function (idx, el){ formData.append('fileSeq', $(el).attr("data-fileseq")); }) formData.append('contentInfo', CrossEditor.GetBodyValue()); $.ajax({ type : 'POST', data : formData, url : "/ivsgt/saveContent", processData: false, contentType: false, success : function(result) { alert("저장되었습니다."); contentFade("out"); $("#MajorEditModal").modal('hide'); getViewModal(result); }, error : function(xhr, status) { alert("저장에 실패하였습니다.") contentFade("out"); } }) } } } function contentCheck(formId){ let flag = true; if(!$("#contentTitle").val()){ alert("제목을 입력해주세요.") flag = false; } flag = fileCheck(flag, files); return flag; } function commentFormReset(){ const commentForm = $("#commentForm"); commentForm[0].reset(); $("#childFormRemoveBtn").hide(); $("#parentComment").val(''); $("#commentFormHome").append(commentForm) }