FAISP/src/main/resources/static/js/faStatistics/asfCov.js

219 lines
5.7 KiB
JavaScript

$("#jqueryBtn").click(function(){
$(".quiz-text").text("Javascript");
$(".quiz-text").css('color', 'blue');
});
$(document).on('click', '#saveBtn', function (){
if(confirm("저장하시겠습니까?")){
if($('#contentTitle').val() == ''){
alert("제목을 입력해주세요.");
$('#contentTitle').focus();
return false;
}
if($('#majorType').val() == ''){
alert("종류를 선택해주세요.");
$('#majorType').focus();
return false;
}
saveContent('DST007');
}
})
$(document).on('click', '#saveTempBtn', function (){
if(confirm("임시저장 하시겠습니까?")){
if($('#contentTitle').val() == ''){
alert("제목을 입력해주세요.");
$('#contentTitle').focus();
return false;
}
if($('#majorType').val() == ''){
alert("종류를 선택해주세요.");
$('#majorType').focus();
return false;
}
saveContent('DST001');
}
})
$(document).on('click', '#addAsfCovBtn', function (){
getEditModal(null)
})
$(document).on('click', '.tr', function (){
$(".trChkBox").prop("checked", false);
$(this).find(".trChkBox").prop("checked", true);
getViewModal(Number($(this).find(".asfCovKey").val()));
})
// $(document).on('click', '#saveBtn', function (){
// saveContent("MajorEditForm")
// })
$(document).on('click', '#editBtn', function (){
$("#asfCovViewModal").modal('hide')
getEditModal($(this).attr("data-asfCovKey"));
})
$(function(){
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
})
$(document).on('click', '#deleteMajorBtn', function (){
const asfCovKey = $('input[name=asfCovKey]').val();
console.log(asfCovKey);
if(confirm("삭제하시겠습니까?")){
//contentFade("in");
$.ajax({
type : 'POST',
url : "/ivsgt/deleteContent",
data : JSON.stringify({asfCovKey:asfCovKey}),
contentType: 'application/json',
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(data) {
alert("삭제 처리되었습니다.");
//contentFade("out");
location.reload();
},
error : function(xhr, status) {
alert("삭제 처리에 실패하였습니다");
//contentFade("out");
}
})
}
})
function getEditModal(cdsKey){
$.ajax({
url: '/faStatistics/asfCovEditModal',
data: {cdsKey: cdsKey},
type: 'GET',
dataType:"html",
success: function(html){
const crackdownPolice = $("#crackdownPolice").val()
if(crackdownPolice){
getCrackdownBoatOption(crackdownPolice)
}
$("#asfCovEditModalContent").empty().append(html);
$("#asfCovEditModal").modal('show');
},
error:function(e){
ajaxErrorAction(e);
}
});
}
function getViewModal(asfCovKey){
$.ajax({
url: '/faStatistics/asfCovViewModal',
data: {asfCovKey: asfCovKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#asfCovViewModalContent").empty().append(html)
$("#asfCovViewModal").modal('show');
},
error:function(e){
ajaxErrorAction(e);
}
});
}
function saveContent(contentStatus){
const formData = new FormData($("#asfCovEditForm")[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('contentStatus', contentStatus);
formData.append('contentInfo', CrossEditor.GetBodyValue());
$.ajax({
type : 'POST',
data : formData,
url : "/ivsgt/saveContent",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
location.reload();
},
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)
}
$(document).on('click', '#asfCovDownExcel', function (){
exportExcel('ASF 및 코로나19 관련 조치현황', 'asfCovTable');
});
$(document).on('click', '#caseNumBtn', function (){
searchModalSubmit(1);
$("#asfCovSubModal").modal('show');
})
$(document).on('click', '#getCrackdownBtn', function (){
getEditModal($(".crackdownChkbox:checked").parents(".crackdownTr").attr("data-key"));
$("#asfCovSubModal").modal('hide');
})
$(function(){
const searchFormBoat = $("#searchFormBoat")
if(searchFormBoat.val()!==""){
searchFormBoat.find("."+$("#searchFormPolice").val()).show();
searchFormBoat.removeAttr("disabled");
}
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
});