267 lines
7.4 KiB
JavaScript
267 lines
7.4 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', '#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("<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>");
|
|
/*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<data.apprvList.length; i++){
|
|
const apprv = data.apprvList[i];
|
|
switch (apprv.state) {
|
|
case "DST004":
|
|
plan.sectionApprv = apprv.userNm
|
|
break;
|
|
case "DST006":
|
|
plan.headApprv = apprv.userNm
|
|
break;
|
|
}
|
|
}
|
|
if(plan.sectionApprv === plan.headApprv){
|
|
plan.sectionApprv = "전결"
|
|
}
|
|
const planInfoSummery = [];
|
|
const planInfoDetail = [];
|
|
for(let i=0; i<data.mainInfoList.length; i++){
|
|
const info = data.mainInfoList[i];
|
|
if(info.planType === "S"){
|
|
planInfoSummery.push({planInfo: info.planInfo})
|
|
}else if(info.planType === "D"){
|
|
planInfoDetail.push({planInfo: info.planInfo})
|
|
}
|
|
}
|
|
plan.planInfoSummery = planInfoSummery;
|
|
plan.planInfoDetail = planInfoDetail;
|
|
const fileList = [];
|
|
for(let i=0; i<data.fileList.length; i++){
|
|
fileList.push({origNm: data.fileList[i].origNm+"."+data.fileList[i].fileExtn});
|
|
}
|
|
plan.fileList = fileList;
|
|
|
|
var url = $("#printUrl").attr("data-printurl")+"/singlePrint.jsp";
|
|
var title = "계획 보고서 인쇄";
|
|
var status = "width=900px,height=800px,scrollbars=yes";
|
|
window.open("", title, status);
|
|
const form = $("#printForm")[0];
|
|
form.target = title;
|
|
form.action = url;
|
|
form.crfName.value = "planBoard";
|
|
form.json.value = JSON.stringify(plan);
|
|
form.method = "post";
|
|
form.submit();
|
|
},
|
|
error:function(e){
|
|
ajaxErrorAction(e);
|
|
}
|
|
});
|
|
})
|
|
|
|
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;
|
|
} |