$(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', '#planTab', function (){
location.href = "/affairPlan/planMgt";
})
$(document).on('click', '#stayTab', function (){
location.href = "/affairPlan/stayPage";
})
$(document).on('click', '#commitTab', function (){
location.href = "/affairPlan/commitPage";
})
$(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', '#planAddBtn', function (){
$("#planDiv").append("")
})
$(document).on('click', '#detailPlanAddBtn', function (){
const detailPlanDiv = $("#detailPlanDiv");
detailPlanDiv.append("");
/*const lastAppendTextarea = detailPlanDiv.children()[detailPlanDiv.children().length-1];
$(lastAppendTextarea).summernote({
lang:'ko-KR',
height: 120,
disableDragAndDrop: true,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
]
});*/
})
$(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("저장되었습니다")
// getPlanViewModal(result);
contentFade("out");
location.reload();
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.");
contentFade("out");
}
})
}
})
$(document).on('click', '#printBtn', function (){
$.ajax({
url: '/affairPlan/planBoardJson',
type: 'GET',
data: {planKey: $(this).attr('data-plankey')},
dataType:"json",
success: function(data){
const plan = {};
plan.contentTitle = data.contentTitle;
plan.planDt = data.planDt;
plan.wrtOrgan = data.wrtOrgan;
plan.wrtPart = data.wrtPart;
plan.wrtUserGrd = data.wrtUserGrd;
plan.wrtUserNm = data.wrtUserNm;
for(let i=0; i