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

146 lines
3.5 KiB
JavaScript
Raw Normal View History

2022-12-29 09:16:45 +00:00
$(document).on('click', '#addCiWorkBtn', function (){
getCiWorkEditModal(null);
})
$(document).on('click', '#arrestType1', function (){
getArrestType2Option(this.value);
})
$(document).on('click', '#saveTempBtn,#saveCiWorkBtn', function(){
saveCiWork($(this).attr("data-status"));
})
2022-12-29 09:16:45 +00:00
function getCiWorkEditModal(ciwKey){
$.ajax({
url: '/counterIntelligence/ciWorkEditModal',
data: {ciwKey: ciwKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#ciWorkEditModalContent").empty().append(html)
$(".dateSelector").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
setUploadDiv();
setEditor('editor', '400');
$("#ciWorkEditModal").modal('show');
},
error:function(){
}
});
}
function getCiwViewModal(ciwKey){
$.ajax({
url: '/counterIntelligence/ciWorkViewModal',
data: {ciwKey: ciwKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#ciWorkViewModalBody").empty().append(html)
$("#ciWorkViewModal").modal('show');
},
error:function(){
}
});
}
function saveCiWork(status){
if(confirm("저장하시겠습니까?")){
let flag = true;
if(status === "DST007"){
flag = contentCheck();
}
if(flag){
const ciWorkEditForm = $("#ciWorkEditForm");
ciWorkEditForm.find("#status").val(status);
const formData = new FormData(ciWorkEditForm[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('content', CrossEditor.GetBodyValue());
$.ajax({
type : 'POST',
data : formData,
url : "/counterIntelligence/saveCiWork",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
$("#affairEditModal").modal('hide');
getCiwViewModal(result);
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
}
}
function contentCheck(){
if(!$("#workStartDate").val()){
alert("착수일을 입력해주세요.")
return false;
}
if(!$("#workEndDate").val()){
alert("종결일을 입력해주세요.")
return false;
}
if(!$("#reRatingDate1").val()){
alert("1차재평가를 입력해주세요.")
return false;
}
if(!$("#reRatingDate2").val()){
alert("2차재평가를 입력해주세요.")
return false;
}
if(!$("#workRating").val()){
alert("등급을 선택해주세요.")
return false;
}
if(!$("#arrestType1").val()){
alert("검거유형1을 선택해주세요.")
return false;
}
if(!$("#arrestType2").val()){
alert("검거유형2를 선택해주세요.")
return false;
}
if(!$("#title").val()){
alert("공작명을 입력해주세요.")
return false;
}
if(!$("#summaryInfo").val()){
alert("사건개요를 입력해주세요.")
return false;
}
return true;
}
2022-12-29 09:16:45 +00:00
function getArrestType2Option(categoryCd){
$.ajax({
url: '/selectBoxOptions',
data: {categoryCd: categoryCd},
type: 'GET',
dataType:"html",
success: function(html){
const arrestType2 = $("#arrestType2");
arrestType2.empty().append(html);
},
error:function(){
}
});
}