FAISP/src/main/resources/static/js/ivsgt/majorStatus.js

191 lines
5.3 KiB
JavaScript
Raw Normal View History

2023-01-05 06:26:05 +00:00
2023-01-06 05:00:33 +00:00
$(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"));
})
2023-01-05 06:26:05 +00:00
$(function(){
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
})
2023-01-06 05:00:33 +00:00
2023-01-06 05:59:25 +00:00
$(document).on('click', '#deleteMajorBtn', function (){
const majorKey = $('input[name=majorKey]').val();
console.log(majorKey);
if(confirm("삭제하시겠습니까?")){
contentFade("in");
$.ajax({
type : 'POST',
url : "/ivsgt/deleteContent",
data : JSON.stringify({majorKey:majorKey}),
contentType: 'application/json',
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(data) {
alert("삭제 처리되었습니다.");
location.reload();
},
error : function(xhr, status) {
alert("삭제 처리에 실패하였습니다");
}
2023-01-06 05:00:33 +00:00
})
}
})
2023-01-06 05:59:25 +00:00
// $(document).on('click', '#delectMajorBtn', function (){
2023-01-06 05:00:33 +00:00
// if(confirm("선택한 대상을 삭제처리 하시겠습니까?")){
// const checkArr = [];
2023-01-06 05:59:25 +00:00
// $('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);
//
2023-01-05 06:26:05 +00:00
// }
// })
2023-01-06 05:59:25 +00:00
// 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("삭제처리에 실패하였습니다");
// }
// })
// }
2023-01-05 06:26:05 +00:00
2023-01-06 05:00:33 +00:00
function getEditModal(majorKey){
2023-01-05 06:26:05 +00:00
$.ajax({
url: '/ivsgt/majorEditModal',
2023-01-06 05:00:33 +00:00
data: {majorKey: majorKey},
2023-01-05 06:26:05 +00:00
type: 'GET',
dataType:"html",
success: function(html){
2023-01-06 05:00:33 +00:00
$("#editContent").empty().append(html);
2023-01-05 06:26:05 +00:00
setUploadDiv();
setEditor('editor', '570');
2023-01-06 05:00:33 +00:00
$("#MajorEditModal").modal('show');
2023-01-05 06:26:05 +00:00
},
error:function(){
}
});
}
2023-01-06 05:00:33 +00:00
function getViewModal(majorKey){
2023-01-05 06:26:05 +00:00
$.ajax({
url: '/ivsgt/majorViewModal',
2023-01-06 05:00:33 +00:00
data: {majorKey: majorKey},
2023-01-05 06:26:05 +00:00
type: 'GET',
dataType:"html",
success: function(html){
$("#viewContent").empty().append(html)
2023-01-06 05:00:33 +00:00
$("#MajorViewModal").modal('show');
2023-01-05 06:26:05 +00:00
},
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"));
})
2023-01-06 05:00:33 +00:00
formData.append('contentInfo', CrossEditor.GetBodyValue());
2023-01-05 06:26:05 +00:00
$.ajax({
type : 'POST',
data : formData,
url : "/ivsgt/saveContent",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
2023-01-06 05:00:33 +00:00
$("#MajorEditModal").modal('hide');
getViewModal(result);
2023-01-05 06:26:05 +00:00
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
}
}
function contentCheck(formId){
let flag = true;
2023-01-06 05:00:33 +00:00
if(!$("#contentTitle").val()){
2023-01-05 06:26:05 +00:00
alert("제목을 입력해주세요.")
flag = false;
}
2023-01-06 05:00:33 +00:00
2023-01-05 06:26:05 +00:00
flag = fileCheck(flag, files);
return flag;
}
function commentFormReset(){
const commentForm = $("#commentForm");
commentForm[0].reset();
$("#childFormRemoveBtn").hide();
$("#parentComment").val('');
$("#commentFormHome").append(commentForm)
}