205 lines
5.5 KiB
JavaScript
205 lines
5.5 KiB
JavaScript
|
|
$(function(){
|
|
if(location.search.includes("refDocKey")){
|
|
const params = location.search.split('&');
|
|
$.each(params, function (idx, param){
|
|
if(param.includes("refDocKey")){
|
|
const key = param.slice(param.indexOf("=")+1, param.length);
|
|
getPlanViewModal(key);
|
|
}
|
|
})
|
|
}
|
|
$("#dateSelectorDiv").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko",
|
|
autoclose: true
|
|
});
|
|
})
|
|
|
|
$(document).on('click', '.pageTab', function (){
|
|
location.href = "/affairPlan/planMgt/"+this.id;
|
|
})
|
|
|
|
$(document).on('click', '#addPlanBtn', function (){
|
|
getPlanEditModal(null)
|
|
})
|
|
$(document).on('click', '#editPlanBtn', function (){
|
|
$("#planViewModal").modal('hide');
|
|
getPlanEditModal(Number($("#planViewBody").find("[name='planKey']").val()));
|
|
})
|
|
|
|
$(document).on('click', '#deletePlanBtn', function (){
|
|
if(confirm("삭제하시겠습니까?\n되돌릴 수 없습니다.")){
|
|
contentFade("in");
|
|
$.ajax({
|
|
type : 'POST',
|
|
data : JSON.stringify({planKey: $("#viewModalPlanKey").val()}),
|
|
url : "/affairPlan/deletePlan",
|
|
contentType: 'application/json',
|
|
beforeSend: function (xhr){
|
|
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
},
|
|
success : function(result) {
|
|
alert("삭제되었습니다.");
|
|
location.reload();
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("삭제를 실패하였습니다.")
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '#planAddBtn', function (){
|
|
$("#planDiv").append("<input type='text' class='form-control' name='planInfos'>")
|
|
})
|
|
|
|
$(document).on('click', '#detailPlanAddBtn', function (){
|
|
const detailPlanDiv = $("#detailPlanDiv");
|
|
detailPlanDiv.append("<textarea type='text' class='form-control' name='detailPlanInfos'></textarea>");
|
|
})
|
|
|
|
$(document).on('click', '#savePlanBtn', function (){
|
|
savePlan('DST002')
|
|
})
|
|
|
|
$(document).on('click', '#saveTempBtn', function (){
|
|
savePlan('DST001')
|
|
})
|
|
|
|
$(document).on('click', '.planTr', function (){
|
|
const chkBox = $(this).find(".rowChkBox");
|
|
if(chkBox.length>0){
|
|
$(".trChkBox").prop("checked", false);
|
|
chkBox[0].checked = !chkBox[0].checked;
|
|
}
|
|
getPlanViewModal(Number($(this).find(".planKey").val()));
|
|
})
|
|
|
|
$(document).on('click', '.apprvBtn', function (){
|
|
$("#apprvFormPlanKey").val($("#viewModalPlanKey").val());
|
|
$("#viewModalApprvValue").val($(this).attr("data-planstate"));
|
|
if(confirm($(this).val()+"하시겠습니까?")){
|
|
const formData = new FormData($("#apprvForm")[0]);
|
|
contentFade("in")
|
|
$.ajax({
|
|
type : 'POST',
|
|
data : formData,
|
|
url : "/affairPlan/planStateChange",
|
|
processData: false,
|
|
contentType: false,
|
|
beforeSend: function (xhr){
|
|
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
},
|
|
success : function(result) {
|
|
alert("저장되었습니다")
|
|
contentFade("out");
|
|
location.reload();
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("저장에 실패하였습니다.");
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
function getPlanViewModal(planKey){
|
|
$.ajax({
|
|
url: '/affairPlan/planViewModal',
|
|
data: {planKey: planKey},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#planViewBody").empty().append(html)
|
|
$("#planViewModal").modal('show');
|
|
},
|
|
error:function(e){
|
|
ajaxErrorAction(e);
|
|
}
|
|
});
|
|
}
|
|
|
|
function getPlanEditModal(planKey){
|
|
$.ajax({
|
|
url: '/affairPlan/planEditModal',
|
|
data: {planKey: planKey},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#planEditModalContent").empty().append(html)
|
|
$("#planEditModal").modal('show');
|
|
$("#planDt").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko",
|
|
autoclose: true
|
|
});
|
|
/*$("[name='detailPlanInfos']").summernote({
|
|
lang:'ko-KR',
|
|
height: 120,
|
|
disableDragAndDrop: true,
|
|
toolbar: [
|
|
['style', ['style']],
|
|
['font', ['bold', 'underline', 'clear']],
|
|
['color', ['color']],
|
|
['para', ['ul', 'ol', 'paragraph']],
|
|
['table', ['table']]
|
|
]
|
|
});*/
|
|
setUploadDiv();
|
|
},
|
|
error:function(e){
|
|
ajaxErrorAction(e);
|
|
}
|
|
});
|
|
}
|
|
function savePlan(planState){
|
|
if(contentCheck()){
|
|
if(confirm("저장하시겠습니까?")){
|
|
$("#planState").val(planState);
|
|
contentFade("in");
|
|
const formData = new FormData($("#planEditForm")[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 : "/affairPlan/savePlan",
|
|
processData: false,
|
|
contentType: false,
|
|
success : function(result) {
|
|
alert("저장되었습니다.");
|
|
contentFade("out");
|
|
$("#planEditModal").modal('hide');
|
|
//getPlanViewModal(result);
|
|
location.reload();
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("저장에 실패하였습니다.")
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function contentCheck(){
|
|
let flag = true;
|
|
if(!$("#contentTitle").val()){
|
|
alert("제목을 입력해주세요.")
|
|
flag = false;
|
|
}
|
|
if(!$("#planDt").val()){
|
|
alert("시행일자를 입력해주세요.")
|
|
flag = false;
|
|
}
|
|
flag = fileCheck(flag, files);
|
|
return flag;
|
|
} |