견문목록 일괄결재 기능 추가.

강석 최 2022-10-04 18:41:46 +09:00
parent dc091550bc
commit c2da2f1b47
6 changed files with 181 additions and 79 deletions

View File

@ -14,6 +14,7 @@ import org.springframework.web.servlet.ModelAndView;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -96,6 +97,7 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
break; break;
} }
} }
mav.addObject("userOrgan", loginUser.getOgCd());
mav.addObject("accessAuth", accessAuth); mav.addObject("accessAuth", accessAuth);
mav.addObject("apprvAuth", apprvAuth); mav.addObject("apprvAuth", apprvAuth);
affairBoard.setQueryInfo(); affairBoard.setQueryInfo();
@ -188,6 +190,7 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
} }
mav.addObject("affair", affairBoard); mav.addObject("affair", affairBoard);
mav.addObject("userSeq",loginUser.getUserSeq()); mav.addObject("userSeq",loginUser.getUserSeq());
mav.addObject("userOrgan", loginUser.getOgCd());
//메뉴권한 확인 //메뉴권한 확인
mav.addObject("accessAuth", authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/affair/affairMgt").get(0).getAccessAuth()); mav.addObject("accessAuth", authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/affair/affairMgt").get(0).getAccessAuth());
String apprvAuth = authMgtService.selectApprovalConfigList(loginUser.getUserSeq(), "/affair/affairMgt").get(0).getApprovalAuth(); String apprvAuth = authMgtService.selectApprovalConfigList(loginUser.getUserSeq(), "/affair/affairMgt").get(0).getApprovalAuth();
@ -207,7 +210,8 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
} }
@PostMapping("/affairStateChange") @PostMapping("/affairStateChange")
public Integer affairStateChange(@AuthenticationPrincipal UserInfo loginUser, AffairRating rating){ @ResponseBody
return affairService.affairStateChange(loginUser, rating); public Integer affairStateChange(@AuthenticationPrincipal UserInfo loginUser, @RequestBody List<AffairRating> ratingList){
return affairService.affairStateChange(loginUser, ratingList);
} }
} }

View File

@ -119,8 +119,9 @@ public class AffairService extends BaseService { // 견문보고
} }
@Transactional @Transactional
public Integer affairStateChange(UserInfo loginUser, AffairRating rating) { public Integer affairStateChange(UserInfo loginUser, List<AffairRating> ratingList) {
AffairRating savedRating = affairRatingRepository.findById(new AffairRating.AffairRatingId(rating.getAffairKey(), rating.getRatingOrgan())).orElse(null); for(AffairRating rating : ratingList){
AffairRating savedRating = affairRatingRepository.findById(new AffairRating.AffairRatingId(rating.getAffairKey(), loginUser.getOgCd())).orElse(null);
if(savedRating != null){ if(savedRating != null){
if(rating.getHeadApprv() == null){ if(rating.getHeadApprv() == null){
savedRating.setSectionNm(loginUser.getUserNm()); savedRating.setSectionNm(loginUser.getUserNm());
@ -148,7 +149,8 @@ public class AffairService extends BaseService { // 견문보고
} }
affairRatingRepository.save(savedRating); affairRatingRepository.save(savedRating);
} }
return rating.getAffairKey(); }
return ratingList.size()>1?0:ratingList.get(0).getAffairKey();
} }
public FileInfo selectAffairFile(Integer parentKey, Integer fileSeq) { public FileInfo selectAffairFile(Integer parentKey, Integer fileSeq) {

View File

@ -60,6 +60,10 @@
</sql> </sql>
<select id="selectAffairBoardList" resultType="AffairBoard" parameterType="AffairBoard"> <select id="selectAffairBoardList" resultType="AffairBoard" parameterType="AffairBoard">
select a.affair_key, select a.affair_key,
a.affair_type1,
a.affair_type2,
a.affair_type3,
a.affair_type4,
a.title, a.title,
a.wrt_organ, a.wrt_organ,
a.wrt_part, a.wrt_part,

View File

@ -15,10 +15,13 @@ $(document).on('click', '#stayTab', function (){
$(document).on('click', '#commitTab', function (){ $(document).on('click', '#commitTab', function (){
location.href = "/affair/commitPage"; location.href = "/affair/commitPage";
}) })
$(document).on('click', '.affairTr', function (){ $(document).on('click', '.affairTr', function (event){
const target = event.target;
if(!(target.className === "apprvTd" || $(target).parents(".apprvTd").length>0)){
$(".trChkBox").prop("checked", false); $(".trChkBox").prop("checked", false);
$(this).find(".trChkBox").prop("checked", true); $(this).find(".trChkBox").prop("checked", true);
getAffairViewModal(Number($(this).find(".affairKey").val())); getAffairViewModal(Number($(this).find(".affairKey").val()));
}
}) })
$(document).on('click', '#addAffairBtn', function (){ $(document).on('click', '#addAffairBtn', function (){
getAffairEditModal(null) getAffairEditModal(null)
@ -62,29 +65,63 @@ $(document).on('click', '.apprvBtn', function (){
if(confirm($(this).val()+"하시겠습니까?")){ if(confirm($(this).val()+"하시겠습니까?")){
const apprvType = $(this).attr("data-apprvtype"); const apprvType = $(this).attr("data-apprvtype");
$((apprvType === "section"?"#sectionApprv":"#headApprv")).val(affairState) $((apprvType === "section"?"#sectionApprv":"#headApprv")).val(affairState)
$("#apprvFormRatingOrgan").val($(".ratingOrganCd")[0].value);
const formData = new FormData($("#apprvForm")[0]); const formData = new FormData($("#apprvForm")[0]);
contentFade("in") const ratingList = [];
$.ajax({ const apprv = {}
type : 'POST', for (let data of formData.entries()) {
data : formData, if(data[0] !== undefined){
url : "/affair/affairStateChange", apprv[data[0]] = data[1];
processData: false, }
contentType: false, }
beforeSend: function (xhr){ ratingList.push(apprv);
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); affairStateChange(ratingList);
}, }
success : function(result) { }
alert("저장되었습니다") })
getAffairViewModal(result);
contentFade("out"); $(document).on('click', '#tableApprvBtn', function (){
}, const ratingList = [];
error : function(xhr, status) { const apprvAuth = $(this).attr("data-apprvauth")
alert("저장에 실패하였습니다."); $.each($(".apprvTd"), function (idx, el) {
contentFade("out"); if (apprvAuth === "APC003" || apprvAuth === "APC004") {
const chkbox = $(el).find(".apprvChkbox:checked")
if(chkbox.length>0){
const affairRating = {};
affairRating["affairKey"] = Number($(el).find(".affairKey").val());
affairRating["sectionApprv"] = chkbox.val();
ratingList.push(affairRating);
}
} else {
const chkbox = $(el).find(".apprvChkbox:checked")
const selectorValue = $(el).find(".ratingSelector").val()
if(chkbox.length>0){
const affairRating = {};
affairRating["affairKey"] = Number($(el).find(".affairKey").val());
affairRating["headApprv"] = chkbox.val();
if(selectorValue !== ""){
affairRating["affairRate"] = selectorValue;
affairRating["organUp"] = $(el).find(".organUpChkBox").prop("checked")?"T":"F";
}
ratingList.push(affairRating);
}
} }
}) })
} affairStateChange(ratingList);
})
$(document).on('change', '.apprvChkbox', function (){
if(this.value === "DST006"){
const apprvTd = $(this).parents(".apprvTd");
apprvTd.find(".ratingSelector").attr("disabled", false)
apprvTd.find(".organUpChkBox").attr("disabled", false)
}else if(this.value === "DST005"){
const apprvTd = $(this).parents(".apprvTd");
const ratingSelector = apprvTd.find(".ratingSelector")
ratingSelector.val("");
ratingSelector.attr("disabled", true)
const organUpChkBox = apprvTd.find(".organUpChkBox")
organUpChkBox.prop("checked", false);
organUpChkBox.attr("disabled", true)
} }
}) })
@ -174,7 +211,31 @@ function saveAffair(affairStatus){
} }
} }
function affairStateChange(ratingList){
contentFade("in")
$.ajax({
type : 'POST',
url : "/affair/affairStateChange",
data : JSON.stringify(ratingList),
contentType: 'application/json',
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(result) {
alert("저장되었습니다")
contentFade("out");
if(result !== 0){
getAffairViewModal(result);
}else{
location.reload()
}
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.");
contentFade("out");
}
})
}
function contentCheck(){ function contentCheck(){
let flag = true; let flag = true;
if(!$("#title").val()){ if(!$("#title").val()){

View File

@ -82,6 +82,10 @@
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th>분야1</th>
<th>분야2</th>
<th>분야3</th>
<th>분야4</th>
<th>제목</th> <th>제목</th>
<th>관서</th> <th>관서</th>
<th>부서</th> <th>부서</th>
@ -89,7 +93,7 @@
<th>작성일시</th> <th>작성일시</th>
<th>첨부파일</th> <th>첨부파일</th>
<th>상태</th> <th>상태</th>
<th:block th:if="${page ne 'main'}"> <th:block th:if="${page ne 'main' and apprvAuth ne null}">
<th>평가</th> <th>평가</th>
<th:block th:if="${page eq 'commit'}"> <th:block th:if="${page eq 'commit'}">
<th>상보</th> <th>상보</th>
@ -101,6 +105,18 @@
<tr class="affairTr" th:each="affair:${affairList}"> <tr class="affairTr" th:each="affair:${affairList}">
<input type="hidden" class="affairKey" th:value="${affair.affairKey}"> <input type="hidden" class="affairKey" th:value="${affair.affairKey}">
<td><input type="checkbox" class="trChkBox"></td> <td><input type="checkbox" class="trChkBox"></td>
<th:block th:each="commonCode:${session.commonCode.get('DC01')}">
<td th:if="${affair.affairType1 eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('DC02')}">
<td th:if="${affair.affairType2 eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('DC03')}">
<td th:if="${affair.affairType3 eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('DC04')}">
<td th:if="${affair.affairType4 eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<td th:text="${affair.title}"></td> <td th:text="${affair.title}"></td>
<th:block th:each="commonCode:${session.commonCode.get('OG')}"> <th:block th:each="commonCode:${session.commonCode.get('OG')}">
<td th:if="${affair.wrtOrgan eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td> <td th:if="${affair.wrtOrgan eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
@ -111,29 +127,46 @@
<td th:text="${affair.wrtUserNm}"></td> <td th:text="${affair.wrtUserNm}"></td>
<td th:text="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd HH:mm')}"></td> <td th:text="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd HH:mm')}"></td>
<td th:text="${affair.fileCnt eq null?'파일 없음':#strings.concat(affair.fileCnt,' 건')}"></td> <td th:text="${affair.fileCnt eq null?'파일 없음':#strings.concat(affair.fileCnt,' 건')}"></td>
<td th:if="${affair.affairStatus eq 'DST001'}">임시저장</td> <th:block th:each="commonCode:${session.commonCode.get('DST')}">
<td th:if="${affair.affairStatus eq 'DST002'}">결재대기</td> <td th:if="${affair.affairStatus eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
<td th:if="${affair.affairStatus eq 'DST003'}">계장반려</td> </th:block>
<td th:if="${affair.affairStatus eq 'DST004'}">계장결재</td>
<td th:if="${affair.affairStatus eq 'DST005'}">부장반려</td>
<td th:if="${affair.affairStatus eq 'DST006'}">부장결재</td>
<th:block th:if="${page eq 'stay'}"> <th:block th:if="${page eq 'stay'}">
<th:block th:if="${apprvAuth eq 'APC004' or apprvAuth eq 'APC003'}"> <th:block th:if="${apprvAuth eq 'APC004' or apprvAuth eq 'APC003'}">
<td> <td class="apprvTd">
<input type="radio" th:id="|apprvChkbox${affair.affairKey}DST004|" th:name="|apprvChkbox${affair.affairKey}|" value="DST004"> <input type="hidden" class="affairKey" th:value="${affair.affairKey}">
<input type="radio" class="apprvChkbox" th:id="|apprvChkbox${affair.affairKey}DST004|" th:name="|apprvChkbox${affair.affairKey}|" value="DST004">
<label th:for="|apprvChkbox${affair.affairKey}DST004|">결재</label> <label th:for="|apprvChkbox${affair.affairKey}DST004|">결재</label>
<input type="radio" th:id="|apprvChkbox${affair.affairKey}DST003|" th:name="|apprvChkbox${affair.affairKey}|" value="DST003"> <input type="radio" class="apprvChkbox" th:id="|apprvChkbox${affair.affairKey}DST003|" th:name="|apprvChkbox${affair.affairKey}|" value="DST003">
<label th:for="|apprvChkbox${affair.affairKey}DST003|">반려</label> <label th:for="|apprvChkbox${affair.affairKey}DST003|">반려</label>
<input type="radio" th:id="|apprvChkbox${affair.affairKey}|" th:name="|apprvChkbox${affair.affairKey}|" value="" checked>
<label th:for="|apprvChkbox${affair.affairKey}|">해제</label>
</td> </td>
</th:block> </th:block>
<th:block th:if="${apprvAuth eq 'APC002' or apprvAuth eq 'APC001'}"> <th:block th:if="${apprvAuth eq 'APC002' or apprvAuth eq 'APC001'}">
<td> <td class="apprvTd">
<select class="form-select form-select-sm"> <input type="hidden" class="affairKey" th:value="${affair.affairKey}">
<option>선택</option> <div class="row justify-content-center">
<div class="col-auto">
<input type="radio" class="apprvChkbox" th:id="|apprvChkbox${affair.affairKey}DST006|" th:name="|apprvChkbox${affair.affairKey}|" value="DST006">
<label th:for="|apprvChkbox${affair.affairKey}DST006|">결재</label>
<input type="radio" class="apprvChkbox" th:id="|apprvChkbox${affair.affairKey}DST005|" th:name="|apprvChkbox${affair.affairKey}|" value="DST005">
<label th:for="|apprvChkbox${affair.affairKey}DST005|">반려</label>
<input type="radio" th:id="|apprvChkbox${affair.affairKey}|" th:name="|apprvChkbox${affair.affairKey}|" value="" checked>
<label th:for="|apprvChkbox${affair.affairKey}|">해제</label>
</div>
<div class="col-auto">
<select class="form-select form-select-sm ratingSelector" disabled>
<option value="">선택</option>
<th:block th:each="ratingCode:${ratingCodeList}"> <th:block th:each="ratingCode:${ratingCodeList}">
<option th:value="${ratingCode.itemCd}" th:text="${ratingCode.itemValue}"></option> <option th:value="${ratingCode.itemCd}" th:text="${ratingCode.itemValue}"></option>
</th:block> </th:block>
</select> </select>
</div>
<div class="col-auto" th:unless="${userOrgan eq 'OG001'}">
<label th:for="|organUp${affair.affairKey}|">상보</label>
<input type="checkbox" class="organUpChkBox" th:id="|organUp${affair.affairKey}|" value="T" disabled>
</div>
</div>
</td> </td>
</th:block> </th:block>
</th:block> </th:block>
@ -183,7 +216,7 @@
</nav> </nav>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<input type="button" class="btn btn-warning" value="결재" id="addAffairBtn" th:if="${page eq 'stay' and apprvAuth ne null}"> <input type="button" class="btn btn-warning" value="결재" id="tableApprvBtn" th:if="${page eq 'stay' and apprvAuth ne null}" th:data-apprvauth="${apprvAuth}">
</div> </div>
</div> </div>
</div> </div>

View File

@ -142,7 +142,6 @@
<th:block th:each="rate:${affair.rateList}"> <th:block th:each="rate:${affair.rateList}">
<div class="row py-1"> <div class="row py-1">
<div class="col-auto"> <div class="col-auto">
<input type="hidden" class="ratingOrganCd" th:value="${rate.ratingOrgan}">
<th:block th:each="commonCode:${session.commonCode.get('OG')}"> <th:block th:each="commonCode:${session.commonCode.get('OG')}">
<p th:if="${commonCode.itemCd eq rate.ratingOrgan}" th:text="${commonCode.itemValue}"></p> <p th:if="${commonCode.itemCd eq rate.ratingOrgan}" th:text="${commonCode.itemValue}"></p>
</th:block> </th:block>
@ -164,7 +163,7 @@
<span th:text="|결재일시: ${#temporals.format(rate.sectionApprvDt, 'yyyy-MM-dd HH:mm:ss')}|"></span> <span th:text="|결재일시: ${#temporals.format(rate.sectionApprvDt, 'yyyy-MM-dd HH:mm:ss')}|"></span>
</div> </div>
<div class="col-12"> <div class="col-12">
<span th:text="|기타의견: ${rate.sectionEtc}|"></span> <span th:text="|기타의견: ${rate.sectionEtc eq null?'':rate.sectionEtc}|"></span>
</div> </div>
</div> </div>
<div class="row" th:if="${rate.headApprv ne null}"> <div class="row" th:if="${rate.headApprv ne null}">
@ -185,7 +184,7 @@
<span th:text="|결재일시: ${#temporals.format(rate.headApprvDt, 'yyyy-MM-dd HH:mm:ss')}|"></span> <span th:text="|결재일시: ${#temporals.format(rate.headApprvDt, 'yyyy-MM-dd HH:mm:ss')}|"></span>
</div> </div>
<div class="col-12"> <div class="col-12">
<span th:text="|기타의견: ${rate.headEtc}|"></span> <span th:text="|기타의견: ${rate.headEtc eq null?'':rate.headEtc}|"></span>
</div> </div>
</div> </div>
</div> </div>
@ -196,12 +195,11 @@
<div class="col-12" th:if="${apprvAuth ne null}"> <div class="col-12" th:if="${apprvAuth ne null}">
<form action="#" method="post" id="apprvForm"> <form action="#" method="post" id="apprvForm">
<input type="hidden" name="affairKey" th:value="${affair.affairKey}"> <input type="hidden" name="affairKey" th:value="${affair.affairKey}">
<input type="hidden" name="ratingOrgan" id="apprvFormRatingOrgan">
<th:block th:if="${(apprvAuth eq 'APC003' or apprvAuth eq 'APC004') and affair.affairStatus eq 'DST002'}"> <th:block th:if="${(apprvAuth eq 'APC003' or apprvAuth eq 'APC004') and affair.affairStatus eq 'DST002'}">
<input type="hidden" name="sectionApprv" id="sectionApprv"> <input type="hidden" name="sectionApprv" id="sectionApprv">
<div class="row"> <div class="row">
<div class="col-10"> <div class="col-10">
<input type="text" class="form-control form-control-sm" name="sectionEtc" placeholder="추가의견, 반려사유 기입"> <input type="text" class="form-control form-control-sm etc" name="sectionEtc" placeholder="추가의견, 반려사유 기입">
<input type="text" class="d-none" id="submitPrevention"> <input type="text" class="d-none" id="submitPrevention">
</div> </div>
<div class="col-auto"> <div class="col-auto">
@ -216,7 +214,7 @@
<input type="hidden" name="headApprv" id="headApprv"> <input type="hidden" name="headApprv" id="headApprv">
<div class="row"> <div class="row">
<div class="col-8"> <div class="col-8">
<input type="text" class="form-control form-control-sm" name="headEtc" placeholder="추가의견, 반려사유 기입"> <input type="text" class="form-control form-control-sm etc" name="headEtc" placeholder="추가의견, 반려사유 기입">
<input type="text" class="d-none" id="submitPrevention"> <input type="text" class="d-none" id="submitPrevention">
</div> </div>
<div class="col-auto"> <div class="col-auto">
@ -227,7 +225,7 @@
</th:block> </th:block>
</select> </select>
</div> </div>
<div class="col-auto"> <div class="col-auto" th:unless="${userOrgan eq 'OG001'}">
<label for="organUp" class="form-check-label">상보여부</label> <label for="organUp" class="form-check-label">상보여부</label>
<input type="checkbox" id="organUp" name="organUp" value="T"> <input type="checkbox" id="organUp" name="organUp" value="T">
</div> </div>