129 lines
3.3 KiB
JavaScript
129 lines
3.3 KiB
JavaScript
let files = [];
|
|
|
|
$(function(){
|
|
$("#dateSelectorDiv").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko"
|
|
});
|
|
})
|
|
$(document).on('click', '#affairTab', function (){
|
|
location.href = "/affair/affairMgt";
|
|
})
|
|
$(document).on('click', '#stayTab', function (){
|
|
location.href = "/affair/stayPage";
|
|
})
|
|
$(document).on('click', '#commitTab', function (){
|
|
location.href = "/affair/commitPage";
|
|
})
|
|
$(document).on('click', '.affairTr', function (){
|
|
$(".trChkBox").prop("checked", false);
|
|
$(this).find(".trChkBox").prop("checked", true);
|
|
getAffairViewModal(Number($(this).find(".affairKey").val()));
|
|
})
|
|
$(document).on('click', '#addAffairBtn', function (){
|
|
getAffairEditModal(null)
|
|
})
|
|
$(document).on('click', '#editAffairBtn', function (){
|
|
$("#affairViewModal").modal('hide');
|
|
getAffairEditModal(Number($("#affairViewBody").find("[name='affairKey']").val()));
|
|
})
|
|
|
|
$(document).on('click', '#saveAffairBtn', function (){
|
|
saveAffair('DST002')
|
|
})
|
|
$(document).on('click', '#saveTempBtn', function (){
|
|
saveAffair('DST001')
|
|
})
|
|
|
|
function getAffairViewModal(affairKey){
|
|
$.ajax({
|
|
url: '/affair/affairViewModal',
|
|
data: {affairKey: affairKey},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#affairViewBody").empty().append(html)
|
|
$("#affairViewModal").modal('show');
|
|
},
|
|
error:function(){
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
function getAffairEditModal(affairKey){
|
|
$.ajax({
|
|
url: '/affair/affairEditModal',
|
|
data: {affairKey: affairKey},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#affairEditModalContent").empty().append(html)
|
|
$("#affairEditModal").modal('show');
|
|
$("#reportDt").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko"
|
|
});
|
|
$("#content").summernote({
|
|
lang:'ko-KR',
|
|
height: 300,
|
|
disableDragAndDrop: true,
|
|
toolbar: [
|
|
['style', ['style']],
|
|
['font', ['bold', 'underline', 'clear']],
|
|
['color', ['color']],
|
|
['para', ['ul', 'ol', 'paragraph']],
|
|
['table', ['table']]
|
|
]
|
|
});
|
|
setUploadDiv();
|
|
},
|
|
error:function(){
|
|
|
|
}
|
|
});
|
|
}
|
|
function saveAffair(affairStatus){
|
|
if(contentCheck()){
|
|
if(confirm("저장하시겠습니까?")){
|
|
$("#affairStatus").val(affairStatus);
|
|
contentFade("in");
|
|
const formData = new FormData($("#affairEditForm")[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"));
|
|
})
|
|
$.ajax({
|
|
type : 'POST',
|
|
data : formData,
|
|
url : "/affair/saveAffair",
|
|
processData: false,
|
|
contentType: false,
|
|
success : function(result) {
|
|
alert("저장되었습니다.");
|
|
contentFade("out");
|
|
$("#affairEditModal").modal('hide');
|
|
getAffairViewModal(result);
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("저장에 실패하였습니다.")
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function contentCheck(){
|
|
let flag = true;
|
|
if(!$("#title").val()){
|
|
alert("제목을 입력해주세요.")
|
|
flag = false;
|
|
}
|
|
flag = fileCheck(flag, files);
|
|
return flag;
|
|
} |