FAISP/src/main/resources/static/js/counterIntelligence/ciaManageCompany.js

120 lines
3.1 KiB
JavaScript

$(function(){
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
})
$(document).on('click', '#addBtn', function (){
getCiaManageCompanyEditModal(null);
})
function getCiaManageCompanyEditModal(ciKey){
$.ajax({
url: '/counterIntelligence/ciaManageCompanyEditModal',
data: {ciKey: ciKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#ciaManageCompanyEditModalContent").empty().append(html)
setUploadDiv();
$("#ciaManageCompanyEditModal").modal('show');
},
error:function(){
}
});
}
$(document).on('click', '#saveBtn', function (){
if(confirm("저장하시겠습니까?")){
save('DST007');
}
})
$(document).on('click', '#saveTempBtn', function (){
if(confirm("임시저장 하시겠습니까?")){
save('DST001');
}
})
function save(contentStatus){
const formData = new FormData($("#ciaManageCompanyEditForm")[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);
$.ajax({
type : 'POST',
data : formData,
url : "/counterIntelligence/saveCiActivity",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
location.reload();
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
$(document).on('click', '.mciTr', function (){
getCiaManageCompanyViewModal($(this).find(".ciKey").val());
})
function getCiaManageCompanyViewModal(ciKey){
$.ajax({
url: '/counterIntelligence/ciaManageCompanyViewModal',
data: {ciKey: ciKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#ciaManageCompanyViewModalBody").empty().append(html)
$("#ciaManageCompanyViewModal").modal('show');
},
error:function(){
}
});
}
$(document).on('click', '#editBtn', function (){
$("#ciaManageCompanyViewModal").modal('hide');
getCiaManageCompanyEditModal($(this).attr("data-cikey"));
})
$(document).on('click', '#excelDown', function (){
exportExcel("해양산업보호 관리업체 현황","mciTb");
})
$(document).on('click', '#deleteBtn', function (){
const ciKey = $(this).attr("data-cikey");
if(confirm("삭제 하시겠습니까?")){
$.ajax({
type : 'POST',
url : "/counterIntelligence/deleteCounterIntelligenceActivity",
data : JSON.stringify({ciKey:ciKey}),
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("삭제처리에 실패하였습니다");
}
})
}
})