$(document).on('click', '#icaAddBtn', function () {
getIcaEditModal(null);
});
$(document).on('click', '#saveIcaBtn', function (){
saveInternationalCrimeArrest('N')
});
$(document).on('click', '#saveTempBtn', function (){
saveInternationalCrimeArrest('Y')
});
$(document).on('change', '#crimeForm', function (){
$('#crimeFormDiv').next().remove();
if ($(this).val() != 'CMF001') {
$('#crimeFormDiv').after('+ ');
} else {
$("#spiDiv").children('.dynamic').remove();
}
});
$(document).on('click', '#spiAddBtn', function (){
let sex = '';
commonCode.SEX.forEach(function (item){
sex += '' + item.itemValue +' ';
});
let age = '';
commonCode.AGE.forEach(function (item){
age += '' + item.itemValue +' ';
})
let country = '';
commonCode.NNY.forEach(function (item){
country += '' + item.itemValue +' ';
})
$("#spiDiv").append(
'
'
+ '
성별 '
+ '
'
+ ''
+ sex
+ ' '
+ '
'
+ '
나이 '
+ '
'
+ ''
+ age
+ ' '
+ '
'
+ '
국적 '
+ '
'
+ ''
+ country
+ '기타 '
+ ' '
+ '
'
+ '
- '
+ '
'
);
});
$(document).on('change', '.country', function (){
if ($(this).val() == 'etc') {
$(this).parent().after(
''
+ ' '
+ '
'
);
} else {
$(this).parent().next().remove();
}
});
$(document).on('change', '#processResult', function (){
if ($(this).val() == 'etc') {
$(this).parent().after(
''
+ ' '
+ '
'
);
} else {
$(this).parent().next().remove();
}
});
$(document).on('click', '#spiCancelBtn', function (){
$(this).parent().remove();
});
$(document).on('change', '#crimeType', function (){
$('#smugglingAmountDiv').children().remove();
$('#crimeNameDiv').children().remove();
$('#arrestAreaDiv').remove();
let smugglingAmount = '';
commonCode.SG.forEach(function (item){
smugglingAmount += '' + item.itemValue +' ';
})
if ($(this).val() == 'CTH002') {
makeArrestAreaDiv('장소');
$('#smugglingAmountDiv').append(
'밀수입출 품목 '
+ ''
+ ''
+ ' '
+ smugglingAmount
+ '기타 '
+ ' '
+ '
'
+ '밀수가액 '
+ ''
+ ' '
+ '
'
+ '단속 인원(경찰관) '
+ ''
+ ' '
+ '
'
);
} else {
$("#crimeNameDiv").append(
'죄명 '
+ ''
+ ' '
+ '
'
);
}
});
$(document).on('change', '#violationType', function (){
$('#spiInfoDiv').remove();
$('#arrestAreaDiv').remove();
$('#meansDiv').remove();
$('.entryVisa').remove();
$('#violationAmountDiv').remove();
if ($(this).val() == 'VLT001') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('밀입국');
makeMeansDiv('밀입국');
makePurposeDiv('밀입국');
makeDestinationDiv('밀입국 출발지(국가)');
}
if ($(this).val() == 'VLT002') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('도외이탈');
makeMeansDiv('도외이탈');
makePurposeDiv('도외이탈');
}
if ($(this).val() == 'VLT003') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('밀출국');
makeMeansDiv('밀출국');
makePurposeDiv('밀출국');
makeDestinationDiv('밀출국 행선지(도착예정지)');
}
if ($(this).val() == 'VLT004') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('밀항');
makeMeansDiv('밀항');
makePurposeDiv('밀항');
makeDestinationDiv('밀항 행선지(도착예정지)');
}
if ($(this).val() == 'VLT005') {
makeSpiInfoDiv('불법체류 및 취업');
makeEntryVisaDiv();
}
if ($(this).val() == 'VLT301') {
makeViolationAmountDiv();
}
});
$(document).on('change', '#smugglingAmount', function (){
if ($(this).val() == 'etc') {
$(this).parent().append(
''
+ ' '
+ '
'
);
} else {
$(this).next().remove();
}
});
$(document).on('change', '#means', function (){
if ($(this).val() == 'etc') {
$(this).parent().append(
''
+ ' '
+ '
'
);
} else {
$(this).next().remove();
}
});
$(document).on('change', '#purpose', function (){
if ($(this).val() == 'etc') {
$(this).parent().append(
''
+ ' '
+ '
'
);
} else {
$(this).next().remove();
}
});
$(function(){
$("#datePickerDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
});
function makeEntryVisaDiv() {
$('#spiWrapper').prepend(
'입국비자 '
+ ''
+ ' '
+ '
'
);
}
function makeSpiInfoDiv(name) {
$('#spiParentDiv').after(
''
+ '
' + name + ' '
+ '
'
+ '
'
+ '
체류 자격 '
+ '
'
+ ' '
+ '
'
+ '
체류기간 만료일 '
+ '
'
+ ' '
+ '
'
+ '
'
+ '
'
+ '
'
);
$("#stayQualificationDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
}
function makeSeaAreaDiv(name) {
let seaArea = '';
commonCode.SAA.forEach(function (item){
seaArea += '' + item.itemValue +' ';
})
$('#arrestAreaDiv').append(
'' + name + '시도 해역(해안) '
+ ''
+ ''
+ ' '
+ seaArea
+ ' '
+ '
'
);
}
function makeArrestAreaDiv(name) {
let arrestArea = '';
commonCode.SAA.forEach(function (item){
arrestArea += '' + item.itemValue +' ';
})
$('#spiParentDiv').after(
''
+ '
검거' + name + ' '
+ '
'
+ ' '
+ '
'
+ '
'
);
}
function makeMeansDiv(name, code) {
let means = '';
if (code == 'VLT001') {
commonCode.MS1.forEach(function (item){
means += '' + item.itemValue +' ';
})
} else {
commonCode.MS2.forEach(function (item){
means += '' + item.itemValue +' ';
})
}
$('#spiParentDiv').after(
''
+ '
' + name + ' 수단(방법) '
+ '
'
+ ''
+ ' '
+ means
+ '기타 '
+ ' '
+ '
'
+ '
'
);
}
function makePurposeDiv(name) {
let purpose = "";
commonCode.PPS.forEach(function (item){
purpose += '' + item.itemValue +' ';
})
$('#meansDiv').append(
'' + name + ' 목적(사유) '
+ ''
+ ''
+ ' '
+ purpose
+ '기타 '
+ ' '
+ '
'
);
}
function makeDestinationDiv(name) {
$('#meansDiv').append(
'' + name + ' '
+ ''
+ ' '
+ '
'
);
}
function makeViolationAmountDiv() {
$('#spiParentDiv').after(
''
+ '
표시위반 금액(만원) '
+ '
'
+ ' '
+ '
'
+ '
'
);
}
function getIcaViewModal(ivsgtKey){
$.ajax({
url: '/faStatistics/internationalCrimeArrest/internationalCrimeArrestViewModal',
data: {ivsgtKey: ivsgtKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#ivsgtViewBody").empty().append(html)
$("#ivsgtViewModal").modal('show');
},
error:function(){
}
});
}
function getIcaEditModal(icaKey){
$.ajax({
url: '/faStatistics/internationalCrimeArrest/internationalCrimeArrestEditModal',
data: {
icaKey: icaKey
},
type: 'GET',
dataType:"html",
success: function(html){
$("#icaEditModalContent").empty().append(html)
$("#icaEditModal").modal('show');
$("#crimeAwarenessDtDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
$("#caseSentDtDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
$("[name='caseOverview']").summernote({
lang:'ko-KR',
height: 120,
disableDragAndDrop: true,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
]
});
},
error:function(){
}
});
}
function saveInternationalCrimeArrest(contentState){
if(contentCheck()){
if(confirm("저장하시겠습니까?")){
$("#contentStatus").val(contentState);
contentFade("in");
const formData = new FormData($("#icaEditForm")[0]);
let spiList = [];
$(".spi-list").each(function (){
spiList.push({
sex: $(this).find('select[name="sex"]').val(),
age: $(this).find('select[name="age"]').val(),
country: $(this).find('select[name="country"]').val()
});
});
for (let i=0; i < spiList.length; i++) {
formData.append(`suspectPersonInfoList[${i}].sex`, spiList[i].sex);
formData.append(`suspectPersonInfoList[${i}].age`, spiList[i].age);
formData.append(`suspectPersonInfoList[${i}].country`, spiList[i].country);
}
/*
// formData 출력
for (const [key,value] of formData.entries()) {
console.log(`${key}: ${value}`);
}
*/
$.ajax({
type : 'POST',
data : formData,
url : "/faStatistics/internationalCrimeArrest/saveInternationalCrimeArrest",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
$("#icaEditModal").modal('hide');
// getIcaViewModal(result);
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
}
}
function contentCheck(){
let flag = true;
if(!$('select[name="organ"]').val()){
alert("지방청을 선택해주세요.")
flag = false;
}
return flag;
}